eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-pxa/zylonite_pxa320.c |
| 3 | * |
| 4 | * PXA320 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 | 80796f2 | 2008-11-25 11:03:03 +0800 | [diff] [blame] | 19 | #include <linux/gpio.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 20 | |
Eric Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 21 | #include <mach/pxa320.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 22 | #include <mach/zylonite.h> |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 23 | |
eric miao | 3d3934c | 2008-02-03 15:49:09 +0800 | [diff] [blame] | 24 | #include "generic.h" |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 25 | |
| 26 | static mfp_cfg_t mfp_cfg[] __initdata = { |
| 27 | /* LCD */ |
| 28 | GPIO6_2_LCD_LDD_0, |
| 29 | GPIO7_2_LCD_LDD_1, |
| 30 | GPIO8_2_LCD_LDD_2, |
| 31 | GPIO9_2_LCD_LDD_3, |
| 32 | GPIO10_2_LCD_LDD_4, |
| 33 | GPIO11_2_LCD_LDD_5, |
| 34 | GPIO12_2_LCD_LDD_6, |
| 35 | GPIO13_2_LCD_LDD_7, |
| 36 | GPIO63_LCD_LDD_8, |
| 37 | GPIO64_LCD_LDD_9, |
| 38 | GPIO65_LCD_LDD_10, |
| 39 | GPIO66_LCD_LDD_11, |
| 40 | GPIO67_LCD_LDD_12, |
| 41 | GPIO68_LCD_LDD_13, |
| 42 | GPIO69_LCD_LDD_14, |
| 43 | GPIO70_LCD_LDD_15, |
| 44 | GPIO71_LCD_LDD_16, |
| 45 | GPIO72_LCD_LDD_17, |
| 46 | GPIO73_LCD_CS_N, |
| 47 | GPIO74_LCD_VSYNC, |
| 48 | GPIO14_2_LCD_FCLK, |
| 49 | GPIO15_2_LCD_LCLK, |
| 50 | GPIO16_2_LCD_PCLK, |
| 51 | GPIO17_2_LCD_BIAS, |
eric miao | 5cca914 | 2008-04-13 21:46:34 +0100 | [diff] [blame] | 52 | GPIO14_PWM3_OUT, /* backlight */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 53 | |
| 54 | /* FFUART */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 55 | GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 56 | GPIO42_UART1_TXD, |
| 57 | GPIO43_UART1_CTS, |
| 58 | GPIO44_UART1_DCD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 59 | GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 60 | GPIO46_UART1_RI, |
| 61 | GPIO47_UART1_DTR, |
| 62 | GPIO48_UART1_RTS, |
| 63 | |
| 64 | /* AC97 */ |
| 65 | GPIO34_AC97_SYSCLK, |
| 66 | GPIO35_AC97_SDATA_IN_0, |
| 67 | GPIO37_AC97_SDATA_OUT, |
| 68 | GPIO38_AC97_SYNC, |
| 69 | GPIO39_AC97_BITCLK, |
| 70 | GPIO40_AC97_nACRESET, |
Eric Miao | 15fbc93 | 2009-04-22 18:34:36 +0800 | [diff] [blame] | 71 | GPIO36_GPIO, /* SDATA_IN_1 but unused - configure to GPIO */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 72 | |
Mark Brown | 58d27fc | 2008-07-10 17:52:10 +0100 | [diff] [blame] | 73 | /* SSP3 */ |
| 74 | GPIO89_SSP3_SCLK, |
| 75 | GPIO90_SSP3_FRM, |
| 76 | GPIO91_SSP3_TXD, |
| 77 | GPIO92_SSP3_RXD, |
| 78 | |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 79 | /* WM9713 IRQ */ |
| 80 | GPIO15_GPIO, |
| 81 | |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 82 | /* I2C */ |
| 83 | GPIO32_I2C_SCL, |
| 84 | GPIO33_I2C_SDA, |
| 85 | |
| 86 | /* Keypad */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 87 | GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH, |
| 88 | GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH, |
| 89 | GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, |
| 90 | GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, |
| 91 | GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, |
| 92 | GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, |
| 93 | GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, |
| 94 | GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, |
| 95 | GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, |
| 96 | GPIO120_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 | GPIO126_KP_MKOUT_5, |
| 103 | GPIO127_KP_MKOUT_6, |
| 104 | GPIO5_2_KP_MKOUT_7, |
| 105 | |
| 106 | /* Ethernet */ |
| 107 | GPIO4_nCS3, |
| 108 | GPIO90_GPIO, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 109 | |
| 110 | /* MMC1 */ |
| 111 | GPIO18_MMC1_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 112 | GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 113 | GPIO20_MMC1_DAT2, |
| 114 | GPIO21_MMC1_DAT3, |
| 115 | GPIO22_MMC1_CLK, |
| 116 | GPIO23_MMC1_CMD,/* CMD0 for slot 0 */ |
| 117 | GPIO31_GPIO, /* CMD1 default as GPIO for slot 0 */ |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 118 | |
| 119 | /* MMC2 */ |
| 120 | GPIO24_MMC2_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 121 | GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 122 | GPIO26_MMC2_DAT2, |
| 123 | GPIO27_MMC2_DAT3, |
| 124 | GPIO28_MMC2_CLK, |
| 125 | GPIO29_MMC2_CMD, |
Eric Miao | 5c9f50e | 2008-06-17 19:03:54 +0800 | [diff] [blame] | 126 | |
Eric Miao | 7ff4353 | 2008-09-27 18:05:49 +0800 | [diff] [blame] | 127 | /* USB Host */ |
| 128 | GPIO2_2_USBH_PEN, |
| 129 | GPIO3_2_USBH_PWR, |
| 130 | |
Eric Miao | 5c9f50e | 2008-06-17 19:03:54 +0800 | [diff] [blame] | 131 | /* Debug LEDs */ |
| 132 | GPIO1_2_GPIO | MFP_LPM_DRIVE_HIGH, |
| 133 | GPIO4_2_GPIO | MFP_LPM_DRIVE_HIGH, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | #define NUM_LCD_DETECT_PINS 7 |
| 137 | |
| 138 | static int lcd_detect_pins[] __initdata = { |
| 139 | MFP_PIN_GPIO72, /* LCD_LDD_17 - ORIENT */ |
| 140 | MFP_PIN_GPIO71, /* LCD_LDD_16 - LCDID[5] */ |
| 141 | MFP_PIN_GPIO17_2, /* LCD_BIAS - LCDID[4] */ |
| 142 | MFP_PIN_GPIO15_2, /* LCD_LCLK - LCDID[3] */ |
| 143 | MFP_PIN_GPIO14_2, /* LCD_FCLK - LCDID[2] */ |
| 144 | MFP_PIN_GPIO73, /* LCD_CS_N - LCDID[1] */ |
| 145 | MFP_PIN_GPIO74, /* LCD_VSYNC - LCDID[0] */ |
| 146 | /* |
| 147 | * set the MFP_PIN_GPIO 14/15/17 to alternate function other than |
| 148 | * GPIO to avoid input level confliction with 14_2, 15_2, 17_2 |
| 149 | */ |
| 150 | MFP_PIN_GPIO14, |
| 151 | MFP_PIN_GPIO15, |
| 152 | MFP_PIN_GPIO17, |
| 153 | }; |
| 154 | |
| 155 | static int lcd_detect_mfpr[] __initdata = { |
| 156 | /* AF0, DS 1X, Pull Neither, Edge Clear */ |
| 157 | 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, |
| 158 | 0xc442, /* Backlight, Pull-Up, AF2 */ |
| 159 | 0x8445, /* AF5 */ |
| 160 | 0x8445, /* AF5 */ |
| 161 | }; |
| 162 | |
| 163 | static void __init zylonite_detect_lcd_panel(void) |
| 164 | { |
| 165 | unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)]; |
| 166 | int i, gpio, id = 0; |
| 167 | |
| 168 | /* save the original MFP settings of these pins and configure them |
| 169 | * as GPIO Input, DS01X, Pull Neither, Edge Clear |
| 170 | */ |
| 171 | for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) { |
| 172 | mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]); |
| 173 | pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]); |
| 174 | } |
| 175 | |
| 176 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
| 177 | id = id << 1; |
| 178 | gpio = mfp_to_gpio(lcd_detect_pins[i]); |
| 179 | gpio_direction_input(gpio); |
| 180 | |
| 181 | if (gpio_get_value(gpio)) |
| 182 | id = id | 0x1; |
| 183 | } |
| 184 | |
| 185 | /* lcd id, flush out bit 1 */ |
| 186 | lcd_id = id & 0x3d; |
| 187 | |
| 188 | /* lcd orientation, portrait or landscape */ |
| 189 | lcd_orientation = (id >> 6) & 0x1; |
| 190 | |
| 191 | /* restore the original MFP settings */ |
| 192 | for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) |
| 193 | pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]); |
| 194 | } |
| 195 | |
| 196 | void __init zylonite_pxa320_init(void) |
| 197 | { |
| 198 | if (cpu_is_pxa320()) { |
| 199 | /* initialize MFP */ |
| 200 | pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg)); |
| 201 | |
| 202 | /* detect LCD panel */ |
| 203 | zylonite_detect_lcd_panel(); |
| 204 | |
| 205 | /* GPIO pin assignment */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 206 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO9); |
Eric Miao | 5c9f50e | 2008-06-17 19:03:54 +0800 | [diff] [blame] | 207 | gpio_debug_led1 = mfp_to_gpio(MFP_PIN_GPIO1_2); |
| 208 | gpio_debug_led2 = mfp_to_gpio(MFP_PIN_GPIO4_2); |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 209 | |
| 210 | /* MMC card detect & write protect for controller 0 */ |
| 211 | zylonite_mmc_slot[0].gpio_cd = mfp_to_gpio(MFP_PIN_GPIO1); |
| 212 | zylonite_mmc_slot[0].gpio_wp = mfp_to_gpio(MFP_PIN_GPIO5); |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 213 | |
| 214 | /* WM9713 IRQ */ |
| 215 | wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO15); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 216 | } |
| 217 | } |