0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #define pr_fmt(fmt) "SPEAr13xx: " fmt
0012
0013 #include <linux/amba/pl022.h>
0014 #include <linux/clk.h>
0015 #include <linux/clk/spear.h>
0016 #include <linux/clocksource.h>
0017 #include <linux/err.h>
0018 #include <linux/of.h>
0019 #include <asm/hardware/cache-l2x0.h>
0020 #include <asm/mach/map.h>
0021 #include "spear.h"
0022 #include "generic.h"
0023
0024 void __init spear13xx_l2x0_init(void)
0025 {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 if (!IS_ENABLED(CONFIG_CACHE_L2X0))
0037 return;
0038
0039 writel_relaxed(0x06, VA_L2CC_BASE + L310_PREFETCH_CTRL);
0040
0041
0042
0043
0044
0045 writel_relaxed(0x221, VA_L2CC_BASE + L310_TAG_LATENCY_CTRL);
0046 writel_relaxed(0x441, VA_L2CC_BASE + L310_DATA_LATENCY_CTRL);
0047 l2x0_init(VA_L2CC_BASE, 0x30a00001, 0xfe0fffff);
0048 }
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 static struct map_desc spear13xx_io_desc[] __initdata = {
0059 {
0060 .virtual = (unsigned long)VA_PERIP_GRP2_BASE,
0061 .pfn = __phys_to_pfn(PERIP_GRP2_BASE),
0062 .length = SZ_16M,
0063 .type = MT_DEVICE
0064 }, {
0065 .virtual = (unsigned long)VA_PERIP_GRP1_BASE,
0066 .pfn = __phys_to_pfn(PERIP_GRP1_BASE),
0067 .length = SZ_16M,
0068 .type = MT_DEVICE
0069 }, {
0070 .virtual = (unsigned long)VA_A9SM_AND_MPMC_BASE,
0071 .pfn = __phys_to_pfn(A9SM_AND_MPMC_BASE),
0072 .length = SZ_16M,
0073 .type = MT_DEVICE
0074 }, {
0075 .virtual = (unsigned long)VA_L2CC_BASE,
0076 .pfn = __phys_to_pfn(L2CC_BASE),
0077 .length = SZ_4K,
0078 .type = MT_DEVICE
0079 },
0080 };
0081
0082
0083 void __init spear13xx_map_io(void)
0084 {
0085 iotable_init(spear13xx_io_desc, ARRAY_SIZE(spear13xx_io_desc));
0086 }
0087
0088 static void __init spear13xx_clk_init(void)
0089 {
0090 if (of_machine_is_compatible("st,spear1310"))
0091 spear1310_clk_init(VA_MISC_BASE, VA_SPEAR1310_RAS_BASE);
0092 else if (of_machine_is_compatible("st,spear1340"))
0093 spear1340_clk_init(VA_MISC_BASE);
0094 else
0095 pr_err("%s: Unknown machine\n", __func__);
0096 }
0097
0098 void __init spear13xx_timer_init(void)
0099 {
0100 char pclk_name[] = "osc_24m_clk";
0101 struct clk *gpt_clk, *pclk;
0102
0103 spear13xx_clk_init();
0104
0105
0106 gpt_clk = clk_get_sys("gpt0", NULL);
0107 if (IS_ERR(gpt_clk)) {
0108 pr_err("%s:couldn't get clk for gpt\n", __func__);
0109 BUG();
0110 }
0111
0112
0113 pclk = clk_get(NULL, pclk_name);
0114 if (IS_ERR(pclk)) {
0115 pr_err("%s:couldn't get %s as parent for gpt\n", __func__,
0116 pclk_name);
0117 BUG();
0118 }
0119
0120 clk_set_parent(gpt_clk, pclk);
0121 clk_put(gpt_clk);
0122 clk_put(pclk);
0123
0124 spear_setup_of_timer();
0125 timer_probe();
0126 }