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 | |
| 308 | static int __init fsl_i2c_of_init(void) |
| 309 | { |
| 310 | struct device_node *np; |
| 311 | unsigned int i; |
| 312 | struct platform_device *i2c_dev; |
| 313 | int ret; |
| 314 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 315 | for (np = NULL, i = 0; |
| 316 | (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; |
| 317 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 318 | struct resource r[2]; |
| 319 | struct fsl_i2c_platform_data i2c_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 320 | const unsigned char *flags = NULL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 321 | |
| 322 | memset(&r, 0, sizeof(r)); |
| 323 | memset(&i2c_data, 0, sizeof(i2c_data)); |
| 324 | |
| 325 | ret = of_address_to_resource(np, 0, &r[0]); |
| 326 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 327 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 328 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 329 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 330 | |
| 331 | i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); |
| 332 | if (IS_ERR(i2c_dev)) { |
| 333 | ret = PTR_ERR(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 334 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | i2c_data.device_flags = 0; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 338 | flags = of_get_property(np, "dfsrr", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 339 | if (flags) |
| 340 | i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; |
| 341 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 342 | flags = of_get_property(np, "fsl5200-clocking", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 343 | if (flags) |
| 344 | i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; |
| 345 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 346 | ret = |
| 347 | platform_device_add_data(i2c_dev, &i2c_data, |
| 348 | sizeof(struct |
| 349 | fsl_i2c_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 350 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 351 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | return 0; |
| 355 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 356 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 357 | platform_device_unregister(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 358 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 359 | return ret; |
| 360 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 361 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 362 | arch_initcall(fsl_i2c_of_init); |
| 363 | |
| 364 | #ifdef CONFIG_PPC_83xx |
| 365 | static int __init mpc83xx_wdt_init(void) |
| 366 | { |
| 367 | struct resource r; |
| 368 | struct device_node *soc, *np; |
| 369 | struct platform_device *dev; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 370 | const unsigned int *freq; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 371 | int ret; |
| 372 | |
| 373 | np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); |
| 374 | |
| 375 | if (!np) { |
| 376 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 377 | goto nodev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | soc = of_find_node_by_type(NULL, "soc"); |
| 381 | |
| 382 | if (!soc) { |
| 383 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 384 | goto nosoc; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 385 | } |
| 386 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 387 | freq = of_get_property(soc, "bus-frequency", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 388 | if (!freq) { |
| 389 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 390 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | memset(&r, 0, sizeof(r)); |
| 394 | |
| 395 | ret = of_address_to_resource(np, 0, &r); |
| 396 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 397 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 398 | |
| 399 | dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); |
| 400 | if (IS_ERR(dev)) { |
| 401 | ret = PTR_ERR(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 402 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | ret = platform_device_add_data(dev, freq, sizeof(int)); |
| 406 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 407 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 408 | |
| 409 | of_node_put(soc); |
| 410 | of_node_put(np); |
| 411 | |
| 412 | return 0; |
| 413 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 414 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 415 | platform_device_unregister(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 416 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 417 | of_node_put(soc); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 418 | nosoc: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 419 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 420 | nodev: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 421 | return ret; |
| 422 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 423 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 424 | arch_initcall(mpc83xx_wdt_init); |
| 425 | #endif |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 426 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 427 | 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] | 428 | { |
| 429 | if (!phy_type) |
| 430 | return FSL_USB2_PHY_NONE; |
| 431 | if (!strcasecmp(phy_type, "ulpi")) |
| 432 | return FSL_USB2_PHY_ULPI; |
| 433 | if (!strcasecmp(phy_type, "utmi")) |
| 434 | return FSL_USB2_PHY_UTMI; |
| 435 | if (!strcasecmp(phy_type, "utmi_wide")) |
| 436 | return FSL_USB2_PHY_UTMI_WIDE; |
| 437 | if (!strcasecmp(phy_type, "serial")) |
| 438 | return FSL_USB2_PHY_SERIAL; |
| 439 | |
| 440 | return FSL_USB2_PHY_NONE; |
| 441 | } |
| 442 | |
| 443 | static int __init fsl_usb_of_init(void) |
| 444 | { |
| 445 | struct device_node *np; |
| 446 | unsigned int i; |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 447 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL, |
| 448 | *usb_dev_dr_client = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 449 | int ret; |
| 450 | |
| 451 | for (np = NULL, i = 0; |
| 452 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL; |
| 453 | i++) { |
| 454 | struct resource r[2]; |
| 455 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 456 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 457 | |
| 458 | memset(&r, 0, sizeof(r)); |
| 459 | memset(&usb_data, 0, sizeof(usb_data)); |
| 460 | |
| 461 | ret = of_address_to_resource(np, 0, &r[0]); |
| 462 | if (ret) |
| 463 | goto err; |
| 464 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 465 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 466 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 467 | usb_dev_mph = |
| 468 | platform_device_register_simple("fsl-ehci", i, r, 2); |
| 469 | if (IS_ERR(usb_dev_mph)) { |
| 470 | ret = PTR_ERR(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 471 | goto err; |
| 472 | } |
| 473 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 474 | usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL; |
| 475 | 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] | 476 | |
| 477 | usb_data.operating_mode = FSL_USB2_MPH_HOST; |
| 478 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 479 | prop = of_get_property(np, "port0", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 480 | if (prop) |
| 481 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; |
| 482 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 483 | prop = of_get_property(np, "port1", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 484 | if (prop) |
| 485 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; |
| 486 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 487 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 488 | usb_data.phy_mode = determine_usb_phy(prop); |
| 489 | |
| 490 | ret = |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 491 | platform_device_add_data(usb_dev_mph, &usb_data, |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 492 | sizeof(struct |
| 493 | fsl_usb2_platform_data)); |
| 494 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 495 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 496 | } |
| 497 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 498 | for (np = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 499 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; |
| 500 | i++) { |
| 501 | struct resource r[2]; |
| 502 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 503 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 504 | |
| 505 | memset(&r, 0, sizeof(r)); |
| 506 | memset(&usb_data, 0, sizeof(usb_data)); |
| 507 | |
| 508 | ret = of_address_to_resource(np, 0, &r[0]); |
| 509 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 510 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 511 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 512 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 513 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 514 | prop = of_get_property(np, "dr_mode", NULL); |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 515 | |
| 516 | if (!prop || !strcmp(prop, "host")) { |
| 517 | usb_data.operating_mode = FSL_USB2_DR_HOST; |
| 518 | usb_dev_dr_host = platform_device_register_simple( |
| 519 | "fsl-ehci", i, r, 2); |
| 520 | if (IS_ERR(usb_dev_dr_host)) { |
| 521 | ret = PTR_ERR(usb_dev_dr_host); |
| 522 | goto err; |
| 523 | } |
| 524 | } else if (prop && !strcmp(prop, "peripheral")) { |
| 525 | usb_data.operating_mode = FSL_USB2_DR_DEVICE; |
| 526 | usb_dev_dr_client = platform_device_register_simple( |
| 527 | "fsl-usb2-udc", i, r, 2); |
| 528 | if (IS_ERR(usb_dev_dr_client)) { |
| 529 | ret = PTR_ERR(usb_dev_dr_client); |
| 530 | goto err; |
| 531 | } |
| 532 | } else if (prop && !strcmp(prop, "otg")) { |
| 533 | usb_data.operating_mode = FSL_USB2_DR_OTG; |
| 534 | usb_dev_dr_host = platform_device_register_simple( |
| 535 | "fsl-ehci", i, r, 2); |
| 536 | if (IS_ERR(usb_dev_dr_host)) { |
| 537 | ret = PTR_ERR(usb_dev_dr_host); |
| 538 | goto err; |
| 539 | } |
| 540 | usb_dev_dr_client = platform_device_register_simple( |
| 541 | "fsl-usb2-udc", i, r, 2); |
| 542 | if (IS_ERR(usb_dev_dr_client)) { |
| 543 | ret = PTR_ERR(usb_dev_dr_client); |
| 544 | goto err; |
| 545 | } |
| 546 | } else { |
| 547 | ret = -EINVAL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 548 | goto err; |
| 549 | } |
| 550 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 551 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 552 | usb_data.phy_mode = determine_usb_phy(prop); |
| 553 | |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 554 | if (usb_dev_dr_host) { |
| 555 | usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL; |
| 556 | usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> |
| 557 | dev.coherent_dma_mask; |
| 558 | if ((ret = platform_device_add_data(usb_dev_dr_host, |
| 559 | &usb_data, sizeof(struct |
| 560 | fsl_usb2_platform_data)))) |
| 561 | goto unreg_dr; |
| 562 | } |
| 563 | if (usb_dev_dr_client) { |
| 564 | usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL; |
| 565 | usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> |
| 566 | dev.coherent_dma_mask; |
| 567 | if ((ret = platform_device_add_data(usb_dev_dr_client, |
| 568 | &usb_data, sizeof(struct |
| 569 | fsl_usb2_platform_data)))) |
| 570 | goto unreg_dr; |
| 571 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 572 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 573 | return 0; |
| 574 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 575 | unreg_dr: |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 576 | if (usb_dev_dr_host) |
| 577 | platform_device_unregister(usb_dev_dr_host); |
| 578 | if (usb_dev_dr_client) |
| 579 | platform_device_unregister(usb_dev_dr_client); |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 580 | unreg_mph: |
| 581 | if (usb_dev_mph) |
| 582 | platform_device_unregister(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 583 | err: |
| 584 | return ret; |
| 585 | } |
| 586 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 587 | arch_initcall(fsl_usb_of_init); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 588 | |
| 589 | #ifdef CONFIG_CPM2 |
| 590 | |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 591 | extern void init_scc_ioports(struct fs_uart_platform_info*); |
| 592 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 593 | static const char fcc_regs[] = "fcc_regs"; |
| 594 | static const char fcc_regs_c[] = "fcc_regs_c"; |
| 595 | static const char fcc_pram[] = "fcc_pram"; |
| 596 | static char bus_id[9][BUS_ID_SIZE]; |
| 597 | |
| 598 | static int __init fs_enet_of_init(void) |
| 599 | { |
| 600 | struct device_node *np; |
| 601 | unsigned int i; |
| 602 | struct platform_device *fs_enet_dev; |
| 603 | struct resource res; |
| 604 | int ret; |
| 605 | |
| 606 | for (np = NULL, i = 0; |
| 607 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 608 | i++) { |
| 609 | struct resource r[4]; |
| 610 | struct device_node *phy, *mdio; |
| 611 | struct fs_platform_info fs_enet_data; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 612 | const unsigned int *id, *phy_addr, *phy_irq; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 613 | const void *mac_addr; |
| 614 | const phandle *ph; |
| 615 | const char *model; |
| 616 | |
| 617 | memset(r, 0, sizeof(r)); |
| 618 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 619 | |
| 620 | ret = of_address_to_resource(np, 0, &r[0]); |
| 621 | if (ret) |
| 622 | goto err; |
| 623 | r[0].name = fcc_regs; |
| 624 | |
| 625 | ret = of_address_to_resource(np, 1, &r[1]); |
| 626 | if (ret) |
| 627 | goto err; |
| 628 | r[1].name = fcc_pram; |
| 629 | |
| 630 | ret = of_address_to_resource(np, 2, &r[2]); |
| 631 | if (ret) |
| 632 | goto err; |
| 633 | r[2].name = fcc_regs_c; |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 634 | fs_enet_data.fcc_regs_c = r[2].start; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 635 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 636 | of_irq_to_resource(np, 0, &r[3]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 637 | |
| 638 | fs_enet_dev = |
| 639 | platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); |
| 640 | |
| 641 | if (IS_ERR(fs_enet_dev)) { |
| 642 | ret = PTR_ERR(fs_enet_dev); |
| 643 | goto err; |
| 644 | } |
| 645 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 646 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 647 | if (model == NULL) { |
| 648 | ret = -ENODEV; |
| 649 | goto unreg; |
| 650 | } |
| 651 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 652 | mac_addr = of_get_mac_address(np); |
| 653 | if (mac_addr) |
| 654 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 655 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 656 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 657 | phy = of_find_node_by_phandle(*ph); |
| 658 | |
| 659 | if (phy == NULL) { |
| 660 | ret = -ENODEV; |
| 661 | goto unreg; |
| 662 | } |
| 663 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 664 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 665 | fs_enet_data.phy_addr = *phy_addr; |
| 666 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 667 | phy_irq = of_get_property(phy, "interrupts", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 668 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 669 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 670 | fs_enet_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 671 | strcpy(fs_enet_data.fs_type, model); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 672 | |
| 673 | mdio = of_get_parent(phy); |
| 674 | ret = of_address_to_resource(mdio, 0, &res); |
| 675 | if (ret) { |
| 676 | of_node_put(phy); |
| 677 | of_node_put(mdio); |
| 678 | goto unreg; |
| 679 | } |
| 680 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 681 | fs_enet_data.clk_rx = *((u32 *)of_get_property(np, |
| 682 | "rx-clock", NULL)); |
| 683 | fs_enet_data.clk_tx = *((u32 *)of_get_property(np, |
| 684 | "tx-clock", NULL)); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 685 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 686 | if (strstr(model, "FCC")) { |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 687 | int fcc_index = *id - 1; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 688 | const unsigned char *mdio_bb_prop; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 689 | |
Vitaly Bordug | fc8e50e | 2006-09-21 22:37:58 +0400 | [diff] [blame] | 690 | fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 691 | fs_enet_data.rx_ring = 32; |
| 692 | fs_enet_data.tx_ring = 32; |
| 693 | fs_enet_data.rx_copybreak = 240; |
| 694 | fs_enet_data.use_napi = 0; |
| 695 | fs_enet_data.napi_weight = 17; |
| 696 | fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index); |
| 697 | fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index); |
| 698 | fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index); |
| 699 | |
| 700 | snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x", |
| 701 | (u32)res.start, fs_enet_data.phy_addr); |
| 702 | fs_enet_data.bus_id = (char*)&bus_id[(*id)]; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 703 | fs_enet_data.init_ioports = init_fcc_ioports; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 704 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 705 | mdio_bb_prop = of_get_property(phy, "bitbang", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 706 | if (mdio_bb_prop) { |
| 707 | struct platform_device *fs_enet_mdio_bb_dev; |
| 708 | struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 709 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 710 | fs_enet_mdio_bb_dev = |
| 711 | platform_device_register_simple("fsl-bb-mdio", |
| 712 | i, NULL, 0); |
| 713 | memset(&fs_enet_mdio_bb_data, 0, |
| 714 | sizeof(struct fs_mii_bb_platform_info)); |
| 715 | fs_enet_mdio_bb_data.mdio_dat.bit = |
| 716 | mdio_bb_prop[0]; |
| 717 | fs_enet_mdio_bb_data.mdio_dir.bit = |
| 718 | mdio_bb_prop[1]; |
| 719 | fs_enet_mdio_bb_data.mdc_dat.bit = |
| 720 | mdio_bb_prop[2]; |
| 721 | fs_enet_mdio_bb_data.mdio_port = |
| 722 | mdio_bb_prop[3]; |
| 723 | fs_enet_mdio_bb_data.mdc_port = |
| 724 | mdio_bb_prop[4]; |
| 725 | fs_enet_mdio_bb_data.delay = |
| 726 | mdio_bb_prop[5]; |
| 727 | |
| 728 | fs_enet_mdio_bb_data.irq[0] = phy_irq[0]; |
| 729 | fs_enet_mdio_bb_data.irq[1] = -1; |
| 730 | fs_enet_mdio_bb_data.irq[2] = -1; |
| 731 | fs_enet_mdio_bb_data.irq[3] = phy_irq[0]; |
| 732 | fs_enet_mdio_bb_data.irq[31] = -1; |
| 733 | |
| 734 | fs_enet_mdio_bb_data.mdio_dat.offset = |
| 735 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 736 | fs_enet_mdio_bb_data.mdio_dir.offset = |
| 737 | (u32)&cpm2_immr->im_ioport.iop_pdirc; |
| 738 | fs_enet_mdio_bb_data.mdc_dat.offset = |
| 739 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 740 | |
| 741 | ret = platform_device_add_data( |
| 742 | fs_enet_mdio_bb_dev, |
| 743 | &fs_enet_mdio_bb_data, |
| 744 | sizeof(struct fs_mii_bb_platform_info)); |
| 745 | if (ret) |
| 746 | goto unreg; |
| 747 | } |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 748 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 749 | of_node_put(phy); |
| 750 | of_node_put(mdio); |
| 751 | |
| 752 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 753 | sizeof(struct |
| 754 | fs_platform_info)); |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 755 | if (ret) |
| 756 | goto unreg; |
| 757 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 758 | } |
| 759 | return 0; |
| 760 | |
| 761 | unreg: |
| 762 | platform_device_unregister(fs_enet_dev); |
| 763 | err: |
| 764 | return ret; |
| 765 | } |
| 766 | |
| 767 | arch_initcall(fs_enet_of_init); |
| 768 | |
| 769 | static const char scc_regs[] = "regs"; |
| 770 | static const char scc_pram[] = "pram"; |
| 771 | |
| 772 | static int __init cpm_uart_of_init(void) |
| 773 | { |
| 774 | struct device_node *np; |
| 775 | unsigned int i; |
| 776 | struct platform_device *cpm_uart_dev; |
| 777 | int ret; |
| 778 | |
| 779 | for (np = NULL, i = 0; |
| 780 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 781 | i++) { |
| 782 | struct resource r[3]; |
| 783 | struct fs_uart_platform_info cpm_uart_data; |
| 784 | const int *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 785 | const char *model; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 786 | |
| 787 | memset(r, 0, sizeof(r)); |
| 788 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 789 | |
| 790 | ret = of_address_to_resource(np, 0, &r[0]); |
| 791 | if (ret) |
| 792 | goto err; |
| 793 | |
| 794 | r[0].name = scc_regs; |
| 795 | |
| 796 | ret = of_address_to_resource(np, 1, &r[1]); |
| 797 | if (ret) |
| 798 | goto err; |
| 799 | r[1].name = scc_pram; |
| 800 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 801 | of_irq_to_resource(np, 0, &r[2]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 802 | |
| 803 | cpm_uart_dev = |
| 804 | platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); |
| 805 | |
| 806 | if (IS_ERR(cpm_uart_dev)) { |
| 807 | ret = PTR_ERR(cpm_uart_dev); |
| 808 | goto err; |
| 809 | } |
| 810 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 811 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 812 | cpm_uart_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 813 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 814 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 815 | strcpy(cpm_uart_data.fs_type, model); |
| 816 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 817 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 818 | |
| 819 | cpm_uart_data.tx_num_fifo = 4; |
| 820 | cpm_uart_data.tx_buf_size = 32; |
| 821 | cpm_uart_data.rx_num_fifo = 4; |
| 822 | cpm_uart_data.rx_buf_size = 32; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 823 | cpm_uart_data.clk_rx = *((u32 *)of_get_property(np, |
| 824 | "rx-clock", NULL)); |
| 825 | cpm_uart_data.clk_tx = *((u32 *)of_get_property(np, |
| 826 | "tx-clock", NULL)); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 827 | |
| 828 | ret = |
| 829 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 830 | sizeof(struct |
| 831 | fs_uart_platform_info)); |
| 832 | if (ret) |
| 833 | goto unreg; |
| 834 | } |
| 835 | |
| 836 | return 0; |
| 837 | |
| 838 | unreg: |
| 839 | platform_device_unregister(cpm_uart_dev); |
| 840 | err: |
| 841 | return ret; |
| 842 | } |
| 843 | |
| 844 | arch_initcall(cpm_uart_of_init); |
| 845 | #endif /* CONFIG_CPM2 */ |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 846 | |
| 847 | #ifdef CONFIG_8xx |
| 848 | |
| 849 | extern void init_scc_ioports(struct fs_platform_info*); |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 850 | extern int platform_device_skip(const char *model, int id); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 851 | |
| 852 | static int __init fs_enet_mdio_of_init(void) |
| 853 | { |
| 854 | struct device_node *np; |
| 855 | unsigned int i; |
| 856 | struct platform_device *mdio_dev; |
| 857 | struct resource res; |
| 858 | int ret; |
| 859 | |
| 860 | for (np = NULL, i = 0; |
| 861 | (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL; |
| 862 | i++) { |
| 863 | struct fs_mii_fec_platform_info mdio_data; |
| 864 | |
| 865 | memset(&res, 0, sizeof(res)); |
| 866 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 867 | |
| 868 | ret = of_address_to_resource(np, 0, &res); |
| 869 | if (ret) |
| 870 | goto err; |
| 871 | |
| 872 | mdio_dev = |
| 873 | platform_device_register_simple("fsl-cpm-fec-mdio", |
| 874 | res.start, &res, 1); |
| 875 | if (IS_ERR(mdio_dev)) { |
| 876 | ret = PTR_ERR(mdio_dev); |
| 877 | goto err; |
| 878 | } |
| 879 | |
| 880 | mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1; |
| 881 | |
| 882 | ret = |
| 883 | platform_device_add_data(mdio_dev, &mdio_data, |
| 884 | sizeof(struct fs_mii_fec_platform_info)); |
| 885 | if (ret) |
| 886 | goto unreg; |
| 887 | } |
| 888 | return 0; |
| 889 | |
| 890 | unreg: |
| 891 | platform_device_unregister(mdio_dev); |
| 892 | err: |
| 893 | return ret; |
| 894 | } |
| 895 | |
| 896 | arch_initcall(fs_enet_mdio_of_init); |
| 897 | |
| 898 | static const char *enet_regs = "regs"; |
| 899 | static const char *enet_pram = "pram"; |
| 900 | static const char *enet_irq = "interrupt"; |
| 901 | static char bus_id[9][BUS_ID_SIZE]; |
| 902 | |
| 903 | static int __init fs_enet_of_init(void) |
| 904 | { |
| 905 | struct device_node *np; |
| 906 | unsigned int i; |
| 907 | struct platform_device *fs_enet_dev = NULL; |
| 908 | struct resource res; |
| 909 | int ret; |
| 910 | |
| 911 | for (np = NULL, i = 0; |
| 912 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 913 | i++) { |
| 914 | struct resource r[4]; |
| 915 | struct device_node *phy = NULL, *mdio = NULL; |
| 916 | struct fs_platform_info fs_enet_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 917 | const unsigned int *id; |
| 918 | const unsigned int *phy_addr; |
Scott Wood | b7a6912 | 2007-05-09 03:15:34 +1000 | [diff] [blame] | 919 | const void *mac_addr; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 920 | const phandle *ph; |
| 921 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 922 | |
| 923 | memset(r, 0, sizeof(r)); |
| 924 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 925 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 926 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 927 | if (model == NULL) { |
| 928 | ret = -ENODEV; |
| 929 | goto unreg; |
| 930 | } |
| 931 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 932 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 933 | fs_enet_data.fs_no = *id; |
| 934 | |
| 935 | if (platform_device_skip(model, *id)) |
| 936 | continue; |
| 937 | |
| 938 | ret = of_address_to_resource(np, 0, &r[0]); |
| 939 | if (ret) |
| 940 | goto err; |
| 941 | r[0].name = enet_regs; |
| 942 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 943 | mac_addr = of_get_mac_address(np); |
| 944 | if (mac_addr) |
| 945 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 946 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 947 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 948 | if (ph != NULL) |
| 949 | phy = of_find_node_by_phandle(*ph); |
| 950 | |
| 951 | if (phy != NULL) { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 952 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 953 | fs_enet_data.phy_addr = *phy_addr; |
| 954 | fs_enet_data.has_phy = 1; |
| 955 | |
| 956 | mdio = of_get_parent(phy); |
| 957 | ret = of_address_to_resource(mdio, 0, &res); |
| 958 | if (ret) { |
| 959 | of_node_put(phy); |
| 960 | of_node_put(mdio); |
| 961 | goto unreg; |
| 962 | } |
| 963 | } |
| 964 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 965 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 966 | strcpy(fs_enet_data.fs_type, model); |
| 967 | |
| 968 | if (strstr(model, "FEC")) { |
| 969 | r[1].start = r[1].end = irq_of_parse_and_map(np, 0); |
| 970 | r[1].flags = IORESOURCE_IRQ; |
| 971 | r[1].name = enet_irq; |
| 972 | |
| 973 | fs_enet_dev = |
| 974 | platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2); |
| 975 | |
| 976 | if (IS_ERR(fs_enet_dev)) { |
| 977 | ret = PTR_ERR(fs_enet_dev); |
| 978 | goto err; |
| 979 | } |
| 980 | |
| 981 | fs_enet_data.rx_ring = 128; |
| 982 | fs_enet_data.tx_ring = 16; |
| 983 | fs_enet_data.rx_copybreak = 240; |
| 984 | fs_enet_data.use_napi = 1; |
| 985 | fs_enet_data.napi_weight = 17; |
| 986 | |
| 987 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x", |
| 988 | (u32)res.start, fs_enet_data.phy_addr); |
| 989 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 990 | fs_enet_data.init_ioports = init_fec_ioports; |
| 991 | } |
| 992 | if (strstr(model, "SCC")) { |
| 993 | ret = of_address_to_resource(np, 1, &r[1]); |
| 994 | if (ret) |
| 995 | goto err; |
| 996 | r[1].name = enet_pram; |
| 997 | |
| 998 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 999 | r[2].flags = IORESOURCE_IRQ; |
| 1000 | r[2].name = enet_irq; |
| 1001 | |
| 1002 | fs_enet_dev = |
| 1003 | platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3); |
| 1004 | |
| 1005 | if (IS_ERR(fs_enet_dev)) { |
| 1006 | ret = PTR_ERR(fs_enet_dev); |
| 1007 | goto err; |
| 1008 | } |
| 1009 | |
| 1010 | fs_enet_data.rx_ring = 64; |
| 1011 | fs_enet_data.tx_ring = 8; |
| 1012 | fs_enet_data.rx_copybreak = 240; |
| 1013 | fs_enet_data.use_napi = 1; |
| 1014 | fs_enet_data.napi_weight = 17; |
| 1015 | |
| 1016 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1"); |
| 1017 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 1018 | fs_enet_data.init_ioports = init_scc_ioports; |
| 1019 | } |
| 1020 | |
| 1021 | of_node_put(phy); |
| 1022 | of_node_put(mdio); |
| 1023 | |
| 1024 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 1025 | sizeof(struct |
| 1026 | fs_platform_info)); |
| 1027 | if (ret) |
| 1028 | goto unreg; |
| 1029 | } |
| 1030 | return 0; |
| 1031 | |
| 1032 | unreg: |
| 1033 | platform_device_unregister(fs_enet_dev); |
| 1034 | err: |
| 1035 | return ret; |
| 1036 | } |
| 1037 | |
| 1038 | arch_initcall(fs_enet_of_init); |
| 1039 | |
Vitaly Bordug | 80128ff | 2007-07-09 11:37:35 -0700 | [diff] [blame] | 1040 | static int __init fsl_pcmcia_of_init(void) |
| 1041 | { |
| 1042 | struct device_node *np = NULL; |
| 1043 | /* |
| 1044 | * Register all the devices which type is "pcmcia" |
| 1045 | */ |
| 1046 | while ((np = of_find_compatible_node(np, |
| 1047 | "pcmcia", "fsl,pq-pcmcia")) != NULL) |
| 1048 | of_platform_device_create(np, "m8xx-pcmcia", NULL); |
| 1049 | return 0; |
| 1050 | } |
| 1051 | |
| 1052 | arch_initcall(fsl_pcmcia_of_init); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1053 | |
| 1054 | static const char *smc_regs = "regs"; |
| 1055 | static const char *smc_pram = "pram"; |
| 1056 | |
| 1057 | static int __init cpm_smc_uart_of_init(void) |
| 1058 | { |
| 1059 | struct device_node *np; |
| 1060 | unsigned int i; |
| 1061 | struct platform_device *cpm_uart_dev; |
| 1062 | int ret; |
| 1063 | |
| 1064 | for (np = NULL, i = 0; |
| 1065 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 1066 | i++) { |
| 1067 | struct resource r[3]; |
| 1068 | struct fs_uart_platform_info cpm_uart_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1069 | const int *id; |
| 1070 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1071 | |
| 1072 | memset(r, 0, sizeof(r)); |
| 1073 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 1074 | |
| 1075 | ret = of_address_to_resource(np, 0, &r[0]); |
| 1076 | if (ret) |
| 1077 | goto err; |
| 1078 | |
| 1079 | r[0].name = smc_regs; |
| 1080 | |
| 1081 | ret = of_address_to_resource(np, 1, &r[1]); |
| 1082 | if (ret) |
| 1083 | goto err; |
| 1084 | r[1].name = smc_pram; |
| 1085 | |
| 1086 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 1087 | r[2].flags = IORESOURCE_IRQ; |
| 1088 | |
| 1089 | cpm_uart_dev = |
| 1090 | platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3); |
| 1091 | |
| 1092 | if (IS_ERR(cpm_uart_dev)) { |
| 1093 | ret = PTR_ERR(cpm_uart_dev); |
| 1094 | goto err; |
| 1095 | } |
| 1096 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1097 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1098 | strcpy(cpm_uart_data.fs_type, model); |
| 1099 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1100 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1101 | cpm_uart_data.fs_no = *id; |
| 1102 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 1103 | |
| 1104 | cpm_uart_data.tx_num_fifo = 4; |
| 1105 | cpm_uart_data.tx_buf_size = 32; |
| 1106 | cpm_uart_data.rx_num_fifo = 4; |
| 1107 | cpm_uart_data.rx_buf_size = 32; |
| 1108 | |
| 1109 | ret = |
| 1110 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 1111 | sizeof(struct |
| 1112 | fs_uart_platform_info)); |
| 1113 | if (ret) |
| 1114 | goto unreg; |
| 1115 | } |
| 1116 | |
| 1117 | return 0; |
| 1118 | |
| 1119 | unreg: |
| 1120 | platform_device_unregister(cpm_uart_dev); |
| 1121 | err: |
| 1122 | return ret; |
| 1123 | } |
| 1124 | |
| 1125 | arch_initcall(cpm_smc_uart_of_init); |
| 1126 | |
| 1127 | #endif /* CONFIG_8xx */ |