tqm5200.c 18 KB

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