aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2010-08-03 05:59:07 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2010-10-01 03:32:24 -0400
commit2b82e64d787f9d1a5d304da137c2b1bdbe3b2d9d (patch)
treeeacd39c67d66f3e89ef25b64f253b1b50207323c /arch/arm
parentf781bc8aa44c8676ad84b69fc4553e8f035c6e89 (diff)
ARM: mx5: Add Nand clock support
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')
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 68aef2d58484..0cef8c4f84ba 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -573,6 +573,64 @@ static int _clk_uart_set_parent(struct clk *clk, struct clk *parent)
573 return 0; 573 return 0;
574} 574}
575 575
576#define clk_nfc_set_parent NULL
577
578static unsigned long clk_nfc_get_rate(struct clk *clk)
579{
580 unsigned long rate;
581 u32 reg, div;
582
583 reg = __raw_readl(MXC_CCM_CBCDR);
584 div = ((reg & MXC_CCM_CBCDR_NFC_PODF_MASK) >>
585 MXC_CCM_CBCDR_NFC_PODF_OFFSET) + 1;
586 rate = clk_get_rate(clk->parent) / div;
587 WARN_ON(rate == 0);
588 return rate;
589}
590
591static unsigned long clk_nfc_round_rate(struct clk *clk,
592 unsigned long rate)
593{
594 u32 div;
595 unsigned long parent_rate = clk_get_rate(clk->parent);
596
597 if (!rate)
598 return -EINVAL;
599
600 div = parent_rate / rate;
601
602 if (parent_rate % rate)
603 div++;
604
605 if (div > 8)
606 return -EINVAL;
607
608 return parent_rate / div;
609
610}
611
612static int clk_nfc_set_rate(struct clk *clk, unsigned long rate)
613{
614 u32 reg, div;
615
616 div = clk_get_rate(clk->parent) / rate;
617 if (div == 0)
618 div++;
619 if (((clk_get_rate(clk->parent) / div) != rate) || (div > 8))
620 return -EINVAL;
621
622 reg = __raw_readl(MXC_CCM_CBCDR);
623 reg &= ~MXC_CCM_CBCDR_NFC_PODF_MASK;
624 reg |= (div - 1) << MXC_CCM_CBCDR_NFC_PODF_OFFSET;
625 __raw_writel(reg, MXC_CCM_CBCDR);
626
627 while (__raw_readl(MXC_CCM_CDHIPR) &
628 MXC_CCM_CDHIPR_NFC_IPG_INT_MEM_PODF_BUSY){
629 }
630
631 return 0;
632}
633
576static unsigned long clk_usboh3_get_rate(struct clk *clk) 634static unsigned long clk_usboh3_get_rate(struct clk *clk)
577{ 635{
578 u32 reg, prediv, podf; 636 u32 reg, prediv, podf;
@@ -622,6 +680,17 @@ static unsigned long get_ckih2_reference_clock_rate(struct clk *clk)
622 return ckih2_reference; 680 return ckih2_reference;
623} 681}
624 682
683static unsigned long clk_emi_slow_get_rate(struct clk *clk)
684{
685 u32 reg, div;
686
687 reg = __raw_readl(MXC_CCM_CBCDR);
688 div = ((reg & MXC_CCM_CBCDR_EMI_PODF_MASK) >>
689 MXC_CCM_CBCDR_EMI_PODF_OFFSET) + 1;
690
691 return clk_get_rate(clk->parent) / div;
692}
693
625/* External high frequency clock */ 694/* External high frequency clock */
626static struct clk ckih_clk = { 695static struct clk ckih_clk = {
627 .get_rate = get_high_reference_clock_rate, 696 .get_rate = get_high_reference_clock_rate,
@@ -764,6 +833,30 @@ static struct clk kpp_clk = {
764 .id = 0, 833 .id = 0,
765}; 834};
766 835
836static struct clk emi_slow_clk = {
837 .parent = &pll2_sw_clk,
838 .enable_reg = MXC_CCM_CCGR5,
839 .enable_shift = MXC_CCM_CCGRx_CG8_OFFSET,
840 .enable = _clk_ccgr_enable,
841 .disable = _clk_ccgr_disable_inwait,
842 .get_rate = clk_emi_slow_get_rate,
843};
844
845#define DEFINE_CLOCK1(name, i, er, es, pfx, p, s) \
846 static struct clk name = { \
847 .id = i, \
848 .enable_reg = er, \
849 .enable_shift = es, \
850 .get_rate = pfx##_get_rate, \
851 .set_rate = pfx##_set_rate, \
852 .round_rate = pfx##_round_rate, \
853 .set_parent = pfx##_set_parent, \
854 .enable = _clk_ccgr_enable, \
855 .disable = _clk_ccgr_disable, \
856 .parent = p, \
857 .secondary = s, \
858 }
859
767/* eCSPI */ 860/* eCSPI */
768static unsigned long clk_ecspi_get_rate(struct clk *clk) 861static unsigned long clk_ecspi_get_rate(struct clk *clk)
769{ 862{
@@ -852,6 +945,10 @@ DEFINE_CLOCK(hsi2c_clk, 0, MXC_CCM_CCGR1, MXC_CCM_CCGRx_CG11_OFFSET,
852DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET, 945DEFINE_CLOCK(fec_clk, 0, MXC_CCM_CCGR2, MXC_CCM_CCGRx_CG12_OFFSET,
853 NULL, NULL, &ipg_clk, NULL); 946 NULL, NULL, &ipg_clk, NULL);
854 947
948/* NFC */
949DEFINE_CLOCK1(nfc_clk, 0, MXC_CCM_CCGR5, MXC_CCM_CCGRx_CG10_OFFSET,
950 clk_nfc, &emi_slow_clk, NULL);
951
855/* eCSPI */ 952/* eCSPI */
856DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET, 953DEFINE_CLOCK_FULL(ecspi1_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
857 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable, 954 NULL, NULL, _clk_ccgr_enable_inrun, _clk_ccgr_disable,
@@ -893,6 +990,7 @@ static struct clk_lookup lookups[] = {
893 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk) 990 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
894 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk) 991 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
895 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk) 992 _REGISTER_CLOCK("imx-keypad.0", NULL, kpp_clk)
993 _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk)
896 _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk) 994 _REGISTER_CLOCK("imx51-ecspi.0", NULL, ecspi1_clk)
897 _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk) 995 _REGISTER_CLOCK("imx51-ecspi.1", NULL, ecspi2_clk)
898 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) 996 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)