tqm5200.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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. #ifdef CONFIG_VIDEO_SM501
  34. #include <sm501.h>
  35. #endif
  36. #if defined(CONFIG_MPC5200_DDR)
  37. #include "mt46v16m16-75.h"
  38. #else
  39. #include "mt48lc16m16a2-75.h"
  40. #endif
  41. #ifdef CONFIG_PS2MULT
  42. void ps2mult_early_init(void);
  43. #endif
  44. #ifndef CFG_RAMBOOT
  45. static void sdram_start (int hi_addr)
  46. {
  47. long hi_addr_bit = hi_addr ? 0x01000000 : 0;
  48. /* unlock mode register */
  49. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
  50. hi_addr_bit;
  51. __asm__ volatile ("sync");
  52. /* precharge all banks */
  53. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  54. hi_addr_bit;
  55. __asm__ volatile ("sync");
  56. #if SDRAM_DDR
  57. /* set mode register: extended mode */
  58. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_EMODE;
  59. __asm__ volatile ("sync");
  60. /* set mode register: reset DLL */
  61. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE | 0x04000000;
  62. __asm__ volatile ("sync");
  63. #endif
  64. /* precharge all banks */
  65. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
  66. hi_addr_bit;
  67. __asm__ volatile ("sync");
  68. /* auto refresh */
  69. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
  70. hi_addr_bit;
  71. __asm__ volatile ("sync");
  72. /* set mode register */
  73. *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
  74. __asm__ volatile ("sync");
  75. /* normal operation */
  76. *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
  77. __asm__ volatile ("sync");
  78. }
  79. #endif
  80. /*
  81. * ATTENTION: Although partially referenced initdram does NOT make real use
  82. * use of CFG_SDRAM_BASE. The code does not work if CFG_SDRAM_BASE
  83. * is something else than 0x00000000.
  84. */
  85. #if defined(CONFIG_MPC5200)
  86. long int initdram (int board_type)
  87. {
  88. ulong dramsize = 0;
  89. ulong dramsize2 = 0;
  90. uint svr, pvr;
  91. #ifndef CFG_RAMBOOT
  92. ulong test1, test2;
  93. /* setup SDRAM chip selects */
  94. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001c; /* 512MB at 0x0 */
  95. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x40000000; /* disabled */
  96. __asm__ volatile ("sync");
  97. /* setup config registers */
  98. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
  99. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
  100. __asm__ volatile ("sync");
  101. #if SDRAM_DDR
  102. /* set tap delay */
  103. *(vu_long *)MPC5XXX_CDM_PORCFG = SDRAM_TAPDELAY;
  104. __asm__ volatile ("sync");
  105. #endif
  106. /* find RAM size using SDRAM CS0 only */
  107. sdram_start(0);
  108. test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
  109. sdram_start(1);
  110. test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x20000000);
  111. if (test1 > test2) {
  112. sdram_start(0);
  113. dramsize = test1;
  114. } else {
  115. dramsize = test2;
  116. }
  117. /* memory smaller than 1MB is impossible */
  118. if (dramsize < (1 << 20)) {
  119. dramsize = 0;
  120. }
  121. /* set SDRAM CS0 size according to the amount of RAM found */
  122. if (dramsize > 0) {
  123. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
  124. __builtin_ffs(dramsize >> 20) - 1;
  125. } else {
  126. *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
  127. }
  128. /* let SDRAM CS1 start right after CS0 */
  129. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize + 0x0000001c; /* 512MB */
  130. /* find RAM size using SDRAM CS1 only */
  131. sdram_start(0);
  132. test1 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
  133. sdram_start(1);
  134. test2 = get_ram_size((long *)(CFG_SDRAM_BASE + dramsize), 0x20000000);
  135. if (test1 > test2) {
  136. sdram_start(0);
  137. dramsize2 = test1;
  138. } else {
  139. dramsize2 = test2;
  140. }
  141. /* memory smaller than 1MB is impossible */
  142. if (dramsize2 < (1 << 20)) {
  143. dramsize2 = 0;
  144. }
  145. /* set SDRAM CS1 size according to the amount of RAM found */
  146. if (dramsize2 > 0) {
  147. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize
  148. | (0x13 + __builtin_ffs(dramsize2 >> 20) - 1);
  149. } else {
  150. *(vu_long *)MPC5XXX_SDRAM_CS1CFG = dramsize; /* disabled */
  151. }
  152. #else /* CFG_RAMBOOT */
  153. /* retrieve size of memory connected to SDRAM CS0 */
  154. dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
  155. if (dramsize >= 0x13) {
  156. dramsize = (1 << (dramsize - 0x13)) << 20;
  157. } else {
  158. dramsize = 0;
  159. }
  160. /* retrieve size of memory connected to SDRAM CS1 */
  161. dramsize2 = *(vu_long *)MPC5XXX_SDRAM_CS1CFG & 0xFF;
  162. if (dramsize2 >= 0x13) {
  163. dramsize2 = (1 << (dramsize2 - 0x13)) << 20;
  164. } else {
  165. dramsize2 = 0;
  166. }
  167. #endif /* CFG_RAMBOOT */
  168. /*
  169. * On MPC5200B we need to set the special configuration delay in the
  170. * DDR controller. Please refer to Freescale's AN3221 "MPC5200B SDRAM
  171. * Initialization and Configuration", 3.3.1 SDelay--MBAR + 0x0190:
  172. *
  173. * "The SDelay should be written to a value of 0x00000004. It is
  174. * required to account for changes caused by normal wafer processing
  175. * parameters."
  176. */
  177. svr = get_svr();
  178. pvr = get_pvr();
  179. if ((SVR_MJREV(svr) >= 2) &&
  180. (PVR_MAJ(pvr) == 1) && (PVR_MIN(pvr) == 4)) {
  181. *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
  182. __asm__ volatile ("sync");
  183. }
  184. #if defined(CONFIG_TQM5200_B)
  185. return dramsize + dramsize2;
  186. #else
  187. return dramsize;
  188. #endif /* CONFIG_TQM5200_B */
  189. }
  190. #elif defined(CONFIG_MGT5100)
  191. long int initdram (int board_type)
  192. {
  193. ulong dramsize = 0;
  194. #ifndef CFG_RAMBOOT
  195. ulong test1, test2;
  196. /* setup and enable SDRAM chip selects */
  197. *(vu_long *)MPC5XXX_SDRAM_START = 0x00000000;
  198. *(vu_long *)MPC5XXX_SDRAM_STOP = 0x0000ffff;/* 2G */
  199. *(vu_long *)MPC5XXX_ADDECR |= (1 << 22); /* Enable SDRAM */
  200. __asm__ volatile ("sync");
  201. /* setup config registers */
  202. *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
  203. *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
  204. /* address select register */
  205. *(vu_long *)MPC5XXX_SDRAM_XLBSEL = SDRAM_ADDRSEL;
  206. __asm__ volatile ("sync");
  207. /* find RAM size */
  208. sdram_start(0);
  209. test1 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
  210. sdram_start(1);
  211. test2 = get_ram_size((ulong *)CFG_SDRAM_BASE, 0x80000000);
  212. if (test1 > test2) {
  213. sdram_start(0);
  214. dramsize = test1;
  215. } else {
  216. dramsize = test2;
  217. }
  218. /* set SDRAM end address according to size */
  219. *(vu_long *)MPC5XXX_SDRAM_STOP = ((dramsize - 1) >> 15);
  220. #else /* CFG_RAMBOOT */
  221. /* Retrieve amount of SDRAM available */
  222. dramsize = ((*(vu_long *)MPC5XXX_SDRAM_STOP + 1) << 15);
  223. #endif /* CFG_RAMBOOT */
  224. return dramsize;
  225. }
  226. #else
  227. #error Neither CONFIG_MPC5200 or CONFIG_MGT5100 defined
  228. #endif
  229. int checkboard (void)
  230. {
  231. #if defined(CONFIG_AEVFIFO)
  232. puts ("Board: AEVFIFO\n");
  233. return 0;
  234. #endif
  235. #if defined(CONFIG_TQM5200S)
  236. # define MODULE_NAME "TQM5200S"
  237. #else
  238. # define MODULE_NAME "TQM5200"
  239. #endif
  240. #if defined(CONFIG_STK52XX)
  241. # define CARRIER_NAME "STK52xx"
  242. #elif defined(CONFIG_TB5200)
  243. # define CARRIER_NAME "TB5200"
  244. #elif defined(CONFIG_CAM5200)
  245. # define CARRIER_NAME "Cam5200"
  246. #elif defined(CONFIG_FO300)
  247. # define CARRIER_NAME "FO300"
  248. #else
  249. # error "Unknown carrier board"
  250. #endif
  251. puts ( "Board: " MODULE_NAME " (TQ-Components GmbH)\n"
  252. " on a " CARRIER_NAME " carrier board\n");
  253. return 0;
  254. }
  255. #undef MODULE_NAME
  256. #undef CARRIER_NAME
  257. void flash_preinit(void)
  258. {
  259. /*
  260. * Now, when we are in RAM, enable flash write
  261. * access for detection process.
  262. * Note that CS_BOOT cannot be cleared when
  263. * executing in flash.
  264. */
  265. #if defined(CONFIG_MGT5100)
  266. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25); /* disable CS_BOOT */
  267. *(vu_long *)MPC5XXX_ADDECR |= (1 << 16); /* enable CS0 */
  268. #endif
  269. *(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
  270. }
  271. #ifdef CONFIG_PCI
  272. static struct pci_controller hose;
  273. extern void pci_mpc5xxx_init(struct pci_controller *);
  274. void pci_init_board(void)
  275. {
  276. pci_mpc5xxx_init(&hose);
  277. }
  278. #endif
  279. #if defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET)
  280. #if defined (CONFIG_MINIFAP)
  281. #define SM501_POWER_MODE0_GATE 0x00000040UL
  282. #define SM501_POWER_MODE1_GATE 0x00000048UL
  283. #define POWER_MODE_GATE_GPIO_PWM_I2C 0x00000040UL
  284. #define SM501_GPIO_DATA_DIR_HIGH 0x0001000CUL
  285. #define SM501_GPIO_DATA_HIGH 0x00010004UL
  286. #define SM501_GPIO_51 0x00080000UL
  287. #else
  288. #define GPIO_PSC1_4 0x01000000UL
  289. #endif
  290. void init_ide_reset (void)
  291. {
  292. debug ("init_ide_reset\n");
  293. #if defined (CONFIG_MINIFAP)
  294. /* Configure GPIO_51 of the SM501 grafic controller as ATA reset */
  295. /* enable GPIO control (in both power modes) */
  296. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE0_GATE) |=
  297. POWER_MODE_GATE_GPIO_PWM_I2C;
  298. *(vu_long *) (SM501_MMIO_BASE+SM501_POWER_MODE1_GATE) |=
  299. POWER_MODE_GATE_GPIO_PWM_I2C;
  300. /* configure GPIO51 as output */
  301. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_DIR_HIGH) |=
  302. SM501_GPIO_51;
  303. #else
  304. /* Configure PSC1_4 as GPIO output for ATA reset */
  305. *(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
  306. *(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
  307. #endif
  308. }
  309. void ide_set_reset (int idereset)
  310. {
  311. debug ("ide_reset(%d)\n", idereset);
  312. #if defined (CONFIG_MINIFAP)
  313. if (idereset) {
  314. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) &=
  315. ~SM501_GPIO_51;
  316. } else {
  317. *(vu_long *) (SM501_MMIO_BASE+SM501_GPIO_DATA_HIGH) |=
  318. SM501_GPIO_51;
  319. }
  320. #else
  321. if (idereset) {
  322. *(vu_long *) MPC5XXX_WU_GPIO_DATA &= ~GPIO_PSC1_4;
  323. } else {
  324. *(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
  325. }
  326. #endif
  327. }
  328. #endif /* defined (CFG_CMD_IDE) && defined (CONFIG_IDE_RESET) */
  329. #ifdef CONFIG_POST
  330. /*
  331. * Reads GPIO pin PSC6_3. A keypress is reported, if PSC6_3 is low. If PSC6_3
  332. * is left open, no keypress is detected.
  333. */
  334. int post_hotkeys_pressed(void)
  335. {
  336. struct mpc5xxx_gpio *gpio;
  337. gpio = (struct mpc5xxx_gpio*) MPC5XXX_GPIO;
  338. /*
  339. * Configure PSC6_1 and PSC6_3 as GPIO. PSC6 then couldn't be used in
  340. * CODEC or UART mode. Consumer IrDA should still be possible.
  341. */
  342. gpio->port_config &= ~(0x07000000);
  343. gpio->port_config |= 0x03000000;
  344. /* Enable GPIO for GPIO_IRDA_1 (IR_USB_CLK pin) = PSC6_3 */
  345. gpio->simple_gpioe |= 0x20000000;
  346. /* Configure GPIO_IRDA_1 as input */
  347. gpio->simple_ddr &= ~(0x20000000);
  348. return ((gpio->simple_ival & 0x20000000) ? 0 : 1);
  349. }
  350. #endif
  351. #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
  352. void post_word_store (ulong a)
  353. {
  354. volatile ulong *save_addr =
  355. (volatile ulong *)(MPC5XXX_SRAM + MPC5XXX_SRAM_POST_SIZE);
  356. *save_addr = a;
  357. }
  358. ulong post_word_load (void)
  359. {
  360. volatile ulong *save_addr =
  361. (volatile ulong *)(MPC5XXX_SRAM + MPC5XXX_SRAM_POST_SIZE);
  362. return *save_addr;
  363. }
  364. #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
  365. #ifdef CONFIG_PS2MULT
  366. #ifdef CONFIG_BOARD_EARLY_INIT_R
  367. int board_early_init_r (void)
  368. {
  369. ps2mult_early_init();
  370. return (0);
  371. }
  372. #endif
  373. #endif /* CONFIG_PS2MULT */
  374. int last_stage_init (void)
  375. {
  376. /*
  377. * auto scan for really existing devices and re-set chip select
  378. * configuration.
  379. */
  380. u16 save, tmp;
  381. int restore;
  382. /*
  383. * Check for SRAM and SRAM size
  384. */
  385. /* save original SRAM content */
  386. save = *(volatile u16 *)CFG_CS2_START;
  387. restore = 1;
  388. /* write test pattern to SRAM */
  389. *(volatile u16 *)CFG_CS2_START = 0xA5A5;
  390. __asm__ volatile ("sync");
  391. /*
  392. * Put a different pattern on the data lines: otherwise they may float
  393. * long enough to read back what we wrote.
  394. */
  395. tmp = *(volatile u16 *)CFG_FLASH_BASE;
  396. if (tmp == 0xA5A5)
  397. puts ("!! possible error in SRAM detection\n");
  398. if (*(volatile u16 *)CFG_CS2_START != 0xA5A5) {
  399. /* no SRAM at all, disable cs */
  400. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 18);
  401. *(vu_long *)MPC5XXX_CS2_START = 0x0000FFFF;
  402. *(vu_long *)MPC5XXX_CS2_STOP = 0x0000FFFF;
  403. restore = 0;
  404. __asm__ volatile ("sync");
  405. } else if (*(volatile u16 *)(CFG_CS2_START + (1<<19)) == 0xA5A5) {
  406. /* make sure that we access a mirrored address */
  407. *(volatile u16 *)CFG_CS2_START = 0x1111;
  408. __asm__ volatile ("sync");
  409. if (*(volatile u16 *)(CFG_CS2_START + (1<<19)) == 0x1111) {
  410. /* SRAM size = 512 kByte */
  411. *(vu_long *)MPC5XXX_CS2_STOP = STOP_REG(CFG_CS2_START,
  412. 0x80000);
  413. __asm__ volatile ("sync");
  414. puts ("SRAM: 512 kB\n");
  415. }
  416. else
  417. puts ("!! possible error in SRAM detection\n");
  418. } else {
  419. puts ("SRAM: 1 MB\n");
  420. }
  421. /* restore origianl SRAM content */
  422. if (restore) {
  423. *(volatile u16 *)CFG_CS2_START = save;
  424. __asm__ volatile ("sync");
  425. }
  426. /*
  427. * Check for Grafic Controller
  428. */
  429. /* save origianl FB content */
  430. save = *(volatile u16 *)CFG_CS1_START;
  431. restore = 1;
  432. /* write test pattern to FB memory */
  433. *(volatile u16 *)CFG_CS1_START = 0xA5A5;
  434. __asm__ volatile ("sync");
  435. /*
  436. * Put a different pattern on the data lines: otherwise they may float
  437. * long enough to read back what we wrote.
  438. */
  439. tmp = *(volatile u16 *)CFG_FLASH_BASE;
  440. if (tmp == 0xA5A5)
  441. puts ("!! possible error in grafic controller detection\n");
  442. if (*(volatile u16 *)CFG_CS1_START != 0xA5A5) {
  443. /* no grafic controller at all, disable cs */
  444. *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 17);
  445. *(vu_long *)MPC5XXX_CS1_START = 0x0000FFFF;
  446. *(vu_long *)MPC5XXX_CS1_STOP = 0x0000FFFF;
  447. restore = 0;
  448. __asm__ volatile ("sync");
  449. } else {
  450. puts ("VGA: SMI501 (Voyager) with 8 MB\n");
  451. }
  452. /* restore origianl FB content */
  453. if (restore) {
  454. *(volatile u16 *)CFG_CS1_START = save;
  455. __asm__ volatile ("sync");
  456. }
  457. return 0;
  458. }
  459. #ifdef CONFIG_VIDEO_SM501
  460. #ifdef CONFIG_FO300
  461. #define DISPLAY_WIDTH 800
  462. #else
  463. #define DISPLAY_WIDTH 640
  464. #endif
  465. #define DISPLAY_HEIGHT 480
  466. #ifdef CONFIG_VIDEO_SM501_8BPP
  467. #error CONFIG_VIDEO_SM501_8BPP not supported.
  468. #endif /* CONFIG_VIDEO_SM501_8BPP */
  469. #ifdef CONFIG_VIDEO_SM501_16BPP
  470. #error CONFIG_VIDEO_SM501_16BPP not supported.
  471. #endif /* CONFIG_VIDEO_SM501_16BPP */
  472. #ifdef CONFIG_VIDEO_SM501_32BPP
  473. static const SMI_REGS init_regs [] =
  474. {
  475. #if 0 /* CRT only */
  476. {0x00004, 0x0},
  477. {0x00048, 0x00021807},
  478. {0x0004C, 0x10090a01},
  479. {0x00054, 0x1},
  480. {0x00040, 0x00021807},
  481. {0x00044, 0x10090a01},
  482. {0x00054, 0x0},
  483. {0x80200, 0x00010000},
  484. {0x80204, 0x0},
  485. {0x80208, 0x0A000A00},
  486. {0x8020C, 0x02fa027f},
  487. {0x80210, 0x004a028b},
  488. {0x80214, 0x020c01df},
  489. {0x80218, 0x000201e9},
  490. {0x80200, 0x00013306},
  491. #else /* panel + CRT */
  492. #ifdef CONFIG_FO300
  493. {0x00004, 0x0},
  494. {0x00048, 0x00021807},
  495. {0x0004C, 0x301a0a01},
  496. {0x00054, 0x1},
  497. {0x00040, 0x00021807},
  498. {0x00044, 0x091a0a01},
  499. {0x00054, 0x0},
  500. {0x80000, 0x0f013106},
  501. {0x80004, 0xc428bb17},
  502. {0x8000C, 0x00000000},
  503. {0x80010, 0x0C800C80},
  504. {0x80014, 0x03200000},
  505. {0x80018, 0x01e00000},
  506. {0x8001C, 0x00000000},
  507. {0x80020, 0x01e00320},
  508. {0x80024, 0x042a031f},
  509. {0x80028, 0x0086034a},
  510. {0x8002C, 0x020c01df},
  511. {0x80030, 0x000201ea},
  512. {0x80200, 0x00010000},
  513. #else
  514. {0x00004, 0x0},
  515. {0x00048, 0x00021807},
  516. {0x0004C, 0x091a0a01},
  517. {0x00054, 0x1},
  518. {0x00040, 0x00021807},
  519. {0x00044, 0x091a0a01},
  520. {0x00054, 0x0},
  521. {0x80000, 0x0f013106},
  522. {0x80004, 0xc428bb17},
  523. {0x8000C, 0x00000000},
  524. {0x80010, 0x0a000a00},
  525. {0x80014, 0x02800000},
  526. {0x80018, 0x01e00000},
  527. {0x8001C, 0x00000000},
  528. {0x80020, 0x01e00280},
  529. {0x80024, 0x02fa027f},
  530. {0x80028, 0x004a028b},
  531. {0x8002C, 0x020c01df},
  532. {0x80030, 0x000201e9},
  533. {0x80200, 0x00010000},
  534. #endif /* #ifdef CONFIG_FO300 */
  535. #endif
  536. {0, 0}
  537. };
  538. #endif /* CONFIG_VIDEO_SM501_32BPP */
  539. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  540. /*
  541. * Return text to be printed besides the logo.
  542. */
  543. void video_get_info_str (int line_number, char *info)
  544. {
  545. if (line_number == 1) {
  546. strcpy (info, " Board: TQM5200 (TQ-Components GmbH)");
  547. #if defined (CONFIG_STK52XX) || defined (CONFIG_TB5200) || defined(CONFIG_FO300)
  548. } else if (line_number == 2) {
  549. #if defined (CONFIG_STK52XX)
  550. strcpy (info, " on a STK52xx carrier board");
  551. #endif
  552. #if defined (CONFIG_TB5200)
  553. strcpy (info, " on a TB5200 carrier board");
  554. #endif
  555. #if defined (CONFIG_FO300)
  556. strcpy (info, " on a FO300 carrier board");
  557. #endif
  558. #endif
  559. }
  560. else {
  561. info [0] = '\0';
  562. }
  563. }
  564. #endif
  565. /*
  566. * Returns SM501 register base address. First thing called in the
  567. * driver. Checks if SM501 is physically present.
  568. */
  569. unsigned int board_video_init (void)
  570. {
  571. u16 save, tmp;
  572. int restore, ret;
  573. /*
  574. * Check for Grafic Controller
  575. */
  576. /* save origianl FB content */
  577. save = *(volatile u16 *)CFG_CS1_START;
  578. restore = 1;
  579. /* write test pattern to FB memory */
  580. *(volatile u16 *)CFG_CS1_START = 0xA5A5;
  581. __asm__ volatile ("sync");
  582. /*
  583. * Put a different pattern on the data lines: otherwise they may float
  584. * long enough to read back what we wrote.
  585. */
  586. tmp = *(volatile u16 *)CFG_FLASH_BASE;
  587. if (tmp == 0xA5A5)
  588. puts ("!! possible error in grafic controller detection\n");
  589. if (*(volatile u16 *)CFG_CS1_START != 0xA5A5) {
  590. /* no grafic controller found */
  591. restore = 0;
  592. ret = 0;
  593. } else {
  594. ret = SM501_MMIO_BASE;
  595. }
  596. if (restore) {
  597. *(volatile u16 *)CFG_CS1_START = save;
  598. __asm__ volatile ("sync");
  599. }
  600. return ret;
  601. }
  602. /*
  603. * Returns SM501 framebuffer address
  604. */
  605. unsigned int board_video_get_fb (void)
  606. {
  607. return SM501_FB_BASE;
  608. }
  609. /*
  610. * Called after initializing the SM501 and before clearing the screen.
  611. */
  612. void board_validate_screen (unsigned int base)
  613. {
  614. }
  615. /*
  616. * Return a pointer to the initialization sequence.
  617. */
  618. const SMI_REGS *board_get_regs (void)
  619. {
  620. return init_regs;
  621. }
  622. int board_get_width (void)
  623. {
  624. return DISPLAY_WIDTH;
  625. }
  626. int board_get_height (void)
  627. {
  628. return DISPLAY_HEIGHT;
  629. }
  630. #endif /* CONFIG_VIDEO_SM501 */
  631. #ifdef CONFIG_BOARD_EARLY_INIT_F
  632. #ifdef CONFIG_FO300
  633. int board_early_init_f (void)
  634. {
  635. vu_long timer3_status;
  636. DECLARE_GLOBAL_DATA_PTR;
  637. /* Configure GPT3 as GPIO input */
  638. *(vu_long *)MPC5XXX_GPT3_ENABLE = 0x00000004;
  639. /* Read in TIMER_3 pin status */
  640. timer3_status = *(vu_long *)MPC5XXX_GPT3_STATUS;
  641. #ifdef FO300_SILENT_CONSOLE_WHEN_S1_CLOSED
  642. /* Force silent console mode if S1 switch
  643. * is in closed position (TIMER_3 pin status is LOW). */
  644. if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 0)
  645. #else
  646. /* Force silent console mode if S1 switch
  647. * is in open position (TIMER_3 pin status is HIGH). */
  648. if (MPC5XXX_GPT_GPIO_PIN(timer3_status) == 1)
  649. #endif
  650. gd->flags |= GD_FLG_SILENT;
  651. return 0;
  652. }
  653. #endif
  654. #endif