Changeset 2c617b0 in mainline
- Timestamp:
- 2011-04-02T18:39:07Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c2be0e5
- Parents:
- 4d946647
- Location:
- uspace/drv/ohci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/hc.c
r4d946647 r2c617b0 45 45 46 46 static int interrupt_emulator(hc_t *instance); 47 static void hc_gain_control(hc_t *instance); 48 static void hc_init_hw(hc_t *instance); 47 49 /*----------------------------------------------------------------------------*/ 48 50 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun) … … 92 94 } 93 95 96 hc_gain_control(instance); 97 94 98 rh_init(&instance->rh, dev, instance->registers); 99 100 hc_init_hw(instance); 95 101 96 102 /* TODO: implement */ … … 117 123 rh_interrupt(&instance->rh); 118 124 125 usb_log_info("OHCI interrupt: %x.\n", status); 126 119 127 /* TODO: Check for further interrupt causes */ 120 128 /* TODO: implement */ … … 126 134 usb_log_info("Started interrupt emulator.\n"); 127 135 while (1) { 128 uint32_t status = instance->registers->interrupt_status;136 const uint32_t status = instance->registers->interrupt_status; 129 137 instance->registers->interrupt_status = status; 130 138 hc_interrupt(instance, status); … … 133 141 return EOK; 134 142 } 143 /*----------------------------------------------------------------------------*/ 144 void hc_gain_control(hc_t *instance) 145 { 146 assert(instance); 147 /* Interrupt routing enabled => smm driver is active */ 148 if (instance->registers->control & C_IR) { 149 usb_log_info("Found SMM driver requesting ownership change.\n"); 150 instance->registers->command_status |= CS_OCR; 151 while (instance->registers->control & C_IR) { 152 async_usleep(1000); 153 } 154 usb_log_info("Ownership taken from SMM driver.\n"); 155 return; 156 } 157 158 const unsigned hc_status = 159 (instance->registers->control >> C_HCFS_SHIFT) & C_HCFS_MASK; 160 /* Interrupt routing disabled && status != USB_RESET => BIOS active */ 161 if (hc_status != C_HCFS_RESET) { 162 usb_log_info("Found BIOS driver.\n"); 163 if (hc_status == C_HCFS_OPERATIONAL) { 164 usb_log_info("HC operational(BIOS).\n"); 165 return; 166 } 167 /* HC is suspended assert resume for 20ms */ 168 instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT); 169 async_usleep(20000); 170 return; 171 } 172 173 /* HC is in reset (hw startup) => no other driver 174 * maintain reset for at least the time specified in USB spec (50 ms)*/ 175 async_usleep(50000); 176 } 177 /*----------------------------------------------------------------------------*/ 178 void hc_init_hw(hc_t *instance) 179 { 180 assert(instance); 181 const uint32_t fm_interval = instance->registers->fm_interval; 182 instance->registers->command_status = CS_HCR; 183 async_usleep(10); 184 instance->registers->fm_interval = fm_interval; 185 assert((instance->registers->command_status & CS_HCR) == 0); 186 /* hc is now in suspend state */ 187 188 instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT); 189 usb_log_info("OHCI HC up and running.\n"); 190 } 135 191 /** 136 192 * @} -
uspace/drv/ohci/ohci_regs.h
r4d946647 r2c617b0 39 39 typedef struct ohci_regs 40 40 { 41 volatile uint32_t revision;41 const volatile uint32_t revision; 42 42 volatile uint32_t control; 43 #define C_CSBR_MASK (0x3) 44 #define C_CSBR_SHIFT (0) 45 #define C_PLE (1 << 2) 46 #define C_IE (1 << 3) 47 #define C_CLE (1 << 4) 48 #define C_BLE (1 << 5) 49 50 #define C_HCFS_MASK (0x3) 51 #define C_HCFS_SHIFT (6) 52 #define C_HCFS_RESET (0x0) 53 #define C_HCFS_OPERATIONAL (0x1) 54 #define C_HCFS_RESUME (0x2) 55 #define C_HCFS_SUSPEND (0x3) 56 57 #define C_IR (1 << 8) 58 #define C_RWC (1 << 9) 59 #define C_RWE (1 << 10) 60 43 61 volatile uint32_t command_status; 62 #define CS_HCR (1 << 0) 63 #define CS_CLF (1 << 1) 64 #define CS_BLF (1 << 2) 65 #define CS_OCR (1 << 3) 66 #define CS_SOC_MASK (0x3) 67 #define CS_SOC_SHIFT (16) 68 44 69 volatile uint32_t interrupt_status; 45 70 #define IS_SO (1 << 0) … … 51 76 #define IS_RHSC (1 << 6) 52 77 #define IS_OC (1 << 30) 78 53 79 volatile uint32_t interupt_enable; 54 80 #define IE_SO (1 << 0) -
uspace/drv/ohci/root_hub.c
r4d946647 r2c617b0 252 252 253 253 254 usb_log_info("OHCI root hub with %d ports.\n", regs->rh_desc_a & 0xff);254 usb_log_info("OHCI root hub with %d ports.\n", instance->port_count); 255 255 256 256 //start generic usb hub driver
Note:
See TracChangeset
for help on using the changeset viewer.