| Eric Benard | a961bf3 | 2009-07-16 16:26:34 +0200 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2009 Eric Benard - eric@eukrea.com | 
|  | 3 | * | 
|  | 4 | * Based on pcm970-baseboard.c which is : | 
|  | 5 | * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) | 
|  | 6 | * | 
|  | 7 | * This program is free software; you can redistribute it and/or | 
|  | 8 | * modify it under the terms of the GNU General Public License | 
|  | 9 | * as published by the Free Software Foundation; either version 2 | 
|  | 10 | * of the License, or (at your option) any later version. | 
|  | 11 | * This program is distributed in the hope that it will be useful, | 
|  | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 14 | * GNU General Public License for more details. | 
|  | 15 | * | 
|  | 16 | * You should have received a copy of the GNU General Public License | 
|  | 17 | * along with this program; if not, write to the Free Software | 
|  | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | 
|  | 19 | * MA 02110-1301, USA. | 
|  | 20 | */ | 
|  | 21 |  | 
|  | 22 | #include <linux/gpio.h> | 
|  | 23 | #include <linux/irq.h> | 
|  | 24 | #include <linux/platform_device.h> | 
|  | 25 | #include <linux/spi/spi.h> | 
|  | 26 | #include <linux/spi/ads7846.h> | 
|  | 27 |  | 
|  | 28 | #include <asm/mach/arch.h> | 
|  | 29 |  | 
|  | 30 | #include <mach/common.h> | 
|  | 31 | #include <mach/iomux.h> | 
|  | 32 | #include <mach/imxfb.h> | 
|  | 33 | #include <mach/hardware.h> | 
|  | 34 | #include <mach/mmc.h> | 
|  | 35 | #include <mach/imx-uart.h> | 
|  | 36 |  | 
|  | 37 | #include "devices.h" | 
|  | 38 |  | 
|  | 39 | static int eukrea_mbimx27_pins[] = { | 
|  | 40 | /* UART2 */ | 
|  | 41 | PE3_PF_UART2_CTS, | 
|  | 42 | PE4_PF_UART2_RTS, | 
|  | 43 | PE6_PF_UART2_TXD, | 
|  | 44 | PE7_PF_UART2_RXD, | 
|  | 45 | /* UART3 */ | 
|  | 46 | PE8_PF_UART3_TXD, | 
|  | 47 | PE9_PF_UART3_RXD, | 
|  | 48 | PE10_PF_UART3_CTS, | 
|  | 49 | PE11_PF_UART3_RTS, | 
|  | 50 | /* UART4 */ | 
|  | 51 | PB26_AF_UART4_RTS, | 
|  | 52 | PB28_AF_UART4_TXD, | 
|  | 53 | PB29_AF_UART4_CTS, | 
|  | 54 | PB31_AF_UART4_RXD, | 
|  | 55 | /* SDHC1*/ | 
|  | 56 | PE18_PF_SD1_D0, | 
|  | 57 | PE19_PF_SD1_D1, | 
|  | 58 | PE20_PF_SD1_D2, | 
|  | 59 | PE21_PF_SD1_D3, | 
|  | 60 | PE22_PF_SD1_CMD, | 
|  | 61 | PE23_PF_SD1_CLK, | 
|  | 62 | /* display */ | 
|  | 63 | PA5_PF_LSCLK, | 
|  | 64 | PA6_PF_LD0, | 
|  | 65 | PA7_PF_LD1, | 
|  | 66 | PA8_PF_LD2, | 
|  | 67 | PA9_PF_LD3, | 
|  | 68 | PA10_PF_LD4, | 
|  | 69 | PA11_PF_LD5, | 
|  | 70 | PA12_PF_LD6, | 
|  | 71 | PA13_PF_LD7, | 
|  | 72 | PA14_PF_LD8, | 
|  | 73 | PA15_PF_LD9, | 
|  | 74 | PA16_PF_LD10, | 
|  | 75 | PA17_PF_LD11, | 
|  | 76 | PA18_PF_LD12, | 
|  | 77 | PA19_PF_LD13, | 
|  | 78 | PA20_PF_LD14, | 
|  | 79 | PA21_PF_LD15, | 
|  | 80 | PA22_PF_LD16, | 
|  | 81 | PA23_PF_LD17, | 
|  | 82 | PA28_PF_HSYNC, | 
|  | 83 | PA29_PF_VSYNC, | 
|  | 84 | PA30_PF_CONTRAST, | 
|  | 85 | PA31_PF_OE_ACD, | 
|  | 86 | /* SPI1 */ | 
|  | 87 | PD28_PF_CSPI1_SS0, | 
|  | 88 | PD29_PF_CSPI1_SCLK, | 
|  | 89 | PD30_PF_CSPI1_MISO, | 
|  | 90 | PD31_PF_CSPI1_MOSI, | 
|  | 91 | }; | 
|  | 92 |  | 
|  | 93 | static struct gpio_led gpio_leds[] = { | 
|  | 94 | { | 
|  | 95 | .name			= "led1", | 
|  | 96 | .default_trigger	= "heartbeat", | 
|  | 97 | .active_low		= 1, | 
|  | 98 | .gpio			= GPIO_PORTF | 16, | 
|  | 99 | }, | 
|  | 100 | { | 
|  | 101 | .name			= "led2", | 
|  | 102 | .default_trigger	= "none", | 
|  | 103 | .active_low		= 1, | 
|  | 104 | .gpio			= GPIO_PORTF | 19, | 
|  | 105 | }, | 
|  | 106 | { | 
|  | 107 | .name			= "backlight", | 
|  | 108 | .default_trigger	= "backlight", | 
|  | 109 | .active_low		= 0, | 
|  | 110 | .gpio			= GPIO_PORTE | 5, | 
|  | 111 | }, | 
|  | 112 | }; | 
|  | 113 |  | 
|  | 114 | static struct gpio_led_platform_data gpio_led_info = { | 
|  | 115 | .leds		= gpio_leds, | 
|  | 116 | .num_leds	= ARRAY_SIZE(gpio_leds), | 
|  | 117 | }; | 
|  | 118 |  | 
|  | 119 | static struct platform_device leds_gpio = { | 
|  | 120 | .name	= "leds-gpio", | 
|  | 121 | .id	= -1, | 
|  | 122 | .dev	= { | 
|  | 123 | .platform_data	= &gpio_led_info, | 
|  | 124 | }, | 
|  | 125 | }; | 
|  | 126 |  | 
|  | 127 | static struct imx_fb_videomode eukrea_mbimx27_modes[] = { | 
|  | 128 | { | 
|  | 129 | .mode = { | 
|  | 130 | .name		= "CMO-QGVA", | 
|  | 131 | .refresh	= 60, | 
|  | 132 | .xres		= 320, | 
|  | 133 | .yres		= 240, | 
|  | 134 | .pixclock	= 156000, | 
|  | 135 | .hsync_len	= 30, | 
|  | 136 | .left_margin	= 38, | 
|  | 137 | .right_margin	= 20, | 
|  | 138 | .vsync_len	= 3, | 
|  | 139 | .upper_margin	= 15, | 
|  | 140 | .lower_margin	= 4, | 
|  | 141 | }, | 
|  | 142 | .pcr		= 0xFAD08B80, | 
|  | 143 | .bpp		= 16, | 
|  | 144 | }, | 
|  | 145 | }; | 
|  | 146 |  | 
|  | 147 | static struct imx_fb_platform_data eukrea_mbimx27_fb_data = { | 
|  | 148 | .mode = eukrea_mbimx27_modes, | 
|  | 149 | .num_modes = ARRAY_SIZE(eukrea_mbimx27_modes), | 
|  | 150 |  | 
|  | 151 | .pwmr		= 0x00A903FF, | 
|  | 152 | .lscr1		= 0x00120300, | 
|  | 153 | .dmacr		= 0x00040060, | 
|  | 154 | }; | 
|  | 155 |  | 
|  | 156 | static struct imxuart_platform_data uart_pdata[] = { | 
|  | 157 | { | 
|  | 158 | .flags = IMXUART_HAVE_RTSCTS, | 
|  | 159 | }, | 
|  | 160 | { | 
|  | 161 | .flags = IMXUART_HAVE_RTSCTS, | 
|  | 162 | }, | 
|  | 163 | }; | 
|  | 164 |  | 
|  | 165 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) | 
|  | 166 | || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | 
|  | 167 |  | 
|  | 168 | #define ADS7846_PENDOWN (GPIO_PORTD | 25) | 
|  | 169 |  | 
|  | 170 | static void ads7846_dev_init(void) | 
|  | 171 | { | 
|  | 172 | if (gpio_request(ADS7846_PENDOWN, "ADS7846 pendown") < 0) { | 
|  | 173 | printk(KERN_ERR "can't get ads746 pen down GPIO\n"); | 
|  | 174 | return; | 
|  | 175 | } | 
|  | 176 |  | 
|  | 177 | gpio_direction_input(ADS7846_PENDOWN); | 
|  | 178 | } | 
|  | 179 |  | 
|  | 180 | static int ads7846_get_pendown_state(void) | 
|  | 181 | { | 
|  | 182 | return !gpio_get_value(ADS7846_PENDOWN); | 
|  | 183 | } | 
|  | 184 |  | 
|  | 185 | static struct ads7846_platform_data ads7846_config __initdata = { | 
|  | 186 | .get_pendown_state	= ads7846_get_pendown_state, | 
|  | 187 | .keep_vref_on		= 1, | 
|  | 188 | }; | 
|  | 189 |  | 
|  | 190 | static struct spi_board_info eukrea_mbimx27_spi_board_info[] __initdata = { | 
|  | 191 | [0] = { | 
|  | 192 | .modalias	= "ads7846", | 
|  | 193 | .bus_num	= 0, | 
|  | 194 | .chip_select	= 0, | 
|  | 195 | .max_speed_hz	= 1500000, | 
|  | 196 | .irq		= IRQ_GPIOD(25), | 
|  | 197 | .platform_data	= &ads7846_config, | 
|  | 198 | .mode           = SPI_MODE_2, | 
|  | 199 | }, | 
|  | 200 | }; | 
|  | 201 |  | 
|  | 202 | static int eukrea_mbimx27_spi_cs[] = {GPIO_PORTD | 28}; | 
|  | 203 |  | 
|  | 204 | static struct spi_imx_master eukrea_mbimx27_spi_0_data = { | 
|  | 205 | .chipselect	= eukrea_mbimx27_spi_cs, | 
|  | 206 | .num_chipselect = ARRAY_SIZE(eukrea_mbimx27_spi_cs), | 
|  | 207 | }; | 
|  | 208 | #endif | 
|  | 209 |  | 
|  | 210 | static struct platform_device *platform_devices[] __initdata = { | 
|  | 211 | &leds_gpio, | 
|  | 212 | }; | 
|  | 213 |  | 
|  | 214 | /* | 
|  | 215 | * system init for baseboard usage. Will be called by cpuimx27 init. | 
|  | 216 | * | 
|  | 217 | * Add platform devices present on this baseboard and init | 
|  | 218 | * them from CPU side as far as required to use them later on | 
|  | 219 | */ | 
|  | 220 | void __init eukrea_mbimx27_baseboard_init(void) | 
|  | 221 | { | 
|  | 222 | mxc_gpio_setup_multiple_pins(eukrea_mbimx27_pins, | 
|  | 223 | ARRAY_SIZE(eukrea_mbimx27_pins), "MBIMX27"); | 
|  | 224 |  | 
|  | 225 | mxc_register_device(&mxc_uart_device1, &uart_pdata[0]); | 
|  | 226 | mxc_register_device(&mxc_uart_device2, &uart_pdata[1]); | 
|  | 227 |  | 
|  | 228 | mxc_register_device(&mxc_fb_device, &eukrea_mbimx27_fb_data); | 
|  | 229 | mxc_register_device(&mxc_sdhc_device0, NULL); | 
|  | 230 |  | 
|  | 231 | #if defined(CONFIG_TOUCHSCREEN_ADS7846) | 
|  | 232 | || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) | 
|  | 233 | /* SPI and ADS7846 Touchscreen controler init */ | 
|  | 234 | mxc_gpio_mode(GPIO_PORTD | 28 | GPIO_GPIO | GPIO_OUT); | 
|  | 235 | mxc_gpio_mode(GPIO_PORTD | 25 | GPIO_GPIO | GPIO_IN); | 
|  | 236 | mxc_register_device(&mxc_spi_device0, &eukrea_mbimx27_spi_0_data); | 
|  | 237 | spi_register_board_info(eukrea_mbimx27_spi_board_info, | 
|  | 238 | ARRAY_SIZE(eukrea_mbimx27_spi_board_info)); | 
|  | 239 | ads7846_dev_init(); | 
|  | 240 | #endif | 
|  | 241 |  | 
|  | 242 | /* Leds configuration */ | 
|  | 243 | mxc_gpio_mode(GPIO_PORTF | 16 | GPIO_GPIO | GPIO_OUT); | 
|  | 244 | mxc_gpio_mode(GPIO_PORTF | 19 | GPIO_GPIO | GPIO_OUT); | 
|  | 245 | /* Backlight */ | 
|  | 246 | mxc_gpio_mode(GPIO_PORTE | 5 | GPIO_GPIO | GPIO_OUT); | 
|  | 247 |  | 
|  | 248 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); | 
|  | 249 | } |