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