hh405.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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. pci_dev_t devbusfn;
  325. dst = malloc(CFG_FPGA_MAX_SIZE);
  326. if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
  327. printf ("GUNZIP ERROR - must RESET board to recover\n");
  328. do_reset (NULL, 0, 0, NULL);
  329. }
  330. status = fpga_boot(dst, len);
  331. if (status != 0) {
  332. printf("\nFPGA: Booting failed ");
  333. switch (status) {
  334. case ERROR_FPGA_PRG_INIT_LOW:
  335. printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
  336. break;
  337. case ERROR_FPGA_PRG_INIT_HIGH:
  338. printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
  339. break;
  340. case ERROR_FPGA_PRG_DONE:
  341. printf("(Timeout: DONE not high after programming FPGA)\n ");
  342. break;
  343. }
  344. /* display infos on fpgaimage */
  345. index = 15;
  346. for (i=0; i<4; i++) {
  347. len = dst[index];
  348. printf("FPGA: %s\n", &(dst[index+1]));
  349. index += len+3;
  350. }
  351. putc ('\n');
  352. /* delayed reboot */
  353. for (i=20; i>0; i--) {
  354. printf("Rebooting in %2d seconds \r",i);
  355. for (index=0;index<1000;index++)
  356. udelay(1000);
  357. }
  358. putc ('\n');
  359. do_reset(NULL, 0, 0, NULL);
  360. }
  361. puts("FPGA: ");
  362. /* display infos on fpgaimage */
  363. index = 15;
  364. for (i=0; i<4; i++) {
  365. len = dst[index];
  366. printf("%s ", &(dst[index+1]));
  367. index += len+3;
  368. }
  369. putc ('\n');
  370. free(dst);
  371. /*
  372. * Reset FPGA via FPGA_INIT pin
  373. */
  374. out32(GPIO0_TCR, in32(GPIO0_TCR) | FPGA_INIT); /* setup FPGA_INIT as output */
  375. out32(GPIO0_OR, in32(GPIO0_OR) & ~FPGA_INIT); /* reset low */
  376. udelay(1000); /* wait 1ms */
  377. out32(GPIO0_OR, in32(GPIO0_OR) | FPGA_INIT); /* reset high */
  378. udelay(1000); /* wait 1ms */
  379. /*
  380. * Write Board revision into FPGA
  381. */
  382. *fpga_ctrl |= gd->board_type & 0x0003;
  383. if (gd->board_type >= 0x0200) {
  384. *fpga_ctrl |= CFG_FPGA_CTRL_CF_BUS_EN;
  385. }
  386. /*
  387. * Setup and enable EEPROM write protection
  388. */
  389. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
  390. /*
  391. * Set NAND-FLASH GPIO signals to default
  392. */
  393. out32(GPIO0_OR, in32(GPIO0_OR) & ~(CFG_NAND_CLE | CFG_NAND_ALE));
  394. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_NAND_CE);
  395. /*
  396. * Reset touch-screen controller
  397. */
  398. out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_TOUCH_RST);
  399. udelay(1000);
  400. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_TOUCH_RST);
  401. /*
  402. * Enable power on PS/2 interface (with reset)
  403. */
  404. *fpga_ctrl &= ~(CFG_FPGA_CTRL_PS2_PWR);
  405. for (i=0;i<500;i++)
  406. udelay(1000);
  407. *fpga_ctrl |= (CFG_FPGA_CTRL_PS2_PWR);
  408. /*
  409. * Get contrast value from environment variable
  410. */
  411. str = getenv("contrast0");
  412. if (str) {
  413. contrast0 = simple_strtol(str, NULL, 16);
  414. if (contrast0 > 255) {
  415. printf("ERROR: contrast0 value too high (0x%lx)!\n", contrast0);
  416. contrast0 = 0;
  417. }
  418. }
  419. /*
  420. * Init lcd interface and display logo
  421. */
  422. str = getenv("bd_type");
  423. if (strcmp(str, "ppc230") == 0) {
  424. /*
  425. * Switch backlight on
  426. */
  427. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL;
  428. *lcd_backlight = 0x0000;
  429. lcd_setup(1, 0);
  430. lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
  431. regs_13806_1024_768_8bpp,
  432. sizeof(regs_13806_1024_768_8bpp)/sizeof(regs_13806_1024_768_8bpp[0]),
  433. logo_bmp_1024, sizeof(logo_bmp_1024));
  434. } else if (strcmp(str, "ppc220") == 0) {
  435. /*
  436. * Switch backlight on
  437. */
  438. *fpga_ctrl &= ~CFG_FPGA_CTRL_VGA0_BL;
  439. *lcd_backlight = 0x0000;
  440. lcd_setup(1, 0);
  441. lcd_init((uchar *)CFG_LCD_BIG_REG, (uchar *)CFG_LCD_BIG_MEM,
  442. regs_13806_640_480_16bpp,
  443. sizeof(regs_13806_640_480_16bpp)/sizeof(regs_13806_640_480_16bpp[0]),
  444. logo_bmp_640, sizeof(logo_bmp_640));
  445. } else if (strcmp(str, "ppc215") == 0) {
  446. /*
  447. * Set default display contrast voltage
  448. */
  449. if (contrast0 == 0xffffffff) {
  450. *lcd_contrast = 0x0082;
  451. } else {
  452. *lcd_contrast = contrast0;
  453. }
  454. *lcd_backlight = 0xffff;
  455. /*
  456. * Switch backlight on
  457. */
  458. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
  459. /*
  460. * Set lcd clock (small epson)
  461. */
  462. *fpga_ctrl |= LCD_CLK_06250;
  463. udelay(100); /* wait for 100 us */
  464. lcd_setup(0, 1);
  465. lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
  466. regs_13705_320_240_8bpp,
  467. sizeof(regs_13705_320_240_8bpp)/sizeof(regs_13705_320_240_8bpp[0]),
  468. logo_bmp_320_8bpp, sizeof(logo_bmp_320_8bpp));
  469. } else if (strcmp(str, "ppc210") == 0) {
  470. /*
  471. * Set default display contrast voltage
  472. */
  473. if (contrast0 == 0xffffffff) {
  474. *lcd_contrast = 0x0060;
  475. } else {
  476. *lcd_contrast = contrast0;
  477. }
  478. *lcd_backlight = 0xffff;
  479. /*
  480. * Switch backlight on
  481. */
  482. *fpga_ctrl |= CFG_FPGA_CTRL_VGA0_BL | CFG_FPGA_CTRL_VGA0_BL_MODE;
  483. /*
  484. * Set lcd clock (small epson)
  485. */
  486. *fpga_ctrl |= LCD_CLK_08330;
  487. lcd_setup(0, 1);
  488. lcd_init((uchar *)CFG_LCD_SMALL_REG, (uchar *)CFG_LCD_SMALL_MEM,
  489. regs_13704_320_240_4bpp,
  490. sizeof(regs_13704_320_240_4bpp)/sizeof(regs_13704_320_240_4bpp[0]),
  491. logo_bmp_320, sizeof(logo_bmp_320));
  492. } else {
  493. /*
  494. * Is SM501 connected (ppc221/ppc231)?
  495. */
  496. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  497. if (devbusfn != -1) {
  498. puts("VGA: SM501 with 8 MB ");
  499. if (strcmp(str, "ppc221") == 0) {
  500. printf("(800*600, %dbpp)\n", BPP);
  501. } else if (strcmp(str, "ppc231") == 0) {
  502. printf("(1024*768, %dbpp)\n", BPP);
  503. } else {
  504. printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
  505. return 0;
  506. }
  507. } else {
  508. printf("Unsupported bd_type defined (%s) -> No display configured!\n", str);
  509. return 0;
  510. }
  511. }
  512. return (0);
  513. }
  514. /*
  515. * Check Board Identity:
  516. */
  517. int checkboard (void)
  518. {
  519. DECLARE_GLOBAL_DATA_PTR;
  520. unsigned char str[64];
  521. int i = getenv_r ("serial#", str, sizeof(str));
  522. puts ("Board: ");
  523. if (i == -1) {
  524. puts ("### No HW ID - assuming HH405");
  525. } else {
  526. puts(str);
  527. }
  528. if (getenv_r("bd_type", str, sizeof(str)) != -1) {
  529. printf(" (%s", str);
  530. } else {
  531. puts(" (Missing bd_type!");
  532. }
  533. gd->board_type = board_revision();
  534. printf(", Rev %ld.%ld)\n",
  535. (gd->board_type >> 8) & 0xff,
  536. gd->board_type & 0xff);
  537. /*
  538. * Disable sleep mode in LXT971
  539. */
  540. lxt971_no_sleep();
  541. return 0;
  542. }
  543. long int initdram (int board_type)
  544. {
  545. unsigned long val;
  546. mtdcr(memcfga, mem_mb0cf);
  547. val = mfdcr(memcfgd);
  548. #if 0
  549. printf("\nmb0cf=%x\n", val); /* test-only */
  550. printf("strap=%x\n", mfdcr(strap)); /* test-only */
  551. #endif
  552. return (4*1024*1024 << ((val & 0x000e0000) >> 17));
  553. }
  554. int testdram (void)
  555. {
  556. /* TODO: XXX XXX XXX */
  557. printf ("test: 16 MB - ok\n");
  558. return (0);
  559. }
  560. #ifdef CONFIG_IDE_RESET
  561. void ide_set_reset(int on)
  562. {
  563. volatile unsigned short *fpga_mode =
  564. (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
  565. /*
  566. * Assert or deassert CompactFlash Reset Pin
  567. */
  568. if (on) { /* assert RESET */
  569. *fpga_mode &= ~(CFG_FPGA_CTRL_CF_RESET);
  570. } else { /* release RESET */
  571. *fpga_mode |= CFG_FPGA_CTRL_CF_RESET;
  572. }
  573. }
  574. #endif /* CONFIG_IDE_RESET */
  575. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  576. #include <linux/mtd/nand.h>
  577. extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
  578. void nand_init(void)
  579. {
  580. nand_probe(CFG_NAND_BASE);
  581. if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
  582. print_size(nand_dev_desc[0].totlen, "\n");
  583. }
  584. }
  585. #endif
  586. #if defined(CFG_EEPROM_WREN)
  587. /* Input: <dev_addr> I2C address of EEPROM device to enable.
  588. * <state> -1: deliver current state
  589. * 0: disable write
  590. * 1: enable write
  591. * Returns: -1: wrong device address
  592. * 0: dis-/en- able done
  593. * 0/1: current state if <state> was -1.
  594. */
  595. int eeprom_write_enable (unsigned dev_addr, int state)
  596. {
  597. if (CFG_I2C_EEPROM_ADDR != dev_addr) {
  598. return -1;
  599. } else {
  600. switch (state) {
  601. case 1:
  602. /* Enable write access, clear bit GPIO_SINT2. */
  603. out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_EEPROM_WP);
  604. state = 0;
  605. break;
  606. case 0:
  607. /* Disable write access, set bit GPIO_SINT2. */
  608. out32(GPIO0_OR, in32(GPIO0_OR) | CFG_EEPROM_WP);
  609. state = 0;
  610. break;
  611. default:
  612. /* Read current status back. */
  613. state = (0 == (in32(GPIO0_OR) & CFG_EEPROM_WP));
  614. break;
  615. }
  616. }
  617. return state;
  618. }
  619. int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  620. {
  621. int query = argc == 1;
  622. int state = 0;
  623. if (query) {
  624. /* Query write access state. */
  625. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, -1);
  626. if (state < 0) {
  627. puts ("Query of write access state failed.\n");
  628. } else {
  629. printf ("Write access for device 0x%0x is %sabled.\n",
  630. CFG_I2C_EEPROM_ADDR, state ? "en" : "dis");
  631. state = 0;
  632. }
  633. } else {
  634. if ('0' == argv[1][0]) {
  635. /* Disable write access. */
  636. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 0);
  637. } else {
  638. /* Enable write access. */
  639. state = eeprom_write_enable (CFG_I2C_EEPROM_ADDR, 1);
  640. }
  641. if (state < 0) {
  642. puts ("Setup of write access state failed.\n");
  643. }
  644. }
  645. return state;
  646. }
  647. U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
  648. "eepwren - Enable / disable / query EEPROM write access\n",
  649. NULL);
  650. #endif /* #if defined(CFG_EEPROM_WREN) */
  651. #ifdef CONFIG_VIDEO_SM501
  652. #ifdef CONFIG_CONSOLE_EXTRA_INFO
  653. /*
  654. * Return text to be printed besides the logo.
  655. */
  656. void video_get_info_str (int line_number, char *info)
  657. {
  658. DECLARE_GLOBAL_DATA_PTR;
  659. char str[64];
  660. char str2[64];
  661. int i = getenv_r("serial#", str2, sizeof(str));
  662. if (line_number == 1) {
  663. sprintf(str, " Board: ");
  664. if (i == -1) {
  665. strcat(str, "### No HW ID - assuming HH405");
  666. } else {
  667. strcat(str, str2);
  668. }
  669. if (getenv_r("bd_type", str2, sizeof(str2)) != -1) {
  670. strcat(str, " (");
  671. strcat(str, str2);
  672. } else {
  673. strcat(str, " (Missing bd_type!");
  674. }
  675. sprintf(str2, ", Rev %ld.%ld)",
  676. (gd->board_type >> 8) & 0xff, gd->board_type & 0xff);
  677. strcat(str, str2);
  678. strcpy(info, str);
  679. } else {
  680. info [0] = '\0';
  681. }
  682. }
  683. #endif /* CONFIG_CONSOLE_EXTRA_INFO */
  684. /*
  685. * Returns SM501 register base address. First thing called in the driver.
  686. */
  687. unsigned int board_video_init (void)
  688. {
  689. pci_dev_t devbusfn;
  690. u32 addr;
  691. /*
  692. * Is SM501 connected (ppc221/ppc231)?
  693. */
  694. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  695. if (devbusfn != -1) {
  696. pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, (u32 *)&addr);
  697. return (addr & 0xfffffffe);
  698. }
  699. return 0;
  700. }
  701. /*
  702. * Returns SM501 framebuffer address
  703. */
  704. unsigned int board_video_get_fb (void)
  705. {
  706. pci_dev_t devbusfn;
  707. u32 addr;
  708. /*
  709. * Is SM501 connected (ppc221/ppc231)?
  710. */
  711. devbusfn = pci_find_device(PCI_VENDOR_SM, PCI_DEVICE_SM501, 0);
  712. if (devbusfn != -1) {
  713. pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, (u32 *)&addr);
  714. return (addr & 0xfffffffe);
  715. }
  716. return 0;
  717. }
  718. /*
  719. * Called after initializing the SM501 and before clearing the screen.
  720. */
  721. void board_validate_screen (unsigned int base)
  722. {
  723. }
  724. /*
  725. * Return a pointer to the initialization sequence.
  726. */
  727. const SMI_REGS *board_get_regs (void)
  728. {
  729. char *str;
  730. str = getenv("bd_type");
  731. if (strcmp(str, "ppc221") == 0) {
  732. return init_regs_800x600;
  733. } else {
  734. return init_regs_1024x768;
  735. }
  736. }
  737. int board_get_width (void)
  738. {
  739. char *str;
  740. str = getenv("bd_type");
  741. if (strcmp(str, "ppc221") == 0) {
  742. return 800;
  743. } else {
  744. return 1024;
  745. }
  746. }
  747. int board_get_height (void)
  748. {
  749. char *str;
  750. str = getenv("bd_type");
  751. if (strcmp(str, "ppc221") == 0) {
  752. return 600;
  753. } else {
  754. return 768;
  755. }
  756. }
  757. #endif /* CONFIG_VIDEO_SM501 */