zipitz2.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (C) 2009
  3. * Marek Vasut <marek.vasut@gmail.com>
  4. *
  5. * Heavily based on pxa255_idp platform
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <serial.h>
  12. #include <asm/arch/hardware.h>
  13. #include <asm/arch/pxa.h>
  14. #include <asm/arch/regs-mmc.h>
  15. #include <spi.h>
  16. #include <asm/io.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #ifdef CONFIG_CMD_SPI
  19. void lcd_start(void);
  20. #else
  21. inline void lcd_start(void) {};
  22. #endif
  23. /*
  24. * Miscelaneous platform dependent initialisations
  25. */
  26. int board_init (void)
  27. {
  28. /* We have RAM, disable cache */
  29. dcache_disable();
  30. icache_disable();
  31. /* arch number of Z2 */
  32. gd->bd->bi_arch_number = MACH_TYPE_ZIPIT2;
  33. /* adress of boot parameters */
  34. gd->bd->bi_boot_params = 0xa0000100;
  35. /* Enable LCD */
  36. lcd_start();
  37. return 0;
  38. }
  39. int dram_init(void)
  40. {
  41. pxa2xx_dram_init();
  42. gd->ram_size = PHYS_SDRAM_1_SIZE;
  43. return 0;
  44. }
  45. void dram_init_banksize(void)
  46. {
  47. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  48. gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
  49. }
  50. #ifdef CONFIG_CMD_MMC
  51. int board_mmc_init(bd_t *bis)
  52. {
  53. pxa_mmc_register(0);
  54. return 0;
  55. }
  56. #endif
  57. #ifdef CONFIG_CMD_SPI
  58. struct {
  59. unsigned char reg;
  60. unsigned short data;
  61. unsigned char mdelay;
  62. } lcd_data[] = {
  63. { 0x07, 0x0000, 0 },
  64. { 0x13, 0x0000, 10 },
  65. { 0x11, 0x3004, 0 },
  66. { 0x14, 0x200F, 0 },
  67. { 0x10, 0x1a20, 0 },
  68. { 0x13, 0x0040, 50 },
  69. { 0x13, 0x0060, 0 },
  70. { 0x13, 0x0070, 200 },
  71. { 0x01, 0x0127, 0 },
  72. { 0x02, 0x0700, 0 },
  73. { 0x03, 0x1030, 0 },
  74. { 0x08, 0x0208, 0 },
  75. { 0x0B, 0x0620, 0 },
  76. { 0x0C, 0x0110, 0 },
  77. { 0x30, 0x0120, 0 },
  78. { 0x31, 0x0127, 0 },
  79. { 0x32, 0x0000, 0 },
  80. { 0x33, 0x0503, 0 },
  81. { 0x34, 0x0727, 0 },
  82. { 0x35, 0x0124, 0 },
  83. { 0x36, 0x0706, 0 },
  84. { 0x37, 0x0701, 0 },
  85. { 0x38, 0x0F00, 0 },
  86. { 0x39, 0x0F00, 0 },
  87. { 0x40, 0x0000, 0 },
  88. { 0x41, 0x0000, 0 },
  89. { 0x42, 0x013f, 0 },
  90. { 0x43, 0x0000, 0 },
  91. { 0x44, 0x013f, 0 },
  92. { 0x45, 0x0000, 0 },
  93. { 0x46, 0xef00, 0 },
  94. { 0x47, 0x013f, 0 },
  95. { 0x48, 0x0000, 0 },
  96. { 0x07, 0x0015, 30 },
  97. { 0x07, 0x0017, 0 },
  98. { 0x20, 0x0000, 0 },
  99. { 0x21, 0x0000, 0 },
  100. { 0x22, 0x0000, 0 },
  101. };
  102. void zipitz2_spi_sda(int set)
  103. {
  104. /* GPIO 13 */
  105. if (set)
  106. writel((1 << 13), GPSR0);
  107. else
  108. writel((1 << 13), GPCR0);
  109. }
  110. void zipitz2_spi_scl(int set)
  111. {
  112. /* GPIO 22 */
  113. if (set)
  114. writel((1 << 22), GPCR0);
  115. else
  116. writel((1 << 22), GPSR0);
  117. }
  118. unsigned char zipitz2_spi_read(void)
  119. {
  120. /* GPIO 40 */
  121. return !!(readl(GPLR1) & (1 << 8));
  122. }
  123. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  124. {
  125. /* Always valid */
  126. return 1;
  127. }
  128. void spi_cs_activate(struct spi_slave *slave)
  129. {
  130. /* GPIO 88 low */
  131. writel((1 << 24), GPCR2);
  132. }
  133. void spi_cs_deactivate(struct spi_slave *slave)
  134. {
  135. /* GPIO 88 high */
  136. writel((1 << 24), GPSR2);
  137. }
  138. void lcd_start(void)
  139. {
  140. int i;
  141. unsigned char reg[3] = { 0x74, 0x00, 0 };
  142. unsigned char data[3] = { 0x76, 0, 0 };
  143. unsigned char dummy[3] = { 0, 0, 0 };
  144. /* PWM2 AF */
  145. writel(readl(GAFR0_L) | 0x00800000, GAFR0_L);
  146. /* Enable clock to all PWM */
  147. writel(readl(CKEN) | 0x3, CKEN);
  148. /* Configure PWM2 */
  149. writel(0x4f, PWM_CTRL2);
  150. writel(0x2ff, PWM_PWDUTY2);
  151. writel(792, PWM_PERVAL2);
  152. /* Toggle the reset pin to reset the LCD */
  153. writel((1 << 19), GPSR0);
  154. udelay(100000);
  155. writel((1 << 19), GPCR0);
  156. udelay(20000);
  157. writel((1 << 19), GPSR0);
  158. udelay(20000);
  159. /* Program the LCD init sequence */
  160. for (i = 0; i < sizeof(lcd_data) / sizeof(lcd_data[0]); i++) {
  161. reg[0] = 0x74;
  162. reg[1] = 0x0;
  163. reg[2] = lcd_data[i].reg;
  164. spi_xfer(NULL, 24, reg, dummy, SPI_XFER_BEGIN | SPI_XFER_END);
  165. data[0] = 0x76;
  166. data[1] = lcd_data[i].data >> 8;
  167. data[2] = lcd_data[i].data & 0xff;
  168. spi_xfer(NULL, 24, data, dummy, SPI_XFER_BEGIN | SPI_XFER_END);
  169. if (lcd_data[i].mdelay)
  170. udelay(lcd_data[i].mdelay * 1000);
  171. }
  172. writel((1 << 11), GPSR0);
  173. }
  174. #endif