regulator, mc13xxx: Remove pointless test for unsigned less than zero
[zen-stable.git] / arch / arm / mach-imx / mach-imx27_visstrim_m10.c
blob40a3666ea6324ad2f39992fb4f48f72b3b445766
1 /*
2 * mach-imx27_visstrim_m10.c
4 * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com>
6 * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
24 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
26 #include <linux/platform_device.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/i2c.h>
29 #include <linux/i2c/pca953x.h>
30 #include <linux/gpio_keys.h>
31 #include <linux/input.h>
32 #include <linux/gpio.h>
33 #include <asm/mach-types.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/time.h>
36 #include <mach/common.h>
37 #include <mach/iomux.h>
39 #include "devices-imx27.h"
41 #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
42 #define SDHC1_IRQ IRQ_GPIOB(25)
44 static const int visstrim_m10_pins[] __initconst = {
45 /* UART1 (console) */
46 PE12_PF_UART1_TXD,
47 PE13_PF_UART1_RXD,
48 PE14_PF_UART1_CTS,
49 PE15_PF_UART1_RTS,
50 /* FEC */
51 PD0_AIN_FEC_TXD0,
52 PD1_AIN_FEC_TXD1,
53 PD2_AIN_FEC_TXD2,
54 PD3_AIN_FEC_TXD3,
55 PD4_AOUT_FEC_RX_ER,
56 PD5_AOUT_FEC_RXD1,
57 PD6_AOUT_FEC_RXD2,
58 PD7_AOUT_FEC_RXD3,
59 PD8_AF_FEC_MDIO,
60 PD9_AIN_FEC_MDC,
61 PD10_AOUT_FEC_CRS,
62 PD11_AOUT_FEC_TX_CLK,
63 PD12_AOUT_FEC_RXD0,
64 PD13_AOUT_FEC_RX_DV,
65 PD14_AOUT_FEC_RX_CLK,
66 PD15_AOUT_FEC_COL,
67 PD16_AIN_FEC_TX_ER,
68 PF23_AIN_FEC_TX_EN,
69 /* SDHC1 */
70 PE18_PF_SD1_D0,
71 PE19_PF_SD1_D1,
72 PE20_PF_SD1_D2,
73 PE21_PF_SD1_D3,
74 PE22_PF_SD1_CMD,
75 PE23_PF_SD1_CLK,
76 /* Both I2Cs */
77 PD17_PF_I2C_DATA,
78 PD18_PF_I2C_CLK,
79 PC5_PF_I2C2_SDA,
80 PC6_PF_I2C2_SCL,
81 /* USB OTG */
82 OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT,
83 PC9_PF_USBOTG_DATA0,
84 PC11_PF_USBOTG_DATA1,
85 PC10_PF_USBOTG_DATA2,
86 PC13_PF_USBOTG_DATA3,
87 PC12_PF_USBOTG_DATA4,
88 PC7_PF_USBOTG_DATA5,
89 PC8_PF_USBOTG_DATA6,
90 PE25_PF_USBOTG_DATA7,
91 PE24_PF_USBOTG_CLK,
92 PE2_PF_USBOTG_DIR,
93 PE0_PF_USBOTG_NXT,
94 PE1_PF_USBOTG_STP,
95 PB23_PF_USB_PWR,
96 PB24_PF_USB_OC,
99 /* GPIOs used as events for applications */
100 static struct gpio_keys_button visstrim_gpio_keys[] = {
102 .type = EV_KEY,
103 .code = KEY_RESTART,
104 .gpio = (GPIO_PORTC + 15),
105 .desc = "Default config",
106 .active_low = 0,
107 .wakeup = 1,
110 .type = EV_KEY,
111 .code = KEY_RECORD,
112 .gpio = (GPIO_PORTF + 14),
113 .desc = "Record",
114 .active_low = 0,
115 .wakeup = 1,
118 .type = EV_KEY,
119 .code = KEY_STOP,
120 .gpio = (GPIO_PORTF + 13),
121 .desc = "Stop",
122 .active_low = 0,
123 .wakeup = 1,
127 static struct gpio_keys_platform_data visstrim_gpio_keys_platform_data = {
128 .buttons = visstrim_gpio_keys,
129 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
132 static struct platform_device visstrim_gpio_keys_device = {
133 .name = "gpio-keys",
134 .id = -1,
135 .dev = {
136 .platform_data = &visstrim_gpio_keys_platform_data,
140 /* Visstrim_SM10 has a microSD slot connected to sdhc1 */
141 static int visstrim_m10_sdhc1_init(struct device *dev,
142 irq_handler_t detect_irq, void *data)
144 int ret;
146 ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING,
147 "mmc-detect", data);
148 return ret;
151 static void visstrim_m10_sdhc1_exit(struct device *dev, void *data)
153 free_irq(SDHC1_IRQ, data);
156 static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = {
157 .init = visstrim_m10_sdhc1_init,
158 .exit = visstrim_m10_sdhc1_exit,
161 /* Visstrim_SM10 NOR flash */
162 static struct physmap_flash_data visstrim_m10_flash_data = {
163 .width = 2,
166 static struct resource visstrim_m10_flash_resource = {
167 .start = 0xc0000000,
168 .end = 0xc0000000 + SZ_64M - 1,
169 .flags = IORESOURCE_MEM,
172 static struct platform_device visstrim_m10_nor_mtd_device = {
173 .name = "physmap-flash",
174 .id = 0,
175 .dev = {
176 .platform_data = &visstrim_m10_flash_data,
178 .num_resources = 1,
179 .resource = &visstrim_m10_flash_resource,
182 static struct platform_device *platform_devices[] __initdata = {
183 &visstrim_gpio_keys_device,
184 &visstrim_m10_nor_mtd_device,
187 /* Visstrim_M10 uses UART0 as console */
188 static const struct imxuart_platform_data uart_pdata __initconst = {
189 .flags = IMXUART_HAVE_RTSCTS,
192 /* I2C */
193 static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = {
194 .bitrate = 100000,
197 static struct pca953x_platform_data visstrim_m10_pca9555_pdata = {
198 .gpio_base = 240, /* After MX27 internal GPIOs */
199 .invert = 0,
202 static struct i2c_board_info visstrim_m10_i2c_devices[] = {
204 I2C_BOARD_INFO("pca9555", 0x20),
205 .platform_data = &visstrim_m10_pca9555_pdata,
209 /* USB OTG */
210 static int otg_phy_init(struct platform_device *pdev)
212 gpio_set_value(OTG_PHY_CS_GPIO, 0);
213 return 0;
216 static const struct mxc_usbh_platform_data
217 visstrim_m10_usbotg_pdata __initconst = {
218 .init = otg_phy_init,
219 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
220 .flags = MXC_EHCI_POWER_PINS_ENABLED,
223 static void __init visstrim_m10_board_init(void)
225 int ret;
227 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
228 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");
229 if (ret)
230 pr_err("Failed to setup pins (%d)\n", ret);
232 imx27_add_imx_uart0(&uart_pdata);
234 i2c_register_board_info(0, visstrim_m10_i2c_devices,
235 ARRAY_SIZE(visstrim_m10_i2c_devices));
236 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
237 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
238 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
239 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
240 imx27_add_fec(NULL);
241 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
244 static void __init visstrim_m10_timer_init(void)
246 mx27_clocks_init((unsigned long)25000000);
249 static struct sys_timer visstrim_m10_timer = {
250 .init = visstrim_m10_timer_init,
253 MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
254 .boot_params = MX27_PHYS_OFFSET + 0x100,
255 .map_io = mx27_map_io,
256 .init_irq = mx27_init_irq,
257 .init_machine = visstrim_m10_board_init,
258 .timer = &visstrim_m10_timer,
259 MACHINE_END