board_bcm963xx.c 16 KB

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