board_bcm963xx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
  7. * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/string.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/mtd/mtd.h>
  14. #include <linux/mtd/partitions.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/ssb/ssb.h>
  17. #include <asm/addrspace.h>
  18. #include <bcm63xx_board.h>
  19. #include <bcm63xx_cpu.h>
  20. #include <bcm63xx_dev_uart.h>
  21. #include <bcm63xx_regs.h>
  22. #include <bcm63xx_io.h>
  23. #include <bcm63xx_dev_pci.h>
  24. #include <bcm63xx_dev_enet.h>
  25. #include <bcm63xx_dev_dsp.h>
  26. #include <bcm63xx_dev_pcmcia.h>
  27. #include <board_bcm963xx.h>
  28. #define PFX "board_bcm963xx: "
  29. static struct bcm963xx_nvram nvram;
  30. static unsigned int mac_addr_used;
  31. static struct board_info board;
  32. /*
  33. * known 6338 boards
  34. */
  35. #ifdef CONFIG_BCM63XX_CPU_6338
  36. static struct board_info __initdata board_96338gw = {
  37. .name = "96338GW",
  38. .expected_cpu_id = 0x6338,
  39. .has_uart0 = 1,
  40. .has_enet0 = 1,
  41. .enet0 = {
  42. .force_speed_100 = 1,
  43. .force_duplex_full = 1,
  44. },
  45. .has_ohci0 = 1,
  46. .leds = {
  47. {
  48. .name = "adsl",
  49. .gpio = 3,
  50. .active_low = 1,
  51. },
  52. {
  53. .name = "ses",
  54. .gpio = 5,
  55. .active_low = 1,
  56. },
  57. {
  58. .name = "ppp-fail",
  59. .gpio = 4,
  60. .active_low = 1,
  61. },
  62. {
  63. .name = "power",
  64. .gpio = 0,
  65. .active_low = 1,
  66. .default_trigger = "default-on",
  67. },
  68. {
  69. .name = "stop",
  70. .gpio = 1,
  71. .active_low = 1,
  72. }
  73. },
  74. };
  75. static struct board_info __initdata board_96338w = {
  76. .name = "96338W",
  77. .expected_cpu_id = 0x6338,
  78. .has_uart0 = 1,
  79. .has_enet0 = 1,
  80. .enet0 = {
  81. .force_speed_100 = 1,
  82. .force_duplex_full = 1,
  83. },
  84. .leds = {
  85. {
  86. .name = "adsl",
  87. .gpio = 3,
  88. .active_low = 1,
  89. },
  90. {
  91. .name = "ses",
  92. .gpio = 5,
  93. .active_low = 1,
  94. },
  95. {
  96. .name = "ppp-fail",
  97. .gpio = 4,
  98. .active_low = 1,
  99. },
  100. {
  101. .name = "power",
  102. .gpio = 0,
  103. .active_low = 1,
  104. .default_trigger = "default-on",
  105. },
  106. {
  107. .name = "stop",
  108. .gpio = 1,
  109. .active_low = 1,
  110. },
  111. },
  112. };
  113. #endif
  114. /*
  115. * known 6345 boards
  116. */
  117. #ifdef CONFIG_BCM63XX_CPU_6345
  118. static struct board_info __initdata board_96345gw2 = {
  119. .name = "96345GW2",
  120. .expected_cpu_id = 0x6345,
  121. .has_uart0 = 1,
  122. };
  123. #endif
  124. /*
  125. * known 6348 boards
  126. */
  127. #ifdef CONFIG_BCM63XX_CPU_6348
  128. static struct board_info __initdata board_96348r = {
  129. .name = "96348R",
  130. .expected_cpu_id = 0x6348,
  131. .has_uart0 = 1,
  132. .has_enet0 = 1,
  133. .has_pci = 1,
  134. .enet0 = {
  135. .has_phy = 1,
  136. .use_internal_phy = 1,
  137. },
  138. .leds = {
  139. {
  140. .name = "adsl-fail",
  141. .gpio = 2,
  142. .active_low = 1,
  143. },
  144. {
  145. .name = "ppp",
  146. .gpio = 3,
  147. .active_low = 1,
  148. },
  149. {
  150. .name = "ppp-fail",
  151. .gpio = 4,
  152. .active_low = 1,
  153. },
  154. {
  155. .name = "power",
  156. .gpio = 0,
  157. .active_low = 1,
  158. .default_trigger = "default-on",
  159. },
  160. {
  161. .name = "stop",
  162. .gpio = 1,
  163. .active_low = 1,
  164. },
  165. },
  166. };
  167. static struct board_info __initdata board_96348gw_10 = {
  168. .name = "96348GW-10",
  169. .expected_cpu_id = 0x6348,
  170. .has_uart0 = 1,
  171. .has_enet0 = 1,
  172. .has_enet1 = 1,
  173. .has_pci = 1,
  174. .enet0 = {
  175. .has_phy = 1,
  176. .use_internal_phy = 1,
  177. },
  178. .enet1 = {
  179. .force_speed_100 = 1,
  180. .force_duplex_full = 1,
  181. },
  182. .has_ohci0 = 1,
  183. .has_pccard = 1,
  184. .has_ehci0 = 1,
  185. .has_dsp = 1,
  186. .dsp = {
  187. .gpio_rst = 6,
  188. .gpio_int = 34,
  189. .cs = 2,
  190. .ext_irq = 2,
  191. },
  192. .leds = {
  193. {
  194. .name = "adsl-fail",
  195. .gpio = 2,
  196. .active_low = 1,
  197. },
  198. {
  199. .name = "ppp",
  200. .gpio = 3,
  201. .active_low = 1,
  202. },
  203. {
  204. .name = "ppp-fail",
  205. .gpio = 4,
  206. .active_low = 1,
  207. },
  208. {
  209. .name = "power",
  210. .gpio = 0,
  211. .active_low = 1,
  212. .default_trigger = "default-on",
  213. },
  214. {
  215. .name = "stop",
  216. .gpio = 1,
  217. .active_low = 1,
  218. },
  219. },
  220. };
  221. static struct board_info __initdata board_96348gw_11 = {
  222. .name = "96348GW-11",
  223. .expected_cpu_id = 0x6348,
  224. .has_uart0 = 1,
  225. .has_enet0 = 1,
  226. .has_enet1 = 1,
  227. .has_pci = 1,
  228. .enet0 = {
  229. .has_phy = 1,
  230. .use_internal_phy = 1,
  231. },
  232. .enet1 = {
  233. .force_speed_100 = 1,
  234. .force_duplex_full = 1,
  235. },
  236. .has_ohci0 = 1,
  237. .has_pccard = 1,
  238. .has_ehci0 = 1,
  239. .leds = {
  240. {
  241. .name = "adsl-fail",
  242. .gpio = 2,
  243. .active_low = 1,
  244. },
  245. {
  246. .name = "ppp",
  247. .gpio = 3,
  248. .active_low = 1,
  249. },
  250. {
  251. .name = "ppp-fail",
  252. .gpio = 4,
  253. .active_low = 1,
  254. },
  255. {
  256. .name = "power",
  257. .gpio = 0,
  258. .active_low = 1,
  259. .default_trigger = "default-on",
  260. },
  261. {
  262. .name = "stop",
  263. .gpio = 1,
  264. .active_low = 1,
  265. },
  266. },
  267. };
  268. static struct board_info __initdata board_96348gw = {
  269. .name = "96348GW",
  270. .expected_cpu_id = 0x6348,
  271. .has_uart0 = 1,
  272. .has_enet0 = 1,
  273. .has_enet1 = 1,
  274. .has_pci = 1,
  275. .enet0 = {
  276. .has_phy = 1,
  277. .use_internal_phy = 1,
  278. },
  279. .enet1 = {
  280. .force_speed_100 = 1,
  281. .force_duplex_full = 1,
  282. },
  283. .has_ohci0 = 1,
  284. .has_dsp = 1,
  285. .dsp = {
  286. .gpio_rst = 6,
  287. .gpio_int = 34,
  288. .ext_irq = 2,
  289. .cs = 2,
  290. },
  291. .leds = {
  292. {
  293. .name = "adsl-fail",
  294. .gpio = 2,
  295. .active_low = 1,
  296. },
  297. {
  298. .name = "ppp",
  299. .gpio = 3,
  300. .active_low = 1,
  301. },
  302. {
  303. .name = "ppp-fail",
  304. .gpio = 4,
  305. .active_low = 1,
  306. },
  307. {
  308. .name = "power",
  309. .gpio = 0,
  310. .active_low = 1,
  311. .default_trigger = "default-on",
  312. },
  313. {
  314. .name = "stop",
  315. .gpio = 1,
  316. .active_low = 1,
  317. },
  318. },
  319. };
  320. static struct board_info __initdata board_FAST2404 = {
  321. .name = "F@ST2404",
  322. .expected_cpu_id = 0x6348,
  323. .has_uart0 = 1,
  324. .has_enet0 = 1,
  325. .has_enet1 = 1,
  326. .has_pci = 1,
  327. .enet0 = {
  328. .has_phy = 1,
  329. .use_internal_phy = 1,
  330. },
  331. .enet1 = {
  332. .force_speed_100 = 1,
  333. .force_duplex_full = 1,
  334. },
  335. .has_ohci0 = 1,
  336. .has_pccard = 1,
  337. .has_ehci0 = 1,
  338. };
  339. static struct board_info __initdata board_rta1025w_16 = {
  340. .name = "RTA1025W_16",
  341. .expected_cpu_id = 0x6348,
  342. .has_enet0 = 1,
  343. .has_enet1 = 1,
  344. .has_pci = 1,
  345. .enet0 = {
  346. .has_phy = 1,
  347. .use_internal_phy = 1,
  348. },
  349. .enet1 = {
  350. .force_speed_100 = 1,
  351. .force_duplex_full = 1,
  352. },
  353. };
  354. static struct board_info __initdata board_DV201AMR = {
  355. .name = "DV201AMR",
  356. .expected_cpu_id = 0x6348,
  357. .has_uart0 = 1,
  358. .has_pci = 1,
  359. .has_ohci0 = 1,
  360. .has_enet0 = 1,
  361. .has_enet1 = 1,
  362. .enet0 = {
  363. .has_phy = 1,
  364. .use_internal_phy = 1,
  365. },
  366. .enet1 = {
  367. .force_speed_100 = 1,
  368. .force_duplex_full = 1,
  369. },
  370. };
  371. static struct board_info __initdata board_96348gw_a = {
  372. .name = "96348GW-A",
  373. .expected_cpu_id = 0x6348,
  374. .has_uart0 = 1,
  375. .has_enet0 = 1,
  376. .has_enet1 = 1,
  377. .has_pci = 1,
  378. .enet0 = {
  379. .has_phy = 1,
  380. .use_internal_phy = 1,
  381. },
  382. .enet1 = {
  383. .force_speed_100 = 1,
  384. .force_duplex_full = 1,
  385. },
  386. .has_ohci0 = 1,
  387. };
  388. #endif
  389. /*
  390. * known 6358 boards
  391. */
  392. #ifdef CONFIG_BCM63XX_CPU_6358
  393. static struct board_info __initdata board_96358vw = {
  394. .name = "96358VW",
  395. .expected_cpu_id = 0x6358,
  396. .has_uart0 = 1,
  397. .has_enet0 = 1,
  398. .has_enet1 = 1,
  399. .has_pci = 1,
  400. .enet0 = {
  401. .has_phy = 1,
  402. .use_internal_phy = 1,
  403. },
  404. .enet1 = {
  405. .force_speed_100 = 1,
  406. .force_duplex_full = 1,
  407. },
  408. .has_ohci0 = 1,
  409. .has_pccard = 1,
  410. .has_ehci0 = 1,
  411. .leds = {
  412. {
  413. .name = "adsl-fail",
  414. .gpio = 15,
  415. .active_low = 1,
  416. },
  417. {
  418. .name = "ppp",
  419. .gpio = 22,
  420. .active_low = 1,
  421. },
  422. {
  423. .name = "ppp-fail",
  424. .gpio = 23,
  425. .active_low = 1,
  426. },
  427. {
  428. .name = "power",
  429. .gpio = 4,
  430. .default_trigger = "default-on",
  431. },
  432. {
  433. .name = "stop",
  434. .gpio = 5,
  435. },
  436. },
  437. };
  438. static struct board_info __initdata board_96358vw2 = {
  439. .name = "96358VW2",
  440. .expected_cpu_id = 0x6358,
  441. .has_uart0 = 1,
  442. .has_enet0 = 1,
  443. .has_enet1 = 1,
  444. .has_pci = 1,
  445. .enet0 = {
  446. .has_phy = 1,
  447. .use_internal_phy = 1,
  448. },
  449. .enet1 = {
  450. .force_speed_100 = 1,
  451. .force_duplex_full = 1,
  452. },
  453. .has_ohci0 = 1,
  454. .has_pccard = 1,
  455. .has_ehci0 = 1,
  456. .leds = {
  457. {
  458. .name = "adsl",
  459. .gpio = 22,
  460. .active_low = 1,
  461. },
  462. {
  463. .name = "ppp-fail",
  464. .gpio = 23,
  465. },
  466. {
  467. .name = "power",
  468. .gpio = 5,
  469. .active_low = 1,
  470. .default_trigger = "default-on",
  471. },
  472. {
  473. .name = "stop",
  474. .gpio = 4,
  475. .active_low = 1,
  476. },
  477. },
  478. };
  479. static struct board_info __initdata board_AGPFS0 = {
  480. .name = "AGPF-S0",
  481. .expected_cpu_id = 0x6358,
  482. .has_uart0 = 1,
  483. .has_enet0 = 1,
  484. .has_enet1 = 1,
  485. .has_pci = 1,
  486. .enet0 = {
  487. .has_phy = 1,
  488. .use_internal_phy = 1,
  489. },
  490. .enet1 = {
  491. .force_speed_100 = 1,
  492. .force_duplex_full = 1,
  493. },
  494. .has_ohci0 = 1,
  495. .has_ehci0 = 1,
  496. };
  497. static struct board_info __initdata board_DWVS0 = {
  498. .name = "DWV-S0",
  499. .expected_cpu_id = 0x6358,
  500. .has_enet0 = 1,
  501. .has_enet1 = 1,
  502. .has_pci = 1,
  503. .enet0 = {
  504. .has_phy = 1,
  505. .use_internal_phy = 1,
  506. },
  507. .enet1 = {
  508. .force_speed_100 = 1,
  509. .force_duplex_full = 1,
  510. },
  511. .has_ohci0 = 1,
  512. };
  513. #endif
  514. /*
  515. * all boards
  516. */
  517. static const struct board_info __initdata *bcm963xx_boards[] = {
  518. #ifdef CONFIG_BCM63XX_CPU_6338
  519. &board_96338gw,
  520. &board_96338w,
  521. #endif
  522. #ifdef CONFIG_BCM63XX_CPU_6345
  523. &board_96345gw2,
  524. #endif
  525. #ifdef CONFIG_BCM63XX_CPU_6348
  526. &board_96348r,
  527. &board_96348gw,
  528. &board_96348gw_10,
  529. &board_96348gw_11,
  530. &board_FAST2404,
  531. &board_DV201AMR,
  532. &board_96348gw_a,
  533. &board_rta1025w_16,
  534. #endif
  535. #ifdef CONFIG_BCM63XX_CPU_6358
  536. &board_96358vw,
  537. &board_96358vw2,
  538. &board_AGPFS0,
  539. &board_DWVS0,
  540. #endif
  541. };
  542. /*
  543. * Register a sane SPROMv2 to make the on-board
  544. * bcm4318 WLAN work
  545. */
  546. #ifdef CONFIG_SSB_PCIHOST
  547. static struct ssb_sprom bcm63xx_sprom = {
  548. .revision = 0x02,
  549. .board_rev = 0x17,
  550. .country_code = 0x0,
  551. .ant_available_bg = 0x3,
  552. .pa0b0 = 0x15ae,
  553. .pa0b1 = 0xfa85,
  554. .pa0b2 = 0xfe8d,
  555. .pa1b0 = 0xffff,
  556. .pa1b1 = 0xffff,
  557. .pa1b2 = 0xffff,
  558. .gpio0 = 0xff,
  559. .gpio1 = 0xff,
  560. .gpio2 = 0xff,
  561. .gpio3 = 0xff,
  562. .maxpwr_bg = 0x004c,
  563. .itssi_bg = 0x00,
  564. .boardflags_lo = 0x2848,
  565. .boardflags_hi = 0x0000,
  566. };
  567. int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  568. {
  569. if (bus->bustype == SSB_BUSTYPE_PCI) {
  570. memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  571. return 0;
  572. } else {
  573. printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
  574. return -EINVAL;
  575. }
  576. }
  577. #endif
  578. /*
  579. * return board name for /proc/cpuinfo
  580. */
  581. const char *board_get_name(void)
  582. {
  583. return board.name;
  584. }
  585. /*
  586. * register & return a new board mac address
  587. */
  588. static int board_get_mac_address(u8 *mac)
  589. {
  590. u8 *p;
  591. int count;
  592. if (mac_addr_used >= nvram.mac_addr_count) {
  593. printk(KERN_ERR PFX "not enough mac address\n");
  594. return -ENODEV;
  595. }
  596. memcpy(mac, nvram.mac_addr_base, ETH_ALEN);
  597. p = mac + ETH_ALEN - 1;
  598. count = mac_addr_used;
  599. while (count--) {
  600. do {
  601. (*p)++;
  602. if (*p != 0)
  603. break;
  604. p--;
  605. } while (p != mac);
  606. }
  607. if (p == mac) {
  608. printk(KERN_ERR PFX "unable to fetch mac address\n");
  609. return -ENODEV;
  610. }
  611. mac_addr_used++;
  612. return 0;
  613. }
  614. /*
  615. * early init callback, read nvram data from flash and checksum it
  616. */
  617. void __init board_prom_init(void)
  618. {
  619. unsigned int check_len, i;
  620. u8 *boot_addr, *cfe, *p;
  621. char cfe_version[32];
  622. u32 val;
  623. /* read base address of boot chip select (0) */
  624. val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  625. val &= MPI_CSBASE_BASE_MASK;
  626. boot_addr = (u8 *)KSEG1ADDR(val);
  627. /* dump cfe version */
  628. cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
  629. if (!memcmp(cfe, "cfe-v", 5))
  630. snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u",
  631. cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]);
  632. else
  633. strcpy(cfe_version, "unknown");
  634. printk(KERN_INFO PFX "CFE version: %s\n", cfe_version);
  635. /* extract nvram data */
  636. memcpy(&nvram, boot_addr + BCM963XX_NVRAM_OFFSET, sizeof(nvram));
  637. /* check checksum before using data */
  638. if (nvram.version <= 4)
  639. check_len = offsetof(struct bcm963xx_nvram, checksum_old);
  640. else
  641. check_len = sizeof(nvram);
  642. val = 0;
  643. p = (u8 *)&nvram;
  644. while (check_len--)
  645. val += *p;
  646. if (val) {
  647. printk(KERN_ERR PFX "invalid nvram checksum\n");
  648. return;
  649. }
  650. /* find board by name */
  651. for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
  652. if (strncmp(nvram.name, bcm963xx_boards[i]->name,
  653. sizeof(nvram.name)))
  654. continue;
  655. /* copy, board desc array is marked initdata */
  656. memcpy(&board, bcm963xx_boards[i], sizeof(board));
  657. break;
  658. }
  659. /* bail out if board is not found, will complain later */
  660. if (!board.name[0]) {
  661. char name[17];
  662. memcpy(name, nvram.name, 16);
  663. name[16] = 0;
  664. printk(KERN_ERR PFX "unknown bcm963xx board: %s\n",
  665. name);
  666. return;
  667. }
  668. /* setup pin multiplexing depending on board enabled device,
  669. * this has to be done this early since PCI init is done
  670. * inside arch_initcall */
  671. val = 0;
  672. #ifdef CONFIG_PCI
  673. if (board.has_pci) {
  674. bcm63xx_pci_enabled = 1;
  675. if (BCMCPU_IS_6348())
  676. val |= GPIO_MODE_6348_G2_PCI;
  677. }
  678. #endif
  679. if (board.has_pccard) {
  680. if (BCMCPU_IS_6348())
  681. val |= GPIO_MODE_6348_G1_MII_PCCARD;
  682. }
  683. if (board.has_enet0 && !board.enet0.use_internal_phy) {
  684. if (BCMCPU_IS_6348())
  685. val |= GPIO_MODE_6348_G3_EXT_MII |
  686. GPIO_MODE_6348_G0_EXT_MII;
  687. }
  688. if (board.has_enet1 && !board.enet1.use_internal_phy) {
  689. if (BCMCPU_IS_6348())
  690. val |= GPIO_MODE_6348_G3_EXT_MII |
  691. GPIO_MODE_6348_G0_EXT_MII;
  692. }
  693. bcm_gpio_writel(val, GPIO_MODE_REG);
  694. }
  695. /*
  696. * second stage init callback, good time to panic if we couldn't
  697. * identify on which board we're running since early printk is working
  698. */
  699. void __init board_setup(void)
  700. {
  701. if (!board.name[0])
  702. panic("unable to detect bcm963xx board");
  703. printk(KERN_INFO PFX "board name: %s\n", board.name);
  704. /* make sure we're running on expected cpu */
  705. if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
  706. panic("unexpected CPU for bcm963xx board");
  707. }
  708. static struct mtd_partition mtd_partitions[] = {
  709. {
  710. .name = "cfe",
  711. .offset = 0x0,
  712. .size = 0x40000,
  713. }
  714. };
  715. static const char *bcm63xx_part_types[] = { "bcm63xxpart", NULL };
  716. static struct physmap_flash_data flash_data = {
  717. .width = 2,
  718. .nr_parts = ARRAY_SIZE(mtd_partitions),
  719. .parts = mtd_partitions,
  720. .part_probe_types = bcm63xx_part_types,
  721. };
  722. static struct resource mtd_resources[] = {
  723. {
  724. .start = 0, /* filled at runtime */
  725. .end = 0, /* filled at runtime */
  726. .flags = IORESOURCE_MEM,
  727. }
  728. };
  729. static struct platform_device mtd_dev = {
  730. .name = "physmap-flash",
  731. .resource = mtd_resources,
  732. .num_resources = ARRAY_SIZE(mtd_resources),
  733. .dev = {
  734. .platform_data = &flash_data,
  735. },
  736. };
  737. static struct gpio_led_platform_data bcm63xx_led_data;
  738. static struct platform_device bcm63xx_gpio_leds = {
  739. .name = "leds-gpio",
  740. .id = 0,
  741. .dev.platform_data = &bcm63xx_led_data,
  742. };
  743. /*
  744. * third stage init callback, register all board devices.
  745. */
  746. int __init board_register_devices(void)
  747. {
  748. u32 val;
  749. if (board.has_uart0)
  750. bcm63xx_uart_register(0);
  751. if (board.has_uart1)
  752. bcm63xx_uart_register(1);
  753. if (board.has_pccard)
  754. bcm63xx_pcmcia_register();
  755. if (board.has_enet0 &&
  756. !board_get_mac_address(board.enet0.mac_addr))
  757. bcm63xx_enet_register(0, &board.enet0);
  758. if (board.has_enet1 &&
  759. !board_get_mac_address(board.enet1.mac_addr))
  760. bcm63xx_enet_register(1, &board.enet1);
  761. if (board.has_dsp)
  762. bcm63xx_dsp_register(&board.dsp);
  763. /* Generate MAC address for WLAN and register our SPROM,
  764. * do this after registering enet devices
  765. */
  766. #ifdef CONFIG_SSB_PCIHOST
  767. if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
  768. memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  769. memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  770. if (ssb_arch_register_fallback_sprom(
  771. &bcm63xx_get_fallback_sprom) < 0)
  772. pr_err(PFX "failed to register fallback SPROM\n");
  773. }
  774. #endif
  775. /* read base address of boot chip select (0) */
  776. val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  777. val &= MPI_CSBASE_BASE_MASK;
  778. mtd_resources[0].start = val;
  779. mtd_resources[0].end = 0x1FFFFFFF;
  780. platform_device_register(&mtd_dev);
  781. bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
  782. bcm63xx_led_data.leds = board.leds;
  783. platform_device_register(&bcm63xx_gpio_leds);
  784. return 0;
  785. }