hh405.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. /*
  2. * (C) Copyright 2001-2004
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  4. *
  5. * (C) Copyright 2005
  6. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <asm/processor.h>
  28. #include <command.h>
  29. #include <malloc.h>
  30. #include <pci.h>
  31. #include <sm501.h>
  32. #ifdef CONFIG_VIDEO_SM501
  33. #define SWAP32(x) ((((x) & 0x000000ff) << 24) | (((x) & 0x0000ff00) << 8)|\
  34. (((x) & 0x00ff0000) >> 8) | (((x) & 0xff000000) >> 24) )
  35. #ifdef CONFIG_VIDEO_SM501_8BPP
  36. #error CONFIG_VIDEO_SM501_8BPP not supported.
  37. #endif /* CONFIG_VIDEO_SM501_8BPP */
  38. #ifdef CONFIG_VIDEO_SM501_16BPP
  39. #define BPP 16
  40. /*
  41. * 800x600 display B084SN03: PCLK = 40MHz
  42. * => 2*PCLK = 80MHz
  43. * 336/4 = 84MHz
  44. * => PCLK = 84MHz
  45. */
  46. static const SMI_REGS init_regs_800x600 [] =
  47. {
  48. #if 1 /* test-only */
  49. {0x0005c, SWAP32(0xffffffff)}, /* set endianess to big endian */
  50. #else
  51. {0x0005c, SWAP32(0x00000000)}, /* set endianess to little endian */
  52. #endif
  53. {0x00004, SWAP32(0x00000000)},
  54. /* clocks for pm1... */
  55. {0x00048, SWAP32(0x00021807)},
  56. {0x0004C, SWAP32(0x221a0a01)},
  57. {0x00054, SWAP32(0x00000001)},
  58. /* clocks for pm0... */
  59. {0x00040, SWAP32(0x00021807)},
  60. {0x00044, SWAP32(0x221a0a01)},
  61. {0x00054, SWAP32(0x00000000)},
  62. /* panel control regs... */
  63. {0x80000, SWAP32(0x0f013105)}, /* panel display control: 16-bit RGB 5:6:5 mode */
  64. {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
  65. {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
  66. {0x80010, SWAP32(0x06400640)}, /* panel fb offset/window width */
  67. {0x80014, SWAP32(0x03200000)}, /* panel fb width (0x320=800) */
  68. {0x80018, SWAP32(0x02580000)}, /* panel fb height (0x258=600) */
  69. {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
  70. {0x80020, SWAP32(0x02580320)}, /* panel plane br location */
  71. {0x80024, SWAP32(0x041f031f)}, /* panel horizontal total */
  72. {0x80028, SWAP32(0x00800347)}, /* panel horizontal sync */
  73. {0x8002C, SWAP32(0x02730257)}, /* panel vertical total */
  74. {0x80030, SWAP32(0x00040258)}, /* panel vertical sync */
  75. {0x80200, SWAP32(0x00010000)}, /* crt display control */
  76. {0, 0}
  77. };
  78. /*
  79. * 1024x768 display G150XG02: PCLK = 65MHz
  80. * => 2*PCLK = 130MHz
  81. * 288/2 = 144MHz
  82. * => PCLK = 72MHz
  83. */
  84. static const SMI_REGS init_regs_1024x768 [] =
  85. {
  86. {0x00004, SWAP32(0x00000000)},
  87. /* clocks for pm1... */
  88. {0x00048, SWAP32(0x00021807)},
  89. {0x0004C, SWAP32(0x011a0a01)},
  90. {0x00054, SWAP32(0x00000001)},
  91. /* clocks for pm0... */
  92. {0x00040, SWAP32(0x00021807)},
  93. {0x00044, SWAP32(0x011a0a01)},
  94. {0x00054, SWAP32(0x00000000)},
  95. /* panel control regs... */
  96. {0x80000, SWAP32(0x0f013105)}, /* panel display control: 16-bit RGB 5:6:5 mode */
  97. {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
  98. {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
  99. {0x80010, SWAP32(0x08000800)}, /* panel fb offset/window width */
  100. {0x80014, SWAP32(0x04000000)}, /* panel fb width (0x400=1024) */
  101. {0x80018, SWAP32(0x03000000)}, /* panel fb height (0x300=768) */
  102. {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
  103. {0x80020, SWAP32(0x03000400)}, /* panel plane br location */
  104. {0x80024, SWAP32(0x053f03ff)}, /* panel horizontal total */
  105. {0x80028, SWAP32(0x0140040f)}, /* panel horizontal sync */
  106. {0x8002C, SWAP32(0x032502ff)}, /* panel vertical total */
  107. {0x80030, SWAP32(0x00260301)}, /* panel vertical sync */
  108. {0x80200, SWAP32(0x00010000)}, /* crt display control */
  109. {0, 0}
  110. };
  111. #endif /* CONFIG_VIDEO_SM501_16BPP */
  112. #ifdef CONFIG_VIDEO_SM501_32BPP
  113. #define BPP 32
  114. /*
  115. * 800x600 display B084SN03: PCLK = 40MHz
  116. * => 2*PCLK = 80MHz
  117. * 336/4 = 84MHz
  118. * => PCLK = 84MHz
  119. */
  120. static const SMI_REGS init_regs_800x600 [] =
  121. {
  122. #if 0 /* test-only */
  123. {0x0005c, SWAP32(0xffffffff)}, /* set endianess to big endian */
  124. #else
  125. {0x0005c, SWAP32(0x00000000)}, /* set endianess to little endian */
  126. #endif
  127. {0x00004, SWAP32(0x00000000)},
  128. /* clocks for pm1... */
  129. {0x00048, SWAP32(0x00021807)},
  130. {0x0004C, SWAP32(0x221a0a01)},
  131. {0x00054, SWAP32(0x00000001)},
  132. /* clocks for pm0... */
  133. {0x00040, SWAP32(0x00021807)},
  134. {0x00044, SWAP32(0x221a0a01)},
  135. {0x00054, SWAP32(0x00000000)},
  136. /* panel control regs... */
  137. {0x80000, SWAP32(0x0f013106)}, /* panel display control: 32-bit RGB 8:8:8 mode */
  138. {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
  139. {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
  140. {0x80010, SWAP32(0x0c800c80)}, /* panel fb offset/window width */
  141. {0x80014, SWAP32(0x03200000)}, /* panel fb width (0x320=800) */
  142. {0x80018, SWAP32(0x02580000)}, /* panel fb height (0x258=600) */
  143. {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
  144. {0x80020, SWAP32(0x02580320)}, /* panel plane br location */
  145. {0x80024, SWAP32(0x041f031f)}, /* panel horizontal total */
  146. {0x80028, SWAP32(0x00800347)}, /* panel horizontal sync */
  147. {0x8002C, SWAP32(0x02730257)}, /* panel vertical total */
  148. {0x80030, SWAP32(0x00040258)}, /* panel vertical sync */
  149. {0x80200, SWAP32(0x00010000)}, /* crt display control */
  150. {0, 0}
  151. };
  152. /*
  153. * 1024x768 display G150XG02: PCLK = 65MHz
  154. * => 2*PCLK = 130MHz
  155. * 288/2 = 144MHz
  156. * => PCLK = 72MHz
  157. */
  158. static const SMI_REGS init_regs_1024x768 [] =
  159. {
  160. {0x00004, SWAP32(0x00000000)},
  161. /* clocks for pm1... */
  162. {0x00048, SWAP32(0x00021807)},
  163. {0x0004C, SWAP32(0x011a0a01)},
  164. {0x00054, SWAP32(0x00000001)},
  165. /* clocks for pm0... */
  166. {0x00040, SWAP32(0x00021807)},
  167. {0x00044, SWAP32(0x011a0a01)},
  168. {0x00054, SWAP32(0x00000000)},
  169. /* panel control regs... */
  170. {0x80000, SWAP32(0x0f013106)}, /* panel display control: 32-bit RGB 8:8:8 mode */
  171. {0x80004, SWAP32(0xc428bb17)}, /* panel panning control ??? */
  172. {0x8000C, SWAP32(0x00000000)}, /* panel fb address */
  173. {0x80010, SWAP32(0x10001000)}, /* panel fb offset/window width */
  174. {0x80014, SWAP32(0x04000000)}, /* panel fb width (0x400=1024) */
  175. {0x80018, SWAP32(0x03000000)}, /* panel fb height (0x300=768) */
  176. {0x8001C, SWAP32(0x00000000)}, /* panel plane tl location */
  177. {0x80020, SWAP32(0x03000400)}, /* panel plane br location */
  178. {0x80024, SWAP32(0x053f03ff)}, /* panel horizontal total */
  179. {0x80028, SWAP32(0x0140040f)}, /* panel horizontal sync */
  180. {0x8002C, SWAP32(0x032502ff)}, /* panel vertical total */
  181. {0x80030, SWAP32(0x00260301)}, /* panel vertical sync */
  182. {0x80200, SWAP32(0x00010000)}, /* crt display control */
  183. {0, 0}
  184. };
  185. #endif /* CONFIG_VIDEO_SM501_32BPP */
  186. #endif /* CONFIG_VIDEO_SM501 */
  187. #if 0
  188. #define FPGA_DEBUG
  189. #endif
  190. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  191. extern void lxt971_no_sleep(void);
  192. /* fpga configuration data - gzip compressed and generated by bin2c */
  193. const unsigned char fpgadata[] =
  194. {
  195. #include "fpgadata.c"
  196. };
  197. /*
  198. * include common fpga code (for esd boards)
  199. */
  200. #include "../common/fpga.c"
  201. /* Prototypes */
  202. int gunzip(void *, int, unsigned char *, unsigned long *);
  203. /* logo bitmap data - gzip compressed and generated by bin2c */
  204. unsigned char logo_bmp_320[] =
  205. {
  206. #include "logo_320_240_4bpp.c"
  207. };
  208. unsigned char logo_bmp_320_8bpp[] =
  209. {
  210. #include "logo_320_240_8bpp.c"
  211. };
  212. unsigned char logo_bmp_640[] =
  213. {
  214. #include "logo_640_480_24bpp.c"
  215. };
  216. unsigned char logo_bmp_1024[] =
  217. {
  218. #include "logo_1024_768_8bpp.c"
  219. };
  220. /*
  221. * include common lcd code (for esd boards)
  222. */
  223. #include "../common/lcd.c"
  224. #include "../common/s1d13704_320_240_4bpp.h"
  225. #include "../common/s1d13705_320_240_8bpp.h"
  226. #include "../common/s1d13806_640_480_16bpp.h"
  227. #include "../common/s1d13806_1024_768_8bpp.h"
  228. /*
  229. * include common auto-update code (for esd boards)
  230. */
  231. #include "../common/auto_update.h"
  232. au_image_t au_image[] = {
  233. {"hh405/preinst.img", 0, -1, AU_SCRIPT},
  234. {"hh405/u-boot.img", 0xfff80000, 0x00080000, AU_FIRMWARE},
  235. {"hh405/pImage_$(bd_type)", 0x00000000, 0x00100000, AU_NAND},
  236. {"hh405/pImage.initrd", 0x00100000, 0x00200000, AU_NAND},
  237. {"hh405/yaffsmt2.img", 0x00300000, 0x01c00000, AU_NAND},
  238. {"hh405/postinst.img", 0, 0, AU_SCRIPT},
  239. };
  240. int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
  241. int board_revision(void)
  242. {
  243. unsigned long osrh_reg;
  244. unsigned long isr1h_reg;
  245. unsigned long tcr_reg;
  246. unsigned long value;
  247. /*
  248. * Get version of HH405 board from GPIO's
  249. */
  250. /*
  251. * Setup GPIO pins (BLAST/GPIO0 and GPIO9 as GPIO)
  252. */
  253. osrh_reg = in32(GPIO0_OSRH);
  254. isr1h_reg = in32(GPIO0_ISR1H);
  255. tcr_reg = in32(GPIO0_TCR);
  256. out32(GPIO0_OSRH, osrh_reg & ~0xC0003000); /* output select */
  257. out32(GPIO0_ISR1H, isr1h_reg | 0xC0003000); /* input select */
  258. out32(GPIO0_TCR, tcr_reg & ~0x80400000); /* select input */
  259. udelay(1000); /* wait some time before reading input */
  260. value = in32(GPIO0_IR) & 0x80400000; /* get config bits */
  261. /*
  262. * Restore GPIO settings
  263. */
  264. out32(GPIO0_OSRH, osrh_reg); /* output select */
  265. out32(GPIO0_ISR1H, isr1h_reg); /* input select */
  266. out32(GPIO0_TCR, tcr_reg); /* enable output driver for outputs */
  267. if (value & 0x80000000) {
  268. /* Revision 1.0 or 1.1 detected */
  269. return 0x0101;
  270. } else {
  271. if (value & 0x00400000) {
  272. /* unused */
  273. return 0x0103;
  274. } else {
  275. /* Revision >= 2.0 detected */
  276. /* rev. 2.x uses four SM501 GPIOs for revision coding */
  277. return 0x0200;
  278. }
  279. }
  280. }
  281. int board_early_init_f (void)
  282. {
  283. /*
  284. * IRQ 0-15 405GP internally generated; active high; level sensitive
  285. * IRQ 16 405GP internally generated; active low; level sensitive
  286. * IRQ 17-24 RESERVED
  287. * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
  288. * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
  289. * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
  290. * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
  291. * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
  292. * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
  293. * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
  294. */
  295. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  296. mtdcr(uicer, 0x00000000); /* disable all ints */
  297. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  298. mtdcr(uicpr, CFG_UIC0_POLARITY);/* set int polarities */
  299. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  300. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  301. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  302. /*
  303. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  304. */
  305. mtebc (epcr, 0xa8400000); /* ebc always driven */
  306. return 0;
  307. }
  308. int misc_init_r (void)
  309. {
  310. DECLARE_GLOBAL_DATA_PTR;
  311. volatile unsigned short *fpga_ctrl =
  312. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
  313. volatile unsigned short *lcd_contrast =
  314. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL + 4);
  315. volatile unsigned short *lcd_backlight =
  316. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL + 6);
  317. unsigned char *dst;
  318. ulong len = sizeof(fpgadata);
  319. int status;
  320. int index;
  321. int i;
  322. char *str;
  323. unsigned long contrast0 = 0xffffffff;
  324. dst = malloc(CFG_FPGA_MAX_SIZE);
  325. if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
  326. printf ("GUNZIP ERROR - must RESET board to recover\n");
  327. do_reset (NULL, 0, 0, NULL);
  328. }
  329. status = fpga_boot(dst, len);
  330. if (status != 0) {
  331. printf("\nFPGA: Booting failed ");
  332. switch (status) {
  333. case ERROR_FPGA_PRG_INIT_LOW:
  334. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  335. break;
  336. case ERROR_FPGA_PRG_INIT_HIGH:
  337. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  338. break;
  339. case ERROR_FPGA_PRG_DONE:
  340. printf("(Timeout: DONE not high after programming FPGA)\n ");
  341. break;
  342. }
  343. /* display infos on fpgaimage */
  344. index = 15;
  345. for (i=0; i<4; i++) {
  346. len = dst[index];
  347. printf("FPGA: %s\n", &(dst[index+1]));
  348. index += len+3;
  349. }
  350. putc ('\n');
  351. /* delayed reboot */
  352. for (i=20; i>0; i--) {
  353. printf("Rebooting in %2d seconds \r",i);
  354. for (index=0;index<1000;index++)
  355. udelay(1000);
  356. }
  357. putc ('\n');
  358. do_reset(NULL, 0, 0, NULL);
  359. }
  360. puts("FPGA: ");
  361. /* display infos on fpgaimage */
  362. index = 15;
  363. for (i=0; i<4; i++) {
  364. len = dst[index];
  365. printf("%s ", &(dst[index+1]));
  366. index += len+3;
  367. }
  368. putc ('\n');
  369. free(dst);
  370. /*
  371. * Reset FPGA via FPGA_INIT pin
  372. */
  373. out32(GPIO0_TCR, in32(GPIO0_TCR) | FPGA_INIT); /* setup FPGA_INIT as output */
  374. out32(GPIO0_OR, in32(GPIO0_OR) & ~FPGA_INIT); /* reset low */
  375. udelay(1000); /* wait 1ms */
  376. out32(GPIO0_OR, in32(GPIO0_OR) | FPGA_INIT); /* reset high */
  377. udelay(1000); /* wait 1ms */
  378. /*
  379. * Write Board revision into FPGA
  380. */
  381. *fpga_ctrl |= gd->board_type & 0x0003;
  382. if (gd->board_type >= 0x0200) {
  383. *fpga_ctrl |= CFG_FPGA_CTRL_CF_BUS_EN;
  384. }
  385. /*
  386. * Setup and enable EEPROM write protection
  387. */
  388. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
  389. /*
  390. * Set NAND-FLASH GPIO signals to default
  391. */
  392. out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
  393. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
  394. /*
  395. * Reset touch-screen controller
  396. */
  397. out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_TOUCH_RST);
  398. udelay(1000);
  399. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_TOUCH_RST);
  400. /*
  401. * Enable power on PS/2 interface (with reset)
  402. */
  403. *fpga_ctrl &= ~(CFG_FPGA_CTRL_PS2_PWR);
  404. for (i=0;i<500;i++)
  405. udelay(1000);
  406. *fpga_ctrl |= (CFG_FPGA_CTRL_PS2_PWR);
  407. /*
  408. * Get contrast value from environment variable
  409. */
  410. str = getenv("contrast0");
  411. if (str) {
  412. contrast0 = simple_strtol(str, NULL, 16);
  413. if (contrast0 > 255) {
  414. printf("ERROR: contrast0 value too high (0x%lx)!\n", contrast0);
  415. contrast0 = 0;
  416. }
  417. }
  418. /*
  419. * Init lcd interface and display logo
  420. */
  421. str = getenv("bd_type");
  422. if (strcmp(str, "ppc230") == 0) {
  423. /*
  424. * Switch backlight on
  425. */
  426. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL;
  427. *lcd_backlight = 0x0000;
  428. lcd_setup(1, 0);
  429. lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
  430. regs_13806_1024_768_8bpp,
  431. sizeof(regs_13806_1024_768_8bpp)/sizeof(regs_13806_1024_768_8bpp[0]),
  432. logo_bmp_1024, sizeof(logo_bmp_1024));
  433. } else if (strcmp(str, "ppc220") == 0) {
  434. /*
  435. * Switch backlight on
  436. */
  437. *fpga_ctrl &= ~CFG_FPGA_CTRL_VGA0_BL;
  438. *lcd_backlight = 0x0000;
  439. lcd_setup(1, 0);
  440. lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
  441. regs_13806_640_480_16bpp,
  442. sizeof(regs_13806_640_480_16bpp)/sizeof(regs_13806_640_480_16bpp[0]),
  443. logo_bmp_640, sizeof(logo_bmp_640));
  444. } else if (strcmp(str, "ppc215") == 0) {
  445. /*
  446. * Set default display contrast voltage
  447. */
  448. if (contrast0 == 0xffffffff) {
  449. *lcd_contrast = 0x0082;
  450. } else {
  451. *lcd_contrast = contrast0;
  452. }
  453. *lcd_backlight = 0xffff;
  454. /*
  455. * Switch backlight on
  456. */
  457. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
  458. /*
  459. * Set lcd clock (small epson)
  460. */
  461. *fpga_ctrl |= LCD_CLK_06250;
  462. udelay(100); /* wait for 100 us */
  463. lcd_setup(0, 1);
  464. lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
  465. regs_13705_320_240_8bpp,
  466. sizeof(regs_13705_320_240_8bpp)/sizeof(regs_13705_320_240_8bpp[0]),
  467. logo_bmp_320_8bpp, sizeof(logo_bmp_320_8bpp));
  468. } else if (strcmp(str, "ppc210") == 0) {
  469. /*
  470. * Set default display contrast voltage
  471. */
  472. if (contrast0 == 0xffffffff) {
  473. *lcd_contrast = 0x0060;
  474. } else {
  475. *lcd_contrast = contrast0;
  476. }
  477. *lcd_backlight = 0xffff;
  478. /*
  479. * Switch backlight on
  480. */
  481. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
  482. /*
  483. * Set lcd clock (small epson)
  484. */
  485. *fpga_ctrl |= LCD_CLK_08330;
  486. lcd_setup(0, 1);
  487. lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
  488. regs_13704_320_240_4bpp,
  489. sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
  490. logo_bmp_320, sizeof(logo_bmp_320));
  491. #ifdef CONFIG_VIDEO_SM501
  492. } else {
  493. pci_dev_t devbusfn;
  494. /*
  495. * Is SM501 connected (ppc221/ppc231)?
  496. */
  497. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  498. if (devbusfn != -1) {
  499. puts("VGA: SM501 with 8 MB ");
  500. if (strcmp(str, "ppc221") == 0) {
  501. printf("(800*600, %dbpp)\n", BPP);
  502. } else if (strcmp(str, "ppc231") == 0) {
  503. printf("(1024*768, %dbpp)\n", BPP);
  504. } else {
  505. printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
  506. return 0;
  507. }
  508. } else {
  509. printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
  510. return 0;
  511. }
  512. #endif /* CONFIG_VIDEO_SM501 */
  513. }
  514. return (0);
  515. }
  516. /*
  517. * Check Board Identity:
  518. */
  519. int checkboard (void)
  520. {
  521. DECLARE_GLOBAL_DATA_PTR;
  522. unsigned char str[64];
  523. int i = getenv_r ("serial#", str, sizeof(str));
  524. puts ("Board: ");
  525. if (i == -1) {
  526. puts ("### No HW ID - assuming HH405");
  527. } else {
  528. puts(str);
  529. }
  530. if (getenv_r("bd_type", str, sizeof(str)) != -1) {
  531. printf(" (%s", str);
  532. } else {
  533. puts(" (Missing bd_type!");
  534. }
  535. gd->board_type = board_revision();
  536. printf(", Rev %ld.%ld)\n",
  537. (gd->board_type >> 8) & 0xff,
  538. gd->board_type & 0xff);
  539. /*
  540. * Disable sleep mode in LXT971
  541. */
  542. lxt971_no_sleep();
  543. return 0;
  544. }
  545. long int initdram (int board_type)
  546. {
  547. unsigned long val;
  548. mtdcr(memcfga, mem_mb0cf);
  549. val = mfdcr(memcfgd);
  550. #if 0
  551. printf("\nmb0cf=%x\n", val); /* test-only */
  552. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  553. #endif
  554. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  555. }
  556. int testdram (void)
  557. {
  558. /* TODO: XXX XXX XXX */
  559. printf ("test: 16 MB - ok\n");
  560. return (0);
  561. }
  562. #ifdef CONFIG_IDE_RESET
  563. void ide_set_reset(int on)
  564. {
  565. volatile unsigned short *fpga_mode =
  566. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
  567. /*
  568. * Assert or deassert CompactFlash Reset Pin
  569. */
  570. if (on) { /* assert RESET */
  571. *fpga_mode &= ~(CFG_FPGA_CTRL_CF_RESET);
  572. } else { /* release RESET */
  573. *fpga_mode |= CFG_FPGA_CTRL_CF_RESET;
  574. }
  575. }
  576. #endif /* CONFIG_IDE_RESET */
  577. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  578. #include <linux/mtd/nand.h>
  579. extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
  580. void nand_init(void)
  581. {
  582. nand_probe(CFG_NAND_BASE);
  583. if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
  584. print_size(nand_dev_desc[0].totlen, "\n");
  585. }
  586. }
  587. #endif
  588. #if defined(CFG_EEPROM_WREN)
  589. /* Input: <dev_addr> I2C address of EEPROM device to enable.
  590. * <state> -1: deliver current state
  591. * 0: disable write
  592. * 1: enable write
  593. * Returns: -1: wrong device address
  594. * 0: dis-/en- able done
  595. * 0/1: current state if <state> was -1.
  596. */
  597. int eeprom_write_enable (unsigned dev_addr, int state)
  598. {
  599. if (CFG_I2C_EEPROM_ADDR != dev_addr) {
  600. return -1;
  601. } else {
  602. switch (state) {
  603. case 1:
  604. /* Enable write access, clear bit GPIO_SINT2. */
  605. out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_EEPROM_WP);
  606. state = 0;
  607. break;
  608. case 0:
  609. /* Disable write access, set bit GPIO_SINT2. */
  610. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
  611. state = 0;
  612. break;
  613. default:
  614. /* Read current status back. */
  615. state = (0 == (in32(GPIO0_OR) & CFG_EEPROM_WP));
  616. break;
  617. }
  618. }
  619. return state;
  620. }
  621. int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  622. {
  623. int query = argc == 1;
  624. int state = 0;
  625. if (query) {
  626. /* Query write access state. */
  627. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, -1);
  628. if (state < 0) {
  629. puts ("Query of write access state failed.\n");
  630. } else {
  631. printf ("Write access for device 0x%0x is %sabled.\n",
  632. CFG_I2C_EEPROM_ADDR, state ? "en" : "dis");
  633. state = 0;
  634. }
  635. } else {
  636. if ('0' == argv[1][0]) {
  637. /* Disable write access. */
  638. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 0);
  639. } else {
  640. /* Enable write access. */
  641. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 1);
  642. }
  643. if (state < 0) {
  644. puts ("Setup of write access state failed.\n");
  645. }
  646. }
  647. return state;
  648. }
  649. U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
  650. "eepwren - Enable / disable / query EEPROM write access\n",
  651. NULL);
  652. #endif /* #if defined(CFG_EEPROM_WREN) */
  653. #ifdef CONFIG_VIDEO_SM501
  654. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  655. /*
  656. * Return text to be printed besides the logo.
  657. */
  658. void video_get_info_str (int line_number, char *info)
  659. {
  660. DECLARE_GLOBAL_DATA_PTR;
  661. char str[64];
  662. char str2[64];
  663. int i = getenv_r("serial#", str2, sizeof(str));
  664. if (line_number == 1) {
  665. sprintf(str, " Board: ");
  666. if (i == -1) {
  667. strcat(str, "### No HW ID - assuming HH405");
  668. } else {
  669. strcat(str, str2);
  670. }
  671. if (getenv_r("bd_type", str2, sizeof(str2)) != -1) {
  672. strcat(str, " (");
  673. strcat(str, str2);
  674. } else {
  675. strcat(str, " (Missing bd_type!");
  676. }
  677. sprintf(str2, ", Rev %ld.%ld)",
  678. (gd->board_type >> 8) & 0xff, gd->board_type & 0xff);
  679. strcat(str, str2);
  680. strcpy(info, str);
  681. } else {
  682. info [0] = '\0';
  683. }
  684. }
  685. #endif /* CONFIG_CONSOLE_EXTRA_INFO */
  686. /*
  687. * Returns SM501 register base address. First thing called in the driver.
  688. */
  689. unsigned int board_video_init (void)
  690. {
  691. pci_dev_t devbusfn;
  692. u32 addr;
  693. /*
  694. * Is SM501 connected (ppc221/ppc231)?
  695. */
  696. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  697. if (devbusfn != -1) {
  698. pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, (u32 *)&addr);
  699. return (addr & 0xfffffffe);
  700. }
  701. return 0;
  702. }
  703. /*
  704. * Returns SM501 framebuffer address
  705. */
  706. unsigned int board_video_get_fb (void)
  707. {
  708. pci_dev_t devbusfn;
  709. u32 addr;
  710. /*
  711. * Is SM501 connected (ppc221/ppc231)?
  712. */
  713. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  714. if (devbusfn != -1) {
  715. pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, (u32 *)&addr);
  716. return (addr & 0xfffffffe);
  717. }
  718. return 0;
  719. }
  720. /*
  721. * Called after initializing the SM501 and before clearing the screen.
  722. */
  723. void board_validate_screen (unsigned int base)
  724. {
  725. }
  726. /*
  727. * Return a pointer to the initialization sequence.
  728. */
  729. const SMI_REGS *board_get_regs (void)
  730. {
  731. char *str;
  732. str = getenv("bd_type");
  733. if (strcmp(str, "ppc221") == 0) {
  734. return init_regs_800x600;
  735. } else {
  736. return init_regs_1024x768;
  737. }
  738. }
  739. int board_get_width (void)
  740. {
  741. char *str;
  742. str = getenv("bd_type");
  743. if (strcmp(str, "ppc221") == 0) {
  744. return 800;
  745. } else {
  746. return 1024;
  747. }
  748. }
  749. int board_get_height (void)
  750. {
  751. char *str;
  752. str = getenv("bd_type");
  753. if (strcmp(str, "ppc221") == 0) {
  754. return 600;
  755. } else {
  756. return 768;
  757. }
  758. }
  759. #endif /* CONFIG_VIDEO_SM501 */