Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2010 Eric Bénard <eric@eukrea.com> |
| 4 | * |
| 5 | * The code contained herein is licensed under the GNU General Public |
| 6 | * License. You may obtain a copy of the GNU General Public License |
| 7 | * Version 2 or later at the following locations: |
| 8 | * |
| 9 | * http://www.opensource.org/licenses/gpl-license.html |
| 10 | * http://www.gnu.org/copyleft/gpl.html |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/serial_8250.h> |
| 16 | #include <linux/i2c.h> |
| 17 | #include <linux/gpio.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/irq.h> |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 21 | #include <linux/i2c/tsc2007.h> |
| 22 | #include <linux/leds.h> |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 23 | |
| 24 | #include <mach/common.h> |
| 25 | #include <mach/hardware.h> |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 26 | #include <mach/iomux-mx51.h> |
| 27 | |
| 28 | #include <asm/mach/arch.h> |
| 29 | |
Uwe Kleine-König | 04b73b15 | 2010-08-11 22:23:06 +0200 | [diff] [blame] | 30 | #include "devices-imx51.h" |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 31 | #include "devices.h" |
| 32 | |
Arnaud Patard (Rtp) | 96886c4 | 2010-11-26 15:20:52 +0100 | [diff] [blame] | 33 | #define MBIMX51_TSC2007_GPIO IMX_GPIO_NR(3, 30) |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 34 | #define MBIMX51_TSC2007_IRQ (MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO) |
Arnaud Patard (Rtp) | 96886c4 | 2010-11-26 15:20:52 +0100 | [diff] [blame] | 35 | #define MBIMX51_LED0 IMX_GPIO_NR(3, 5) |
| 36 | #define MBIMX51_LED1 IMX_GPIO_NR(3, 6) |
| 37 | #define MBIMX51_LED2 IMX_GPIO_NR(3, 7) |
| 38 | #define MBIMX51_LED3 IMX_GPIO_NR(3, 8) |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 39 | |
| 40 | static struct gpio_led mbimx51_leds[] = { |
| 41 | { |
| 42 | .name = "led0", |
| 43 | .default_trigger = "heartbeat", |
| 44 | .active_low = 1, |
| 45 | .gpio = MBIMX51_LED0, |
| 46 | }, |
| 47 | { |
| 48 | .name = "led1", |
| 49 | .default_trigger = "nand-disk", |
| 50 | .active_low = 1, |
| 51 | .gpio = MBIMX51_LED1, |
| 52 | }, |
| 53 | { |
| 54 | .name = "led2", |
| 55 | .default_trigger = "mmc0", |
| 56 | .active_low = 1, |
| 57 | .gpio = MBIMX51_LED2, |
| 58 | }, |
| 59 | { |
| 60 | .name = "led3", |
| 61 | .default_trigger = "default-on", |
| 62 | .active_low = 1, |
| 63 | .gpio = MBIMX51_LED3, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | static struct gpio_led_platform_data mbimx51_leds_info = { |
| 68 | .leds = mbimx51_leds, |
| 69 | .num_leds = ARRAY_SIZE(mbimx51_leds), |
| 70 | }; |
| 71 | |
| 72 | static struct platform_device mbimx51_leds_gpio = { |
| 73 | .name = "leds-gpio", |
| 74 | .id = -1, |
| 75 | .dev = { |
| 76 | .platform_data = &mbimx51_leds_info, |
| 77 | }, |
| 78 | }; |
| 79 | |
| 80 | static struct platform_device *devices[] __initdata = { |
| 81 | &mbimx51_leds_gpio, |
| 82 | }; |
| 83 | |
Lothar Waßmann | 8f5260c | 2010-10-26 14:28:31 +0200 | [diff] [blame] | 84 | static iomux_v3_cfg_t mbimx51_pads[] = { |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 85 | /* UART2 */ |
| 86 | MX51_PAD_UART2_RXD__UART2_RXD, |
| 87 | MX51_PAD_UART2_TXD__UART2_TXD, |
| 88 | |
| 89 | /* UART3 */ |
| 90 | MX51_PAD_UART3_RXD__UART3_RXD, |
| 91 | MX51_PAD_UART3_TXD__UART3_TXD, |
| 92 | MX51_PAD_KEY_COL4__UART3_RTS, |
| 93 | MX51_PAD_KEY_COL5__UART3_CTS, |
| 94 | |
| 95 | /* TSC2007 IRQ */ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 96 | MX51_PAD_NANDF_D10__GPIO3_30, |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 97 | |
| 98 | /* LEDS */ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 99 | MX51_PAD_DISPB2_SER_DIN__GPIO3_5, |
| 100 | MX51_PAD_DISPB2_SER_DIO__GPIO3_6, |
| 101 | MX51_PAD_DISPB2_SER_CLK__GPIO3_7, |
| 102 | MX51_PAD_DISPB2_SER_RS__GPIO3_8, |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 103 | |
| 104 | /* KPP */ |
| 105 | MX51_PAD_KEY_ROW0__KEY_ROW0, |
| 106 | MX51_PAD_KEY_ROW1__KEY_ROW1, |
| 107 | MX51_PAD_KEY_ROW2__KEY_ROW2, |
| 108 | MX51_PAD_KEY_ROW3__KEY_ROW3, |
| 109 | MX51_PAD_KEY_COL0__KEY_COL0, |
| 110 | MX51_PAD_KEY_COL1__KEY_COL1, |
| 111 | MX51_PAD_KEY_COL2__KEY_COL2, |
| 112 | MX51_PAD_KEY_COL3__KEY_COL3, |
Eric Bénard | a392741 | 2010-10-12 16:29:20 +0200 | [diff] [blame] | 113 | |
| 114 | /* SD 1 */ |
| 115 | MX51_PAD_SD1_CMD__SD1_CMD, |
| 116 | MX51_PAD_SD1_CLK__SD1_CLK, |
| 117 | MX51_PAD_SD1_DATA0__SD1_DATA0, |
| 118 | MX51_PAD_SD1_DATA1__SD1_DATA1, |
| 119 | MX51_PAD_SD1_DATA2__SD1_DATA2, |
| 120 | MX51_PAD_SD1_DATA3__SD1_DATA3, |
| 121 | |
| 122 | /* SD 2 */ |
| 123 | MX51_PAD_SD2_CMD__SD2_CMD, |
| 124 | MX51_PAD_SD2_CLK__SD2_CLK, |
| 125 | MX51_PAD_SD2_DATA0__SD2_DATA0, |
| 126 | MX51_PAD_SD2_DATA1__SD2_DATA1, |
| 127 | MX51_PAD_SD2_DATA2__SD2_DATA2, |
| 128 | MX51_PAD_SD2_DATA3__SD2_DATA3, |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
Uwe Kleine-König | 04b73b15 | 2010-08-11 22:23:06 +0200 | [diff] [blame] | 131 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 132 | .flags = IMXUART_HAVE_RTSCTS, |
| 133 | }; |
| 134 | |
| 135 | static int mbimx51_keymap[] = { |
| 136 | KEY(0, 0, KEY_1), |
| 137 | KEY(0, 1, KEY_2), |
| 138 | KEY(0, 2, KEY_3), |
| 139 | KEY(0, 3, KEY_UP), |
| 140 | |
| 141 | KEY(1, 0, KEY_4), |
| 142 | KEY(1, 1, KEY_5), |
| 143 | KEY(1, 2, KEY_6), |
| 144 | KEY(1, 3, KEY_LEFT), |
| 145 | |
| 146 | KEY(2, 0, KEY_7), |
| 147 | KEY(2, 1, KEY_8), |
| 148 | KEY(2, 2, KEY_9), |
| 149 | KEY(2, 3, KEY_RIGHT), |
| 150 | |
| 151 | KEY(3, 0, KEY_0), |
| 152 | KEY(3, 1, KEY_DOWN), |
| 153 | KEY(3, 2, KEY_ESC), |
| 154 | KEY(3, 3, KEY_ENTER), |
| 155 | }; |
| 156 | |
Fabio Estevam | a5fcfef | 2010-12-01 11:11:47 -0200 | [diff] [blame] | 157 | static const struct matrix_keymap_data mbimx51_map_data __initconst = { |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 158 | .keymap = mbimx51_keymap, |
| 159 | .keymap_size = ARRAY_SIZE(mbimx51_keymap), |
| 160 | }; |
| 161 | |
| 162 | static int tsc2007_get_pendown_state(void) |
| 163 | { |
| 164 | return !gpio_get_value(MBIMX51_TSC2007_GPIO); |
| 165 | } |
| 166 | |
| 167 | struct tsc2007_platform_data tsc2007_data = { |
| 168 | .model = 2007, |
| 169 | .x_plate_ohms = 180, |
| 170 | .get_pendown_state = tsc2007_get_pendown_state, |
| 171 | }; |
| 172 | |
| 173 | static struct i2c_board_info mbimx51_i2c_devices[] = { |
| 174 | { |
Eric Bénard | a392741 | 2010-10-12 16:29:20 +0200 | [diff] [blame] | 175 | I2C_BOARD_INFO("tsc2007", 0x49), |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 176 | .irq = MBIMX51_TSC2007_IRQ, |
| 177 | .platform_data = &tsc2007_data, |
Eric Bénard | a392741 | 2010-10-12 16:29:20 +0200 | [diff] [blame] | 178 | }, { |
| 179 | I2C_BOARD_INFO("tlv320aic23", 0x1a), |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 180 | }, |
| 181 | }; |
| 182 | |
| 183 | /* |
| 184 | * baseboard initialization. |
| 185 | */ |
| 186 | void __init eukrea_mbimx51_baseboard_init(void) |
| 187 | { |
| 188 | mxc_iomux_v3_setup_multiple_pads(mbimx51_pads, |
| 189 | ARRAY_SIZE(mbimx51_pads)); |
| 190 | |
Uwe Kleine-König | 04b73b15 | 2010-08-11 22:23:06 +0200 | [diff] [blame] | 191 | imx51_add_imx_uart(1, NULL); |
| 192 | imx51_add_imx_uart(2, &uart_pdata); |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 193 | |
| 194 | gpio_request(MBIMX51_LED0, "LED0"); |
| 195 | gpio_direction_output(MBIMX51_LED0, 1); |
| 196 | gpio_free(MBIMX51_LED0); |
| 197 | gpio_request(MBIMX51_LED1, "LED1"); |
| 198 | gpio_direction_output(MBIMX51_LED1, 1); |
| 199 | gpio_free(MBIMX51_LED1); |
| 200 | gpio_request(MBIMX51_LED2, "LED2"); |
| 201 | gpio_direction_output(MBIMX51_LED2, 1); |
| 202 | gpio_free(MBIMX51_LED2); |
| 203 | gpio_request(MBIMX51_LED3, "LED3"); |
| 204 | gpio_direction_output(MBIMX51_LED3, 1); |
| 205 | gpio_free(MBIMX51_LED3); |
| 206 | |
| 207 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 208 | |
Fabio Estevam | a5fcfef | 2010-12-01 11:11:47 -0200 | [diff] [blame] | 209 | imx51_add_imx_keypad(&mbimx51_map_data); |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 210 | |
| 211 | gpio_request(MBIMX51_TSC2007_GPIO, "tsc2007_irq"); |
| 212 | gpio_direction_input(MBIMX51_TSC2007_GPIO); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 213 | irq_set_irq_type(MBIMX51_TSC2007_IRQ, IRQF_TRIGGER_FALLING); |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 214 | i2c_register_board_info(1, mbimx51_i2c_devices, |
| 215 | ARRAY_SIZE(mbimx51_i2c_devices)); |
Eric Bénard | a392741 | 2010-10-12 16:29:20 +0200 | [diff] [blame] | 216 | |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 217 | imx51_add_sdhci_esdhc_imx(0, NULL); |
| 218 | imx51_add_sdhci_esdhc_imx(1, NULL); |
Eric Bénard | ef93f14 | 2010-07-23 16:11:19 +0200 | [diff] [blame] | 219 | } |