board_bcm963xx.c 16 KB

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