Changeset 063ae706 in mainline
- Timestamp:
- 2012-04-05T05:27:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb8dcb4
- Parents:
- 712a10b
- Location:
- uspace/drv/infrastructure/rootamdm37x
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
r712a10b r063ae706 43 43 #include <ddi.h> 44 44 45 #include "uhh.h" 46 #include "usbtll.h" 47 45 48 #define NAME "rootamdm37x" 46 49 47 50 /** Obtain function soft-state from DDF function node */ 48 #define ROOT MAC_FUN(fnode) \51 #define ROOTARM_FUN(fnode) \ 49 52 ((rootamdm37x_fun_t *) (fnode)->driver_data) 50 53 … … 53 56 } rootamdm37x_fun_t; 54 57 58 #define OHCI_BASE_ADDRESS 0x48064400 59 #define OHCI_SIZE 1024 60 #define EHCI_BASE_ADDRESS 0x48064800 61 #define EHCI_SIZE 1024 62 55 63 static hw_resource_t ohci_res[] = { 56 64 { … … 58 66 /* See amdm37x TRM page. 3316 for these values */ 59 67 .res.io_range = { 60 .address = 0x48064400,61 .size = 1024,68 .address = OHCI_BASE_ADDRESS, 69 .size = OHCI_SIZE, 62 70 .endianness = LITTLE_ENDIAN 63 71 }, … … 66 74 .type = INTERRUPT, 67 75 .res.interrupt = { .irq = 76 }, 68 },69 };70 71 static hw_resource_t ehci_res[] = {72 {73 .type = MEM_RANGE,74 /* See amdm37x TRM page. 3316 for these values */75 .res.io_range = {76 .address = 0x48064800,77 .size = 1024,78 .endianness = LITTLE_ENDIAN79 },80 },81 {82 .type = INTERRUPT,83 .res.interrupt = { .irq = 77 },84 76 }, 85 77 }; … … 92 84 }; 93 85 86 static hw_resource_t ehci_res[] = { 87 { 88 .type = MEM_RANGE, 89 /* See amdm37x TRM page. 3316 for these values */ 90 .res.io_range = { 91 .address = EHCI_BASE_ADDRESS, 92 .size = EHCI_SIZE, 93 .endianness = LITTLE_ENDIAN 94 }, 95 }, 96 { 97 .type = INTERRUPT, 98 .res.interrupt = { .irq = 77 }, 99 }, 100 }; 101 94 102 static const rootamdm37x_fun_t ehci = { 95 103 .hw_resources = { … … 99 107 }; 100 108 101 102 static ddf_dev_ops_t rootamdm37x_fun_ops; 109 static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode); 110 static bool rootamdm37x_enable_interrupt(ddf_fun_t *fun); 111 112 static hw_res_ops_t fun_hw_res_ops = { 113 .get_resource_list = &rootamdm37x_get_resources, 114 .enable_interrupt = &rootamdm37x_enable_interrupt, 115 }; 116 117 static ddf_dev_ops_t rootamdm37x_fun_ops = 118 { 119 .interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops 120 }; 121 122 static int usb_clocks(bool on) 123 { 124 uint32_t *usb_host_cm = NULL; 125 uint32_t *l4_core_cm = NULL; 126 127 int ret = pio_enable((void*)0x48005400, 8192, (void**)&usb_host_cm); 128 if (ret != EOK) 129 return ret; 130 131 ret = pio_enable((void*)0x48004a00, 8192, (void**)&l4_core_cm); 132 if (ret != EOK) 133 return ret; 134 135 assert(l4_core_cm); 136 assert(usb_host_cm); 137 if (on) { 138 l4_core_cm[0xe] |= 0x4; /* iclk */ 139 l4_core_cm[0x3] |= 0x4; /* fclk */ 140 141 /* offset 0x10 (0x4 int32)[0] enables fclk, 142 * offset 0x00 (0x0 int32)[0 and 1] enables iclk, 143 * offset 0x30 (0xc int32)[0] enables autoidle 144 */ 145 usb_host_cm[0x4] = 0x1; 146 usb_host_cm[0x0] = 0x3; 147 usb_host_cm[0xc] = 0x1; 148 } else { 149 usb_host_cm[0xc] = 0; 150 usb_host_cm[0x0] = 0; 151 usb_host_cm[0x4] = 0; 152 l4_core_cm[0xe] &= ~0x4; 153 l4_core_cm[0x3] &= ~0x4; 154 } 155 156 return ret; 157 } 158 159 static int usb_tll_init() 160 { 161 return EOK; 162 } 103 163 104 164 static bool rootamdm37x_add_fun(ddf_dev_t *dev, const char *name, … … 151 211 } 152 212 153 /** Getthe root device.213 /** Add the root device. 154 214 * 155 215 * @param dev Device which is root of the whole device tree … … 161 221 static int rootamdm37x_dev_add(ddf_dev_t *dev) 162 222 { 163 { 164 /* Enable USB host clocks */ 165 uint32_t *reg = NULL; 166 const int ret = pio_enable((void*)0x48005400, 8192, (void**)®); 167 assert(ret == EOK); 168 assert(reg); 169 /* offset 0x10 (0x4 int32)[0] enables fclk, 170 * offset 0x00 (0x0 int32)[0 and 1] enables iclk, 171 * offset 0x30 (0xc int32)[0] enables autoidle 172 */ 173 reg[0x4] = 0x1; 174 reg[0x0] = 0x3; 175 reg[0xc] = 0x1; 223 int ret = usb_clocks(true); 224 if (ret != EOK) { 225 ddf_msg(LVL_FATAL, "Failed to enable USB HC clocks!.\n"); 226 return ret; 227 } 228 229 ret = usb_tll_init(); 230 if (ret != EOK) { 231 ddf_msg(LVL_FATAL, "Failed to init USB TLL!.\n"); 232 usb_clocks(false); 233 return ret; 176 234 } 177 235 … … 200 258 static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode) 201 259 { 202 rootamdm37x_fun_t *fun = ROOT MAC_FUN(fnode);260 rootamdm37x_fun_t *fun = ROOTARM_FUN(fnode); 203 261 assert(fun != NULL); 204 205 262 return &fun->hw_resources; 206 263 } … … 209 266 { 210 267 /* TODO */ 211 212 268 return false; 213 269 } 214 215 static hw_res_ops_t fun_hw_res_ops = {216 .get_resource_list = &rootamdm37x_get_resources,217 .enable_interrupt = &rootamdm37x_enable_interrupt218 };219 270 220 271 int main(int argc, char *argv[]) … … 222 273 printf("%s: HelenOS AM/DM37x(OMAP37x) platform driver\n", NAME); 223 274 ddf_log_init(NAME, LVL_ERROR); 224 rootamdm37x_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops;225 275 return ddf_driver_main(&rootamdm37x_driver); 226 276 }
Note:
See TracChangeset
for help on using the changeset viewer.