board_bcm963xx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  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_nvram.h>
  21. #include <bcm63xx_dev_pci.h>
  22. #include <bcm63xx_dev_enet.h>
  23. #include <bcm63xx_dev_dsp.h>
  24. #include <bcm63xx_dev_flash.h>
  25. #include <bcm63xx_dev_pcmcia.h>
  26. #include <bcm63xx_dev_spi.h>
  27. #include <bcm63xx_dev_usb_usbd.h>
  28. #include <board_bcm963xx.h>
  29. #include <uapi/linux/bcm933xx_hcs.h>
  30. #define PFX "board_bcm963xx: "
  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. .has_dsp = 1,
  257. .dsp = {
  258. .gpio_rst = 6,
  259. .gpio_int = 34,
  260. .cs = 2,
  261. .ext_irq = 2,
  262. },
  263. .leds = {
  264. {
  265. .name = "adsl-fail",
  266. .gpio = 2,
  267. .active_low = 1,
  268. },
  269. {
  270. .name = "ppp",
  271. .gpio = 3,
  272. .active_low = 1,
  273. },
  274. {
  275. .name = "ppp-fail",
  276. .gpio = 4,
  277. .active_low = 1,
  278. },
  279. {
  280. .name = "power",
  281. .gpio = 0,
  282. .active_low = 1,
  283. .default_trigger = "default-on",
  284. },
  285. {
  286. .name = "stop",
  287. .gpio = 1,
  288. .active_low = 1,
  289. },
  290. },
  291. };
  292. static struct board_info __initdata board_96348gw_11 = {
  293. .name = "96348GW-11",
  294. .expected_cpu_id = 0x6348,
  295. .has_uart0 = 1,
  296. .has_enet0 = 1,
  297. .has_enet1 = 1,
  298. .has_pci = 1,
  299. .enet0 = {
  300. .has_phy = 1,
  301. .use_internal_phy = 1,
  302. },
  303. .enet1 = {
  304. .force_speed_100 = 1,
  305. .force_duplex_full = 1,
  306. },
  307. .has_ohci0 = 1,
  308. .has_pccard = 1,
  309. .has_ehci0 = 1,
  310. .leds = {
  311. {
  312. .name = "adsl-fail",
  313. .gpio = 2,
  314. .active_low = 1,
  315. },
  316. {
  317. .name = "ppp",
  318. .gpio = 3,
  319. .active_low = 1,
  320. },
  321. {
  322. .name = "ppp-fail",
  323. .gpio = 4,
  324. .active_low = 1,
  325. },
  326. {
  327. .name = "power",
  328. .gpio = 0,
  329. .active_low = 1,
  330. .default_trigger = "default-on",
  331. },
  332. {
  333. .name = "stop",
  334. .gpio = 1,
  335. .active_low = 1,
  336. },
  337. },
  338. };
  339. static struct board_info __initdata board_96348gw = {
  340. .name = "96348GW",
  341. .expected_cpu_id = 0x6348,
  342. .has_uart0 = 1,
  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. .has_ohci0 = 1,
  355. .has_dsp = 1,
  356. .dsp = {
  357. .gpio_rst = 6,
  358. .gpio_int = 34,
  359. .ext_irq = 2,
  360. .cs = 2,
  361. },
  362. .leds = {
  363. {
  364. .name = "adsl-fail",
  365. .gpio = 2,
  366. .active_low = 1,
  367. },
  368. {
  369. .name = "ppp",
  370. .gpio = 3,
  371. .active_low = 1,
  372. },
  373. {
  374. .name = "ppp-fail",
  375. .gpio = 4,
  376. .active_low = 1,
  377. },
  378. {
  379. .name = "power",
  380. .gpio = 0,
  381. .active_low = 1,
  382. .default_trigger = "default-on",
  383. },
  384. {
  385. .name = "stop",
  386. .gpio = 1,
  387. .active_low = 1,
  388. },
  389. },
  390. };
  391. static struct board_info __initdata board_FAST2404 = {
  392. .name = "F@ST2404",
  393. .expected_cpu_id = 0x6348,
  394. .has_uart0 = 1,
  395. .has_enet0 = 1,
  396. .has_enet1 = 1,
  397. .has_pci = 1,
  398. .enet0 = {
  399. .has_phy = 1,
  400. .use_internal_phy = 1,
  401. },
  402. .enet1 = {
  403. .force_speed_100 = 1,
  404. .force_duplex_full = 1,
  405. },
  406. .has_ohci0 = 1,
  407. .has_pccard = 1,
  408. .has_ehci0 = 1,
  409. };
  410. static struct board_info __initdata board_rta1025w_16 = {
  411. .name = "RTA1025W_16",
  412. .expected_cpu_id = 0x6348,
  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. };
  425. static struct board_info __initdata board_DV201AMR = {
  426. .name = "DV201AMR",
  427. .expected_cpu_id = 0x6348,
  428. .has_uart0 = 1,
  429. .has_pci = 1,
  430. .has_ohci0 = 1,
  431. .has_enet0 = 1,
  432. .has_enet1 = 1,
  433. .enet0 = {
  434. .has_phy = 1,
  435. .use_internal_phy = 1,
  436. },
  437. .enet1 = {
  438. .force_speed_100 = 1,
  439. .force_duplex_full = 1,
  440. },
  441. };
  442. static struct board_info __initdata board_96348gw_a = {
  443. .name = "96348GW-A",
  444. .expected_cpu_id = 0x6348,
  445. .has_uart0 = 1,
  446. .has_enet0 = 1,
  447. .has_enet1 = 1,
  448. .has_pci = 1,
  449. .enet0 = {
  450. .has_phy = 1,
  451. .use_internal_phy = 1,
  452. },
  453. .enet1 = {
  454. .force_speed_100 = 1,
  455. .force_duplex_full = 1,
  456. },
  457. .has_ohci0 = 1,
  458. };
  459. #endif
  460. /*
  461. * known 6358 boards
  462. */
  463. #ifdef CONFIG_BCM63XX_CPU_6358
  464. static struct board_info __initdata board_96358vw = {
  465. .name = "96358VW",
  466. .expected_cpu_id = 0x6358,
  467. .has_uart0 = 1,
  468. .has_enet0 = 1,
  469. .has_enet1 = 1,
  470. .has_pci = 1,
  471. .enet0 = {
  472. .has_phy = 1,
  473. .use_internal_phy = 1,
  474. },
  475. .enet1 = {
  476. .force_speed_100 = 1,
  477. .force_duplex_full = 1,
  478. },
  479. .has_ohci0 = 1,
  480. .has_pccard = 1,
  481. .has_ehci0 = 1,
  482. .leds = {
  483. {
  484. .name = "adsl-fail",
  485. .gpio = 15,
  486. .active_low = 1,
  487. },
  488. {
  489. .name = "ppp",
  490. .gpio = 22,
  491. .active_low = 1,
  492. },
  493. {
  494. .name = "ppp-fail",
  495. .gpio = 23,
  496. .active_low = 1,
  497. },
  498. {
  499. .name = "power",
  500. .gpio = 4,
  501. .default_trigger = "default-on",
  502. },
  503. {
  504. .name = "stop",
  505. .gpio = 5,
  506. },
  507. },
  508. };
  509. static struct board_info __initdata board_96358vw2 = {
  510. .name = "96358VW2",
  511. .expected_cpu_id = 0x6358,
  512. .has_uart0 = 1,
  513. .has_enet0 = 1,
  514. .has_enet1 = 1,
  515. .has_pci = 1,
  516. .enet0 = {
  517. .has_phy = 1,
  518. .use_internal_phy = 1,
  519. },
  520. .enet1 = {
  521. .force_speed_100 = 1,
  522. .force_duplex_full = 1,
  523. },
  524. .has_ohci0 = 1,
  525. .has_pccard = 1,
  526. .has_ehci0 = 1,
  527. .leds = {
  528. {
  529. .name = "adsl",
  530. .gpio = 22,
  531. .active_low = 1,
  532. },
  533. {
  534. .name = "ppp-fail",
  535. .gpio = 23,
  536. },
  537. {
  538. .name = "power",
  539. .gpio = 5,
  540. .active_low = 1,
  541. .default_trigger = "default-on",
  542. },
  543. {
  544. .name = "stop",
  545. .gpio = 4,
  546. .active_low = 1,
  547. },
  548. },
  549. };
  550. static struct board_info __initdata board_AGPFS0 = {
  551. .name = "AGPF-S0",
  552. .expected_cpu_id = 0x6358,
  553. .has_uart0 = 1,
  554. .has_enet0 = 1,
  555. .has_enet1 = 1,
  556. .has_pci = 1,
  557. .enet0 = {
  558. .has_phy = 1,
  559. .use_internal_phy = 1,
  560. },
  561. .enet1 = {
  562. .force_speed_100 = 1,
  563. .force_duplex_full = 1,
  564. },
  565. .has_ohci0 = 1,
  566. .has_ehci0 = 1,
  567. };
  568. static struct board_info __initdata board_DWVS0 = {
  569. .name = "DWV-S0",
  570. .expected_cpu_id = 0x6358,
  571. .has_enet0 = 1,
  572. .has_enet1 = 1,
  573. .has_pci = 1,
  574. .enet0 = {
  575. .has_phy = 1,
  576. .use_internal_phy = 1,
  577. },
  578. .enet1 = {
  579. .force_speed_100 = 1,
  580. .force_duplex_full = 1,
  581. },
  582. .has_ohci0 = 1,
  583. };
  584. #endif
  585. /*
  586. * all boards
  587. */
  588. static const struct board_info __initconst *bcm963xx_boards[] = {
  589. #ifdef CONFIG_BCM63XX_CPU_3368
  590. &board_cvg834g,
  591. #endif
  592. #ifdef CONFIG_BCM63XX_CPU_6328
  593. &board_96328avng,
  594. #endif
  595. #ifdef CONFIG_BCM63XX_CPU_6338
  596. &board_96338gw,
  597. &board_96338w,
  598. #endif
  599. #ifdef CONFIG_BCM63XX_CPU_6345
  600. &board_96345gw2,
  601. #endif
  602. #ifdef CONFIG_BCM63XX_CPU_6348
  603. &board_96348r,
  604. &board_96348gw,
  605. &board_96348gw_10,
  606. &board_96348gw_11,
  607. &board_FAST2404,
  608. &board_DV201AMR,
  609. &board_96348gw_a,
  610. &board_rta1025w_16,
  611. #endif
  612. #ifdef CONFIG_BCM63XX_CPU_6358
  613. &board_96358vw,
  614. &board_96358vw2,
  615. &board_AGPFS0,
  616. &board_DWVS0,
  617. #endif
  618. };
  619. /*
  620. * Register a sane SPROMv2 to make the on-board
  621. * bcm4318 WLAN work
  622. */
  623. #ifdef CONFIG_SSB_PCIHOST
  624. static struct ssb_sprom bcm63xx_sprom = {
  625. .revision = 0x02,
  626. .board_rev = 0x17,
  627. .country_code = 0x0,
  628. .ant_available_bg = 0x3,
  629. .pa0b0 = 0x15ae,
  630. .pa0b1 = 0xfa85,
  631. .pa0b2 = 0xfe8d,
  632. .pa1b0 = 0xffff,
  633. .pa1b1 = 0xffff,
  634. .pa1b2 = 0xffff,
  635. .gpio0 = 0xff,
  636. .gpio1 = 0xff,
  637. .gpio2 = 0xff,
  638. .gpio3 = 0xff,
  639. .maxpwr_bg = 0x004c,
  640. .itssi_bg = 0x00,
  641. .boardflags_lo = 0x2848,
  642. .boardflags_hi = 0x0000,
  643. };
  644. int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
  645. {
  646. if (bus->bustype == SSB_BUSTYPE_PCI) {
  647. memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
  648. return 0;
  649. } else {
  650. printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
  651. return -EINVAL;
  652. }
  653. }
  654. #endif
  655. /*
  656. * return board name for /proc/cpuinfo
  657. */
  658. const char *board_get_name(void)
  659. {
  660. return board.name;
  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 i;
  668. u8 *boot_addr, *cfe;
  669. char cfe_version[32];
  670. char *board_name = NULL;
  671. u32 val;
  672. struct bcm_hcs *hcs;
  673. /* read base address of boot chip select (0)
  674. * 6328/6362 do not have MPI but boot from a fixed address
  675. */
  676. if (BCMCPU_IS_6328() || BCMCPU_IS_6362()) {
  677. val = 0x18000000;
  678. } else {
  679. val = bcm_mpi_readl(MPI_CSBASE_REG(0));
  680. val &= MPI_CSBASE_BASE_MASK;
  681. }
  682. boot_addr = (u8 *)KSEG1ADDR(val);
  683. /* dump cfe version */
  684. cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
  685. if (!memcmp(cfe, "cfe-v", 5))
  686. snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u",
  687. cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]);
  688. else
  689. strcpy(cfe_version, "unknown");
  690. printk(KERN_INFO PFX "CFE version: %s\n", cfe_version);
  691. bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
  692. if (BCMCPU_IS_3368()) {
  693. hcs = (struct bcm_hcs *)boot_addr;
  694. board_name = hcs->filename;
  695. } else {
  696. board_name = bcm63xx_nvram_get_name();
  697. }
  698. /* find board by name */
  699. for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
  700. if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
  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, board_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. !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr))
  774. bcm63xx_enet_register(0, &board.enet0);
  775. if (board.has_enet1 &&
  776. !bcm63xx_nvram_get_mac_address(board.enet1.mac_addr))
  777. bcm63xx_enet_register(1, &board.enet1);
  778. if (board.has_enetsw &&
  779. !bcm63xx_nvram_get_mac_address(board.enetsw.mac_addr))
  780. bcm63xx_enetsw_register(&board.enetsw);
  781. if (board.has_usbd)
  782. bcm63xx_usbd_register(&board.usbd);
  783. if (board.has_dsp)
  784. bcm63xx_dsp_register(&board.dsp);
  785. /* Generate MAC address for WLAN and register our SPROM,
  786. * do this after registering enet devices
  787. */
  788. #ifdef CONFIG_SSB_PCIHOST
  789. if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
  790. memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  791. memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
  792. if (ssb_arch_register_fallback_sprom(
  793. &bcm63xx_get_fallback_sprom) < 0)
  794. pr_err(PFX "failed to register fallback SPROM\n");
  795. }
  796. #endif
  797. bcm63xx_spi_register();
  798. bcm63xx_flash_register();
  799. bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
  800. bcm63xx_led_data.leds = board.leds;
  801. platform_device_register(&bcm63xx_gpio_leds);
  802. if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
  803. gpio_request_one(board.ephy_reset_gpio,
  804. board.ephy_reset_gpio_flags, "ephy-reset");
  805. return 0;
  806. }