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> |
| 27 | #include <linux/irq.h> |
| 28 | #include <linux/leds.h> |
| 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/gpio_keys.h> |
| 31 | #include <linux/input.h> |
| 32 | #include <linux/i2c.h> |
| 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 | |
| 39 | #include <mach/hardware.h> |
| 40 | #include <mach/common.h> |
| 41 | #include <mach/imx-uart.h> |
| 42 | #include <mach/iomux-mx51.h> |
| 43 | #include <mach/audmux.h> |
| 44 | |
| 45 | #include "devices-imx51.h" |
| 46 | #include "devices.h" |
| 47 | |
| 48 | #define MBIMXSD_GPIO_3_31 IOMUX_PAD(0x554, 0x16C, 3, 0x0, 0, \ |
| 49 | MX51_PAD_CTRL_1 | PAD_CTL_PUS_22K_UP) |
| 50 | |
| 51 | static struct pad_desc eukrea_mbimxsd_pads[] = { |
| 52 | /* LED */ |
| 53 | MX51_PAD_NANDF_D10__GPIO_3_30, |
| 54 | /* SWITCH */ |
| 55 | MBIMXSD_GPIO_3_31, |
| 56 | /* UART2 */ |
| 57 | MX51_PAD_UART2_RXD__UART2_RXD, |
| 58 | MX51_PAD_UART2_TXD__UART2_TXD, |
| 59 | /* UART 3 */ |
| 60 | MX51_PAD_UART3_RXD__UART3_RXD, |
| 61 | MX51_PAD_UART3_TXD__UART3_TXD, |
| 62 | MX51_PAD_KEY_COL4__UART3_RTS, |
| 63 | MX51_PAD_KEY_COL5__UART3_CTS, |
| 64 | /* SD */ |
| 65 | MX51_PAD_SD1_CMD__SD1_CMD, |
| 66 | MX51_PAD_SD1_CLK__SD1_CLK, |
| 67 | MX51_PAD_SD1_DATA0__SD1_DATA0, |
| 68 | MX51_PAD_SD1_DATA1__SD1_DATA1, |
| 69 | MX51_PAD_SD1_DATA2__SD1_DATA2, |
| 70 | MX51_PAD_SD1_DATA3__SD1_DATA3, |
| 71 | }; |
| 72 | |
| 73 | #define GPIO_LED1 (2 * 32 + 30) |
| 74 | #define GPIO_SWITCH1 (2 * 32 + 31) |
| 75 | |
| 76 | static struct gpio_led eukrea_mbimxsd_leds[] = { |
| 77 | { |
| 78 | .name = "led1", |
| 79 | .default_trigger = "heartbeat", |
| 80 | .active_low = 1, |
| 81 | .gpio = GPIO_LED1, |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | static struct gpio_led_platform_data eukrea_mbimxsd_led_info = { |
| 86 | .leds = eukrea_mbimxsd_leds, |
| 87 | .num_leds = ARRAY_SIZE(eukrea_mbimxsd_leds), |
| 88 | }; |
| 89 | |
| 90 | static struct platform_device eukrea_mbimxsd_leds_gpio = { |
| 91 | .name = "leds-gpio", |
| 92 | .id = -1, |
| 93 | .dev = { |
| 94 | .platform_data = &eukrea_mbimxsd_led_info, |
| 95 | }, |
| 96 | }; |
| 97 | |
| 98 | static struct gpio_keys_button eukrea_mbimxsd_gpio_buttons[] = { |
| 99 | { |
| 100 | .gpio = GPIO_SWITCH1, |
| 101 | .code = BTN_0, |
| 102 | .desc = "BP1", |
| 103 | .active_low = 1, |
| 104 | .wakeup = 1, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct gpio_keys_platform_data eukrea_mbimxsd_button_data = { |
| 109 | .buttons = eukrea_mbimxsd_gpio_buttons, |
| 110 | .nbuttons = ARRAY_SIZE(eukrea_mbimxsd_gpio_buttons), |
| 111 | }; |
| 112 | |
| 113 | static struct platform_device eukrea_mbimxsd_button_device = { |
| 114 | .name = "gpio-keys", |
| 115 | .id = -1, |
| 116 | .num_resources = 0, |
| 117 | .dev = { |
| 118 | .platform_data = &eukrea_mbimxsd_button_data, |
| 119 | } |
| 120 | }; |
| 121 | |
| 122 | static struct platform_device *platform_devices[] __initdata = { |
| 123 | &eukrea_mbimxsd_leds_gpio, |
| 124 | &eukrea_mbimxsd_button_device, |
| 125 | }; |
| 126 | |
| 127 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 128 | .flags = IMXUART_HAVE_RTSCTS, |
| 129 | }; |
| 130 | |
| 131 | static struct i2c_board_info eukrea_mbimxsd_i2c_devices[] = { |
| 132 | { |
| 133 | I2C_BOARD_INFO("tlv320aic23", 0x1a), |
| 134 | }, |
| 135 | }; |
| 136 | |
| 137 | /* |
| 138 | * system init for baseboard usage. Will be called by cpuimx51sd init. |
| 139 | * |
| 140 | * Add platform devices present on this baseboard and init |
| 141 | * them from CPU side as far as required to use them later on |
| 142 | */ |
| 143 | void __init eukrea_mbimxsd51_baseboard_init(void) |
| 144 | { |
| 145 | if (mxc_iomux_v3_setup_multiple_pads(eukrea_mbimxsd_pads, |
| 146 | ARRAY_SIZE(eukrea_mbimxsd_pads))) |
| 147 | printk(KERN_ERR "error setting mbimxsd pads !\n"); |
| 148 | |
| 149 | imx51_add_imx_uart(1, NULL); |
| 150 | imx51_add_imx_uart(2, &uart_pdata); |
| 151 | |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 152 | imx51_add_sdhci_esdhc_imx(0, NULL); |
Eric Bénard | 70b1726 | 2010-10-12 16:12:36 +0200 | [diff] [blame] | 153 | |
| 154 | gpio_request(GPIO_LED1, "LED1"); |
| 155 | gpio_direction_output(GPIO_LED1, 1); |
| 156 | gpio_free(GPIO_LED1); |
| 157 | |
| 158 | gpio_request(GPIO_SWITCH1, "SWITCH1"); |
| 159 | gpio_direction_input(GPIO_SWITCH1); |
| 160 | gpio_free(GPIO_SWITCH1); |
| 161 | |
| 162 | i2c_register_board_info(0, eukrea_mbimxsd_i2c_devices, |
| 163 | ARRAY_SIZE(eukrea_mbimxsd_i2c_devices)); |
| 164 | |
| 165 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
| 166 | } |