aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx5
diff options
context:
space:
mode:
authorJason Wang <jason77.wang@gmail.com>2010-09-02 03:52:00 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2010-10-01 03:32:18 -0400
commit8d83db81affd71af0fb6f054ab552d16a7cb805b (patch)
treec6ae933ff0aa74dd6b77c8d83d78fb3c37a3ef71 /arch/arm/mach-mx5
parent74d99f395901502747a44a1379f3b4fdb638dafa (diff)
ARM: mx5/clock-mx51: add spi clocks
Signed-off-by: Jason Wang <jason77.wang@gmail.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx5')
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 0e396981c27c..68aef2d58484 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -764,6 +764,42 @@ static struct clk kpp_clk = {
764 .id = 0, 764 .id = 0,
765}; 765};
766 766
767/* eCSPI */
768static unsigned long clk_ecspi_get_rate(struct clk *clk)
769{
770 u32 reg, pred, podf;
771
772 reg = __raw_readl(MXC_CCM_CSCDR2);
773
774 pred = (reg & MXC_CCM_CSCDR2_CSPI_CLK_PRED_MASK) >>
775 MXC_CCM_CSCDR2_CSPI_CLK_PRED_OFFSET;
776 podf = (reg & MXC_CCM_CSCDR2_CSPI_CLK_PODF_MASK) >>
777 MXC_CCM_CSCDR2_CSPI_CLK_PODF_OFFSET;
778
779 return DIV_ROUND_CLOSEST(clk_get_rate(clk->parent),
780 (pred + 1) * (podf + 1));
781}
782
783static int clk_ecspi_set_parent(struct clk *clk, struct clk *parent)
784{
785 u32 reg, mux;
786
787 mux = _get_mux(parent, &pll1_sw_clk, &pll2_sw_clk, &pll3_sw_clk,
788 &lp_apm_clk);
789
790 reg = __raw_readl(MXC_CCM_CSCMR1) & ~MXC_CCM_CSCMR1_CSPI_CLK_SEL_MASK;
791 reg |= mux << MXC_CCM_CSCMR1_CSPI_CLK_SEL_OFFSET;
792 __raw_writel(reg, MXC_CCM_CSCMR1);
793
794 return 0;
795}
796
797static struct clk ecspi_main_clk = {
798 .parent = &pll3_sw_clk,
799 .get_rate = clk_ecspi_get_rate,
800 .set_parent = clk_ecspi_set_parent,
801};
802
767#define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \ 803#define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \
768 static struct clk name = { \ 804 static struct clk name = { \
769 .id = i, \ 805 .id = i, \
@@ -816,6 +852,24 @@ DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
816DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET, 852DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
817 NULL, NULL, &ipg_clk, NULL); 853 NULL, NULL, &ipg_clk, NULL);
818 854
855/* eCSPI */
856DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
857 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
858 &ipg_clk, &spba_clk);
859DEFINE_CLOCK(ecspi1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG10_OFFSET,
860 NULL, NULL, &ecspi_main_clk, &ecspi1_ipg_clk);
861DEFINE_CLOCK_FULL(ecspi2_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG11_OFFSET,
862 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
863 &ipg_clk, &aips_tz2_clk);
864DEFINE_CLOCK(ecspi2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG12_OFFSET,
865 NULL, NULL, &ecspi_main_clk, &ecspi2_ipg_clk);
866
867/* CSPI */
868DEFINE_CLOCK(cspi_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
869 NULL, NULL, &ipg_clk, &aips_tz2_clk);
870DEFINE_CLOCK(cspi_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET,
871 NULL, NULL, &ipg_clk, &cspi_ipg_clk);
872
819#define _REGISTER_CLOCK(d, n, c) \ 873#define _REGISTER_CLOCK(d, n, c) \
820 { \ 874 { \
821 .dev_id = d, \ 875 .dev_id = d, \
@@ -839,6 +893,9 @@ static struct clk_lookup lookups[] = {
839 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk) 893 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
840 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk) 894 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
841 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk) 895 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk)
896 _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk)
897 _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk)
898 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)
842}; 899};
843 900
844static void clk_tree_init(void) 901static void clk_tree_init(void)