Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * LILLY-1131 development board support |
| 3 | * |
| 4 | * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> |
| 5 | * |
| 6 | * based on code for other MX31 boards, |
| 7 | * |
| 8 | * Copyright 2005-2007 Freescale Semiconductor |
| 9 | * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> |
| 10 | * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by |
| 14 | * the Free Software Foundation; either version 2 of the License, or |
| 15 | * (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <linux/kernel.h> |
| 28 | #include <linux/types.h> |
| 29 | #include <linux/init.h> |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 30 | #include <linux/gpio.h> |
Daniel Mack | b9923872 | 2009-05-20 19:54:37 +0200 | [diff] [blame] | 31 | #include <linux/platform_device.h> |
Daniel Mack | 50f349e | 2009-10-26 11:55:57 +0100 | [diff] [blame] | 32 | #include <linux/spi/spi.h> |
| 33 | #include <linux/mfd/mc13783.h> |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 34 | |
| 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | #include <asm/mach/map.h> |
| 38 | |
| 39 | #include <mach/hardware.h> |
| 40 | #include <mach/common.h> |
| 41 | #include <mach/imx-uart.h> |
| 42 | #include <mach/iomux-mx3.h> |
| 43 | #include <mach/board-mx31lilly.h> |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 44 | #include <mach/mmc.h> |
Daniel Mack | b9923872 | 2009-05-20 19:54:37 +0200 | [diff] [blame] | 45 | #include <mach/mx3fb.h> |
| 46 | #include <mach/ipu.h> |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 47 | |
| 48 | #include "devices.h" |
| 49 | |
| 50 | /* |
| 51 | * This file contains board-specific initialization routines for the |
| 52 | * LILLY-1131 development board. If you design an own baseboard for the |
| 53 | * module, use this file as base for support code. |
| 54 | */ |
| 55 | |
| 56 | static unsigned int lilly_db_board_pins[] __initdata = { |
| 57 | MX31_PIN_CTS1__CTS1, |
| 58 | MX31_PIN_RTS1__RTS1, |
| 59 | MX31_PIN_TXD1__TXD1, |
| 60 | MX31_PIN_RXD1__RXD1, |
Daniel Mack | 8d9fb9b | 2009-05-31 12:57:22 +0200 | [diff] [blame] | 61 | MX31_PIN_CTS2__CTS2, |
| 62 | MX31_PIN_RTS2__RTS2, |
| 63 | MX31_PIN_TXD2__TXD2, |
| 64 | MX31_PIN_RXD2__RXD2, |
| 65 | MX31_PIN_CSPI3_MOSI__RXD3, |
| 66 | MX31_PIN_CSPI3_MISO__TXD3, |
| 67 | MX31_PIN_CSPI3_SCLK__RTS3, |
| 68 | MX31_PIN_CSPI3_SPI_RDY__CTS3, |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 69 | MX31_PIN_SD1_DATA3__SD1_DATA3, |
| 70 | MX31_PIN_SD1_DATA2__SD1_DATA2, |
| 71 | MX31_PIN_SD1_DATA1__SD1_DATA1, |
| 72 | MX31_PIN_SD1_DATA0__SD1_DATA0, |
| 73 | MX31_PIN_SD1_CLK__SD1_CLK, |
| 74 | MX31_PIN_SD1_CMD__SD1_CMD, |
Daniel Mack | b9923872 | 2009-05-20 19:54:37 +0200 | [diff] [blame] | 75 | MX31_PIN_LD0__LD0, |
| 76 | MX31_PIN_LD1__LD1, |
| 77 | MX31_PIN_LD2__LD2, |
| 78 | MX31_PIN_LD3__LD3, |
| 79 | MX31_PIN_LD4__LD4, |
| 80 | MX31_PIN_LD5__LD5, |
| 81 | MX31_PIN_LD6__LD6, |
| 82 | MX31_PIN_LD7__LD7, |
| 83 | MX31_PIN_LD8__LD8, |
| 84 | MX31_PIN_LD9__LD9, |
| 85 | MX31_PIN_LD10__LD10, |
| 86 | MX31_PIN_LD11__LD11, |
| 87 | MX31_PIN_LD12__LD12, |
| 88 | MX31_PIN_LD13__LD13, |
| 89 | MX31_PIN_LD14__LD14, |
| 90 | MX31_PIN_LD15__LD15, |
| 91 | MX31_PIN_LD16__LD16, |
| 92 | MX31_PIN_LD17__LD17, |
| 93 | MX31_PIN_VSYNC3__VSYNC3, |
| 94 | MX31_PIN_HSYNC__HSYNC, |
| 95 | MX31_PIN_FPSHIFT__FPSHIFT, |
| 96 | MX31_PIN_DRDY0__DRDY0, |
| 97 | MX31_PIN_CONTRAST__CONTRAST, |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | /* UART */ |
| 101 | static struct imxuart_platform_data uart_pdata __initdata = { |
| 102 | .flags = IMXUART_HAVE_RTSCTS, |
| 103 | }; |
| 104 | |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 105 | /* MMC support */ |
| 106 | |
| 107 | static int mxc_mmc1_get_ro(struct device *dev) |
| 108 | { |
| 109 | return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_LCS0)); |
| 110 | } |
| 111 | |
| 112 | static int gpio_det, gpio_wp; |
| 113 | |
Daniel Mack | 24fb842 | 2009-10-26 11:55:58 +0100 | [diff] [blame^] | 114 | #define MMC_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \ |
| 115 | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) |
| 116 | |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 117 | static int mxc_mmc1_init(struct device *dev, |
| 118 | irq_handler_t detect_irq, void *data) |
| 119 | { |
| 120 | int ret; |
| 121 | |
| 122 | gpio_det = IOMUX_TO_GPIO(MX31_PIN_GPIO1_1); |
| 123 | gpio_wp = IOMUX_TO_GPIO(MX31_PIN_LCS0); |
| 124 | |
Daniel Mack | 24fb842 | 2009-10-26 11:55:58 +0100 | [diff] [blame^] | 125 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA0, MMC_PAD_CFG); |
| 126 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA1, MMC_PAD_CFG); |
| 127 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA2, MMC_PAD_CFG); |
| 128 | mxc_iomux_set_pad(MX31_PIN_SD1_DATA3, MMC_PAD_CFG); |
| 129 | mxc_iomux_set_pad(MX31_PIN_SD1_CLK, MMC_PAD_CFG); |
| 130 | mxc_iomux_set_pad(MX31_PIN_SD1_CMD, MMC_PAD_CFG); |
| 131 | |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 132 | ret = gpio_request(gpio_det, "MMC detect"); |
| 133 | if (ret) |
| 134 | return ret; |
| 135 | |
| 136 | ret = gpio_request(gpio_wp, "MMC w/p"); |
| 137 | if (ret) |
| 138 | goto exit_free_det; |
| 139 | |
| 140 | gpio_direction_input(gpio_det); |
| 141 | gpio_direction_input(gpio_wp); |
| 142 | |
| 143 | ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), detect_irq, |
| 144 | IRQF_DISABLED | IRQF_TRIGGER_FALLING, |
| 145 | "MMC detect", data); |
| 146 | if (ret) |
| 147 | goto exit_free_wp; |
| 148 | |
| 149 | return 0; |
| 150 | |
| 151 | exit_free_wp: |
| 152 | gpio_free(gpio_wp); |
| 153 | |
| 154 | exit_free_det: |
| 155 | gpio_free(gpio_det); |
| 156 | |
| 157 | return ret; |
| 158 | } |
| 159 | |
| 160 | static void mxc_mmc1_exit(struct device *dev, void *data) |
| 161 | { |
| 162 | gpio_free(gpio_det); |
| 163 | gpio_free(gpio_wp); |
| 164 | free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), data); |
| 165 | } |
| 166 | |
| 167 | static struct imxmmc_platform_data mmc_pdata = { |
| 168 | .get_ro = mxc_mmc1_get_ro, |
| 169 | .init = mxc_mmc1_init, |
| 170 | .exit = mxc_mmc1_exit, |
| 171 | }; |
| 172 | |
Daniel Mack | b9923872 | 2009-05-20 19:54:37 +0200 | [diff] [blame] | 173 | /* Framebuffer support */ |
| 174 | static struct ipu_platform_data ipu_data __initdata = { |
| 175 | .irq_base = MXC_IPU_IRQ_START, |
| 176 | }; |
| 177 | |
| 178 | static const struct fb_videomode fb_modedb = { |
| 179 | /* 640x480 TFT panel (IPS-056T) */ |
| 180 | .name = "CRT-VGA", |
| 181 | .refresh = 64, |
| 182 | .xres = 640, |
| 183 | .yres = 480, |
| 184 | .pixclock = 30000, |
| 185 | .left_margin = 200, |
| 186 | .right_margin = 2, |
| 187 | .upper_margin = 2, |
| 188 | .lower_margin = 2, |
| 189 | .hsync_len = 3, |
| 190 | .vsync_len = 1, |
| 191 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_OE_ACT_HIGH, |
| 192 | .vmode = FB_VMODE_NONINTERLACED, |
| 193 | .flag = 0, |
| 194 | }; |
| 195 | |
| 196 | static struct mx3fb_platform_data fb_pdata __initdata = { |
| 197 | .dma_dev = &mx3_ipu.dev, |
| 198 | .name = "CRT-VGA", |
| 199 | .mode = &fb_modedb, |
| 200 | .num_modes = 1, |
| 201 | }; |
| 202 | |
| 203 | #define LCD_VCC_EN_GPIO (7) |
| 204 | |
| 205 | static void __init mx31lilly_init_fb(void) |
| 206 | { |
| 207 | if (gpio_request(LCD_VCC_EN_GPIO, "LCD enable") != 0) { |
| 208 | printk(KERN_WARNING "unable to request LCD_VCC_EN pin.\n"); |
| 209 | return; |
| 210 | } |
| 211 | |
| 212 | mxc_register_device(&mx3_ipu, &ipu_data); |
| 213 | mxc_register_device(&mx3_fb, &fb_pdata); |
| 214 | gpio_direction_output(LCD_VCC_EN_GPIO, 1); |
| 215 | } |
| 216 | |
Daniel Mack | 50f349e | 2009-10-26 11:55:57 +0100 | [diff] [blame] | 217 | /* SPI */ |
| 218 | |
| 219 | static struct mc13783_platform_data mc13783_pdata __initdata = { |
| 220 | .flags = MC13783_USE_RTC | MC13783_USE_TOUCHSCREEN, |
| 221 | }; |
| 222 | |
| 223 | static struct spi_board_info lilly_spi_devs[] __initdata = { |
| 224 | { |
| 225 | .modalias = "mc13783", |
| 226 | .max_speed_hz = 1000000, |
| 227 | .bus_num = 1, |
| 228 | .chip_select = 0, |
| 229 | .platform_data = &mc13783_pdata, |
| 230 | }, |
| 231 | }; |
| 232 | |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 233 | void __init mx31lilly_db_init(void) |
| 234 | { |
| 235 | mxc_iomux_setup_multiple_pins(lilly_db_board_pins, |
| 236 | ARRAY_SIZE(lilly_db_board_pins), |
| 237 | "development board pins"); |
| 238 | mxc_register_device(&mxc_uart_device0, &uart_pdata); |
Daniel Mack | 8d9fb9b | 2009-05-31 12:57:22 +0200 | [diff] [blame] | 239 | mxc_register_device(&mxc_uart_device1, &uart_pdata); |
| 240 | mxc_register_device(&mxc_uart_device2, &uart_pdata); |
Daniel Mack | d0b1eab | 2009-05-20 19:54:36 +0200 | [diff] [blame] | 241 | mxc_register_device(&mxcsdhc_device0, &mmc_pdata); |
Daniel Mack | b9923872 | 2009-05-20 19:54:37 +0200 | [diff] [blame] | 242 | mx31lilly_init_fb(); |
Daniel Mack | 50f349e | 2009-10-26 11:55:57 +0100 | [diff] [blame] | 243 | spi_register_board_info(lilly_spi_devs, ARRAY_SIZE(lilly_spi_devs)); |
Daniel Mack | 1bc34f7 | 2009-05-20 19:54:34 +0200 | [diff] [blame] | 244 | } |
| 245 | |