Jason Liu | bc5833c | 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 | f5cdc11 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Jason Liu | bc5833c | 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 | af2a35f | 2012-07-19 08:18:22 +0000 | [diff] [blame] | 25 | #include <asm/arch/clock.h> |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 26 | #include <asm/arch/imx-regs.h> |
Troy Kisky | d1c679a | 2012-08-15 10:27:11 +0000 | [diff] [blame] | 27 | #include <asm/arch/iomux.h> |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 28 | #include <asm/arch/mx6q_pins.h> |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 29 | #include <asm/errno.h> |
| 30 | #include <asm/gpio.h> |
Troy Kisky | af2a35f | 2012-07-19 08:18:22 +0000 | [diff] [blame] | 31 | #include <asm/imx-common/iomux-v3.h> |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 32 | #include <asm/imx-common/mxc_i2c.h> |
Troy Kisky | bb05b40 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 33 | #include <asm/imx-common/boot_mode.h> |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 34 | #include <mmc.h> |
| 35 | #include <fsl_esdhc.h> |
Troy Kisky | 3236921 | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 36 | #include <malloc.h> |
Troy Kisky | 2bf3359 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 37 | #include <micrel.h> |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 38 | #include <miiphy.h> |
| 39 | #include <netdev.h> |
Eric Nelson | e58010b | 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 | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 46 | DECLARE_GLOBAL_DATA_PTR; |
| 47 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 48 | #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 49 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 50 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 51 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 52 | #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ |
| 53 | PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \ |
| 54 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 55 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 56 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 57 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 58 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 59 | #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \ |
Eric Nelson | 373a1d8 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 60 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST) |
| 61 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 62 | #define BUTTON_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 63 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 64 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 65 | #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 66 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
Troy Kisky | 3174689 | 2012-04-24 17:33:26 +0000 | [diff] [blame] | 67 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 68 | |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 69 | int dram_init(void) |
| 70 | { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 71 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 72 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 73 | return 0; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 76 | iomux_v3_cfg_t const uart1_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 77 | MX6_PAD_SD3_DAT6__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 78 | MX6_PAD_SD3_DAT7__UART1_TXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
Troy Kisky | 8e7d7b6 | 2012-01-12 23:49:25 +0000 | [diff] [blame] | 79 | }; |
| 80 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 81 | iomux_v3_cfg_t const uart2_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 82 | MX6_PAD_EIM_D26__UART2_TXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 83 | MX6_PAD_EIM_D27__UART2_RXD | MUX_PAD_CTRL(UART_PAD_CTRL), |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 86 | #define PC MUX_PAD_CTRL(I2C_PAD_CTRL) |
| 87 | |
| 88 | /* I2C1, SGTL5000 */ |
| 89 | struct i2c_pads_info i2c_pad_info0 = { |
| 90 | .scl = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 91 | .i2c_mode = MX6_PAD_EIM_D21__I2C1_SCL | PC, |
| 92 | .gpio_mode = MX6_PAD_EIM_D21__GPIO_3_21 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 93 | .gp = IMX_GPIO_NR(3, 21) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 94 | }, |
| 95 | .sda = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 96 | .i2c_mode = MX6_PAD_EIM_D28__I2C1_SDA | PC, |
| 97 | .gpio_mode = MX6_PAD_EIM_D28__GPIO_3_28 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 98 | .gp = IMX_GPIO_NR(3, 28) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 99 | } |
| 100 | }; |
| 101 | |
| 102 | /* I2C2 Camera, MIPI */ |
| 103 | struct i2c_pads_info i2c_pad_info1 = { |
| 104 | .scl = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 105 | .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL | PC, |
| 106 | .gpio_mode = MX6_PAD_KEY_COL3__GPIO_4_12 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 107 | .gp = IMX_GPIO_NR(4, 12) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 108 | }, |
| 109 | .sda = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 110 | .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA | PC, |
| 111 | .gpio_mode = MX6_PAD_KEY_ROW3__GPIO_4_13 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 112 | .gp = IMX_GPIO_NR(4, 13) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 113 | } |
| 114 | }; |
| 115 | |
| 116 | /* I2C3, J15 - RGB connector */ |
| 117 | struct i2c_pads_info i2c_pad_info2 = { |
| 118 | .scl = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 119 | .i2c_mode = MX6_PAD_GPIO_5__I2C3_SCL | PC, |
| 120 | .gpio_mode = MX6_PAD_GPIO_5__GPIO_1_5 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 121 | .gp = IMX_GPIO_NR(1, 5) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 122 | }, |
| 123 | .sda = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 124 | .i2c_mode = MX6_PAD_GPIO_16__I2C3_SDA | PC, |
| 125 | .gpio_mode = MX6_PAD_GPIO_16__GPIO_7_11 | PC, |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 126 | .gp = IMX_GPIO_NR(7, 11) |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 127 | } |
Troy Kisky | 3174689 | 2012-04-24 17:33:26 +0000 | [diff] [blame] | 128 | }; |
| 129 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 130 | iomux_v3_cfg_t const usdhc3_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 131 | MX6_PAD_SD3_CLK__USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 132 | MX6_PAD_SD3_CMD__USDHC3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 133 | MX6_PAD_SD3_DAT0__USDHC3_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 134 | MX6_PAD_SD3_DAT1__USDHC3_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 135 | MX6_PAD_SD3_DAT2__USDHC3_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 136 | MX6_PAD_SD3_DAT3__USDHC3_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 137 | MX6_PAD_SD3_DAT5__GPIO_7_0 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 140 | iomux_v3_cfg_t const usdhc4_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 141 | MX6_PAD_SD4_CLK__USDHC4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 142 | MX6_PAD_SD4_CMD__USDHC4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 143 | MX6_PAD_SD4_DAT0__USDHC4_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 144 | MX6_PAD_SD4_DAT1__USDHC4_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 145 | MX6_PAD_SD4_DAT2__USDHC4_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 146 | MX6_PAD_SD4_DAT3__USDHC4_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), |
| 147 | MX6_PAD_NANDF_D6__GPIO_2_6 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 150 | iomux_v3_cfg_t const enet_pads1[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 151 | MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 152 | MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 153 | MX6_PAD_RGMII_TXC__ENET_RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 154 | MX6_PAD_RGMII_TD0__ENET_RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 155 | MX6_PAD_RGMII_TD1__ENET_RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 156 | MX6_PAD_RGMII_TD2__ENET_RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 157 | MX6_PAD_RGMII_TD3__ENET_RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 158 | MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 159 | MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 160 | /* pin 35 - 1 (PHY_AD2) on reset */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 161 | MX6_PAD_RGMII_RXC__GPIO_6_30 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 162 | /* pin 32 - 1 - (MODE0) all */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 163 | MX6_PAD_RGMII_RD0__GPIO_6_25 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 164 | /* pin 31 - 1 - (MODE1) all */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 165 | MX6_PAD_RGMII_RD1__GPIO_6_27 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 166 | /* pin 28 - 1 - (MODE2) all */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 167 | MX6_PAD_RGMII_RD2__GPIO_6_28 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 168 | /* pin 27 - 1 - (MODE3) all */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 169 | MX6_PAD_RGMII_RD3__GPIO_6_29 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 170 | /* pin 33 - 1 - (CLK125_EN) 125Mhz clockout enabled */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 171 | MX6_PAD_RGMII_RX_CTL__GPIO_6_24 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 172 | /* pin 42 PHY nRST */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 173 | MX6_PAD_EIM_D23__GPIO_3_23 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 174 | }; |
| 175 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 176 | iomux_v3_cfg_t const enet_pads2[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 177 | MX6_PAD_RGMII_RXC__ENET_RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 178 | MX6_PAD_RGMII_RD0__ENET_RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 179 | MX6_PAD_RGMII_RD1__ENET_RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 180 | MX6_PAD_RGMII_RD2__ENET_RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 181 | MX6_PAD_RGMII_RD3__ENET_RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL), |
| 182 | MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL), |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 183 | }; |
| 184 | |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 185 | /* Button assignments for J14 */ |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 186 | static iomux_v3_cfg_t const button_pads[] = { |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 187 | /* Menu */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 188 | MX6_PAD_NANDF_D1__GPIO_2_1 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 189 | /* Back */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 190 | MX6_PAD_NANDF_D2__GPIO_2_2 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 191 | /* Labelled Search (mapped to Power under Android) */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 192 | MX6_PAD_NANDF_D3__GPIO_2_3 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 193 | /* Home */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 194 | MX6_PAD_NANDF_D4__GPIO_2_4 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 195 | /* Volume Down */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 196 | MX6_PAD_GPIO_19__GPIO_4_5 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 197 | /* Volume Up */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 198 | MX6_PAD_GPIO_18__GPIO_7_13 | MUX_PAD_CTRL(BUTTON_PAD_CTRL), |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 199 | }; |
| 200 | |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 201 | static void setup_iomux_enet(void) |
| 202 | { |
Ashok Kumar Reddy | 5d20881 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 203 | gpio_direction_output(IMX_GPIO_NR(3, 23), 0); |
| 204 | gpio_direction_output(IMX_GPIO_NR(6, 30), 1); |
| 205 | gpio_direction_output(IMX_GPIO_NR(6, 25), 1); |
| 206 | gpio_direction_output(IMX_GPIO_NR(6, 27), 1); |
| 207 | gpio_direction_output(IMX_GPIO_NR(6, 28), 1); |
| 208 | gpio_direction_output(IMX_GPIO_NR(6, 29), 1); |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 209 | imx_iomux_v3_setup_multiple_pads(enet_pads1, ARRAY_SIZE(enet_pads1)); |
Ashok Kumar Reddy | 5d20881 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 210 | gpio_direction_output(IMX_GPIO_NR(6, 24), 1); |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 211 | |
| 212 | /* Need delay 10ms according to KSZ9021 spec */ |
| 213 | udelay(1000 * 10); |
Ashok Kumar Reddy | 5d20881 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 214 | gpio_set_value(IMX_GPIO_NR(3, 23), 1); |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 215 | |
| 216 | imx_iomux_v3_setup_multiple_pads(enet_pads2, ARRAY_SIZE(enet_pads2)); |
| 217 | } |
| 218 | |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 219 | iomux_v3_cfg_t const usb_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 220 | MX6_PAD_GPIO_17__GPIO_7_12 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Wolfgang Grandegger | 2ea73e9 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 221 | }; |
| 222 | |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 223 | static void setup_iomux_uart(void) |
| 224 | { |
Troy Kisky | 8e7d7b6 | 2012-01-12 23:49:25 +0000 | [diff] [blame] | 225 | imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 226 | imx_iomux_v3_setup_multiple_pads(uart2_pads, ARRAY_SIZE(uart2_pads)); |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Wolfgang Grandegger | 2ea73e9 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 229 | #ifdef CONFIG_USB_EHCI_MX6 |
| 230 | int board_ehci_hcd_init(int port) |
| 231 | { |
| 232 | imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads)); |
| 233 | |
| 234 | /* Reset USB hub */ |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 235 | gpio_direction_output(IMX_GPIO_NR(7, 12), 0); |
Wolfgang Grandegger | 2ea73e9 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 236 | mdelay(2); |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 237 | gpio_set_value(IMX_GPIO_NR(7, 12), 1); |
Wolfgang Grandegger | 2ea73e9 | 2012-02-08 22:33:26 +0000 | [diff] [blame] | 238 | |
| 239 | return 0; |
| 240 | } |
| 241 | #endif |
| 242 | |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 243 | #ifdef CONFIG_FSL_ESDHC |
| 244 | struct fsl_esdhc_cfg usdhc_cfg[2] = { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 245 | {USDHC3_BASE_ADDR}, |
| 246 | {USDHC4_BASE_ADDR}, |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 247 | }; |
| 248 | |
| 249 | int board_mmc_getcd(struct mmc *mmc) |
| 250 | { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 251 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
| 252 | int ret; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 253 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 254 | if (cfg->esdhc_base == USDHC3_BASE_ADDR) { |
Ashok Kumar Reddy | 5d20881 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 255 | gpio_direction_input(IMX_GPIO_NR(7, 0)); |
| 256 | ret = !gpio_get_value(IMX_GPIO_NR(7, 0)); |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 257 | } else { |
Ashok Kumar Reddy | 5d20881 | 2012-09-08 17:56:51 +0530 | [diff] [blame] | 258 | gpio_direction_input(IMX_GPIO_NR(2, 6)); |
| 259 | ret = !gpio_get_value(IMX_GPIO_NR(2, 6)); |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 260 | } |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 261 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 262 | return ret; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | int board_mmc_init(bd_t *bis) |
| 266 | { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 267 | s32 status = 0; |
| 268 | u32 index = 0; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 269 | |
Benoît Thébaudeau | a2ac1b3 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 270 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 271 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); |
| 272 | |
Abbas Raza | aad4659 | 2013-03-25 09:13:34 +0000 | [diff] [blame] | 273 | usdhc_cfg[0].max_bus_width = 4; |
| 274 | usdhc_cfg[1].max_bus_width = 4; |
| 275 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 276 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { |
| 277 | switch (index) { |
| 278 | case 0: |
| 279 | imx_iomux_v3_setup_multiple_pads( |
| 280 | usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); |
| 281 | break; |
| 282 | case 1: |
| 283 | imx_iomux_v3_setup_multiple_pads( |
| 284 | usdhc4_pads, ARRAY_SIZE(usdhc4_pads)); |
Wolfgang Denk | f5cdc11 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 285 | break; |
| 286 | default: |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 287 | printf("Warning: you configured more USDHC controllers" |
Wolfgang Denk | f5cdc11 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 288 | "(%d) then supported by the board (%d)\n", |
| 289 | index + 1, CONFIG_SYS_FSL_USDHC_NUM); |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 290 | return status; |
| 291 | } |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 292 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 293 | status |= fsl_esdhc_initialize(bis, &usdhc_cfg[index]); |
| 294 | } |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 295 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 296 | return status; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 297 | } |
| 298 | #endif |
| 299 | |
Eric Nelson | 373a1d8 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 300 | #ifdef CONFIG_MXC_SPI |
Eric Nelson | 6e14232 | 2012-10-03 07:26:38 +0000 | [diff] [blame] | 301 | iomux_v3_cfg_t const ecspi1_pads[] = { |
Eric Nelson | 373a1d8 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 302 | /* SS1 */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 303 | MX6_PAD_EIM_D19__GPIO_3_19 | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 304 | MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 305 | MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL), |
| 306 | MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL), |
Eric Nelson | 373a1d8 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 307 | }; |
| 308 | |
| 309 | void setup_spi(void) |
| 310 | { |
Eric Nelson | ba54b92 | 2012-01-31 07:52:09 +0000 | [diff] [blame] | 311 | gpio_direction_output(CONFIG_SF_DEFAULT_CS, 1); |
Eric Nelson | 373a1d8 | 2012-01-31 07:52:05 +0000 | [diff] [blame] | 312 | imx_iomux_v3_setup_multiple_pads(ecspi1_pads, |
| 313 | ARRAY_SIZE(ecspi1_pads)); |
| 314 | } |
| 315 | #endif |
| 316 | |
Troy Kisky | 2bf3359 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 317 | int board_phy_config(struct phy_device *phydev) |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 318 | { |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 319 | /* min rx data delay */ |
Troy Kisky | 2bf3359 | 2012-02-07 14:08:50 +0000 | [diff] [blame] | 320 | ksz9021_phy_extended_write(phydev, |
| 321 | MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0x0); |
| 322 | /* min tx data delay */ |
| 323 | ksz9021_phy_extended_write(phydev, |
| 324 | MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0x0); |
| 325 | /* max rx/tx clock delay, min rx/tx control */ |
| 326 | ksz9021_phy_extended_write(phydev, |
| 327 | MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0xf0f0); |
| 328 | if (phydev->drv->config) |
| 329 | phydev->drv->config(phydev); |
Wolfgang Denk | f5cdc11 | 2012-04-16 23:13:51 +0200 | [diff] [blame] | 330 | |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | int board_eth_init(bd_t *bis) |
| 335 | { |
Troy Kisky | 3236921 | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 336 | uint32_t base = IMX_FEC_BASE; |
| 337 | struct mii_dev *bus = NULL; |
| 338 | struct phy_device *phydev = NULL; |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 339 | int ret; |
| 340 | |
| 341 | setup_iomux_enet(); |
| 342 | |
Troy Kisky | 3236921 | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 343 | #ifdef CONFIG_FEC_MXC |
| 344 | bus = fec_get_miibus(base, -1); |
| 345 | if (!bus) |
| 346 | return 0; |
| 347 | /* scan phy 4,5,6,7 */ |
| 348 | phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); |
| 349 | if (!phydev) { |
| 350 | free(bus); |
| 351 | return 0; |
| 352 | } |
| 353 | printf("using phy at %d\n", phydev->addr); |
| 354 | ret = fec_probe(bis, -1, base, bus, phydev); |
| 355 | if (ret) { |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 356 | printf("FEC MXC: %s:failed\n", __func__); |
Troy Kisky | 3236921 | 2012-10-22 16:40:47 +0000 | [diff] [blame] | 357 | free(phydev); |
| 358 | free(bus); |
| 359 | } |
| 360 | #endif |
Jason Liu | 2af81e2 | 2012-01-12 22:56:16 +0000 | [diff] [blame] | 361 | return 0; |
| 362 | } |
| 363 | |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 364 | static void setup_buttons(void) |
| 365 | { |
| 366 | imx_iomux_v3_setup_multiple_pads(button_pads, |
| 367 | ARRAY_SIZE(button_pads)); |
| 368 | } |
| 369 | |
Eric Nelson | 3996a96 | 2012-05-01 09:55:11 +0000 | [diff] [blame] | 370 | #ifdef CONFIG_CMD_SATA |
| 371 | |
| 372 | int setup_sata(void) |
| 373 | { |
| 374 | struct iomuxc_base_regs *const iomuxc_regs |
| 375 | = (struct iomuxc_base_regs *) IOMUXC_BASE_ADDR; |
| 376 | int ret = enable_sata_clock(); |
| 377 | if (ret) |
| 378 | return ret; |
| 379 | |
| 380 | clrsetbits_le32(&iomuxc_regs->gpr[13], |
| 381 | IOMUXC_GPR13_SATA_MASK, |
| 382 | IOMUXC_GPR13_SATA_PHY_8_RXEQ_3P0DB |
| 383 | |IOMUXC_GPR13_SATA_PHY_7_SATA2M |
| 384 | |IOMUXC_GPR13_SATA_SPEED_3G |
| 385 | |(3<<IOMUXC_GPR13_SATA_PHY_6_SHIFT) |
| 386 | |IOMUXC_GPR13_SATA_SATA_PHY_5_SS_DISABLED |
| 387 | |IOMUXC_GPR13_SATA_SATA_PHY_4_ATTEN_9_16 |
| 388 | |IOMUXC_GPR13_SATA_PHY_3_TXBOOST_0P00_DB |
| 389 | |IOMUXC_GPR13_SATA_PHY_2_TX_1P104V |
| 390 | |IOMUXC_GPR13_SATA_PHY_1_SLOW); |
| 391 | |
| 392 | return 0; |
| 393 | } |
| 394 | #endif |
| 395 | |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 396 | #if defined(CONFIG_VIDEO_IPUV3) |
| 397 | |
| 398 | static iomux_v3_cfg_t const backlight_pads[] = { |
| 399 | /* Backlight on RGB connector: J15 */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 400 | MX6_PAD_SD1_DAT3__GPIO_1_21 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 401 | #define RGB_BACKLIGHT_GP IMX_GPIO_NR(1, 21) |
| 402 | |
| 403 | /* Backlight on LVDS connector: J6 */ |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 404 | MX6_PAD_SD1_CMD__GPIO_1_18 | MUX_PAD_CTRL(NO_PAD_CTRL), |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 405 | #define LVDS_BACKLIGHT_GP IMX_GPIO_NR(1, 18) |
| 406 | }; |
| 407 | |
| 408 | static iomux_v3_cfg_t const rgb_pads[] = { |
Eric Nelson | cfb8b9d | 2013-02-19 10:07:01 +0000 | [diff] [blame] | 409 | MX6_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK, |
| 410 | MX6_PAD_DI0_PIN15__IPU1_DI0_PIN15, |
| 411 | MX6_PAD_DI0_PIN2__IPU1_DI0_PIN2, |
| 412 | MX6_PAD_DI0_PIN3__IPU1_DI0_PIN3, |
| 413 | MX6_PAD_DI0_PIN4__GPIO_4_20, |
| 414 | MX6_PAD_DISP0_DAT0__IPU1_DISP0_DAT_0, |
| 415 | MX6_PAD_DISP0_DAT1__IPU1_DISP0_DAT_1, |
| 416 | MX6_PAD_DISP0_DAT2__IPU1_DISP0_DAT_2, |
| 417 | MX6_PAD_DISP0_DAT3__IPU1_DISP0_DAT_3, |
| 418 | MX6_PAD_DISP0_DAT4__IPU1_DISP0_DAT_4, |
| 419 | MX6_PAD_DISP0_DAT5__IPU1_DISP0_DAT_5, |
| 420 | MX6_PAD_DISP0_DAT6__IPU1_DISP0_DAT_6, |
| 421 | MX6_PAD_DISP0_DAT7__IPU1_DISP0_DAT_7, |
| 422 | MX6_PAD_DISP0_DAT8__IPU1_DISP0_DAT_8, |
| 423 | MX6_PAD_DISP0_DAT9__IPU1_DISP0_DAT_9, |
| 424 | MX6_PAD_DISP0_DAT10__IPU1_DISP0_DAT_10, |
| 425 | MX6_PAD_DISP0_DAT11__IPU1_DISP0_DAT_11, |
| 426 | MX6_PAD_DISP0_DAT12__IPU1_DISP0_DAT_12, |
| 427 | MX6_PAD_DISP0_DAT13__IPU1_DISP0_DAT_13, |
| 428 | MX6_PAD_DISP0_DAT14__IPU1_DISP0_DAT_14, |
| 429 | MX6_PAD_DISP0_DAT15__IPU1_DISP0_DAT_15, |
| 430 | MX6_PAD_DISP0_DAT16__IPU1_DISP0_DAT_16, |
| 431 | MX6_PAD_DISP0_DAT17__IPU1_DISP0_DAT_17, |
| 432 | MX6_PAD_DISP0_DAT18__IPU1_DISP0_DAT_18, |
| 433 | MX6_PAD_DISP0_DAT19__IPU1_DISP0_DAT_19, |
| 434 | MX6_PAD_DISP0_DAT20__IPU1_DISP0_DAT_20, |
| 435 | MX6_PAD_DISP0_DAT21__IPU1_DISP0_DAT_21, |
| 436 | MX6_PAD_DISP0_DAT22__IPU1_DISP0_DAT_22, |
| 437 | MX6_PAD_DISP0_DAT23__IPU1_DISP0_DAT_23, |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 438 | }; |
| 439 | |
| 440 | struct display_info_t { |
| 441 | int bus; |
| 442 | int addr; |
| 443 | int pixfmt; |
| 444 | int (*detect)(struct display_info_t const *dev); |
| 445 | void (*enable)(struct display_info_t const *dev); |
| 446 | struct fb_videomode mode; |
| 447 | }; |
| 448 | |
| 449 | |
| 450 | static int detect_hdmi(struct display_info_t const *dev) |
| 451 | { |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 452 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
| 453 | return readb(&hdmi->phy_stat0) & HDMI_PHY_HPD; |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | static void enable_hdmi(struct display_info_t const *dev) |
| 457 | { |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 458 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 459 | u8 reg; |
| 460 | printf("%s: setup HDMI monitor\n", __func__); |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 461 | reg = readb(&hdmi->phy_conf0); |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 462 | reg |= HDMI_PHY_CONF0_PDZ_MASK; |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 463 | writeb(reg, &hdmi->phy_conf0); |
| 464 | |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 465 | udelay(3000); |
| 466 | reg |= HDMI_PHY_CONF0_ENTMDS_MASK; |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 467 | writeb(reg, &hdmi->phy_conf0); |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 468 | udelay(3000); |
| 469 | reg |= HDMI_PHY_CONF0_GEN2_TXPWRON_MASK; |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 470 | writeb(reg, &hdmi->phy_conf0); |
| 471 | writeb(HDMI_MC_PHYRSTZ_ASSERT, &hdmi->mc_phyrstz); |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | static int detect_i2c(struct display_info_t const *dev) |
| 475 | { |
| 476 | return ((0 == i2c_set_bus_num(dev->bus)) |
| 477 | && |
| 478 | (0 == i2c_probe(dev->addr))); |
| 479 | } |
| 480 | |
| 481 | static void enable_lvds(struct display_info_t const *dev) |
| 482 | { |
| 483 | struct iomuxc *iomux = (struct iomuxc *) |
| 484 | IOMUXC_BASE_ADDR; |
| 485 | u32 reg = readl(&iomux->gpr[2]); |
| 486 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT; |
| 487 | writel(reg, &iomux->gpr[2]); |
| 488 | gpio_direction_output(LVDS_BACKLIGHT_GP, 1); |
| 489 | } |
| 490 | |
| 491 | static void enable_rgb(struct display_info_t const *dev) |
| 492 | { |
| 493 | imx_iomux_v3_setup_multiple_pads( |
| 494 | rgb_pads, |
| 495 | ARRAY_SIZE(rgb_pads)); |
| 496 | gpio_direction_output(RGB_BACKLIGHT_GP, 1); |
| 497 | } |
| 498 | |
| 499 | static struct display_info_t const displays[] = {{ |
| 500 | .bus = -1, |
| 501 | .addr = 0, |
| 502 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 503 | .detect = detect_hdmi, |
| 504 | .enable = enable_hdmi, |
| 505 | .mode = { |
| 506 | .name = "HDMI", |
| 507 | .refresh = 60, |
| 508 | .xres = 1024, |
| 509 | .yres = 768, |
| 510 | .pixclock = 15385, |
| 511 | .left_margin = 220, |
| 512 | .right_margin = 40, |
| 513 | .upper_margin = 21, |
| 514 | .lower_margin = 7, |
| 515 | .hsync_len = 60, |
| 516 | .vsync_len = 10, |
| 517 | .sync = FB_SYNC_EXT, |
| 518 | .vmode = FB_VMODE_NONINTERLACED |
| 519 | } }, { |
| 520 | .bus = 2, |
| 521 | .addr = 0x4, |
| 522 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 523 | .detect = detect_i2c, |
| 524 | .enable = enable_lvds, |
| 525 | .mode = { |
| 526 | .name = "Hannstar-XGA", |
| 527 | .refresh = 60, |
| 528 | .xres = 1024, |
| 529 | .yres = 768, |
| 530 | .pixclock = 15385, |
| 531 | .left_margin = 220, |
| 532 | .right_margin = 40, |
| 533 | .upper_margin = 21, |
| 534 | .lower_margin = 7, |
| 535 | .hsync_len = 60, |
| 536 | .vsync_len = 10, |
| 537 | .sync = FB_SYNC_EXT, |
| 538 | .vmode = FB_VMODE_NONINTERLACED |
| 539 | } }, { |
| 540 | .bus = 2, |
| 541 | .addr = 0x38, |
| 542 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 543 | .detect = detect_i2c, |
| 544 | .enable = enable_lvds, |
| 545 | .mode = { |
| 546 | .name = "wsvga-lvds", |
| 547 | .refresh = 60, |
| 548 | .xres = 1024, |
| 549 | .yres = 600, |
| 550 | .pixclock = 15385, |
| 551 | .left_margin = 220, |
| 552 | .right_margin = 40, |
| 553 | .upper_margin = 21, |
| 554 | .lower_margin = 7, |
| 555 | .hsync_len = 60, |
| 556 | .vsync_len = 10, |
| 557 | .sync = FB_SYNC_EXT, |
| 558 | .vmode = FB_VMODE_NONINTERLACED |
| 559 | } }, { |
| 560 | .bus = 2, |
| 561 | .addr = 0x48, |
| 562 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 563 | .detect = detect_i2c, |
| 564 | .enable = enable_rgb, |
| 565 | .mode = { |
| 566 | .name = "wvga-rgb", |
| 567 | .refresh = 57, |
| 568 | .xres = 800, |
| 569 | .yres = 480, |
| 570 | .pixclock = 37037, |
| 571 | .left_margin = 40, |
| 572 | .right_margin = 60, |
| 573 | .upper_margin = 10, |
| 574 | .lower_margin = 10, |
| 575 | .hsync_len = 20, |
| 576 | .vsync_len = 10, |
| 577 | .sync = 0, |
| 578 | .vmode = FB_VMODE_NONINTERLACED |
| 579 | } } }; |
| 580 | |
| 581 | int board_video_skip(void) |
| 582 | { |
| 583 | int i; |
| 584 | int ret; |
| 585 | char const *panel = getenv("panel"); |
| 586 | if (!panel) { |
| 587 | for (i = 0; i < ARRAY_SIZE(displays); i++) { |
| 588 | struct display_info_t const *dev = displays+i; |
| 589 | if (dev->detect(dev)) { |
| 590 | panel = dev->mode.name; |
| 591 | printf("auto-detected panel %s\n", panel); |
| 592 | break; |
| 593 | } |
| 594 | } |
| 595 | if (!panel) { |
| 596 | panel = displays[0].mode.name; |
| 597 | printf("No panel detected: default to %s\n", panel); |
| 598 | } |
| 599 | } else { |
| 600 | for (i = 0; i < ARRAY_SIZE(displays); i++) { |
| 601 | if (!strcmp(panel, displays[i].mode.name)) |
| 602 | break; |
| 603 | } |
| 604 | } |
| 605 | if (i < ARRAY_SIZE(displays)) { |
| 606 | ret = ipuv3_fb_init(&displays[i].mode, 0, |
| 607 | displays[i].pixfmt); |
| 608 | if (!ret) { |
| 609 | displays[i].enable(displays+i); |
| 610 | printf("Display: %s (%ux%u)\n", |
| 611 | displays[i].mode.name, |
| 612 | displays[i].mode.xres, |
| 613 | displays[i].mode.yres); |
| 614 | } else |
| 615 | printf("LCD %s cannot be configured: %d\n", |
| 616 | displays[i].mode.name, ret); |
| 617 | } else { |
| 618 | printf("unsupported panel %s\n", panel); |
| 619 | ret = -EINVAL; |
| 620 | } |
| 621 | return (0 != ret); |
| 622 | } |
| 623 | |
| 624 | static void setup_display(void) |
| 625 | { |
| 626 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 627 | struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR; |
| 628 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 629 | struct hdmi_regs *hdmi = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR; |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 630 | |
| 631 | int reg; |
| 632 | |
| 633 | /* Turn on LDB0,IPU,IPU DI0 clocks */ |
| 634 | reg = __raw_readl(&mxc_ccm->CCGR3); |
| 635 | reg |= MXC_CCM_CCGR3_IPU1_IPU_DI0_OFFSET |
| 636 | |MXC_CCM_CCGR3_LDB_DI0_MASK; |
| 637 | writel(reg, &mxc_ccm->CCGR3); |
| 638 | |
| 639 | /* Turn on HDMI PHY clock */ |
| 640 | reg = __raw_readl(&mxc_ccm->CCGR2); |
| 641 | reg |= MXC_CCM_CCGR2_HDMI_TX_IAHBCLK_MASK |
| 642 | |MXC_CCM_CCGR2_HDMI_TX_ISFRCLK_MASK; |
| 643 | writel(reg, &mxc_ccm->CCGR2); |
| 644 | |
| 645 | /* clear HDMI PHY reset */ |
Fabio Estevam | 1b097cf | 2013-02-28 14:35:02 +0000 | [diff] [blame] | 646 | writeb(HDMI_MC_PHYRSTZ_DEASSERT, &hdmi->mc_phyrstz); |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 647 | |
| 648 | /* set PFD1_FRAC to 0x13 == 455 MHz (480*18)/0x13 */ |
| 649 | writel(ANATOP_PFD_480_PFD1_FRAC_MASK, &anatop->pfd_480_clr); |
| 650 | writel(0x13<<ANATOP_PFD_480_PFD1_FRAC_SHIFT, &anatop->pfd_480_set); |
| 651 | |
| 652 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 653 | reg = readl(&mxc_ccm->cs2cdr); |
| 654 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 655 | |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 656 | reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 657 | |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 658 | writel(reg, &mxc_ccm->cs2cdr); |
| 659 | |
| 660 | reg = readl(&mxc_ccm->cscmr2); |
| 661 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV; |
| 662 | writel(reg, &mxc_ccm->cscmr2); |
| 663 | |
| 664 | reg = readl(&mxc_ccm->chsccdr); |
| 665 | reg &= ~(MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_MASK |
| 666 | |MXC_CCM_CHSCCDR_IPU1_DI0_PODF_MASK |
| 667 | |MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_MASK); |
| 668 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 669 | <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET) |
| 670 | |(CHSCCDR_PODF_DIVIDE_BY_3 |
| 671 | <<MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET) |
| 672 | |(CHSCCDR_IPU_PRE_CLK_540M_PFD |
| 673 | <<MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET); |
| 674 | writel(reg, &mxc_ccm->chsccdr); |
| 675 | |
| 676 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 677 | |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
| 678 | |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 679 | |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 680 | |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 681 | |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 682 | |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 683 | |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
| 684 | |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0; |
| 685 | writel(reg, &iomux->gpr[2]); |
| 686 | |
| 687 | reg = readl(&iomux->gpr[3]); |
| 688 | reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK) |
| 689 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 690 | <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET); |
| 691 | writel(reg, &iomux->gpr[3]); |
| 692 | |
| 693 | /* backlights off until needed */ |
| 694 | imx_iomux_v3_setup_multiple_pads(backlight_pads, |
| 695 | ARRAY_SIZE(backlight_pads)); |
| 696 | gpio_direction_input(LVDS_BACKLIGHT_GP); |
| 697 | gpio_direction_input(RGB_BACKLIGHT_GP); |
| 698 | } |
| 699 | #endif |
| 700 | |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 701 | int board_early_init_f(void) |
| 702 | { |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 703 | setup_iomux_uart(); |
| 704 | setup_buttons(); |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 705 | |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 706 | #if defined(CONFIG_VIDEO_IPUV3) |
| 707 | setup_display(); |
| 708 | #endif |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 709 | return 0; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 710 | } |
| 711 | |
Eric Nelson | e58010b | 2012-10-03 07:28:43 +0000 | [diff] [blame] | 712 | /* |
| 713 | * Do not overwrite the console |
| 714 | * Use always serial for U-Boot console |
| 715 | */ |
| 716 | int overwrite_console(void) |
| 717 | { |
| 718 | return 1; |
| 719 | } |
| 720 | |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 721 | int board_init(void) |
| 722 | { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 723 | /* address of boot parameters */ |
| 724 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 725 | |
Eric Nelson | d928a8f | 2012-02-26 12:03:15 +0000 | [diff] [blame] | 726 | #ifdef CONFIG_MXC_SPI |
| 727 | setup_spi(); |
| 728 | #endif |
Troy Kisky | 9c06782 | 2012-07-19 08:18:26 +0000 | [diff] [blame] | 729 | setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info0); |
| 730 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1); |
| 731 | setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2); |
Eric Nelson | d928a8f | 2012-02-26 12:03:15 +0000 | [diff] [blame] | 732 | |
Eric Nelson | 3996a96 | 2012-05-01 09:55:11 +0000 | [diff] [blame] | 733 | #ifdef CONFIG_CMD_SATA |
| 734 | setup_sata(); |
| 735 | #endif |
| 736 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 737 | return 0; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | int checkboard(void) |
| 741 | { |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 742 | puts("Board: MX6Q-Sabre Lite\n"); |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 743 | |
Eric Nelson | 74cf809 | 2013-02-19 10:07:00 +0000 | [diff] [blame] | 744 | return 0; |
Jason Liu | bc5833c | 2011-12-29 06:34:19 +0000 | [diff] [blame] | 745 | } |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 746 | |
| 747 | struct button_key { |
| 748 | char const *name; |
| 749 | unsigned gpnum; |
| 750 | char ident; |
| 751 | }; |
| 752 | |
| 753 | static struct button_key const buttons[] = { |
Stefano Babic | 5fecb36 | 2012-08-19 21:33:50 +0000 | [diff] [blame] | 754 | {"back", IMX_GPIO_NR(2, 2), 'B'}, |
| 755 | {"home", IMX_GPIO_NR(2, 4), 'H'}, |
| 756 | {"menu", IMX_GPIO_NR(2, 1), 'M'}, |
| 757 | {"search", IMX_GPIO_NR(2, 3), 'S'}, |
| 758 | {"volup", IMX_GPIO_NR(7, 13), 'V'}, |
| 759 | {"voldown", IMX_GPIO_NR(4, 5), 'v'}, |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 760 | }; |
| 761 | |
| 762 | /* |
| 763 | * generate a null-terminated string containing the buttons pressed |
| 764 | * returns number of keys pressed |
| 765 | */ |
| 766 | static int read_keys(char *buf) |
| 767 | { |
| 768 | int i, numpressed = 0; |
| 769 | for (i = 0; i < ARRAY_SIZE(buttons); i++) { |
| 770 | if (!gpio_get_value(buttons[i].gpnum)) |
| 771 | buf[numpressed++] = buttons[i].ident; |
| 772 | } |
| 773 | buf[numpressed] = '\0'; |
| 774 | return numpressed; |
| 775 | } |
| 776 | |
| 777 | static int do_kbd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 778 | { |
| 779 | char envvalue[ARRAY_SIZE(buttons)+1]; |
| 780 | int numpressed = read_keys(envvalue); |
| 781 | setenv("keybd", envvalue); |
| 782 | return numpressed == 0; |
| 783 | } |
| 784 | |
| 785 | U_BOOT_CMD( |
| 786 | kbd, 1, 1, do_kbd, |
| 787 | "Tests for keypresses, sets 'keybd' environment variable", |
| 788 | "Returns 0 (true) to shell if key is pressed." |
| 789 | ); |
| 790 | |
| 791 | #ifdef CONFIG_PREBOOT |
| 792 | static char const kbd_magic_prefix[] = "key_magic"; |
| 793 | static char const kbd_command_prefix[] = "key_cmd"; |
| 794 | |
| 795 | static void preboot_keys(void) |
| 796 | { |
| 797 | int numpressed; |
| 798 | char keypress[ARRAY_SIZE(buttons)+1]; |
| 799 | numpressed = read_keys(keypress); |
| 800 | if (numpressed) { |
| 801 | char *kbd_magic_keys = getenv("magic_keys"); |
| 802 | char *suffix; |
| 803 | /* |
| 804 | * loop over all magic keys |
| 805 | */ |
| 806 | for (suffix = kbd_magic_keys; *suffix; ++suffix) { |
| 807 | char *keys; |
| 808 | char magic[sizeof(kbd_magic_prefix) + 1]; |
| 809 | sprintf(magic, "%s%c", kbd_magic_prefix, *suffix); |
| 810 | keys = getenv(magic); |
| 811 | if (keys) { |
| 812 | if (!strcmp(keys, keypress)) |
| 813 | break; |
| 814 | } |
| 815 | } |
| 816 | if (*suffix) { |
| 817 | char cmd_name[sizeof(kbd_command_prefix) + 1]; |
| 818 | char *cmd; |
| 819 | sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix); |
| 820 | cmd = getenv(cmd_name); |
| 821 | if (cmd) { |
| 822 | setenv("preboot", cmd); |
| 823 | return; |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | } |
| 828 | #endif |
| 829 | |
Troy Kisky | bb05b40 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 830 | #ifdef CONFIG_CMD_BMODE |
| 831 | static const struct boot_mode board_boot_modes[] = { |
| 832 | /* 4 bit bus width */ |
| 833 | {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 834 | {"mmc1", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)}, |
| 835 | {NULL, 0}, |
| 836 | }; |
| 837 | #endif |
| 838 | |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 839 | int misc_init_r(void) |
| 840 | { |
| 841 | #ifdef CONFIG_PREBOOT |
| 842 | preboot_keys(); |
| 843 | #endif |
Troy Kisky | bb05b40 | 2012-08-15 10:31:21 +0000 | [diff] [blame] | 844 | |
| 845 | #ifdef CONFIG_CMD_BMODE |
| 846 | add_board_boot_modes(board_boot_modes); |
| 847 | #endif |
Eric Nelson | 28fdbdd | 2012-04-25 14:14:04 +0000 | [diff] [blame] | 848 | return 0; |
| 849 | } |