Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Eric Benard - eric@eukrea.com |
| 3 | * Copyright (C) 2009 Sascha Hauer, Pengutronix |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | #include <linux/types.h> |
| 21 | #include <linux/init.h> |
| 22 | |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/mtd/physmap.h> |
| 25 | #include <linux/memory.h> |
| 26 | #include <linux/gpio.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/i2c.h> |
| 30 | #include <linux/i2c/tsc2007.h> |
| 31 | #include <linux/usb/otg.h> |
| 32 | #include <linux/usb/ulpi.h> |
Eric Bénard | 54dc3f4 | 2010-10-02 17:15:26 +0200 | [diff] [blame] | 33 | #include <linux/i2c-gpio.h> |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 34 | |
| 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | #include <asm/mach/time.h> |
| 38 | #include <asm/mach/map.h> |
| 39 | |
Eric Bénard | 95afd09 | 2010-07-23 14:56:40 +0200 | [diff] [blame] | 40 | #include <mach/eukrea-baseboards.h> |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 41 | #include <mach/hardware.h> |
| 42 | #include <mach/common.h> |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 43 | #include <mach/iomux-mx35.h> |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 44 | |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 45 | #include "devices-imx35.h" |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 46 | |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 47 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 48 | .flags = IMXUART_HAVE_RTSCTS, |
| 49 | }; |
| 50 | |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 51 | static const struct imxi2c_platform_data |
Eric Bénard | 54dc3f4 | 2010-10-02 17:15:26 +0200 | [diff] [blame] | 52 | eukrea_cpuimx35_i2c0_data __initconst = { |
| 53 | .bitrate = 100000, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 54 | }; |
| 55 | |
Eric Bénard | 4d4b256 | 2011-12-13 07:31:44 +0100 | [diff] [blame] | 56 | #define TSC2007_IRQGPIO IMX_GPIO_NR(3, 2) |
| 57 | static int tsc2007_get_pendown_state(void) |
| 58 | { |
| 59 | return !gpio_get_value(TSC2007_IRQGPIO); |
| 60 | } |
| 61 | |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 62 | static struct tsc2007_platform_data tsc2007_info = { |
| 63 | .model = 2007, |
| 64 | .x_plate_ohms = 180, |
Eric Bénard | 4d4b256 | 2011-12-13 07:31:44 +0100 | [diff] [blame] | 65 | .get_pendown_state = tsc2007_get_pendown_state, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | static struct i2c_board_info eukrea_cpuimx35_i2c_devices[] = { |
| 69 | { |
| 70 | I2C_BOARD_INFO("pcf8563", 0x51), |
| 71 | }, { |
| 72 | I2C_BOARD_INFO("tsc2007", 0x48), |
| 73 | .type = "tsc2007", |
| 74 | .platform_data = &tsc2007_info, |
Shawn Guo | e309fb1 | 2011-08-14 00:14:01 +0800 | [diff] [blame] | 75 | .irq = IMX_GPIO_TO_IRQ(TSC2007_IRQGPIO), |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 76 | }, |
| 77 | }; |
| 78 | |
Lothar Waßmann | 8f5260c | 2010-10-26 14:28:31 +0200 | [diff] [blame] | 79 | static iomux_v3_cfg_t eukrea_cpuimx35_pads[] = { |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 80 | /* UART1 */ |
| 81 | MX35_PAD_CTS1__UART1_CTS, |
| 82 | MX35_PAD_RTS1__UART1_RTS, |
| 83 | MX35_PAD_TXD1__UART1_TXD_MUX, |
| 84 | MX35_PAD_RXD1__UART1_RXD_MUX, |
| 85 | /* FEC */ |
| 86 | MX35_PAD_FEC_TX_CLK__FEC_TX_CLK, |
| 87 | MX35_PAD_FEC_RX_CLK__FEC_RX_CLK, |
| 88 | MX35_PAD_FEC_RX_DV__FEC_RX_DV, |
| 89 | MX35_PAD_FEC_COL__FEC_COL, |
| 90 | MX35_PAD_FEC_RDATA0__FEC_RDATA_0, |
| 91 | MX35_PAD_FEC_TDATA0__FEC_TDATA_0, |
| 92 | MX35_PAD_FEC_TX_EN__FEC_TX_EN, |
| 93 | MX35_PAD_FEC_MDC__FEC_MDC, |
| 94 | MX35_PAD_FEC_MDIO__FEC_MDIO, |
| 95 | MX35_PAD_FEC_TX_ERR__FEC_TX_ERR, |
| 96 | MX35_PAD_FEC_RX_ERR__FEC_RX_ERR, |
| 97 | MX35_PAD_FEC_CRS__FEC_CRS, |
| 98 | MX35_PAD_FEC_RDATA1__FEC_RDATA_1, |
| 99 | MX35_PAD_FEC_TDATA1__FEC_TDATA_1, |
| 100 | MX35_PAD_FEC_RDATA2__FEC_RDATA_2, |
| 101 | MX35_PAD_FEC_TDATA2__FEC_TDATA_2, |
| 102 | MX35_PAD_FEC_RDATA3__FEC_RDATA_3, |
| 103 | MX35_PAD_FEC_TDATA3__FEC_TDATA_3, |
| 104 | /* I2C1 */ |
| 105 | MX35_PAD_I2C1_CLK__I2C1_SCL, |
| 106 | MX35_PAD_I2C1_DAT__I2C1_SDA, |
| 107 | /* TSC2007 IRQ */ |
| 108 | MX35_PAD_ATA_DA2__GPIO3_2, |
| 109 | }; |
| 110 | |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 111 | static const struct mxc_nand_platform_data |
Eric Bénard | 54dc3f4 | 2010-10-02 17:15:26 +0200 | [diff] [blame] | 112 | eukrea_cpuimx35_nand_board_info __initconst = { |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 113 | .width = 1, |
| 114 | .hw_ecc = 1, |
| 115 | .flash_bbt = 1, |
| 116 | }; |
| 117 | |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 118 | static int eukrea_cpuimx35_otg_init(struct platform_device *pdev) |
| 119 | { |
| 120 | return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_DIFF_UNI); |
| 121 | } |
| 122 | |
Uwe Kleine-König | 2d58de2 | 2010-11-15 11:57:49 +0100 | [diff] [blame] | 123 | static const struct mxc_usbh_platform_data otg_pdata __initconst = { |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 124 | .init = eukrea_cpuimx35_otg_init, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 125 | .portsc = MXC_EHCI_MODE_UTMI, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 126 | }; |
| 127 | |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 128 | static int eukrea_cpuimx35_usbh1_init(struct platform_device *pdev) |
| 129 | { |
| 130 | return mx35_initialize_usb_hw(pdev->id, MXC_EHCI_INTERFACE_SINGLE_UNI | |
| 131 | MXC_EHCI_INTERNAL_PHY | MXC_EHCI_IPPUE_DOWN); |
| 132 | } |
| 133 | |
Uwe Kleine-König | 2d58de2 | 2010-11-15 11:57:49 +0100 | [diff] [blame] | 134 | static const struct mxc_usbh_platform_data usbh1_pdata __initconst = { |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 135 | .init = eukrea_cpuimx35_usbh1_init, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 136 | .portsc = MXC_EHCI_MODE_SERIAL, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 137 | }; |
| 138 | |
Uwe Kleine-König | 9e1dde3 | 2010-11-12 16:40:06 +0100 | [diff] [blame] | 139 | static const struct fsl_usb2_platform_data otg_device_pdata __initconst = { |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 140 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 141 | .phy_mode = FSL_USB2_PHY_UTMI, |
Eric Bénard | 69cb1ec | 2010-10-15 14:30:58 +0200 | [diff] [blame] | 142 | .workaround = FLS_USB2_WORKAROUND_ENGCM09152, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | static int otg_mode_host; |
| 146 | |
| 147 | static int __init eukrea_cpuimx35_otg_mode(char *options) |
| 148 | { |
| 149 | if (!strcmp(options, "host")) |
| 150 | otg_mode_host = 1; |
| 151 | else if (!strcmp(options, "device")) |
| 152 | otg_mode_host = 0; |
| 153 | else |
| 154 | pr_info("otg_mode neither \"host\" nor \"device\". " |
| 155 | "Defaulting to device\n"); |
| 156 | return 0; |
| 157 | } |
| 158 | __setup("otg_mode=", eukrea_cpuimx35_otg_mode); |
| 159 | |
| 160 | /* |
| 161 | * Board specific initialization. |
| 162 | */ |
Uwe Kleine-König | e134fb2 | 2011-02-11 10:23:19 +0100 | [diff] [blame] | 163 | static void __init eukrea_cpuimx35_init(void) |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 164 | { |
Shawn Guo | b78d8e5 | 2011-06-06 00:07:55 +0800 | [diff] [blame] | 165 | imx35_soc_init(); |
| 166 | |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 167 | mxc_iomux_v3_setup_multiple_pads(eukrea_cpuimx35_pads, |
| 168 | ARRAY_SIZE(eukrea_cpuimx35_pads)); |
| 169 | |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 170 | imx35_add_fec(NULL); |
Uwe Kleine-König | 742269e | 2010-11-15 15:28:45 +0100 | [diff] [blame] | 171 | imx35_add_imx2_wdt(NULL); |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 172 | |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 173 | imx35_add_imx_uart0(&uart_pdata); |
| 174 | imx35_add_mxc_nand(&eukrea_cpuimx35_nand_board_info); |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 175 | |
| 176 | i2c_register_board_info(0, eukrea_cpuimx35_i2c_devices, |
| 177 | ARRAY_SIZE(eukrea_cpuimx35_i2c_devices)); |
Uwe Kleine-König | 2dcf78c | 2010-06-30 12:16:24 +0200 | [diff] [blame] | 178 | imx35_add_imx_i2c0(&eukrea_cpuimx35_i2c0_data); |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 179 | |
Eric Bénard | 52d084f | 2010-10-05 18:02:30 +0200 | [diff] [blame] | 180 | if (otg_mode_host) |
Uwe Kleine-König | 2d58de2 | 2010-11-15 11:57:49 +0100 | [diff] [blame] | 181 | imx35_add_mxc_ehci_otg(&otg_pdata); |
Eric Bénard | 52d084f | 2010-10-05 18:02:30 +0200 | [diff] [blame] | 182 | else |
Uwe Kleine-König | 9e1dde3 | 2010-11-12 16:40:06 +0100 | [diff] [blame] | 183 | imx35_add_fsl_usb2_udc(&otg_device_pdata); |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 184 | |
Uwe Kleine-König | 2d58de2 | 2010-11-15 11:57:49 +0100 | [diff] [blame] | 185 | imx35_add_mxc_ehci_hs(&usbh1_pdata); |
Eric Bénard | 52d084f | 2010-10-05 18:02:30 +0200 | [diff] [blame] | 186 | |
Eric Bénard | ec53fe3 | 2010-07-30 22:58:40 +0200 | [diff] [blame] | 187 | #ifdef CONFIG_MACH_EUKREA_MBIMXSD35_BASEBOARD |
| 188 | eukrea_mbimxsd35_baseboard_init(); |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 189 | #endif |
| 190 | } |
| 191 | |
| 192 | static void __init eukrea_cpuimx35_timer_init(void) |
| 193 | { |
| 194 | mx35_clocks_init(); |
| 195 | } |
| 196 | |
| 197 | struct sys_timer eukrea_cpuimx35_timer = { |
| 198 | .init = eukrea_cpuimx35_timer_init, |
| 199 | }; |
| 200 | |
Eric Bénard | 0d6cfa3 | 2011-08-22 15:41:46 +0100 | [diff] [blame] | 201 | MACHINE_START(EUKREA_CPUIMX35SD, "Eukrea CPUIMX35") |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 202 | /* Maintainer: Eukrea Electromatique */ |
Nicolas Pitre | dc8f190 | 2011-07-05 22:38:12 -0400 | [diff] [blame] | 203 | .atag_offset = 0x100, |
Uwe Kleine-König | 97976e2 | 2011-02-07 16:35:20 +0100 | [diff] [blame] | 204 | .map_io = mx35_map_io, |
Uwe Kleine-König | 3fc6b60 | 2011-03-01 21:30:58 +0100 | [diff] [blame] | 205 | .init_early = imx35_init_early, |
Uwe Kleine-König | 97976e2 | 2011-02-07 16:35:20 +0100 | [diff] [blame] | 206 | .init_irq = mx35_init_irq, |
Sascha Hauer | ffa2ea3 | 2011-09-20 14:31:24 +0200 | [diff] [blame] | 207 | .handle_irq = imx35_handle_irq, |
Uwe Kleine-König | 97976e2 | 2011-02-07 16:35:20 +0100 | [diff] [blame] | 208 | .timer = &eukrea_cpuimx35_timer, |
Uwe Kleine-König | e134fb2 | 2011-02-11 10:23:19 +0100 | [diff] [blame] | 209 | .init_machine = eukrea_cpuimx35_init, |
Russell King | 65ea788 | 2011-11-06 17:12:08 +0000 | [diff] [blame] | 210 | .restart = mxc_restart, |
Eric Bénard | 21744f1 | 2010-06-10 16:07:50 +0200 | [diff] [blame] | 211 | MACHINE_END |