diff options
Diffstat (limited to 'arch/arm/mach-davinci/da850.c')
-rw-r--r-- | arch/arm/mach-davinci/da850.c | 90 |
1 files changed, 74 insertions, 16 deletions
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 717806c6cef9..d0fd7566712a 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <mach/time.h> | 26 | #include <mach/time.h> |
27 | #include <mach/da8xx.h> | 27 | #include <mach/da8xx.h> |
28 | #include <mach/cpufreq.h> | 28 | #include <mach/cpufreq.h> |
29 | #include <mach/pm.h> | ||
29 | 30 | ||
30 | #include "clock.h" | 31 | #include "clock.h" |
31 | #include "mux.h" | 32 | #include "mux.h" |
@@ -40,6 +41,7 @@ | |||
40 | #define DA850_REF_FREQ 24000000 | 41 | #define DA850_REF_FREQ 24000000 |
41 | 42 | ||
42 | #define CFGCHIP3_ASYNC3_CLKSRC BIT(4) | 43 | #define CFGCHIP3_ASYNC3_CLKSRC BIT(4) |
44 | #define CFGCHIP3_PLL1_MASTER_LOCK BIT(5) | ||
43 | #define CFGCHIP0_PLL_MASTER_LOCK BIT(4) | 45 | #define CFGCHIP0_PLL_MASTER_LOCK BIT(4) |
44 | 46 | ||
45 | static int da850_set_armrate(struct clk *clk, unsigned long rate); | 47 | static int da850_set_armrate(struct clk *clk, unsigned long rate); |
@@ -333,7 +335,7 @@ static struct clk aemif_clk = { | |||
333 | .flags = ALWAYS_ENABLED, | 335 | .flags = ALWAYS_ENABLED, |
334 | }; | 336 | }; |
335 | 337 | ||
336 | static struct davinci_clk da850_clks[] = { | 338 | static struct clk_lookup da850_clks[] = { |
337 | CLK(NULL, "ref", &ref_clk), | 339 | CLK(NULL, "ref", &ref_clk), |
338 | CLK(NULL, "pll0", &pll0_clk), | 340 | CLK(NULL, "pll0", &pll0_clk), |
339 | CLK(NULL, "pll0_aux", &pll0_aux_clk), | 341 | CLK(NULL, "pll0_aux", &pll0_aux_clk), |
@@ -535,6 +537,7 @@ static const struct mux_config da850_pins[] = { | |||
535 | MUX_CFG(DA850, GPIO2_15, 5, 0, 15, 8, false) | 537 | MUX_CFG(DA850, GPIO2_15, 5, 0, 15, 8, false) |
536 | MUX_CFG(DA850, GPIO4_0, 10, 28, 15, 8, false) | 538 | MUX_CFG(DA850, GPIO4_0, 10, 28, 15, 8, false) |
537 | MUX_CFG(DA850, GPIO4_1, 10, 24, 15, 8, false) | 539 | MUX_CFG(DA850, GPIO4_1, 10, 24, 15, 8, false) |
540 | MUX_CFG(DA850, RTC_ALARM, 0, 28, 15, 2, false) | ||
538 | #endif | 541 | #endif |
539 | }; | 542 | }; |
540 | 543 | ||
@@ -770,6 +773,12 @@ static struct map_desc da850_io_desc[] = { | |||
770 | .length = DA8XX_CP_INTC_SIZE, | 773 | .length = DA8XX_CP_INTC_SIZE, |
771 | .type = MT_DEVICE | 774 | .type = MT_DEVICE |
772 | }, | 775 | }, |
776 | { | ||
777 | .virtual = SRAM_VIRT, | ||
778 | .pfn = __phys_to_pfn(DA8XX_ARM_RAM_BASE), | ||
779 | .length = SZ_8K, | ||
780 | .type = MT_DEVICE | ||
781 | }, | ||
773 | }; | 782 | }; |
774 | 783 | ||
775 | static void __iomem *da850_psc_bases[] = { | 784 | static void __iomem *da850_psc_bases[] = { |
@@ -825,12 +834,12 @@ static struct davinci_timer_info da850_timer_info = { | |||
825 | static void da850_set_async3_src(int pllnum) | 834 | static void da850_set_async3_src(int pllnum) |
826 | { | 835 | { |
827 | struct clk *clk, *newparent = pllnum ? &pll1_sysclk2 : &pll0_sysclk2; | 836 | struct clk *clk, *newparent = pllnum ? &pll1_sysclk2 : &pll0_sysclk2; |
828 | struct davinci_clk *c; | 837 | struct clk_lookup *c; |
829 | unsigned int v; | 838 | unsigned int v; |
830 | int ret; | 839 | int ret; |
831 | 840 | ||
832 | for (c = da850_clks; c->lk.clk; c++) { | 841 | for (c = da850_clks; c->clk; c++) { |
833 | clk = c->lk.clk; | 842 | clk = c->clk; |
834 | if (clk->flags & DA850_CLK_ASYNC3) { | 843 | if (clk->flags & DA850_CLK_ASYNC3) { |
835 | ret = clk_set_parent(clk, newparent); | 844 | ret = clk_set_parent(clk, newparent); |
836 | WARN(ret, "DA850: unable to re-parent clock %s", | 845 | WARN(ret, "DA850: unable to re-parent clock %s", |
@@ -838,12 +847,12 @@ static void da850_set_async3_src(int pllnum) | |||
838 | } | 847 | } |
839 | } | 848 | } |
840 | 849 | ||
841 | v = __raw_readl(DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG)); | 850 | v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); |
842 | if (pllnum) | 851 | if (pllnum) |
843 | v |= CFGCHIP3_ASYNC3_CLKSRC; | 852 | v |= CFGCHIP3_ASYNC3_CLKSRC; |
844 | else | 853 | else |
845 | v &= ~CFGCHIP3_ASYNC3_CLKSRC; | 854 | v &= ~CFGCHIP3_ASYNC3_CLKSRC; |
846 | __raw_writel(v, DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP3_REG)); | 855 | __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); |
847 | } | 856 | } |
848 | 857 | ||
849 | #ifdef CONFIG_CPU_FREQ | 858 | #ifdef CONFIG_CPU_FREQ |
@@ -987,7 +996,6 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index) | |||
987 | unsigned int prediv, mult, postdiv; | 996 | unsigned int prediv, mult, postdiv; |
988 | struct da850_opp *opp; | 997 | struct da850_opp *opp; |
989 | struct pll_data *pll = clk->pll_data; | 998 | struct pll_data *pll = clk->pll_data; |
990 | unsigned int v; | ||
991 | int ret; | 999 | int ret; |
992 | 1000 | ||
993 | opp = (struct da850_opp *) da850_freq_table[index].index; | 1001 | opp = (struct da850_opp *) da850_freq_table[index].index; |
@@ -995,11 +1003,6 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index) | |||
995 | mult = opp->mult; | 1003 | mult = opp->mult; |
996 | postdiv = opp->postdiv; | 1004 | postdiv = opp->postdiv; |
997 | 1005 | ||
998 | /* Unlock writing to PLL registers */ | ||
999 | v = __raw_readl(DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP0_REG)); | ||
1000 | v &= ~CFGCHIP0_PLL_MASTER_LOCK; | ||
1001 | __raw_writel(v, DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP0_REG)); | ||
1002 | |||
1003 | ret = davinci_set_pllrate(pll, prediv, mult, postdiv); | 1006 | ret = davinci_set_pllrate(pll, prediv, mult, postdiv); |
1004 | if (WARN_ON(ret)) | 1007 | if (WARN_ON(ret)) |
1005 | return ret; | 1008 | return ret; |
@@ -1028,6 +1031,43 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate) | |||
1028 | } | 1031 | } |
1029 | #endif | 1032 | #endif |
1030 | 1033 | ||
1034 | int da850_register_pm(struct platform_device *pdev) | ||
1035 | { | ||
1036 | int ret; | ||
1037 | struct davinci_pm_config *pdata = pdev->dev.platform_data; | ||
1038 | |||
1039 | ret = davinci_cfg_reg(DA850_RTC_ALARM); | ||
1040 | if (ret) | ||
1041 | return ret; | ||
1042 | |||
1043 | pdata->ddr2_ctlr_base = da8xx_get_mem_ctlr(); | ||
1044 | pdata->deepsleep_reg = DA8XX_SYSCFG1_VIRT(DA8XX_DEEPSLEEP_REG); | ||
1045 | pdata->ddrpsc_num = DA8XX_LPSC1_EMIF3C; | ||
1046 | |||
1047 | pdata->cpupll_reg_base = ioremap(DA8XX_PLL0_BASE, SZ_4K); | ||
1048 | if (!pdata->cpupll_reg_base) | ||
1049 | return -ENOMEM; | ||
1050 | |||
1051 | pdata->ddrpll_reg_base = ioremap(DA8XX_PLL1_BASE, SZ_4K); | ||
1052 | if (!pdata->ddrpll_reg_base) { | ||
1053 | ret = -ENOMEM; | ||
1054 | goto no_ddrpll_mem; | ||
1055 | } | ||
1056 | |||
1057 | pdata->ddrpsc_reg_base = ioremap(DA8XX_PSC1_BASE, SZ_4K); | ||
1058 | if (!pdata->ddrpsc_reg_base) { | ||
1059 | ret = -ENOMEM; | ||
1060 | goto no_ddrpsc_mem; | ||
1061 | } | ||
1062 | |||
1063 | return platform_device_register(pdev); | ||
1064 | |||
1065 | no_ddrpsc_mem: | ||
1066 | iounmap(pdata->ddrpll_reg_base); | ||
1067 | no_ddrpll_mem: | ||
1068 | iounmap(pdata->cpupll_reg_base); | ||
1069 | return ret; | ||
1070 | } | ||
1031 | 1071 | ||
1032 | static struct davinci_soc_info davinci_soc_info_da850 = { | 1072 | static struct davinci_soc_info davinci_soc_info_da850 = { |
1033 | .io_desc = da850_io_desc, | 1073 | .io_desc = da850_io_desc, |
@@ -1049,17 +1089,25 @@ static struct davinci_soc_info davinci_soc_info_da850 = { | |||
1049 | .gpio_irq = IRQ_DA8XX_GPIO0, | 1089 | .gpio_irq = IRQ_DA8XX_GPIO0, |
1050 | .serial_dev = &da8xx_serial_device, | 1090 | .serial_dev = &da8xx_serial_device, |
1051 | .emac_pdata = &da8xx_emac_pdata, | 1091 | .emac_pdata = &da8xx_emac_pdata, |
1092 | .sram_dma = DA8XX_ARM_RAM_BASE, | ||
1093 | .sram_len = SZ_8K, | ||
1052 | }; | 1094 | }; |
1053 | 1095 | ||
1054 | void __init da850_init(void) | 1096 | void __init da850_init(void) |
1055 | { | 1097 | { |
1056 | da8xx_syscfg_base = ioremap(DA8XX_SYSCFG_BASE, SZ_4K); | 1098 | unsigned int v; |
1057 | if (WARN(!da8xx_syscfg_base, "Unable to map syscfg module")) | 1099 | |
1100 | da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); | ||
1101 | if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module")) | ||
1102 | return; | ||
1103 | |||
1104 | da8xx_syscfg1_base = ioremap(DA8XX_SYSCFG1_BASE, SZ_4K); | ||
1105 | if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module")) | ||
1058 | return; | 1106 | return; |
1059 | 1107 | ||
1060 | davinci_soc_info_da850.jtag_id_base = | 1108 | davinci_soc_info_da850.jtag_id_base = |
1061 | DA8XX_SYSCFG_VIRT(DA8XX_JTAG_ID_REG); | 1109 | DA8XX_SYSCFG0_VIRT(DA8XX_JTAG_ID_REG); |
1062 | davinci_soc_info_da850.pinmux_base = DA8XX_SYSCFG_VIRT(0x120); | 1110 | davinci_soc_info_da850.pinmux_base = DA8XX_SYSCFG0_VIRT(0x120); |
1063 | 1111 | ||
1064 | davinci_common_init(&davinci_soc_info_da850); | 1112 | davinci_common_init(&davinci_soc_info_da850); |
1065 | 1113 | ||
@@ -1071,4 +1119,14 @@ void __init da850_init(void) | |||
1071 | * be any noticible change even in non-DVFS use cases. | 1119 | * be any noticible change even in non-DVFS use cases. |
1072 | */ | 1120 | */ |
1073 | da850_set_async3_src(1); | 1121 | da850_set_async3_src(1); |
1122 | |||
1123 | /* Unlock writing to PLL0 registers */ | ||
1124 | v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG)); | ||
1125 | v &= ~CFGCHIP0_PLL_MASTER_LOCK; | ||
1126 | __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG)); | ||
1127 | |||
1128 | /* Unlock writing to PLL1 registers */ | ||
1129 | v = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); | ||
1130 | v &= ~CFGCHIP3_PLL1_MASTER_LOCK; | ||
1131 | __raw_writel(v, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG)); | ||
1074 | } | 1132 | } |