zylonite_pxa320.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/zylonite_pxa320.c
  4. *
  5. * PXA320 specific support code for the
  6. * PXA3xx Development Platform (aka Zylonite)
  7. *
  8. * Copyright (C) 2007 Marvell Internation Ltd.
  9. * 2007-08-21: eric miao <[email protected]>
  10. * initial version
  11. */
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/gpio.h>
  16. #include <linux/soc/pxa/cpu.h>
  17. #include "pxa320.h"
  18. #include "zylonite.h"
  19. #include "generic.h"
  20. static mfp_cfg_t mfp_cfg[] __initdata = {
  21. /* LCD */
  22. GPIO6_2_LCD_LDD_0,
  23. GPIO7_2_LCD_LDD_1,
  24. GPIO8_2_LCD_LDD_2,
  25. GPIO9_2_LCD_LDD_3,
  26. GPIO10_2_LCD_LDD_4,
  27. GPIO11_2_LCD_LDD_5,
  28. GPIO12_2_LCD_LDD_6,
  29. GPIO13_2_LCD_LDD_7,
  30. GPIO63_LCD_LDD_8,
  31. GPIO64_LCD_LDD_9,
  32. GPIO65_LCD_LDD_10,
  33. GPIO66_LCD_LDD_11,
  34. GPIO67_LCD_LDD_12,
  35. GPIO68_LCD_LDD_13,
  36. GPIO69_LCD_LDD_14,
  37. GPIO70_LCD_LDD_15,
  38. GPIO71_LCD_LDD_16,
  39. GPIO72_LCD_LDD_17,
  40. GPIO73_LCD_CS_N,
  41. GPIO74_LCD_VSYNC,
  42. GPIO14_2_LCD_FCLK,
  43. GPIO15_2_LCD_LCLK,
  44. GPIO16_2_LCD_PCLK,
  45. GPIO17_2_LCD_BIAS,
  46. GPIO14_PWM3_OUT, /* backlight */
  47. /* FFUART */
  48. GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL,
  49. GPIO42_UART1_TXD,
  50. GPIO43_UART1_CTS,
  51. GPIO44_UART1_DCD,
  52. GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL,
  53. GPIO46_UART1_RI,
  54. GPIO47_UART1_DTR,
  55. GPIO48_UART1_RTS,
  56. /* AC97 */
  57. GPIO34_AC97_SYSCLK,
  58. GPIO35_AC97_SDATA_IN_0,
  59. GPIO37_AC97_SDATA_OUT,
  60. GPIO38_AC97_SYNC,
  61. GPIO39_AC97_BITCLK,
  62. GPIO40_AC97_nACRESET,
  63. GPIO36_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */
  64. /* SSP3 */
  65. GPIO89_SSP3_SCLK,
  66. GPIO90_SSP3_FRM,
  67. GPIO91_SSP3_TXD,
  68. GPIO92_SSP3_RXD,
  69. /* WM9713 IRQ */
  70. GPIO15_GPIO,
  71. /* I2C */
  72. GPIO32_I2C_SCL,
  73. GPIO33_I2C_SDA,
  74. /* Keypad */
  75. GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
  76. GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
  77. GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
  78. GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
  79. GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
  80. GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
  81. GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
  82. GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
  83. GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
  84. GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
  85. GPIO121_KP_MKOUT_0,
  86. GPIO122_KP_MKOUT_1,
  87. GPIO123_KP_MKOUT_2,
  88. GPIO124_KP_MKOUT_3,
  89. GPIO125_KP_MKOUT_4,
  90. GPIO126_KP_MKOUT_5,
  91. GPIO127_KP_MKOUT_6,
  92. GPIO5_2_KP_MKOUT_7,
  93. /* Ethernet */
  94. GPIO4_nCS3,
  95. GPIO90_GPIO,
  96. /* MMC1 */
  97. GPIO18_MMC1_DAT0,
  98. GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
  99. GPIO20_MMC1_DAT2,
  100. GPIO21_MMC1_DAT3,
  101. GPIO22_MMC1_CLK,
  102. GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
  103. GPIO31_GPIO, /* CMD1 default as GPIO for slot 0 */
  104. /* MMC2 */
  105. GPIO24_MMC2_DAT0,
  106. GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
  107. GPIO26_MMC2_DAT2,
  108. GPIO27_MMC2_DAT3,
  109. GPIO28_MMC2_CLK,
  110. GPIO29_MMC2_CMD,
  111. /* USB Host */
  112. GPIO2_2_USBH_PEN,
  113. GPIO3_2_USBH_PWR,
  114. /* Debug LEDs */
  115. GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
  116. GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
  117. };
  118. #define NUM_LCD_DETECT_PINS 7
  119. static int lcd_detect_pins[] __initdata = {
  120. MFP_PIN_GPIO72, /* LCD_LDD_17 - ORIENT */
  121. MFP_PIN_GPIO71, /* LCD_LDD_16 - LCDID[5] */
  122. MFP_PIN_GPIO17_2, /* LCD_BIAS - LCDID[4] */
  123. MFP_PIN_GPIO15_2, /* LCD_LCLK - LCDID[3] */
  124. MFP_PIN_GPIO14_2, /* LCD_FCLK - LCDID[2] */
  125. MFP_PIN_GPIO73, /* LCD_CS_N - LCDID[1] */
  126. MFP_PIN_GPIO74, /* LCD_VSYNC - LCDID[0] */
  127. /*
  128. * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
  129. * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
  130. */
  131. MFP_PIN_GPIO14,
  132. MFP_PIN_GPIO15,
  133. MFP_PIN_GPIO17,
  134. };
  135. static int lcd_detect_mfpr[] __initdata = {
  136. /* AF0, DS 1X, Pull Neither, Edge Clear */
  137. 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
  138. 0xc442, /* Backlight, Pull-Up, AF2 */
  139. 0x8445, /* AF5 */
  140. 0x8445, /* AF5 */
  141. };
  142. static void __init zylonite_detect_lcd_panel(void)
  143. {
  144. unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
  145. int i, gpio, id = 0;
  146. /* save the original MFP settings of these pins and configure them
  147. * as GPIO Input, DS01X, Pull Neither, Edge Clear
  148. */
  149. for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
  150. mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
  151. pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
  152. }
  153. for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
  154. id = id << 1;
  155. gpio = mfp_to_gpio(lcd_detect_pins[i]);
  156. gpio_request(gpio, "LCD_ID_PINS");
  157. gpio_direction_input(gpio);
  158. if (gpio_get_value(gpio))
  159. id = id | 0x1;
  160. gpio_free(gpio);
  161. }
  162. /* lcd id, flush out bit 1 */
  163. lcd_id = id & 0x3d;
  164. /* lcd orientation, portrait or landscape */
  165. lcd_orientation = (id >> 6) & 0x1;
  166. /* restore the original MFP settings */
  167. for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
  168. pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
  169. }
  170. void __init zylonite_pxa320_init(void)
  171. {
  172. if (cpu_is_pxa320()) {
  173. /* initialize MFP */
  174. pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
  175. /* detect LCD panel */
  176. zylonite_detect_lcd_panel();
  177. /* GPIO pin assignment */
  178. gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO9);
  179. gpio_debug_led1 = mfp_to_gpio(MFP_PIN_GPIO1_2);
  180. gpio_debug_led2 = mfp_to_gpio(MFP_PIN_GPIO4_2);
  181. /* WM9713 IRQ */
  182. wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15);
  183. }
  184. }