Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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/types.h> |
| 23 | #include <linux/init.h> |
| 24 | |
| 25 | #include <linux/gpio.h> |
| 26 | #include <linux/interrupt.h> |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 27 | #include <linux/leds.h> |
| 28 | #include <linux/platform_device.h> |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 29 | #include <linux/input.h> |
| 30 | #include <linux/i2c.h> |
Denis Carikli | 13d1dd8 | 2012-05-08 09:20:24 +0200 | [diff] [blame] | 31 | #include <video/platform_lcd.h> |
| 32 | #include <linux/backlight.h> |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 33 | |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/time.h> |
| 37 | #include <asm/mach/map.h> |
| 38 | |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 39 | #include "common.h" |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 40 | #include "devices-imx51.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 41 | #include "hardware.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 42 | #include "iomux-mx51.h" |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 43 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 44 | static iomux_v3_cfg_t eukrea_mbimxsd51_pads[] = { |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 45 | /* LED */ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 46 | MX51_PAD_NANDF_D10__GPIO3_30, |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 47 | /* SWITCH */ |
Troy Kisky | 7242e24 | 2011-08-13 12:51:41 -0700 | [diff] [blame] | 48 | NEW_PAD_CTRL(MX51_PAD_NANDF_D9__GPIO3_31, PAD_CTL_PUS_22K_UP | |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 49 | PAD_CTL_PKE | PAD_CTL_SRE_FAST | |
| 50 | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS), |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 51 | /* UART2 */ |
| 52 | MX51_PAD_UART2_RXD__UART2_RXD, |
| 53 | MX51_PAD_UART2_TXD__UART2_TXD, |
| 54 | /* UART 3 */ |
| 55 | MX51_PAD_UART3_RXD__UART3_RXD, |
| 56 | MX51_PAD_UART3_TXD__UART3_TXD, |
| 57 | MX51_PAD_KEY_COL4__UART3_RTS, |
| 58 | MX51_PAD_KEY_COL5__UART3_CTS, |
| 59 | /* SD */ |
| 60 | MX51_PAD_SD1_CMD__SD1_CMD, |
| 61 | MX51_PAD_SD1_CLK__SD1_CLK, |
| 62 | MX51_PAD_SD1_DATA0__SD1_DATA0, |
| 63 | MX51_PAD_SD1_DATA1__SD1_DATA1, |
| 64 | MX51_PAD_SD1_DATA2__SD1_DATA2, |
| 65 | MX51_PAD_SD1_DATA3__SD1_DATA3, |
Eric Bénard | ef560bf | 2011-02-25 14:38:31 +0100 | [diff] [blame] | 66 | /* SD1 CD */ |
Troy Kisky | 7242e24 | 2011-08-13 12:51:41 -0700 | [diff] [blame] | 67 | NEW_PAD_CTRL(MX51_PAD_GPIO1_0__SD1_CD, PAD_CTL_PUS_22K_UP | |
Eric Bénard | ef560bf | 2011-02-25 14:38:31 +0100 | [diff] [blame] | 68 | PAD_CTL_PKE | PAD_CTL_SRE_FAST | |
| 69 | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS), |
Eric Bénard | 932d67d | 2012-05-08 09:20:22 +0200 | [diff] [blame] | 70 | /* SSI */ |
| 71 | MX51_PAD_AUD3_BB_TXD__AUD3_TXD, |
| 72 | MX51_PAD_AUD3_BB_RXD__AUD3_RXD, |
| 73 | MX51_PAD_AUD3_BB_CK__AUD3_TXC, |
| 74 | MX51_PAD_AUD3_BB_FS__AUD3_TXFS, |
Denis Carikli | 13d1dd8 | 2012-05-08 09:20:24 +0200 | [diff] [blame] | 75 | /* LCD Backlight */ |
| 76 | MX51_PAD_DI1_D1_CS__GPIO3_4, |
| 77 | /* LCD RST */ |
| 78 | MX51_PAD_CSI1_D9__GPIO3_13, |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 79 | }; |
| 80 | |
Arnaud Patard (Rtp) | 96886c4 | 2010-11-26 15:20:52 +0100 | [diff] [blame] | 81 | #define GPIO_LED1 IMX_GPIO_NR(3, 30) |
| 82 | #define GPIO_SWITCH1 IMX_GPIO_NR(3, 31) |
Denis Carikli | 13d1dd8 | 2012-05-08 09:20:24 +0200 | [diff] [blame] | 83 | #define GPIO_LCDRST IMX_GPIO_NR(3, 13) |
| 84 | #define GPIO_LCDBL IMX_GPIO_NR(3, 4) |
| 85 | |
| 86 | static void eukrea_mbimxsd51_lcd_power_set(struct plat_lcd_data *pd, |
| 87 | unsigned int power) |
| 88 | { |
| 89 | if (power) |
| 90 | gpio_direction_output(GPIO_LCDRST, 1); |
| 91 | else |
| 92 | gpio_direction_output(GPIO_LCDRST, 0); |
| 93 | } |
| 94 | |
| 95 | static struct plat_lcd_data eukrea_mbimxsd51_lcd_power_data = { |
| 96 | .set_power = eukrea_mbimxsd51_lcd_power_set, |
| 97 | }; |
| 98 | |
| 99 | static struct platform_device eukrea_mbimxsd51_lcd_powerdev = { |
| 100 | .name = "platform-lcd", |
| 101 | .dev.platform_data = &eukrea_mbimxsd51_lcd_power_data, |
| 102 | }; |
| 103 | |
| 104 | static void eukrea_mbimxsd51_bl_set_intensity(int intensity) |
| 105 | { |
| 106 | if (intensity) |
| 107 | gpio_direction_output(GPIO_LCDBL, 1); |
| 108 | else |
| 109 | gpio_direction_output(GPIO_LCDBL, 0); |
| 110 | } |
| 111 | |
| 112 | static struct generic_bl_info eukrea_mbimxsd51_bl_info = { |
| 113 | .name = "eukrea_mbimxsd51-bl", |
| 114 | .max_intensity = 0xff, |
| 115 | .default_intensity = 0xff, |
| 116 | .set_bl_intensity = eukrea_mbimxsd51_bl_set_intensity, |
| 117 | }; |
| 118 | |
| 119 | static struct platform_device eukrea_mbimxsd51_bl_dev = { |
| 120 | .name = "generic-bl", |
| 121 | .id = 1, |
| 122 | .dev = { |
| 123 | .platform_data = &eukrea_mbimxsd51_bl_info, |
| 124 | }, |
| 125 | }; |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 126 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 127 | static const struct gpio_led eukrea_mbimxsd51_leds[] __initconst = { |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 128 | { |
| 129 | .name = "led1", |
| 130 | .default_trigger = "heartbeat", |
| 131 | .active_low = 1, |
| 132 | .gpio = GPIO_LED1, |
| 133 | }, |
| 134 | }; |
| 135 | |
Uwe Kleine-König | 5b8d628 | 2011-05-28 21:05:02 +0200 | [diff] [blame] | 136 | static const struct gpio_led_platform_data |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 137 | eukrea_mbimxsd51_led_info __initconst = { |
| 138 | .leds = eukrea_mbimxsd51_leds, |
| 139 | .num_leds = ARRAY_SIZE(eukrea_mbimxsd51_leds), |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 140 | }; |
| 141 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 142 | static struct gpio_keys_button eukrea_mbimxsd51_gpio_buttons[] = { |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 143 | { |
| 144 | .gpio = GPIO_SWITCH1, |
| 145 | .code = BTN_0, |
| 146 | .desc = "BP1", |
| 147 | .active_low = 1, |
| 148 | .wakeup = 1, |
| 149 | }, |
| 150 | }; |
| 151 | |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 152 | static const struct gpio_keys_platform_data |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 153 | eukrea_mbimxsd51_button_data __initconst = { |
| 154 | .buttons = eukrea_mbimxsd51_gpio_buttons, |
| 155 | .nbuttons = ARRAY_SIZE(eukrea_mbimxsd51_gpio_buttons), |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 156 | }; |
| 157 | |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 158 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 159 | .flags = IMXUART_HAVE_RTSCTS, |
| 160 | }; |
| 161 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 162 | static struct i2c_board_info eukrea_mbimxsd51_i2c_devices[] = { |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 163 | { |
| 164 | I2C_BOARD_INFO("tlv320aic23", 0x1a), |
| 165 | }, |
| 166 | }; |
| 167 | |
Eric Bénard | 932d67d | 2012-05-08 09:20:22 +0200 | [diff] [blame] | 168 | static const |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 169 | struct imx_ssi_platform_data eukrea_mbimxsd51_ssi_pdata __initconst = { |
Eric Bénard | 932d67d | 2012-05-08 09:20:22 +0200 | [diff] [blame] | 170 | .flags = IMX_SSI_SYN | IMX_SSI_NET | IMX_SSI_USE_I2S_SLAVE, |
| 171 | }; |
| 172 | |
Denis Carikli | 13d1dd8 | 2012-05-08 09:20:24 +0200 | [diff] [blame] | 173 | static int screen_type; |
| 174 | |
| 175 | static int __init eukrea_mbimxsd51_screen_type(char *options) |
| 176 | { |
| 177 | if (!strcmp(options, "dvi")) |
| 178 | screen_type = 1; |
| 179 | else if (!strcmp(options, "tft")) |
| 180 | screen_type = 0; |
| 181 | |
| 182 | return 0; |
| 183 | } |
| 184 | __setup("screen_type=", eukrea_mbimxsd51_screen_type); |
| 185 | |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 186 | /* |
| 187 | * system init for baseboard usage. Will be called by cpuimx51sd init. |
| 188 | * |
| 189 | * Add platform devices present on this baseboard and init |
| 190 | * them from CPU side as far as required to use them later on |
| 191 | */ |
| 192 | void __init eukrea_mbimxsd51_baseboard_init(void) |
| 193 | { |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 194 | if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd51_pads, |
| 195 | ARRAY_SIZE(eukrea_mbimxsd51_pads))) |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 196 | printk(KERN_ERR "error setting mbimxsd pads !\n"); |
| 197 | |
| 198 | imx51_add_imx_uart(1, NULL); |
| 199 | imx51_add_imx_uart(2, &uart_pdata); |
| 200 | |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 201 | imx51_add_sdhci_esdhc_imx(0, NULL); |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 202 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 203 | imx51_add_imx_ssi(0, &eukrea_mbimxsd51_ssi_pdata); |
Eric Bénard | 932d67d | 2012-05-08 09:20:22 +0200 | [diff] [blame] | 204 | |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 205 | gpio_request(GPIO_LED1, "LED1"); |
| 206 | gpio_direction_output(GPIO_LED1, 1); |
| 207 | gpio_free(GPIO_LED1); |
| 208 | |
| 209 | gpio_request(GPIO_SWITCH1, "SWITCH1"); |
| 210 | gpio_direction_input(GPIO_SWITCH1); |
| 211 | gpio_free(GPIO_SWITCH1); |
| 212 | |
Denis Carikli | 13d1dd8 | 2012-05-08 09:20:24 +0200 | [diff] [blame] | 213 | gpio_request(GPIO_LCDRST, "LCDRST"); |
| 214 | gpio_direction_output(GPIO_LCDRST, 0); |
| 215 | gpio_request(GPIO_LCDBL, "LCDBL"); |
| 216 | gpio_direction_output(GPIO_LCDBL, 0); |
| 217 | if (!screen_type) { |
| 218 | platform_device_register(&eukrea_mbimxsd51_bl_dev); |
| 219 | platform_device_register(&eukrea_mbimxsd51_lcd_powerdev); |
| 220 | } else { |
| 221 | gpio_free(GPIO_LCDRST); |
| 222 | gpio_free(GPIO_LCDBL); |
| 223 | } |
| 224 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 225 | i2c_register_board_info(0, eukrea_mbimxsd51_i2c_devices, |
| 226 | ARRAY_SIZE(eukrea_mbimxsd51_i2c_devices)); |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 227 | |
Eric Bénard | 53a02d1 | 2012-05-08 09:20:27 +0200 | [diff] [blame] | 228 | gpio_led_register_device(-1, &eukrea_mbimxsd51_led_info); |
| 229 | imx_add_gpio_keys(&eukrea_mbimxsd51_button_data); |
Fabio Estevam | da75c92 | 2012-09-22 12:27:31 -0300 | [diff] [blame] | 230 | imx_add_platform_device("eukrea_tlv320", 0, NULL, 0, NULL, 0); |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 231 | } |