pdm360ng.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * (C) Copyright 2009, 2010 Wolfgang Denk <wd@denx.de>
  3. *
  4. * (C) Copyright 2009-2010
  5. * Michael Weiß, ifm ecomatic gmbh, michael.weiss@ifm.com
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. *
  25. */
  26. #include <common.h>
  27. #include <asm/bitops.h>
  28. #include <command.h>
  29. #include <asm/io.h>
  30. #include <asm/processor.h>
  31. #include <asm/mpc512x.h>
  32. #include <fdt_support.h>
  33. #include <flash.h>
  34. #ifdef CONFIG_MISC_INIT_R
  35. #include <i2c.h>
  36. #endif
  37. #include <serial.h>
  38. #include <jffs2/load_kernel.h>
  39. #include <mtd_node.h>
  40. DECLARE_GLOBAL_DATA_PTR;
  41. extern flash_info_t flash_info[];
  42. ulong flash_get_size (phys_addr_t base, int banknum);
  43. /* Clocks in use */
  44. #define SCCR1_CLOCKS_EN (CLOCK_SCCR1_CFG_EN | \
  45. CLOCK_SCCR1_LPC_EN | \
  46. CLOCK_SCCR1_NFC_EN | \
  47. CLOCK_SCCR1_PSC_EN(CONFIG_PSC_CONSOLE) | \
  48. CLOCK_SCCR1_PSCFIFO_EN | \
  49. CLOCK_SCCR1_DDR_EN | \
  50. CLOCK_SCCR1_FEC_EN | \
  51. CLOCK_SCCR1_TPR_EN)
  52. #define SCCR2_CLOCKS_EN (CLOCK_SCCR2_MEM_EN | \
  53. CLOCK_SCCR2_SPDIF_EN | \
  54. CLOCK_SCCR2_DIU_EN | \
  55. CLOCK_SCCR2_I2C_EN)
  56. int board_early_init_f(void)
  57. {
  58. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  59. /*
  60. * Initialize Local Window for FLASH-Bank1 access (CS1)
  61. */
  62. out_be32(&im->sysconf.lpcs1aw,
  63. CSAW_START(CONFIG_SYS_FLASH1_BASE) |
  64. CSAW_STOP(CONFIG_SYS_FLASH1_BASE, CONFIG_SYS_FLASH_SIZE)
  65. );
  66. out_be32(&im->lpc.cs_cfg[1], CONFIG_SYS_CS1_CFG);
  67. /*
  68. * Local Window for MRAM access (CS2)
  69. */
  70. out_be32(&im->sysconf.lpcs2aw,
  71. CSAW_START(CONFIG_SYS_MRAM_BASE) |
  72. CSAW_STOP(CONFIG_SYS_MRAM_BASE, CONFIG_SYS_MRAM_SIZE)
  73. );
  74. out_be32(&im->lpc.cs_cfg[2], CONFIG_SYS_CS2_CFG);
  75. sync_law(&im->sysconf.lpcs2aw);
  76. /*
  77. * Configure Flash Speed
  78. */
  79. out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG);
  80. out_be32(&im->lpc.altr, CONFIG_SYS_CS_ALETIMING);
  81. /*
  82. * Enable clocks
  83. */
  84. out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN);
  85. out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN);
  86. #if defined(CONFIG_IIM) || defined(CONFIG_CMD_FUSE)
  87. setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN);
  88. #endif
  89. return 0;
  90. }
  91. sdram_conf_t mddrc_config[] = {
  92. {
  93. (512 << 20), /* 512 MB RAM configuration */
  94. {
  95. CONFIG_SYS_MDDRC_SYS_CFG,
  96. CONFIG_SYS_MDDRC_TIME_CFG0,
  97. CONFIG_SYS_MDDRC_TIME_CFG1,
  98. CONFIG_SYS_MDDRC_TIME_CFG2
  99. }
  100. },
  101. {
  102. (128 << 20), /* 128 MB RAM configuration */
  103. {
  104. CONFIG_SYS_MDDRC_SYS_CFG_ALT1,
  105. CONFIG_SYS_MDDRC_TIME_CFG0_ALT1,
  106. CONFIG_SYS_MDDRC_TIME_CFG1_ALT1,
  107. CONFIG_SYS_MDDRC_TIME_CFG2_ALT1
  108. }
  109. },
  110. };
  111. phys_size_t initdram (int board_type)
  112. {
  113. int i;
  114. u32 msize = 0;
  115. u32 pdm360ng_init_seq[] = {
  116. CONFIG_SYS_DDRCMD_NOP,
  117. CONFIG_SYS_DDRCMD_NOP,
  118. CONFIG_SYS_DDRCMD_NOP,
  119. CONFIG_SYS_DDRCMD_NOP,
  120. CONFIG_SYS_DDRCMD_NOP,
  121. CONFIG_SYS_DDRCMD_NOP,
  122. CONFIG_SYS_DDRCMD_NOP,
  123. CONFIG_SYS_DDRCMD_NOP,
  124. CONFIG_SYS_DDRCMD_NOP,
  125. CONFIG_SYS_DDRCMD_NOP,
  126. CONFIG_SYS_DDRCMD_PCHG_ALL,
  127. CONFIG_SYS_DDRCMD_NOP,
  128. CONFIG_SYS_DDRCMD_RFSH,
  129. CONFIG_SYS_DDRCMD_NOP,
  130. CONFIG_SYS_DDRCMD_RFSH,
  131. CONFIG_SYS_DDRCMD_NOP,
  132. CONFIG_SYS_MICRON_INIT_DEV_OP,
  133. CONFIG_SYS_DDRCMD_NOP,
  134. CONFIG_SYS_DDRCMD_EM2,
  135. CONFIG_SYS_DDRCMD_NOP,
  136. CONFIG_SYS_DDRCMD_PCHG_ALL,
  137. CONFIG_SYS_DDRCMD_EM2,
  138. CONFIG_SYS_DDRCMD_EM3,
  139. CONFIG_SYS_DDRCMD_EN_DLL,
  140. CONFIG_SYS_DDRCMD_RES_DLL,
  141. CONFIG_SYS_DDRCMD_PCHG_ALL,
  142. CONFIG_SYS_DDRCMD_RFSH,
  143. CONFIG_SYS_DDRCMD_RFSH,
  144. CONFIG_SYS_MICRON_INIT_DEV_OP,
  145. CONFIG_SYS_DDRCMD_OCD_DEFAULT,
  146. CONFIG_SYS_DDRCMD_OCD_EXIT,
  147. CONFIG_SYS_DDRCMD_PCHG_ALL,
  148. CONFIG_SYS_DDRCMD_NOP
  149. };
  150. for (i = 0; i < ARRAY_SIZE(mddrc_config); i++) {
  151. msize = fixed_sdram(&mddrc_config[i].cfg, pdm360ng_init_seq,
  152. ARRAY_SIZE(pdm360ng_init_seq));
  153. if (msize == mddrc_config[i].size)
  154. break;
  155. }
  156. return msize;
  157. }
  158. static int set_lcd_brightness(char *);
  159. int misc_init_r(void)
  160. {
  161. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  162. /*
  163. * Re-configure flash setup using auto-detected info
  164. */
  165. if (flash_info[1].size > 0) {
  166. out_be32(&im->sysconf.lpcs1aw,
  167. CSAW_START(gd->bd->bi_flashstart + flash_info[1].size) |
  168. CSAW_STOP(gd->bd->bi_flashstart + flash_info[1].size,
  169. flash_info[1].size));
  170. sync_law(&im->sysconf.lpcs1aw);
  171. /*
  172. * Re-check to get correct base address
  173. */
  174. flash_get_size (gd->bd->bi_flashstart + flash_info[1].size, 1);
  175. } else {
  176. /* Disable Bank 1 */
  177. out_be32(&im->sysconf.lpcs1aw, 0x01000100);
  178. sync_law(&im->sysconf.lpcs1aw);
  179. }
  180. out_be32(&im->sysconf.lpcs0aw,
  181. CSAW_START(gd->bd->bi_flashstart) |
  182. CSAW_STOP(gd->bd->bi_flashstart, flash_info[0].size));
  183. sync_law(&im->sysconf.lpcs0aw);
  184. /*
  185. * Re-check to get correct base address
  186. */
  187. flash_get_size (gd->bd->bi_flashstart, 0);
  188. /*
  189. * Re-do flash protection upon new addresses
  190. */
  191. flash_protect (FLAG_PROTECT_CLEAR,
  192. gd->bd->bi_flashstart, 0xffffffff,
  193. &flash_info[0]);
  194. /* Monitor protection ON by default */
  195. flash_protect (FLAG_PROTECT_SET,
  196. CONFIG_SYS_MONITOR_BASE,
  197. CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1,
  198. &flash_info[0]);
  199. /* Environment protection ON by default */
  200. flash_protect (FLAG_PROTECT_SET,
  201. CONFIG_ENV_ADDR,
  202. CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
  203. &flash_info[0]);
  204. #ifdef CONFIG_ENV_ADDR_REDUND
  205. /* Redundant environment protection ON by default */
  206. flash_protect (FLAG_PROTECT_SET,
  207. CONFIG_ENV_ADDR_REDUND,
  208. CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
  209. &flash_info[0]);
  210. #endif
  211. #ifdef CONFIG_FSL_DIU_FB
  212. set_lcd_brightness(0);
  213. /* Switch LCD-Backlight and LVDS-Interface on */
  214. setbits_be32(&im->gpio.gpdir, 0x01040000);
  215. clrsetbits_be32(&im->gpio.gpdat, 0x01000000, 0x00040000);
  216. #endif
  217. #if defined(CONFIG_HARD_I2C)
  218. if (!getenv("ethaddr")) {
  219. uchar buf[6];
  220. uchar ifm_oui[3] = { 0, 2, 1, };
  221. int ret;
  222. /* I2C-0 for on-board eeprom */
  223. i2c_set_bus_num(CONFIG_SYS_I2C_EEPROM_BUS_NUM);
  224. /* Read ethaddr from EEPROM */
  225. ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR,
  226. CONFIG_SYS_I2C_EEPROM_MAC_OFFSET, 1, buf, 6);
  227. if (ret != 0) {
  228. printf("Error: Unable to read MAC from I2C"
  229. " EEPROM at address %02X:%02X\n",
  230. CONFIG_SYS_I2C_EEPROM_ADDR,
  231. CONFIG_SYS_I2C_EEPROM_MAC_OFFSET);
  232. return 1;
  233. }
  234. /* Owned by IFM ? */
  235. if (memcmp(buf, ifm_oui, sizeof(ifm_oui))) {
  236. printf("Illegal MAC address in EEPROM: %pM\n", buf);
  237. return 1;
  238. }
  239. eth_setenv_enetaddr("ethaddr", buf);
  240. }
  241. #endif /* defined(CONFIG_HARD_I2C) */
  242. return 0;
  243. }
  244. static iopin_t ioregs_init[] = {
  245. /* FUNC1=LPC_CS4 */
  246. {
  247. offsetof(struct ioctrl512x, io_control_pata_ce1), 1, 0,
  248. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(1) |
  249. IO_PIN_PUE(1) | IO_PIN_ST(0) | IO_PIN_DS(3)
  250. },
  251. /* FUNC3=GPIO10 */
  252. {
  253. offsetof(struct ioctrl512x, io_control_pata_ce2), 1, 0,
  254. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  255. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  256. },
  257. /* FUNC1=CAN3_TX */
  258. {
  259. offsetof(struct ioctrl512x, io_control_pata_isolate), 1, 0,
  260. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  261. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  262. },
  263. /* FUNC3=GPIO14 */
  264. {
  265. offsetof(struct ioctrl512x, io_control_pata_iochrdy), 1, 0,
  266. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  267. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  268. },
  269. /* FUNC2=DIU_LD22 Sets Next 2 to DIU_LD pads */
  270. /* DIU_LD22-DIU_LD23 */
  271. {
  272. offsetof(struct ioctrl512x, io_control_pci_ad31), 2, 0,
  273. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  274. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  275. },
  276. /* FUNC2=USB1_DATA7 Sets Next 12 to USB1 pads */
  277. /* USB1_DATA7-USB1_DATA0, USB1_STOP, USB1_NEXT, USB1_CLK, USB1_DIR */
  278. {
  279. offsetof(struct ioctrl512x, io_control_pci_ad29), 12, 0,
  280. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  281. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  282. },
  283. /* FUNC1=VIU_DATA0 Sets Next 3 to VIU_DATA pads */
  284. /* VIU_DATA0-VIU_DATA2 */
  285. {
  286. offsetof(struct ioctrl512x, io_control_pci_ad17), 3, 0,
  287. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  288. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  289. },
  290. /* FUNC2=FEC_TXD_0 */
  291. {
  292. offsetof(struct ioctrl512x, io_control_pci_ad14), 1, 0,
  293. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  294. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  295. },
  296. /* FUNC1=VIU_DATA3 Sets Next 2 to VIU_DATA pads */
  297. /* VIU_DATA3, VIU_DATA4 */
  298. {
  299. offsetof(struct ioctrl512x, io_control_pci_ad13), 2, 0,
  300. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  301. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  302. },
  303. /* FUNC2=FEC_RXD_1 Sets Next 12 to FEC pads */
  304. /* FEC_RXD_1, FEC_RXD_0, FEC_RX_CLK, FEC_TX_CLK, FEC_RX_ER, FEC_RX_DV */
  305. /* FEC_TX_EN, FEC_TX_ER, FEC_CRS, FEC_MDC, FEC_MDIO, FEC_COL */
  306. {
  307. offsetof(struct ioctrl512x, io_control_pci_ad11), 12, 0,
  308. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  309. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  310. },
  311. /* FUNC2=DIU_LD03 Sets Next 25 to DIU pads */
  312. /* DIU_LD00-DIU_LD21 */
  313. {
  314. offsetof(struct ioctrl512x, io_control_pci_cbe0), 22, 0,
  315. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  316. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(1)
  317. },
  318. /* FUNC2=DIU_CLK Sets Next 3 to DIU pads */
  319. /* DIU_CLK, DIU_VSYNC, DIU_HSYNC */
  320. {
  321. offsetof(struct ioctrl512x, io_control_spdif_txclk), 3, 0,
  322. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  323. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  324. },
  325. /* FUNC2=CAN3_RX */
  326. {
  327. offsetof(struct ioctrl512x, io_control_irq1), 1, 0,
  328. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  329. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  330. },
  331. /* Sets lowest slew on 2 CAN_TX Pins*/
  332. {
  333. offsetof(struct ioctrl512x, io_control_can1_tx), 2, 0,
  334. IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  335. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  336. },
  337. /* FUNC3=CAN4_TX Sets Next 2 to CAN4 pads */
  338. /* CAN4_TX, CAN4_RX */
  339. {
  340. offsetof(struct ioctrl512x, io_control_j1850_tx), 2, 0,
  341. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  342. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  343. },
  344. /* FUNC3=GPIO8 Sets Next 2 to GPIO pads */
  345. /* GPIO8, GPIO9 */
  346. {
  347. offsetof(struct ioctrl512x, io_control_psc0_0), 2, 0,
  348. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  349. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  350. },
  351. /* FUNC1=FEC_TXD_1 Sets Next 3 to FEC pads */
  352. /* FEC_TXD_1, FEC_TXD_2, FEC_TXD_3 */
  353. {
  354. offsetof(struct ioctrl512x, io_control_psc0_4), 3, 0,
  355. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  356. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  357. },
  358. /* FUNC1=FEC_RXD_3 Sets Next 2 to FEC pads */
  359. /* FEC_RXD_3, FEC_RXD_2 */
  360. {
  361. offsetof(struct ioctrl512x, io_control_psc1_4), 2, 0,
  362. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  363. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  364. },
  365. /* FUNC3=GPIO17 */
  366. {
  367. offsetof(struct ioctrl512x, io_control_psc2_1), 1, 0,
  368. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  369. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  370. },
  371. /* FUNC3=GPIO2/GPT2 Sets Next 3 to GPIO pads */
  372. /* GPIO2, GPIO20, GPIO21 */
  373. {
  374. offsetof(struct ioctrl512x, io_control_psc2_4), 3, 0,
  375. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  376. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  377. },
  378. /* FUNC2=VIU_PIX_CLK */
  379. {
  380. offsetof(struct ioctrl512x, io_control_psc3_4), 1, 0,
  381. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  382. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  383. },
  384. /* FUNC3=GPIO24 Sets Next 2 to GPIO pads */
  385. /* GPIO24, GPIO25 */
  386. {
  387. offsetof(struct ioctrl512x, io_control_psc4_0), 2, 0,
  388. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  389. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  390. },
  391. /* FUNC1=NFC_CE2 */
  392. {
  393. offsetof(struct ioctrl512x, io_control_psc4_4), 1, 0,
  394. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(1) |
  395. IO_PIN_PUE(1) | IO_PIN_ST(0) | IO_PIN_DS(0)
  396. },
  397. /* FUNC2=VIU_DATA5 Sets Next 5 to VIU_DATA pads */
  398. /* VIU_DATA5-VIU_DATA9 */
  399. {
  400. offsetof(struct ioctrl512x, io_control_psc5_0), 5, 0,
  401. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  402. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  403. },
  404. /* FUNC1=LPC_TSIZ1 Sets Next 2 to LPC_TSIZ pads */
  405. /* LPC_TSIZ1-LPC_TSIZ2 */
  406. {
  407. offsetof(struct ioctrl512x, io_control_psc6_0), 2, 0,
  408. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  409. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  410. },
  411. /* FUNC1=LPC_TS */
  412. {
  413. offsetof(struct ioctrl512x, io_control_psc6_4), 1, 0,
  414. IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  415. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  416. },
  417. /* FUNC3=GPIO16 */
  418. {
  419. offsetof(struct ioctrl512x, io_control_psc7_0), 1, 0,
  420. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  421. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  422. },
  423. /* FUNC3=GPIO18 Sets Next 3 to GPIO pads */
  424. /* GPIO18-GPIO19, GPT7/GPIO7 */
  425. {
  426. offsetof(struct ioctrl512x, io_control_psc7_2), 3, 0,
  427. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  428. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  429. },
  430. /* FUNC3=GPIO0/GPT0 */
  431. {
  432. offsetof(struct ioctrl512x, io_control_psc8_4), 1, 0,
  433. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  434. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  435. },
  436. /* FUNC3=GPIO11 Sets Next 4 to GPIO pads */
  437. /* GPIO11, GPIO2, GPIO12, GPIO13 */
  438. {
  439. offsetof(struct ioctrl512x, io_control_psc10_3), 4, 0,
  440. IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  441. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(0)
  442. },
  443. /* FUNC2=DIU_DE */
  444. {
  445. offsetof(struct ioctrl512x, io_control_psc11_4), 1, 0,
  446. IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
  447. IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
  448. }
  449. };
  450. int checkboard (void)
  451. {
  452. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  453. puts("Board: PDM360NG\n");
  454. /* initialize function mux & slew rate IO inter alia on IO Pins */
  455. iopin_initialize(ioregs_init, ARRAY_SIZE(ioregs_init));
  456. /* initialize IO_CONTROL_GP (GPIO/GPT-mux-register) */
  457. setbits_be32(&im->io_ctrl.io_control_gp,
  458. (1 << 0) | /* GP_MUX7->GPIO7 */
  459. (1 << 5)); /* GP_MUX2->GPIO2 */
  460. /* configure GPIO24 (VIU_CE), output/high */
  461. setbits_be32(&im->gpio.gpdir, 0x80);
  462. setbits_be32(&im->gpio.gpdat, 0x80);
  463. return 0;
  464. }
  465. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  466. #ifdef CONFIG_FDT_FIXUP_PARTITIONS
  467. struct node_info nodes[] = {
  468. { "fsl,mpc5121-nfc", MTD_DEV_TYPE_NAND, },
  469. { "cfi-flash", MTD_DEV_TYPE_NOR, },
  470. };
  471. #endif
  472. #if defined(CONFIG_VIDEO)
  473. /*
  474. * EDID block has been generated using Phoenix EDID Designer 1.3.
  475. * This tool creates a text file containing:
  476. *
  477. * EDID BYTES:
  478. * 0x 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  479. * ------------------------------------------------
  480. * 00 | 00 FF FF FF FF FF FF 00 42 C9 34 12 01 00 00 00
  481. * 10 | 0A 0C 01 03 80 98 5B 78 CA 7E 50 A0 58 4E 96 25
  482. * 20 | 1E 50 54 00 00 00 01 01 01 01 01 01 01 01 01 01
  483. * 30 | 01 01 01 01 01 01 80 0C 20 00 31 E0 2D 10 2A 80
  484. * 40 | 12 08 30 E4 10 00 00 18 00 00 00 FD 00 38 3C 1F
  485. * 50 | 3C 04 0A 20 20 20 20 20 20 20 00 00 00 FF 00 50
  486. * 60 | 4D 30 37 30 57 4C 33 0A 0A 0A 0A 0A 00 00 00 FF
  487. * 70 | 00 41 30 30 30 30 30 30 30 30 30 30 30 31 00 D4
  488. *
  489. * Then this data has been manually converted to the char
  490. * array below.
  491. */
  492. static unsigned char edid_buf[128] = {
  493. 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
  494. 0x42, 0xC9, 0x34, 0x12, 0x01, 0x00, 0x00, 0x00,
  495. 0x0A, 0x0C, 0x01, 0x03, 0x80, 0x98, 0x5B, 0x78,
  496. 0xCA, 0x7E, 0x50, 0xA0, 0x58, 0x4E, 0x96, 0x25,
  497. 0x1E, 0x50, 0x54, 0x00, 0x00, 0x00, 0x01, 0x01,
  498. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  499. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80, 0x0C,
  500. 0x20, 0x00, 0x31, 0xE0, 0x2D, 0x10, 0x2A, 0x80,
  501. 0x12, 0x08, 0x30, 0xE4, 0x10, 0x00, 0x00, 0x18,
  502. 0x00, 0x00, 0x00, 0xFD, 0x00, 0x38, 0x3C, 0x1F,
  503. 0x3C, 0x04, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20,
  504. 0x20, 0x20, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x50,
  505. 0x4D, 0x30, 0x37, 0x30, 0x57, 0x4C, 0x33, 0x0A,
  506. 0x0A, 0x0A, 0x0A, 0x0A, 0x00, 0x00, 0x00, 0xFF,
  507. 0x00, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
  508. 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x00, 0xD4,
  509. };
  510. #endif
  511. void ft_board_setup(void *blob, bd_t *bd)
  512. {
  513. u32 val[8];
  514. int rc, i = 0;
  515. ft_cpu_setup(blob, bd);
  516. fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
  517. #ifdef CONFIG_FDT_FIXUP_PARTITIONS
  518. fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
  519. #endif
  520. #if defined(CONFIG_VIDEO)
  521. fdt_add_edid(blob, "fsl,mpc5121-diu", edid_buf);
  522. #endif
  523. /* Fixup NOR FLASH mapping */
  524. val[i++] = 0; /* chip select number */
  525. val[i++] = 0; /* always 0 */
  526. val[i++] = gd->bd->bi_flashstart;
  527. val[i++] = gd->bd->bi_flashsize;
  528. /* Fixup MRAM mapping */
  529. val[i++] = 2; /* chip select number */
  530. val[i++] = 0; /* always 0 */
  531. val[i++] = CONFIG_SYS_MRAM_BASE;
  532. val[i++] = CONFIG_SYS_MRAM_SIZE;
  533. rc = fdt_find_and_setprop(blob, "/localbus", "ranges",
  534. val, i * sizeof(u32), 1);
  535. if (rc)
  536. printf("Unable to update localbus ranges, err=%s\n",
  537. fdt_strerror(rc));
  538. /* Fixup reg property in NOR Flash node */
  539. i = 0;
  540. val[i++] = 0; /* always 0 */
  541. val[i++] = 0; /* start at offset 0 */
  542. val[i++] = flash_info[0].size; /* size of Bank 0 */
  543. /* Second Bank available? */
  544. if (flash_info[1].size > 0) {
  545. val[i++] = 0; /* always 0 */
  546. val[i++] = flash_info[0].size; /* offset of Bank 1 */
  547. val[i++] = flash_info[1].size; /* size of Bank 1 */
  548. }
  549. rc = fdt_find_and_setprop(blob, "/localbus/flash", "reg",
  550. val, i * sizeof(u32), 1);
  551. if (rc)
  552. printf("Unable to update flash reg property, err=%s\n",
  553. fdt_strerror(rc));
  554. }
  555. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
  556. /*
  557. * If argument is NULL, set the LCD brightness to the
  558. * value from "brightness" environment variable. Set
  559. * the LCD brightness to the value specified by the
  560. * argument otherwise. Default brightness is zero.
  561. */
  562. #define MAX_BRIGHTNESS 99
  563. static int set_lcd_brightness(char *brightness)
  564. {
  565. struct stdio_dev *cop_port;
  566. char *env;
  567. char cmd_buf[20];
  568. int val = 0;
  569. int cs = 0;
  570. int len, i;
  571. if (brightness) {
  572. val = simple_strtol(brightness, NULL, 10);
  573. } else {
  574. env = getenv("brightness");
  575. if (env)
  576. val = simple_strtol(env, NULL, 10);
  577. }
  578. if (val < 0)
  579. val = 0;
  580. if (val > MAX_BRIGHTNESS)
  581. val = MAX_BRIGHTNESS;
  582. sprintf(cmd_buf, "$SB;%04d;", val);
  583. len = strlen(cmd_buf);
  584. for (i = 1; i <= len; i++)
  585. cs += cmd_buf[i];
  586. cs = (~cs + 1) & 0xff;
  587. sprintf(cmd_buf + len, "%02X\n", cs);
  588. /* IO Coprocessor communication */
  589. cop_port = open_port(4, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
  590. if (!cop_port) {
  591. printf("Error: Can't open IO Coprocessor port.\n");
  592. return -1;
  593. }
  594. debug("%s: cmd: %s", __func__, cmd_buf);
  595. write_port(cop_port, cmd_buf);
  596. /*
  597. * Wait for transmission and maybe response data
  598. * before closing the port.
  599. */
  600. udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
  601. memset(cmd_buf, 0, sizeof(cmd_buf));
  602. len = read_port(cop_port, cmd_buf, sizeof(cmd_buf));
  603. if (len)
  604. printf("Error: %s\n", cmd_buf);
  605. close_port(4);
  606. return 0;
  607. }
  608. static int cmd_lcd_brightness(cmd_tbl_t *cmdtp, int flag,
  609. int argc, char * const argv[])
  610. {
  611. if (argc < 2)
  612. return cmd_usage(cmdtp);
  613. return set_lcd_brightness(argv[1]);
  614. }
  615. U_BOOT_CMD(lcdbr, 2, 1, cmd_lcd_brightness,
  616. "set LCD brightness",
  617. "<brightness> - set LCD backlight level to <brightness>.\n"
  618. );