Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 1 | /* |
| 2 | * FSL SoC setup code |
| 3 | * |
| 4 | * Maintained by Kumar Gala (see MAINTAINERS for contact information) |
| 5 | * |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 6 | * 2006 (c) MontaVista Software, Inc. |
| 7 | * Vitaly Bordug <vbordug@ru.mvista.com> |
| 8 | * |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | */ |
| 14 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 15 | #include <linux/stddef.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/major.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/irq.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/device.h> |
| 24 | #include <linux/platform_device.h> |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 25 | #include <linux/phy.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 26 | #include <linux/fsl_devices.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 27 | #include <linux/fs_enet_pd.h> |
| 28 | #include <linux/fs_uart_pd.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 29 | |
| 30 | #include <asm/system.h> |
| 31 | #include <asm/atomic.h> |
| 32 | #include <asm/io.h> |
| 33 | #include <asm/irq.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 34 | #include <asm/time.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 35 | #include <asm/prom.h> |
| 36 | #include <sysdev/fsl_soc.h> |
| 37 | #include <mm/mmu_decl.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 38 | #include <asm/cpm2.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 39 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 40 | extern void init_fcc_ioports(struct fs_platform_info*); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 41 | extern void init_fec_ioports(struct fs_platform_info*); |
| 42 | extern void init_smc_ioports(struct fs_uart_platform_info*); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 43 | static phys_addr_t immrbase = -1; |
| 44 | |
| 45 | phys_addr_t get_immrbase(void) |
| 46 | { |
| 47 | struct device_node *soc; |
| 48 | |
| 49 | if (immrbase != -1) |
| 50 | return immrbase; |
| 51 | |
| 52 | soc = of_find_node_by_type(NULL, "soc"); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 53 | if (soc) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 54 | unsigned int size; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 55 | const void *prop = of_get_property(soc, "reg", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 56 | |
| 57 | if (prop) |
| 58 | immrbase = of_translate_address(soc, prop); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 59 | of_node_put(soc); |
| 60 | }; |
| 61 | |
| 62 | return immrbase; |
| 63 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 64 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 65 | EXPORT_SYMBOL(get_immrbase); |
| 66 | |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 67 | #if defined(CONFIG_CPM2) || defined(CONFIG_8xx) |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 68 | |
| 69 | static u32 brgfreq = -1; |
| 70 | |
| 71 | u32 get_brgfreq(void) |
| 72 | { |
| 73 | struct device_node *node; |
| 74 | |
| 75 | if (brgfreq != -1) |
| 76 | return brgfreq; |
| 77 | |
| 78 | node = of_find_node_by_type(NULL, "cpm"); |
| 79 | if (node) { |
| 80 | unsigned int size; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 81 | const unsigned int *prop = of_get_property(node, |
| 82 | "brg-frequency", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 83 | |
| 84 | if (prop) |
| 85 | brgfreq = *prop; |
| 86 | of_node_put(node); |
| 87 | }; |
| 88 | |
| 89 | return brgfreq; |
| 90 | } |
| 91 | |
| 92 | EXPORT_SYMBOL(get_brgfreq); |
| 93 | |
| 94 | static u32 fs_baudrate = -1; |
| 95 | |
| 96 | u32 get_baudrate(void) |
| 97 | { |
| 98 | struct device_node *node; |
| 99 | |
| 100 | if (fs_baudrate != -1) |
| 101 | return fs_baudrate; |
| 102 | |
| 103 | node = of_find_node_by_type(NULL, "serial"); |
| 104 | if (node) { |
| 105 | unsigned int size; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 106 | const unsigned int *prop = of_get_property(node, |
| 107 | "current-speed", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 108 | |
| 109 | if (prop) |
| 110 | fs_baudrate = *prop; |
| 111 | of_node_put(node); |
| 112 | }; |
| 113 | |
| 114 | return fs_baudrate; |
| 115 | } |
| 116 | |
| 117 | EXPORT_SYMBOL(get_baudrate); |
| 118 | #endif /* CONFIG_CPM2 */ |
| 119 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 120 | static int __init gfar_mdio_of_init(void) |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 121 | { |
| 122 | struct device_node *np; |
| 123 | unsigned int i; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 124 | struct platform_device *mdio_dev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 125 | struct resource res; |
| 126 | int ret; |
| 127 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 128 | for (np = NULL, i = 0; |
| 129 | (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL; |
| 130 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 131 | int k; |
| 132 | struct device_node *child = NULL; |
| 133 | struct gianfar_mdio_data mdio_data; |
| 134 | |
| 135 | memset(&res, 0, sizeof(res)); |
| 136 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 137 | |
| 138 | ret = of_address_to_resource(np, 0, &res); |
| 139 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 140 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 141 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 142 | mdio_dev = |
| 143 | platform_device_register_simple("fsl-gianfar_mdio", |
| 144 | res.start, &res, 1); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 145 | if (IS_ERR(mdio_dev)) { |
| 146 | ret = PTR_ERR(mdio_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 147 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | for (k = 0; k < 32; k++) |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 151 | mdio_data.irq[k] = PHY_POLL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 152 | |
| 153 | while ((child = of_get_next_child(np, child)) != NULL) { |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 154 | int irq = irq_of_parse_and_map(child, 0); |
| 155 | if (irq != NO_IRQ) { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 156 | const u32 *id = of_get_property(child, |
| 157 | "reg", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 158 | mdio_data.irq[*id] = irq; |
| 159 | } |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 160 | } |
| 161 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 162 | ret = |
| 163 | platform_device_add_data(mdio_dev, &mdio_data, |
| 164 | sizeof(struct gianfar_mdio_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 165 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 166 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 167 | } |
| 168 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 169 | return 0; |
| 170 | |
| 171 | unreg: |
| 172 | platform_device_unregister(mdio_dev); |
| 173 | err: |
| 174 | return ret; |
| 175 | } |
| 176 | |
| 177 | arch_initcall(gfar_mdio_of_init); |
| 178 | |
| 179 | static const char *gfar_tx_intr = "tx"; |
| 180 | static const char *gfar_rx_intr = "rx"; |
| 181 | static const char *gfar_err_intr = "error"; |
| 182 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 183 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 184 | static int __init gfar_of_init(void) |
| 185 | { |
| 186 | struct device_node *np; |
| 187 | unsigned int i; |
| 188 | struct platform_device *gfar_dev; |
| 189 | struct resource res; |
| 190 | int ret; |
| 191 | |
| 192 | for (np = NULL, i = 0; |
| 193 | (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; |
| 194 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 195 | struct resource r[4]; |
| 196 | struct device_node *phy, *mdio; |
| 197 | struct gianfar_platform_data gfar_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 198 | const unsigned int *id; |
| 199 | const char *model; |
Andy Fleming | 7132ab7 | 2007-07-11 11:43:07 -0500 | [diff] [blame] | 200 | const char *ctype; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 201 | const void *mac_addr; |
| 202 | const phandle *ph; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 203 | int n_res = 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 204 | |
| 205 | memset(r, 0, sizeof(r)); |
| 206 | memset(&gfar_data, 0, sizeof(gfar_data)); |
| 207 | |
| 208 | ret = of_address_to_resource(np, 0, &r[0]); |
| 209 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 210 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 211 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 212 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 213 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 214 | model = of_get_property(np, "model", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 215 | |
| 216 | /* If we aren't the FEC we have multiple interrupts */ |
| 217 | if (model && strcasecmp(model, "FEC")) { |
| 218 | r[1].name = gfar_tx_intr; |
| 219 | |
| 220 | r[2].name = gfar_rx_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 221 | of_irq_to_resource(np, 1, &r[2]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 222 | |
| 223 | r[3].name = gfar_err_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 224 | of_irq_to_resource(np, 2, &r[3]); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 225 | |
| 226 | n_res += 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 227 | } |
| 228 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 229 | gfar_dev = |
| 230 | platform_device_register_simple("fsl-gianfar", i, &r[0], |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 231 | n_res); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 232 | |
| 233 | if (IS_ERR(gfar_dev)) { |
| 234 | ret = PTR_ERR(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 235 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 236 | } |
| 237 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 238 | mac_addr = of_get_mac_address(np); |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 239 | if (mac_addr) |
| 240 | memcpy(gfar_data.mac_addr, mac_addr, 6); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 241 | |
| 242 | if (model && !strcasecmp(model, "TSEC")) |
| 243 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 244 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 245 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 246 | FSL_GIANFAR_DEV_HAS_RMON | |
| 247 | FSL_GIANFAR_DEV_HAS_MULTI_INTR; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 248 | if (model && !strcasecmp(model, "eTSEC")) |
| 249 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 250 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 251 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 252 | FSL_GIANFAR_DEV_HAS_RMON | |
| 253 | FSL_GIANFAR_DEV_HAS_MULTI_INTR | |
| 254 | FSL_GIANFAR_DEV_HAS_CSUM | |
| 255 | FSL_GIANFAR_DEV_HAS_VLAN | |
| 256 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 257 | |
Andy Fleming | 7132ab7 | 2007-07-11 11:43:07 -0500 | [diff] [blame] | 258 | ctype = of_get_property(np, "phy-connection-type", NULL); |
| 259 | |
| 260 | /* We only care about rgmii-id. The rest are autodetected */ |
| 261 | if (ctype && !strcmp(ctype, "rgmii-id")) |
| 262 | gfar_data.interface = PHY_INTERFACE_MODE_RGMII_ID; |
| 263 | else |
| 264 | gfar_data.interface = PHY_INTERFACE_MODE_MII; |
| 265 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 266 | ph = of_get_property(np, "phy-handle", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 267 | phy = of_find_node_by_phandle(*ph); |
| 268 | |
| 269 | if (phy == NULL) { |
| 270 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 271 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | mdio = of_get_parent(phy); |
| 275 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 276 | id = of_get_property(phy, "reg", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 277 | ret = of_address_to_resource(mdio, 0, &res); |
| 278 | if (ret) { |
| 279 | of_node_put(phy); |
| 280 | of_node_put(mdio); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 281 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | gfar_data.phy_id = *id; |
| 285 | gfar_data.bus_id = res.start; |
| 286 | |
| 287 | of_node_put(phy); |
| 288 | of_node_put(mdio); |
| 289 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 290 | ret = |
| 291 | platform_device_add_data(gfar_dev, &gfar_data, |
| 292 | sizeof(struct |
| 293 | gianfar_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 294 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 295 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | return 0; |
| 299 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 300 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 301 | platform_device_unregister(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 302 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 303 | return ret; |
| 304 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 305 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 306 | arch_initcall(gfar_of_init); |
| 307 | |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame^] | 308 | #ifdef CONFIG_I2C_BOARDINFO |
| 309 | #include <linux/i2c.h> |
| 310 | struct i2c_driver_device { |
| 311 | char *of_device; |
| 312 | char *i2c_driver; |
| 313 | char *i2c_type; |
| 314 | }; |
| 315 | |
| 316 | static struct i2c_driver_device i2c_devices[] __initdata = { |
| 317 | {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",}, |
| 318 | {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",}, |
| 319 | {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",}, |
| 320 | {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, |
| 321 | }; |
| 322 | |
| 323 | static int __init of_find_i2c_driver(struct device_node *node, struct i2c_board_info *info) |
| 324 | { |
| 325 | int i; |
| 326 | |
| 327 | for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { |
| 328 | if (!of_device_is_compatible(node, i2c_devices[i].of_device)) |
| 329 | continue; |
| 330 | strncpy(info->driver_name, i2c_devices[i].i2c_driver, KOBJ_NAME_LEN); |
| 331 | strncpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE); |
| 332 | return 0; |
| 333 | } |
| 334 | return -ENODEV; |
| 335 | } |
| 336 | |
| 337 | static void __init of_register_i2c_devices(struct device_node *adap_node, int bus_num) |
| 338 | { |
| 339 | struct device_node *node = NULL; |
| 340 | |
| 341 | while ((node = of_get_next_child(adap_node, node))) { |
| 342 | struct i2c_board_info info; |
| 343 | const u32 *addr; |
| 344 | int len; |
| 345 | |
| 346 | addr = of_get_property(node, "reg", &len); |
| 347 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { |
| 348 | printk(KERN_WARNING "fsl_ioc.c: invalid i2c device entry\n"); |
| 349 | continue; |
| 350 | } |
| 351 | |
| 352 | info.irq = irq_of_parse_and_map(node, 0); |
| 353 | if (info.irq == NO_IRQ) |
| 354 | info.irq = -1; |
| 355 | |
| 356 | if (of_find_i2c_driver(node, &info) < 0) |
| 357 | continue; |
| 358 | |
| 359 | info.platform_data = NULL; |
| 360 | info.addr = *addr; |
| 361 | |
| 362 | i2c_register_board_info(bus_num, &info, 1); |
| 363 | } |
| 364 | } |
| 365 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 366 | static int __init fsl_i2c_of_init(void) |
| 367 | { |
| 368 | struct device_node *np; |
| 369 | unsigned int i; |
| 370 | struct platform_device *i2c_dev; |
| 371 | int ret; |
| 372 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 373 | for (np = NULL, i = 0; |
| 374 | (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; |
| 375 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 376 | struct resource r[2]; |
| 377 | struct fsl_i2c_platform_data i2c_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 378 | const unsigned char *flags = NULL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 379 | |
| 380 | memset(&r, 0, sizeof(r)); |
| 381 | memset(&i2c_data, 0, sizeof(i2c_data)); |
| 382 | |
| 383 | ret = of_address_to_resource(np, 0, &r[0]); |
| 384 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 385 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 386 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 387 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 388 | |
| 389 | i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); |
| 390 | if (IS_ERR(i2c_dev)) { |
| 391 | ret = PTR_ERR(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 392 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | i2c_data.device_flags = 0; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 396 | flags = of_get_property(np, "dfsrr", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 397 | if (flags) |
| 398 | i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; |
| 399 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 400 | flags = of_get_property(np, "fsl5200-clocking", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 401 | if (flags) |
| 402 | i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; |
| 403 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 404 | ret = |
| 405 | platform_device_add_data(i2c_dev, &i2c_data, |
| 406 | sizeof(struct |
| 407 | fsl_i2c_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 408 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 409 | goto unreg; |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame^] | 410 | |
| 411 | of_register_i2c_devices(np, i); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 412 | } |
| 413 | |
| 414 | return 0; |
| 415 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 416 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 417 | platform_device_unregister(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 418 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 419 | return ret; |
| 420 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 421 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 422 | arch_initcall(fsl_i2c_of_init); |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame^] | 423 | #endif |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 424 | |
| 425 | #ifdef CONFIG_PPC_83xx |
| 426 | static int __init mpc83xx_wdt_init(void) |
| 427 | { |
| 428 | struct resource r; |
| 429 | struct device_node *soc, *np; |
| 430 | struct platform_device *dev; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 431 | const unsigned int *freq; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 432 | int ret; |
| 433 | |
| 434 | np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); |
| 435 | |
| 436 | if (!np) { |
| 437 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 438 | goto nodev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | soc = of_find_node_by_type(NULL, "soc"); |
| 442 | |
| 443 | if (!soc) { |
| 444 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 445 | goto nosoc; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 446 | } |
| 447 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 448 | freq = of_get_property(soc, "bus-frequency", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 449 | if (!freq) { |
| 450 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 451 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | memset(&r, 0, sizeof(r)); |
| 455 | |
| 456 | ret = of_address_to_resource(np, 0, &r); |
| 457 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 458 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 459 | |
| 460 | dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); |
| 461 | if (IS_ERR(dev)) { |
| 462 | ret = PTR_ERR(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 463 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | ret = platform_device_add_data(dev, freq, sizeof(int)); |
| 467 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 468 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 469 | |
| 470 | of_node_put(soc); |
| 471 | of_node_put(np); |
| 472 | |
| 473 | return 0; |
| 474 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 475 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 476 | platform_device_unregister(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 477 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 478 | of_node_put(soc); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 479 | nosoc: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 480 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 481 | nodev: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 482 | return ret; |
| 483 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 484 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 485 | arch_initcall(mpc83xx_wdt_init); |
| 486 | #endif |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 487 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 488 | static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type) |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 489 | { |
| 490 | if (!phy_type) |
| 491 | return FSL_USB2_PHY_NONE; |
| 492 | if (!strcasecmp(phy_type, "ulpi")) |
| 493 | return FSL_USB2_PHY_ULPI; |
| 494 | if (!strcasecmp(phy_type, "utmi")) |
| 495 | return FSL_USB2_PHY_UTMI; |
| 496 | if (!strcasecmp(phy_type, "utmi_wide")) |
| 497 | return FSL_USB2_PHY_UTMI_WIDE; |
| 498 | if (!strcasecmp(phy_type, "serial")) |
| 499 | return FSL_USB2_PHY_SERIAL; |
| 500 | |
| 501 | return FSL_USB2_PHY_NONE; |
| 502 | } |
| 503 | |
| 504 | static int __init fsl_usb_of_init(void) |
| 505 | { |
| 506 | struct device_node *np; |
| 507 | unsigned int i; |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 508 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL, |
| 509 | *usb_dev_dr_client = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 510 | int ret; |
| 511 | |
| 512 | for (np = NULL, i = 0; |
| 513 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL; |
| 514 | i++) { |
| 515 | struct resource r[2]; |
| 516 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 517 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 518 | |
| 519 | memset(&r, 0, sizeof(r)); |
| 520 | memset(&usb_data, 0, sizeof(usb_data)); |
| 521 | |
| 522 | ret = of_address_to_resource(np, 0, &r[0]); |
| 523 | if (ret) |
| 524 | goto err; |
| 525 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 526 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 527 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 528 | usb_dev_mph = |
| 529 | platform_device_register_simple("fsl-ehci", i, r, 2); |
| 530 | if (IS_ERR(usb_dev_mph)) { |
| 531 | ret = PTR_ERR(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 532 | goto err; |
| 533 | } |
| 534 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 535 | usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL; |
| 536 | usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 537 | |
| 538 | usb_data.operating_mode = FSL_USB2_MPH_HOST; |
| 539 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 540 | prop = of_get_property(np, "port0", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 541 | if (prop) |
| 542 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; |
| 543 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 544 | prop = of_get_property(np, "port1", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 545 | if (prop) |
| 546 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; |
| 547 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 548 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 549 | usb_data.phy_mode = determine_usb_phy(prop); |
| 550 | |
| 551 | ret = |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 552 | platform_device_add_data(usb_dev_mph, &usb_data, |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 553 | sizeof(struct |
| 554 | fsl_usb2_platform_data)); |
| 555 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 556 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 557 | } |
| 558 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 559 | for (np = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 560 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; |
| 561 | i++) { |
| 562 | struct resource r[2]; |
| 563 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 564 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 565 | |
| 566 | memset(&r, 0, sizeof(r)); |
| 567 | memset(&usb_data, 0, sizeof(usb_data)); |
| 568 | |
| 569 | ret = of_address_to_resource(np, 0, &r[0]); |
| 570 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 571 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 572 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 573 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 574 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 575 | prop = of_get_property(np, "dr_mode", NULL); |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 576 | |
| 577 | if (!prop || !strcmp(prop, "host")) { |
| 578 | usb_data.operating_mode = FSL_USB2_DR_HOST; |
| 579 | usb_dev_dr_host = platform_device_register_simple( |
| 580 | "fsl-ehci", i, r, 2); |
| 581 | if (IS_ERR(usb_dev_dr_host)) { |
| 582 | ret = PTR_ERR(usb_dev_dr_host); |
| 583 | goto err; |
| 584 | } |
| 585 | } else if (prop && !strcmp(prop, "peripheral")) { |
| 586 | usb_data.operating_mode = FSL_USB2_DR_DEVICE; |
| 587 | usb_dev_dr_client = platform_device_register_simple( |
| 588 | "fsl-usb2-udc", i, r, 2); |
| 589 | if (IS_ERR(usb_dev_dr_client)) { |
| 590 | ret = PTR_ERR(usb_dev_dr_client); |
| 591 | goto err; |
| 592 | } |
| 593 | } else if (prop && !strcmp(prop, "otg")) { |
| 594 | usb_data.operating_mode = FSL_USB2_DR_OTG; |
| 595 | usb_dev_dr_host = platform_device_register_simple( |
| 596 | "fsl-ehci", i, r, 2); |
| 597 | if (IS_ERR(usb_dev_dr_host)) { |
| 598 | ret = PTR_ERR(usb_dev_dr_host); |
| 599 | goto err; |
| 600 | } |
| 601 | usb_dev_dr_client = platform_device_register_simple( |
| 602 | "fsl-usb2-udc", i, r, 2); |
| 603 | if (IS_ERR(usb_dev_dr_client)) { |
| 604 | ret = PTR_ERR(usb_dev_dr_client); |
| 605 | goto err; |
| 606 | } |
| 607 | } else { |
| 608 | ret = -EINVAL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 609 | goto err; |
| 610 | } |
| 611 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 612 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 613 | usb_data.phy_mode = determine_usb_phy(prop); |
| 614 | |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 615 | if (usb_dev_dr_host) { |
| 616 | usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL; |
| 617 | usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> |
| 618 | dev.coherent_dma_mask; |
| 619 | if ((ret = platform_device_add_data(usb_dev_dr_host, |
| 620 | &usb_data, sizeof(struct |
| 621 | fsl_usb2_platform_data)))) |
| 622 | goto unreg_dr; |
| 623 | } |
| 624 | if (usb_dev_dr_client) { |
| 625 | usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL; |
| 626 | usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> |
| 627 | dev.coherent_dma_mask; |
| 628 | if ((ret = platform_device_add_data(usb_dev_dr_client, |
| 629 | &usb_data, sizeof(struct |
| 630 | fsl_usb2_platform_data)))) |
| 631 | goto unreg_dr; |
| 632 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 633 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 634 | return 0; |
| 635 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 636 | unreg_dr: |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 637 | if (usb_dev_dr_host) |
| 638 | platform_device_unregister(usb_dev_dr_host); |
| 639 | if (usb_dev_dr_client) |
| 640 | platform_device_unregister(usb_dev_dr_client); |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 641 | unreg_mph: |
| 642 | if (usb_dev_mph) |
| 643 | platform_device_unregister(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 644 | err: |
| 645 | return ret; |
| 646 | } |
| 647 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 648 | arch_initcall(fsl_usb_of_init); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 649 | |
| 650 | #ifdef CONFIG_CPM2 |
| 651 | |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 652 | extern void init_scc_ioports(struct fs_uart_platform_info*); |
| 653 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 654 | static const char fcc_regs[] = "fcc_regs"; |
| 655 | static const char fcc_regs_c[] = "fcc_regs_c"; |
| 656 | static const char fcc_pram[] = "fcc_pram"; |
| 657 | static char bus_id[9][BUS_ID_SIZE]; |
| 658 | |
| 659 | static int __init fs_enet_of_init(void) |
| 660 | { |
| 661 | struct device_node *np; |
| 662 | unsigned int i; |
| 663 | struct platform_device *fs_enet_dev; |
| 664 | struct resource res; |
| 665 | int ret; |
| 666 | |
| 667 | for (np = NULL, i = 0; |
| 668 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 669 | i++) { |
| 670 | struct resource r[4]; |
| 671 | struct device_node *phy, *mdio; |
| 672 | struct fs_platform_info fs_enet_data; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 673 | const unsigned int *id, *phy_addr, *phy_irq; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 674 | const void *mac_addr; |
| 675 | const phandle *ph; |
| 676 | const char *model; |
| 677 | |
| 678 | memset(r, 0, sizeof(r)); |
| 679 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 680 | |
| 681 | ret = of_address_to_resource(np, 0, &r[0]); |
| 682 | if (ret) |
| 683 | goto err; |
| 684 | r[0].name = fcc_regs; |
| 685 | |
| 686 | ret = of_address_to_resource(np, 1, &r[1]); |
| 687 | if (ret) |
| 688 | goto err; |
| 689 | r[1].name = fcc_pram; |
| 690 | |
| 691 | ret = of_address_to_resource(np, 2, &r[2]); |
| 692 | if (ret) |
| 693 | goto err; |
| 694 | r[2].name = fcc_regs_c; |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 695 | fs_enet_data.fcc_regs_c = r[2].start; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 696 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 697 | of_irq_to_resource(np, 0, &r[3]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 698 | |
| 699 | fs_enet_dev = |
| 700 | platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); |
| 701 | |
| 702 | if (IS_ERR(fs_enet_dev)) { |
| 703 | ret = PTR_ERR(fs_enet_dev); |
| 704 | goto err; |
| 705 | } |
| 706 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 707 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 708 | if (model == NULL) { |
| 709 | ret = -ENODEV; |
| 710 | goto unreg; |
| 711 | } |
| 712 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 713 | mac_addr = of_get_mac_address(np); |
| 714 | if (mac_addr) |
| 715 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 716 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 717 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 718 | phy = of_find_node_by_phandle(*ph); |
| 719 | |
| 720 | if (phy == NULL) { |
| 721 | ret = -ENODEV; |
| 722 | goto unreg; |
| 723 | } |
| 724 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 725 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 726 | fs_enet_data.phy_addr = *phy_addr; |
| 727 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 728 | phy_irq = of_get_property(phy, "interrupts", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 729 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 730 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 731 | fs_enet_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 732 | strcpy(fs_enet_data.fs_type, model); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 733 | |
| 734 | mdio = of_get_parent(phy); |
| 735 | ret = of_address_to_resource(mdio, 0, &res); |
| 736 | if (ret) { |
| 737 | of_node_put(phy); |
| 738 | of_node_put(mdio); |
| 739 | goto unreg; |
| 740 | } |
| 741 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 742 | fs_enet_data.clk_rx = *((u32 *)of_get_property(np, |
| 743 | "rx-clock", NULL)); |
| 744 | fs_enet_data.clk_tx = *((u32 *)of_get_property(np, |
| 745 | "tx-clock", NULL)); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 746 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 747 | if (strstr(model, "FCC")) { |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 748 | int fcc_index = *id - 1; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 749 | const unsigned char *mdio_bb_prop; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 750 | |
Vitaly Bordug | fc8e50e | 2006-09-21 22:37:58 +0400 | [diff] [blame] | 751 | fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 752 | fs_enet_data.rx_ring = 32; |
| 753 | fs_enet_data.tx_ring = 32; |
| 754 | fs_enet_data.rx_copybreak = 240; |
| 755 | fs_enet_data.use_napi = 0; |
| 756 | fs_enet_data.napi_weight = 17; |
| 757 | fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index); |
| 758 | fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index); |
| 759 | fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index); |
| 760 | |
| 761 | snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x", |
| 762 | (u32)res.start, fs_enet_data.phy_addr); |
| 763 | fs_enet_data.bus_id = (char*)&bus_id[(*id)]; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 764 | fs_enet_data.init_ioports = init_fcc_ioports; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 765 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 766 | mdio_bb_prop = of_get_property(phy, "bitbang", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 767 | if (mdio_bb_prop) { |
| 768 | struct platform_device *fs_enet_mdio_bb_dev; |
| 769 | struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 770 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 771 | fs_enet_mdio_bb_dev = |
| 772 | platform_device_register_simple("fsl-bb-mdio", |
| 773 | i, NULL, 0); |
| 774 | memset(&fs_enet_mdio_bb_data, 0, |
| 775 | sizeof(struct fs_mii_bb_platform_info)); |
| 776 | fs_enet_mdio_bb_data.mdio_dat.bit = |
| 777 | mdio_bb_prop[0]; |
| 778 | fs_enet_mdio_bb_data.mdio_dir.bit = |
| 779 | mdio_bb_prop[1]; |
| 780 | fs_enet_mdio_bb_data.mdc_dat.bit = |
| 781 | mdio_bb_prop[2]; |
| 782 | fs_enet_mdio_bb_data.mdio_port = |
| 783 | mdio_bb_prop[3]; |
| 784 | fs_enet_mdio_bb_data.mdc_port = |
| 785 | mdio_bb_prop[4]; |
| 786 | fs_enet_mdio_bb_data.delay = |
| 787 | mdio_bb_prop[5]; |
| 788 | |
| 789 | fs_enet_mdio_bb_data.irq[0] = phy_irq[0]; |
| 790 | fs_enet_mdio_bb_data.irq[1] = -1; |
| 791 | fs_enet_mdio_bb_data.irq[2] = -1; |
| 792 | fs_enet_mdio_bb_data.irq[3] = phy_irq[0]; |
| 793 | fs_enet_mdio_bb_data.irq[31] = -1; |
| 794 | |
| 795 | fs_enet_mdio_bb_data.mdio_dat.offset = |
| 796 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 797 | fs_enet_mdio_bb_data.mdio_dir.offset = |
| 798 | (u32)&cpm2_immr->im_ioport.iop_pdirc; |
| 799 | fs_enet_mdio_bb_data.mdc_dat.offset = |
| 800 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 801 | |
| 802 | ret = platform_device_add_data( |
| 803 | fs_enet_mdio_bb_dev, |
| 804 | &fs_enet_mdio_bb_data, |
| 805 | sizeof(struct fs_mii_bb_platform_info)); |
| 806 | if (ret) |
| 807 | goto unreg; |
| 808 | } |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 809 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 810 | of_node_put(phy); |
| 811 | of_node_put(mdio); |
| 812 | |
| 813 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 814 | sizeof(struct |
| 815 | fs_platform_info)); |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 816 | if (ret) |
| 817 | goto unreg; |
| 818 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 819 | } |
| 820 | return 0; |
| 821 | |
| 822 | unreg: |
| 823 | platform_device_unregister(fs_enet_dev); |
| 824 | err: |
| 825 | return ret; |
| 826 | } |
| 827 | |
| 828 | arch_initcall(fs_enet_of_init); |
| 829 | |
| 830 | static const char scc_regs[] = "regs"; |
| 831 | static const char scc_pram[] = "pram"; |
| 832 | |
| 833 | static int __init cpm_uart_of_init(void) |
| 834 | { |
| 835 | struct device_node *np; |
| 836 | unsigned int i; |
| 837 | struct platform_device *cpm_uart_dev; |
| 838 | int ret; |
| 839 | |
| 840 | for (np = NULL, i = 0; |
| 841 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 842 | i++) { |
| 843 | struct resource r[3]; |
| 844 | struct fs_uart_platform_info cpm_uart_data; |
| 845 | const int *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 846 | const char *model; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 847 | |
| 848 | memset(r, 0, sizeof(r)); |
| 849 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 850 | |
| 851 | ret = of_address_to_resource(np, 0, &r[0]); |
| 852 | if (ret) |
| 853 | goto err; |
| 854 | |
| 855 | r[0].name = scc_regs; |
| 856 | |
| 857 | ret = of_address_to_resource(np, 1, &r[1]); |
| 858 | if (ret) |
| 859 | goto err; |
| 860 | r[1].name = scc_pram; |
| 861 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 862 | of_irq_to_resource(np, 0, &r[2]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 863 | |
| 864 | cpm_uart_dev = |
| 865 | platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); |
| 866 | |
| 867 | if (IS_ERR(cpm_uart_dev)) { |
| 868 | ret = PTR_ERR(cpm_uart_dev); |
| 869 | goto err; |
| 870 | } |
| 871 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 872 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 873 | cpm_uart_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 874 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 875 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 876 | strcpy(cpm_uart_data.fs_type, model); |
| 877 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 878 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 879 | |
| 880 | cpm_uart_data.tx_num_fifo = 4; |
| 881 | cpm_uart_data.tx_buf_size = 32; |
| 882 | cpm_uart_data.rx_num_fifo = 4; |
| 883 | cpm_uart_data.rx_buf_size = 32; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 884 | cpm_uart_data.clk_rx = *((u32 *)of_get_property(np, |
| 885 | "rx-clock", NULL)); |
| 886 | cpm_uart_data.clk_tx = *((u32 *)of_get_property(np, |
| 887 | "tx-clock", NULL)); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 888 | |
| 889 | ret = |
| 890 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 891 | sizeof(struct |
| 892 | fs_uart_platform_info)); |
| 893 | if (ret) |
| 894 | goto unreg; |
| 895 | } |
| 896 | |
| 897 | return 0; |
| 898 | |
| 899 | unreg: |
| 900 | platform_device_unregister(cpm_uart_dev); |
| 901 | err: |
| 902 | return ret; |
| 903 | } |
| 904 | |
| 905 | arch_initcall(cpm_uart_of_init); |
| 906 | #endif /* CONFIG_CPM2 */ |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 907 | |
| 908 | #ifdef CONFIG_8xx |
| 909 | |
| 910 | extern void init_scc_ioports(struct fs_platform_info*); |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 911 | extern int platform_device_skip(const char *model, int id); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 912 | |
| 913 | static int __init fs_enet_mdio_of_init(void) |
| 914 | { |
| 915 | struct device_node *np; |
| 916 | unsigned int i; |
| 917 | struct platform_device *mdio_dev; |
| 918 | struct resource res; |
| 919 | int ret; |
| 920 | |
| 921 | for (np = NULL, i = 0; |
| 922 | (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL; |
| 923 | i++) { |
| 924 | struct fs_mii_fec_platform_info mdio_data; |
| 925 | |
| 926 | memset(&res, 0, sizeof(res)); |
| 927 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 928 | |
| 929 | ret = of_address_to_resource(np, 0, &res); |
| 930 | if (ret) |
| 931 | goto err; |
| 932 | |
| 933 | mdio_dev = |
| 934 | platform_device_register_simple("fsl-cpm-fec-mdio", |
| 935 | res.start, &res, 1); |
| 936 | if (IS_ERR(mdio_dev)) { |
| 937 | ret = PTR_ERR(mdio_dev); |
| 938 | goto err; |
| 939 | } |
| 940 | |
| 941 | mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1; |
| 942 | |
| 943 | ret = |
| 944 | platform_device_add_data(mdio_dev, &mdio_data, |
| 945 | sizeof(struct fs_mii_fec_platform_info)); |
| 946 | if (ret) |
| 947 | goto unreg; |
| 948 | } |
| 949 | return 0; |
| 950 | |
| 951 | unreg: |
| 952 | platform_device_unregister(mdio_dev); |
| 953 | err: |
| 954 | return ret; |
| 955 | } |
| 956 | |
| 957 | arch_initcall(fs_enet_mdio_of_init); |
| 958 | |
| 959 | static const char *enet_regs = "regs"; |
| 960 | static const char *enet_pram = "pram"; |
| 961 | static const char *enet_irq = "interrupt"; |
| 962 | static char bus_id[9][BUS_ID_SIZE]; |
| 963 | |
| 964 | static int __init fs_enet_of_init(void) |
| 965 | { |
| 966 | struct device_node *np; |
| 967 | unsigned int i; |
| 968 | struct platform_device *fs_enet_dev = NULL; |
| 969 | struct resource res; |
| 970 | int ret; |
| 971 | |
| 972 | for (np = NULL, i = 0; |
| 973 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 974 | i++) { |
| 975 | struct resource r[4]; |
| 976 | struct device_node *phy = NULL, *mdio = NULL; |
| 977 | struct fs_platform_info fs_enet_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 978 | const unsigned int *id; |
| 979 | const unsigned int *phy_addr; |
Scott Wood | b7a6912 | 2007-05-09 03:15:34 +1000 | [diff] [blame] | 980 | const void *mac_addr; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 981 | const phandle *ph; |
| 982 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 983 | |
| 984 | memset(r, 0, sizeof(r)); |
| 985 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 986 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 987 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 988 | if (model == NULL) { |
| 989 | ret = -ENODEV; |
| 990 | goto unreg; |
| 991 | } |
| 992 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 993 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 994 | fs_enet_data.fs_no = *id; |
| 995 | |
| 996 | if (platform_device_skip(model, *id)) |
| 997 | continue; |
| 998 | |
| 999 | ret = of_address_to_resource(np, 0, &r[0]); |
| 1000 | if (ret) |
| 1001 | goto err; |
| 1002 | r[0].name = enet_regs; |
| 1003 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 1004 | mac_addr = of_get_mac_address(np); |
| 1005 | if (mac_addr) |
| 1006 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1007 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1008 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1009 | if (ph != NULL) |
| 1010 | phy = of_find_node_by_phandle(*ph); |
| 1011 | |
| 1012 | if (phy != NULL) { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1013 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1014 | fs_enet_data.phy_addr = *phy_addr; |
| 1015 | fs_enet_data.has_phy = 1; |
| 1016 | |
| 1017 | mdio = of_get_parent(phy); |
| 1018 | ret = of_address_to_resource(mdio, 0, &res); |
| 1019 | if (ret) { |
| 1020 | of_node_put(phy); |
| 1021 | of_node_put(mdio); |
| 1022 | goto unreg; |
| 1023 | } |
| 1024 | } |
| 1025 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1026 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1027 | strcpy(fs_enet_data.fs_type, model); |
| 1028 | |
| 1029 | if (strstr(model, "FEC")) { |
| 1030 | r[1].start = r[1].end = irq_of_parse_and_map(np, 0); |
| 1031 | r[1].flags = IORESOURCE_IRQ; |
| 1032 | r[1].name = enet_irq; |
| 1033 | |
| 1034 | fs_enet_dev = |
| 1035 | platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2); |
| 1036 | |
| 1037 | if (IS_ERR(fs_enet_dev)) { |
| 1038 | ret = PTR_ERR(fs_enet_dev); |
| 1039 | goto err; |
| 1040 | } |
| 1041 | |
| 1042 | fs_enet_data.rx_ring = 128; |
| 1043 | fs_enet_data.tx_ring = 16; |
| 1044 | fs_enet_data.rx_copybreak = 240; |
| 1045 | fs_enet_data.use_napi = 1; |
| 1046 | fs_enet_data.napi_weight = 17; |
| 1047 | |
| 1048 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x", |
| 1049 | (u32)res.start, fs_enet_data.phy_addr); |
| 1050 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 1051 | fs_enet_data.init_ioports = init_fec_ioports; |
| 1052 | } |
| 1053 | if (strstr(model, "SCC")) { |
| 1054 | ret = of_address_to_resource(np, 1, &r[1]); |
| 1055 | if (ret) |
| 1056 | goto err; |
| 1057 | r[1].name = enet_pram; |
| 1058 | |
| 1059 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 1060 | r[2].flags = IORESOURCE_IRQ; |
| 1061 | r[2].name = enet_irq; |
| 1062 | |
| 1063 | fs_enet_dev = |
| 1064 | platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3); |
| 1065 | |
| 1066 | if (IS_ERR(fs_enet_dev)) { |
| 1067 | ret = PTR_ERR(fs_enet_dev); |
| 1068 | goto err; |
| 1069 | } |
| 1070 | |
| 1071 | fs_enet_data.rx_ring = 64; |
| 1072 | fs_enet_data.tx_ring = 8; |
| 1073 | fs_enet_data.rx_copybreak = 240; |
| 1074 | fs_enet_data.use_napi = 1; |
| 1075 | fs_enet_data.napi_weight = 17; |
| 1076 | |
| 1077 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1"); |
| 1078 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 1079 | fs_enet_data.init_ioports = init_scc_ioports; |
| 1080 | } |
| 1081 | |
| 1082 | of_node_put(phy); |
| 1083 | of_node_put(mdio); |
| 1084 | |
| 1085 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 1086 | sizeof(struct |
| 1087 | fs_platform_info)); |
| 1088 | if (ret) |
| 1089 | goto unreg; |
| 1090 | } |
| 1091 | return 0; |
| 1092 | |
| 1093 | unreg: |
| 1094 | platform_device_unregister(fs_enet_dev); |
| 1095 | err: |
| 1096 | return ret; |
| 1097 | } |
| 1098 | |
| 1099 | arch_initcall(fs_enet_of_init); |
| 1100 | |
Vitaly Bordug | 80128ff | 2007-07-09 11:37:35 -0700 | [diff] [blame] | 1101 | static int __init fsl_pcmcia_of_init(void) |
| 1102 | { |
| 1103 | struct device_node *np = NULL; |
| 1104 | /* |
| 1105 | * Register all the devices which type is "pcmcia" |
| 1106 | */ |
| 1107 | while ((np = of_find_compatible_node(np, |
| 1108 | "pcmcia", "fsl,pq-pcmcia")) != NULL) |
| 1109 | of_platform_device_create(np, "m8xx-pcmcia", NULL); |
| 1110 | return 0; |
| 1111 | } |
| 1112 | |
| 1113 | arch_initcall(fsl_pcmcia_of_init); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1114 | |
| 1115 | static const char *smc_regs = "regs"; |
| 1116 | static const char *smc_pram = "pram"; |
| 1117 | |
| 1118 | static int __init cpm_smc_uart_of_init(void) |
| 1119 | { |
| 1120 | struct device_node *np; |
| 1121 | unsigned int i; |
| 1122 | struct platform_device *cpm_uart_dev; |
| 1123 | int ret; |
| 1124 | |
| 1125 | for (np = NULL, i = 0; |
| 1126 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 1127 | i++) { |
| 1128 | struct resource r[3]; |
| 1129 | struct fs_uart_platform_info cpm_uart_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1130 | const int *id; |
| 1131 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1132 | |
| 1133 | memset(r, 0, sizeof(r)); |
| 1134 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 1135 | |
| 1136 | ret = of_address_to_resource(np, 0, &r[0]); |
| 1137 | if (ret) |
| 1138 | goto err; |
| 1139 | |
| 1140 | r[0].name = smc_regs; |
| 1141 | |
| 1142 | ret = of_address_to_resource(np, 1, &r[1]); |
| 1143 | if (ret) |
| 1144 | goto err; |
| 1145 | r[1].name = smc_pram; |
| 1146 | |
| 1147 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 1148 | r[2].flags = IORESOURCE_IRQ; |
| 1149 | |
| 1150 | cpm_uart_dev = |
| 1151 | platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3); |
| 1152 | |
| 1153 | if (IS_ERR(cpm_uart_dev)) { |
| 1154 | ret = PTR_ERR(cpm_uart_dev); |
| 1155 | goto err; |
| 1156 | } |
| 1157 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1158 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1159 | strcpy(cpm_uart_data.fs_type, model); |
| 1160 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1161 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1162 | cpm_uart_data.fs_no = *id; |
| 1163 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 1164 | |
| 1165 | cpm_uart_data.tx_num_fifo = 4; |
| 1166 | cpm_uart_data.tx_buf_size = 32; |
| 1167 | cpm_uart_data.rx_num_fifo = 4; |
| 1168 | cpm_uart_data.rx_buf_size = 32; |
| 1169 | |
| 1170 | ret = |
| 1171 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 1172 | sizeof(struct |
| 1173 | fs_uart_platform_info)); |
| 1174 | if (ret) |
| 1175 | goto unreg; |
| 1176 | } |
| 1177 | |
| 1178 | return 0; |
| 1179 | |
| 1180 | unreg: |
| 1181 | platform_device_unregister(cpm_uart_dev); |
| 1182 | err: |
| 1183 | return ret; |
| 1184 | } |
| 1185 | |
| 1186 | arch_initcall(cpm_smc_uart_of_init); |
| 1187 | |
| 1188 | #endif /* CONFIG_8xx */ |