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> |
Kumar Gala | 0af666f | 2007-08-17 08:23:06 -0500 | [diff] [blame] | 25 | #include <linux/of_platform.h> |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 26 | #include <linux/phy.h> |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 27 | #include <linux/phy_fixed.h> |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 28 | #include <linux/spi/spi.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 29 | #include <linux/fsl_devices.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 30 | #include <linux/fs_enet_pd.h> |
| 31 | #include <linux/fs_uart_pd.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 32 | |
| 33 | #include <asm/system.h> |
| 34 | #include <asm/atomic.h> |
| 35 | #include <asm/io.h> |
| 36 | #include <asm/irq.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 37 | #include <asm/time.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 38 | #include <asm/prom.h> |
| 39 | #include <sysdev/fsl_soc.h> |
| 40 | #include <mm/mmu_decl.h> |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 41 | #include <asm/cpm2.h> |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 42 | |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 43 | extern void init_fcc_ioports(struct fs_platform_info*); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 44 | extern void init_fec_ioports(struct fs_platform_info*); |
| 45 | extern void init_smc_ioports(struct fs_uart_platform_info*); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 46 | static phys_addr_t immrbase = -1; |
| 47 | |
| 48 | phys_addr_t get_immrbase(void) |
| 49 | { |
| 50 | struct device_node *soc; |
| 51 | |
| 52 | if (immrbase != -1) |
| 53 | return immrbase; |
| 54 | |
| 55 | soc = of_find_node_by_type(NULL, "soc"); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 56 | if (soc) { |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 57 | int size; |
Scott Wood | 6c7e072 | 2008-01-14 10:29:35 -0600 | [diff] [blame] | 58 | u32 naddr; |
| 59 | const u32 *prop = of_get_property(soc, "#address-cells", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 60 | |
Scott Wood | 6c7e072 | 2008-01-14 10:29:35 -0600 | [diff] [blame] | 61 | if (prop && size == 4) |
| 62 | naddr = *prop; |
| 63 | else |
| 64 | naddr = 2; |
| 65 | |
| 66 | prop = of_get_property(soc, "ranges", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 67 | if (prop) |
Scott Wood | 6c7e072 | 2008-01-14 10:29:35 -0600 | [diff] [blame] | 68 | immrbase = of_translate_address(soc, prop + naddr); |
| 69 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 70 | of_node_put(soc); |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 71 | } |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 72 | |
| 73 | return immrbase; |
| 74 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 75 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 76 | EXPORT_SYMBOL(get_immrbase); |
| 77 | |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 78 | #if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx) |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 79 | |
| 80 | static u32 brgfreq = -1; |
| 81 | |
| 82 | u32 get_brgfreq(void) |
| 83 | { |
| 84 | struct device_node *node; |
Scott Wood | 6d817aa | 2007-08-29 15:08:40 -0500 | [diff] [blame] | 85 | const unsigned int *prop; |
| 86 | int size; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 87 | |
| 88 | if (brgfreq != -1) |
| 89 | return brgfreq; |
| 90 | |
Scott Wood | 6d817aa | 2007-08-29 15:08:40 -0500 | [diff] [blame] | 91 | node = of_find_compatible_node(NULL, NULL, "fsl,cpm-brg"); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 92 | if (node) { |
Scott Wood | 6d817aa | 2007-08-29 15:08:40 -0500 | [diff] [blame] | 93 | prop = of_get_property(node, "clock-frequency", &size); |
| 94 | if (prop && size == 4) |
| 95 | brgfreq = *prop; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 96 | |
Scott Wood | 6d817aa | 2007-08-29 15:08:40 -0500 | [diff] [blame] | 97 | of_node_put(node); |
| 98 | return brgfreq; |
| 99 | } |
| 100 | |
| 101 | /* Legacy device binding -- will go away when no users are left. */ |
| 102 | node = of_find_node_by_type(NULL, "cpm"); |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 103 | if (!node) |
| 104 | node = of_find_compatible_node(NULL, NULL, "fsl,qe"); |
| 105 | if (!node) |
| 106 | node = of_find_node_by_type(NULL, "qe"); |
| 107 | |
Scott Wood | 6d817aa | 2007-08-29 15:08:40 -0500 | [diff] [blame] | 108 | if (node) { |
| 109 | prop = of_get_property(node, "brg-frequency", &size); |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 110 | if (prop && size == 4) |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 111 | brgfreq = *prop; |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 112 | |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 113 | if (brgfreq == -1 || brgfreq == 0) { |
| 114 | prop = of_get_property(node, "bus-frequency", &size); |
| 115 | if (prop && size == 4) |
| 116 | brgfreq = *prop / 2; |
| 117 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 118 | of_node_put(node); |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 119 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 120 | |
| 121 | return brgfreq; |
| 122 | } |
| 123 | |
| 124 | EXPORT_SYMBOL(get_brgfreq); |
| 125 | |
| 126 | static u32 fs_baudrate = -1; |
| 127 | |
| 128 | u32 get_baudrate(void) |
| 129 | { |
| 130 | struct device_node *node; |
| 131 | |
| 132 | if (fs_baudrate != -1) |
| 133 | return fs_baudrate; |
| 134 | |
| 135 | node = of_find_node_by_type(NULL, "serial"); |
| 136 | if (node) { |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 137 | int size; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 138 | const unsigned int *prop = of_get_property(node, |
| 139 | "current-speed", &size); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 140 | |
| 141 | if (prop) |
| 142 | fs_baudrate = *prop; |
| 143 | of_node_put(node); |
Scott Wood | f923473 | 2007-08-20 11:38:12 -0500 | [diff] [blame] | 144 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 145 | |
| 146 | return fs_baudrate; |
| 147 | } |
| 148 | |
| 149 | EXPORT_SYMBOL(get_baudrate); |
| 150 | #endif /* CONFIG_CPM2 */ |
| 151 | |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 152 | #ifdef CONFIG_FIXED_PHY |
| 153 | static int __init of_add_fixed_phys(void) |
| 154 | { |
| 155 | int ret; |
| 156 | struct device_node *np; |
| 157 | u32 *fixed_link; |
| 158 | struct fixed_phy_status status = {}; |
| 159 | |
| 160 | for_each_node_by_name(np, "ethernet") { |
| 161 | fixed_link = (u32 *)of_get_property(np, "fixed-link", NULL); |
| 162 | if (!fixed_link) |
| 163 | continue; |
| 164 | |
| 165 | status.link = 1; |
| 166 | status.duplex = fixed_link[1]; |
| 167 | status.speed = fixed_link[2]; |
| 168 | status.pause = fixed_link[3]; |
| 169 | status.asym_pause = fixed_link[4]; |
| 170 | |
| 171 | ret = fixed_phy_add(PHY_POLL, fixed_link[0], &status); |
| 172 | if (ret) { |
| 173 | of_node_put(np); |
| 174 | return ret; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return 0; |
| 179 | } |
| 180 | arch_initcall(of_add_fixed_phys); |
| 181 | #endif /* CONFIG_FIXED_PHY */ |
| 182 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 183 | static int __init gfar_mdio_of_init(void) |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 184 | { |
Kumar Gala | e77b28e | 2007-12-12 00:28:35 -0600 | [diff] [blame] | 185 | struct device_node *np = NULL; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 186 | struct platform_device *mdio_dev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 187 | struct resource res; |
| 188 | int ret; |
| 189 | |
Kumar Gala | e77b28e | 2007-12-12 00:28:35 -0600 | [diff] [blame] | 190 | np = of_find_compatible_node(np, NULL, "fsl,gianfar-mdio"); |
| 191 | |
| 192 | /* try the deprecated version */ |
| 193 | if (!np) |
| 194 | np = of_find_compatible_node(np, "mdio", "gianfar"); |
| 195 | |
| 196 | if (np) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 197 | int k; |
| 198 | struct device_node *child = NULL; |
| 199 | struct gianfar_mdio_data mdio_data; |
| 200 | |
| 201 | memset(&res, 0, sizeof(res)); |
| 202 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 203 | |
| 204 | ret = of_address_to_resource(np, 0, &res); |
| 205 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 206 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 207 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 208 | mdio_dev = |
| 209 | platform_device_register_simple("fsl-gianfar_mdio", |
| 210 | res.start, &res, 1); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 211 | if (IS_ERR(mdio_dev)) { |
| 212 | ret = PTR_ERR(mdio_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 213 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | for (k = 0; k < 32; k++) |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 217 | mdio_data.irq[k] = PHY_POLL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 218 | |
| 219 | while ((child = of_get_next_child(np, child)) != NULL) { |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 220 | int irq = irq_of_parse_and_map(child, 0); |
| 221 | if (irq != NO_IRQ) { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 222 | const u32 *id = of_get_property(child, |
| 223 | "reg", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 224 | mdio_data.irq[*id] = irq; |
| 225 | } |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 226 | } |
| 227 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 228 | ret = |
| 229 | platform_device_add_data(mdio_dev, &mdio_data, |
| 230 | sizeof(struct gianfar_mdio_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 231 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 232 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 233 | } |
| 234 | |
Kumar Gala | e77b28e | 2007-12-12 00:28:35 -0600 | [diff] [blame] | 235 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 236 | return 0; |
| 237 | |
| 238 | unreg: |
| 239 | platform_device_unregister(mdio_dev); |
| 240 | err: |
Kumar Gala | e77b28e | 2007-12-12 00:28:35 -0600 | [diff] [blame] | 241 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | arch_initcall(gfar_mdio_of_init); |
| 246 | |
| 247 | static const char *gfar_tx_intr = "tx"; |
| 248 | static const char *gfar_rx_intr = "rx"; |
| 249 | static const char *gfar_err_intr = "error"; |
| 250 | |
| 251 | static int __init gfar_of_init(void) |
| 252 | { |
| 253 | struct device_node *np; |
| 254 | unsigned int i; |
| 255 | struct platform_device *gfar_dev; |
| 256 | struct resource res; |
| 257 | int ret; |
| 258 | |
| 259 | for (np = NULL, i = 0; |
| 260 | (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; |
| 261 | i++) { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 262 | struct resource r[4]; |
| 263 | struct device_node *phy, *mdio; |
| 264 | struct gianfar_platform_data gfar_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 265 | const unsigned int *id; |
| 266 | const char *model; |
Andy Fleming | 7132ab7 | 2007-07-11 11:43:07 -0500 | [diff] [blame] | 267 | const char *ctype; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 268 | const void *mac_addr; |
| 269 | const phandle *ph; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 270 | int n_res = 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 271 | |
| 272 | memset(r, 0, sizeof(r)); |
| 273 | memset(&gfar_data, 0, sizeof(gfar_data)); |
| 274 | |
| 275 | ret = of_address_to_resource(np, 0, &r[0]); |
| 276 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 277 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 278 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 279 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 280 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 281 | model = of_get_property(np, "model", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 282 | |
| 283 | /* If we aren't the FEC we have multiple interrupts */ |
| 284 | if (model && strcasecmp(model, "FEC")) { |
| 285 | r[1].name = gfar_tx_intr; |
| 286 | |
| 287 | r[2].name = gfar_rx_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 288 | of_irq_to_resource(np, 1, &r[2]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 289 | |
| 290 | r[3].name = gfar_err_intr; |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 291 | of_irq_to_resource(np, 2, &r[3]); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 292 | |
| 293 | n_res += 2; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 294 | } |
| 295 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 296 | gfar_dev = |
| 297 | platform_device_register_simple("fsl-gianfar", i, &r[0], |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 298 | n_res); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 299 | |
| 300 | if (IS_ERR(gfar_dev)) { |
| 301 | ret = PTR_ERR(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 302 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 303 | } |
| 304 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 305 | mac_addr = of_get_mac_address(np); |
Jon Loeliger | f583165 | 2006-08-17 08:42:35 -0500 | [diff] [blame] | 306 | if (mac_addr) |
| 307 | memcpy(gfar_data.mac_addr, mac_addr, 6); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 308 | |
| 309 | if (model && !strcasecmp(model, "TSEC")) |
| 310 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 311 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 312 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 313 | FSL_GIANFAR_DEV_HAS_RMON | |
| 314 | FSL_GIANFAR_DEV_HAS_MULTI_INTR; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 315 | if (model && !strcasecmp(model, "eTSEC")) |
| 316 | gfar_data.device_flags = |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 317 | FSL_GIANFAR_DEV_HAS_GIGABIT | |
| 318 | FSL_GIANFAR_DEV_HAS_COALESCE | |
| 319 | FSL_GIANFAR_DEV_HAS_RMON | |
| 320 | FSL_GIANFAR_DEV_HAS_MULTI_INTR | |
| 321 | FSL_GIANFAR_DEV_HAS_CSUM | |
| 322 | FSL_GIANFAR_DEV_HAS_VLAN | |
| 323 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 324 | |
Andy Fleming | 7132ab7 | 2007-07-11 11:43:07 -0500 | [diff] [blame] | 325 | ctype = of_get_property(np, "phy-connection-type", NULL); |
| 326 | |
| 327 | /* We only care about rgmii-id. The rest are autodetected */ |
| 328 | if (ctype && !strcmp(ctype, "rgmii-id")) |
| 329 | gfar_data.interface = PHY_INTERFACE_MODE_RGMII_ID; |
| 330 | else |
| 331 | gfar_data.interface = PHY_INTERFACE_MODE_MII; |
| 332 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 333 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 334 | if (ph == NULL) { |
| 335 | u32 *fixed_link; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 336 | |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 337 | fixed_link = (u32 *)of_get_property(np, "fixed-link", |
| 338 | NULL); |
| 339 | if (!fixed_link) { |
| 340 | ret = -ENODEV; |
| 341 | goto unreg; |
| 342 | } |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 343 | |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 344 | gfar_data.bus_id = 0; |
| 345 | gfar_data.phy_id = fixed_link[0]; |
| 346 | } else { |
| 347 | phy = of_find_node_by_phandle(*ph); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 348 | |
Vitaly Bordug | a21e282 | 2007-12-07 01:51:31 +0300 | [diff] [blame] | 349 | if (phy == NULL) { |
| 350 | ret = -ENODEV; |
| 351 | goto unreg; |
| 352 | } |
| 353 | |
| 354 | mdio = of_get_parent(phy); |
| 355 | |
| 356 | id = of_get_property(phy, "reg", NULL); |
| 357 | ret = of_address_to_resource(mdio, 0, &res); |
| 358 | if (ret) { |
| 359 | of_node_put(phy); |
| 360 | of_node_put(mdio); |
| 361 | goto unreg; |
| 362 | } |
| 363 | |
| 364 | gfar_data.phy_id = *id; |
| 365 | gfar_data.bus_id = res.start; |
| 366 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 367 | of_node_put(phy); |
| 368 | of_node_put(mdio); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 369 | } |
| 370 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 371 | ret = |
| 372 | platform_device_add_data(gfar_dev, &gfar_data, |
| 373 | sizeof(struct |
| 374 | gianfar_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 375 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 376 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | return 0; |
| 380 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 381 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 382 | platform_device_unregister(gfar_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 383 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 384 | return ret; |
| 385 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 386 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 387 | arch_initcall(gfar_of_init); |
| 388 | |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 389 | #ifdef CONFIG_I2C_BOARDINFO |
| 390 | #include <linux/i2c.h> |
| 391 | struct i2c_driver_device { |
| 392 | char *of_device; |
| 393 | char *i2c_driver; |
| 394 | char *i2c_type; |
| 395 | }; |
| 396 | |
| 397 | static struct i2c_driver_device i2c_devices[] __initdata = { |
| 398 | {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",}, |
| 399 | {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",}, |
| 400 | {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",}, |
| 401 | {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, |
Peter Korsgaard | 0438c28 | 2007-09-20 12:42:13 +0200 | [diff] [blame] | 402 | {"dallas,ds1307", "rtc-ds1307", "ds1307",}, |
| 403 | {"dallas,ds1337", "rtc-ds1307", "ds1337",}, |
| 404 | {"dallas,ds1338", "rtc-ds1307", "ds1338",}, |
| 405 | {"dallas,ds1339", "rtc-ds1307", "ds1339",}, |
| 406 | {"dallas,ds1340", "rtc-ds1307", "ds1340",}, |
| 407 | {"stm,m41t00", "rtc-ds1307", "m41t00"}, |
Anton Vorontsov | c0e4eb2 | 2007-10-02 17:47:43 +0400 | [diff] [blame] | 408 | {"dallas,ds1374", "rtc-ds1374", "rtc-ds1374",}, |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 409 | }; |
| 410 | |
Guennadi Liakhovetski | e78bb5d | 2007-08-16 05:15:03 +1000 | [diff] [blame] | 411 | static int __init of_find_i2c_driver(struct device_node *node, |
| 412 | struct i2c_board_info *info) |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 413 | { |
| 414 | int i; |
| 415 | |
| 416 | for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { |
| 417 | if (!of_device_is_compatible(node, i2c_devices[i].of_device)) |
| 418 | continue; |
Guennadi Liakhovetski | e78bb5d | 2007-08-16 05:15:03 +1000 | [diff] [blame] | 419 | if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver, |
| 420 | KOBJ_NAME_LEN) >= KOBJ_NAME_LEN || |
| 421 | strlcpy(info->type, i2c_devices[i].i2c_type, |
| 422 | I2C_NAME_SIZE) >= I2C_NAME_SIZE) |
| 423 | return -ENOMEM; |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 424 | return 0; |
| 425 | } |
| 426 | return -ENODEV; |
| 427 | } |
| 428 | |
Guennadi Liakhovetski | e78bb5d | 2007-08-16 05:15:03 +1000 | [diff] [blame] | 429 | static void __init of_register_i2c_devices(struct device_node *adap_node, |
| 430 | int bus_num) |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 431 | { |
| 432 | struct device_node *node = NULL; |
| 433 | |
| 434 | while ((node = of_get_next_child(adap_node, node))) { |
Anton Vorontsov | da1bb3a | 2007-10-02 17:47:40 +0400 | [diff] [blame] | 435 | struct i2c_board_info info = {}; |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 436 | const u32 *addr; |
| 437 | int len; |
| 438 | |
| 439 | addr = of_get_property(node, "reg", &len); |
| 440 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { |
Peter Korsgaard | 210805e | 2007-09-20 12:42:12 +0200 | [diff] [blame] | 441 | printk(KERN_WARNING "fsl_soc.c: invalid i2c device entry\n"); |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 442 | continue; |
| 443 | } |
| 444 | |
| 445 | info.irq = irq_of_parse_and_map(node, 0); |
| 446 | if (info.irq == NO_IRQ) |
| 447 | info.irq = -1; |
| 448 | |
| 449 | if (of_find_i2c_driver(node, &info) < 0) |
| 450 | continue; |
| 451 | |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 452 | info.addr = *addr; |
| 453 | |
| 454 | i2c_register_board_info(bus_num, &info, 1); |
| 455 | } |
| 456 | } |
| 457 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 458 | static int __init fsl_i2c_of_init(void) |
| 459 | { |
| 460 | struct device_node *np; |
Kumar Gala | ec9686c | 2007-12-11 23:17:24 -0600 | [diff] [blame] | 461 | unsigned int i = 0; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 462 | struct platform_device *i2c_dev; |
| 463 | int ret; |
| 464 | |
Kumar Gala | ec9686c | 2007-12-11 23:17:24 -0600 | [diff] [blame] | 465 | for_each_compatible_node(np, NULL, "fsl-i2c") { |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 466 | struct resource r[2]; |
| 467 | struct fsl_i2c_platform_data i2c_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 468 | const unsigned char *flags = NULL; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 469 | |
| 470 | memset(&r, 0, sizeof(r)); |
| 471 | memset(&i2c_data, 0, sizeof(i2c_data)); |
| 472 | |
| 473 | ret = of_address_to_resource(np, 0, &r[0]); |
| 474 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 475 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 476 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 477 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 478 | |
| 479 | i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); |
| 480 | if (IS_ERR(i2c_dev)) { |
| 481 | ret = PTR_ERR(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 482 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | i2c_data.device_flags = 0; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 486 | flags = of_get_property(np, "dfsrr", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 487 | if (flags) |
| 488 | i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; |
| 489 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 490 | flags = of_get_property(np, "fsl5200-clocking", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 491 | if (flags) |
| 492 | i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; |
| 493 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 494 | ret = |
| 495 | platform_device_add_data(i2c_dev, &i2c_data, |
| 496 | sizeof(struct |
| 497 | fsl_i2c_platform_data)); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 498 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 499 | goto unreg; |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 500 | |
Kumar Gala | ec9686c | 2007-12-11 23:17:24 -0600 | [diff] [blame] | 501 | of_register_i2c_devices(np, i++); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 502 | } |
| 503 | |
| 504 | return 0; |
| 505 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 506 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 507 | platform_device_unregister(i2c_dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 508 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 509 | return ret; |
| 510 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 511 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 512 | arch_initcall(fsl_i2c_of_init); |
Guennadi Liakhovetski | d13ae86 | 2007-07-21 06:26:15 +1000 | [diff] [blame] | 513 | #endif |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 514 | |
| 515 | #ifdef CONFIG_PPC_83xx |
| 516 | static int __init mpc83xx_wdt_init(void) |
| 517 | { |
| 518 | struct resource r; |
| 519 | struct device_node *soc, *np; |
| 520 | struct platform_device *dev; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 521 | const unsigned int *freq; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 522 | int ret; |
| 523 | |
| 524 | np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); |
| 525 | |
| 526 | if (!np) { |
| 527 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 528 | goto nodev; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | soc = of_find_node_by_type(NULL, "soc"); |
| 532 | |
| 533 | if (!soc) { |
| 534 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 535 | goto nosoc; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 536 | } |
| 537 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 538 | freq = of_get_property(soc, "bus-frequency", NULL); |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 539 | if (!freq) { |
| 540 | ret = -ENODEV; |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 541 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | memset(&r, 0, sizeof(r)); |
| 545 | |
| 546 | ret = of_address_to_resource(np, 0, &r); |
| 547 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 548 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 549 | |
| 550 | dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1); |
| 551 | if (IS_ERR(dev)) { |
| 552 | ret = PTR_ERR(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 553 | goto err; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | ret = platform_device_add_data(dev, freq, sizeof(int)); |
| 557 | if (ret) |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 558 | goto unreg; |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 559 | |
| 560 | of_node_put(soc); |
| 561 | of_node_put(np); |
| 562 | |
| 563 | return 0; |
| 564 | |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 565 | unreg: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 566 | platform_device_unregister(dev); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 567 | err: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 568 | of_node_put(soc); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 569 | nosoc: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 570 | of_node_put(np); |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 571 | nodev: |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 572 | return ret; |
| 573 | } |
Kumar Gala | 2fb07d7 | 2006-01-23 16:58:04 -0600 | [diff] [blame] | 574 | |
Kumar Gala | eed3200 | 2006-01-13 11:19:13 -0600 | [diff] [blame] | 575 | arch_initcall(mpc83xx_wdt_init); |
| 576 | #endif |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 577 | |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 578 | 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] | 579 | { |
| 580 | if (!phy_type) |
| 581 | return FSL_USB2_PHY_NONE; |
| 582 | if (!strcasecmp(phy_type, "ulpi")) |
| 583 | return FSL_USB2_PHY_ULPI; |
| 584 | if (!strcasecmp(phy_type, "utmi")) |
| 585 | return FSL_USB2_PHY_UTMI; |
| 586 | if (!strcasecmp(phy_type, "utmi_wide")) |
| 587 | return FSL_USB2_PHY_UTMI_WIDE; |
| 588 | if (!strcasecmp(phy_type, "serial")) |
| 589 | return FSL_USB2_PHY_SERIAL; |
| 590 | |
| 591 | return FSL_USB2_PHY_NONE; |
| 592 | } |
| 593 | |
| 594 | static int __init fsl_usb_of_init(void) |
| 595 | { |
| 596 | struct device_node *np; |
Li Yang | 866b6dd | 2008-01-08 15:18:46 +0800 | [diff] [blame] | 597 | unsigned int i = 0; |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 598 | struct platform_device *usb_dev_mph = NULL, *usb_dev_dr_host = NULL, |
| 599 | *usb_dev_dr_client = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 600 | int ret; |
| 601 | |
Li Yang | 866b6dd | 2008-01-08 15:18:46 +0800 | [diff] [blame] | 602 | for_each_compatible_node(np, NULL, "fsl-usb2-mph") { |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 603 | struct resource r[2]; |
| 604 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 605 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 606 | |
| 607 | memset(&r, 0, sizeof(r)); |
| 608 | memset(&usb_data, 0, sizeof(usb_data)); |
| 609 | |
| 610 | ret = of_address_to_resource(np, 0, &r[0]); |
| 611 | if (ret) |
| 612 | goto err; |
| 613 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 614 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 615 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 616 | usb_dev_mph = |
| 617 | platform_device_register_simple("fsl-ehci", i, r, 2); |
| 618 | if (IS_ERR(usb_dev_mph)) { |
| 619 | ret = PTR_ERR(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 620 | goto err; |
| 621 | } |
| 622 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 623 | usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL; |
| 624 | 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] | 625 | |
| 626 | usb_data.operating_mode = FSL_USB2_MPH_HOST; |
| 627 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 628 | prop = of_get_property(np, "port0", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 629 | if (prop) |
| 630 | usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; |
| 631 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 632 | prop = of_get_property(np, "port1", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 633 | if (prop) |
| 634 | usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; |
| 635 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 636 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 637 | usb_data.phy_mode = determine_usb_phy(prop); |
| 638 | |
| 639 | ret = |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 640 | platform_device_add_data(usb_dev_mph, &usb_data, |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 641 | sizeof(struct |
| 642 | fsl_usb2_platform_data)); |
| 643 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 644 | goto unreg_mph; |
Li Yang | 866b6dd | 2008-01-08 15:18:46 +0800 | [diff] [blame] | 645 | i++; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 646 | } |
| 647 | |
Li Yang | 866b6dd | 2008-01-08 15:18:46 +0800 | [diff] [blame] | 648 | for_each_compatible_node(np, NULL, "fsl-usb2-dr") { |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 649 | struct resource r[2]; |
| 650 | struct fsl_usb2_platform_data usb_data; |
Jeremy Kerr | a7f67bd | 2006-07-12 15:35:54 +1000 | [diff] [blame] | 651 | const unsigned char *prop = NULL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 652 | |
| 653 | memset(&r, 0, sizeof(r)); |
| 654 | memset(&usb_data, 0, sizeof(usb_data)); |
| 655 | |
| 656 | ret = of_address_to_resource(np, 0, &r[0]); |
| 657 | if (ret) |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 658 | goto unreg_mph; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 659 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 660 | of_irq_to_resource(np, 0, &r[1]); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 661 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 662 | prop = of_get_property(np, "dr_mode", NULL); |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 663 | |
| 664 | if (!prop || !strcmp(prop, "host")) { |
| 665 | usb_data.operating_mode = FSL_USB2_DR_HOST; |
| 666 | usb_dev_dr_host = platform_device_register_simple( |
| 667 | "fsl-ehci", i, r, 2); |
| 668 | if (IS_ERR(usb_dev_dr_host)) { |
| 669 | ret = PTR_ERR(usb_dev_dr_host); |
| 670 | goto err; |
| 671 | } |
| 672 | } else if (prop && !strcmp(prop, "peripheral")) { |
| 673 | usb_data.operating_mode = FSL_USB2_DR_DEVICE; |
| 674 | usb_dev_dr_client = platform_device_register_simple( |
| 675 | "fsl-usb2-udc", i, r, 2); |
| 676 | if (IS_ERR(usb_dev_dr_client)) { |
| 677 | ret = PTR_ERR(usb_dev_dr_client); |
| 678 | goto err; |
| 679 | } |
| 680 | } else if (prop && !strcmp(prop, "otg")) { |
| 681 | usb_data.operating_mode = FSL_USB2_DR_OTG; |
| 682 | usb_dev_dr_host = platform_device_register_simple( |
| 683 | "fsl-ehci", i, r, 2); |
| 684 | if (IS_ERR(usb_dev_dr_host)) { |
| 685 | ret = PTR_ERR(usb_dev_dr_host); |
| 686 | goto err; |
| 687 | } |
| 688 | usb_dev_dr_client = platform_device_register_simple( |
| 689 | "fsl-usb2-udc", i, r, 2); |
| 690 | if (IS_ERR(usb_dev_dr_client)) { |
| 691 | ret = PTR_ERR(usb_dev_dr_client); |
| 692 | goto err; |
| 693 | } |
| 694 | } else { |
| 695 | ret = -EINVAL; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 696 | goto err; |
| 697 | } |
| 698 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 699 | prop = of_get_property(np, "phy_type", NULL); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 700 | usb_data.phy_mode = determine_usb_phy(prop); |
| 701 | |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 702 | if (usb_dev_dr_host) { |
| 703 | usb_dev_dr_host->dev.coherent_dma_mask = 0xffffffffUL; |
| 704 | usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> |
| 705 | dev.coherent_dma_mask; |
| 706 | if ((ret = platform_device_add_data(usb_dev_dr_host, |
| 707 | &usb_data, sizeof(struct |
| 708 | fsl_usb2_platform_data)))) |
| 709 | goto unreg_dr; |
| 710 | } |
| 711 | if (usb_dev_dr_client) { |
| 712 | usb_dev_dr_client->dev.coherent_dma_mask = 0xffffffffUL; |
| 713 | usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> |
| 714 | dev.coherent_dma_mask; |
| 715 | if ((ret = platform_device_add_data(usb_dev_dr_client, |
| 716 | &usb_data, sizeof(struct |
| 717 | fsl_usb2_platform_data)))) |
| 718 | goto unreg_dr; |
| 719 | } |
Li Yang | 866b6dd | 2008-01-08 15:18:46 +0800 | [diff] [blame] | 720 | i++; |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 721 | } |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 722 | return 0; |
| 723 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 724 | unreg_dr: |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 725 | if (usb_dev_dr_host) |
| 726 | platform_device_unregister(usb_dev_dr_host); |
| 727 | if (usb_dev_dr_client) |
| 728 | platform_device_unregister(usb_dev_dr_client); |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 729 | unreg_mph: |
| 730 | if (usb_dev_mph) |
| 731 | platform_device_unregister(usb_dev_mph); |
Kumar Gala | 4b10cfd | 2006-02-02 12:31:00 -0600 | [diff] [blame] | 732 | err: |
| 733 | return ret; |
| 734 | } |
| 735 | |
Kumar Gala | 01cced2 | 2006-04-11 10:07:16 -0500 | [diff] [blame] | 736 | arch_initcall(fsl_usb_of_init); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 737 | |
Scott Wood | e631ae3 | 2007-09-14 13:04:54 -0500 | [diff] [blame] | 738 | #ifndef CONFIG_PPC_CPM_NEW_BINDING |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 739 | #ifdef CONFIG_CPM2 |
| 740 | |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 741 | extern void init_scc_ioports(struct fs_uart_platform_info*); |
| 742 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 743 | static const char fcc_regs[] = "fcc_regs"; |
| 744 | static const char fcc_regs_c[] = "fcc_regs_c"; |
| 745 | static const char fcc_pram[] = "fcc_pram"; |
| 746 | static char bus_id[9][BUS_ID_SIZE]; |
| 747 | |
| 748 | static int __init fs_enet_of_init(void) |
| 749 | { |
| 750 | struct device_node *np; |
| 751 | unsigned int i; |
| 752 | struct platform_device *fs_enet_dev; |
| 753 | struct resource res; |
| 754 | int ret; |
| 755 | |
| 756 | for (np = NULL, i = 0; |
| 757 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 758 | i++) { |
| 759 | struct resource r[4]; |
| 760 | struct device_node *phy, *mdio; |
| 761 | struct fs_platform_info fs_enet_data; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 762 | const unsigned int *id, *phy_addr, *phy_irq; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 763 | const void *mac_addr; |
| 764 | const phandle *ph; |
| 765 | const char *model; |
| 766 | |
| 767 | memset(r, 0, sizeof(r)); |
| 768 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 769 | |
| 770 | ret = of_address_to_resource(np, 0, &r[0]); |
| 771 | if (ret) |
| 772 | goto err; |
| 773 | r[0].name = fcc_regs; |
| 774 | |
| 775 | ret = of_address_to_resource(np, 1, &r[1]); |
| 776 | if (ret) |
| 777 | goto err; |
| 778 | r[1].name = fcc_pram; |
| 779 | |
| 780 | ret = of_address_to_resource(np, 2, &r[2]); |
| 781 | if (ret) |
| 782 | goto err; |
| 783 | r[2].name = fcc_regs_c; |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 784 | fs_enet_data.fcc_regs_c = r[2].start; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 785 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 786 | of_irq_to_resource(np, 0, &r[3]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 787 | |
| 788 | fs_enet_dev = |
| 789 | platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); |
| 790 | |
| 791 | if (IS_ERR(fs_enet_dev)) { |
| 792 | ret = PTR_ERR(fs_enet_dev); |
| 793 | goto err; |
| 794 | } |
| 795 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 796 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 797 | if (model == NULL) { |
| 798 | ret = -ENODEV; |
| 799 | goto unreg; |
| 800 | } |
| 801 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 802 | mac_addr = of_get_mac_address(np); |
| 803 | if (mac_addr) |
| 804 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 805 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 806 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 807 | phy = of_find_node_by_phandle(*ph); |
| 808 | |
| 809 | if (phy == NULL) { |
| 810 | ret = -ENODEV; |
| 811 | goto unreg; |
| 812 | } |
| 813 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 814 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 815 | fs_enet_data.phy_addr = *phy_addr; |
| 816 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 817 | phy_irq = of_get_property(phy, "interrupts", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 818 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 819 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 820 | fs_enet_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 821 | strcpy(fs_enet_data.fs_type, model); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 822 | |
| 823 | mdio = of_get_parent(phy); |
| 824 | ret = of_address_to_resource(mdio, 0, &res); |
| 825 | if (ret) { |
| 826 | of_node_put(phy); |
| 827 | of_node_put(mdio); |
| 828 | goto unreg; |
| 829 | } |
| 830 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 831 | fs_enet_data.clk_rx = *((u32 *)of_get_property(np, |
| 832 | "rx-clock", NULL)); |
| 833 | fs_enet_data.clk_tx = *((u32 *)of_get_property(np, |
| 834 | "tx-clock", NULL)); |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 835 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 836 | if (strstr(model, "FCC")) { |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 837 | int fcc_index = *id - 1; |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 838 | const unsigned char *mdio_bb_prop; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 839 | |
Vitaly Bordug | fc8e50e | 2006-09-21 22:37:58 +0400 | [diff] [blame] | 840 | fs_enet_data.dpram_offset = (u32)cpm_dpram_addr(0); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 841 | fs_enet_data.rx_ring = 32; |
| 842 | fs_enet_data.tx_ring = 32; |
| 843 | fs_enet_data.rx_copybreak = 240; |
| 844 | fs_enet_data.use_napi = 0; |
| 845 | fs_enet_data.napi_weight = 17; |
| 846 | fs_enet_data.mem_offset = FCC_MEM_OFFSET(fcc_index); |
| 847 | fs_enet_data.cp_page = CPM_CR_FCC_PAGE(fcc_index); |
| 848 | fs_enet_data.cp_block = CPM_CR_FCC_SBLOCK(fcc_index); |
| 849 | |
| 850 | snprintf((char*)&bus_id[(*id)], BUS_ID_SIZE, "%x:%02x", |
| 851 | (u32)res.start, fs_enet_data.phy_addr); |
| 852 | fs_enet_data.bus_id = (char*)&bus_id[(*id)]; |
Vitaly Bordug | d3465c9 | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 853 | fs_enet_data.init_ioports = init_fcc_ioports; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 854 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 855 | mdio_bb_prop = of_get_property(phy, "bitbang", NULL); |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 856 | if (mdio_bb_prop) { |
| 857 | struct platform_device *fs_enet_mdio_bb_dev; |
| 858 | struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 859 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 860 | fs_enet_mdio_bb_dev = |
| 861 | platform_device_register_simple("fsl-bb-mdio", |
| 862 | i, NULL, 0); |
| 863 | memset(&fs_enet_mdio_bb_data, 0, |
| 864 | sizeof(struct fs_mii_bb_platform_info)); |
| 865 | fs_enet_mdio_bb_data.mdio_dat.bit = |
| 866 | mdio_bb_prop[0]; |
| 867 | fs_enet_mdio_bb_data.mdio_dir.bit = |
| 868 | mdio_bb_prop[1]; |
| 869 | fs_enet_mdio_bb_data.mdc_dat.bit = |
| 870 | mdio_bb_prop[2]; |
| 871 | fs_enet_mdio_bb_data.mdio_port = |
| 872 | mdio_bb_prop[3]; |
| 873 | fs_enet_mdio_bb_data.mdc_port = |
| 874 | mdio_bb_prop[4]; |
| 875 | fs_enet_mdio_bb_data.delay = |
| 876 | mdio_bb_prop[5]; |
| 877 | |
| 878 | fs_enet_mdio_bb_data.irq[0] = phy_irq[0]; |
| 879 | fs_enet_mdio_bb_data.irq[1] = -1; |
| 880 | fs_enet_mdio_bb_data.irq[2] = -1; |
| 881 | fs_enet_mdio_bb_data.irq[3] = phy_irq[0]; |
| 882 | fs_enet_mdio_bb_data.irq[31] = -1; |
| 883 | |
| 884 | fs_enet_mdio_bb_data.mdio_dat.offset = |
| 885 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 886 | fs_enet_mdio_bb_data.mdio_dir.offset = |
| 887 | (u32)&cpm2_immr->im_ioport.iop_pdirc; |
| 888 | fs_enet_mdio_bb_data.mdc_dat.offset = |
| 889 | (u32)&cpm2_immr->im_ioport.iop_pdatc; |
| 890 | |
| 891 | ret = platform_device_add_data( |
| 892 | fs_enet_mdio_bb_dev, |
| 893 | &fs_enet_mdio_bb_data, |
| 894 | sizeof(struct fs_mii_bb_platform_info)); |
| 895 | if (ret) |
| 896 | goto unreg; |
| 897 | } |
Li Yang | 97c5a20 | 2007-02-07 13:49:24 +0800 | [diff] [blame] | 898 | |
Vitaly Bordug | ed943c1 | 2006-10-02 22:41:50 +0400 | [diff] [blame] | 899 | of_node_put(phy); |
| 900 | of_node_put(mdio); |
| 901 | |
| 902 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 903 | sizeof(struct |
| 904 | fs_platform_info)); |
Olof Johansson | 2b00b25 | 2006-10-05 21:16:48 -0500 | [diff] [blame] | 905 | if (ret) |
| 906 | goto unreg; |
| 907 | } |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 908 | } |
| 909 | return 0; |
| 910 | |
| 911 | unreg: |
| 912 | platform_device_unregister(fs_enet_dev); |
| 913 | err: |
| 914 | return ret; |
| 915 | } |
| 916 | |
| 917 | arch_initcall(fs_enet_of_init); |
| 918 | |
| 919 | static const char scc_regs[] = "regs"; |
| 920 | static const char scc_pram[] = "pram"; |
| 921 | |
| 922 | static int __init cpm_uart_of_init(void) |
| 923 | { |
| 924 | struct device_node *np; |
| 925 | unsigned int i; |
| 926 | struct platform_device *cpm_uart_dev; |
| 927 | int ret; |
| 928 | |
| 929 | for (np = NULL, i = 0; |
| 930 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 931 | i++) { |
| 932 | struct resource r[3]; |
| 933 | struct fs_uart_platform_info cpm_uart_data; |
| 934 | const int *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 935 | const char *model; |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 936 | |
| 937 | memset(r, 0, sizeof(r)); |
| 938 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 939 | |
| 940 | ret = of_address_to_resource(np, 0, &r[0]); |
| 941 | if (ret) |
| 942 | goto err; |
| 943 | |
| 944 | r[0].name = scc_regs; |
| 945 | |
| 946 | ret = of_address_to_resource(np, 1, &r[1]); |
| 947 | if (ret) |
| 948 | goto err; |
| 949 | r[1].name = scc_pram; |
| 950 | |
Andy Fleming | a9b1497 | 2006-10-19 19:52:26 -0500 | [diff] [blame] | 951 | of_irq_to_resource(np, 0, &r[2]); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 952 | |
| 953 | cpm_uart_dev = |
| 954 | platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); |
| 955 | |
| 956 | if (IS_ERR(cpm_uart_dev)) { |
| 957 | ret = PTR_ERR(cpm_uart_dev); |
| 958 | goto err; |
| 959 | } |
| 960 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 961 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 962 | cpm_uart_data.fs_no = *id; |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 963 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 964 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 611a15a | 2006-09-21 22:38:05 +0400 | [diff] [blame] | 965 | strcpy(cpm_uart_data.fs_type, model); |
| 966 | |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 967 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 968 | |
| 969 | cpm_uart_data.tx_num_fifo = 4; |
| 970 | cpm_uart_data.tx_buf_size = 32; |
| 971 | cpm_uart_data.rx_num_fifo = 4; |
| 972 | cpm_uart_data.rx_buf_size = 32; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 973 | cpm_uart_data.clk_rx = *((u32 *)of_get_property(np, |
| 974 | "rx-clock", NULL)); |
| 975 | cpm_uart_data.clk_tx = *((u32 *)of_get_property(np, |
| 976 | "tx-clock", NULL)); |
Vitaly Bordug | fba4366 | 2006-09-21 17:26:34 +0400 | [diff] [blame] | 977 | |
| 978 | ret = |
| 979 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 980 | sizeof(struct |
| 981 | fs_uart_platform_info)); |
| 982 | if (ret) |
| 983 | goto unreg; |
| 984 | } |
| 985 | |
| 986 | return 0; |
| 987 | |
| 988 | unreg: |
| 989 | platform_device_unregister(cpm_uart_dev); |
| 990 | err: |
| 991 | return ret; |
| 992 | } |
| 993 | |
| 994 | arch_initcall(cpm_uart_of_init); |
| 995 | #endif /* CONFIG_CPM2 */ |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 996 | |
| 997 | #ifdef CONFIG_8xx |
| 998 | |
| 999 | extern void init_scc_ioports(struct fs_platform_info*); |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1000 | extern int platform_device_skip(const char *model, int id); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1001 | |
| 1002 | static int __init fs_enet_mdio_of_init(void) |
| 1003 | { |
| 1004 | struct device_node *np; |
| 1005 | unsigned int i; |
| 1006 | struct platform_device *mdio_dev; |
| 1007 | struct resource res; |
| 1008 | int ret; |
| 1009 | |
| 1010 | for (np = NULL, i = 0; |
| 1011 | (np = of_find_compatible_node(np, "mdio", "fs_enet")) != NULL; |
| 1012 | i++) { |
| 1013 | struct fs_mii_fec_platform_info mdio_data; |
| 1014 | |
| 1015 | memset(&res, 0, sizeof(res)); |
| 1016 | memset(&mdio_data, 0, sizeof(mdio_data)); |
| 1017 | |
| 1018 | ret = of_address_to_resource(np, 0, &res); |
| 1019 | if (ret) |
| 1020 | goto err; |
| 1021 | |
| 1022 | mdio_dev = |
| 1023 | platform_device_register_simple("fsl-cpm-fec-mdio", |
| 1024 | res.start, &res, 1); |
| 1025 | if (IS_ERR(mdio_dev)) { |
| 1026 | ret = PTR_ERR(mdio_dev); |
| 1027 | goto err; |
| 1028 | } |
| 1029 | |
| 1030 | mdio_data.mii_speed = ((((ppc_proc_freq + 4999999) / 2500000) / 2) & 0x3F) << 1; |
| 1031 | |
| 1032 | ret = |
| 1033 | platform_device_add_data(mdio_dev, &mdio_data, |
| 1034 | sizeof(struct fs_mii_fec_platform_info)); |
| 1035 | if (ret) |
| 1036 | goto unreg; |
| 1037 | } |
| 1038 | return 0; |
| 1039 | |
| 1040 | unreg: |
| 1041 | platform_device_unregister(mdio_dev); |
| 1042 | err: |
| 1043 | return ret; |
| 1044 | } |
| 1045 | |
| 1046 | arch_initcall(fs_enet_mdio_of_init); |
| 1047 | |
| 1048 | static const char *enet_regs = "regs"; |
| 1049 | static const char *enet_pram = "pram"; |
| 1050 | static const char *enet_irq = "interrupt"; |
| 1051 | static char bus_id[9][BUS_ID_SIZE]; |
| 1052 | |
| 1053 | static int __init fs_enet_of_init(void) |
| 1054 | { |
| 1055 | struct device_node *np; |
| 1056 | unsigned int i; |
| 1057 | struct platform_device *fs_enet_dev = NULL; |
| 1058 | struct resource res; |
| 1059 | int ret; |
| 1060 | |
| 1061 | for (np = NULL, i = 0; |
| 1062 | (np = of_find_compatible_node(np, "network", "fs_enet")) != NULL; |
| 1063 | i++) { |
| 1064 | struct resource r[4]; |
| 1065 | struct device_node *phy = NULL, *mdio = NULL; |
| 1066 | struct fs_platform_info fs_enet_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1067 | const unsigned int *id; |
| 1068 | const unsigned int *phy_addr; |
Scott Wood | b7a6912 | 2007-05-09 03:15:34 +1000 | [diff] [blame] | 1069 | const void *mac_addr; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1070 | const phandle *ph; |
| 1071 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1072 | |
| 1073 | memset(r, 0, sizeof(r)); |
| 1074 | memset(&fs_enet_data, 0, sizeof(fs_enet_data)); |
| 1075 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1076 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1077 | if (model == NULL) { |
| 1078 | ret = -ENODEV; |
| 1079 | goto unreg; |
| 1080 | } |
| 1081 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1082 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1083 | fs_enet_data.fs_no = *id; |
| 1084 | |
| 1085 | if (platform_device_skip(model, *id)) |
| 1086 | continue; |
| 1087 | |
| 1088 | ret = of_address_to_resource(np, 0, &r[0]); |
| 1089 | if (ret) |
| 1090 | goto err; |
| 1091 | r[0].name = enet_regs; |
| 1092 | |
Timur Tabi | 29cfe6f | 2007-02-16 12:01:29 -0600 | [diff] [blame] | 1093 | mac_addr = of_get_mac_address(np); |
| 1094 | if (mac_addr) |
| 1095 | memcpy(fs_enet_data.macaddr, mac_addr, 6); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1096 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1097 | ph = of_get_property(np, "phy-handle", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1098 | if (ph != NULL) |
| 1099 | phy = of_find_node_by_phandle(*ph); |
| 1100 | |
| 1101 | if (phy != NULL) { |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1102 | phy_addr = of_get_property(phy, "reg", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1103 | fs_enet_data.phy_addr = *phy_addr; |
| 1104 | fs_enet_data.has_phy = 1; |
| 1105 | |
| 1106 | mdio = of_get_parent(phy); |
| 1107 | ret = of_address_to_resource(mdio, 0, &res); |
| 1108 | if (ret) { |
| 1109 | of_node_put(phy); |
| 1110 | of_node_put(mdio); |
| 1111 | goto unreg; |
| 1112 | } |
| 1113 | } |
| 1114 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1115 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1116 | strcpy(fs_enet_data.fs_type, model); |
| 1117 | |
| 1118 | if (strstr(model, "FEC")) { |
| 1119 | r[1].start = r[1].end = irq_of_parse_and_map(np, 0); |
| 1120 | r[1].flags = IORESOURCE_IRQ; |
| 1121 | r[1].name = enet_irq; |
| 1122 | |
| 1123 | fs_enet_dev = |
| 1124 | platform_device_register_simple("fsl-cpm-fec", i, &r[0], 2); |
| 1125 | |
| 1126 | if (IS_ERR(fs_enet_dev)) { |
| 1127 | ret = PTR_ERR(fs_enet_dev); |
| 1128 | goto err; |
| 1129 | } |
| 1130 | |
| 1131 | fs_enet_data.rx_ring = 128; |
| 1132 | fs_enet_data.tx_ring = 16; |
| 1133 | fs_enet_data.rx_copybreak = 240; |
| 1134 | fs_enet_data.use_napi = 1; |
| 1135 | fs_enet_data.napi_weight = 17; |
| 1136 | |
| 1137 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%x:%02x", |
| 1138 | (u32)res.start, fs_enet_data.phy_addr); |
| 1139 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 1140 | fs_enet_data.init_ioports = init_fec_ioports; |
| 1141 | } |
| 1142 | if (strstr(model, "SCC")) { |
| 1143 | ret = of_address_to_resource(np, 1, &r[1]); |
| 1144 | if (ret) |
| 1145 | goto err; |
| 1146 | r[1].name = enet_pram; |
| 1147 | |
| 1148 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 1149 | r[2].flags = IORESOURCE_IRQ; |
| 1150 | r[2].name = enet_irq; |
| 1151 | |
| 1152 | fs_enet_dev = |
| 1153 | platform_device_register_simple("fsl-cpm-scc", i, &r[0], 3); |
| 1154 | |
| 1155 | if (IS_ERR(fs_enet_dev)) { |
| 1156 | ret = PTR_ERR(fs_enet_dev); |
| 1157 | goto err; |
| 1158 | } |
| 1159 | |
| 1160 | fs_enet_data.rx_ring = 64; |
| 1161 | fs_enet_data.tx_ring = 8; |
| 1162 | fs_enet_data.rx_copybreak = 240; |
| 1163 | fs_enet_data.use_napi = 1; |
| 1164 | fs_enet_data.napi_weight = 17; |
| 1165 | |
| 1166 | snprintf((char*)&bus_id[i], BUS_ID_SIZE, "%s", "fixed@10:1"); |
| 1167 | fs_enet_data.bus_id = (char*)&bus_id[i]; |
| 1168 | fs_enet_data.init_ioports = init_scc_ioports; |
| 1169 | } |
| 1170 | |
| 1171 | of_node_put(phy); |
| 1172 | of_node_put(mdio); |
| 1173 | |
| 1174 | ret = platform_device_add_data(fs_enet_dev, &fs_enet_data, |
| 1175 | sizeof(struct |
| 1176 | fs_platform_info)); |
| 1177 | if (ret) |
| 1178 | goto unreg; |
| 1179 | } |
| 1180 | return 0; |
| 1181 | |
| 1182 | unreg: |
| 1183 | platform_device_unregister(fs_enet_dev); |
| 1184 | err: |
| 1185 | return ret; |
| 1186 | } |
| 1187 | |
| 1188 | arch_initcall(fs_enet_of_init); |
| 1189 | |
Vitaly Bordug | 80128ff | 2007-07-09 11:37:35 -0700 | [diff] [blame] | 1190 | static int __init fsl_pcmcia_of_init(void) |
| 1191 | { |
Cyrill Gorcunov | 26cb7d8 | 2007-11-30 06:44:36 +1100 | [diff] [blame] | 1192 | struct device_node *np; |
Vitaly Bordug | 80128ff | 2007-07-09 11:37:35 -0700 | [diff] [blame] | 1193 | /* |
| 1194 | * Register all the devices which type is "pcmcia" |
| 1195 | */ |
Cyrill Gorcunov | 26cb7d8 | 2007-11-30 06:44:36 +1100 | [diff] [blame] | 1196 | for_each_compatible_node(np, "pcmcia", "fsl,pq-pcmcia") |
| 1197 | of_platform_device_create(np, "m8xx-pcmcia", NULL); |
Vitaly Bordug | 80128ff | 2007-07-09 11:37:35 -0700 | [diff] [blame] | 1198 | return 0; |
| 1199 | } |
| 1200 | |
| 1201 | arch_initcall(fsl_pcmcia_of_init); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1202 | |
| 1203 | static const char *smc_regs = "regs"; |
| 1204 | static const char *smc_pram = "pram"; |
| 1205 | |
| 1206 | static int __init cpm_smc_uart_of_init(void) |
| 1207 | { |
| 1208 | struct device_node *np; |
| 1209 | unsigned int i; |
| 1210 | struct platform_device *cpm_uart_dev; |
| 1211 | int ret; |
| 1212 | |
| 1213 | for (np = NULL, i = 0; |
| 1214 | (np = of_find_compatible_node(np, "serial", "cpm_uart")) != NULL; |
| 1215 | i++) { |
| 1216 | struct resource r[3]; |
| 1217 | struct fs_uart_platform_info cpm_uart_data; |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1218 | const int *id; |
| 1219 | const char *model; |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1220 | |
| 1221 | memset(r, 0, sizeof(r)); |
| 1222 | memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); |
| 1223 | |
| 1224 | ret = of_address_to_resource(np, 0, &r[0]); |
| 1225 | if (ret) |
| 1226 | goto err; |
| 1227 | |
| 1228 | r[0].name = smc_regs; |
| 1229 | |
| 1230 | ret = of_address_to_resource(np, 1, &r[1]); |
| 1231 | if (ret) |
| 1232 | goto err; |
| 1233 | r[1].name = smc_pram; |
| 1234 | |
| 1235 | r[2].start = r[2].end = irq_of_parse_and_map(np, 0); |
| 1236 | r[2].flags = IORESOURCE_IRQ; |
| 1237 | |
| 1238 | cpm_uart_dev = |
| 1239 | platform_device_register_simple("fsl-cpm-smc:uart", i, &r[0], 3); |
| 1240 | |
| 1241 | if (IS_ERR(cpm_uart_dev)) { |
| 1242 | ret = PTR_ERR(cpm_uart_dev); |
| 1243 | goto err; |
| 1244 | } |
| 1245 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1246 | model = of_get_property(np, "model", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1247 | strcpy(cpm_uart_data.fs_type, model); |
| 1248 | |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 1249 | id = of_get_property(np, "device-id", NULL); |
Vitaly Bordug | 88bdc6f | 2007-01-24 22:41:15 +0300 | [diff] [blame] | 1250 | cpm_uart_data.fs_no = *id; |
| 1251 | cpm_uart_data.uart_clk = ppc_proc_freq; |
| 1252 | |
| 1253 | cpm_uart_data.tx_num_fifo = 4; |
| 1254 | cpm_uart_data.tx_buf_size = 32; |
| 1255 | cpm_uart_data.rx_num_fifo = 4; |
| 1256 | cpm_uart_data.rx_buf_size = 32; |
| 1257 | |
| 1258 | ret = |
| 1259 | platform_device_add_data(cpm_uart_dev, &cpm_uart_data, |
| 1260 | sizeof(struct |
| 1261 | fs_uart_platform_info)); |
| 1262 | if (ret) |
| 1263 | goto unreg; |
| 1264 | } |
| 1265 | |
| 1266 | return 0; |
| 1267 | |
| 1268 | unreg: |
| 1269 | platform_device_unregister(cpm_uart_dev); |
| 1270 | err: |
| 1271 | return ret; |
| 1272 | } |
| 1273 | |
| 1274 | arch_initcall(cpm_smc_uart_of_init); |
| 1275 | |
| 1276 | #endif /* CONFIG_8xx */ |
Scott Wood | e631ae3 | 2007-09-14 13:04:54 -0500 | [diff] [blame] | 1277 | #endif /* CONFIG_PPC_CPM_NEW_BINDING */ |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 1278 | |
| 1279 | int __init fsl_spi_init(struct spi_board_info *board_infos, |
| 1280 | unsigned int num_board_infos, |
| 1281 | void (*activate_cs)(u8 cs, u8 polarity), |
| 1282 | void (*deactivate_cs)(u8 cs, u8 polarity)) |
| 1283 | { |
| 1284 | struct device_node *np; |
| 1285 | unsigned int i; |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1286 | u32 sysclk = -1; |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 1287 | |
Peter Korsgaard | 082ea86 | 2007-10-06 22:06:40 +0200 | [diff] [blame] | 1288 | /* SPI controller is either clocked from QE or SoC clock */ |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1289 | #ifdef CONFIG_QUICC_ENGINE |
| 1290 | sysclk = get_brgfreq(); |
| 1291 | #endif |
| 1292 | if (sysclk == -1) { |
| 1293 | const u32 *freq; |
| 1294 | int size; |
Anton Vorontsov | a2dd70a | 2008-01-24 18:39:59 +0300 | [diff] [blame] | 1295 | |
Peter Korsgaard | 082ea86 | 2007-10-06 22:06:40 +0200 | [diff] [blame] | 1296 | np = of_find_node_by_type(NULL, "soc"); |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1297 | if (!np) |
| 1298 | return -ENODEV; |
Peter Korsgaard | 082ea86 | 2007-10-06 22:06:40 +0200 | [diff] [blame] | 1299 | |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1300 | freq = of_get_property(np, "clock-frequency", &size); |
| 1301 | if (!freq || size != sizeof(*freq) || *freq == 0) { |
| 1302 | freq = of_get_property(np, "bus-frequency", &size); |
| 1303 | if (!freq || size != sizeof(*freq) || *freq == 0) { |
| 1304 | of_node_put(np); |
| 1305 | return -ENODEV; |
| 1306 | } |
| 1307 | } |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 1308 | |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1309 | sysclk = *freq; |
| 1310 | of_node_put(np); |
| 1311 | } |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 1312 | |
| 1313 | for (np = NULL, i = 1; |
| 1314 | (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; |
| 1315 | i++) { |
| 1316 | int ret = 0; |
| 1317 | unsigned int j; |
| 1318 | const void *prop; |
| 1319 | struct resource res[2]; |
| 1320 | struct platform_device *pdev; |
| 1321 | struct fsl_spi_platform_data pdata = { |
| 1322 | .activate_cs = activate_cs, |
| 1323 | .deactivate_cs = deactivate_cs, |
| 1324 | }; |
| 1325 | |
| 1326 | memset(res, 0, sizeof(res)); |
| 1327 | |
Anton Vorontsov | 59a0ea5 | 2008-01-24 18:40:03 +0300 | [diff] [blame^] | 1328 | pdata.sysclk = sysclk; |
Anton Vorontsov | 26f6cb9 | 2007-08-23 15:35:56 +0400 | [diff] [blame] | 1329 | |
| 1330 | prop = of_get_property(np, "reg", NULL); |
| 1331 | if (!prop) |
| 1332 | goto err; |
| 1333 | pdata.bus_num = *(u32 *)prop; |
| 1334 | |
| 1335 | prop = of_get_property(np, "mode", NULL); |
| 1336 | if (prop && !strcmp(prop, "cpu-qe")) |
| 1337 | pdata.qe_mode = 1; |
| 1338 | |
| 1339 | for (j = 0; j < num_board_infos; j++) { |
| 1340 | if (board_infos[j].bus_num == pdata.bus_num) |
| 1341 | pdata.max_chipselect++; |
| 1342 | } |
| 1343 | |
| 1344 | if (!pdata.max_chipselect) |
| 1345 | goto err; |
| 1346 | |
| 1347 | ret = of_address_to_resource(np, 0, &res[0]); |
| 1348 | if (ret) |
| 1349 | goto err; |
| 1350 | |
| 1351 | ret = of_irq_to_resource(np, 0, &res[1]); |
| 1352 | if (ret == NO_IRQ) |
| 1353 | goto err; |
| 1354 | |
| 1355 | pdev = platform_device_alloc("mpc83xx_spi", i); |
| 1356 | if (!pdev) |
| 1357 | goto err; |
| 1358 | |
| 1359 | ret = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 1360 | if (ret) |
| 1361 | goto unreg; |
| 1362 | |
| 1363 | ret = platform_device_add_resources(pdev, res, |
| 1364 | ARRAY_SIZE(res)); |
| 1365 | if (ret) |
| 1366 | goto unreg; |
| 1367 | |
| 1368 | ret = platform_device_register(pdev); |
| 1369 | if (ret) |
| 1370 | goto unreg; |
| 1371 | |
| 1372 | continue; |
| 1373 | unreg: |
| 1374 | platform_device_del(pdev); |
| 1375 | err: |
| 1376 | continue; |
| 1377 | } |
| 1378 | |
| 1379 | return spi_register_board_info(board_infos, num_board_infos); |
| 1380 | } |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 1381 | |
| 1382 | #if defined(CONFIG_PPC_85xx) || defined(CONFIG_PPC_86xx) |
| 1383 | static __be32 __iomem *rstcr; |
| 1384 | |
| 1385 | static int __init setup_rstcr(void) |
| 1386 | { |
| 1387 | struct device_node *np; |
| 1388 | np = of_find_node_by_name(NULL, "global-utilities"); |
| 1389 | if ((np && of_get_property(np, "fsl,has-rstcr", NULL))) { |
| 1390 | const u32 *prop = of_get_property(np, "reg", NULL); |
| 1391 | if (prop) { |
| 1392 | /* map reset control register |
| 1393 | * 0xE00B0 is offset of reset control register |
| 1394 | */ |
| 1395 | rstcr = ioremap(get_immrbase() + *prop + 0xB0, 0xff); |
| 1396 | if (!rstcr) |
| 1397 | printk (KERN_EMERG "Error: reset control " |
| 1398 | "register not mapped!\n"); |
| 1399 | } |
| 1400 | } else |
| 1401 | printk (KERN_INFO "rstcr compatible register does not exist!\n"); |
| 1402 | if (np) |
| 1403 | of_node_put(np); |
| 1404 | return 0; |
| 1405 | } |
| 1406 | |
| 1407 | arch_initcall(setup_rstcr); |
| 1408 | |
| 1409 | void fsl_rstcr_restart(char *cmd) |
| 1410 | { |
| 1411 | local_irq_disable(); |
| 1412 | if (rstcr) |
| 1413 | /* set reset control register */ |
| 1414 | out_be32(rstcr, 0x2); /* HRESET_REQ */ |
| 1415 | |
| 1416 | while (1) ; |
| 1417 | } |
| 1418 | #endif |