board_bcm963xx.c 16 KB

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