eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 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. |
eric miao | e9bba8e | 2007-10-30 08:01:38 +0100 | [diff] [blame] | 8 | * 2007-08-21: eric miao <eric.miao@marvell.com> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 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> |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 19 | #include <linux/i2c.h> |
Sebastian Andrzej Siewior | b459396 | 2011-02-23 12:38:16 +0100 | [diff] [blame] | 20 | #include <linux/i2c/pxa-i2c.h> |
Vivien Didelot | 5877457 | 2013-08-29 15:24:14 -0400 | [diff] [blame] | 21 | #include <linux/platform_data/pca953x.h> |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 22 | #include <linux/gpio.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 23 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 24 | #include <mach/pxa300.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 25 | #include <mach/zylonite.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 26 | |
eric miao | 3d3934c | 2008-02-03 15:49:09 +0800 | [diff] [blame] | 27 | #include "generic.h" |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 28 | |
| 29 | /* PXA300/PXA310 common configurations */ |
| 30 | static mfp_cfg_t common_mfp_cfg[] __initdata = { |
| 31 | /* LCD */ |
| 32 | GPIO54_LCD_LDD_0, |
| 33 | GPIO55_LCD_LDD_1, |
| 34 | GPIO56_LCD_LDD_2, |
| 35 | GPIO57_LCD_LDD_3, |
| 36 | GPIO58_LCD_LDD_4, |
| 37 | GPIO59_LCD_LDD_5, |
| 38 | GPIO60_LCD_LDD_6, |
| 39 | GPIO61_LCD_LDD_7, |
| 40 | GPIO62_LCD_LDD_8, |
| 41 | GPIO63_LCD_LDD_9, |
| 42 | GPIO64_LCD_LDD_10, |
| 43 | GPIO65_LCD_LDD_11, |
| 44 | GPIO66_LCD_LDD_12, |
| 45 | GPIO67_LCD_LDD_13, |
| 46 | GPIO68_LCD_LDD_14, |
| 47 | GPIO69_LCD_LDD_15, |
| 48 | GPIO70_LCD_LDD_16, |
| 49 | GPIO71_LCD_LDD_17, |
| 50 | GPIO72_LCD_FCLK, |
| 51 | GPIO73_LCD_LCLK, |
| 52 | GPIO74_LCD_PCLK, |
| 53 | GPIO75_LCD_BIAS, |
| 54 | GPIO76_LCD_VSYNC, |
| 55 | GPIO127_LCD_CS_N, |
eric miao | 5cca914 | 2008-04-13 21:46:34 +0100 | [diff] [blame] | 56 | GPIO20_PWM3_OUT, /* backlight */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 57 | |
| 58 | /* BTUART */ |
| 59 | GPIO111_UART2_RTS, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 60 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 61 | GPIO113_UART2_TXD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 62 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 63 | |
| 64 | /* STUART */ |
| 65 | GPIO109_UART3_TXD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 66 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 67 | |
| 68 | /* AC97 */ |
| 69 | GPIO23_AC97_nACRESET, |
| 70 | GPIO24_AC97_SYSCLK, |
| 71 | GPIO29_AC97_BITCLK, |
| 72 | GPIO25_AC97_SDATA_IN_0, |
| 73 | GPIO27_AC97_SDATA_OUT, |
| 74 | GPIO28_AC97_SYNC, |
Eric Miao | 15fbc93 | 2009-04-22 18:34:36 +0800 | [diff] [blame] | 75 | GPIO17_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 76 | |
Mark Brown | 58d27fc | 2008-07-10 17:52:10 +0100 | [diff] [blame] | 77 | /* SSP3 */ |
| 78 | GPIO91_SSP3_SCLK, |
| 79 | GPIO92_SSP3_FRM, |
| 80 | GPIO93_SSP3_TXD, |
| 81 | GPIO94_SSP3_RXD, |
| 82 | |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 83 | /* WM9713 IRQ */ |
| 84 | GPIO26_GPIO, |
| 85 | |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 86 | /* Keypad */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 87 | GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH, |
| 88 | GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH, |
| 89 | GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, |
| 90 | GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, |
| 91 | GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, |
| 92 | GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, |
| 93 | GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, |
| 94 | GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, |
| 95 | GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, |
| 96 | GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 97 | GPIO121_KP_MKOUT_0, |
| 98 | GPIO122_KP_MKOUT_1, |
| 99 | GPIO123_KP_MKOUT_2, |
| 100 | GPIO124_KP_MKOUT_3, |
| 101 | GPIO125_KP_MKOUT_4, |
| 102 | GPIO4_2_KP_MKOUT_5, |
| 103 | GPIO5_2_KP_MKOUT_6, |
| 104 | GPIO6_2_KP_MKOUT_7, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 105 | |
| 106 | /* MMC1 */ |
| 107 | GPIO3_MMC1_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 108 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 109 | GPIO5_MMC1_DAT2, |
| 110 | GPIO6_MMC1_DAT3, |
| 111 | GPIO7_MMC1_CLK, |
| 112 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ |
| 113 | GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */ |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 114 | |
| 115 | /* MMC2 */ |
| 116 | GPIO9_MMC2_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 117 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 118 | GPIO11_MMC2_DAT2, |
| 119 | GPIO12_MMC2_DAT3, |
| 120 | GPIO13_MMC2_CLK, |
| 121 | GPIO14_MMC2_CMD, |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 122 | |
Eric Miao | 7ff4353 | 2008-09-27 18:05:49 +0800 | [diff] [blame] | 123 | /* USB Host */ |
| 124 | GPIO0_2_USBH_PEN, |
| 125 | GPIO1_2_USBH_PWR, |
| 126 | |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 127 | /* Standard I2C */ |
| 128 | GPIO21_I2C_SCL, |
| 129 | GPIO22_I2C_SDA, |
Eric Miao | b49e385 | 2009-04-22 18:38:40 +0800 | [diff] [blame] | 130 | |
| 131 | /* GPIO */ |
Haojian Zhuang | f91e490 | 2009-12-22 07:29:40 -0500 | [diff] [blame] | 132 | GPIO18_GPIO | MFP_PULL_HIGH, /* GPIO Expander #0 INT_N */ |
| 133 | GPIO19_GPIO | MFP_PULL_HIGH, /* GPIO Expander #1 INT_N */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | static mfp_cfg_t pxa300_mfp_cfg[] __initdata = { |
| 137 | /* FFUART */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 138 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 139 | GPIO31_UART1_TXD, |
| 140 | GPIO32_UART1_CTS, |
| 141 | GPIO37_UART1_RTS, |
| 142 | GPIO33_UART1_DCD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 143 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 144 | GPIO35_UART1_RI, |
| 145 | GPIO36_UART1_DTR, |
| 146 | |
| 147 | /* Ethernet */ |
| 148 | GPIO2_nCS3, |
| 149 | GPIO99_GPIO, |
| 150 | }; |
| 151 | |
| 152 | static mfp_cfg_t pxa310_mfp_cfg[] __initdata = { |
| 153 | /* FFUART */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 154 | GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 155 | GPIO100_UART1_TXD, |
| 156 | GPIO101_UART1_CTS, |
| 157 | GPIO106_UART1_RTS, |
| 158 | |
| 159 | /* Ethernet */ |
| 160 | GPIO2_nCS3, |
| 161 | GPIO102_GPIO, |
Bridge Wu | 5a1f21b | 2007-12-21 19:27:08 +0800 | [diff] [blame] | 162 | |
| 163 | /* MMC3 */ |
| 164 | GPIO7_2_MMC3_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 165 | GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | 5a1f21b | 2007-12-21 19:27:08 +0800 | [diff] [blame] | 166 | GPIO9_2_MMC3_DAT2, |
| 167 | GPIO10_2_MMC3_DAT3, |
| 168 | GPIO103_MMC3_CLK, |
| 169 | GPIO105_MMC3_CMD, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | #define NUM_LCD_DETECT_PINS 7 |
| 173 | |
| 174 | static int lcd_detect_pins[] __initdata = { |
| 175 | MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */ |
| 176 | MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */ |
| 177 | MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */ |
| 178 | MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */ |
| 179 | MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */ |
| 180 | MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */ |
| 181 | MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */ |
| 182 | }; |
| 183 | |
| 184 | static void __init zylonite_detect_lcd_panel(void) |
| 185 | { |
| 186 | unsigned long mfpr_save[NUM_LCD_DETECT_PINS]; |
| 187 | int i, gpio, id = 0; |
| 188 | |
| 189 | /* save the original MFP settings of these pins and configure |
| 190 | * them as GPIO Input, DS01X, Pull Neither, Edge Clear |
| 191 | */ |
| 192 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
| 193 | mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]); |
| 194 | pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440); |
| 195 | } |
| 196 | |
| 197 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
| 198 | id = id << 1; |
| 199 | gpio = mfp_to_gpio(lcd_detect_pins[i]); |
Haojian Zhuang | eb90691 | 2009-07-15 19:47:24 +0800 | [diff] [blame] | 200 | gpio_request(gpio, "LCD_ID_PINS"); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 201 | gpio_direction_input(gpio); |
| 202 | |
| 203 | if (gpio_get_value(gpio)) |
| 204 | id = id | 0x1; |
Haojian Zhuang | eb90691 | 2009-07-15 19:47:24 +0800 | [diff] [blame] | 205 | gpio_free(gpio); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /* lcd id, flush out bit 1 */ |
| 209 | lcd_id = id & 0x3d; |
| 210 | |
| 211 | /* lcd orientation, portrait or landscape */ |
| 212 | lcd_orientation = (id >> 6) & 0x1; |
| 213 | |
| 214 | /* restore the original MFP settings */ |
| 215 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) |
| 216 | pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]); |
| 217 | } |
| 218 | |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 219 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 220 | static struct pca953x_platform_data gpio_exp[] = { |
| 221 | [0] = { |
| 222 | .gpio_base = 128, |
| 223 | }, |
| 224 | [1] = { |
| 225 | .gpio_base = 144, |
| 226 | }, |
| 227 | }; |
| 228 | |
Mark Brown | a461a8d | 2008-08-26 10:58:54 +0100 | [diff] [blame] | 229 | static struct i2c_board_info zylonite_i2c_board_info[] = { |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 230 | { |
| 231 | .type = "pca9539", |
| 232 | .addr = 0x74, |
| 233 | .platform_data = &gpio_exp[0], |
Haojian Zhuang | 6384fda | 2011-10-10 14:21:08 +0800 | [diff] [blame] | 234 | .irq = PXA_GPIO_TO_IRQ(18), |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 235 | }, { |
| 236 | .type = "pca9539", |
| 237 | .addr = 0x75, |
| 238 | .platform_data = &gpio_exp[1], |
Haojian Zhuang | 6384fda | 2011-10-10 14:21:08 +0800 | [diff] [blame] | 239 | .irq = PXA_GPIO_TO_IRQ(19), |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 240 | }, |
| 241 | }; |
| 242 | |
| 243 | static void __init zylonite_init_i2c(void) |
| 244 | { |
| 245 | pxa_set_i2c_info(NULL); |
| 246 | i2c_register_board_info(0, ARRAY_AND_SIZE(zylonite_i2c_board_info)); |
| 247 | } |
| 248 | #else |
| 249 | static inline void zylonite_init_i2c(void) {} |
| 250 | #endif |
| 251 | |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 252 | void __init zylonite_pxa300_init(void) |
| 253 | { |
| 254 | if (cpu_is_pxa300() || cpu_is_pxa310()) { |
| 255 | /* initialize MFP */ |
| 256 | pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg)); |
| 257 | |
| 258 | /* detect LCD panel */ |
| 259 | zylonite_detect_lcd_panel(); |
| 260 | |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 261 | /* WM9713 IRQ */ |
| 262 | wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26); |
Eric Miao | a1f7fc4 | 2008-05-28 10:44:16 +0800 | [diff] [blame] | 263 | |
| 264 | zylonite_init_i2c(); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | if (cpu_is_pxa300()) { |
| 268 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg)); |
| 269 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99); |
| 270 | } |
| 271 | |
| 272 | if (cpu_is_pxa310()) { |
| 273 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg)); |
| 274 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 275 | } |
Eric Miao | 5c9f50e | 2008-06-17 19:03:54 +0800 | [diff] [blame] | 276 | |
| 277 | /* GPIOs for Debug LEDs */ |
| 278 | gpio_debug_led1 = EXT_GPIO(25); |
| 279 | gpio_debug_led2 = EXT_GPIO(26); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 280 | } |