diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2012-06-14 15:20:59 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-06-30 12:53:23 +0200 |
commit | b20296bae53d0475c7d6846efbe1200b9204bcc4 (patch) | |
tree | ea73409b1698f6b64cde59b49e34b3b81ccf7d04 /arch | |
parent | 8a6877364ad7cb6a04e5d41580b68873215ef8fc (diff) | |
download | barebox-b20296bae53d0475c7d6846efbe1200b9204bcc4.tar.gz barebox-b20296bae53d0475c7d6846efbe1200b9204bcc4.tar.xz |
arm: mxs: add imx_set_hclk
needed for writing the One-Time-Prgorammable
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-mxs/include/mach/clock-imx23.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-mxs/include/mach/clock-imx28.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-mxs/speed-imx23.c | 21 | ||||
-rw-r--r-- | arch/arm/mach-mxs/speed-imx28.c | 21 |
4 files changed, 44 insertions, 0 deletions
diff --git a/arch/arm/mach-mxs/include/mach/clock-imx23.h b/arch/arm/mach-mxs/include/mach/clock-imx23.h index 723f343566..4f20e09d3d 100644 --- a/arch/arm/mach-mxs/include/mach/clock-imx23.h +++ b/arch/arm/mach-mxs/include/mach/clock-imx23.h @@ -18,6 +18,7 @@ unsigned imx_get_emiclk(void); unsigned imx_get_ioclk(void); unsigned imx_get_armclk(void); unsigned imx_get_hclk(void); +unsigned imx_set_hclk(unsigned); unsigned imx_get_xclk(void); unsigned imx_get_sspclk(unsigned); unsigned imx_set_sspclk(unsigned, unsigned, int); diff --git a/arch/arm/mach-mxs/include/mach/clock-imx28.h b/arch/arm/mach-mxs/include/mach/clock-imx28.h index 45fb043ac4..613c97b916 100644 --- a/arch/arm/mach-mxs/include/mach/clock-imx28.h +++ b/arch/arm/mach-mxs/include/mach/clock-imx28.h @@ -18,6 +18,7 @@ unsigned imx_get_emiclk(void); unsigned imx_get_ioclk(unsigned); unsigned imx_get_armclk(void); unsigned imx_get_hclk(void); +unsigned imx_set_hclk(unsigned); unsigned imx_get_xclk(void); unsigned imx_get_sspclk(unsigned); unsigned imx_set_sspclk(unsigned, unsigned, int); diff --git a/arch/arm/mach-mxs/speed-imx23.c b/arch/arm/mach-mxs/speed-imx23.c index c9ca7ac30b..f41b9bc75a 100644 --- a/arch/arm/mach-mxs/speed-imx23.c +++ b/arch/arm/mach-mxs/speed-imx23.c @@ -191,6 +191,27 @@ unsigned imx_get_hclk(void) return rate * 1000; } +unsigned imx_set_hclk(unsigned nc) +{ + unsigned root_rate = imx_get_armclk(); + unsigned reg, div; + + div = DIV_ROUND_UP(root_rate, nc); + if ((div == 0) || (div >= 32)) + return 0; + + if ((root_rate < nc) && (root_rate == 64000000)) + div = 3; + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & ~0x3f; + writel(reg | div, IMX_CCM_BASE + HW_CLKCTRL_HBUS); + + while (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & (1 << 31)) + ; + + return imx_get_hclk(); +} + /* * Source of UART, debug UART, audio, PWM, dri, timer, digctl */ diff --git a/arch/arm/mach-mxs/speed-imx28.c b/arch/arm/mach-mxs/speed-imx28.c index 4f4db1bbfb..2641fb6fb2 100644 --- a/arch/arm/mach-mxs/speed-imx28.c +++ b/arch/arm/mach-mxs/speed-imx28.c @@ -258,6 +258,27 @@ unsigned imx_get_hclk(void) return rate * 1000; } +unsigned imx_set_hclk(unsigned nc) +{ + unsigned root_rate = imx_get_armclk(); + unsigned reg, div; + + div = DIV_ROUND_UP(root_rate, nc); + if ((div == 0) || (div >= 32)) + return 0; + + if ((root_rate < nc) && (root_rate == 64000000)) + div = 3; + + reg = readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & ~0x3f; + writel(reg | div, IMX_CCM_BASE + HW_CLKCTRL_HBUS); + + while (readl(IMX_CCM_BASE + HW_CLKCTRL_HBUS) & (1 << 31)) + ; + + return imx_get_hclk(); +} + /* * Source of UART, debug UART, audio, PWM, dri, timer, digctl */ |