Changes in uspace/drv/bus/usb/ehci/res.c [b7fd2a0:5a6cc679] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/res.c
rb7fd2a0 r5a6cc679 45 45 #include <pci_dev_iface.h> 46 46 47 #include "hc.h" 47 48 #include "res.h" 48 49 #include "ehci_regs.h" … … 73 74 eecp + USBLEGSUP_OFFSET, &usblegsup); 74 75 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);76 usb_log_error("Failed to read USBLEGSUP: %s.", str_error(ret)); 77 return ret; 78 } 79 usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup); 79 80 80 81 /* Request control from firmware/BIOS by writing 1 to highest 81 82 * byte. (OS Control semaphore)*/ 82 usb_log_debug("Requesting OS control. \n");83 usb_log_debug("Requesting OS control."); 83 84 ret = pci_config_space_write_8(parent_sess, 84 85 eecp + USBLEGSUP_OFFSET + 3, 1); 85 86 if (ret != EOK) { 86 usb_log_error("Failed to request OS EHCI control: %s. \n",87 usb_log_error("Failed to request OS EHCI control: %s.", 87 88 str_error(ret)); 88 89 return ret; … … 102 103 103 104 if ((usblegsup & USBLEGSUP_BIOS_CONTROL) == 0) { 104 usb_log_info("BIOS released control after %zu usec. \n", wait);105 usb_log_info("BIOS released control after %zu usec.", wait); 105 106 return EOK; 106 107 } … … 108 109 /* BIOS failed to hand over control, this should not happen. */ 109 110 usb_log_warning( "BIOS failed to release control after " 110 "%zu usecs, force it. \n", wait);111 "%zu usecs, force it.", wait); 111 112 ret = pci_config_space_write_32(parent_sess, 112 113 eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL); 113 114 if (ret != EOK) { 114 usb_log_error("Failed to force OS control: %s. \n",115 usb_log_error("Failed to force OS control: %s.", 115 116 str_error(ret)); 116 117 return ret; … … 129 130 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 130 131 if (ret != EOK) { 131 usb_log_error("Failed to get USBLEGCTLSTS: %s. \n",132 usb_log_error("Failed to get USBLEGCTLSTS: %s.", 132 133 str_error(ret)); 133 134 return ret; 134 135 } 135 usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ". \n", usblegctlsts);136 usb_log_debug2("USBLEGCTLSTS: %" PRIx32 ".", usblegctlsts); 136 137 /* 137 138 * Zero SMI enables in legacy control register. … … 142 143 eecp + USBLEGCTLSTS_OFFSET, 0xe0000000); 143 144 if (ret != EOK) { 144 usb_log_error("Failed to zero USBLEGCTLSTS: %s \n",145 usb_log_error("Failed to zero USBLEGCTLSTS: %s", 145 146 str_error(ret)); 146 147 return ret; … … 152 153 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 153 154 if (ret != EOK) { 154 usb_log_error("Failed to get USBLEGCTLSTS 2: %s. \n",155 usb_log_error("Failed to get USBLEGCTLSTS 2: %s.", 155 156 str_error(ret)); 156 157 return ret; 157 158 } 158 usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ". \n",159 usb_log_debug2("Zeroed USBLEGCTLSTS: %" PRIx32 ".", 159 160 usblegctlsts); 160 161 } … … 164 165 eecp + USBLEGSUP_OFFSET, &usblegsup); 165 166 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);167 usb_log_error("Failed to read USBLEGSUP: %s.", 168 str_error(ret)); 169 return ret; 170 } 171 usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup); 171 172 return ret; 172 173 } 173 174 174 errno_t disable_legacy( ddf_dev_t *device)175 errno_t disable_legacy(hc_device_t *hcd) 175 176 { 176 assert(device);177 178 async_sess_t *parent_sess = ddf_dev_parent_sess_get( device);177 hc_t *hc = hcd_to_hc(hcd); 178 179 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev); 179 180 if (parent_sess == NULL) 180 181 return ENOMEM; 181 182 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); 183 usb_log_debug("Disabling EHCI legacy support."); 184 185 const uint32_t hcc_params = EHCI_RD(hc->caps->hccparams); 186 usb_log_debug2("Value of hcc params register: %x.", hcc_params); 215 187 216 188 /* Read value of EHCI Extended Capabilities Pointer … … 218 190 const uint32_t eecp = 219 191 (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",192 usb_log_debug2("Value of EECP: %x.", eecp); 193 194 int ret = disable_extended_caps(parent_sess, eecp); 195 if (ret != EOK) { 196 usb_log_error("Failed to disable extended capabilities: %s.", 225 197 str_error(ret)); 226 198 goto clean; 227 199 } 228 200 clean: 229 //TODO unmap registers 230 hw_res_list_parsed_clean(&res); 201 async_hangup(parent_sess); 231 202 return ret; 232 203 }
Note:
See TracChangeset
for help on using the changeset viewer.