| 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> | 
|  | 19 |  | 
|  | 20 | #include <asm/arch/gpio.h> | 
|  | 21 | #include <asm/arch/mfp-pxa320.h> | 
|  | 22 | #include <asm/arch/zylonite.h> | 
|  | 23 |  | 
|  | 24 | #define ARRAY_AND_SIZE(x)	(x), ARRAY_SIZE(x) | 
|  | 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, | 
|  | 52 |  | 
|  | 53 | /* FFUART */ | 
| Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 54 | GPIO41_UART1_RXD | MFP_LPM_EDGE_FALL, | 
| eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 55 | GPIO42_UART1_TXD, | 
|  | 56 | GPIO43_UART1_CTS, | 
|  | 57 | GPIO44_UART1_DCD, | 
| Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 58 | GPIO45_UART1_DSR | MFP_LPM_EDGE_FALL, | 
| eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 59 | GPIO46_UART1_RI, | 
|  | 60 | GPIO47_UART1_DTR, | 
|  | 61 | GPIO48_UART1_RTS, | 
|  | 62 |  | 
|  | 63 | /* AC97 */ | 
|  | 64 | GPIO34_AC97_SYSCLK, | 
|  | 65 | GPIO35_AC97_SDATA_IN_0, | 
|  | 66 | GPIO37_AC97_SDATA_OUT, | 
|  | 67 | GPIO38_AC97_SYNC, | 
|  | 68 | GPIO39_AC97_BITCLK, | 
|  | 69 | GPIO40_AC97_nACRESET, | 
|  | 70 |  | 
|  | 71 | /* I2C */ | 
|  | 72 | GPIO32_I2C_SCL, | 
|  | 73 | GPIO33_I2C_SDA, | 
|  | 74 |  | 
|  | 75 | /* Keypad */ | 
| Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 76 | GPIO105_KP_DKIN_0 | MFP_LPM_EDGE_BOTH, | 
|  | 77 | GPIO106_KP_DKIN_1 | MFP_LPM_EDGE_BOTH, | 
|  | 78 | GPIO113_KP_MKIN_0 | MFP_LPM_EDGE_BOTH, | 
|  | 79 | GPIO114_KP_MKIN_1 | MFP_LPM_EDGE_BOTH, | 
|  | 80 | GPIO115_KP_MKIN_2 | MFP_LPM_EDGE_BOTH, | 
|  | 81 | GPIO116_KP_MKIN_3 | MFP_LPM_EDGE_BOTH, | 
|  | 82 | GPIO117_KP_MKIN_4 | MFP_LPM_EDGE_BOTH, | 
|  | 83 | GPIO118_KP_MKIN_5 | MFP_LPM_EDGE_BOTH, | 
|  | 84 | GPIO119_KP_MKIN_6 | MFP_LPM_EDGE_BOTH, | 
|  | 85 | GPIO120_KP_MKIN_7 | MFP_LPM_EDGE_BOTH, | 
| eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 86 | GPIO121_KP_MKOUT_0, | 
|  | 87 | GPIO122_KP_MKOUT_1, | 
|  | 88 | GPIO123_KP_MKOUT_2, | 
|  | 89 | GPIO124_KP_MKOUT_3, | 
|  | 90 | GPIO125_KP_MKOUT_4, | 
|  | 91 | GPIO126_KP_MKOUT_5, | 
|  | 92 | GPIO127_KP_MKOUT_6, | 
|  | 93 | GPIO5_2_KP_MKOUT_7, | 
|  | 94 |  | 
|  | 95 | /* Ethernet */ | 
|  | 96 | GPIO4_nCS3, | 
|  | 97 | GPIO90_GPIO, | 
| Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 98 |  | 
|  | 99 | /* MMC1 */ | 
|  | 100 | GPIO18_MMC1_DAT0, | 
| Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 101 | GPIO19_MMC1_DAT1 | MFP_LPM_EDGE_BOTH, | 
| Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 102 | GPIO20_MMC1_DAT2, | 
|  | 103 | GPIO21_MMC1_DAT3, | 
|  | 104 | GPIO22_MMC1_CLK, | 
|  | 105 | GPIO23_MMC1_CMD,/* CMD0 for slot 0 */ | 
|  | 106 | GPIO31_GPIO,	/* CMD1 default as GPIO for slot 0 */ | 
| Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 107 |  | 
|  | 108 | /* MMC2 */ | 
|  | 109 | GPIO24_MMC2_DAT0, | 
| Russell King | a10476d | 2008-01-08 15:25:01 +0000 | [diff] [blame] | 110 | GPIO25_MMC2_DAT1 | MFP_LPM_EDGE_BOTH, | 
| Bridge Wu | 8d33b05 | 2007-12-21 19:15:36 +0800 | [diff] [blame] | 111 | GPIO26_MMC2_DAT2, | 
|  | 112 | GPIO27_MMC2_DAT3, | 
|  | 113 | GPIO28_MMC2_CLK, | 
|  | 114 | GPIO29_MMC2_CMD, | 
| eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 115 | }; | 
|  | 116 |  | 
|  | 117 | #define NUM_LCD_DETECT_PINS	7 | 
|  | 118 |  | 
|  | 119 | static int lcd_detect_pins[] __initdata = { | 
|  | 120 | MFP_PIN_GPIO72,   /* LCD_LDD_17 - ORIENT */ | 
|  | 121 | MFP_PIN_GPIO71,   /* LCD_LDD_16 - LCDID[5] */ | 
|  | 122 | MFP_PIN_GPIO17_2, /* LCD_BIAS   - LCDID[4] */ | 
|  | 123 | MFP_PIN_GPIO15_2, /* LCD_LCLK   - LCDID[3] */ | 
|  | 124 | MFP_PIN_GPIO14_2, /* LCD_FCLK   - LCDID[2] */ | 
|  | 125 | MFP_PIN_GPIO73,   /* LCD_CS_N   - LCDID[1] */ | 
|  | 126 | MFP_PIN_GPIO74,   /* LCD_VSYNC  - LCDID[0] */ | 
|  | 127 | /* | 
|  | 128 | * set the MFP_PIN_GPIO 14/15/17 to alternate function other than | 
|  | 129 | * GPIO to avoid input level confliction with 14_2, 15_2, 17_2 | 
|  | 130 | */ | 
|  | 131 | MFP_PIN_GPIO14, | 
|  | 132 | MFP_PIN_GPIO15, | 
|  | 133 | MFP_PIN_GPIO17, | 
|  | 134 | }; | 
|  | 135 |  | 
|  | 136 | static int lcd_detect_mfpr[] __initdata = { | 
|  | 137 | /* AF0, DS 1X, Pull Neither, Edge Clear */ | 
|  | 138 | 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, 0x8440, | 
|  | 139 | 0xc442, /* Backlight, Pull-Up, AF2 */ | 
|  | 140 | 0x8445, /* AF5 */ | 
|  | 141 | 0x8445, /* AF5 */ | 
|  | 142 | }; | 
|  | 143 |  | 
|  | 144 | static void __init zylonite_detect_lcd_panel(void) | 
|  | 145 | { | 
|  | 146 | unsigned long mfpr_save[ARRAY_SIZE(lcd_detect_pins)]; | 
|  | 147 | int i, gpio, id = 0; | 
|  | 148 |  | 
|  | 149 | /* save the original MFP settings of these pins and configure them | 
|  | 150 | * as GPIO Input, DS01X, Pull Neither, Edge Clear | 
|  | 151 | */ | 
|  | 152 | for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) { | 
|  | 153 | mfpr_save[i] = pxa3xx_mfp_read(lcd_detect_pins[i]); | 
|  | 154 | pxa3xx_mfp_write(lcd_detect_pins[i], lcd_detect_mfpr[i]); | 
|  | 155 | } | 
|  | 156 |  | 
|  | 157 | for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { | 
|  | 158 | id = id << 1; | 
|  | 159 | gpio = mfp_to_gpio(lcd_detect_pins[i]); | 
|  | 160 | gpio_direction_input(gpio); | 
|  | 161 |  | 
|  | 162 | if (gpio_get_value(gpio)) | 
|  | 163 | id = id | 0x1; | 
|  | 164 | } | 
|  | 165 |  | 
|  | 166 | /* lcd id, flush out bit 1 */ | 
|  | 167 | lcd_id = id & 0x3d; | 
|  | 168 |  | 
|  | 169 | /* lcd orientation, portrait or landscape */ | 
|  | 170 | lcd_orientation = (id >> 6) & 0x1; | 
|  | 171 |  | 
|  | 172 | /* restore the original MFP settings */ | 
|  | 173 | for (i = 0; i < ARRAY_SIZE(lcd_detect_pins); i++) | 
|  | 174 | pxa3xx_mfp_write(lcd_detect_pins[i], mfpr_save[i]); | 
|  | 175 | } | 
|  | 176 |  | 
|  | 177 | void __init zylonite_pxa320_init(void) | 
|  | 178 | { | 
|  | 179 | if (cpu_is_pxa320()) { | 
|  | 180 | /* initialize MFP */ | 
|  | 181 | pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_cfg)); | 
|  | 182 |  | 
|  | 183 | /* detect LCD panel */ | 
|  | 184 | zylonite_detect_lcd_panel(); | 
|  | 185 |  | 
|  | 186 | /* GPIO pin assignment */ | 
|  | 187 | gpio_backlight	= mfp_to_gpio(MFP_PIN_GPIO14); | 
|  | 188 | gpio_eth_irq	= mfp_to_gpio(MFP_PIN_GPIO9); | 
| Bridge Wu | fafc9d3 | 2007-12-21 19:00:13 +0800 | [diff] [blame] | 189 |  | 
|  | 190 | /* MMC card detect & write protect for controller 0 */ | 
|  | 191 | zylonite_mmc_slot[0].gpio_cd  = mfp_to_gpio(MFP_PIN_GPIO1); | 
|  | 192 | zylonite_mmc_slot[0].gpio_wp  = mfp_to_gpio(MFP_PIN_GPIO5); | 
| eric miao | 2c8086a | 2007-09-11 19:13:17 -0700 | [diff] [blame] | 193 | } | 
|  | 194 | } |