board_bcm963xx.c 16 KB

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