blob: 35a3af13fb30d866fcfec362ef076aef642b27b7 [file] [log] [blame]
Rabin Vincent178980f2010-05-03 07:39:02 +01001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2
6 */
7
8#include <linux/platform_device.h>
Rabin Vincent178980f2010-05-03 07:39:02 +01009#include <linux/io.h>
10#include <linux/clk.h>
11
Per Franssonae694802010-09-08 21:21:40 +053012#include <asm/cacheflush.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010013#include <asm/hardware/cache-l2x0.h>
14#include <asm/hardware/gic.h>
15#include <asm/mach/map.h>
Rabin Vincent41ac3292010-05-03 08:28:05 +010016#include <asm/localtimer.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010017
Rabin Vincent41ac3292010-05-03 08:28:05 +010018#include <plat/mtu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010019#include <mach/hardware.h>
20#include <mach/setup.h>
Rabin Vincentd48fd002010-05-03 07:46:56 +010021#include <mach/devices.h>
Mattias Wallinfcbd4582010-12-02 16:20:42 +010022#include <mach/prcmu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010023
24#include "clock.h"
25
Rabin Vincent92389ca2010-12-08 11:07:57 +053026#ifdef CONFIG_CACHE_L2X0
27static void __iomem *l2x0_base;
28#endif
Rabin Vincent178980f2010-05-03 07:39:02 +010029
30void __init ux500_map_io(void)
31{
Rabin Vincent178980f2010-05-03 07:39:02 +010032}
33
Rabin Vincent178980f2010-05-03 07:39:02 +010034void __init ux500_init_irq(void)
35{
Rabin Vincent92389ca2010-12-08 11:07:57 +053036 void __iomem *dist_base;
37 void __iomem *cpu_base;
38
39 if (cpu_is_u5500()) {
40 dist_base = __io_address(U5500_GIC_DIST_BASE);
41 cpu_base = __io_address(U5500_GIC_CPU_BASE);
42 } else if (cpu_is_u8500()) {
43 dist_base = __io_address(U8500_GIC_DIST_BASE);
44 cpu_base = __io_address(U8500_GIC_CPU_BASE);
45 } else
46 ux500_unknown_soc();
47
48 gic_init(0, 29, dist_base, cpu_base);
Linus Walleijba327b12010-05-26 07:38:54 +010049
50 /*
51 * Init clocks here so that they are available for system timer
52 * initialization.
53 */
Per Forlin9b04f8b2010-12-05 12:27:05 +010054 if (cpu_is_u8500())
55 prcmu_early_init();
Linus Walleijba327b12010-05-26 07:38:54 +010056 clk_init();
Rabin Vincent178980f2010-05-03 07:39:02 +010057}
58
59#ifdef CONFIG_CACHE_L2X0
Per Franssonae694802010-09-08 21:21:40 +053060static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
61{
62 /* wait for the operation to complete */
Per Franssonffc43ef2010-11-15 14:31:17 +010063 while (readl_relaxed(reg) & mask)
Per Franssonae694802010-09-08 21:21:40 +053064 ;
65}
66
67static inline void ux500_cache_sync(void)
68{
Rabin Vincent92389ca2010-12-08 11:07:57 +053069 void __iomem *base = l2x0_base;
70
Per Franssonffc43ef2010-11-15 14:31:17 +010071 writel_relaxed(0, base + L2X0_CACHE_SYNC);
Per Franssonae694802010-09-08 21:21:40 +053072 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
73}
74
75/*
76 * The L2 cache cannot be turned off in the non-secure world.
77 * Dummy until a secure service is in place.
78 */
79static void ux500_l2x0_disable(void)
80{
81}
82
83/*
84 * This is only called when doing a kexec, just after turning off the L2
85 * and L1 cache, and it is surrounded by a spinlock in the generic version.
86 * However, we're not really turning off the L2 cache right now and the
87 * PL310 does not support exclusive accesses (used to implement the spinlock).
88 * So, the invalidation needs to be done without the spinlock.
89 */
90static void ux500_l2x0_inv_all(void)
91{
Rabin Vincent92389ca2010-12-08 11:07:57 +053092 void __iomem *base = l2x0_base;
Per Franssonae694802010-09-08 21:21:40 +053093 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
94
95 /* invalidate all ways */
Rabin Vincent92389ca2010-12-08 11:07:57 +053096 writel_relaxed(l2x0_way_mask, base + L2X0_INV_WAY);
97 ux500_cache_wait(base + L2X0_INV_WAY, l2x0_way_mask);
Per Franssonae694802010-09-08 21:21:40 +053098 ux500_cache_sync();
99}
100
Rabin Vincent178980f2010-05-03 07:39:02 +0100101static int ux500_l2x0_init(void)
102{
Rabin Vincent92389ca2010-12-08 11:07:57 +0530103 if (cpu_is_u5500())
104 l2x0_base = __io_address(U5500_L2CC_BASE);
105 else if (cpu_is_u8500())
106 l2x0_base = __io_address(U8500_L2CC_BASE);
107 else
108 ux500_unknown_soc();
Rabin Vincent178980f2010-05-03 07:39:02 +0100109
110 /* 64KB way size, 8 way associativity, force WA */
111 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
112
Per Franssonae694802010-09-08 21:21:40 +0530113 /* Override invalidate function */
114 outer_cache.disable = ux500_l2x0_disable;
115 outer_cache.inv_all = ux500_l2x0_inv_all;
116
Rabin Vincent178980f2010-05-03 07:39:02 +0100117 return 0;
118}
119early_initcall(ux500_l2x0_init);
120#endif
Rabin Vincent41ac3292010-05-03 08:28:05 +0100121
122static void __init ux500_timer_init(void)
123{
124#ifdef CONFIG_LOCAL_TIMERS
125 /* Setup the local timer base */
Rabin Vincent92389ca2010-12-08 11:07:57 +0530126 if (cpu_is_u5500())
127 twd_base = __io_address(U5500_TWD_BASE);
128 else if (cpu_is_u8500())
129 twd_base = __io_address(U8500_TWD_BASE);
Rabin Vincent41ac3292010-05-03 08:28:05 +0100130 else
Rabin Vincent92389ca2010-12-08 11:07:57 +0530131 ux500_unknown_soc();
132#endif
133 if (cpu_is_u5500())
134 mtu_base = __io_address(U5500_MTU0_BASE);
135 else if (cpu_is_u8500ed())
136 mtu_base = __io_address(U8500_MTU0_BASE_ED);
137 else if (cpu_is_u8500())
138 mtu_base = __io_address(U8500_MTU0_BASE);
139 else
140 ux500_unknown_soc();
Rabin Vincent41ac3292010-05-03 08:28:05 +0100141
142 nmdk_timer_init();
143}
144
145struct sys_timer ux500_timer = {
146 .init = ux500_timer_init,
147};