tqm5200.c 19 KB

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