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> |
| 19 | |
| 20 | #include <asm/gpio.h> |
| 21 | #include <asm/arch/mfp-pxa300.h> |
| 22 | #include <asm/arch/zylonite.h> |
| 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 | /* 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, |
eric miao | 5cca914 | 2008-04-13 21:46:34 +0100 | [diff] [blame] | 53 | GPIO20_PWM3_OUT, /* backlight */ |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 54 | |
| 55 | /* BTUART */ |
| 56 | GPIO111_UART2_RTS, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 57 | GPIO112_UART2_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 58 | GPIO113_UART2_TXD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 59 | GPIO114_UART2_CTS | MFP_LPM_EDGE_BOTH, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 60 | |
| 61 | /* STUART */ |
| 62 | GPIO109_UART3_TXD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 63 | GPIO110_UART3_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 64 | |
| 65 | /* AC97 */ |
| 66 | GPIO23_AC97_nACRESET, |
| 67 | GPIO24_AC97_SYSCLK, |
| 68 | GPIO29_AC97_BITCLK, |
| 69 | GPIO25_AC97_SDATA_IN_0, |
| 70 | GPIO27_AC97_SDATA_OUT, |
| 71 | GPIO28_AC97_SYNC, |
| 72 | |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 73 | /* WM9713 IRQ */ |
| 74 | GPIO26_GPIO, |
| 75 | |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 76 | /* Keypad */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 77 | GPIO107_KP_DKIN_0 | MFP_LPM_EDGE_BOTH, |
| 78 | GPIO108_KP_DKIN_1 | MFP_LPM_EDGE_BOTH, |
| 79 | GPIO115_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, |
| 80 | GPIO116_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, |
| 81 | GPIO117_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, |
| 82 | GPIO118_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, |
| 83 | GPIO119_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, |
| 84 | GPIO120_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, |
| 85 | GPIO2_2_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, |
| 86 | GPIO3_2_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 87 | GPIO121_KP_MKOUT_0, |
| 88 | GPIO122_KP_MKOUT_1, |
| 89 | GPIO123_KP_MKOUT_2, |
| 90 | GPIO124_KP_MKOUT_3, |
| 91 | GPIO125_KP_MKOUT_4, |
| 92 | GPIO4_2_KP_MKOUT_5, |
| 93 | GPIO5_2_KP_MKOUT_6, |
| 94 | GPIO6_2_KP_MKOUT_7, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 95 | |
| 96 | /* MMC1 */ |
| 97 | GPIO3_MMC1_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 98 | GPIO4_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 99 | GPIO5_MMC1_DAT2, |
| 100 | GPIO6_MMC1_DAT3, |
| 101 | GPIO7_MMC1_CLK, |
| 102 | GPIO8_MMC1_CMD, /* CMD0 for slot 0 */ |
| 103 | GPIO15_GPIO, /* CMD1 default as GPIO for slot 0 */ |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 104 | |
| 105 | /* MMC2 */ |
| 106 | GPIO9_MMC2_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 107 | GPIO10_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 108 | GPIO11_MMC2_DAT2, |
| 109 | GPIO12_MMC2_DAT3, |
| 110 | GPIO13_MMC2_CLK, |
| 111 | GPIO14_MMC2_CMD, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | static mfp_cfg_t pxa300_mfp_cfg[] __initdata = { |
| 115 | /* FFUART */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 116 | GPIO30_UART1_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 117 | GPIO31_UART1_TXD, |
| 118 | GPIO32_UART1_CTS, |
| 119 | GPIO37_UART1_RTS, |
| 120 | GPIO33_UART1_DCD, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 121 | GPIO34_UART1_DSR | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 122 | GPIO35_UART1_RI, |
| 123 | GPIO36_UART1_DTR, |
| 124 | |
| 125 | /* Ethernet */ |
| 126 | GPIO2_nCS3, |
| 127 | GPIO99_GPIO, |
| 128 | }; |
| 129 | |
| 130 | static mfp_cfg_t pxa310_mfp_cfg[] __initdata = { |
| 131 | /* FFUART */ |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 132 | GPIO99_UART1_RXD | MFP_LPM_EDGE_FALL, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 133 | GPIO100_UART1_TXD, |
| 134 | GPIO101_UART1_CTS, |
| 135 | GPIO106_UART1_RTS, |
| 136 | |
| 137 | /* Ethernet */ |
| 138 | GPIO2_nCS3, |
| 139 | GPIO102_GPIO, |
Bridge Wu | 5a1f21b | 2007-12-21 19:27:08 +0800 | [diff] [blame] | 140 | |
| 141 | /* MMC3 */ |
| 142 | GPIO7_2_MMC3_DAT0, |
Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 143 | GPIO8_2_MMC3_DAT1 | MFP_LPM_EDGE_BOTH, |
Bridge Wu | 5a1f21b | 2007-12-21 19:27:08 +0800 | [diff] [blame] | 144 | GPIO9_2_MMC3_DAT2, |
| 145 | GPIO10_2_MMC3_DAT3, |
| 146 | GPIO103_MMC3_CLK, |
| 147 | GPIO105_MMC3_CMD, |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | #define NUM_LCD_DETECT_PINS 7 |
| 151 | |
| 152 | static int lcd_detect_pins[] __initdata = { |
| 153 | MFP_PIN_GPIO71, /* LCD_LDD_17 - ORIENT */ |
| 154 | MFP_PIN_GPIO70, /* LCD_LDD_16 - LCDID[5] */ |
| 155 | MFP_PIN_GPIO75, /* LCD_BIAS - LCDID[4] */ |
| 156 | MFP_PIN_GPIO73, /* LCD_LCLK - LCDID[3] */ |
| 157 | MFP_PIN_GPIO72, /* LCD_FCLK - LCDID[2] */ |
| 158 | MFP_PIN_GPIO127,/* LCD_CS_N - LCDID[1] */ |
| 159 | MFP_PIN_GPIO76, /* LCD_VSYNC - LCDID[0] */ |
| 160 | }; |
| 161 | |
| 162 | static void __init zylonite_detect_lcd_panel(void) |
| 163 | { |
| 164 | unsigned long mfpr_save[NUM_LCD_DETECT_PINS]; |
| 165 | int i, gpio, id = 0; |
| 166 | |
| 167 | /* save the original MFP settings of these pins and configure |
| 168 | * them as GPIO Input, DS01X, Pull Neither, Edge Clear |
| 169 | */ |
| 170 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
| 171 | mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]); |
| 172 | pxa3xx_mfp_write(lcd_detect_pins[i], 0x8440); |
| 173 | } |
| 174 | |
| 175 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { |
| 176 | id = id << 1; |
| 177 | gpio = mfp_to_gpio(lcd_detect_pins[i]); |
| 178 | gpio_direction_input(gpio); |
| 179 | |
| 180 | if (gpio_get_value(gpio)) |
| 181 | id = id | 0x1; |
| 182 | } |
| 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 < NUM_LCD_DETECT_PINS; i++) |
| 192 | pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]); |
| 193 | } |
| 194 | |
| 195 | void __init zylonite_pxa300_init(void) |
| 196 | { |
| 197 | if (cpu_is_pxa300() || cpu_is_pxa310()) { |
| 198 | /* initialize MFP */ |
| 199 | pxa3xx_mfp_config(ARRAY_AND_SIZE(common_mfp_cfg)); |
| 200 | |
| 201 | /* detect LCD panel */ |
| 202 | zylonite_detect_lcd_panel(); |
| 203 | |
Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 204 | /* MMC card detect & write protect for controller 0 */ |
| 205 | zylonite_mmc_slot[0].gpio_cd = EXT_GPIO(0); |
| 206 | zylonite_mmc_slot[0].gpio_wp = EXT_GPIO(2); |
Mark Brown | 768dec4 | 2008-04-15 15:50:49 +0100 | [diff] [blame] | 207 | |
| 208 | /* WM9713 IRQ */ |
| 209 | wm9713_irq = mfp_to_gpio(MFP_PIN_GPIO26); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | if (cpu_is_pxa300()) { |
| 213 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa300_mfp_cfg)); |
| 214 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO99); |
| 215 | } |
| 216 | |
| 217 | if (cpu_is_pxa310()) { |
| 218 | pxa3xx_mfp_config(ARRAY_AND_SIZE(pxa310_mfp_cfg)); |
| 219 | gpio_eth_irq = mfp_to_gpio(MFP_PIN_GPIO102); |
Bridge Wu | 5a1f21b | 2007-12-21 19:27:08 +0800 | [diff] [blame] | 220 | |
| 221 | /* MMC card detect & write protect for controller 2 */ |
| 222 | zylonite_mmc_slot[2].gpio_cd = EXT_GPIO(30); |
| 223 | zylonite_mmc_slot[2].gpio_wp = EXT_GPIO(31); |
eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 224 | } |
| 225 | } |