Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <asm/io.h> |
Troy Kisky | 2714e17 | 2012-07-19 08:18:22 +0000 | [diff] [blame] | 25 | #include <asm/arch/clock.h> |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 26 | #include <asm/arch/imx-regs.h> |
Troy Kisky | c939e2c | 2012-08-15 10:27:11 +0000 | [diff] [blame] | 27 | #include <asm/arch/iomux.h> |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 28 | #include <asm/arch/mx6x_pins.h> |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 29 | #include <asm/errno.h> |
| 30 | #include <asm/gpio.h> |
Troy Kisky | 2714e17 | 2012-07-19 08:18:22 +0000 | [diff] [blame] | 31 | #include <asm/imx-common/iomux-v3.h> |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 32 | #include <asm/imx-common/mxc_i2c.h> |
Troy Kisky | 580f4e3 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 33 | #include <asm/imx-common/boot_mode.h> |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 34 | #include <mmc.h> |
| 35 | #include <fsl_esdhc.h> |
Troy Kisky | dc887ab | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 36 | #include <malloc.h> |
Troy Kisky | 0f1dc84 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 37 | #include <micrel.h> |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 38 | #include <miiphy.h> |
| 39 | #include <netdev.h> |
Eric Nelson | 641d806 | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 40 | #include <linux/fb.h> |
| 41 | #include <ipu_pixfmt.h> |
| 42 | #include <asm/arch/crm_regs.h> |
| 43 | #include <asm/arch/mxc_hdmi.h> |
| 44 | #include <i2c.h> |
| 45 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 46 | DECLARE_GLOBAL_DATA_PTR; |
| 47 | |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 48 | #define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 49 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 50 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 51 | |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 52 | #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 53 | PAD_CTL_PUS_47K_UP | PAD_CTL_SPEED_LOW | \ |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 54 | PAD_CTL_DSE_80ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
| 55 | |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 56 | #define ENET_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 57 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 58 | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
| 59 | |
Eric Nelson | 570c607 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 60 | #define SPI_PAD_CTRL (PAD_CTL_HYS | \ |
| 61 | PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED | \ |
| 62 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST) |
| 63 | |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 64 | #define BUTTON_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 65 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
| 66 | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
| 67 | |
Troy Kisky | 553aeb5 | 2012-04-24 17:33:26 +0000 | [diff] [blame] | 68 | #define I2C_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \ |
| 69 | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ |
| 70 | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
| 71 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 72 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 73 | int dram_init(void) |
| 74 | { |
| 75 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 80 | iomux_v3_cfg_t const uart1_pads[] = { |
Troy Kisky | 8f0c454 | 2012-01-12 23:49:25 +0000 | [diff] [blame] | 81 | MX6Q_PAD_SD3_DAT6__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 82 | MX6Q_PAD_SD3_DAT7__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 83 | }; |
| 84 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 85 | iomux_v3_cfg_t const uart2_pads[] = { |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 86 | MX6Q_PAD_EIM_D26__UART2_TXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 87 | MX6Q_PAD_EIM_D27__UART2_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 88 | }; |
| 89 | |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 90 | #define PC MUX_PAD_CTRL(I2C_PAD_CTRL) |
| 91 | |
| 92 | /* I2C1, SGTL5000 */ |
| 93 | struct i2c_pads_info i2c_pad_info0 = { |
| 94 | .scl = { |
| 95 | .i2c_mode = MX6Q_PAD_EIM_D21__I2C1_SCL | PC, |
| 96 | .gpio_mode = MX6Q_PAD_EIM_D21__GPIO_3_21 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 97 | .gp = IMX_GPIO_NR(3, 21) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 98 | }, |
| 99 | .sda = { |
| 100 | .i2c_mode = MX6Q_PAD_EIM_D28__I2C1_SDA | PC, |
| 101 | .gpio_mode = MX6Q_PAD_EIM_D28__GPIO_3_28 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 102 | .gp = IMX_GPIO_NR(3, 28) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 103 | } |
| 104 | }; |
| 105 | |
| 106 | /* I2C2 Camera, MIPI */ |
| 107 | struct i2c_pads_info i2c_pad_info1 = { |
| 108 | .scl = { |
| 109 | .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | PC, |
| 110 | .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO_4_12 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 111 | .gp = IMX_GPIO_NR(4, 12) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 112 | }, |
| 113 | .sda = { |
| 114 | .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC, |
| 115 | .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO_4_13 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 116 | .gp = IMX_GPIO_NR(4, 13) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 117 | } |
| 118 | }; |
| 119 | |
| 120 | /* I2C3, J15 - RGB connector */ |
| 121 | struct i2c_pads_info i2c_pad_info2 = { |
| 122 | .scl = { |
| 123 | .i2c_mode = MX6Q_PAD_GPIO_5__I2C3_SCL | PC, |
| 124 | .gpio_mode = MX6Q_PAD_GPIO_5__GPIO_1_5 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 125 | .gp = IMX_GPIO_NR(1, 5) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 126 | }, |
| 127 | .sda = { |
| 128 | .i2c_mode = MX6Q_PAD_GPIO_16__I2C3_SDA | PC, |
| 129 | .gpio_mode = MX6Q_PAD_GPIO_16__GPIO_7_11 | PC, |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 130 | .gp = IMX_GPIO_NR(7, 11) |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 131 | } |
Troy Kisky | 553aeb5 | 2012-04-24 17:33:26 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 134 | iomux_v3_cfg_t const usdhc3_pads[] = { |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 135 | MX6Q_PAD_SD3_CLK__USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 136 | MX6Q_PAD_SD3_CMD__USDHC3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 137 | MX6Q_PAD_SD3_DAT0__USDHC3_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 138 | MX6Q_PAD_SD3_DAT1__USDHC3_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 139 | MX6Q_PAD_SD3_DAT2__USDHC3_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 140 | MX6Q_PAD_SD3_DAT3__USDHC3_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 141 | MX6Q_PAD_SD3_DAT5__GPIO_7_0 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ |
| 142 | }; |
| 143 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 144 | iomux_v3_cfg_t const usdhc4_pads[] = { |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 145 | MX6Q_PAD_SD4_CLK__USDHC4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 146 | MX6Q_PAD_SD4_CMD__USDHC4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 147 | MX6Q_PAD_SD4_DAT0__USDHC4_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 148 | MX6Q_PAD_SD4_DAT1__USDHC4_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 149 | MX6Q_PAD_SD4_DAT2__USDHC4_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 150 | MX6Q_PAD_SD4_DAT3__USDHC4_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 151 | MX6Q_PAD_NANDF_D6__GPIO_2_6 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ |
| 152 | }; |
| 153 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 154 | iomux_v3_cfg_t const enet_pads1[] = { |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 155 | MX6Q_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 156 | MX6Q_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 157 | MX6Q_PAD_RGMII_TXC__ENET_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 158 | MX6Q_PAD_RGMII_TD0__ENET_RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 159 | MX6Q_PAD_RGMII_TD1__ENET_RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 160 | MX6Q_PAD_RGMII_TD2__ENET_RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 161 | MX6Q_PAD_RGMII_TD3__ENET_RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 162 | MX6Q_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 163 | MX6Q_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 164 | /* pin 35 - 1 (PHY_AD2) on reset */ |
| 165 | MX6Q_PAD_RGMII_RXC__GPIO_6_30 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 166 | /* pin 32 - 1 - (MODE0) all */ |
| 167 | MX6Q_PAD_RGMII_RD0__GPIO_6_25 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 168 | /* pin 31 - 1 - (MODE1) all */ |
| 169 | MX6Q_PAD_RGMII_RD1__GPIO_6_27 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 170 | /* pin 28 - 1 - (MODE2) all */ |
| 171 | MX6Q_PAD_RGMII_RD2__GPIO_6_28 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 172 | /* pin 27 - 1 - (MODE3) all */ |
| 173 | MX6Q_PAD_RGMII_RD3__GPIO_6_29 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 174 | /* pin 33 - 1 - (CLK125_EN) 125Mhz clockout enabled */ |
| 175 | MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 176 | /* pin 42 PHY nRST */ |
| 177 | MX6Q_PAD_EIM_D23__GPIO_3_23 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 178 | }; |
| 179 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 180 | iomux_v3_cfg_t const enet_pads2[] = { |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 181 | MX6Q_PAD_RGMII_RXC__ENET_RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 182 | MX6Q_PAD_RGMII_RD0__ENET_RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 183 | MX6Q_PAD_RGMII_RD1__ENET_RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 184 | MX6Q_PAD_RGMII_RD2__ENET_RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 185 | MX6Q_PAD_RGMII_RD3__ENET_RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 186 | MX6Q_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 187 | }; |
| 188 | |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 189 | /* Button assignments for J14 */ |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 190 | static iomux_v3_cfg_t const button_pads[] = { |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 191 | /* Menu */ |
| 192 | MX6Q_PAD_NANDF_D1__GPIO_2_1 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 193 | /* Back */ |
| 194 | MX6Q_PAD_NANDF_D2__GPIO_2_2 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 195 | /* Labelled Search (mapped to Power under Android) */ |
| 196 | MX6Q_PAD_NANDF_D3__GPIO_2_3 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 197 | /* Home */ |
| 198 | MX6Q_PAD_NANDF_D4__GPIO_2_4 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 199 | /* Volume Down */ |
| 200 | MX6Q_PAD_GPIO_19__GPIO_4_5 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 201 | /* Volume Up */ |
| 202 | MX6Q_PAD_GPIO_18__GPIO_7_13 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
| 203 | }; |
| 204 | |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 205 | static void setup_iomux_enet(void) |
| 206 | { |
Ashok Kumar Reddy | 4a3f7c5 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 207 | gpio_direction_output(IMX_GPIO_NR(3, 23), 0); |
| 208 | gpio_direction_output(IMX_GPIO_NR(6, 30), 1); |
| 209 | gpio_direction_output(IMX_GPIO_NR(6, 25), 1); |
| 210 | gpio_direction_output(IMX_GPIO_NR(6, 27), 1); |
| 211 | gpio_direction_output(IMX_GPIO_NR(6, 28), 1); |
| 212 | gpio_direction_output(IMX_GPIO_NR(6, 29), 1); |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 213 | imx_iomux_v3_setup_multiple_pads(enet_pads1, ARRAY_SIZE(enet_pads1)); |
Ashok Kumar Reddy | 4a3f7c5 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 214 | gpio_direction_output(IMX_GPIO_NR(6, 24), 1); |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 215 | |
| 216 | /* Need delay 10ms according to KSZ9021 spec */ |
| 217 | udelay(1000 * 10); |
Ashok Kumar Reddy | 4a3f7c5 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 218 | gpio_set_value(IMX_GPIO_NR(3, 23), 1); |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 219 | |
| 220 | imx_iomux_v3_setup_multiple_pads(enet_pads2, ARRAY_SIZE(enet_pads2)); |
| 221 | } |
| 222 | |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 223 | iomux_v3_cfg_t const usb_pads[] = { |
Wolfgang Grandegger | 4b7e897 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 224 | MX6Q_PAD_GPIO_17__GPIO_7_12 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 225 | }; |
| 226 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 227 | static void setup_iomux_uart(void) |
| 228 | { |
Troy Kisky | 8f0c454 | 2012-01-12 23:49:25 +0000 | [diff] [blame] | 229 | imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 230 | imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads)); |
| 231 | } |
| 232 | |
Wolfgang Grandegger | 4b7e897 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 233 | #ifdef CONFIG_USB_EHCI_MX6 |
| 234 | int board_ehci_hcd_init(int port) |
| 235 | { |
| 236 | imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads)); |
| 237 | |
| 238 | /* Reset USB hub */ |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 239 | gpio_direction_output(IMX_GPIO_NR(7, 12), 0); |
Wolfgang Grandegger | 4b7e897 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 240 | mdelay(2); |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 241 | gpio_set_value(IMX_GPIO_NR(7, 12), 1); |
Wolfgang Grandegger | 4b7e897 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 242 | |
| 243 | return 0; |
| 244 | } |
| 245 | #endif |
| 246 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 247 | #ifdef CONFIG_FSL_ESDHC |
| 248 | struct fsl_esdhc_cfg usdhc_cfg[2] = { |
Benoît Thébaudeau | c08d11c | 2012-08-13 07:28:16 +0000 | [diff] [blame] | 249 | {USDHC3_BASE_ADDR}, |
| 250 | {USDHC4_BASE_ADDR}, |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | int board_mmc_getcd(struct mmc *mmc) |
| 254 | { |
| 255 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
| 256 | int ret; |
| 257 | |
| 258 | if (cfg->esdhc_base == USDHC3_BASE_ADDR) { |
Ashok Kumar Reddy | 4a3f7c5 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 259 | gpio_direction_input(IMX_GPIO_NR(7, 0)); |
| 260 | ret = !gpio_get_value(IMX_GPIO_NR(7, 0)); |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 261 | } else { |
Ashok Kumar Reddy | 4a3f7c5 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 262 | gpio_direction_input(IMX_GPIO_NR(2, 6)); |
| 263 | ret = !gpio_get_value(IMX_GPIO_NR(2, 6)); |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | return ret; |
| 267 | } |
| 268 | |
| 269 | int board_mmc_init(bd_t *bis) |
| 270 | { |
| 271 | s32 status = 0; |
| 272 | u32 index = 0; |
| 273 | |
Benoît Thébaudeau | c58ff34 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 274 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 275 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); |
| 276 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 277 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 278 | switch (index) { |
| 279 | case 0: |
| 280 | imx_iomux_v3_setup_multiple_pads( |
| 281 | usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); |
| 282 | break; |
| 283 | case 1: |
| 284 | imx_iomux_v3_setup_multiple_pads( |
| 285 | usdhc4_pads, ARRAY_SIZE(usdhc4_pads)); |
| 286 | break; |
| 287 | default: |
| 288 | printf("Warning: you configured more USDHC controllers" |
| 289 | "(%d) then supported by the board (%d)\n", |
| 290 | index + 1, CONFIG_SYS_FSL_USDHC_NUM); |
| 291 | return status; |
| 292 | } |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 293 | |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 294 | status |= fsl_esdhc_initialize(bis, &usdhc_cfg[index]); |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | return status; |
| 298 | } |
| 299 | #endif |
| 300 | |
Eric Nelson | c3e41cf | 2012-03-12 15:04:12 +0000 | [diff] [blame] | 301 | u32 get_board_rev(void) |
| 302 | { |
| 303 | return 0x63000 ; |
| 304 | } |
| 305 | |
Eric Nelson | 570c607 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 306 | #ifdef CONFIG_MXC_SPI |
Eric Nelson | 1680209 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 307 | iomux_v3_cfg_t const ecspi1_pads[] = { |
Eric Nelson | 570c607 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 308 | /* SS1 */ |
| 309 | MX6Q_PAD_EIM_D19__GPIO_3_19 | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 310 | MX6Q_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 311 | MX6Q_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 312 | MX6Q_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 313 | }; |
| 314 | |
| 315 | void setup_spi(void) |
| 316 | { |
Eric Nelson | 2453640 | 2012-01-31 07:52:09 +0000 | [diff] [blame] | 317 | gpio_direction_output(CONFIG_SF_DEFAULT_CS, 1); |
Eric Nelson | 570c607 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 318 | imx_iomux_v3_setup_multiple_pads(ecspi1_pads, |
| 319 | ARRAY_SIZE(ecspi1_pads)); |
| 320 | } |
| 321 | #endif |
| 322 | |
Troy Kisky | 0f1dc84 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 323 | int board_phy_config(struct phy_device *phydev) |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 324 | { |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 325 | /* min rx data delay */ |
Troy Kisky | 0f1dc84 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 326 | ksz9021_phy_extended_write(phydev, |
| 327 | MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0x0); |
| 328 | /* min tx data delay */ |
| 329 | ksz9021_phy_extended_write(phydev, |
| 330 | MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0x0); |
| 331 | /* max rx/tx clock delay, min rx/tx control */ |
| 332 | ksz9021_phy_extended_write(phydev, |
| 333 | MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0xf0f0); |
| 334 | if (phydev->drv->config) |
| 335 | phydev->drv->config(phydev); |
Wolfgang Denk | 97753b1 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 336 | |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | int board_eth_init(bd_t *bis) |
| 341 | { |
Troy Kisky | dc887ab | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 342 | uint32_t base = IMX_FEC_BASE; |
| 343 | struct mii_dev *bus = NULL; |
| 344 | struct phy_device *phydev = NULL; |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 345 | int ret; |
| 346 | |
| 347 | setup_iomux_enet(); |
| 348 | |
Troy Kisky | dc887ab | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 349 | #ifdef CONFIG_FEC_MXC |
| 350 | bus = fec_get_miibus(base, -1); |
| 351 | if (!bus) |
| 352 | return 0; |
| 353 | /* scan phy 4,5,6,7 */ |
| 354 | phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); |
| 355 | if (!phydev) { |
| 356 | free(bus); |
| 357 | return 0; |
| 358 | } |
| 359 | printf("using phy at %d\n", phydev->addr); |
| 360 | ret = fec_probe(bis, -1, base, bus, phydev); |
| 361 | if (ret) { |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 362 | printf("FEC MXC: %s:failed\n", __func__); |
Troy Kisky | dc887ab | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 363 | free(phydev); |
| 364 | free(bus); |
| 365 | } |
| 366 | #endif |
Jason Liu | fa8ec67 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 370 | static void setup_buttons(void) |
| 371 | { |
| 372 | imx_iomux_v3_setup_multiple_pads(button_pads, |
| 373 | ARRAY_SIZE(button_pads)); |
| 374 | } |
| 375 | |
Eric Nelson | e474c58 | 2012-05-01 09:55:11 +0000 | [diff] [blame] | 376 | #ifdef CONFIG_CMD_SATA |
| 377 | |
| 378 | int setup_sata(void) |
| 379 | { |
| 380 | struct iomuxc_base_regs *const iomuxc_regs |
| 381 | = (struct iomuxc_base_regs *) IOMUXC_BASE_ADDR; |
| 382 | int ret = enable_sata_clock(); |
| 383 | if (ret) |
| 384 | return ret; |
| 385 | |
| 386 | clrsetbits_le32(&iomuxc_regs->gpr[13], |
| 387 | IOMUXC_GPR13_SATA_MASK, |
| 388 | IOMUXC_GPR13_SATA_PHY_8_RXEQ_3P0DB |
| 389 | |IOMUXC_GPR13_SATA_PHY_7_SATA2M |
| 390 | |IOMUXC_GPR13_SATA_SPEED_3G |
| 391 | |(3<<IOMUXC_GPR13_SATA_PHY_6_SHIFT) |
| 392 | |IOMUXC_GPR13_SATA_SATA_PHY_5_SS_DISABLED |
| 393 | |IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_9_16 |
| 394 | |IOMUXC_GPR13_SATA_PHY_3_TXBOOST_0P00_DB |
| 395 | |IOMUXC_GPR13_SATA_PHY_2_TX_1P104V |
| 396 | |IOMUXC_GPR13_SATA_PHY_1_SLOW); |
| 397 | |
| 398 | return 0; |
| 399 | } |
| 400 | #endif |
| 401 | |
Eric Nelson | 641d806 | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 402 | #if defined(CONFIG_VIDEO_IPUV3) |
| 403 | |
| 404 | static iomux_v3_cfg_t const backlight_pads[] = { |
| 405 | /* Backlight on RGB connector: J15 */ |
| 406 | MX6Q_PAD_SD1_DAT3__GPIO_1_21 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 407 | #define RGB_BACKLIGHT_GP IMX_GPIO_NR(1, 21) |
| 408 | |
| 409 | /* Backlight on LVDS connector: J6 */ |
| 410 | MX6Q_PAD_SD1_CMD__GPIO_1_18 | MUX_PAD_CTRL(NO_PAD_CTRL), |
| 411 | #define LVDS_BACKLIGHT_GP IMX_GPIO_NR(1, 18) |
| 412 | }; |
| 413 | |
| 414 | static iomux_v3_cfg_t const rgb_pads[] = { |
| 415 | MX6Q_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK, |
| 416 | MX6Q_PAD_DI0_PIN15__IPU1_DI0_PIN15, |
| 417 | MX6Q_PAD_DI0_PIN2__IPU1_DI0_PIN2, |
| 418 | MX6Q_PAD_DI0_PIN3__IPU1_DI0_PIN3, |
| 419 | MX6Q_PAD_DI0_PIN4__GPIO_4_20, |
| 420 | MX6Q_PAD_DISP0_DAT0__IPU1_DISP0_DAT_0, |
| 421 | MX6Q_PAD_DISP0_DAT1__IPU1_DISP0_DAT_1, |
| 422 | MX6Q_PAD_DISP0_DAT2__IPU1_DISP0_DAT_2, |
| 423 | MX6Q_PAD_DISP0_DAT3__IPU1_DISP0_DAT_3, |
| 424 | MX6Q_PAD_DISP0_DAT4__IPU1_DISP0_DAT_4, |
| 425 | MX6Q_PAD_DISP0_DAT5__IPU1_DISP0_DAT_5, |
| 426 | MX6Q_PAD_DISP0_DAT6__IPU1_DISP0_DAT_6, |
| 427 | MX6Q_PAD_DISP0_DAT7__IPU1_DISP0_DAT_7, |
| 428 | MX6Q_PAD_DISP0_DAT8__IPU1_DISP0_DAT_8, |
| 429 | MX6Q_PAD_DISP0_DAT9__IPU1_DISP0_DAT_9, |
| 430 | MX6Q_PAD_DISP0_DAT10__IPU1_DISP0_DAT_10, |
| 431 | MX6Q_PAD_DISP0_DAT11__IPU1_DISP0_DAT_11, |
| 432 | MX6Q_PAD_DISP0_DAT12__IPU1_DISP0_DAT_12, |
| 433 | MX6Q_PAD_DISP0_DAT13__IPU1_DISP0_DAT_13, |
| 434 | MX6Q_PAD_DISP0_DAT14__IPU1_DISP0_DAT_14, |
| 435 | MX6Q_PAD_DISP0_DAT15__IPU1_DISP0_DAT_15, |
| 436 | MX6Q_PAD_DISP0_DAT16__IPU1_DISP0_DAT_16, |
| 437 | MX6Q_PAD_DISP0_DAT17__IPU1_DISP0_DAT_17, |
| 438 | MX6Q_PAD_DISP0_DAT18__IPU1_DISP0_DAT_18, |
| 439 | MX6Q_PAD_DISP0_DAT19__IPU1_DISP0_DAT_19, |
| 440 | MX6Q_PAD_DISP0_DAT20__IPU1_DISP0_DAT_20, |
| 441 | MX6Q_PAD_DISP0_DAT21__IPU1_DISP0_DAT_21, |
| 442 | MX6Q_PAD_DISP0_DAT22__IPU1_DISP0_DAT_22, |
| 443 | MX6Q_PAD_DISP0_DAT23__IPU1_DISP0_DAT_23, |
| 444 | }; |
| 445 | |
| 446 | struct display_info_t { |
| 447 | int bus; |
| 448 | int addr; |
| 449 | int pixfmt; |
| 450 | int (*detect)(struct display_info_t const *dev); |
| 451 | void (*enable)(struct display_info_t const *dev); |
| 452 | struct fb_videomode mode; |
| 453 | }; |
| 454 | |
| 455 | |
| 456 | static int detect_hdmi(struct display_info_t const *dev) |
| 457 | { |
| 458 | return __raw_readb(HDMI_ARB_BASE_ADDR+HDMI_PHY_STAT0) & HDMI_PHY_HPD; |
| 459 | } |
| 460 | |
| 461 | static void enable_hdmi(struct display_info_t const *dev) |
| 462 | { |
| 463 | u8 reg; |
| 464 | printf("%s: setup HDMI monitor\n", __func__); |
| 465 | reg = __raw_readb( |
| 466 | HDMI_ARB_BASE_ADDR |
| 467 | +HDMI_PHY_CONF0); |
| 468 | reg |= HDMI_PHY_CONF0_PDZ_MASK; |
| 469 | __raw_writeb(reg, |
| 470 | HDMI_ARB_BASE_ADDR |
| 471 | +HDMI_PHY_CONF0); |
| 472 | udelay(3000); |
| 473 | reg |= HDMI_PHY_CONF0_ENTMDS_MASK; |
| 474 | __raw_writeb(reg, |
| 475 | HDMI_ARB_BASE_ADDR |
| 476 | +HDMI_PHY_CONF0); |
| 477 | udelay(3000); |
| 478 | reg |= HDMI_PHY_CONF0_GEN2_TXPWRON_MASK; |
| 479 | __raw_writeb(reg, |
| 480 | HDMI_ARB_BASE_ADDR |
| 481 | +HDMI_PHY_CONF0); |
| 482 | __raw_writeb(HDMI_MC_PHYRSTZ_ASSERT, |
| 483 | HDMI_ARB_BASE_ADDR+HDMI_MC_PHYRSTZ); |
| 484 | } |
| 485 | |
| 486 | static int detect_i2c(struct display_info_t const *dev) |
| 487 | { |
| 488 | return ((0 == i2c_set_bus_num(dev->bus)) |
| 489 | && |
| 490 | (0 == i2c_probe(dev->addr))); |
| 491 | } |
| 492 | |
| 493 | static void enable_lvds(struct display_info_t const *dev) |
| 494 | { |
| 495 | struct iomuxc *iomux = (struct iomuxc *) |
| 496 | IOMUXC_BASE_ADDR; |
| 497 | u32 reg = readl(&iomux->gpr[2]); |
| 498 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT; |
| 499 | writel(reg, &iomux->gpr[2]); |
| 500 | gpio_direction_output(LVDS_BACKLIGHT_GP, 1); |
| 501 | } |
| 502 | |
| 503 | static void enable_rgb(struct display_info_t const *dev) |
| 504 | { |
| 505 | imx_iomux_v3_setup_multiple_pads( |
| 506 | rgb_pads, |
| 507 | ARRAY_SIZE(rgb_pads)); |
| 508 | gpio_direction_output(RGB_BACKLIGHT_GP, 1); |
| 509 | } |
| 510 | |
| 511 | static struct display_info_t const displays[] = {{ |
| 512 | .bus = -1, |
| 513 | .addr = 0, |
| 514 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 515 | .detect = detect_hdmi, |
| 516 | .enable = enable_hdmi, |
| 517 | .mode = { |
| 518 | .name = "HDMI", |
| 519 | .refresh = 60, |
| 520 | .xres = 1024, |
| 521 | .yres = 768, |
| 522 | .pixclock = 15385, |
| 523 | .left_margin = 220, |
| 524 | .right_margin = 40, |
| 525 | .upper_margin = 21, |
| 526 | .lower_margin = 7, |
| 527 | .hsync_len = 60, |
| 528 | .vsync_len = 10, |
| 529 | .sync = FB_SYNC_EXT, |
| 530 | .vmode = FB_VMODE_NONINTERLACED |
| 531 | } }, { |
| 532 | .bus = 2, |
| 533 | .addr = 0x4, |
| 534 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 535 | .detect = detect_i2c, |
| 536 | .enable = enable_lvds, |
| 537 | .mode = { |
| 538 | .name = "Hannstar-XGA", |
| 539 | .refresh = 60, |
| 540 | .xres = 1024, |
| 541 | .yres = 768, |
| 542 | .pixclock = 15385, |
| 543 | .left_margin = 220, |
| 544 | .right_margin = 40, |
| 545 | .upper_margin = 21, |
| 546 | .lower_margin = 7, |
| 547 | .hsync_len = 60, |
| 548 | .vsync_len = 10, |
| 549 | .sync = FB_SYNC_EXT, |
| 550 | .vmode = FB_VMODE_NONINTERLACED |
| 551 | } }, { |
| 552 | .bus = 2, |
| 553 | .addr = 0x38, |
| 554 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 555 | .detect = detect_i2c, |
| 556 | .enable = enable_lvds, |
| 557 | .mode = { |
| 558 | .name = "wsvga-lvds", |
| 559 | .refresh = 60, |
| 560 | .xres = 1024, |
| 561 | .yres = 600, |
| 562 | .pixclock = 15385, |
| 563 | .left_margin = 220, |
| 564 | .right_margin = 40, |
| 565 | .upper_margin = 21, |
| 566 | .lower_margin = 7, |
| 567 | .hsync_len = 60, |
| 568 | .vsync_len = 10, |
| 569 | .sync = FB_SYNC_EXT, |
| 570 | .vmode = FB_VMODE_NONINTERLACED |
| 571 | } }, { |
| 572 | .bus = 2, |
| 573 | .addr = 0x48, |
| 574 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 575 | .detect = detect_i2c, |
| 576 | .enable = enable_rgb, |
| 577 | .mode = { |
| 578 | .name = "wvga-rgb", |
| 579 | .refresh = 57, |
| 580 | .xres = 800, |
| 581 | .yres = 480, |
| 582 | .pixclock = 37037, |
| 583 | .left_margin = 40, |
| 584 | .right_margin = 60, |
| 585 | .upper_margin = 10, |
| 586 | .lower_margin = 10, |
| 587 | .hsync_len = 20, |
| 588 | .vsync_len = 10, |
| 589 | .sync = 0, |
| 590 | .vmode = FB_VMODE_NONINTERLACED |
| 591 | } } }; |
| 592 | |
| 593 | int board_video_skip(void) |
| 594 | { |
| 595 | int i; |
| 596 | int ret; |
| 597 | char const *panel = getenv("panel"); |
| 598 | if (!panel) { |
| 599 | for (i = 0; i < ARRAY_SIZE(displays); i++) { |
| 600 | struct display_info_t const *dev = displays+i; |
| 601 | if (dev->detect(dev)) { |
| 602 | panel = dev->mode.name; |
| 603 | printf("auto-detected panel %s\n", panel); |
| 604 | break; |
| 605 | } |
| 606 | } |
| 607 | if (!panel) { |
| 608 | panel = displays[0].mode.name; |
| 609 | printf("No panel detected: default to %s\n", panel); |
| 610 | } |
| 611 | } else { |
| 612 | for (i = 0; i < ARRAY_SIZE(displays); i++) { |
| 613 | if (!strcmp(panel, displays[i].mode.name)) |
| 614 | break; |
| 615 | } |
| 616 | } |
| 617 | if (i < ARRAY_SIZE(displays)) { |
| 618 | ret = ipuv3_fb_init(&displays[i].mode, 0, |
| 619 | displays[i].pixfmt); |
| 620 | if (!ret) { |
| 621 | displays[i].enable(displays+i); |
| 622 | printf("Display: %s (%ux%u)\n", |
| 623 | displays[i].mode.name, |
| 624 | displays[i].mode.xres, |
| 625 | displays[i].mode.yres); |
| 626 | } else |
| 627 | printf("LCD %s cannot be configured: %d\n", |
| 628 | displays[i].mode.name, ret); |
| 629 | } else { |
| 630 | printf("unsupported panel %s\n", panel); |
| 631 | ret = -EINVAL; |
| 632 | } |
| 633 | return (0 != ret); |
| 634 | } |
| 635 | |
| 636 | static void setup_display(void) |
| 637 | { |
| 638 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 639 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
| 640 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 641 | |
| 642 | int reg; |
| 643 | |
| 644 | /* Turn on LDB0,IPU,IPU DI0 clocks */ |
| 645 | reg = __raw_readl(&mxc_ccm->CCGR3); |
| 646 | reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET |
| 647 | |MXC_CCM_CCGR3_LDB_DI0_MASK; |
| 648 | writel(reg, &mxc_ccm->CCGR3); |
| 649 | |
| 650 | /* Turn on HDMI PHY clock */ |
| 651 | reg = __raw_readl(&mxc_ccm->CCGR2); |
| 652 | reg |= MXC_CCM_CCGR2_HDMI_TX_IAHBCLK_MASK |
| 653 | |MXC_CCM_CCGR2_HDMI_TX_ISFRCLK_MASK; |
| 654 | writel(reg, &mxc_ccm->CCGR2); |
| 655 | |
| 656 | /* clear HDMI PHY reset */ |
| 657 | __raw_writeb(HDMI_MC_PHYRSTZ_DEASSERT, |
| 658 | HDMI_ARB_BASE_ADDR+HDMI_MC_PHYRSTZ); |
| 659 | |
| 660 | /* set PFD1_FRAC to 0x13 == 455 MHz (480*18)/0x13 */ |
| 661 | writel(ANATOP_PFD_480_PFD1_FRAC_MASK, &anatop->pfd_480_clr); |
| 662 | writel(0x13<<ANATOP_PFD_480_PFD1_FRAC_SHIFT, &anatop->pfd_480_set); |
| 663 | |
| 664 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 665 | reg = readl(&mxc_ccm->cs2cdr); |
| 666 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 667 | |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 668 | reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 669 | |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 670 | writel(reg, &mxc_ccm->cs2cdr); |
| 671 | |
| 672 | reg = readl(&mxc_ccm->cscmr2); |
| 673 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV; |
| 674 | writel(reg, &mxc_ccm->cscmr2); |
| 675 | |
| 676 | reg = readl(&mxc_ccm->chsccdr); |
| 677 | reg &= ~(MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_MASK |
| 678 | |MXC_CCM_CHSCCDR_IPU1_DI0_PODF_MASK |
| 679 | |MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK); |
| 680 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 681 | <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET) |
| 682 | |(CHSCCDR_PODF_DIVIDE_BY_3 |
| 683 | <<MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET) |
| 684 | |(CHSCCDR_IPU_PRE_CLK_540M_PFD |
| 685 | <<MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET); |
| 686 | writel(reg, &mxc_ccm->chsccdr); |
| 687 | |
| 688 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 689 | |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
| 690 | |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 691 | |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 692 | |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 693 | |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 694 | |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 695 | |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
| 696 | |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0; |
| 697 | writel(reg, &iomux->gpr[2]); |
| 698 | |
| 699 | reg = readl(&iomux->gpr[3]); |
| 700 | reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK) |
| 701 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 702 | <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET); |
| 703 | writel(reg, &iomux->gpr[3]); |
| 704 | |
| 705 | /* backlights off until needed */ |
| 706 | imx_iomux_v3_setup_multiple_pads(backlight_pads, |
| 707 | ARRAY_SIZE(backlight_pads)); |
| 708 | gpio_direction_input(LVDS_BACKLIGHT_GP); |
| 709 | gpio_direction_input(RGB_BACKLIGHT_GP); |
| 710 | } |
| 711 | #endif |
| 712 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 713 | int board_early_init_f(void) |
| 714 | { |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 715 | setup_iomux_uart(); |
| 716 | setup_buttons(); |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 717 | |
Eric Nelson | 641d806 | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 718 | #if defined(CONFIG_VIDEO_IPUV3) |
| 719 | setup_display(); |
| 720 | #endif |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 721 | return 0; |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 722 | } |
| 723 | |
Eric Nelson | 641d806 | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 724 | /* |
| 725 | * Do not overwrite the console |
| 726 | * Use always serial for U-Boot console |
| 727 | */ |
| 728 | int overwrite_console(void) |
| 729 | { |
| 730 | return 1; |
| 731 | } |
| 732 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 733 | int board_init(void) |
| 734 | { |
| 735 | /* address of boot parameters */ |
| 736 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 737 | |
Eric Nelson | b585977 | 2012-02-26 12:03:15 +0000 | [diff] [blame] | 738 | #ifdef CONFIG_MXC_SPI |
| 739 | setup_spi(); |
| 740 | #endif |
Troy Kisky | b401e64 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 741 | setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0); |
| 742 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); |
| 743 | setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2); |
Eric Nelson | b585977 | 2012-02-26 12:03:15 +0000 | [diff] [blame] | 744 | |
Eric Nelson | e474c58 | 2012-05-01 09:55:11 +0000 | [diff] [blame] | 745 | #ifdef CONFIG_CMD_SATA |
| 746 | setup_sata(); |
| 747 | #endif |
| 748 | |
Jason Liu | 0238468 | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | int checkboard(void) |
| 753 | { |
| 754 | puts("Board: MX6Q-Sabre Lite\n"); |
| 755 | |
| 756 | return 0; |
| 757 | } |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 758 | |
| 759 | struct button_key { |
| 760 | char const *name; |
| 761 | unsigned gpnum; |
| 762 | char ident; |
| 763 | }; |
| 764 | |
| 765 | static struct button_key const buttons[] = { |
Stefano Babic | fc05b90 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 766 | {"back", IMX_GPIO_NR(2, 2), 'B'}, |
| 767 | {"home", IMX_GPIO_NR(2, 4), 'H'}, |
| 768 | {"menu", IMX_GPIO_NR(2, 1), 'M'}, |
| 769 | {"search", IMX_GPIO_NR(2, 3), 'S'}, |
| 770 | {"volup", IMX_GPIO_NR(7, 13), 'V'}, |
| 771 | {"voldown", IMX_GPIO_NR(4, 5), 'v'}, |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 772 | }; |
| 773 | |
| 774 | /* |
| 775 | * generate a null-terminated string containing the buttons pressed |
| 776 | * returns number of keys pressed |
| 777 | */ |
| 778 | static int read_keys(char *buf) |
| 779 | { |
| 780 | int i, numpressed = 0; |
| 781 | for (i = 0; i < ARRAY_SIZE(buttons); i++) { |
| 782 | if (!gpio_get_value(buttons[i].gpnum)) |
| 783 | buf[numpressed++] = buttons[i].ident; |
| 784 | } |
| 785 | buf[numpressed] = '\0'; |
| 786 | return numpressed; |
| 787 | } |
| 788 | |
| 789 | static int do_kbd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 790 | { |
| 791 | char envvalue[ARRAY_SIZE(buttons)+1]; |
| 792 | int numpressed = read_keys(envvalue); |
| 793 | setenv("keybd", envvalue); |
| 794 | return numpressed == 0; |
| 795 | } |
| 796 | |
| 797 | U_BOOT_CMD( |
| 798 | kbd, 1, 1, do_kbd, |
| 799 | "Tests for keypresses, sets 'keybd' environment variable", |
| 800 | "Returns 0 (true) to shell if key is pressed." |
| 801 | ); |
| 802 | |
| 803 | #ifdef CONFIG_PREBOOT |
| 804 | static char const kbd_magic_prefix[] = "key_magic"; |
| 805 | static char const kbd_command_prefix[] = "key_cmd"; |
| 806 | |
| 807 | static void preboot_keys(void) |
| 808 | { |
| 809 | int numpressed; |
| 810 | char keypress[ARRAY_SIZE(buttons)+1]; |
| 811 | numpressed = read_keys(keypress); |
| 812 | if (numpressed) { |
| 813 | char *kbd_magic_keys = getenv("magic_keys"); |
| 814 | char *suffix; |
| 815 | /* |
| 816 | * loop over all magic keys |
| 817 | */ |
| 818 | for (suffix = kbd_magic_keys; *suffix; ++suffix) { |
| 819 | char *keys; |
| 820 | char magic[sizeof(kbd_magic_prefix) + 1]; |
| 821 | sprintf(magic, "%s%c", kbd_magic_prefix, *suffix); |
| 822 | keys = getenv(magic); |
| 823 | if (keys) { |
| 824 | if (!strcmp(keys, keypress)) |
| 825 | break; |
| 826 | } |
| 827 | } |
| 828 | if (*suffix) { |
| 829 | char cmd_name[sizeof(kbd_command_prefix) + 1]; |
| 830 | char *cmd; |
| 831 | sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix); |
| 832 | cmd = getenv(cmd_name); |
| 833 | if (cmd) { |
| 834 | setenv("preboot", cmd); |
| 835 | return; |
| 836 | } |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | #endif |
| 841 | |
Troy Kisky | 580f4e3 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 842 | #ifdef CONFIG_CMD_BMODE |
| 843 | static const struct boot_mode board_boot_modes[] = { |
| 844 | /* 4 bit bus width */ |
| 845 | {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 846 | {"mmc1", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)}, |
| 847 | {NULL, 0}, |
| 848 | }; |
| 849 | #endif |
| 850 | |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 851 | int misc_init_r(void) |
| 852 | { |
| 853 | #ifdef CONFIG_PREBOOT |
| 854 | preboot_keys(); |
| 855 | #endif |
Troy Kisky | 580f4e3 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 856 | |
| 857 | #ifdef CONFIG_CMD_BMODE |
| 858 | add_board_boot_modes(board_boot_modes); |
| 859 | #endif |
Eric Nelson | 5fa17e0 | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 860 | return 0; |
| 861 | } |