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 | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 41 | extern void init_scc_ioports(struct fs_uart_platform_info*); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 42 | static phys_addr_t immrbase = -1; |
| 43 | |
| 44 | phys_addr_t get_immrbase(void) |
| 45 | { |
| 46 | struct device_node *soc; |
| 47 | |
| 48 | if (immrbase != -1) |
| 49 | return immrbase; |
| 50 | |
| 51 | soc = of_find_node_by_type(NULL, "soc"); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 52 | if (soc) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 53 | unsigned int size; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 54 | const void *prop = get_property(soc, "reg", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 55 | |
| 56 | if (prop) |
| 57 | immrbase = of_translate_address(soc, prop); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 58 | of_node_put(soc); |
| 59 | }; |
| 60 | |
| 61 | return immrbase; |
| 62 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 63 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 64 | EXPORT_SYMBOL(get_immrbase); |
| 65 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 66 | #ifdef CONFIG_CPM2 |
| 67 | |
| 68 | static u32 brgfreq = -1; |
| 69 | |
| 70 | u32 get_brgfreq(void) |
| 71 | { |
| 72 | struct device_node *node; |
| 73 | |
| 74 | if (brgfreq != -1) |
| 75 | return brgfreq; |
| 76 | |
| 77 | node = of_find_node_by_type(NULL, "cpm"); |
| 78 | if (node) { |
| 79 | unsigned int size; |
| 80 | const unsigned int *prop = get_property(node, "brg-frequency", |
| 81 | &size); |
| 82 | |
| 83 | if (prop) |
| 84 | brgfreq = *prop; |
| 85 | of_node_put(node); |
| 86 | }; |
| 87 | |
| 88 | return brgfreq; |
| 89 | } |
| 90 | |
| 91 | EXPORT_SYMBOL(get_brgfreq); |
| 92 | |
| 93 | static u32 fs_baudrate = -1; |
| 94 | |
| 95 | u32 get_baudrate(void) |
| 96 | { |
| 97 | struct device_node *node; |
| 98 | |
| 99 | if (fs_baudrate != -1) |
| 100 | return fs_baudrate; |
| 101 | |
| 102 | node = of_find_node_by_type(NULL, "serial"); |
| 103 | if (node) { |
| 104 | unsigned int size; |
| 105 | const unsigned int *prop = get_property(node, "current-speed", |
| 106 | &size); |
| 107 | |
| 108 | if (prop) |
| 109 | fs_baudrate = *prop; |
| 110 | of_node_put(node); |
| 111 | }; |
| 112 | |
| 113 | return fs_baudrate; |
| 114 | } |
| 115 | |
| 116 | EXPORT_SYMBOL(get_baudrate); |
| 117 | #endif /* CONFIG_CPM2 */ |
| 118 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 119 | static int __init gfar_mdio_of_init(void) |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 120 | { |
| 121 | struct device_node *np; |
| 122 | unsigned int i; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 123 | struct platform_device *mdio_dev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 124 | struct resource res; |
| 125 | int ret; |
| 126 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 127 | for (np = NULL, i = 0; |
| 128 | (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL; |
| 129 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 130 | int k; |
| 131 | struct device_node *child = NULL; |
| 132 | struct gianfar_mdio_data mdio_data; |
| 133 | |
| 134 | memset(&res, 0, sizeof(res)); |
| 135 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 136 | |
| 137 | ret = of_address_to_resource(np, 0, &res); |
| 138 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 139 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 140 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 141 | mdio_dev = |
| 142 | platform_device_register_simple("fsl-gianfar_mdio", |
| 143 | res.start, &res, 1); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 144 | if (IS_ERR(mdio_dev)) { |
| 145 | ret = PTR_ERR(mdio_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 146 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | for (k = 0; k < 32; k++) |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 150 | mdio_data.irq[k] = PHY_POLL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 151 | |
| 152 | while ((child = of_get_next_child(np, child)) != NULL) { |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 153 | int irq = irq_of_parse_and_map(child, 0); |
| 154 | if (irq != NO_IRQ) { |
| 155 | const u32 *id = get_property(child, "reg", NULL); |
| 156 | mdio_data.irq[*id] = irq; |
| 157 | } |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 158 | } |
| 159 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 160 | ret = |
| 161 | platform_device_add_data(mdio_dev, &mdio_data, |
| 162 | sizeof(struct gianfar_mdio_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 163 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 164 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 165 | } |
| 166 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 167 | return 0; |
| 168 | |
| 169 | unreg: |
| 170 | platform_device_unregister(mdio_dev); |
| 171 | err: |
| 172 | return ret; |
| 173 | } |
| 174 | |
| 175 | arch_initcall(gfar_mdio_of_init); |
| 176 | |
| 177 | static const char *gfar_tx_intr = "tx"; |
| 178 | static const char *gfar_rx_intr = "rx"; |
| 179 | static const char *gfar_err_intr = "error"; |
| 180 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 181 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 182 | static int __init gfar_of_init(void) |
| 183 | { |
| 184 | struct device_node *np; |
| 185 | unsigned int i; |
| 186 | struct platform_device *gfar_dev; |
| 187 | struct resource res; |
| 188 | int ret; |
| 189 | |
| 190 | for (np = NULL, i = 0; |
| 191 | (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; |
| 192 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 193 | struct resource r[4]; |
| 194 | struct device_node *phy, *mdio; |
| 195 | struct gianfar_platform_data gfar_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 196 | const unsigned int *id; |
| 197 | const char *model; |
| 198 | const void *mac_addr; |
| 199 | const phandle *ph; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 200 | int n_res = 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 201 | |
| 202 | memset(r, 0, sizeof(r)); |
| 203 | memset(&gfar_data, 0, sizeof(gfar_data)); |
| 204 | |
| 205 | ret = of_address_to_resource(np, 0, &r[0]); |
| 206 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 207 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 208 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 209 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 210 | |
| 211 | model = get_property(np, "model", NULL); |
| 212 | |
| 213 | /* If we aren't the FEC we have multiple interrupts */ |
| 214 | if (model && strcasecmp(model, "FEC")) { |
| 215 | r[1].name = gfar_tx_intr; |
| 216 | |
| 217 | r[2].name = gfar_rx_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 218 | of_irq_to_resource(np, 1, &r[2]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 219 | |
| 220 | r[3].name = gfar_err_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 221 | of_irq_to_resource(np, 2, &r[3]); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 222 | |
| 223 | n_res += 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 224 | } |
| 225 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 226 | gfar_dev = |
| 227 | platform_device_register_simple("fsl-gianfar", i, &r[0], |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 228 | n_res); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 229 | |
| 230 | if (IS_ERR(gfar_dev)) { |
| 231 | ret = PTR_ERR(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 232 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 233 | } |
| 234 | |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 235 | mac_addr = get_property(np, "local-mac-address", NULL); |
| 236 | if (mac_addr == NULL) |
| 237 | mac_addr = get_property(np, "mac-address", NULL); |
| 238 | if (mac_addr == NULL) { |
| 239 | /* Obsolete */ |
| 240 | mac_addr = get_property(np, "address", NULL); |
| 241 | } |
| 242 | |
| 243 | if (mac_addr) |
| 244 | memcpy(gfar_data.mac_addr, mac_addr, 6); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 245 | |
| 246 | if (model && !strcasecmp(model, "TSEC")) |
| 247 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 248 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 249 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 250 | FSL_GIANFAR_DEV_HAS_RMON | |
| 251 | FSL_GIANFAR_DEV_HAS_MULTI_INTR; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 252 | if (model && !strcasecmp(model, "eTSEC")) |
| 253 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 254 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 255 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 256 | FSL_GIANFAR_DEV_HAS_RMON | |
| 257 | FSL_GIANFAR_DEV_HAS_MULTI_INTR | |
| 258 | FSL_GIANFAR_DEV_HAS_CSUM | |
| 259 | FSL_GIANFAR_DEV_HAS_VLAN | |
| 260 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 261 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 262 | ph = get_property(np, "phy-handle", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 263 | phy = of_find_node_by_phandle(*ph); |
| 264 | |
| 265 | if (phy == NULL) { |
| 266 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 267 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | mdio = of_get_parent(phy); |
| 271 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 272 | id = get_property(phy, "reg", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 273 | ret = of_address_to_resource(mdio, 0, &res); |
| 274 | if (ret) { |
| 275 | of_node_put(phy); |
| 276 | of_node_put(mdio); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 277 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | gfar_data.phy_id = *id; |
| 281 | gfar_data.bus_id = res.start; |
| 282 | |
| 283 | of_node_put(phy); |
| 284 | of_node_put(mdio); |
| 285 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 286 | ret = |
| 287 | platform_device_add_data(gfar_dev, &gfar_data, |
| 288 | sizeof(struct |
| 289 | gianfar_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 290 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 291 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | return 0; |
| 295 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 296 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 297 | platform_device_unregister(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 298 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 299 | return ret; |
| 300 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 301 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 302 | arch_initcall(gfar_of_init); |
| 303 | |
| 304 | static int __init fsl_i2c_of_init(void) |
| 305 | { |
| 306 | struct device_node *np; |
| 307 | unsigned int i; |
| 308 | struct platform_device *i2c_dev; |
| 309 | int ret; |
| 310 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 311 | for (np = NULL, i = 0; |
| 312 | (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; |
| 313 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 314 | struct resource r[2]; |
| 315 | struct fsl_i2c_platform_data i2c_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 316 | const unsigned char *flags = NULL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 317 | |
| 318 | memset(&r, 0, sizeof(r)); |
| 319 | memset(&i2c_data, 0, sizeof(i2c_data)); |
| 320 | |
| 321 | ret = of_address_to_resource(np, 0, &r[0]); |
| 322 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 323 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 324 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 325 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 326 | |
| 327 | i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); |
| 328 | if (IS_ERR(i2c_dev)) { |
| 329 | ret = PTR_ERR(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 330 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | i2c_data.device_flags = 0; |
| 334 | flags = get_property(np, "dfsrr", NULL); |
| 335 | if (flags) |
| 336 | i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; |
| 337 | |
| 338 | flags = get_property(np, "fsl5200-clocking", NULL); |
| 339 | if (flags) |
| 340 | i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; |
| 341 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 342 | ret = |
| 343 | platform_device_add_data(i2c_dev, &i2c_data, |
| 344 | sizeof(struct |
| 345 | fsl_i2c_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 346 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 347 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | return 0; |
| 351 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 352 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 353 | platform_device_unregister(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 354 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 355 | return ret; |
| 356 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 357 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 358 | arch_initcall(fsl_i2c_of_init); |
| 359 | |
| 360 | #ifdef CONFIG_PPC_83xx |
| 361 | static int __init mpc83xx_wdt_init(void) |
| 362 | { |
| 363 | struct resource r; |
| 364 | struct device_node *soc, *np; |
| 365 | struct platform_device *dev; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 366 | const unsigned int *freq; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 367 | int ret; |
| 368 | |
| 369 | np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); |
| 370 | |
| 371 | if (!np) { |
| 372 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 373 | goto nodev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | soc = of_find_node_by_type(NULL, "soc"); |
| 377 | |
| 378 | if (!soc) { |
| 379 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 380 | goto nosoc; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 381 | } |
| 382 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 383 | freq = get_property(soc, "bus-frequency", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 384 | if (!freq) { |
| 385 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 386 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | memset(&r, 0, sizeof(r)); |
| 390 | |
| 391 | ret = of_address_to_resource(np, 0, &r); |
| 392 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 393 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 394 | |
| 395 | dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); |
| 396 | if (IS_ERR(dev)) { |
| 397 | ret = PTR_ERR(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 398 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | ret = platform_device_add_data(dev, freq, sizeof(int)); |
| 402 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 403 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 404 | |
| 405 | of_node_put(soc); |
| 406 | of_node_put(np); |
| 407 | |
| 408 | return 0; |
| 409 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 410 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 411 | platform_device_unregister(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 412 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 413 | of_node_put(soc); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 414 | nosoc: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 415 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 416 | nodev: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 417 | return ret; |
| 418 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 419 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 420 | arch_initcall(mpc83xx_wdt_init); |
| 421 | #endif |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 422 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 423 | 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] | 424 | { |
| 425 | if (!phy_type) |
| 426 | return FSL_USB2_PHY_NONE; |
| 427 | if (!strcasecmp(phy_type, "ulpi")) |
| 428 | return FSL_USB2_PHY_ULPI; |
| 429 | if (!strcasecmp(phy_type, "utmi")) |
| 430 | return FSL_USB2_PHY_UTMI; |
| 431 | if (!strcasecmp(phy_type, "utmi_wide")) |
| 432 | return FSL_USB2_PHY_UTMI_WIDE; |
| 433 | if (!strcasecmp(phy_type, "serial")) |
| 434 | return FSL_USB2_PHY_SERIAL; |
| 435 | |
| 436 | return FSL_USB2_PHY_NONE; |
| 437 | } |
| 438 | |
| 439 | static int __init fsl_usb_of_init(void) |
| 440 | { |
| 441 | struct device_node *np; |
| 442 | unsigned int i; |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 443 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 444 | int ret; |
| 445 | |
| 446 | for (np = NULL, i = 0; |
| 447 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL; |
| 448 | i++) { |
| 449 | struct resource r[2]; |
| 450 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 451 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 452 | |
| 453 | memset(&r, 0, sizeof(r)); |
| 454 | memset(&usb_data, 0, sizeof(usb_data)); |
| 455 | |
| 456 | ret = of_address_to_resource(np, 0, &r[0]); |
| 457 | if (ret) |
| 458 | goto err; |
| 459 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 460 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 461 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 462 | usb_dev_mph = |
| 463 | platform_device_register_simple("fsl-ehci", i, r, 2); |
| 464 | if (IS_ERR(usb_dev_mph)) { |
| 465 | ret = PTR_ERR(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 466 | goto err; |
| 467 | } |
| 468 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 469 | usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL; |
| 470 | 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] | 471 | |
| 472 | usb_data.operating_mode = FSL_USB2_MPH_HOST; |
| 473 | |
| 474 | prop = get_property(np, "port0", NULL); |
| 475 | if (prop) |
| 476 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; |
| 477 | |
| 478 | prop = get_property(np, "port1", NULL); |
| 479 | if (prop) |
| 480 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; |
| 481 | |
| 482 | prop = get_property(np, "phy_type", NULL); |
| 483 | usb_data.phy_mode = determine_usb_phy(prop); |
| 484 | |
| 485 | ret = |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 486 | platform_device_add_data(usb_dev_mph, &usb_data, |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 487 | sizeof(struct |
| 488 | fsl_usb2_platform_data)); |
| 489 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 490 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 491 | } |
| 492 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 493 | for (np = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 494 | (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL; |
| 495 | i++) { |
| 496 | struct resource r[2]; |
| 497 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 498 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 499 | |
| 500 | memset(&r, 0, sizeof(r)); |
| 501 | memset(&usb_data, 0, sizeof(usb_data)); |
| 502 | |
| 503 | ret = of_address_to_resource(np, 0, &r[0]); |
| 504 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 505 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 506 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 507 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 508 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 509 | usb_dev_dr = |
| 510 | platform_device_register_simple("fsl-ehci", i, r, 2); |
| 511 | if (IS_ERR(usb_dev_dr)) { |
| 512 | ret = PTR_ERR(usb_dev_dr); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 513 | goto err; |
| 514 | } |
| 515 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 516 | usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL; |
| 517 | usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 518 | |
| 519 | usb_data.operating_mode = FSL_USB2_DR_HOST; |
| 520 | |
| 521 | prop = get_property(np, "phy_type", NULL); |
| 522 | usb_data.phy_mode = determine_usb_phy(prop); |
| 523 | |
| 524 | ret = |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 525 | platform_device_add_data(usb_dev_dr, &usb_data, |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 526 | sizeof(struct |
| 527 | fsl_usb2_platform_data)); |
| 528 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 529 | goto unreg_dr; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 530 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 531 | return 0; |
| 532 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 533 | unreg_dr: |
| 534 | if (usb_dev_dr) |
| 535 | platform_device_unregister(usb_dev_dr); |
| 536 | unreg_mph: |
| 537 | if (usb_dev_mph) |
| 538 | platform_device_unregister(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 539 | err: |
| 540 | return ret; |
| 541 | } |
| 542 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 543 | arch_initcall(fsl_usb_of_init); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 544 | |
| 545 | #ifdef CONFIG_CPM2 |
| 546 | |
| 547 | static const char fcc_regs[] = "fcc_regs"; |
| 548 | static const char fcc_regs_c[] = "fcc_regs_c"; |
| 549 | static const char fcc_pram[] = "fcc_pram"; |
| 550 | static char bus_id[9][BUS_ID_SIZE]; |
| 551 | |
| 552 | static int __init fs_enet_of_init(void) |
| 553 | { |
| 554 | struct device_node *np; |
| 555 | unsigned int i; |
| 556 | struct platform_device *fs_enet_dev; |
| 557 | struct resource res; |
| 558 | int ret; |
| 559 | |
| 560 | for (np = NULL, i = 0; |
| 561 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 562 | i++) { |
| 563 | struct resource r[4]; |
| 564 | struct device_node *phy, *mdio; |
| 565 | struct fs_platform_info fs_enet_data; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 566 | const unsigned int *id, *phy_addr, *phy_irq; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 567 | const void *mac_addr; |
| 568 | const phandle *ph; |
| 569 | const char *model; |
| 570 | |
| 571 | memset(r, 0, sizeof(r)); |
| 572 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 573 | |
| 574 | ret = of_address_to_resource(np, 0, &r[0]); |
| 575 | if (ret) |
| 576 | goto err; |
| 577 | r[0].name = fcc_regs; |
| 578 | |
| 579 | ret = of_address_to_resource(np, 1, &r[1]); |
| 580 | if (ret) |
| 581 | goto err; |
| 582 | r[1].name = fcc_pram; |
| 583 | |
| 584 | ret = of_address_to_resource(np, 2, &r[2]); |
| 585 | if (ret) |
| 586 | goto err; |
| 587 | r[2].name = fcc_regs_c; |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 588 | fs_enet_data.fcc_regs_c = r[2].start; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 589 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 590 | of_irq_to_resource(np, 0, &r[3]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 591 | |
| 592 | fs_enet_dev = |
| 593 | platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); |
| 594 | |
| 595 | if (IS_ERR(fs_enet_dev)) { |
| 596 | ret = PTR_ERR(fs_enet_dev); |
| 597 | goto err; |
| 598 | } |
| 599 | |
| 600 | model = get_property(np, "model", NULL); |
| 601 | if (model == NULL) { |
| 602 | ret = -ENODEV; |
| 603 | goto unreg; |
| 604 | } |
| 605 | |
| 606 | mac_addr = get_property(np, "mac-address", NULL); |
| 607 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
| 608 | |
| 609 | ph = get_property(np, "phy-handle", NULL); |
| 610 | phy = of_find_node_by_phandle(*ph); |
| 611 | |
| 612 | if (phy == NULL) { |
| 613 | ret = -ENODEV; |
| 614 | goto unreg; |
| 615 | } |
| 616 | |
| 617 | phy_addr = get_property(phy, "reg", NULL); |
| 618 | fs_enet_data.phy_addr = *phy_addr; |
| 619 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 620 | phy_irq = get_property(phy, "interrupts", NULL); |
| 621 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 622 | id = get_property(np, "device-id", NULL); |
| 623 | fs_enet_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 624 | strcpy(fs_enet_data.fs_type, model); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 625 | |
| 626 | mdio = of_get_parent(phy); |
| 627 | ret = of_address_to_resource(mdio, 0, &res); |
| 628 | if (ret) { |
| 629 | of_node_put(phy); |
| 630 | of_node_put(mdio); |
| 631 | goto unreg; |
| 632 | } |
| 633 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 634 | fs_enet_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL)); |
| 635 | fs_enet_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL)); |
| 636 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 637 | if (strstr(model, "FCC")) { |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 638 | int fcc_index = *id - 1; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 639 | const unsigned char *mdio_bb_prop; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 640 | |
Vitaly Bordug | fc8e50e | 2006-09-21 22:37:58 +0400 | [diff] [blame] | 641 | fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 642 | fs_enet_data.rx_ring = 32; |
| 643 | fs_enet_data.tx_ring = 32; |
| 644 | fs_enet_data.rx_copybreak = 240; |
| 645 | fs_enet_data.use_napi = 0; |
| 646 | fs_enet_data.napi_weight = 17; |
| 647 | fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index); |
| 648 | fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index); |
| 649 | fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index); |
| 650 | |
| 651 | snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x", |
| 652 | (u32)res.start, fs_enet_data.phy_addr); |
| 653 | fs_enet_data.bus_id = (char*)&bus_id[(*id)]; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 654 | fs_enet_data.init_ioports = init_fcc_ioports; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 655 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 656 | mdio_bb_prop = get_property(phy, "bitbang", NULL); |
| 657 | if (mdio_bb_prop) { |
| 658 | struct platform_device *fs_enet_mdio_bb_dev; |
| 659 | struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 660 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 661 | fs_enet_mdio_bb_dev = |
| 662 | platform_device_register_simple("fsl-bb-mdio", |
| 663 | i, NULL, 0); |
| 664 | memset(&fs_enet_mdio_bb_data, 0, |
| 665 | sizeof(struct fs_mii_bb_platform_info)); |
| 666 | fs_enet_mdio_bb_data.mdio_dat.bit = |
| 667 | mdio_bb_prop[0]; |
| 668 | fs_enet_mdio_bb_data.mdio_dir.bit = |
| 669 | mdio_bb_prop[1]; |
| 670 | fs_enet_mdio_bb_data.mdc_dat.bit = |
| 671 | mdio_bb_prop[2]; |
| 672 | fs_enet_mdio_bb_data.mdio_port = |
| 673 | mdio_bb_prop[3]; |
| 674 | fs_enet_mdio_bb_data.mdc_port = |
| 675 | mdio_bb_prop[4]; |
| 676 | fs_enet_mdio_bb_data.delay = |
| 677 | mdio_bb_prop[5]; |
| 678 | |
| 679 | fs_enet_mdio_bb_data.irq[0] = phy_irq[0]; |
| 680 | fs_enet_mdio_bb_data.irq[1] = -1; |
| 681 | fs_enet_mdio_bb_data.irq[2] = -1; |
| 682 | fs_enet_mdio_bb_data.irq[3] = phy_irq[0]; |
| 683 | fs_enet_mdio_bb_data.irq[31] = -1; |
| 684 | |
| 685 | fs_enet_mdio_bb_data.mdio_dat.offset = |
| 686 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 687 | fs_enet_mdio_bb_data.mdio_dir.offset = |
| 688 | (u32)&cpm2_immr->im_ioport.iop_pdirc; |
| 689 | fs_enet_mdio_bb_data.mdc_dat.offset = |
| 690 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 691 | |
| 692 | ret = platform_device_add_data( |
| 693 | fs_enet_mdio_bb_dev, |
| 694 | &fs_enet_mdio_bb_data, |
| 695 | sizeof(struct fs_mii_bb_platform_info)); |
| 696 | if (ret) |
| 697 | goto unreg; |
| 698 | } |
| 699 | |
| 700 | of_node_put(phy); |
| 701 | of_node_put(mdio); |
| 702 | |
| 703 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 704 | sizeof(struct |
| 705 | fs_platform_info)); |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 706 | if (ret) |
| 707 | goto unreg; |
| 708 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 709 | } |
| 710 | return 0; |
| 711 | |
| 712 | unreg: |
| 713 | platform_device_unregister(fs_enet_dev); |
| 714 | err: |
| 715 | return ret; |
| 716 | } |
| 717 | |
| 718 | arch_initcall(fs_enet_of_init); |
| 719 | |
| 720 | static const char scc_regs[] = "regs"; |
| 721 | static const char scc_pram[] = "pram"; |
| 722 | |
| 723 | static int __init cpm_uart_of_init(void) |
| 724 | { |
| 725 | struct device_node *np; |
| 726 | unsigned int i; |
| 727 | struct platform_device *cpm_uart_dev; |
| 728 | int ret; |
| 729 | |
| 730 | for (np = NULL, i = 0; |
| 731 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 732 | i++) { |
| 733 | struct resource r[3]; |
| 734 | struct fs_uart_platform_info cpm_uart_data; |
| 735 | const int *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 736 | const char *model; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 737 | |
| 738 | memset(r, 0, sizeof(r)); |
| 739 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 740 | |
| 741 | ret = of_address_to_resource(np, 0, &r[0]); |
| 742 | if (ret) |
| 743 | goto err; |
| 744 | |
| 745 | r[0].name = scc_regs; |
| 746 | |
| 747 | ret = of_address_to_resource(np, 1, &r[1]); |
| 748 | if (ret) |
| 749 | goto err; |
| 750 | r[1].name = scc_pram; |
| 751 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 752 | of_irq_to_resource(np, 0, &r[2]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 753 | |
| 754 | cpm_uart_dev = |
| 755 | platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); |
| 756 | |
| 757 | if (IS_ERR(cpm_uart_dev)) { |
| 758 | ret = PTR_ERR(cpm_uart_dev); |
| 759 | goto err; |
| 760 | } |
| 761 | |
| 762 | id = get_property(np, "device-id", NULL); |
| 763 | cpm_uart_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 764 | |
| 765 | model = (char*)get_property(np, "model", NULL); |
| 766 | strcpy(cpm_uart_data.fs_type, model); |
| 767 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 768 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 769 | |
| 770 | cpm_uart_data.tx_num_fifo = 4; |
| 771 | cpm_uart_data.tx_buf_size = 32; |
| 772 | cpm_uart_data.rx_num_fifo = 4; |
| 773 | cpm_uart_data.rx_buf_size = 32; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 774 | cpm_uart_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL)); |
| 775 | cpm_uart_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL)); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 776 | |
| 777 | ret = |
| 778 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 779 | sizeof(struct |
| 780 | fs_uart_platform_info)); |
| 781 | if (ret) |
| 782 | goto unreg; |
| 783 | } |
| 784 | |
| 785 | return 0; |
| 786 | |
| 787 | unreg: |
| 788 | platform_device_unregister(cpm_uart_dev); |
| 789 | err: |
| 790 | return ret; |
| 791 | } |
| 792 | |
| 793 | arch_initcall(cpm_uart_of_init); |
| 794 | #endif /* CONFIG_CPM2 */ |