pdm360ng.c 17 KB

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