blob: d799fe6526af9733a503575a6d84b7837869a6e3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jagan Teki0d6d48b2016-10-08 18:00:11 +05302/*
3 * Copyright (C) 2016 Amarula Solutions B.V.
4 * Copyright (C) 2016 Engicam S.r.l.
5 * Author: Jagan Teki <jagan@amarulasolutions.com>
Jagan Teki0d6d48b2016-10-08 18:00:11 +05306 */
7
Jagan Teki0d6d48b2016-10-08 18:00:11 +05308
9#include <asm/io.h>
10#include <asm/gpio.h>
11#include <linux/sizes.h>
12
13#include <asm/arch/clock.h>
Jagan Teki12c8e2d2016-10-08 18:00:13 +053014#include <asm/arch/crm_regs.h>
Jagan Teki0d6d48b2016-10-08 18:00:11 +053015#include <asm/arch/iomux.h>
16#include <asm/arch/mx6-pins.h>
17#include <asm/arch/sys_proto.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020018#include <asm/mach-imx/iomux-v3.h>
19#include <asm/mach-imx/video.h>
Jagan Teki0d6d48b2016-10-08 18:00:11 +053020
Jagan Tekic5d86812017-05-07 02:43:14 +053021#include "../common/board.h"
22
Jagan Teki0313c132016-10-25 11:53:23 +053023#ifdef CONFIG_NAND_MXS
Jagan Teki0313c132016-10-25 11:53:23 +053024#define GPMI_PAD_CTRL0 (PAD_CTL_PKE | PAD_CTL_PUE | PAD_CTL_PUS_100K_UP)
25#define GPMI_PAD_CTRL1 (PAD_CTL_DSE_40ohm | PAD_CTL_SPEED_MED | \
26 PAD_CTL_SRE_FAST)
27#define GPMI_PAD_CTRL2 (GPMI_PAD_CTRL0 | GPMI_PAD_CTRL1)
28
Jagan Teki515bd002017-11-21 00:02:16 +053029static iomux_v3_cfg_t gpmi_pads[] = {
Jagan Teki0313c132016-10-25 11:53:23 +053030 IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
31 IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
32 IOMUX_PADS(PAD_NANDF_WP_B__NAND_WP_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
33 IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B | MUX_PAD_CTRL(GPMI_PAD_CTRL0)),
34 IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
35 IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
36 IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
37 IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
38 IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
39 IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
40 IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
41 IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
42 IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
43 IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
44 IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07 | MUX_PAD_CTRL(GPMI_PAD_CTRL2)),
45};
46
Jagan Tekic5d86812017-05-07 02:43:14 +053047void setup_gpmi_nand(void)
Jagan Teki0313c132016-10-25 11:53:23 +053048{
49 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
50
51 /* config gpmi nand iomux */
52 SETUP_IOMUX_PADS(gpmi_pads);
53
54 /* gate ENFC_CLK_ROOT clock first,before clk source switch */
55 clrbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
56
57 /* config gpmi and bch clock to 100 MHz */
58 clrsetbits_le32(&mxc_ccm->cs2cdr,
59 MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK |
60 MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK |
61 MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK,
62 MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
63 MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
64 MXC_CCM_CS2CDR_ENFC_CLK_SEL(3));
65
66 /* enable ENFC_CLK_ROOT clock */
67 setbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
68
69 /* enable gpmi and bch clock gating */
70 setbits_le32(&mxc_ccm->CCGR4,
71 MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK |
72 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK |
73 MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK |
74 MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK |
75 MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET);
76
77 /* enable apbh clock gating */
78 setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
79}
80#endif
81
Jagan Tekib62dc482016-12-06 00:00:55 +010082#if defined(CONFIG_VIDEO_IPUV3)
83static iomux_v3_cfg_t const rgb_pads[] = {
84 IOMUX_PADS(PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK),
85 IOMUX_PADS(PAD_DI0_PIN15__IPU1_DI0_PIN15),
86 IOMUX_PADS(PAD_DI0_PIN2__IPU1_DI0_PIN02),
87 IOMUX_PADS(PAD_DI0_PIN3__IPU1_DI0_PIN03),
88 IOMUX_PADS(PAD_DISP0_DAT0__IPU1_DISP0_DATA00),
89 IOMUX_PADS(PAD_DISP0_DAT1__IPU1_DISP0_DATA01),
90 IOMUX_PADS(PAD_DISP0_DAT2__IPU1_DISP0_DATA02),
91 IOMUX_PADS(PAD_DISP0_DAT3__IPU1_DISP0_DATA03),
92 IOMUX_PADS(PAD_DISP0_DAT4__IPU1_DISP0_DATA04),
93 IOMUX_PADS(PAD_DISP0_DAT5__IPU1_DISP0_DATA05),
94 IOMUX_PADS(PAD_DISP0_DAT6__IPU1_DISP0_DATA06),
95 IOMUX_PADS(PAD_DISP0_DAT7__IPU1_DISP0_DATA07),
96 IOMUX_PADS(PAD_DISP0_DAT8__IPU1_DISP0_DATA08),
97 IOMUX_PADS(PAD_DISP0_DAT9__IPU1_DISP0_DATA09),
98 IOMUX_PADS(PAD_DISP0_DAT10__IPU1_DISP0_DATA10),
99 IOMUX_PADS(PAD_DISP0_DAT11__IPU1_DISP0_DATA11),
100 IOMUX_PADS(PAD_DISP0_DAT12__IPU1_DISP0_DATA12),
101 IOMUX_PADS(PAD_DISP0_DAT13__IPU1_DISP0_DATA13),
102 IOMUX_PADS(PAD_DISP0_DAT14__IPU1_DISP0_DATA14),
103 IOMUX_PADS(PAD_DISP0_DAT15__IPU1_DISP0_DATA15),
104 IOMUX_PADS(PAD_DISP0_DAT16__IPU1_DISP0_DATA16),
105 IOMUX_PADS(PAD_DISP0_DAT17__IPU1_DISP0_DATA17),
106};
107
108static void enable_rgb(struct display_info_t const *dev)
109{
110 SETUP_IOMUX_PADS(rgb_pads);
111}
112
113struct display_info_t const displays[] = {
114 {
115 .bus = -1,
116 .addr = 0,
117 .pixfmt = IPU_PIX_FMT_RGB666,
118 .detect = NULL,
119 .enable = enable_rgb,
120 .mode = {
121 .name = "Amp-WD",
122 .refresh = 60,
123 .xres = 800,
124 .yres = 480,
125 .pixclock = 30000,
126 .left_margin = 30,
127 .right_margin = 30,
128 .upper_margin = 5,
129 .lower_margin = 5,
130 .hsync_len = 64,
131 .vsync_len = 20,
132 .sync = FB_SYNC_EXT,
133 .vmode = FB_VMODE_NONINTERLACED
134 }
135 },
136};
137
138size_t display_count = ARRAY_SIZE(displays);
139
Jagan Tekic5d86812017-05-07 02:43:14 +0530140void setup_display(void)
Jagan Tekib62dc482016-12-06 00:00:55 +0100141{
142 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
143 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
144 int reg;
145
146 enable_ipu_clock();
147
148 /* Turn on LDB0,IPU,IPU DI0 clocks */
149 reg = __raw_readl(&mxc_ccm->CCGR3);
150 reg |= (MXC_CCM_CCGR3_LDB_DI0_MASK | 0xffff);
151 writel(reg, &mxc_ccm->CCGR3);
152
153 /* set LDB0, LDB1 clk select to 011/011 */
154 reg = readl(&mxc_ccm->cs2cdr);
155 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
156 MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
157 reg |= (3 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
158 (3 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
159 writel(reg, &mxc_ccm->cs2cdr);
160
161 reg = readl(&mxc_ccm->cscmr2);
162 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
163 writel(reg, &mxc_ccm->cscmr2);
164
165 reg = readl(&mxc_ccm->chsccdr);
166 reg |= (CHSCCDR_CLK_SEL_LDB_DI0 <<
167 MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
168 writel(reg, &mxc_ccm->chsccdr);
169
170 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
171 IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
172 IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
173 IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
174 IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
175 IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
176 IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
177 IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
178 IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
179 writel(reg, &iomux->gpr[2]);
180
181 reg = readl(&iomux->gpr[3]);
182 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK) |
183 (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 <<
184 IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
185 writel(reg, &iomux->gpr[3]);
186}
187#endif /* CONFIG_VIDEO_IPUV3 */
Jagan Teki515bd002017-11-21 00:02:16 +0530188
189#ifdef CONFIG_ENV_IS_IN_MMC
190int board_mmc_get_env_dev(int devno)
191{
Jagan Tekidc91b402017-11-21 00:02:17 +0530192 /* i.CoreM6 RQS has USDHC3 for SD and USDHC4 for eMMC */
193 return (devno == 0) ? 0: (devno - 1);
Jagan Teki515bd002017-11-21 00:02:16 +0530194}
195#endif