blob: 94cb834f36cda35bff6f5ce86ea0384d5cd7a73e [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
eric miao2c8086a2007-09-11 19:13:17 -07002/*
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.
eric miaoe9bba8e2007-10-30 08:01:38 +01009 * 2007-08-21: eric miao <eric.miao@marvell.com>
eric miao2c8086a2007-09-11 19:13:17 -070010 * initial version
eric miao2c8086a2007-09-11 19:13:17 -070011 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
Eric Miao80796f22008-11-25 11:03:03 +080016#include <linux/gpio.h>
eric miao2c8086a2007-09-11 19:13:17 -070017
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010018#include "pxa320.h"
19#include "zylonite.h"
eric miao2c8086a2007-09-11 19:13:17 -070020
eric miao3d3934c2008-02-03 15:49:09 +080021#include "generic.h"
eric miao2c8086a2007-09-11 19:13:17 -070022
23static mfp_cfg_t mfp_cfg[] __initdata = {
24 /* LCD */
25 GPIO6_2_LCD_LDD_0,
26 GPIO7_2_LCD_LDD_1,
27 GPIO8_2_LCD_LDD_2,
28 GPIO9_2_LCD_LDD_3,
29 GPIO10_2_LCD_LDD_4,
30 GPIO11_2_LCD_LDD_5,
31 GPIO12_2_LCD_LDD_6,
32 GPIO13_2_LCD_LDD_7,
33 GPIO63_LCD_LDD_8,
34 GPIO64_LCD_LDD_9,
35 GPIO65_LCD_LDD_10,
36 GPIO66_LCD_LDD_11,
37 GPIO67_LCD_LDD_12,
38 GPIO68_LCD_LDD_13,
39 GPIO69_LCD_LDD_14,
40 GPIO70_LCD_LDD_15,
41 GPIO71_LCD_LDD_16,
42 GPIO72_LCD_LDD_17,
43 GPIO73_LCD_CS_N,
44 GPIO74_LCD_VSYNC,
45 GPIO14_2_LCD_FCLK,
46 GPIO15_2_LCD_LCLK,
47 GPIO16_2_LCD_PCLK,
48 GPIO17_2_LCD_BIAS,
eric miao5cca9142008-04-13 21:46:34 +010049 GPIO14_PWM3_OUT, /* backlight */
eric miao2c8086a2007-09-11 19:13:17 -070050
51 /* FFUART */
Russell Kinga10476d2008-01-08 15:25:01 +000052 GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -070053 GPIO42_UART1_TXD,
54 GPIO43_UART1_CTS,
55 GPIO44_UART1_DCD,
Russell Kinga10476d2008-01-08 15:25:01 +000056 GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL,
eric miao2c8086a2007-09-11 19:13:17 -070057 GPIO46_UART1_RI,
58 GPIO47_UART1_DTR,
59 GPIO48_UART1_RTS,
60
61 /* AC97 */
62 GPIO34_AC97_SYSCLK,
63 GPIO35_AC97_SDATA_IN_0,
64 GPIO37_AC97_SDATA_OUT,
65 GPIO38_AC97_SYNC,
66 GPIO39_AC97_BITCLK,
67 GPIO40_AC97_nACRESET,
Eric Miao15fbc932009-04-22 18:34:36 +080068 GPIO36_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */
eric miao2c8086a2007-09-11 19:13:17 -070069
Mark Brown58d27fc2008-07-10 17:52:10 +010070 /* SSP3 */
71 GPIO89_SSP3_SCLK,
72 GPIO90_SSP3_FRM,
73 GPIO91_SSP3_TXD,
74 GPIO92_SSP3_RXD,
75
Mark Brown768dec42008-04-15 15:50:49 +010076 /* WM9713 IRQ */
77 GPIO15_GPIO,
78
eric miao2c8086a2007-09-11 19:13:17 -070079 /* I2C */
80 GPIO32_I2C_SCL,
81 GPIO33_I2C_SDA,
82
83 /* Keypad */
Russell Kinga10476d2008-01-08 15:25:01 +000084 GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH,
85 GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH,
86 GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH,
87 GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH,
88 GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH,
89 GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH,
90 GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH,
91 GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH,
92 GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH,
93 GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH,
eric miao2c8086a2007-09-11 19:13:17 -070094 GPIO121_KP_MKOUT_0,
95 GPIO122_KP_MKOUT_1,
96 GPIO123_KP_MKOUT_2,
97 GPIO124_KP_MKOUT_3,
98 GPIO125_KP_MKOUT_4,
99 GPIO126_KP_MKOUT_5,
100 GPIO127_KP_MKOUT_6,
101 GPIO5_2_KP_MKOUT_7,
102
103 /* Ethernet */
104 GPIO4_nCS3,
105 GPIO90_GPIO,
Bridge Wufafc9d32007-12-21 19:00:13 +0800106
107 /* MMC1 */
108 GPIO18_MMC1_DAT0,
Russell Kinga10476d2008-01-08 15:25:01 +0000109 GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH,
Bridge Wufafc9d32007-12-21 19:00:13 +0800110 GPIO20_MMC1_DAT2,
111 GPIO21_MMC1_DAT3,
112 GPIO22_MMC1_CLK,
113 GPIO23_MMC1_CMD,/* CMD0 for slot 0 */
114 GPIO31_GPIO, /* CMD1 default as GPIO for slot 0 */
Bridge Wu8d33b052007-12-21 19:15:36 +0800115
116 /* MMC2 */
117 GPIO24_MMC2_DAT0,
Russell Kinga10476d2008-01-08 15:25:01 +0000118 GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH,
Bridge Wu8d33b052007-12-21 19:15:36 +0800119 GPIO26_MMC2_DAT2,
120 GPIO27_MMC2_DAT3,
121 GPIO28_MMC2_CLK,
122 GPIO29_MMC2_CMD,
Eric Miao5c9f50e2008-06-17 19:03:54 +0800123
Eric Miao7ff43532008-09-27 18:05:49 +0800124 /* USB Host */
125 GPIO2_2_USBH_PEN,
126 GPIO3_2_USBH_PWR,
127
Eric Miao5c9f50e2008-06-17 19:03:54 +0800128 /* Debug LEDs */
129 GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH,
130 GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH,
eric miao2c8086a2007-09-11 19:13:17 -0700131};
132
133#define NUM_LCD_DETECT_PINS 7
134
135static int lcd_detect_pins[] __initdata = {
136 MFP_PIN_GPIO72, /* LCD_LDD_17 - ORIENT */
137 MFP_PIN_GPIO71, /* LCD_LDD_16 - LCDID[5] */
138 MFP_PIN_GPIO17_2, /* LCD_BIAS - LCDID[4] */
139 MFP_PIN_GPIO15_2, /* LCD_LCLK - LCDID[3] */
140 MFP_PIN_GPIO14_2, /* LCD_FCLK - LCDID[2] */
141 MFP_PIN_GPIO73, /* LCD_CS_N - LCDID[1] */
142 MFP_PIN_GPIO74, /* LCD_VSYNC - LCDID[0] */
143 /*
144 * set the MFP_PIN_GPIO 14/15/17 to alternate function other than
145 * GPIO to avoid input level confliction with 14_2, 15_2, 17_2
146 */
147 MFP_PIN_GPIO14,
148 MFP_PIN_GPIO15,
149 MFP_PIN_GPIO17,
150};
151
152static int lcd_detect_mfpr[] __initdata = {
153 /* AF0, DS 1X, Pull Neither, Edge Clear */
154 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440,
155 0xc442, /* Backlight, Pull-Up, AF2 */
156 0x8445, /* AF5 */
157 0x8445, /* AF5 */
158};
159
160static void __init zylonite_detect_lcd_panel(void)
161{
162 unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)];
163 int i, gpio, id = 0;
164
165 /* save the original MFP settings of these pins and configure them
166 * as GPIO Input, DS01X, Pull Neither, Edge Clear
167 */
168 for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) {
169 mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]);
170 pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]);
171 }
172
173 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
174 id = id << 1;
175 gpio = mfp_to_gpio(lcd_detect_pins[i]);
Haojian Zhuangeb906912009-07-15 19:47:24 +0800176 gpio_request(gpio, "LCD_ID_PINS");
eric miao2c8086a2007-09-11 19:13:17 -0700177 gpio_direction_input(gpio);
178
179 if (gpio_get_value(gpio))
180 id = id | 0x1;
Haojian Zhuangeb906912009-07-15 19:47:24 +0800181 gpio_free(gpio);
eric miao2c8086a2007-09-11 19:13:17 -0700182 }
183
184 /* lcd id, flush out bit 1 */
185 lcd_id = id & 0x3d;
186
187 /* lcd orientation, portrait or landscape */
188 lcd_orientation = (id >> 6) & 0x1;
189
190 /* restore the original MFP settings */
191 for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++)
192 pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]);
193}
194
195void __init zylonite_pxa320_init(void)
196{
197 if (cpu_is_pxa320()) {
198 /* initialize MFP */
199 pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg));
200
201 /* detect LCD panel */
202 zylonite_detect_lcd_panel();
203
204 /* GPIO pin assignment */
eric miao2c8086a2007-09-11 19:13:17 -0700205 gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO9);
Eric Miao5c9f50e2008-06-17 19:03:54 +0800206 gpio_debug_led1 = mfp_to_gpio(MFP_PIN_GPIO1_2);
207 gpio_debug_led2 = mfp_to_gpio(MFP_PIN_GPIO4_2);
Bridge Wufafc9d32007-12-21 19:00:13 +0800208
Mark Brown768dec42008-04-15 15:50:49 +0100209 /* WM9713 IRQ */
210 wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15);
eric miao2c8086a2007-09-11 19:13:17 -0700211 }
212}