Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Platform device setup for Marvell mv64360/mv64460 host bridges (Discovery) |
| 3 | * |
| 4 | * Author: Dale Farnsworth <dale@farnsworth.org> |
| 5 | * |
| 6 | * 2007 (c) MontaVista, Software, Inc. This file is licensed under |
| 7 | * the terms of the GNU General Public License version 2. This program |
| 8 | * is licensed "as is" without any warranty of any kind, whether express |
| 9 | * or implied. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/stddef.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
Mark A. Greer | 542c98c | 2007-06-07 10:38:00 +1000 | [diff] [blame] | 15 | #include <linux/console.h> |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 16 | #include <linux/mv643xx.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | |
| 19 | #include <asm/prom.h> |
| 20 | |
| 21 | /* |
| 22 | * These functions provide the necessary setup for the mv64x60 drivers. |
| 23 | * These drivers are unusual in that they work on both the MIPS and PowerPC |
| 24 | * architectures. Because of that, the drivers do not support the normal |
| 25 | * PowerPC of_platform_bus_type. They support platform_bus_type instead. |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * Create MPSC platform devices |
| 30 | */ |
| 31 | static int __init mv64x60_mpsc_register_shared_pdev(struct device_node *np) |
| 32 | { |
| 33 | struct platform_device *pdev; |
| 34 | struct resource r[2]; |
| 35 | struct mpsc_shared_pdata pdata; |
| 36 | const phandle *ph; |
| 37 | struct device_node *mpscrouting, *mpscintr; |
| 38 | int err; |
| 39 | |
| 40 | ph = of_get_property(np, "mpscrouting", NULL); |
| 41 | mpscrouting = of_find_node_by_phandle(*ph); |
| 42 | if (!mpscrouting) |
| 43 | return -ENODEV; |
| 44 | |
| 45 | err = of_address_to_resource(mpscrouting, 0, &r[0]); |
| 46 | of_node_put(mpscrouting); |
| 47 | if (err) |
| 48 | return err; |
| 49 | |
| 50 | ph = of_get_property(np, "mpscintr", NULL); |
| 51 | mpscintr = of_find_node_by_phandle(*ph); |
| 52 | if (!mpscintr) |
| 53 | return -ENODEV; |
| 54 | |
| 55 | err = of_address_to_resource(mpscintr, 0, &r[1]); |
| 56 | of_node_put(mpscintr); |
| 57 | if (err) |
| 58 | return err; |
| 59 | |
| 60 | memset(&pdata, 0, sizeof(pdata)); |
| 61 | |
| 62 | pdev = platform_device_alloc(MPSC_SHARED_NAME, 0); |
| 63 | if (!pdev) |
| 64 | return -ENOMEM; |
| 65 | |
| 66 | err = platform_device_add_resources(pdev, r, 2); |
| 67 | if (err) |
| 68 | goto error; |
| 69 | |
| 70 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 71 | if (err) |
| 72 | goto error; |
| 73 | |
| 74 | err = platform_device_add(pdev); |
| 75 | if (err) |
| 76 | goto error; |
| 77 | |
| 78 | return 0; |
| 79 | |
| 80 | error: |
| 81 | platform_device_put(pdev); |
| 82 | return err; |
| 83 | } |
| 84 | |
| 85 | |
| 86 | static int __init mv64x60_mpsc_device_setup(struct device_node *np, int id) |
| 87 | { |
| 88 | struct resource r[5]; |
| 89 | struct mpsc_pdata pdata; |
| 90 | struct platform_device *pdev; |
| 91 | const unsigned int *prop; |
| 92 | const phandle *ph; |
| 93 | struct device_node *sdma, *brg; |
| 94 | int err; |
| 95 | int port_number; |
| 96 | |
| 97 | /* only register the shared platform device the first time through */ |
| 98 | if (id == 0 && (err = mv64x60_mpsc_register_shared_pdev(np))) |
| 99 | return err; |
| 100 | |
| 101 | memset(r, 0, sizeof(r)); |
| 102 | |
| 103 | err = of_address_to_resource(np, 0, &r[0]); |
| 104 | if (err) |
| 105 | return err; |
| 106 | |
| 107 | of_irq_to_resource(np, 0, &r[4]); |
| 108 | |
| 109 | ph = of_get_property(np, "sdma", NULL); |
| 110 | sdma = of_find_node_by_phandle(*ph); |
| 111 | if (!sdma) |
| 112 | return -ENODEV; |
| 113 | |
| 114 | of_irq_to_resource(sdma, 0, &r[3]); |
| 115 | err = of_address_to_resource(sdma, 0, &r[1]); |
| 116 | of_node_put(sdma); |
| 117 | if (err) |
| 118 | return err; |
| 119 | |
| 120 | ph = of_get_property(np, "brg", NULL); |
| 121 | brg = of_find_node_by_phandle(*ph); |
| 122 | if (!brg) |
| 123 | return -ENODEV; |
| 124 | |
| 125 | err = of_address_to_resource(brg, 0, &r[2]); |
| 126 | of_node_put(brg); |
| 127 | if (err) |
| 128 | return err; |
| 129 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 130 | prop = of_get_property(np, "cell-index", NULL); |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 131 | if (!prop) |
| 132 | return -ENODEV; |
| 133 | port_number = *(int *)prop; |
| 134 | |
| 135 | memset(&pdata, 0, sizeof(pdata)); |
| 136 | |
| 137 | pdata.cache_mgmt = 1; /* All current revs need this set */ |
| 138 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 139 | pdata.max_idle = 40; /* default */ |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 140 | prop = of_get_property(np, "max_idle", NULL); |
| 141 | if (prop) |
| 142 | pdata.max_idle = *prop; |
| 143 | |
| 144 | prop = of_get_property(brg, "current-speed", NULL); |
| 145 | if (prop) |
| 146 | pdata.default_baud = *prop; |
| 147 | |
| 148 | /* Default is 8 bits, no parity, no flow control */ |
| 149 | pdata.default_bits = 8; |
| 150 | pdata.default_parity = 'n'; |
| 151 | pdata.default_flow = 'n'; |
| 152 | |
| 153 | prop = of_get_property(np, "chr_1", NULL); |
| 154 | if (prop) |
| 155 | pdata.chr_1_val = *prop; |
| 156 | |
| 157 | prop = of_get_property(np, "chr_2", NULL); |
| 158 | if (prop) |
| 159 | pdata.chr_2_val = *prop; |
| 160 | |
| 161 | prop = of_get_property(np, "chr_10", NULL); |
| 162 | if (prop) |
| 163 | pdata.chr_10_val = *prop; |
| 164 | |
| 165 | prop = of_get_property(np, "mpcr", NULL); |
| 166 | if (prop) |
| 167 | pdata.mpcr_val = *prop; |
| 168 | |
| 169 | prop = of_get_property(brg, "bcr", NULL); |
| 170 | if (prop) |
| 171 | pdata.bcr_val = *prop; |
| 172 | |
| 173 | pdata.brg_can_tune = 1; /* All current revs need this set */ |
| 174 | |
| 175 | prop = of_get_property(brg, "clock-src", NULL); |
| 176 | if (prop) |
| 177 | pdata.brg_clk_src = *prop; |
| 178 | |
| 179 | prop = of_get_property(brg, "clock-frequency", NULL); |
| 180 | if (prop) |
| 181 | pdata.brg_clk_freq = *prop; |
| 182 | |
| 183 | pdev = platform_device_alloc(MPSC_CTLR_NAME, port_number); |
| 184 | if (!pdev) |
| 185 | return -ENOMEM; |
| 186 | |
| 187 | err = platform_device_add_resources(pdev, r, 5); |
| 188 | if (err) |
| 189 | goto error; |
| 190 | |
| 191 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 192 | if (err) |
| 193 | goto error; |
| 194 | |
| 195 | err = platform_device_add(pdev); |
| 196 | if (err) |
| 197 | goto error; |
| 198 | |
| 199 | return 0; |
| 200 | |
| 201 | error: |
| 202 | platform_device_put(pdev); |
| 203 | return err; |
| 204 | } |
| 205 | |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 206 | /* |
| 207 | * Create mv64x60_eth platform devices |
| 208 | */ |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 209 | static struct platform_device * __init mv64x60_eth_register_shared_pdev( |
| 210 | struct device_node *np, int id) |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 211 | { |
| 212 | struct platform_device *pdev; |
| 213 | struct resource r[1]; |
| 214 | int err; |
| 215 | |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 216 | err = of_address_to_resource(np, 0, &r[0]); |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 217 | if (err) |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 218 | return ERR_PTR(err); |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 219 | |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 220 | pdev = platform_device_register_simple(MV643XX_ETH_SHARED_NAME, id, |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 221 | r, 1); |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 222 | return pdev; |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 223 | } |
| 224 | |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 225 | static int __init mv64x60_eth_device_setup(struct device_node *np, int id, |
| 226 | struct platform_device *shared_pdev) |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 227 | { |
| 228 | struct resource r[1]; |
| 229 | struct mv643xx_eth_platform_data pdata; |
| 230 | struct platform_device *pdev; |
| 231 | struct device_node *phy; |
| 232 | const u8 *mac_addr; |
| 233 | const int *prop; |
| 234 | const phandle *ph; |
| 235 | int err; |
| 236 | |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 237 | memset(r, 0, sizeof(r)); |
| 238 | of_irq_to_resource(np, 0, &r[0]); |
| 239 | |
| 240 | memset(&pdata, 0, sizeof(pdata)); |
| 241 | |
Lennert Buytenhek | fa3959f | 2008-04-24 01:27:02 +0200 | [diff] [blame] | 242 | pdata.shared = shared_pdev; |
| 243 | |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 244 | prop = of_get_property(np, "reg", NULL); |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 245 | if (!prop) |
| 246 | return -ENODEV; |
| 247 | pdata.port_number = *prop; |
| 248 | |
| 249 | mac_addr = of_get_mac_address(np); |
| 250 | if (mac_addr) |
| 251 | memcpy(pdata.mac_addr, mac_addr, 6); |
| 252 | |
| 253 | prop = of_get_property(np, "speed", NULL); |
| 254 | if (prop) |
| 255 | pdata.speed = *prop; |
| 256 | |
| 257 | prop = of_get_property(np, "tx_queue_size", NULL); |
| 258 | if (prop) |
| 259 | pdata.tx_queue_size = *prop; |
| 260 | |
| 261 | prop = of_get_property(np, "rx_queue_size", NULL); |
| 262 | if (prop) |
| 263 | pdata.rx_queue_size = *prop; |
| 264 | |
| 265 | prop = of_get_property(np, "tx_sram_addr", NULL); |
| 266 | if (prop) |
| 267 | pdata.tx_sram_addr = *prop; |
| 268 | |
| 269 | prop = of_get_property(np, "tx_sram_size", NULL); |
| 270 | if (prop) |
| 271 | pdata.tx_sram_size = *prop; |
| 272 | |
| 273 | prop = of_get_property(np, "rx_sram_addr", NULL); |
| 274 | if (prop) |
| 275 | pdata.rx_sram_addr = *prop; |
| 276 | |
| 277 | prop = of_get_property(np, "rx_sram_size", NULL); |
| 278 | if (prop) |
| 279 | pdata.rx_sram_size = *prop; |
| 280 | |
| 281 | ph = of_get_property(np, "phy", NULL); |
| 282 | if (!ph) |
| 283 | return -ENODEV; |
| 284 | |
| 285 | phy = of_find_node_by_phandle(*ph); |
| 286 | if (phy == NULL) |
| 287 | return -ENODEV; |
| 288 | |
| 289 | prop = of_get_property(phy, "reg", NULL); |
| 290 | if (prop) { |
| 291 | pdata.force_phy_addr = 1; |
| 292 | pdata.phy_addr = *prop; |
| 293 | } |
| 294 | |
| 295 | of_node_put(phy); |
| 296 | |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 297 | pdev = platform_device_alloc(MV643XX_ETH_NAME, id); |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 298 | if (!pdev) |
| 299 | return -ENOMEM; |
| 300 | |
| 301 | err = platform_device_add_resources(pdev, r, 1); |
| 302 | if (err) |
| 303 | goto error; |
| 304 | |
| 305 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 306 | if (err) |
| 307 | goto error; |
| 308 | |
| 309 | err = platform_device_add(pdev); |
| 310 | if (err) |
| 311 | goto error; |
| 312 | |
| 313 | return 0; |
| 314 | |
| 315 | error: |
| 316 | platform_device_put(pdev); |
| 317 | return err; |
| 318 | } |
| 319 | |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 320 | /* |
| 321 | * Create mv64x60_i2c platform devices |
| 322 | */ |
| 323 | static int __init mv64x60_i2c_device_setup(struct device_node *np, int id) |
| 324 | { |
| 325 | struct resource r[2]; |
| 326 | struct platform_device *pdev; |
| 327 | struct mv64xxx_i2c_pdata pdata; |
| 328 | const unsigned int *prop; |
| 329 | int err; |
| 330 | |
| 331 | memset(r, 0, sizeof(r)); |
| 332 | |
| 333 | err = of_address_to_resource(np, 0, &r[0]); |
| 334 | if (err) |
| 335 | return err; |
| 336 | |
| 337 | of_irq_to_resource(np, 0, &r[1]); |
| 338 | |
| 339 | memset(&pdata, 0, sizeof(pdata)); |
| 340 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 341 | pdata.freq_m = 8; /* default */ |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 342 | prop = of_get_property(np, "freq_m", NULL); |
Remi Machet | 21dbfd2 | 2008-04-22 03:36:48 +1000 | [diff] [blame] | 343 | if (prop) |
| 344 | pdata.freq_m = *prop; |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 345 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 346 | pdata.freq_m = 3; /* default */ |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 347 | prop = of_get_property(np, "freq_n", NULL); |
Remi Machet | 21dbfd2 | 2008-04-22 03:36:48 +1000 | [diff] [blame] | 348 | if (prop) |
| 349 | pdata.freq_n = *prop; |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 350 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 351 | pdata.timeout = 1000; /* default: 1 second */ |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 352 | |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 353 | pdev = platform_device_alloc(MV64XXX_I2C_CTLR_NAME, id); |
| 354 | if (!pdev) |
| 355 | return -ENOMEM; |
| 356 | |
| 357 | err = platform_device_add_resources(pdev, r, 2); |
| 358 | if (err) |
| 359 | goto error; |
| 360 | |
| 361 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 362 | if (err) |
| 363 | goto error; |
| 364 | |
| 365 | err = platform_device_add(pdev); |
| 366 | if (err) |
| 367 | goto error; |
| 368 | |
| 369 | return 0; |
| 370 | |
| 371 | error: |
| 372 | platform_device_put(pdev); |
| 373 | return err; |
| 374 | } |
| 375 | |
Dale Farnsworth | 7e07a15 | 2007-07-24 11:12:24 -0700 | [diff] [blame] | 376 | /* |
| 377 | * Create mv64x60_wdt platform devices |
| 378 | */ |
| 379 | static int __init mv64x60_wdt_device_setup(struct device_node *np, int id) |
| 380 | { |
| 381 | struct resource r; |
| 382 | struct platform_device *pdev; |
| 383 | struct mv64x60_wdt_pdata pdata; |
| 384 | const unsigned int *prop; |
| 385 | int err; |
| 386 | |
| 387 | err = of_address_to_resource(np, 0, &r); |
| 388 | if (err) |
| 389 | return err; |
| 390 | |
| 391 | memset(&pdata, 0, sizeof(pdata)); |
| 392 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 393 | pdata.timeout = 10; /* Default: 10 seconds */ |
Dale Farnsworth | 7e07a15 | 2007-07-24 11:12:24 -0700 | [diff] [blame] | 394 | |
| 395 | np = of_get_parent(np); |
| 396 | if (!np) |
| 397 | return -ENODEV; |
| 398 | |
| 399 | prop = of_get_property(np, "clock-frequency", NULL); |
| 400 | of_node_put(np); |
| 401 | if (!prop) |
| 402 | return -ENODEV; |
| 403 | pdata.bus_clk = *prop / 1000000; /* wdt driver wants freq in MHz */ |
| 404 | |
| 405 | pdev = platform_device_alloc(MV64x60_WDT_NAME, id); |
| 406 | if (!pdev) |
| 407 | return -ENOMEM; |
| 408 | |
| 409 | err = platform_device_add_resources(pdev, &r, 1); |
| 410 | if (err) |
| 411 | goto error; |
| 412 | |
| 413 | err = platform_device_add_data(pdev, &pdata, sizeof(pdata)); |
| 414 | if (err) |
| 415 | goto error; |
| 416 | |
| 417 | err = platform_device_add(pdev); |
| 418 | if (err) |
| 419 | goto error; |
| 420 | |
| 421 | return 0; |
| 422 | |
| 423 | error: |
| 424 | platform_device_put(pdev); |
| 425 | return err; |
| 426 | } |
| 427 | |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 428 | static int __init mv64x60_device_setup(void) |
| 429 | { |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 430 | struct device_node *np, *np2; |
| 431 | struct platform_device *pdev; |
| 432 | int id, id2; |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 433 | int err; |
| 434 | |
Cyrill Gorcunov | 26cb7d8 | 2007-11-30 06:44:36 +1100 | [diff] [blame] | 435 | id = 0; |
Remi Machet | ff114b6 | 2008-04-22 04:46:12 +1000 | [diff] [blame] | 436 | for_each_compatible_node(np, "serial", "marvell,mv64360-mpsc") { |
| 437 | err = mv64x60_mpsc_device_setup(np, id++); |
| 438 | if (err) |
| 439 | printk(KERN_ERR "Failed to initialize MV64x60 " |
| 440 | "serial device %s: error %d.\n", |
| 441 | np->full_name, err); |
| 442 | } |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 443 | |
Cyrill Gorcunov | 26cb7d8 | 2007-11-30 06:44:36 +1100 | [diff] [blame] | 444 | id = 0; |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 445 | id2 = 0; |
| 446 | for_each_compatible_node(np, NULL, "marvell,mv64360-eth-group") { |
| 447 | pdev = mv64x60_eth_register_shared_pdev(np, id++); |
| 448 | if (IS_ERR(pdev)) { |
| 449 | err = PTR_ERR(pdev); |
Remi Machet | ff114b6 | 2008-04-22 04:46:12 +1000 | [diff] [blame] | 450 | printk(KERN_ERR "Failed to initialize MV64x60 " |
| 451 | "network block %s: error %d.\n", |
| 452 | np->full_name, err); |
| 453 | continue; |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 454 | } |
| 455 | for_each_child_of_node(np, np2) { |
| 456 | if (!of_device_is_compatible(np2, |
| 457 | "marvell,mv64360-eth")) |
| 458 | continue; |
| 459 | err = mv64x60_eth_device_setup(np2, id2++, pdev); |
Remi Machet | ff114b6 | 2008-04-22 04:46:12 +1000 | [diff] [blame] | 460 | if (err) |
| 461 | printk(KERN_ERR "Failed to initialize " |
| 462 | "MV64x60 network device %s: " |
| 463 | "error %d.\n", |
| 464 | np2->full_name, err); |
Dale Farnsworth | a0916bd | 2008-04-08 08:11:27 +1000 | [diff] [blame] | 465 | } |
| 466 | } |
Dale Farnsworth | 649c8e0 | 2007-05-12 10:56:24 +1000 | [diff] [blame] | 467 | |
Cyrill Gorcunov | 26cb7d8 | 2007-11-30 06:44:36 +1100 | [diff] [blame] | 468 | id = 0; |
Remi Machet | ff114b6 | 2008-04-22 04:46:12 +1000 | [diff] [blame] | 469 | for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c") { |
| 470 | err = mv64x60_i2c_device_setup(np, id++); |
| 471 | if (err) |
| 472 | printk(KERN_ERR "Failed to initialize MV64x60 I2C " |
| 473 | "bus %s: error %d.\n", |
| 474 | np->full_name, err); |
| 475 | } |
Dale Farnsworth | 01f0e78 | 2007-05-12 10:56:47 +1000 | [diff] [blame] | 476 | |
Dale Farnsworth | 7e07a15 | 2007-07-24 11:12:24 -0700 | [diff] [blame] | 477 | /* support up to one watchdog timer */ |
Mark A. Greer | a1810b4 | 2008-04-08 08:09:03 +1000 | [diff] [blame] | 478 | np = of_find_compatible_node(np, NULL, "marvell,mv64360-wdt"); |
Dale Farnsworth | 7e07a15 | 2007-07-24 11:12:24 -0700 | [diff] [blame] | 479 | if (np) { |
| 480 | if ((err = mv64x60_wdt_device_setup(np, id))) |
Remi Machet | ff114b6 | 2008-04-22 04:46:12 +1000 | [diff] [blame] | 481 | printk(KERN_ERR "Failed to initialize MV64x60 " |
| 482 | "Watchdog %s: error %d.\n", |
| 483 | np->full_name, err); |
Dale Farnsworth | 7e07a15 | 2007-07-24 11:12:24 -0700 | [diff] [blame] | 484 | of_node_put(np); |
| 485 | } |
| 486 | |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 487 | return 0; |
Dale Farnsworth | 52d3aff | 2007-05-12 10:55:53 +1000 | [diff] [blame] | 488 | } |
| 489 | arch_initcall(mv64x60_device_setup); |
Mark A. Greer | 542c98c | 2007-06-07 10:38:00 +1000 | [diff] [blame] | 490 | |
| 491 | static int __init mv64x60_add_mpsc_console(void) |
| 492 | { |
| 493 | struct device_node *np = NULL; |
| 494 | const char *prop; |
| 495 | |
| 496 | prop = of_get_property(of_chosen, "linux,stdout-path", NULL); |
| 497 | if (prop == NULL) |
| 498 | goto not_mpsc; |
| 499 | |
| 500 | np = of_find_node_by_path(prop); |
| 501 | if (!np) |
| 502 | goto not_mpsc; |
| 503 | |
Mark A. Greer | a1810b4 | 2008-04-08 08:09:03 +1000 | [diff] [blame] | 504 | if (!of_device_is_compatible(np, "marvell,mv64360-mpsc")) |
Mark A. Greer | 542c98c | 2007-06-07 10:38:00 +1000 | [diff] [blame] | 505 | goto not_mpsc; |
| 506 | |
Mark A. Greer | 1791f91 | 2008-04-08 08:10:34 +1000 | [diff] [blame] | 507 | prop = of_get_property(np, "cell-index", NULL); |
Mark A. Greer | 542c98c | 2007-06-07 10:38:00 +1000 | [diff] [blame] | 508 | if (!prop) |
| 509 | goto not_mpsc; |
| 510 | |
| 511 | add_preferred_console("ttyMM", *(int *)prop, NULL); |
| 512 | |
| 513 | not_mpsc: |
| 514 | return 0; |
| 515 | } |
| 516 | console_initcall(mv64x60_add_mpsc_console); |