2c8086a5 |
1 | /* |
2 | * linux/arch/arm/mach-pxa/zylonite_pxa300.c |
3 | * |
4 | * PXA300/PXA310 specific support code for the |
5 | * PXA3xx Development Platform (aka Zylonite) |
6 | * |
7 | * Copyright (C) 2007 Marvell Internation Ltd. |
8 | * 2007-08-21: eric miao <eric.y.miao@gmail.com> |
9 | * initial version |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License version 2 as |
13 | * published by the Free Software Foundation. |
14 | */ |
15 | |
16 | #include <linux/module.h> |
17 | #include <linux/kernel.h> |
18 | #include <linux/init.h> |
19 | |
20 | #include <asm/gpio.h> |
21 | #include <asm/arch/mfp-pxa300.h> |
22 | #include <asm/arch/zylonite.h> |
23 | |
24 | #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x) |
25 | |
26 | /* PXA300/PXA310 common configurations */ |
27 | static mfp_cfg_t common_mfp_cfg[] __initdata = { |
28 | /* LCD */ |
29 | GPIO54_LCD_LDD_0, |
30 | GPIO55_LCD_LDD_1, |
31 | GPIO56_LCD_LDD_2, |
32 | GPIO57_LCD_LDD_3, |
33 | GPIO58_LCD_LDD_4, |
34 | GPIO59_LCD_LDD_5, |
35 | GPIO60_LCD_LDD_6, |
36 | GPIO61_LCD_LDD_7, |
37 | GPIO62_LCD_LDD_8, |
38 | GPIO63_LCD_LDD_9, |
39 | GPIO64_LCD_LDD_10, |
40 | GPIO65_LCD_LDD_11, |
41 | GPIO66_LCD_LDD_12, |
42 | GPIO67_LCD_LDD_13, |
43 | GPIO68_LCD_LDD_14, |
44 | GPIO69_LCD_LDD_15, |
45 | GPIO70_LCD_LDD_16, |
46 | GPIO71_LCD_LDD_17, |
47 | GPIO72_LCD_FCLK, |
48 | GPIO73_LCD_LCLK, |
49 | GPIO74_LCD_PCLK, |
50 | GPIO75_LCD_BIAS, |
51 | GPIO76_LCD_VSYNC, |
52 | GPIO127_LCD_CS_N, |
53 | |
54 | /* BTUART */ |
55 | GPIO111_UART2_RTS, |
56 | GPIO112_UART2_RXD, |
57 | GPIO113_UART2_TXD, |
58 | GPIO114_UART2_CTS, |
59 | |
60 | /* STUART */ |
61 | GPIO109_UART3_TXD, |
62 | GPIO110_UART3_RXD, |
63 | |
64 | /* AC97 */ |
65 | GPIO23_AC97_nACRESET, |
66 | GPIO24_AC97_SYSCLK, |
67 | GPIO29_AC97_BITCLK, |
68 | GPIO25_AC97_SDATA_IN_0, |
69 | GPIO27_AC97_SDATA_OUT, |
70 | GPIO28_AC97_SYNC, |
71 | |
72 | /* Keypad */ |
73 | GPIO107_KP_DKIN_0, |
74 | GPIO108_KP_DKIN_1, |
75 | GPIO115_KP_MKIN_0, |
76 | GPIO116_KP_MKIN_1, |
77 | GPIO117_KP_MKIN_2, |
78 | GPIO118_KP_MKIN_3, |
79 | GPIO119_KP_MKIN_4, |
80 | GPIO120_KP_MKIN_5, |
81 | GPIO2_2_KP_MKIN_6, |
82 | GPIO3_2_KP_MKIN_7, |
83 | GPIO121_KP_MKOUT_0, |
84 | GPIO122_KP_MKOUT_1, |
85 | GPIO123_KP_MKOUT_2, |
86 | GPIO124_KP_MKOUT_3, |
87 | GPIO125_KP_MKOUT_4, |
88 | GPIO4_2_KP_MKOUT_5, |
89 | GPIO5_2_KP_MKOUT_6, |
90 | GPIO6_2_KP_MKOUT_7, |
91 | }; |
92 | |
93 | static mfp_cfg_t pxa300_mfp_cfg[] __initdata = { |
94 | /* FFUART */ |
95 | GPIO30_UART1_RXD, |
96 | GPIO31_UART1_TXD, |
97 | GPIO32_UART1_CTS, |
98 | GPIO37_UART1_RTS, |
99 | GPIO33_UART1_DCD, |
100 | GPIO34_UART1_DSR, |
101 | GPIO35_UART1_RI, |
102 | GPIO36_UART1_DTR, |
103 | |
104 | /* Ethernet */ |
105 | GPIO2_nCS3, |
106 | GPIO99_GPIO, |
107 | }; |
108 | |
109 | static mfp_cfg_t pxa310_mfp_cfg[] __initdata = { |
110 | /* FFUART */ |
111 | GPIO99_UART1_RXD, |
112 | GPIO100_UART1_TXD, |
113 | GPIO101_UART1_CTS, |
114 | GPIO106_UART1_RTS, |
115 | |
116 | /* Ethernet */ |
117 | GPIO2_nCS3, |
118 | GPIO102_GPIO, |
119 | }; |
120 | |
121 | #define NUM_LCD_DETECT_PINS 7 |
122 | |
123 | static int lcd_detect_pins[] __initdata = { |
124 | MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */ |
125 | MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */ |
126 | MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */ |
127 | MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */ |
128 | MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */ |
129 | MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */ |
130 | MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */ |
131 | }; |
132 | |
133 | static void __init zylonite_detect_lcd_panel(void) |
134 | { |
135 | unsigned long mfpr_save[NUM_LCD_DETECT_PINS]; |
136 | int i, gpio, id = 0; |
137 | |
138 | /* save the original MFP settings of these pins and configure |
139 | * them as GPIO Input, DS01X, Pull Neither, Edge Clear |
140 | */ |
141 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
142 | mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]); |
143 | pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440); |
144 | } |
145 | |
146 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
147 | id = id << 1; |
148 | gpio = mfp_to_gpio(lcd_detect_pins[i]); |
149 | gpio_direction_input(gpio); |
150 | |
151 | if (gpio_get_value(gpio)) |
152 | id = id | 0x1; |
153 | } |
154 | |
155 | /* lcd id, flush out bit 1 */ |
156 | lcd_id = id & 0x3d; |
157 | |
158 | /* lcd orientation, portrait or landscape */ |
159 | lcd_orientation = (id >> 6) & 0x1; |
160 | |
161 | /* restore the original MFP settings */ |
162 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) |
163 | pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]); |
164 | } |
165 | |
166 | void __init zylonite_pxa300_init(void) |
167 | { |
168 | if (cpu_is_pxa300() || cpu_is_pxa310()) { |
169 | /* initialize MFP */ |
170 | pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg)); |
171 | |
172 | /* detect LCD panel */ |
173 | zylonite_detect_lcd_panel(); |
174 | |
175 | /* GPIO pin assignment */ |
176 | gpio_backlight = mfp_to_gpio(MFP_PIN_GPIO20); |
177 | } |
178 | |
179 | if (cpu_is_pxa300()) { |
180 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg)); |
181 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99); |
182 | } |
183 | |
184 | if (cpu_is_pxa310()) { |
185 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg)); |
186 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102); |
187 | } |
188 | } |