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