tqm5200.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905
  1. /*
  2. * (C) Copyright 2003-2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2004
  6. * Mark Jonas, Freescale Semiconductor, mark.jonas@motorola.com.
  7. *
  8. * (C) Copyright 2004-2006
  9. * Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <mpc5xxx.h>
  31. #include <pci.h>
  32. #include <asm/processor.h>
  33. #include <libfdt.h>
  34. #include <netdev.h>
  35. #ifdef CONFIG_VIDEO_SM501
  36. #include <sm501.h>
  37. #endif
  38. #if defined(CONFIG_MPC5200_DDR)
  39. #include "mt46v16m16-75.h"
  40. #else
  41. #include "mt48lc16m16a2-75.h"
  42. #endif
  43. #ifdef CONFIG_OF_LIBFDT
  44. #include <fdt_support.h>
  45. #endif /* CONFIG_OF_LIBFDT */
  46. DECLARE_GLOBAL_DATA_PTR;
  47. #ifdef CONFIG_PS2MULT
  48. void ps2mult_early_init(void);
  49. #endif
  50. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) && \
  51. defined(CONFIG_VIDEO)
  52. /*
  53. * EDID block has been generated using Phoenix EDID Designer 1.3.
  54. * This tool creates a text file containing:
  55. *
  56. * EDID BYTES:
  57. *
  58. * 0x 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  59. * ------------------------------------------------
  60. * 00 | 00 FF FF FF FF FF FF 00 04 21 00 00 00 00 00 00
  61. * 10 | 01 00 01 03 00 00 00 00 00 00 00 00 00 00 00 00
  62. * 20 | 00 00 00 21 00 00 01 01 01 01 01 01 01 01 01 01
  63. * 30 | 01 01 01 01 01 01 64 00 00 00 00 00 00 00 00 00
  64. * 40 | 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00
  65. * 50 | 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00
  66. * 60 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10
  67. * 70 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17
  68. *
  69. * Then this data has been manually converted to the char
  70. * array below.
  71. */
  72. static unsigned char edid_buf[128] = {
  73. 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
  74. 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  75. 0x01, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00,
  76. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  77. 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x01, 0x01,
  78. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
  79. 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x64, 0x00,
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  81. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  82. 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
  83. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  84. 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  85. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  86. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
  87. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  88. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17,
  89. };
  90. #endif
  91. #ifndef CONFIG_SYS_RAMBOOT
  92. static void sdram_start (int hi_addr)
  93. {
  94. long hi_addr_bit = hi_addr ? 0x01000000 : 0;
  95. /* unlock mode register */
  96. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
  97. hi_addr_bit;
  98. __asm__ volatile ("sync");
  99. /* precharge all banks */
  100. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  101. hi_addr_bit;
  102. __asm__ volatile ("sync");
  103. #if SDRAM_DDR
  104. /* set mode register: extended mode */
  105. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
  106. __asm__ volatile ("sync");
  107. /* set mode register: reset DLL */
  108. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
  109. __asm__ volatile ("sync");
  110. #endif
  111. /* precharge all banks */
  112. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  113. hi_addr_bit;
  114. __asm__ volatile ("sync");
  115. /* auto refresh */
  116. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  117. hi_addr_bit;
  118. __asm__ volatile ("sync");
  119. /* set mode register */
  120. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
  121. __asm__ volatile ("sync");
  122. /* normal operation */
  123. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
  124. __asm__ volatile ("sync");
  125. }
  126. #endif
  127. /*
  128. * ATTENTION: Although partially referenced initdram does NOT make real use
  129. * use of CONFIG_SYS_SDRAM_BASE. The code does not work if CONFIG_SYS_SDRAM_BASE
  130. * is something else than 0x00000000.
  131. */
  132. phys_size_t initdram (int board_type)
  133. {
  134. ulong dramsize = 0;
  135. ulong dramsize2 = 0;
  136. uint svr, pvr;
  137. #ifndef CONFIG_SYS_RAMBOOT
  138. ulong test1, test2;
  139. /* setup SDRAM chip selects */
  140. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */
  141. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */
  142. __asm__ volatile ("sync");
  143. /* setup config registers */
  144. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
  145. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
  146. __asm__ volatile ("sync");
  147. #if SDRAM_DDR
  148. /* set tap delay */
  149. *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
  150. __asm__ volatile ("sync");
  151. #endif
  152. /* find RAM size using SDRAM CS0 only */
  153. sdram_start(0);
  154. test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
  155. sdram_start(1);
  156. test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
  157. if (test1 > test2) {
  158. sdram_start(0);
  159. dramsize = test1;
  160. } else {
  161. dramsize = test2;
  162. }
  163. /* memory smaller than 1MB is impossible */
  164. if (dramsize < (1 << 20)) {
  165. dramsize = 0;
  166. }
  167. /* set SDRAM CS0 size according to the amount of RAM found */
  168. if (dramsize > 0) {
  169. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
  170. __builtin_ffs(dramsize >> 20) - 1;
  171. } else {
  172. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
  173. }
  174. /* let SDRAM CS1 start right after CS0 */
  175. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c; /* 512MB */
  176. /* find RAM size using SDRAM CS1 only */
  177. if (!dramsize)
  178. sdram_start(0);
  179. test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
  180. if (!dramsize) {
  181. sdram_start(1);
  182. test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
  183. }
  184. if (test1 > test2) {
  185. sdram_start(0);
  186. dramsize2 = test1;
  187. } else {
  188. dramsize2 = test2;
  189. }
  190. /* memory smaller than 1MB is impossible */
  191. if (dramsize2 < (1 << 20)) {
  192. dramsize2 = 0;
  193. }
  194. /* set SDRAM CS1 size according to the amount of RAM found */
  195. if (dramsize2 > 0) {
  196. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
  197. | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
  198. } else {
  199. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
  200. }
  201. #else /* CONFIG_SYS_RAMBOOT */
  202. /* retrieve size of memory connected to SDRAM CS0 */
  203. dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
  204. if (dramsize >= 0x13) {
  205. dramsize = (1 << (dramsize - 0x13)) << 20;
  206. } else {
  207. dramsize = 0;
  208. }
  209. /* retrieve size of memory connected to SDRAM CS1 */
  210. dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
  211. if (dramsize2 >= 0x13) {
  212. dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
  213. } else {
  214. dramsize2 = 0;
  215. }
  216. #endif /* CONFIG_SYS_RAMBOOT */
  217. /*
  218. * On MPC5200B we need to set the special configuration delay in the
  219. * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
  220. * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
  221. *
  222. * "The SDelay should be written to a value of 0x00000004. It is
  223. * required to account for changes caused by normal wafer processing
  224. * parameters."
  225. */
  226. svr = get_svr();
  227. pvr = get_pvr();
  228. if ((SVR_MJREV(svr) >= 2) &&
  229. (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
  230. *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
  231. __asm__ volatile ("sync");
  232. }
  233. #if defined(CONFIG_TQM5200_B)
  234. return dramsize + dramsize2;
  235. #else
  236. return dramsize;
  237. #endif /* CONFIG_TQM5200_B */
  238. }
  239. int checkboard (void)
  240. {
  241. #if defined(CONFIG_AEVFIFO)
  242. puts ("Board: AEVFIFO\n");
  243. return 0;
  244. #endif
  245. #if defined(CONFIG_TQM5200S)
  246. # define MODULE_NAME "TQM5200S"
  247. #else
  248. # define MODULE_NAME "TQM5200"
  249. #endif
  250. #if defined(CONFIG_STK52XX)
  251. # define CARRIER_NAME "STK52xx"
  252. #elif defined(CONFIG_TB5200)
  253. # define CARRIER_NAME "TB5200"
  254. #elif defined(CONFIG_CAM5200)
  255. # define CARRIER_NAME "CAM5200"
  256. #elif defined(CONFIG_FO300)
  257. # define CARRIER_NAME "FO300"
  258. #elif defined(CONFIG_CHARON)
  259. # define CARRIER_NAME "CHARON"
  260. #else
  261. # error "UNKNOWN"
  262. #endif
  263. puts ( "Board: " MODULE_NAME " (TQ-Components GmbH)\n"
  264. " on a " CARRIER_NAME " carrier board\n");
  265. return 0;
  266. }
  267. #undef MODULE_NAME
  268. #undef CARRIER_NAME
  269. void flash_preinit(void)
  270. {
  271. /*
  272. * Now, when we are in RAM, enable flash write
  273. * access for detection process.
  274. * Note that CS_BOOT cannot be cleared when
  275. * executing in flash.
  276. */
  277. *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
  278. }
  279. #ifdef CONFIG_PCI
  280. static struct pci_controller hose;
  281. extern void pci_mpc5xxx_init(struct pci_controller *);
  282. void pci_init_board(void)
  283. {
  284. pci_mpc5xxx_init(&hose);
  285. }
  286. #endif
  287. #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_RESET)
  288. #if defined (CONFIG_MINIFAP)
  289. #define SM501_POWER_MODE0_GATE 0x00000040UL
  290. #define SM501_POWER_MODE1_GATE 0x00000048UL
  291. #define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL
  292. #define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL
  293. #define SM501_GPIO_DATA_HIGH 0x00010004UL
  294. #define SM501_GPIO_51 0x00080000UL
  295. #endif /* CONFIG MINIFAP */
  296. void init_ide_reset (void)
  297. {
  298. debug ("init_ide_reset\n");
  299. #if defined (CONFIG_MINIFAP)
  300. /* Configure GPIO_51 of the SM501 grafic controller as ATA reset */
  301. /* enable GPIO control (in both power modes) */
  302. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |=
  303. POWER_MODE_GATE_GPIO_PWM_I2C;
  304. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |=
  305. POWER_MODE_GATE_GPIO_PWM_I2C;
  306. /* configure GPIO51 as output */
  307. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |=
  308. SM501_GPIO_51;
  309. #else
  310. /* Configure PSC1_4 as GPIO output for ATA reset */
  311. *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
  312. *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
  313. /* by default the ATA reset is de-asserted */
  314. *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
  315. #endif
  316. }
  317. void ide_set_reset (int idereset)
  318. {
  319. debug ("ide_reset(%d)\n", idereset);
  320. #if defined (CONFIG_MINIFAP)
  321. if (idereset) {
  322. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  323. ~SM501_GPIO_51;
  324. } else {
  325. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  326. SM501_GPIO_51;
  327. }
  328. #else
  329. if (idereset) {
  330. *(vu_long *) MPC5XXX_WU_GPIO_DATA_O &= ~GPIO_PSC1_4;
  331. } else {
  332. *(vu_long *) MPC5XXX_WU_GPIO_DATA_O |= GPIO_PSC1_4;
  333. }
  334. #endif
  335. }
  336. #endif
  337. #ifdef CONFIG_POST
  338. /*
  339. * Reads GPIO pin PSC6_3. A keypress is reported, if PSC6_3 is low. If PSC6_3
  340. * is left open, no keypress is detected.
  341. */
  342. int post_hotkeys_pressed(void)
  343. {
  344. #ifdef CONFIG_STK52XX
  345. struct mpc5xxx_gpio *gpio;
  346. gpio = (struct mpc5xxx_gpio*) MPC5XXX_GPIO;
  347. /*
  348. * Configure PSC6_0 through PSC6_3 as GPIO.
  349. */
  350. gpio->port_config &= ~(0x00700000);
  351. /* Enable GPIO for GPIO_IRDA_1 (IR_USB_CLK pin) = PSC6_3 */
  352. gpio->simple_gpioe |= 0x20000000;
  353. /* Configure GPIO_IRDA_1 as input */
  354. gpio->simple_ddr &= ~(0x20000000);
  355. return ((gpio->simple_ival & 0x20000000) ? 0 : 1);
  356. #else
  357. return 0;
  358. #endif
  359. }
  360. #endif
  361. #ifdef CONFIG_BOARD_EARLY_INIT_R
  362. int board_early_init_r (void)
  363. {
  364. extern int usb_cpu_init(void);
  365. #ifdef CONFIG_PS2MULT
  366. ps2mult_early_init();
  367. #endif /* CONFIG_PS2MULT */
  368. #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
  369. /* Low level USB init, required for proper kernel operation */
  370. usb_cpu_init();
  371. #endif
  372. return (0);
  373. }
  374. #endif
  375. #ifdef CONFIG_FO300
  376. int silent_boot (void)
  377. {
  378. vu_long timer3_status;
  379. /* Configure GPT3 as GPIO input */
  380. *(vu_long *)MPC5XXX_GPT3_ENABLE = 0x00000004;
  381. /* Read in TIMER_3 pin status */
  382. timer3_status = *(vu_long *)MPC5XXX_GPT3_STATUS;
  383. #ifdef FO300_SILENT_CONSOLE_WHEN_S1_CLOSED
  384. /* Force silent console mode if S1 switch
  385. * is in closed position (TIMER_3 pin status is LOW). */
  386. if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 0)
  387. return 1;
  388. #else
  389. /* Force silent console mode if S1 switch
  390. * is in open position (TIMER_3 pin status is HIGH). */
  391. if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 1)
  392. return 1;
  393. #endif
  394. return 0;
  395. }
  396. int board_early_init_f (void)
  397. {
  398. if (silent_boot())
  399. gd->flags |= GD_FLG_SILENT;
  400. return 0;
  401. }
  402. #endif /* CONFIG_FO300 */
  403. #if defined(CONFIG_CHARON)
  404. #include <i2c.h>
  405. #include <asm/io.h>
  406. /* The TFP410 registers */
  407. #define TFP410_REG_VEN_ID_L 0x00
  408. #define TFP410_REG_VEN_ID_H 0x01
  409. #define TFP410_REG_DEV_ID_L 0x02
  410. #define TFP410_REG_DEV_ID_H 0x03
  411. #define TFP410_REG_REV_ID 0x04
  412. #define TFP410_REG_CTL_1_MODE 0x08
  413. #define TFP410_REG_CTL_2_MODE 0x09
  414. #define TFP410_REG_CTL_3_MODE 0x0A
  415. #define TFP410_REG_CFG 0x0B
  416. #define TFP410_REG_DE_DLY 0x32
  417. #define TFP410_REG_DE_CTL 0x33
  418. #define TFP410_REG_DE_TOP 0x34
  419. #define TFP410_REG_DE_CNT_L 0x36
  420. #define TFP410_REG_DE_CNT_H 0x37
  421. #define TFP410_REG_DE_LIN_L 0x38
  422. #define TFP410_REG_DE_LIN_H 0x39
  423. #define TFP410_REG_H_RES_L 0x3A
  424. #define TFP410_REG_H_RES_H 0x3B
  425. #define TFP410_REG_V_RES_L 0x3C
  426. #define TFP410_REG_V_RES_H 0x3D
  427. static int tfp410_read_reg(int reg, uchar *buf)
  428. {
  429. if (i2c_read(CONFIG_SYS_TFP410_ADDR, reg, 1, buf, 1) != 0) {
  430. puts ("Error reading the chip.\n");
  431. return 1;
  432. }
  433. return 0;
  434. }
  435. static int tfp410_write_reg(int reg, uchar buf)
  436. {
  437. if (i2c_write(CONFIG_SYS_TFP410_ADDR, reg, 1, &buf, 1) != 0) {
  438. puts ("Error writing the chip.\n");
  439. return 1;
  440. }
  441. return 0;
  442. }
  443. typedef struct _tfp410_config {
  444. int reg;
  445. uchar val;
  446. }TFP410_CONFIG;
  447. static TFP410_CONFIG tfp410_configtbl[] = {
  448. {TFP410_REG_CTL_1_MODE, 0x37},
  449. {TFP410_REG_CTL_2_MODE, 0x20},
  450. {TFP410_REG_CTL_3_MODE, 0x80},
  451. {TFP410_REG_DE_DLY, 0x90},
  452. {TFP410_REG_DE_CTL, 0x00},
  453. {TFP410_REG_DE_TOP, 0x23},
  454. {TFP410_REG_DE_CNT_H, 0x02},
  455. {TFP410_REG_DE_CNT_L, 0x80},
  456. {TFP410_REG_DE_LIN_H, 0x01},
  457. {TFP410_REG_DE_LIN_L, 0xe0},
  458. {-1, 0},
  459. };
  460. static int charon_last_stage_init(void)
  461. {
  462. volatile struct mpc5xxx_lpb *lpb =
  463. (struct mpc5xxx_lpb *) MPC5XXX_LPB;
  464. int oldbus = i2c_get_bus_num();
  465. uchar buf;
  466. int i = 0;
  467. i2c_set_bus_num(CONFIG_SYS_TFP410_BUS);
  468. /* check version */
  469. if (tfp410_read_reg(TFP410_REG_DEV_ID_H, &buf) != 0)
  470. return -1;
  471. if (!(buf & 0x04))
  472. return -1;
  473. if (tfp410_read_reg(TFP410_REG_DEV_ID_L, &buf) != 0)
  474. return -1;
  475. if (!(buf & 0x10))
  476. return -1;
  477. /* OK, now init the chip */
  478. while (tfp410_configtbl[i].reg != -1) {
  479. int ret;
  480. ret = tfp410_write_reg(tfp410_configtbl[i].reg,
  481. tfp410_configtbl[i].val);
  482. if (ret != 0)
  483. return -1;
  484. i++;
  485. }
  486. printf("TFP410 initialized.\n");
  487. i2c_set_bus_num(oldbus);
  488. /* set deadcycle for cs3 to 0 */
  489. setbits_be32(&lpb->cs_deadcycle, 0xffffcfff);
  490. return 0;
  491. }
  492. #endif
  493. int last_stage_init (void)
  494. {
  495. /*
  496. * auto scan for really existing devices and re-set chip select
  497. * configuration.
  498. */
  499. u16 save, tmp;
  500. int restore;
  501. /*
  502. * Check for SRAM and SRAM size
  503. */
  504. /* save original SRAM content */
  505. save = *(volatile u16 *)CONFIG_SYS_CS2_START;
  506. restore = 1;
  507. /* write test pattern to SRAM */
  508. *(volatile u16 *)CONFIG_SYS_CS2_START = 0xA5A5;
  509. __asm__ volatile ("sync");
  510. /*
  511. * Put a different pattern on the data lines: otherwise they may float
  512. * long enough to read back what we wrote.
  513. */
  514. tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
  515. if (tmp == 0xA5A5)
  516. puts ("!! possible error in SRAM detection\n");
  517. if (*(volatile u16 *)CONFIG_SYS_CS2_START != 0xA5A5) {
  518. /* no SRAM at all, disable cs */
  519. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 18);
  520. *(vu_long *)MPC5XXX_CS2_START = 0x0000FFFF;
  521. *(vu_long *)MPC5XXX_CS2_STOP = 0x0000FFFF;
  522. restore = 0;
  523. __asm__ volatile ("sync");
  524. } else if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0xA5A5) {
  525. /* make sure that we access a mirrored address */
  526. *(volatile u16 *)CONFIG_SYS_CS2_START = 0x1111;
  527. __asm__ volatile ("sync");
  528. if (*(volatile u16 *)(CONFIG_SYS_CS2_START + (1<<19)) == 0x1111) {
  529. /* SRAM size = 512 kByte */
  530. *(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CONFIG_SYS_CS2_START,
  531. 0x80000);
  532. __asm__ volatile ("sync");
  533. puts ("SRAM: 512 kB\n");
  534. }
  535. else
  536. puts ("!! possible error in SRAM detection\n");
  537. } else {
  538. puts ("SRAM: 1 MB\n");
  539. }
  540. /* restore origianl SRAM content */
  541. if (restore) {
  542. *(volatile u16 *)CONFIG_SYS_CS2_START = save;
  543. __asm__ volatile ("sync");
  544. }
  545. #ifndef CONFIG_TQM5200S /* The TQM5200S has no SM501 grafic controller */
  546. /*
  547. * Check for Grafic Controller
  548. */
  549. /* save origianl FB content */
  550. save = *(volatile u16 *)CONFIG_SYS_CS1_START;
  551. restore = 1;
  552. /* write test pattern to FB memory */
  553. *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5;
  554. __asm__ volatile ("sync");
  555. /*
  556. * Put a different pattern on the data lines: otherwise they may float
  557. * long enough to read back what we wrote.
  558. */
  559. tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
  560. if (tmp == 0xA5A5)
  561. puts ("!! possible error in grafic controller detection\n");
  562. if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) {
  563. /* no grafic controller at all, disable cs */
  564. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 17);
  565. *(vu_long *)MPC5XXX_CS1_START = 0x0000FFFF;
  566. *(vu_long *)MPC5XXX_CS1_STOP = 0x0000FFFF;
  567. restore = 0;
  568. __asm__ volatile ("sync");
  569. } else {
  570. puts ("VGA: SMI501 (Voyager) with 8 MB\n");
  571. }
  572. /* restore origianl FB content */
  573. if (restore) {
  574. *(volatile u16 *)CONFIG_SYS_CS1_START = save;
  575. __asm__ volatile ("sync");
  576. }
  577. #ifdef CONFIG_FO300
  578. if (silent_boot()) {
  579. setenv("bootdelay", "0");
  580. disable_ctrlc(1);
  581. }
  582. #endif
  583. #endif /* !CONFIG_TQM5200S */
  584. #if defined(CONFIG_CHARON)
  585. charon_last_stage_init();
  586. #endif
  587. return 0;
  588. }
  589. #ifdef CONFIG_VIDEO_SM501
  590. #ifdef CONFIG_FO300
  591. #define DISPLAY_WIDTH 800
  592. #else
  593. #define DISPLAY_WIDTH 640
  594. #endif
  595. #define DISPLAY_HEIGHT 480
  596. #ifdef CONFIG_VIDEO_SM501_8BPP
  597. #error CONFIG_VIDEO_SM501_8BPP not supported.
  598. #endif /* CONFIG_VIDEO_SM501_8BPP */
  599. #ifdef CONFIG_VIDEO_SM501_16BPP
  600. #error CONFIG_VIDEO_SM501_16BPP not supported.
  601. #endif /* CONFIG_VIDEO_SM501_16BPP */
  602. #ifdef CONFIG_VIDEO_SM501_32BPP
  603. static const SMI_REGS init_regs [] =
  604. {
  605. #if 0 /* CRT only */
  606. {0x00004, 0x0},
  607. {0x00048, 0x00021807},
  608. {0x0004C, 0x10090a01},
  609. {0x00054, 0x1},
  610. {0x00040, 0x00021807},
  611. {0x00044, 0x10090a01},
  612. {0x00054, 0x0},
  613. {0x80200, 0x00010000},
  614. {0x80204, 0x0},
  615. {0x80208, 0x0A000A00},
  616. {0x8020C, 0x02fa027f},
  617. {0x80210, 0x004a028b},
  618. {0x80214, 0x020c01df},
  619. {0x80218, 0x000201e9},
  620. {0x80200, 0x00013306},
  621. #else /* panel + CRT */
  622. #ifdef CONFIG_FO300
  623. {0x00004, 0x0},
  624. {0x00048, 0x00021807},
  625. {0x0004C, 0x301a0a01},
  626. {0x00054, 0x1},
  627. {0x00040, 0x00021807},
  628. {0x00044, 0x091a0a01},
  629. {0x00054, 0x0},
  630. {0x80000, 0x0f013106},
  631. {0x80004, 0xc428bb17},
  632. {0x8000C, 0x00000000},
  633. {0x80010, 0x0C800C80},
  634. {0x80014, 0x03200000},
  635. {0x80018, 0x01e00000},
  636. {0x8001C, 0x00000000},
  637. {0x80020, 0x01e00320},
  638. {0x80024, 0x042a031f},
  639. {0x80028, 0x0086034a},
  640. {0x8002C, 0x020c01df},
  641. {0x80030, 0x000201ea},
  642. {0x80200, 0x00010000},
  643. #else
  644. {0x00004, 0x0},
  645. {0x00048, 0x00021807},
  646. {0x0004C, 0x091a0a01},
  647. {0x00054, 0x1},
  648. {0x00040, 0x00021807},
  649. {0x00044, 0x091a0a01},
  650. {0x00054, 0x0},
  651. {0x80000, 0x0f013106},
  652. {0x80004, 0xc428bb17},
  653. {0x8000C, 0x00000000},
  654. {0x80010, 0x0a000a00},
  655. {0x80014, 0x02800000},
  656. {0x80018, 0x01e00000},
  657. {0x8001C, 0x00000000},
  658. {0x80020, 0x01e00280},
  659. {0x80024, 0x02fa027f},
  660. {0x80028, 0x004a028b},
  661. {0x8002C, 0x020c01df},
  662. {0x80030, 0x000201e9},
  663. {0x80200, 0x00010000},
  664. #endif /* #ifdef CONFIG_FO300 */
  665. #endif
  666. {0, 0}
  667. };
  668. #endif /* CONFIG_VIDEO_SM501_32BPP */
  669. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  670. /*
  671. * Return text to be printed besides the logo.
  672. */
  673. void video_get_info_str (int line_number, char *info)
  674. {
  675. if (line_number == 1) {
  676. strcpy (info, " Board: TQM5200 (TQ-Components GmbH)");
  677. #if defined (CONFIG_CHARON) || defined (CONFIG_FO300) || \
  678. defined(CONFIG_STK52XX) || defined(CONFIG_TB5200)
  679. } else if (line_number == 2) {
  680. #if defined (CONFIG_CHARON)
  681. strcpy (info, " on a CHARON carrier board");
  682. #endif
  683. #if defined (CONFIG_STK52XX)
  684. strcpy (info, " on a STK52xx carrier board");
  685. #endif
  686. #if defined (CONFIG_TB5200)
  687. strcpy (info, " on a TB5200 carrier board");
  688. #endif
  689. #if defined (CONFIG_FO300)
  690. strcpy (info, " on a FO300 carrier board");
  691. #endif
  692. #endif
  693. }
  694. else {
  695. info [0] = '\0';
  696. }
  697. }
  698. #endif
  699. /*
  700. * Returns SM501 register base address. First thing called in the
  701. * driver. Checks if SM501 is physically present.
  702. */
  703. unsigned int board_video_init (void)
  704. {
  705. u16 save, tmp;
  706. int restore, ret;
  707. /*
  708. * Check for Grafic Controller
  709. */
  710. /* save origianl FB content */
  711. save = *(volatile u16 *)CONFIG_SYS_CS1_START;
  712. restore = 1;
  713. /* write test pattern to FB memory */
  714. *(volatile u16 *)CONFIG_SYS_CS1_START = 0xA5A5;
  715. __asm__ volatile ("sync");
  716. /*
  717. * Put a different pattern on the data lines: otherwise they may float
  718. * long enough to read back what we wrote.
  719. */
  720. tmp = *(volatile u16 *)CONFIG_SYS_FLASH_BASE;
  721. if (tmp == 0xA5A5)
  722. puts ("!! possible error in grafic controller detection\n");
  723. if (*(volatile u16 *)CONFIG_SYS_CS1_START != 0xA5A5) {
  724. /* no grafic controller found */
  725. restore = 0;
  726. ret = 0;
  727. } else {
  728. ret = SM501_MMIO_BASE;
  729. }
  730. if (restore) {
  731. *(volatile u16 *)CONFIG_SYS_CS1_START = save;
  732. __asm__ volatile ("sync");
  733. }
  734. return ret;
  735. }
  736. /*
  737. * Returns SM501 framebuffer address
  738. */
  739. unsigned int board_video_get_fb (void)
  740. {
  741. return SM501_FB_BASE;
  742. }
  743. /*
  744. * Called after initializing the SM501 and before clearing the screen.
  745. */
  746. void board_validate_screen (unsigned int base)
  747. {
  748. }
  749. /*
  750. * Return a pointer to the initialization sequence.
  751. */
  752. const SMI_REGS *board_get_regs (void)
  753. {
  754. return init_regs;
  755. }
  756. int board_get_width (void)
  757. {
  758. return DISPLAY_WIDTH;
  759. }
  760. int board_get_height (void)
  761. {
  762. return DISPLAY_HEIGHT;
  763. }
  764. #endif /* CONFIG_VIDEO_SM501 */
  765. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  766. void ft_board_setup(void *blob, bd_t *bd)
  767. {
  768. ft_cpu_setup(blob, bd);
  769. #if defined(CONFIG_VIDEO)
  770. fdt_add_edid(blob, "smi,sm501", edid_buf);
  771. #endif
  772. }
  773. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
  774. #if defined(CONFIG_RESET_PHY_R)
  775. #include <miiphy.h>
  776. void reset_phy(void)
  777. {
  778. /* init Micrel KSZ8993 PHY */
  779. miiphy_write("FEC", CONFIG_PHY_ADDR, 0x01, 0x09);
  780. }
  781. #endif
  782. int board_eth_init(bd_t *bis)
  783. {
  784. cpu_eth_init(bis); /* Built in FEC comes first */
  785. return pci_eth_init(bis);
  786. }