summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-02-13 15:14:52 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-19 08:30:32 +0100
commitcc76af2676a995a34aa7aad01ce0752f62bff7e0 (patch)
treec1e6a4c9b3eb4c1725912315a64031b4806bac53 /arch
parentd97b8f93ee35b09d6a76cfb137c708470e3e47b2 (diff)
downloadbarebox-cc76af2676a995a34aa7aad01ce0752f62bff7e0.tar.gz
ARM: i.MX7: Add and use function for early UART clock setup
The i.MX7 boards have the same code for setting up the UART clock. Add a common helper function for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/freescale-mx7-sabresd/lowlevel.c9
-rw-r--r--arch/arm/boards/zii-imx7d-dev/lowlevel.c9
-rw-r--r--arch/arm/mach-imx/include/mach/imx7-ccm-regs.h12
3 files changed, 14 insertions, 16 deletions
diff --git a/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c b/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
index 995bf6c..8db46ca 100644
--- a/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
+++ b/arch/arm/boards/freescale-mx7-sabresd/lowlevel.c
@@ -15,14 +15,7 @@ extern char __dtb_imx7d_sdb_start[];
static inline void setup_uart(void)
{
- void __iomem *ccm = IOMEM(MX7_CCM_BASE_ADDR);
-
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_CLR(IMX7_CCM_CCGR_UART1));
- writel(IMX7_CCM_TARGET_ROOTn_ENABLE | IMX7_UART1_CLK_ROOT__OSC_24M,
- ccm + IMX7_CCM_TARGET_ROOTn(IMX7_UART1_CLK_ROOT));
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_SET(IMX7_CCM_CCGR_UART1));
+ imx7_early_setup_uart_clock();
imx7_setup_pad(MX7D_PAD_UART1_TX_DATA__UART1_DCE_TX);
diff --git a/arch/arm/boards/zii-imx7d-dev/lowlevel.c b/arch/arm/boards/zii-imx7d-dev/lowlevel.c
index 83fb646..7579a2a 100644
--- a/arch/arm/boards/zii-imx7d-dev/lowlevel.c
+++ b/arch/arm/boards/zii-imx7d-dev/lowlevel.c
@@ -23,14 +23,7 @@ extern char __dtb_z_imx7d_zii_rmu2_start[];
static inline void setup_uart(void)
{
- void __iomem *ccm = IOMEM(MX7_CCM_BASE_ADDR);
-
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_CLR(IMX7_CCM_CCGR_UART2));
- writel(IMX7_CCM_TARGET_ROOTn_ENABLE | IMX7_UART2_CLK_ROOT__OSC_24M,
- ccm + IMX7_CCM_TARGET_ROOTn(IMX7_UART2_CLK_ROOT));
- writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
- ccm + IMX7_CCM_CCGRn_SET(IMX7_CCM_CCGR_UART2));
+ imx7_early_setup_uart_clock();
imx7_setup_pad(MX7D_PAD_UART2_TX_DATA__UART2_DCE_TX);
diff --git a/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h b/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
index b78adf9..de6eb1b 100644
--- a/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx7-ccm-regs.h
@@ -33,4 +33,16 @@
#define IMX7_CCM_CCGR_SETTINGn_NEEDED_RUN_WAIT(n) IMX7_CCM_CCGR_SETTINGn(n, 0b10)
#define IMX7_CCM_CCGR_SETTINGn_NEEDED(n) IMX7_CCM_CCGR_SETTINGn(n, 0b11)
+static inline void imx7_early_setup_uart_clock(void)
+{
+ void __iomem *ccm = IOMEM(MX7_CCM_BASE_ADDR);
+
+ writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
+ ccm + IMX7_CCM_CCGRn_CLR(IMX7_CCM_CCGR_UART1));
+ writel(IMX7_CCM_TARGET_ROOTn_ENABLE | IMX7_UART1_CLK_ROOT__OSC_24M,
+ ccm + IMX7_CCM_TARGET_ROOTn(IMX7_UART1_CLK_ROOT));
+ writel(IMX7_CCM_CCGR_SETTINGn_NEEDED(0),
+ ccm + IMX7_CCM_CCGRn_SET(IMX7_CCM_CCGR_UART1));
+}
+
#endif