t4qds.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. /*
  2. * Copyright 2009-2012 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. #include <i2c.h>
  25. #include <netdev.h>
  26. #include <linux/compiler.h>
  27. #include <asm/mmu.h>
  28. #include <asm/processor.h>
  29. #include <asm/cache.h>
  30. #include <asm/immap_85xx.h>
  31. #include <asm/fsl_law.h>
  32. #include <asm/fsl_serdes.h>
  33. #include <asm/fsl_portals.h>
  34. #include <asm/fsl_liodn.h>
  35. #include <fm_eth.h>
  36. #include "../common/qixis.h"
  37. #include "../common/vsc3316_3308.h"
  38. #include "t4qds.h"
  39. #include "t4240qds_qixis.h"
  40. DECLARE_GLOBAL_DATA_PTR;
  41. static const int8_t vsc3316_fsm1_tx[8][2] = { {0, 0}, {1, 1}, {6, 6}, {7, 7},
  42. {8, 8}, {9, 9}, {14, 14}, {15, 15} };
  43. static const int8_t vsc3316_fsm2_tx[8][2] = { {2, 2}, {3, 3}, {4, 4}, {5, 5},
  44. {10, 10}, {11, 11}, {12, 12}, {13, 13} };
  45. static const int8_t vsc3316_fsm1_rx[8][2] = { {2, 12}, {3, 13}, {4, 5}, {5, 4},
  46. {10, 11}, {11, 10}, {12, 2}, {13, 3} };
  47. static const int8_t vsc3316_fsm2_rx[8][2] = { {0, 15}, {1, 14}, {6, 7}, {7, 6},
  48. {8, 9}, {9, 8}, {14, 1}, {15, 0} };
  49. int checkboard(void)
  50. {
  51. char buf[64];
  52. u8 sw;
  53. struct cpu_type *cpu = gd->arch.cpu;
  54. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
  55. unsigned int i;
  56. printf("Board: %sQDS, ", cpu->name);
  57. printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, ",
  58. QIXIS_READ(id), QIXIS_READ(arch));
  59. sw = QIXIS_READ(brdcfg[0]);
  60. sw = (sw & QIXIS_LBMAP_MASK) >> QIXIS_LBMAP_SHIFT;
  61. if (sw < 0x8)
  62. printf("vBank: %d\n", sw);
  63. else if (sw == 0x8)
  64. puts("Promjet\n");
  65. else if (sw == 0x9)
  66. puts("NAND\n");
  67. else
  68. printf("invalid setting of SW%u\n", QIXIS_LBMAP_SWITCH);
  69. printf("FPGA: v%d (%s), build %d",
  70. (int)QIXIS_READ(scver), qixis_read_tag(buf),
  71. (int)qixis_read_minor());
  72. /* the timestamp string contains "\n" at the end */
  73. printf(" on %s", qixis_read_time(buf));
  74. /* Display the RCW, so that no one gets confused as to what RCW
  75. * we're actually using for this boot.
  76. */
  77. puts("Reset Configuration Word (RCW):");
  78. for (i = 0; i < ARRAY_SIZE(gur->rcwsr); i++) {
  79. u32 rcw = in_be32(&gur->rcwsr[i]);
  80. if ((i % 4) == 0)
  81. printf("\n %08x:", i * 4);
  82. printf(" %08x", rcw);
  83. }
  84. puts("\n");
  85. /*
  86. * Display the actual SERDES reference clocks as configured by the
  87. * dip switches on the board. Note that the SWx registers could
  88. * technically be set to force the reference clocks to match the
  89. * values that the SERDES expects (or vice versa). For now, however,
  90. * we just display both values and hope the user notices when they
  91. * don't match.
  92. */
  93. puts("SERDES Reference Clocks: ");
  94. sw = QIXIS_READ(brdcfg[2]);
  95. for (i = 0; i < MAX_SERDES; i++) {
  96. static const char *freq[] = {
  97. "100", "125", "156.25", "161.1328125"};
  98. unsigned int clock = (sw >> (6 - 2 * i)) & 3;
  99. printf("SERDES%u=%sMHz ", i+1, freq[clock]);
  100. }
  101. puts("\n");
  102. return 0;
  103. }
  104. int select_i2c_ch_pca9547(u8 ch)
  105. {
  106. int ret;
  107. ret = i2c_write(I2C_MUX_PCA_ADDR_PRI, 0, 1, &ch, 1);
  108. if (ret) {
  109. puts("PCA: failed to select proper channel\n");
  110. return ret;
  111. }
  112. return 0;
  113. }
  114. /*
  115. * read_voltage from sensor on I2C bus
  116. * We use average of 4 readings, waiting for 532us befor another reading
  117. */
  118. #define NUM_READINGS 4 /* prefer to be power of 2 for efficiency */
  119. #define WAIT_FOR_ADC 532 /* wait for 532 microseconds for ADC */
  120. static inline int read_voltage(void)
  121. {
  122. int i, ret, voltage_read = 0;
  123. u16 vol_mon;
  124. for (i = 0; i < NUM_READINGS; i++) {
  125. ret = i2c_read(I2C_VOL_MONITOR_ADDR,
  126. I2C_VOL_MONITOR_BUS_V_OFFSET, 1, (void *)&vol_mon, 2);
  127. if (ret) {
  128. printf("VID: failed to read core voltage\n");
  129. return ret;
  130. }
  131. if (vol_mon & I2C_VOL_MONITOR_BUS_V_OVF) {
  132. printf("VID: Core voltage sensor error\n");
  133. return -1;
  134. }
  135. debug("VID: bus voltage reads 0x%04x\n", vol_mon);
  136. /* LSB = 4mv */
  137. voltage_read += (vol_mon >> I2C_VOL_MONITOR_BUS_V_SHIFT) * 4;
  138. udelay(WAIT_FOR_ADC);
  139. }
  140. /* calculate the average */
  141. voltage_read /= NUM_READINGS;
  142. return voltage_read;
  143. }
  144. /*
  145. * We need to calculate how long before the voltage starts to drop or increase
  146. * It returns with the loop count. Each loop takes several readings (532us)
  147. */
  148. static inline int wait_for_voltage_change(int vdd_last)
  149. {
  150. int timeout, vdd_current;
  151. vdd_current = read_voltage();
  152. /* wait until voltage starts to drop */
  153. for (timeout = 0; abs(vdd_last - vdd_current) <= 4 &&
  154. timeout < 100; timeout++) {
  155. vdd_current = read_voltage();
  156. }
  157. if (timeout >= 100) {
  158. printf("VID: Voltage adjustment timeout\n");
  159. return -1;
  160. }
  161. return timeout;
  162. }
  163. /*
  164. * argument 'wait' is the time we know the voltage difference can be measured
  165. * this function keeps reading the voltage until it is stable
  166. */
  167. static inline int wait_for_voltage_stable(int wait)
  168. {
  169. int timeout, vdd_current, vdd_last;
  170. vdd_last = read_voltage();
  171. udelay(wait * NUM_READINGS * WAIT_FOR_ADC);
  172. /* wait until voltage is stable */
  173. vdd_current = read_voltage();
  174. for (timeout = 0; abs(vdd_last - vdd_current) >= 4 &&
  175. timeout < 100; timeout++) {
  176. vdd_last = vdd_current;
  177. udelay(wait * NUM_READINGS * WAIT_FOR_ADC);
  178. vdd_current = read_voltage();
  179. }
  180. if (timeout >= 100) {
  181. printf("VID: Voltage adjustment timeout\n");
  182. return -1;
  183. }
  184. return vdd_current;
  185. }
  186. static inline int set_voltage(u8 vid)
  187. {
  188. int wait, vdd_last;
  189. vdd_last = read_voltage();
  190. QIXIS_WRITE(brdcfg[6], vid);
  191. wait = wait_for_voltage_change(vdd_last);
  192. if (wait < 0)
  193. return -1;
  194. debug("VID: Waited %d us\n", wait * NUM_READINGS * WAIT_FOR_ADC);
  195. wait = wait ? wait : 1;
  196. vdd_last = wait_for_voltage_stable(wait);
  197. if (vdd_last < 0)
  198. return -1;
  199. debug("VID: Current voltage is %d mV\n", vdd_last);
  200. return vdd_last;
  201. }
  202. static int adjust_vdd(void)
  203. {
  204. int re_enable = disable_interrupts();
  205. ccsr_gur_t __iomem *gur =
  206. (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  207. u32 fusesr;
  208. u8 vid, vid_current;
  209. int vdd_target, vdd_current, vdd_last;
  210. int ret;
  211. static const uint16_t vdd[32] = {
  212. 0, /* unused */
  213. 9875, /* 0.9875V */
  214. 9750,
  215. 9625,
  216. 9500,
  217. 9375,
  218. 9250,
  219. 9125,
  220. 9000,
  221. 8875,
  222. 8750,
  223. 8625,
  224. 8500,
  225. 8375,
  226. 8250,
  227. 8125,
  228. 10000, /* 1.0000V */
  229. 10125,
  230. 10250,
  231. 10375,
  232. 10500,
  233. 10625,
  234. 10750,
  235. 10875,
  236. 11000,
  237. 0, /* reserved */
  238. };
  239. struct vdd_drive {
  240. u8 vid;
  241. unsigned voltage;
  242. };
  243. ret = select_i2c_ch_pca9547(I2C_MUX_CH_VOL_MONITOR);
  244. if (ret) {
  245. debug("VID: I2c failed to switch channel\n");
  246. ret = -1;
  247. goto exit;
  248. }
  249. /* get the voltage ID from fuse status register */
  250. fusesr = in_be32(&gur->dcfg_fusesr);
  251. vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_VID_SHIFT) &
  252. FSL_CORENET_DCFG_FUSESR_VID_MASK;
  253. if (vid == FSL_CORENET_DCFG_FUSESR_VID_MASK) {
  254. vid = (fusesr >> FSL_CORENET_DCFG_FUSESR_ALTVID_SHIFT) &
  255. FSL_CORENET_DCFG_FUSESR_ALTVID_MASK;
  256. }
  257. vdd_target = vdd[vid];
  258. if (vdd_target == 0) {
  259. debug("VID: VID not used\n");
  260. ret = 0;
  261. goto exit;
  262. } else {
  263. /* round up and divice by 10 to get a value in mV */
  264. vdd_target = DIV_ROUND_UP(vdd_target, 10);
  265. debug("VID: vid = %d mV\n", vdd_target);
  266. }
  267. /*
  268. * Check current board VID setting
  269. * Voltage regulator support output to 6.250mv step
  270. * The highes voltage allowed for this board is (vid=0x40) 1.21250V
  271. * the lowest is (vid=0x7f) 0.81875V
  272. */
  273. vid_current = QIXIS_READ(brdcfg[6]);
  274. vdd_current = 121250 - (vid_current - 0x40) * 625;
  275. debug("VID: Current vid setting is (0x%x) %d mV\n",
  276. vid_current, vdd_current/100);
  277. /*
  278. * Read voltage monitor to check real voltage.
  279. * Voltage monitor LSB is 4mv.
  280. */
  281. vdd_last = read_voltage();
  282. if (vdd_last < 0) {
  283. printf("VID: Could not read voltage sensor abort VID adjustment\n");
  284. ret = -1;
  285. goto exit;
  286. }
  287. debug("VID: Core voltage is at %d mV\n", vdd_last);
  288. /*
  289. * Adjust voltage to at or 8mV above target.
  290. * Each step of adjustment is 6.25mV.
  291. * Stepping down too fast may cause over current.
  292. */
  293. while (vdd_last > 0 && vid_current < 0x80 &&
  294. vdd_last > (vdd_target + 8)) {
  295. vid_current++;
  296. vdd_last = set_voltage(vid_current);
  297. }
  298. /*
  299. * Check if we need to step up
  300. * This happens when board voltage switch was set too low
  301. */
  302. while (vdd_last > 0 && vid_current >= 0x40 &&
  303. vdd_last < vdd_target + 2) {
  304. vid_current--;
  305. vdd_last = set_voltage(vid_current);
  306. }
  307. if (vdd_last > 0)
  308. printf("VID: Core voltage %d mV\n", vdd_last);
  309. else
  310. ret = -1;
  311. exit:
  312. if (re_enable)
  313. enable_interrupts();
  314. return ret;
  315. }
  316. /* Configure Crossbar switches for Front-Side SerDes Ports */
  317. int config_frontside_crossbar_vsc3316(void)
  318. {
  319. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  320. u32 srds_prtcl_s1, srds_prtcl_s2;
  321. int ret;
  322. ret = select_i2c_ch_pca9547(I2C_MUX_CH_VSC3316_FS);
  323. if (ret)
  324. return ret;
  325. srds_prtcl_s1 = in_be32(&gur->rcwsr[4]) &
  326. FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
  327. srds_prtcl_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
  328. if (srds_prtcl_s1) {
  329. ret = vsc3316_config(VSC3316_FSM_TX_ADDR, vsc3316_fsm1_tx, 8);
  330. if (ret)
  331. return ret;
  332. ret = vsc3316_config(VSC3316_FSM_RX_ADDR, vsc3316_fsm1_rx, 8);
  333. if (ret)
  334. return ret;
  335. }
  336. srds_prtcl_s2 = in_be32(&gur->rcwsr[4]) &
  337. FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
  338. srds_prtcl_s2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
  339. if (srds_prtcl_s2) {
  340. ret = vsc3316_config(VSC3316_FSM_TX_ADDR, vsc3316_fsm2_tx, 8);
  341. if (ret)
  342. return ret;
  343. ret = vsc3316_config(VSC3316_FSM_RX_ADDR, vsc3316_fsm2_rx, 8);
  344. if (ret)
  345. return ret;
  346. }
  347. return 0;
  348. }
  349. int config_backside_crossbar_mux(void)
  350. {
  351. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  352. u32 srds_prtcl_s3, srds_prtcl_s4;
  353. u8 brdcfg;
  354. srds_prtcl_s3 = in_be32(&gur->rcwsr[4]) &
  355. FSL_CORENET2_RCWSR4_SRDS3_PRTCL;
  356. srds_prtcl_s3 >>= FSL_CORENET2_RCWSR4_SRDS3_PRTCL_SHIFT;
  357. switch (srds_prtcl_s3) {
  358. case 0:
  359. /* SerDes3 is not enabled */
  360. break;
  361. case 2:
  362. case 9:
  363. case 10:
  364. /* SD3(0:7) => SLOT5(0:7) */
  365. brdcfg = QIXIS_READ(brdcfg[12]);
  366. brdcfg &= ~BRDCFG12_SD3MX_MASK;
  367. brdcfg |= BRDCFG12_SD3MX_SLOT5;
  368. QIXIS_WRITE(brdcfg[12], brdcfg);
  369. break;
  370. case 4:
  371. case 6:
  372. case 8:
  373. case 12:
  374. case 14:
  375. case 16:
  376. case 17:
  377. case 19:
  378. case 20:
  379. /* SD3(4:7) => SLOT6(0:3) */
  380. brdcfg = QIXIS_READ(brdcfg[12]);
  381. brdcfg &= ~BRDCFG12_SD3MX_MASK;
  382. brdcfg |= BRDCFG12_SD3MX_SLOT6;
  383. QIXIS_WRITE(brdcfg[12], brdcfg);
  384. break;
  385. default:
  386. printf("WARNING: unsupported for SerDes3 Protocol %d\n",
  387. srds_prtcl_s3);
  388. return -1;
  389. }
  390. srds_prtcl_s4 = in_be32(&gur->rcwsr[4]) &
  391. FSL_CORENET2_RCWSR4_SRDS4_PRTCL;
  392. srds_prtcl_s4 >>= FSL_CORENET2_RCWSR4_SRDS4_PRTCL_SHIFT;
  393. switch (srds_prtcl_s4) {
  394. case 0:
  395. /* SerDes4 is not enabled */
  396. break;
  397. case 2:
  398. /* 10b, SD4(0:7) => SLOT7(0:7) */
  399. brdcfg = QIXIS_READ(brdcfg[12]);
  400. brdcfg &= ~BRDCFG12_SD4MX_MASK;
  401. brdcfg |= BRDCFG12_SD4MX_SLOT7;
  402. QIXIS_WRITE(brdcfg[12], brdcfg);
  403. break;
  404. case 4:
  405. case 6:
  406. case 8:
  407. /* x1b, SD4(4:7) => SLOT8(0:3) */
  408. brdcfg = QIXIS_READ(brdcfg[12]);
  409. brdcfg &= ~BRDCFG12_SD4MX_MASK;
  410. brdcfg |= BRDCFG12_SD4MX_SLOT8;
  411. QIXIS_WRITE(brdcfg[12], brdcfg);
  412. break;
  413. case 10:
  414. case 12:
  415. case 14:
  416. case 16:
  417. case 18:
  418. /* 00b, SD4(4:5) => AURORA, SD4(6:7) => SATA */
  419. brdcfg = QIXIS_READ(brdcfg[12]);
  420. brdcfg &= ~BRDCFG12_SD4MX_MASK;
  421. brdcfg |= BRDCFG12_SD4MX_AURO_SATA;
  422. QIXIS_WRITE(brdcfg[12], brdcfg);
  423. break;
  424. default:
  425. printf("WARNING: unsupported for SerDes4 Protocol %d\n",
  426. srds_prtcl_s4);
  427. return -1;
  428. }
  429. return 0;
  430. }
  431. int board_early_init_r(void)
  432. {
  433. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  434. const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
  435. /*
  436. * Remap Boot flash + PROMJET region to caching-inhibited
  437. * so that flash can be erased properly.
  438. */
  439. /* Flush d-cache and invalidate i-cache of any FLASH data */
  440. flush_dcache();
  441. invalidate_icache();
  442. /* invalidate existing TLB entry for flash + promjet */
  443. disable_tlb(flash_esel);
  444. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
  445. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  446. 0, flash_esel, BOOKE_PAGESZ_256M, 1);
  447. set_liodns();
  448. #ifdef CONFIG_SYS_DPAA_QBMAN
  449. setup_portals();
  450. #endif
  451. /* Disable remote I2C connectoin */
  452. QIXIS_WRITE(brdcfg[5], BRDCFG5_RESET);
  453. /*
  454. * Adjust core voltage according to voltage ID
  455. * This function changes I2C mux to channel 2.
  456. */
  457. if (adjust_vdd())
  458. printf("Warning: Adjusting core voltage failed.\n");
  459. /* Configure board SERDES ports crossbar */
  460. config_frontside_crossbar_vsc3316();
  461. config_backside_crossbar_mux();
  462. select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
  463. return 0;
  464. }
  465. unsigned long get_board_sys_clk(void)
  466. {
  467. u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
  468. switch (sysclk_conf & 0x0F) {
  469. case QIXIS_SYSCLK_83:
  470. return 83333333;
  471. case QIXIS_SYSCLK_100:
  472. return 100000000;
  473. case QIXIS_SYSCLK_125:
  474. return 125000000;
  475. case QIXIS_SYSCLK_133:
  476. return 133333333;
  477. case QIXIS_SYSCLK_150:
  478. return 150000000;
  479. case QIXIS_SYSCLK_160:
  480. return 160000000;
  481. case QIXIS_SYSCLK_166:
  482. return 166666666;
  483. }
  484. return 66666666;
  485. }
  486. unsigned long get_board_ddr_clk(void)
  487. {
  488. u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
  489. switch ((ddrclk_conf & 0x30) >> 4) {
  490. case QIXIS_DDRCLK_100:
  491. return 100000000;
  492. case QIXIS_DDRCLK_125:
  493. return 125000000;
  494. case QIXIS_DDRCLK_133:
  495. return 133333333;
  496. }
  497. return 66666666;
  498. }
  499. static const char *serdes_clock_to_string(u32 clock)
  500. {
  501. switch (clock) {
  502. case SRDS_PLLCR0_RFCK_SEL_100:
  503. return "100";
  504. case SRDS_PLLCR0_RFCK_SEL_125:
  505. return "125";
  506. case SRDS_PLLCR0_RFCK_SEL_156_25:
  507. return "156.25";
  508. case SRDS_PLLCR0_RFCK_SEL_161_13:
  509. return "161.1328125";
  510. default:
  511. return "???";
  512. }
  513. }
  514. int misc_init_r(void)
  515. {
  516. u8 sw;
  517. serdes_corenet_t *srds_regs =
  518. (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
  519. u32 actual[MAX_SERDES];
  520. unsigned int i;
  521. sw = QIXIS_READ(brdcfg[2]);
  522. for (i = 0; i < MAX_SERDES; i++) {
  523. unsigned int clock = (sw >> (6 - 2 * i)) & 3;
  524. switch (clock) {
  525. case 0:
  526. actual[i] = SRDS_PLLCR0_RFCK_SEL_100;
  527. break;
  528. case 1:
  529. actual[i] = SRDS_PLLCR0_RFCK_SEL_125;
  530. break;
  531. case 2:
  532. actual[i] = SRDS_PLLCR0_RFCK_SEL_156_25;
  533. break;
  534. case 3:
  535. actual[i] = SRDS_PLLCR0_RFCK_SEL_161_13;
  536. break;
  537. }
  538. }
  539. for (i = 0; i < MAX_SERDES; i++) {
  540. u32 pllcr0 = srds_regs->bank[i].pllcr0;
  541. u32 expected = pllcr0 & SRDS_PLLCR0_RFCK_SEL_MASK;
  542. if (expected != actual[i]) {
  543. printf("Warning: SERDES%u expects reference clock"
  544. " %sMHz, but actual is %sMHz\n", i + 1,
  545. serdes_clock_to_string(expected),
  546. serdes_clock_to_string(actual[i]));
  547. }
  548. }
  549. return 0;
  550. }
  551. void ft_board_setup(void *blob, bd_t *bd)
  552. {
  553. phys_addr_t base;
  554. phys_size_t size;
  555. ft_cpu_setup(blob, bd);
  556. base = getenv_bootm_low();
  557. size = getenv_bootm_size();
  558. fdt_fixup_memory(blob, (u64)base, (u64)size);
  559. #ifdef CONFIG_PCI
  560. pci_of_setup(blob, bd);
  561. #endif
  562. fdt_fixup_liodn(blob);
  563. fdt_fixup_dr_usb(blob, bd);
  564. #ifdef CONFIG_SYS_DPAA_FMAN
  565. fdt_fixup_fman_ethernet(blob);
  566. fdt_fixup_board_enet(blob);
  567. #endif
  568. }
  569. /*
  570. * Reverse engineering switch settings.
  571. * Some bits cannot be figured out. They will be displayed as
  572. * underscore in binary format. mask[] has those bits.
  573. * Some bits are calculated differently than the actual switches
  574. * if booting with overriding by FPGA.
  575. */
  576. void qixis_dump_switch(void)
  577. {
  578. int i;
  579. u8 sw[9];
  580. /*
  581. * Any bit with 1 means that bit cannot be reverse engineered.
  582. * It will be displayed as _ in binary format.
  583. */
  584. static const u8 mask[] = {0, 0, 0, 0, 0, 0x1, 0xdf, 0x3f, 0x1f};
  585. char buf[10];
  586. u8 brdcfg[16], dutcfg[16];
  587. for (i = 0; i < 16; i++) {
  588. brdcfg[i] = qixis_read(offsetof(struct qixis, brdcfg[0]) + i);
  589. dutcfg[i] = qixis_read(offsetof(struct qixis, dutcfg[0]) + i);
  590. }
  591. sw[0] = dutcfg[0];
  592. sw[1] = (dutcfg[1] << 0x07) | \
  593. ((dutcfg[12] & 0xC0) >> 1) | \
  594. ((dutcfg[11] & 0xE0) >> 3) | \
  595. ((dutcfg[6] & 0x80) >> 6) | \
  596. ((dutcfg[1] & 0x80) >> 7);
  597. sw[2] = ((brdcfg[1] & 0x0f) << 4) | \
  598. ((brdcfg[1] & 0x30) >> 2) | \
  599. ((brdcfg[1] & 0x40) >> 5) | \
  600. ((brdcfg[1] & 0x80) >> 7);
  601. sw[3] = brdcfg[2];
  602. sw[4] = ((dutcfg[2] & 0x01) << 7) | \
  603. ((dutcfg[2] & 0x06) << 4) | \
  604. ((~QIXIS_READ(present)) & 0x10) | \
  605. ((brdcfg[3] & 0x80) >> 4) | \
  606. ((brdcfg[3] & 0x01) << 2) | \
  607. ((brdcfg[6] == 0x62) ? 3 : \
  608. ((brdcfg[6] == 0x5a) ? 2 : \
  609. ((brdcfg[6] == 0x5e) ? 1 : 0)));
  610. sw[5] = ((brdcfg[0] & 0x0f) << 4) | \
  611. ((QIXIS_READ(rst_ctl) & 0x30) >> 2) | \
  612. ((brdcfg[0] & 0x40) >> 5);
  613. sw[6] = (brdcfg[11] & 0x20);
  614. sw[7] = (((~QIXIS_READ(rst_ctl)) & 0x40) << 1) | \
  615. ((brdcfg[5] & 0x10) << 2);
  616. sw[8] = ((brdcfg[12] & 0x08) << 4) | \
  617. ((brdcfg[12] & 0x03) << 5);
  618. puts("DIP switch (reverse-engineering)\n");
  619. for (i = 0; i < 9; i++) {
  620. printf("SW%d = 0b%s (0x%02x)\n",
  621. i + 1, byte_to_binary_mask(sw[i], mask[i], buf), sw[i]);
  622. }
  623. }