board_bcm963xx.c 16 KB

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