pdm360ng.c 18 KB

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