tqm5200.c 16 KB

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