Changeset df6ded8 in mainline for uspace/drv/bus/usb/uhci/main.c
- Timestamp:
- 2018-02-28T16:37:50Z (7 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/uhci/main.c
rf5e5f73 rdf6ded8 1 1 /* 2 2 * Copyright (c) 2011 Vojtech Horky, Jan Vesely 3 * Copyright (c) 2018 Ondrej Hlavaty, Petr Manek 3 4 * All rights reserved. 4 5 * … … 43 44 #include <str_error.h> 44 45 #include <usb/debug.h> 45 #include <usb/host/ ddf_helpers.h>46 #include <usb/host/utility.h> 46 47 47 48 #include "hc.h" … … 49 50 #define NAME "uhci" 50 51 51 static errno_t uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool); 52 static void uhci_driver_fini(hcd_t *); 53 static errno_t disable_legacy(ddf_dev_t *); 52 static errno_t disable_legacy(hc_device_t *); 54 53 55 static const ddf_hc_driver_t uhci_hc_driver = { 56 .claim = disable_legacy, 57 .hc_speed = USB_SPEED_FULL, 58 .irq_code_gen = uhci_hc_gen_irq_code, 59 .init = uhci_driver_init, 60 .fini = uhci_driver_fini, 61 .name = "UHCI", 62 .ops = { 63 .schedule = uhci_hc_schedule, 64 .irq_hook = uhci_hc_interrupt, 65 .status_hook = uhci_hc_status, 66 }, 54 static const hc_driver_t uhci_driver = { 55 .name = NAME, 56 .hc_device_size = sizeof(hc_t), 57 .claim = disable_legacy, 58 .irq_code_gen = hc_gen_irq_code, 59 .hc_add = hc_add, 60 .start = hc_start, 61 .setup_root_hub = hc_setup_roothub, 62 .hc_gone = hc_gone, 67 63 }; 68 69 static errno_t uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)70 {71 assert(hcd);72 assert(hcd_get_driver_data(hcd) == NULL);73 74 hc_t *instance = malloc(sizeof(hc_t));75 if (!instance)76 return ENOMEM;77 78 const errno_t ret = hc_init(instance, res, irq);79 if (ret == EOK) {80 hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops);81 } else {82 free(instance);83 }84 return ret;85 }86 87 static void uhci_driver_fini(hcd_t *hcd)88 {89 assert(hcd);90 hc_t *hc = hcd_get_driver_data(hcd);91 if (hc)92 hc_fini(hc);93 94 hcd_set_implementation(hcd, NULL, NULL);95 free(hc);96 }97 64 98 65 /** Call the PCI driver with a request to clear legacy support register … … 101 68 * @return Error code. 102 69 */ 103 static errno_t disable_legacy( ddf_dev_t *device)70 static errno_t disable_legacy(hc_device_t *hcd) 104 71 { 105 assert( device);72 assert(hcd); 106 73 107 async_sess_t *parent_sess = ddf_dev_parent_sess_get( device);74 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev); 108 75 if (parent_sess == NULL) 109 76 return ENOMEM; … … 113 80 return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00); 114 81 } 115 116 /** Initialize a new ddf driver instance for uhci hc and hub.117 *118 * @param[in] device DDF instance of the device to initialize.119 * @return Error code.120 */121 static errno_t uhci_dev_add(ddf_dev_t *device)122 {123 usb_log_debug2("uhci_dev_add() called\n");124 assert(device);125 return hcd_ddf_add_hc(device, &uhci_hc_driver);126 }127 128 static const driver_ops_t uhci_driver_ops = {129 .dev_add = uhci_dev_add,130 };131 132 static const driver_t uhci_driver = {133 .name = NAME,134 .driver_ops = &uhci_driver_ops135 };136 137 82 138 83 /** Initialize global driver structures (NONE). … … 149 94 log_init(NAME); 150 95 logctl_set_log_level(NAME, LVL_NOTE); 151 return ddf_driver_main(&uhci_driver);96 return hc_driver_main(&uhci_driver); 152 97 } 153 98 /**
Note:
See TracChangeset
for help on using the changeset viewer.