Changeset df6ded8 in mainline for uspace/drv/bus/usb/ehci/res.c
- Timestamp:
- 2018-02-28T16:37:50Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b20da0
- Parents:
- f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
- git-committer:
- Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/res.c
rf5e5f73 rdf6ded8 1 1 /* 2 2 * Copyright (c) 2011 Jan Vesely 3 * Copyright (c) 2018 Ondrej Hlavaty 3 4 * All rights reserved. 4 5 * … … 45 46 #include <pci_dev_iface.h> 46 47 48 #include "hc.h" 47 49 #include "res.h" 48 50 #include "ehci_regs.h" … … 73 75 eecp + USBLEGSUP_OFFSET, &usblegsup); 74 76 if (ret != EOK) { 75 usb_log_error("Failed to read USBLEGSUP: %s. \n", str_error(ret));76 return ret; 77 } 78 usb_log_debug2("USBLEGSUP: %" PRIx32 ". \n", usblegsup);77 usb_log_error("Failed to read USBLEGSUP: %s.", str_error(ret)); 78 return ret; 79 } 80 usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup); 79 81 80 82 /* Request control from firmware/BIOS by writing 1 to highest 81 83 * byte. (OS Control semaphore)*/ 82 usb_log_debug("Requesting OS control. \n");84 usb_log_debug("Requesting OS control."); 83 85 ret = pci_config_space_write_8(parent_sess, 84 86 eecp + USBLEGSUP_OFFSET + 3, 1); 85 87 if (ret != EOK) { 86 usb_log_error("Failed to request OS EHCI control: %s. \n",88 usb_log_error("Failed to request OS EHCI control: %s.", 87 89 str_error(ret)); 88 90 return ret; … … 102 104 103 105 if ((usblegsup & USBLEGSUP_BIOS_CONTROL) == 0) { 104 usb_log_info("BIOS released control after %zu usec. \n", wait);106 usb_log_info("BIOS released control after %zu usec.", wait); 105 107 return EOK; 106 108 } … … 108 110 /* BIOS failed to hand over control, this should not happen. */ 109 111 usb_log_warning( "BIOS failed to release control after " 110 "%zu usecs, force it. \n", wait);112 "%zu usecs, force it.", wait); 111 113 ret = pci_config_space_write_32(parent_sess, 112 114 eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL); 113 115 if (ret != EOK) { 114 usb_log_error("Failed to force OS control: %s. \n",116 usb_log_error("Failed to force OS control: %s.", 115 117 str_error(ret)); 116 118 return ret; … … 129 131 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 130 132 if (ret != EOK) { 131 usb_log_error("Failed to get USBLEGCTLSTS: %s. \n",133 usb_log_error("Failed to get USBLEGCTLSTS: %s.", 132 134 str_error(ret)); 133 135 return ret; 134 136 } 135 usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ". \n", usblegctlsts);137 usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ".", usblegctlsts); 136 138 /* 137 139 * Zero SMI enables in legacy control register. … … 142 144 eecp + USBLEGCTLSTS_OFFSET, 0xe0000000); 143 145 if (ret != EOK) { 144 usb_log_error("Failed to zero USBLEGCTLSTS: %s \n",146 usb_log_error("Failed to zero USBLEGCTLSTS: %s", 145 147 str_error(ret)); 146 148 return ret; … … 152 154 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 153 155 if (ret != EOK) { 154 usb_log_error("Failed to get USBLEGCTLSTS 2: %s. \n",156 usb_log_error("Failed to get USBLEGCTLSTS 2: %s.", 155 157 str_error(ret)); 156 158 return ret; 157 159 } 158 usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ". \n",160 usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ".", 159 161 usblegctlsts); 160 162 } … … 164 166 eecp + USBLEGSUP_OFFSET, &usblegsup); 165 167 if (ret != EOK) { 166 usb_log_error("Failed to read USBLEGSUP: %s. \n",167 str_error(ret)); 168 return ret; 169 } 170 usb_log_debug2("USBLEGSUP: %" PRIx32 ". \n", usblegsup);168 usb_log_error("Failed to read USBLEGSUP: %s.", 169 str_error(ret)); 170 return ret; 171 } 172 usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup); 171 173 return ret; 172 174 } 173 175 174 errno_t disable_legacy( ddf_dev_t *device)176 errno_t disable_legacy(hc_device_t *hcd) 175 177 { 176 assert(device);177 178 async_sess_t *parent_sess = ddf_dev_parent_sess_get( device);178 hc_t *hc = hcd_to_hc(hcd); 179 180 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev); 179 181 if (parent_sess == NULL) 180 182 return ENOMEM; 181 183 182 usb_log_debug("Disabling EHCI legacy support.\n"); 183 184 hw_res_list_parsed_t res; 185 hw_res_list_parsed_init(&res); 186 errno_t ret = hw_res_get_list_parsed(parent_sess, &res, 0); 187 if (ret != EOK) { 188 usb_log_error("Failed to get resource list: %s\n", 189 str_error(ret)); 190 goto clean; 191 } 192 193 if (res.mem_ranges.count < 1) { 194 usb_log_error("Incorrect mem range count: %zu", 195 res.mem_ranges.count); 196 ret = EINVAL; 197 goto clean; 198 } 199 200 /* Map EHCI registers */ 201 void *regs = NULL; 202 ret = pio_enable_range(&res.mem_ranges.ranges[0], ®s); 203 if (ret != EOK) { 204 usb_log_error("Failed to map registers %p: %s.\n", 205 RNGABSPTR(res.mem_ranges.ranges[0]), str_error(ret)); 206 goto clean; 207 } 208 209 usb_log_debug("Registers mapped at: %p.\n", regs); 210 211 ehci_caps_regs_t *ehci_caps = regs; 212 213 const uint32_t hcc_params = EHCI_RD(ehci_caps->hccparams); 214 usb_log_debug2("Value of hcc params register: %x.\n", hcc_params); 184 usb_log_debug("Disabling EHCI legacy support."); 185 186 const uint32_t hcc_params = EHCI_RD(hc->caps->hccparams); 187 usb_log_debug2("Value of hcc params register: %x.", hcc_params); 215 188 216 189 /* Read value of EHCI Extended Capabilities Pointer … … 218 191 const uint32_t eecp = 219 192 (hcc_params >> EHCI_CAPS_HCC_EECP_SHIFT) & EHCI_CAPS_HCC_EECP_MASK; 220 usb_log_debug2("Value of EECP: %x. \n", eecp);221 222 ret = disable_extended_caps(parent_sess, eecp);223 if (ret != EOK) { 224 usb_log_error("Failed to disable extended capabilities: %s. \n",193 usb_log_debug2("Value of EECP: %x.", eecp); 194 195 int ret = disable_extended_caps(parent_sess, eecp); 196 if (ret != EOK) { 197 usb_log_error("Failed to disable extended capabilities: %s.", 225 198 str_error(ret)); 226 199 goto clean; 227 200 } 228 201 clean: 229 //TODO unmap registers 230 hw_res_list_parsed_clean(&res); 202 async_hangup(parent_sess); 231 203 return ret; 232 204 }
Note:
See TracChangeset
for help on using the changeset viewer.