Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * mach-imx27_visstrim_m10.c |
| 3 | * |
| 4 | * Copyright 2010 Javier Martin <javier.martin@vista-silicon.com> |
| 5 | * |
| 6 | * Based on mach-pcm038.c, mach-pca100.c, mach-mx27ads.c and others. |
| 7 | * |
| 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. |
| 12 | * |
| 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. |
| 17 | * |
| 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. |
| 22 | */ |
| 23 | |
| 24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 25 | |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/i2c/pca953x.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 30 | #include <linux/input.h> |
| 31 | #include <linux/gpio.h> |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 32 | #include <linux/delay.h> |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 33 | #include <sound/tlv320aic32x4.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/time.h> |
| 37 | #include <mach/common.h> |
Sascha Hauer | c0450df | 2011-05-09 18:29:00 +0200 | [diff] [blame] | 38 | #include <mach/iomux-mx27.h> |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 39 | |
| 40 | #include "devices-imx27.h" |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 41 | |
| 42 | #define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) |
| 43 | #define SDHC1_IRQ IRQ_GPIOB(25) |
| 44 | |
Uwe Kleine-König | 6c80ee5 | 2010-09-28 21:53:31 +0200 | [diff] [blame] | 45 | static const int visstrim_m10_pins[] __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 46 | /* UART1 (console) */ |
| 47 | PE12_PF_UART1_TXD, |
| 48 | PE13_PF_UART1_RXD, |
| 49 | PE14_PF_UART1_CTS, |
| 50 | PE15_PF_UART1_RTS, |
| 51 | /* FEC */ |
| 52 | PD0_AIN_FEC_TXD0, |
| 53 | PD1_AIN_FEC_TXD1, |
| 54 | PD2_AIN_FEC_TXD2, |
| 55 | PD3_AIN_FEC_TXD3, |
| 56 | PD4_AOUT_FEC_RX_ER, |
| 57 | PD5_AOUT_FEC_RXD1, |
| 58 | PD6_AOUT_FEC_RXD2, |
| 59 | PD7_AOUT_FEC_RXD3, |
| 60 | PD8_AF_FEC_MDIO, |
| 61 | PD9_AIN_FEC_MDC, |
| 62 | PD10_AOUT_FEC_CRS, |
| 63 | PD11_AOUT_FEC_TX_CLK, |
| 64 | PD12_AOUT_FEC_RXD0, |
| 65 | PD13_AOUT_FEC_RX_DV, |
| 66 | PD14_AOUT_FEC_RX_CLK, |
| 67 | PD15_AOUT_FEC_COL, |
| 68 | PD16_AIN_FEC_TX_ER, |
| 69 | PF23_AIN_FEC_TX_EN, |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 70 | /* SSI1 */ |
| 71 | PC20_PF_SSI1_FS, |
| 72 | PC21_PF_SSI1_RXD, |
| 73 | PC22_PF_SSI1_TXD, |
| 74 | PC23_PF_SSI1_CLK, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 75 | /* SDHC1 */ |
| 76 | PE18_PF_SD1_D0, |
| 77 | PE19_PF_SD1_D1, |
| 78 | PE20_PF_SD1_D2, |
| 79 | PE21_PF_SD1_D3, |
| 80 | PE22_PF_SD1_CMD, |
| 81 | PE23_PF_SD1_CLK, |
| 82 | /* Both I2Cs */ |
| 83 | PD17_PF_I2C_DATA, |
| 84 | PD18_PF_I2C_CLK, |
| 85 | PC5_PF_I2C2_SDA, |
| 86 | PC6_PF_I2C2_SCL, |
| 87 | /* USB OTG */ |
| 88 | OTG_PHY_CS_GPIO | GPIO_GPIO | GPIO_OUT, |
| 89 | PC9_PF_USBOTG_DATA0, |
| 90 | PC11_PF_USBOTG_DATA1, |
| 91 | PC10_PF_USBOTG_DATA2, |
| 92 | PC13_PF_USBOTG_DATA3, |
| 93 | PC12_PF_USBOTG_DATA4, |
| 94 | PC7_PF_USBOTG_DATA5, |
| 95 | PC8_PF_USBOTG_DATA6, |
| 96 | PE25_PF_USBOTG_DATA7, |
| 97 | PE24_PF_USBOTG_CLK, |
| 98 | PE2_PF_USBOTG_DIR, |
| 99 | PE0_PF_USBOTG_NXT, |
| 100 | PE1_PF_USBOTG_STP, |
| 101 | PB23_PF_USB_PWR, |
| 102 | PB24_PF_USB_OC, |
| 103 | }; |
| 104 | |
| 105 | /* GPIOs used as events for applications */ |
| 106 | static struct gpio_keys_button visstrim_gpio_keys[] = { |
| 107 | { |
| 108 | .type = EV_KEY, |
| 109 | .code = KEY_RESTART, |
| 110 | .gpio = (GPIO_PORTC + 15), |
| 111 | .desc = "Default config", |
| 112 | .active_low = 0, |
| 113 | .wakeup = 1, |
| 114 | }, |
| 115 | { |
| 116 | .type = EV_KEY, |
| 117 | .code = KEY_RECORD, |
| 118 | .gpio = (GPIO_PORTF + 14), |
| 119 | .desc = "Record", |
| 120 | .active_low = 0, |
| 121 | .wakeup = 1, |
| 122 | }, |
| 123 | { |
| 124 | .type = EV_KEY, |
| 125 | .code = KEY_STOP, |
| 126 | .gpio = (GPIO_PORTF + 13), |
| 127 | .desc = "Stop", |
| 128 | .active_low = 0, |
| 129 | .wakeup = 1, |
| 130 | } |
| 131 | }; |
| 132 | |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 133 | static const struct gpio_keys_platform_data |
| 134 | visstrim_gpio_keys_platform_data __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 135 | .buttons = visstrim_gpio_keys, |
| 136 | .nbuttons = ARRAY_SIZE(visstrim_gpio_keys), |
| 137 | }; |
| 138 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 139 | /* Visstrim_SM10 has a microSD slot connected to sdhc1 */ |
| 140 | static int visstrim_m10_sdhc1_init(struct device *dev, |
| 141 | irq_handler_t detect_irq, void *data) |
| 142 | { |
| 143 | int ret; |
| 144 | |
| 145 | ret = request_irq(SDHC1_IRQ, detect_irq, IRQF_TRIGGER_FALLING, |
| 146 | "mmc-detect", data); |
| 147 | return ret; |
| 148 | } |
| 149 | |
| 150 | static void visstrim_m10_sdhc1_exit(struct device *dev, void *data) |
| 151 | { |
| 152 | free_irq(SDHC1_IRQ, data); |
| 153 | } |
| 154 | |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 155 | static const struct imxmmc_platform_data visstrim_m10_sdhc_pdata __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 156 | .init = visstrim_m10_sdhc1_init, |
| 157 | .exit = visstrim_m10_sdhc1_exit, |
| 158 | }; |
| 159 | |
| 160 | /* Visstrim_SM10 NOR flash */ |
| 161 | static struct physmap_flash_data visstrim_m10_flash_data = { |
| 162 | .width = 2, |
| 163 | }; |
| 164 | |
| 165 | static struct resource visstrim_m10_flash_resource = { |
| 166 | .start = 0xc0000000, |
| 167 | .end = 0xc0000000 + SZ_64M - 1, |
| 168 | .flags = IORESOURCE_MEM, |
| 169 | }; |
| 170 | |
| 171 | static struct platform_device visstrim_m10_nor_mtd_device = { |
| 172 | .name = "physmap-flash", |
| 173 | .id = 0, |
| 174 | .dev = { |
| 175 | .platform_data = &visstrim_m10_flash_data, |
| 176 | }, |
| 177 | .num_resources = 1, |
| 178 | .resource = &visstrim_m10_flash_resource, |
| 179 | }; |
| 180 | |
| 181 | static struct platform_device *platform_devices[] __initdata = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 182 | &visstrim_m10_nor_mtd_device, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | /* Visstrim_M10 uses UART0 as console */ |
| 186 | static const struct imxuart_platform_data uart_pdata __initconst = { |
| 187 | .flags = IMXUART_HAVE_RTSCTS, |
| 188 | }; |
| 189 | |
| 190 | /* I2C */ |
| 191 | static const struct imxi2c_platform_data visstrim_m10_i2c_data __initconst = { |
| 192 | .bitrate = 100000, |
| 193 | }; |
| 194 | |
| 195 | static struct pca953x_platform_data visstrim_m10_pca9555_pdata = { |
| 196 | .gpio_base = 240, /* After MX27 internal GPIOs */ |
| 197 | .invert = 0, |
| 198 | }; |
| 199 | |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 200 | static struct aic32x4_pdata visstrim_m10_aic32x4_pdata = { |
| 201 | .power_cfg = AIC32X4_PWR_MICBIAS_2075_LDOIN | |
| 202 | AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE | |
| 203 | AIC32X4_PWR_AIC32X4_LDO_ENABLE | |
| 204 | AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 | |
| 205 | AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED, |
| 206 | .micpga_routing = AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K | |
| 207 | AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K, |
| 208 | .swapdacs = false, |
| 209 | }; |
| 210 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 211 | static struct i2c_board_info visstrim_m10_i2c_devices[] = { |
| 212 | { |
| 213 | I2C_BOARD_INFO("pca9555", 0x20), |
| 214 | .platform_data = &visstrim_m10_pca9555_pdata, |
| 215 | }, |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 216 | { |
| 217 | I2C_BOARD_INFO("tlv320aic32x4", 0x18), |
Javier Martin | c86566b | 2011-06-07 17:37:18 +0200 | [diff] [blame] | 218 | .platform_data = &visstrim_m10_aic32x4_pdata, |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 219 | } |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | /* USB OTG */ |
| 223 | static int otg_phy_init(struct platform_device *pdev) |
| 224 | { |
| 225 | gpio_set_value(OTG_PHY_CS_GPIO, 0); |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 226 | |
| 227 | mdelay(10); |
| 228 | |
| 229 | return mx27_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 230 | } |
| 231 | |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 232 | static const struct mxc_usbh_platform_data |
| 233 | visstrim_m10_usbotg_pdata __initconst = { |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 234 | .init = otg_phy_init, |
| 235 | .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 236 | }; |
| 237 | |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 238 | /* SSI */ |
| 239 | static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { |
| 240 | .flags = IMX_SSI_DMA | IMX_SSI_SYN, |
| 241 | }; |
| 242 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 243 | static void __init visstrim_m10_board_init(void) |
| 244 | { |
| 245 | int ret; |
| 246 | |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 247 | imx27_soc_init(); |
| 248 | |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 249 | ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins, |
| 250 | ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10"); |
| 251 | if (ret) |
| 252 | pr_err("Failed to setup pins (%d)\n", ret); |
| 253 | |
Javier Martin | a5e2051 | 2011-03-01 15:02:08 +0100 | [diff] [blame] | 254 | imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 255 | imx27_add_imx_uart0(&uart_pdata); |
| 256 | |
| 257 | i2c_register_board_info(0, visstrim_m10_i2c_devices, |
| 258 | ARRAY_SIZE(visstrim_m10_i2c_devices)); |
Uwe Kleine-König | 77a406d | 2010-08-25 12:19:50 +0200 | [diff] [blame] | 259 | imx27_add_imx_i2c(0, &visstrim_m10_i2c_data); |
| 260 | imx27_add_imx_i2c(1, &visstrim_m10_i2c_data); |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 261 | imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata); |
Uwe Kleine-König | 2eb42d5 | 2010-11-05 18:52:09 +0100 | [diff] [blame] | 262 | imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata); |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 263 | imx27_add_fec(NULL); |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 264 | imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 265 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
| 266 | } |
| 267 | |
| 268 | static void __init visstrim_m10_timer_init(void) |
| 269 | { |
| 270 | mx27_clocks_init((unsigned long)25000000); |
| 271 | } |
| 272 | |
| 273 | static struct sys_timer visstrim_m10_timer = { |
| 274 | .init = visstrim_m10_timer_init, |
| 275 | }; |
| 276 | |
| 277 | MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10") |
Nicolas Pitre | dc8f190 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 278 | .atag_offset = 0x100, |
Uwe Kleine-König | 3dac219 | 2011-02-07 16:35:19 +0100 | [diff] [blame] | 279 | .map_io = mx27_map_io, |
| 280 | .init_early = imx27_init_early, |
| 281 | .init_irq = mx27_init_irq, |
| 282 | .timer = &visstrim_m10_timer, |
| 283 | .init_machine = visstrim_m10_board_init, |
Javier Martin | 3b161e5 | 2010-07-30 10:06:01 +0200 | [diff] [blame] | 284 | MACHINE_END |