Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 1 | /* |
Yong Shen | 64f102b | 2010-10-21 21:18:59 +0800 | [diff] [blame] | 2 | * Copyright 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved. |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 3 | * Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.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> |
Dinh Nguyen | f00b771 | 2010-05-27 10:45:05 -0500 | [diff] [blame] | 15 | #include <linux/i2c.h> |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 16 | #include <linux/gpio.h> |
| 17 | #include <linux/delay.h> |
| 18 | #include <linux/io.h> |
Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 19 | #include <linux/fsl_devices.h> |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 20 | #include <linux/fec.h> |
Dinh Nguyen | f2d36ecb | 2010-10-23 09:12:47 -0500 | [diff] [blame] | 21 | #include <linux/gpio_keys.h> |
| 22 | #include <linux/input.h> |
Fabio Estevam | 374daa4 | 2010-11-10 07:00:02 -0800 | [diff] [blame] | 23 | #include <linux/spi/flash.h> |
| 24 | #include <linux/spi/spi.h> |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 25 | |
| 26 | #include <mach/common.h> |
| 27 | #include <mach/hardware.h> |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 28 | #include <mach/iomux-mx51.h> |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 29 | #include <mach/mxc_ehci.h> |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 30 | |
| 31 | #include <asm/irq.h> |
| 32 | #include <asm/setup.h> |
| 33 | #include <asm/mach-types.h> |
| 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/time.h> |
| 36 | |
Uwe Kleine-König | 04b73b1 | 2010-08-11 22:23:06 +0200 | [diff] [blame] | 37 | #include "devices-imx51.h" |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 38 | #include "devices.h" |
Yong Shen | 64f102b | 2010-10-21 21:18:59 +0800 | [diff] [blame] | 39 | #include "cpu_op-mx51.h" |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 40 | |
Arnaud Patard (Rtp) | 96886c4 | 2010-11-26 15:20:52 +0100 | [diff] [blame] | 41 | #define BABBAGE_USB_HUB_RESET IMX_GPIO_NR(1, 7) |
| 42 | #define BABBAGE_USBH1_STP IMX_GPIO_NR(1, 27) |
| 43 | #define BABBAGE_PHY_RESET IMX_GPIO_NR(2, 5) |
| 44 | #define BABBAGE_FEC_PHY_RESET IMX_GPIO_NR(2, 14) |
| 45 | #define BABBAGE_POWER_KEY IMX_GPIO_NR(2, 21) |
| 46 | #define BABBAGE_ECSPI1_CS0 IMX_GPIO_NR(4, 24) |
| 47 | #define BABBAGE_ECSPI1_CS1 IMX_GPIO_NR(4, 25) |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 48 | |
| 49 | /* USB_CTRL_1 */ |
| 50 | #define MX51_USB_CTRL_1_OFFSET 0x10 |
| 51 | #define MX51_USB_CTRL_UH1_EXT_CLK_EN (1 << 25) |
| 52 | |
| 53 | #define MX51_USB_PLLDIV_12_MHZ 0x00 |
| 54 | #define MX51_USB_PLL_DIV_19_2_MHZ 0x01 |
| 55 | #define MX51_USB_PLL_DIV_24_MHZ 0x02 |
| 56 | |
Dinh Nguyen | f2d36ecb | 2010-10-23 09:12:47 -0500 | [diff] [blame] | 57 | static struct gpio_keys_button babbage_buttons[] = { |
| 58 | { |
| 59 | .gpio = BABBAGE_POWER_KEY, |
| 60 | .code = BTN_0, |
| 61 | .desc = "PWR", |
| 62 | .active_low = 1, |
| 63 | .wakeup = 1, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | static const struct gpio_keys_platform_data imx_button_data __initconst = { |
| 68 | .buttons = babbage_buttons, |
| 69 | .nbuttons = ARRAY_SIZE(babbage_buttons), |
| 70 | }; |
| 71 | |
Lothar Waßmann | 8f5260c | 2010-10-26 14:28:31 +0200 | [diff] [blame] | 72 | static iomux_v3_cfg_t mx51babbage_pads[] = { |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 73 | /* UART1 */ |
| 74 | MX51_PAD_UART1_RXD__UART1_RXD, |
| 75 | MX51_PAD_UART1_TXD__UART1_TXD, |
| 76 | MX51_PAD_UART1_RTS__UART1_RTS, |
| 77 | MX51_PAD_UART1_CTS__UART1_CTS, |
| 78 | |
| 79 | /* UART2 */ |
| 80 | MX51_PAD_UART2_RXD__UART2_RXD, |
| 81 | MX51_PAD_UART2_TXD__UART2_TXD, |
| 82 | |
| 83 | /* UART3 */ |
| 84 | MX51_PAD_EIM_D25__UART3_RXD, |
| 85 | MX51_PAD_EIM_D26__UART3_TXD, |
| 86 | MX51_PAD_EIM_D27__UART3_RTS, |
| 87 | MX51_PAD_EIM_D24__UART3_CTS, |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 88 | |
Dinh Nguyen | f00b771 | 2010-05-27 10:45:05 -0500 | [diff] [blame] | 89 | /* I2C1 */ |
| 90 | MX51_PAD_EIM_D16__I2C1_SDA, |
| 91 | MX51_PAD_EIM_D19__I2C1_SCL, |
| 92 | |
| 93 | /* I2C2 */ |
| 94 | MX51_PAD_KEY_COL4__I2C2_SCL, |
| 95 | MX51_PAD_KEY_COL5__I2C2_SDA, |
| 96 | |
| 97 | /* HSI2C */ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 98 | MX51_PAD_I2C1_CLK__I2C1_CLK, |
| 99 | MX51_PAD_I2C1_DAT__I2C1_DAT, |
Dinh Nguyen | f00b771 | 2010-05-27 10:45:05 -0500 | [diff] [blame] | 100 | |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 101 | /* USB HOST1 */ |
| 102 | MX51_PAD_USBH1_CLK__USBH1_CLK, |
| 103 | MX51_PAD_USBH1_DIR__USBH1_DIR, |
| 104 | MX51_PAD_USBH1_NXT__USBH1_NXT, |
| 105 | MX51_PAD_USBH1_DATA0__USBH1_DATA0, |
| 106 | MX51_PAD_USBH1_DATA1__USBH1_DATA1, |
| 107 | MX51_PAD_USBH1_DATA2__USBH1_DATA2, |
| 108 | MX51_PAD_USBH1_DATA3__USBH1_DATA3, |
| 109 | MX51_PAD_USBH1_DATA4__USBH1_DATA4, |
| 110 | MX51_PAD_USBH1_DATA5__USBH1_DATA5, |
| 111 | MX51_PAD_USBH1_DATA6__USBH1_DATA6, |
| 112 | MX51_PAD_USBH1_DATA7__USBH1_DATA7, |
| 113 | |
| 114 | /* USB HUB reset line*/ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 115 | MX51_PAD_GPIO1_7__GPIO1_7, |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 116 | |
| 117 | /* FEC */ |
| 118 | MX51_PAD_EIM_EB2__FEC_MDIO, |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 119 | MX51_PAD_EIM_EB3__FEC_RDATA1, |
| 120 | MX51_PAD_EIM_CS2__FEC_RDATA2, |
| 121 | MX51_PAD_EIM_CS3__FEC_RDATA3, |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 122 | MX51_PAD_EIM_CS4__FEC_RX_ER, |
| 123 | MX51_PAD_EIM_CS5__FEC_CRS, |
| 124 | MX51_PAD_NANDF_RB2__FEC_COL, |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 125 | MX51_PAD_NANDF_RB3__FEC_RX_CLK, |
| 126 | MX51_PAD_NANDF_D9__FEC_RDATA0, |
| 127 | MX51_PAD_NANDF_D8__FEC_TDATA0, |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 128 | MX51_PAD_NANDF_CS2__FEC_TX_ER, |
| 129 | MX51_PAD_NANDF_CS3__FEC_MDC, |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 130 | MX51_PAD_NANDF_CS4__FEC_TDATA1, |
| 131 | MX51_PAD_NANDF_CS5__FEC_TDATA2, |
| 132 | MX51_PAD_NANDF_CS6__FEC_TDATA3, |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 133 | MX51_PAD_NANDF_CS7__FEC_TX_EN, |
| 134 | MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK, |
| 135 | |
| 136 | /* FEC PHY reset line */ |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 137 | MX51_PAD_EIM_A20__GPIO2_14, |
Shawn Guo | 7223066 | 2010-10-22 00:55:20 +0800 | [diff] [blame] | 138 | |
| 139 | /* SD 1 */ |
| 140 | MX51_PAD_SD1_CMD__SD1_CMD, |
| 141 | MX51_PAD_SD1_CLK__SD1_CLK, |
| 142 | MX51_PAD_SD1_DATA0__SD1_DATA0, |
| 143 | MX51_PAD_SD1_DATA1__SD1_DATA1, |
| 144 | MX51_PAD_SD1_DATA2__SD1_DATA2, |
| 145 | MX51_PAD_SD1_DATA3__SD1_DATA3, |
| 146 | |
| 147 | /* SD 2 */ |
| 148 | MX51_PAD_SD2_CMD__SD2_CMD, |
| 149 | MX51_PAD_SD2_CLK__SD2_CLK, |
| 150 | MX51_PAD_SD2_DATA0__SD2_DATA0, |
| 151 | MX51_PAD_SD2_DATA1__SD2_DATA1, |
| 152 | MX51_PAD_SD2_DATA2__SD2_DATA2, |
| 153 | MX51_PAD_SD2_DATA3__SD2_DATA3, |
Fabio Estevam | 374daa4 | 2010-11-10 07:00:02 -0800 | [diff] [blame] | 154 | |
| 155 | /* eCSPI1 */ |
| 156 | MX51_PAD_CSPI1_MISO__ECSPI1_MISO, |
| 157 | MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, |
| 158 | MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 159 | MX51_PAD_CSPI1_SS0__GPIO4_24, |
| 160 | MX51_PAD_CSPI1_SS1__GPIO4_25, |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | /* Serial ports */ |
Uwe Kleine-König | 04b73b1 | 2010-08-11 22:23:06 +0200 | [diff] [blame] | 164 | static const struct imxuart_platform_data uart_pdata __initconst = { |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 165 | .flags = IMXUART_HAVE_RTSCTS, |
| 166 | }; |
| 167 | |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 168 | static const struct imxi2c_platform_data babbage_i2c_data __initconst = { |
Dinh Nguyen | f00b771 | 2010-05-27 10:45:05 -0500 | [diff] [blame] | 169 | .bitrate = 100000, |
| 170 | }; |
| 171 | |
| 172 | static struct imxi2c_platform_data babbage_hsi2c_data = { |
| 173 | .bitrate = 400000, |
| 174 | }; |
| 175 | |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 176 | static int gpio_usbh1_active(void) |
| 177 | { |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 178 | iomux_v3_cfg_t usbh1stp_gpio = MX51_PAD_USBH1_STP__GPIO1_27; |
| 179 | iomux_v3_cfg_t phyreset_gpio = MX51_PAD_EIM_D21__GPIO2_5; |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 180 | int ret; |
| 181 | |
| 182 | /* Set USBH1_STP to GPIO and toggle it */ |
Lothar Waßmann | 96f3e25 | 2010-11-22 09:39:51 +0100 | [diff] [blame] | 183 | mxc_iomux_v3_setup_pad(usbh1stp_gpio); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 184 | ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp"); |
| 185 | |
| 186 | if (ret) { |
| 187 | pr_debug("failed to get MX51_PAD_USBH1_STP__GPIO_1_27: %d\n", ret); |
| 188 | return ret; |
| 189 | } |
| 190 | gpio_direction_output(BABBAGE_USBH1_STP, 0); |
| 191 | gpio_set_value(BABBAGE_USBH1_STP, 1); |
| 192 | msleep(100); |
| 193 | gpio_free(BABBAGE_USBH1_STP); |
Dinh Nguyen | d6b273b | 2010-05-17 10:46:01 -0500 | [diff] [blame] | 194 | |
| 195 | /* De-assert USB PHY RESETB */ |
Lothar Waßmann | 96f3e25 | 2010-11-22 09:39:51 +0100 | [diff] [blame] | 196 | mxc_iomux_v3_setup_pad(phyreset_gpio); |
Dinh Nguyen | d6b273b | 2010-05-17 10:46:01 -0500 | [diff] [blame] | 197 | ret = gpio_request(BABBAGE_PHY_RESET, "phy_reset"); |
| 198 | |
| 199 | if (ret) { |
| 200 | pr_debug("failed to get MX51_PAD_EIM_D21__GPIO_2_5: %d\n", ret); |
| 201 | return ret; |
| 202 | } |
| 203 | gpio_direction_output(BABBAGE_PHY_RESET, 1); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | static inline void babbage_usbhub_reset(void) |
| 208 | { |
| 209 | int ret; |
| 210 | |
| 211 | /* Bring USB hub out of reset */ |
| 212 | ret = gpio_request(BABBAGE_USB_HUB_RESET, "GPIO1_7"); |
| 213 | if (ret) { |
| 214 | printk(KERN_ERR"failed to get GPIO_USB_HUB_RESET: %d\n", ret); |
| 215 | return; |
| 216 | } |
| 217 | gpio_direction_output(BABBAGE_USB_HUB_RESET, 0); |
| 218 | |
| 219 | /* USB HUB RESET - De-assert USB HUB RESET_N */ |
| 220 | msleep(1); |
| 221 | gpio_set_value(BABBAGE_USB_HUB_RESET, 0); |
| 222 | msleep(1); |
| 223 | gpio_set_value(BABBAGE_USB_HUB_RESET, 1); |
| 224 | } |
| 225 | |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 226 | static inline void babbage_fec_reset(void) |
| 227 | { |
| 228 | int ret; |
| 229 | |
| 230 | /* reset FEC PHY */ |
Fabio Estevam | ce191e4 | 2011-03-16 22:52:31 -0300 | [diff] [blame] | 231 | ret = gpio_request_one(BABBAGE_FEC_PHY_RESET, |
| 232 | GPIOF_OUT_INIT_LOW, "fec-phy-reset"); |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 233 | if (ret) { |
| 234 | printk(KERN_ERR"failed to get GPIO_FEC_PHY_RESET: %d\n", ret); |
| 235 | return; |
| 236 | } |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 237 | msleep(1); |
| 238 | gpio_set_value(BABBAGE_FEC_PHY_RESET, 1); |
| 239 | } |
| 240 | |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 241 | /* This function is board specific as the bit mask for the plldiv will also |
| 242 | be different for other Freescale SoCs, thus a common bitmask is not |
| 243 | possible and cannot get place in /plat-mxc/ehci.c.*/ |
| 244 | static int initialize_otg_port(struct platform_device *pdev) |
| 245 | { |
| 246 | u32 v; |
| 247 | void __iomem *usb_base; |
Sascha Hauer | e7a895b | 2010-08-19 11:37:31 +0200 | [diff] [blame] | 248 | void __iomem *usbother_base; |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 249 | |
| 250 | usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); |
Fabio Estevam | 28a4f90 | 2010-12-13 10:47:05 -0200 | [diff] [blame] | 251 | if (!usb_base) |
| 252 | return -ENOMEM; |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 253 | usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET; |
| 254 | |
| 255 | /* Set the PHY clock to 19.2MHz */ |
| 256 | v = __raw_readl(usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET); |
| 257 | v &= ~MX5_USB_UTMI_PHYCTRL1_PLLDIV_MASK; |
| 258 | v |= MX51_USB_PLL_DIV_19_2_MHZ; |
| 259 | __raw_writel(v, usbother_base + MXC_USB_PHY_CTR_FUNC2_OFFSET); |
| 260 | iounmap(usb_base); |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 261 | |
| 262 | mdelay(10); |
| 263 | |
| 264 | return mx51_initialize_usb_hw(0, MXC_EHCI_INTERNAL_PHY); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | static int initialize_usbh1_port(struct platform_device *pdev) |
| 268 | { |
| 269 | u32 v; |
| 270 | void __iomem *usb_base; |
Sascha Hauer | e7a895b | 2010-08-19 11:37:31 +0200 | [diff] [blame] | 271 | void __iomem *usbother_base; |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 272 | |
| 273 | usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); |
Fabio Estevam | 28a4f90 | 2010-12-13 10:47:05 -0200 | [diff] [blame] | 274 | if (!usb_base) |
| 275 | return -ENOMEM; |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 276 | usbother_base = usb_base + MX5_USBOTHER_REGS_OFFSET; |
| 277 | |
| 278 | /* The clock for the USBH1 ULPI port will come externally from the PHY. */ |
| 279 | v = __raw_readl(usbother_base + MX51_USB_CTRL_1_OFFSET); |
| 280 | __raw_writel(v | MX51_USB_CTRL_UH1_EXT_CLK_EN, usbother_base + MX51_USB_CTRL_1_OFFSET); |
| 281 | iounmap(usb_base); |
Sascha Hauer | 4bd597b | 2011-01-03 11:30:28 +0100 | [diff] [blame] | 282 | |
| 283 | mdelay(10); |
| 284 | |
| 285 | return mx51_initialize_usb_hw(1, MXC_EHCI_POWER_PINS_ENABLED | |
| 286 | MXC_EHCI_ITC_NO_THRESHOLD); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | static struct mxc_usbh_platform_data dr_utmi_config = { |
| 290 | .init = initialize_otg_port, |
| 291 | .portsc = MXC_EHCI_UTMI_16BIT, |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 292 | }; |
| 293 | |
Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 294 | static struct fsl_usb2_platform_data usb_pdata = { |
| 295 | .operating_mode = FSL_USB2_DR_DEVICE, |
| 296 | .phy_mode = FSL_USB2_PHY_UTMI_WIDE, |
| 297 | }; |
| 298 | |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 299 | static struct mxc_usbh_platform_data usbh1_config = { |
| 300 | .init = initialize_usbh1_port, |
| 301 | .portsc = MXC_EHCI_MODE_ULPI, |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 302 | }; |
| 303 | |
Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 304 | static int otg_mode_host; |
| 305 | |
| 306 | static int __init babbage_otg_mode(char *options) |
| 307 | { |
| 308 | if (!strcmp(options, "host")) |
| 309 | otg_mode_host = 1; |
| 310 | else if (!strcmp(options, "device")) |
| 311 | otg_mode_host = 0; |
| 312 | else |
| 313 | pr_info("otg_mode neither \"host\" nor \"device\". " |
| 314 | "Defaulting to device\n"); |
| 315 | return 0; |
| 316 | } |
| 317 | __setup("otg_mode=", babbage_otg_mode); |
| 318 | |
Fabio Estevam | 374daa4 | 2010-11-10 07:00:02 -0800 | [diff] [blame] | 319 | static struct spi_board_info mx51_babbage_spi_board_info[] __initdata = { |
| 320 | { |
| 321 | .modalias = "mtd_dataflash", |
| 322 | .max_speed_hz = 25000000, |
| 323 | .bus_num = 0, |
| 324 | .chip_select = 1, |
| 325 | .mode = SPI_MODE_0, |
| 326 | .platform_data = NULL, |
| 327 | }, |
| 328 | }; |
| 329 | |
| 330 | static int mx51_babbage_spi_cs[] = { |
| 331 | BABBAGE_ECSPI1_CS0, |
| 332 | BABBAGE_ECSPI1_CS1, |
| 333 | }; |
| 334 | |
| 335 | static const struct spi_imx_master mx51_babbage_spi_pdata __initconst = { |
| 336 | .chipselect = mx51_babbage_spi_cs, |
| 337 | .num_chipselect = ARRAY_SIZE(mx51_babbage_spi_cs), |
| 338 | }; |
| 339 | |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 340 | /* |
| 341 | * Board specific initialization. |
| 342 | */ |
Uwe Kleine-König | e134fb2 | 2011-02-11 10:23:19 +0100 | [diff] [blame] | 343 | static void __init mx51_babbage_init(void) |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 344 | { |
Lothar Waßmann | 8f5260c | 2010-10-26 14:28:31 +0200 | [diff] [blame] | 345 | iomux_v3_cfg_t usbh1stp = MX51_PAD_USBH1_STP__USBH1_STP; |
Sascha Hauer | ee1ae4d | 2010-12-15 09:56:35 +0100 | [diff] [blame] | 346 | iomux_v3_cfg_t power_key = _MX51_PAD_EIM_A27__GPIO2_21 | |
| 347 | MUX_PAD_CTRL(PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | PAD_CTL_PUS_100K_UP); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 348 | |
Yong Shen | 64f102b | 2010-10-21 21:18:59 +0800 | [diff] [blame] | 349 | #if defined(CONFIG_CPU_FREQ_IMX) |
| 350 | get_cpu_op = mx51_get_cpu_op; |
| 351 | #endif |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 352 | mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, |
| 353 | ARRAY_SIZE(mx51babbage_pads)); |
Sascha Hauer | 27d2d62 | 2011-01-14 11:30:33 +0100 | [diff] [blame] | 354 | |
| 355 | imx51_add_imx_uart(0, &uart_pdata); |
| 356 | imx51_add_imx_uart(1, &uart_pdata); |
| 357 | imx51_add_imx_uart(2, &uart_pdata); |
| 358 | |
Fabio Estevam | 3efee47 | 2010-08-23 07:32:09 -0700 | [diff] [blame] | 359 | babbage_fec_reset(); |
Uwe Kleine-König | 6bd96f3 | 2010-10-06 12:00:18 +0200 | [diff] [blame] | 360 | imx51_add_fec(NULL); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 361 | |
Dinh Nguyen | f2d36ecb | 2010-10-23 09:12:47 -0500 | [diff] [blame] | 362 | /* Set the PAD settings for the pwr key. */ |
Lothar Waßmann | 96f3e25 | 2010-11-22 09:39:51 +0100 | [diff] [blame] | 363 | mxc_iomux_v3_setup_pad(power_key); |
Dinh Nguyen | f2d36ecb | 2010-10-23 09:12:47 -0500 | [diff] [blame] | 364 | imx51_add_gpio_keys(&imx_button_data); |
| 365 | |
Uwe Kleine-König | 44505c0 | 2010-09-30 16:44:53 +0200 | [diff] [blame] | 366 | imx51_add_imx_i2c(0, &babbage_i2c_data); |
| 367 | imx51_add_imx_i2c(1, &babbage_i2c_data); |
Dinh Nguyen | f00b771 | 2010-05-27 10:45:05 -0500 | [diff] [blame] | 368 | mxc_register_device(&mxc_hsi2c_device, &babbage_hsi2c_data); |
| 369 | |
Dinh Nguyen | 2ba5a2c | 2010-05-10 13:45:59 -0500 | [diff] [blame] | 370 | if (otg_mode_host) |
| 371 | mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config); |
| 372 | else { |
| 373 | initialize_otg_port(NULL); |
| 374 | mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata); |
| 375 | } |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 376 | |
| 377 | gpio_usbh1_active(); |
| 378 | mxc_register_device(&mxc_usbh1_device, &usbh1_config); |
| 379 | /* setback USBH1_STP to be function */ |
Lothar Waßmann | 96f3e25 | 2010-11-22 09:39:51 +0100 | [diff] [blame] | 380 | mxc_iomux_v3_setup_pad(usbh1stp); |
Dinh Nguyen | 231637f | 2010-04-30 15:48:25 -0500 | [diff] [blame] | 381 | babbage_usbhub_reset(); |
Shawn Guo | 7223066 | 2010-10-22 00:55:20 +0800 | [diff] [blame] | 382 | |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 383 | imx51_add_sdhci_esdhc_imx(0, NULL); |
| 384 | imx51_add_sdhci_esdhc_imx(1, NULL); |
Fabio Estevam | 374daa4 | 2010-11-10 07:00:02 -0800 | [diff] [blame] | 385 | |
| 386 | spi_register_board_info(mx51_babbage_spi_board_info, |
| 387 | ARRAY_SIZE(mx51_babbage_spi_board_info)); |
| 388 | imx51_add_ecspi(0, &mx51_babbage_spi_pdata); |
Fabio Estevam | a96efbc | 2010-12-06 16:38:34 -0200 | [diff] [blame] | 389 | imx51_add_imx2_wdt(0, NULL); |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | static void __init mx51_babbage_timer_init(void) |
| 393 | { |
Fabio Estevam | 82d52a1 | 2010-02-17 12:02:56 -0800 | [diff] [blame] | 394 | mx51_clocks_init(32768, 24000000, 22579200, 0); |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 395 | } |
| 396 | |
Uwe Kleine-König | e134fb2 | 2011-02-11 10:23:19 +0100 | [diff] [blame] | 397 | static struct sys_timer mx51_babbage_timer = { |
| 398 | .init = mx51_babbage_timer_init, |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 399 | }; |
| 400 | |
| 401 | MACHINE_START(MX51_BABBAGE, "Freescale MX51 Babbage Board") |
| 402 | /* Maintainer: Amit Kucheria <amit.kucheria@canonical.com> */ |
Uwe Kleine-König | e16ddb3 | 2010-08-24 12:33:23 +0200 | [diff] [blame] | 403 | .boot_params = MX51_PHYS_OFFSET + 0x100, |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 404 | .map_io = mx51_map_io, |
Uwe Kleine-König | ab130421 | 2011-02-07 16:35:21 +0100 | [diff] [blame] | 405 | .init_early = imx51_init_early, |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 406 | .init_irq = mx51_init_irq, |
Uwe Kleine-König | e134fb2 | 2011-02-11 10:23:19 +0100 | [diff] [blame] | 407 | .timer = &mx51_babbage_timer, |
| 408 | .init_machine = mx51_babbage_init, |
Amit Kucheria | b996b58 | 2010-02-02 11:57:53 -0800 | [diff] [blame] | 409 | MACHINE_END |