bc3450.c 15 KB

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