Changes in uspace/drv/bus/usb/uhci/main.c [920d0fc:58563585] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/main.c
r920d0fc r58563585 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 /** @addtogroup drvusbuhcihc 28 29 /** @addtogroup drvusbuhci 29 30 * @{ 30 31 */ … … 32 33 * @brief UHCI driver initialization 33 34 */ 35 36 #include <assert.h> 34 37 #include <ddf/driver.h> 38 #include <devman.h> 35 39 #include <errno.h> 40 #include <io/log.h> 41 #include <io/logctl.h> 42 #include <pci_dev_iface.h> 43 #include <stdio.h> 36 44 #include <str_error.h> 45 #include <usb/debug.h> 46 #include <usb/host/ddf_helpers.h> 37 47 38 #include <usb/ddfiface.h> 39 #include <usb/debug.h> 40 41 #include "uhci.h" 48 #include "hc.h" 42 49 43 50 #define NAME "uhci" 44 51 45 static int uhci_dev_add(ddf_dev_t *device); 52 static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 53 static void uhci_driver_fini(hcd_t *); 54 static int disable_legacy(ddf_dev_t *); 46 55 47 static driver_ops_t uhci_driver_ops = { 48 .dev_add = uhci_dev_add, 56 static const ddf_hc_driver_t uhci_hc_driver = { 57 .claim = disable_legacy, 58 .hc_speed = USB_SPEED_FULL, 59 .irq_code_gen = uhci_hc_gen_irq_code, 60 .init = uhci_driver_init, 61 .fini = uhci_driver_fini, 62 .name = "UHCI", 63 .ops = { 64 .schedule = uhci_hc_schedule, 65 .irq_hook = uhci_hc_interrupt, 66 .status_hook = uhci_hc_status, 67 }, 49 68 }; 50 69 51 static driver_t uhci_driver = { 52 .name = NAME, 53 .driver_ops = &uhci_driver_ops 54 }; 70 static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq) 71 { 72 assert(hcd); 73 assert(hcd_get_driver_data(hcd) == NULL); 74 75 hc_t *instance = malloc(sizeof(hc_t)); 76 if (!instance) 77 return ENOMEM; 78 79 const int ret = hc_init(instance, res, irq); 80 if (ret == EOK) { 81 hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops); 82 } else { 83 free(instance); 84 } 85 return ret; 86 } 87 88 static void uhci_driver_fini(hcd_t *hcd) 89 { 90 assert(hcd); 91 hc_t *hc = hcd_get_driver_data(hcd); 92 if (hc) 93 hc_fini(hc); 94 95 hcd_set_implementation(hcd, NULL, NULL); 96 free(hc); 97 } 98 99 /** Call the PCI driver with a request to clear legacy support register 100 * 101 * @param[in] device Device asking to disable interrupts 102 * @return Error code. 103 */ 104 static int disable_legacy(ddf_dev_t *device) 105 { 106 assert(device); 107 108 async_sess_t *parent_sess = devman_parent_device_connect( 109 ddf_dev_get_handle(device), IPC_FLAG_BLOCKING); 110 if (!parent_sess) 111 return ENOMEM; 112 113 /* See UHCI design guide page 45 for these values. 114 * Write all WC bits in USB legacy register */ 115 const int rc = pci_config_space_write_16(parent_sess, 0xc0, 0xaf00); 116 117 async_hangup(parent_sess); 118 return rc; 119 } 55 120 56 121 /** Initialize a new ddf driver instance for uhci hc and hub. … … 59 124 * @return Error code. 60 125 */ 61 int uhci_dev_add(ddf_dev_t *device)126 static int uhci_dev_add(ddf_dev_t *device) 62 127 { 63 128 usb_log_debug2("uhci_dev_add() called\n"); 64 129 assert(device); 130 return hcd_ddf_add_hc(device, &uhci_hc_driver); 131 } 65 132 66 const int ret = device_setup_uhci(device); 67 if (ret != EOK) { 68 usb_log_error("Failed to initialize UHCI driver: %s.\n", 69 str_error(ret)); 70 } else { 71 usb_log_info("Controlling new UHCI device '%s'.\n", 72 ddf_dev_get_name(device)); 73 } 133 static const driver_ops_t uhci_driver_ops = { 134 .dev_add = uhci_dev_add, 135 }; 74 136 75 return ret; 76 } 137 static const driver_t uhci_driver = { 138 .name = NAME, 139 .driver_ops = &uhci_driver_ops 140 }; 141 77 142 78 143 /** Initialize global driver structures (NONE). … … 88 153 printf(NAME ": HelenOS UHCI driver.\n"); 89 154 log_init(NAME); 90 155 logctl_set_log_level(NAME, LVL_NOTE); 91 156 return ddf_driver_main(&uhci_driver); 92 157 }
Note:
See TracChangeset
for help on using the changeset viewer.