tqm5200.c 18 KB

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