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