Changeset bab71635 in mainline
- Timestamp:
- 2011-03-21T11:13:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b0beee82
- Parents:
- c15070c
- Location:
- uspace/drv/ohci
- Files:
-
- 3 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/ohci/Makefile
rc15070c rbab71635 33 33 34 34 SOURCES = \ 35 hc_iface.c \35 iface.c \ 36 36 batch.c \ 37 37 main.c \ 38 ohci_hc.c \39 ohci_rh.c \38 hc.c \ 39 root_hub.c \ 40 40 pci.c 41 41 -
uspace/drv/ohci/hc.c
rc15070c rbab71635 42 42 #include <usb_iface.h> 43 43 44 #include " ohci_hc.h"44 #include "hc.h" 45 45 46 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,46 int hc_init(hc_t *instance, ddf_fun_t *fun, 47 47 uintptr_t regs, size_t reg_size, bool interrupts) 48 48 { … … 53 53 return ret; 54 54 } 55 instance->registers->interrupt_disable = 0; 56 /* enable interrupt on root hub status change */ 57 instance->registers->interupt_enable |= IE_RHSC | IE_MIE; 55 device_keeper_init(&instance->manager); 58 56 59 57 60 ohci_rh_init(&instance->rh, instance->registers);58 rh_init(&instance->rh, instance->registers); 61 59 /* TODO: implement */ 62 60 /* TODO: register root hub */ … … 64 62 } 65 63 /*----------------------------------------------------------------------------*/ 66 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch)64 int hc_schedule(hc_t *instance, batch_t *batch) 67 65 { 68 66 assert(instance); 69 67 assert(batch); 70 68 if (batch->target.address == instance->rh.address) { 71 ohci_rh_request(&instance->rh, batch);69 rh_request(&instance->rh, batch); 72 70 return EOK; 73 71 } … … 76 74 } 77 75 /*----------------------------------------------------------------------------*/ 78 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status)76 void hc_interrupt(hc_t *instance, uint16_t status) 79 77 { 80 78 assert(instance); 81 79 /* TODO: Check for interrupt cause */ 82 ohci_rh_interrupt(&instance->rh);80 rh_interrupt(&instance->rh); 83 81 /* TODO: implement */ 84 82 } -
uspace/drv/ohci/hc.h
rc15070c rbab71635 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 29 /** @addtogroup drvusbohcihc 28 /** @addtogroup drvusbohci 30 29 * @{ 31 30 */ … … 33 32 * @brief OHCI host controller driver structure 34 33 */ 35 #ifndef DRV_OHCI_ OHCI_HC_H36 #define DRV_OHCI_ OHCI_HC_H34 #ifndef DRV_OHCI_HC_H 35 #define DRV_OHCI_HC_H 37 36 38 37 #include <fibril.h> … … 42 41 43 42 #include <usb/usb.h> 43 #include <usb/host/device_keeper.h> 44 44 #include <usbhc_iface.h> 45 45 46 46 #include "batch.h" 47 47 #include "ohci_regs.h" 48 #include " ohci_rh.h"48 #include "root_hub.h" 49 49 50 typedef struct ohci_hc {50 typedef struct hc { 51 51 ohci_regs_t *registers; 52 52 usb_address_t rh_address; 53 53 ohci_rh_t rh; 54 54 ddf_fun_t *ddf_instance; 55 } ohci_hc_t; 55 device_keeper_t manager; 56 } hc_t; 56 57 57 int ohci_hc_init(ohci_hc_t *instance, ddf_fun_t *fun,58 int hc_init(hc_t *instance, ddf_fun_t *fun, 58 59 uintptr_t regs, size_t reg_size, bool interrupts); 59 60 60 int ohci_hc_schedule(ohci_hc_t *instance, batch_t *batch);61 int hc_schedule(hc_t *instance, batch_t *batch); 61 62 62 void ohci_hc_interrupt(ohci_hc_t *instance, uint16_t status);63 void hc_interrupt(hc_t *instance, uint16_t status); 63 64 64 65 /** Safely dispose host controller internal structures … … 66 67 * @param[in] instance Host controller structure to use. 67 68 */ 68 static inline void ohci_hc_fini(ohci_hc_t *instance) { /* TODO: implement*/ };69 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ }; 69 70 70 71 /** Get and cast pointer to the driver data … … 73 74 * @return cast pointer to driver_data 74 75 */ 75 static inline ohci_hc_t * fun_to_ohci_hc(ddf_fun_t *fun)76 { return ( ohci_hc_t*)fun->driver_data; }76 static inline hc_t * fun_to_hc(ddf_fun_t *fun) 77 { return (hc_t*)fun->driver_data; } 77 78 #endif 78 79 /** -
uspace/drv/ohci/iface.c
rc15070c rbab71635 43 43 44 44 #include "iface.h" 45 #include "hc.h" 45 46 46 47 #define UNSUPPORTED(methodname) \ … … 59 60 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 60 61 { 61 UNSUPPORTED("reserve_default_address"); 62 63 return ENOTSUP; 62 assert(fun); 63 hc_t *hc = fun_to_hc(fun); 64 assert(hc); 65 usb_log_debug("Default address request with speed %d.\n", speed); 66 device_keeper_reserve_default(&hc->manager, speed); 67 return EOK; 64 68 } 65 69 … … 323 327 324 328 /** Host controller interface implementation for OHCI. */ 325 usbhc_iface_t ohci_hc_iface = {329 usbhc_iface_t hc_iface = { 326 330 .reserve_default_address = reserve_default_address, 327 331 .release_default_address = release_default_address, -
uspace/drv/ohci/iface.h
rc15070c rbab71635 40 40 #define NAME "ohci" 41 41 42 extern usbhc_iface_t ohci_hc_iface;42 extern usbhc_iface_t hc_iface; 43 43 44 44 #endif -
uspace/drv/ohci/main.c
rc15070c rbab71635 45 45 #include "pci.h" 46 46 #include "iface.h" 47 #include " ohci_hc.h"47 #include "hc.h" 48 48 49 49 static int ohci_add_device(ddf_dev_t *device); … … 58 58 { 59 59 assert(dev); 60 ohci_hc_t *hc = (ohci_hc_t*)dev->driver_data;60 hc_t *hc = (hc_t*)dev->driver_data; 61 61 assert(hc); 62 ohci_hc_interrupt(hc, 0);62 hc_interrupt(hc, 0); 63 63 } 64 64 /*----------------------------------------------------------------------------*/ … … 72 72 }; 73 73 static ddf_dev_ops_t hc_ops = { 74 .interfaces[USBHC_DEV_IFACE] = & ohci_hc_iface,74 .interfaces[USBHC_DEV_IFACE] = &hc_iface, 75 75 }; 76 76 … … 105 105 "Failed(%d) disable legacy USB: %s.\n", ret, str_error(ret)); 106 106 107 ohci_hc_t *hcd = malloc(sizeof(ohci_hc_t));107 hc_t *hcd = malloc(sizeof(hc_t)); 108 108 if (hcd == NULL) { 109 109 usb_log_error("Failed to allocate OHCI driver.\n"); … … 129 129 } 130 130 131 ret = ohci_hc_init(hcd, hc_fun, mem_reg_base, mem_reg_size, interrupts);131 ret = hc_init(hcd, hc_fun, mem_reg_base, mem_reg_size, interrupts); 132 132 if (ret != EOK) { 133 133 usb_log_error("Failed to initialize OHCI driver.\n"); -
uspace/drv/ohci/root_hub.c
rc15070c rbab71635 38 38 #include <usb/debug.h> 39 39 40 #include " ohci_rh.h"40 #include "root_hub.h" 41 41 42 42 /** Root hub initialization 43 43 * @return Error code. 44 44 */ 45 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs)45 int rh_init(ohci_rh_t *instance, ohci_regs_t *regs) 46 46 { 47 47 assert(instance); … … 55 55 } 56 56 /*----------------------------------------------------------------------------*/ 57 void ohci_rh_request(ohci_rh_t *instance, batch_t *request)57 void rh_request(ohci_rh_t *instance, batch_t *request) 58 58 { 59 59 /* TODO: implement */ 60 60 } 61 61 /*----------------------------------------------------------------------------*/ 62 void ohci_rh_interrupt(ohci_rh_t *instance)62 void rh_interrupt(ohci_rh_t *instance) 63 63 { 64 64 usb_log_info("Interrupt!!.\n"); -
uspace/drv/ohci/root_hub.h
rc15070c rbab71635 33 33 * @brief OHCI driver 34 34 */ 35 #ifndef DRV_OHCI_ OHCI_RH_H36 #define DRV_OHCI_ OHCI_RH_H35 #ifndef DRV_OHCI_ROOT_HUB_H 36 #define DRV_OHCI_ROOT_HUB_H 37 37 38 38 #include <usb/usb.h> … … 46 46 } ohci_rh_t; 47 47 48 int ohci_rh_init(ohci_rh_t *instance, ohci_regs_t *regs);48 int rh_init(ohci_rh_t *instance, ohci_regs_t *regs); 49 49 50 void ohci_rh_request(ohci_rh_t *instance, batch_t *request);50 void rh_request(ohci_rh_t *instance, batch_t *request); 51 51 52 void ohci_rh_interrupt(ohci_rh_t *instance);52 void rh_interrupt(ohci_rh_t *instance); 53 53 #endif 54 54 /**
Note:
See TracChangeset
for help on using the changeset viewer.