blob: 1da23bb87c16bcec2047d9ac8e08e474d2f505ce [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>
Linus Walleij650c2a22011-05-15 22:53:56 +020011#include <linux/mfd/db8500-prcmu.h>
Linus Walleij83177972011-05-03 18:14:48 +020012#include <linux/mfd/db5500-prcmu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010013
Per Franssonae694802010-09-08 21:21:40 +053014#include <asm/cacheflush.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010015#include <asm/hardware/cache-l2x0.h>
16#include <asm/hardware/gic.h>
17#include <asm/mach/map.h>
Rabin Vincent41ac3292010-05-03 08:28:05 +010018#include <asm/localtimer.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010019
Rabin Vincent41ac3292010-05-03 08:28:05 +010020#include <plat/mtu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010021#include <mach/hardware.h>
22#include <mach/setup.h>
Rabin Vincentd48fd002010-05-03 07:46:56 +010023#include <mach/devices.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010024
25#include "clock.h"
26
Linus Walleij11871892011-03-29 16:53:29 +020027void __iomem *_PRCMU_BASE;
28
Rabin Vincent92389ca2010-12-08 11:07:57 +053029#ifdef CONFIG_CACHE_L2X0
30static void __iomem *l2x0_base;
31#endif
Rabin Vincent178980f2010-05-03 07:39:02 +010032
Rabin Vincent178980f2010-05-03 07:39:02 +010033void __init ux500_init_irq(void)
34{
Rabin Vincent92389ca2010-12-08 11:07:57 +053035 void __iomem *dist_base;
36 void __iomem *cpu_base;
37
38 if (cpu_is_u5500()) {
39 dist_base = __io_address(U5500_GIC_DIST_BASE);
40 cpu_base = __io_address(U5500_GIC_CPU_BASE);
41 } else if (cpu_is_u8500()) {
42 dist_base = __io_address(U8500_GIC_DIST_BASE);
43 cpu_base = __io_address(U8500_GIC_CPU_BASE);
44 } else
45 ux500_unknown_soc();
46
47 gic_init(0, 29, dist_base, cpu_base);
Linus Walleijba327b12010-05-26 07:38:54 +010048
49 /*
50 * Init clocks here so that they are available for system timer
51 * initialization.
52 */
Linus Walleij83177972011-05-03 18:14:48 +020053 if (cpu_is_u5500())
54 db5500_prcmu_early_init();
Per Forlin9b04f8b2010-12-05 12:27:05 +010055 if (cpu_is_u8500())
56 prcmu_early_init();
Linus Walleijba327b12010-05-26 07:38:54 +010057 clk_init();
Rabin Vincent178980f2010-05-03 07:39:02 +010058}
59
60#ifdef CONFIG_CACHE_L2X0
Per Franssonae694802010-09-08 21:21:40 +053061static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
62{
63 /* wait for the operation to complete */
Per Franssonffc43ef2010-11-15 14:31:17 +010064 while (readl_relaxed(reg) & mask)
Per Franssonae694802010-09-08 21:21:40 +053065 ;
66}
67
68static inline void ux500_cache_sync(void)
69{
Rabin Vincent92389ca2010-12-08 11:07:57 +053070 void __iomem *base = l2x0_base;
71
Per Franssonffc43ef2010-11-15 14:31:17 +010072 writel_relaxed(0, base + L2X0_CACHE_SYNC);
Per Franssonae694802010-09-08 21:21:40 +053073 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
74}
75
76/*
77 * The L2 cache cannot be turned off in the non-secure world.
78 * Dummy until a secure service is in place.
79 */
80static void ux500_l2x0_disable(void)
81{
82}
83
84/*
85 * This is only called when doing a kexec, just after turning off the L2
86 * and L1 cache, and it is surrounded by a spinlock in the generic version.
87 * However, we're not really turning off the L2 cache right now and the
88 * PL310 does not support exclusive accesses (used to implement the spinlock).
89 * So, the invalidation needs to be done without the spinlock.
90 */
91static void ux500_l2x0_inv_all(void)
92{
Rabin Vincent92389ca2010-12-08 11:07:57 +053093 void __iomem *base = l2x0_base;
Per Franssonae694802010-09-08 21:21:40 +053094 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
95
96 /* invalidate all ways */
Rabin Vincent92389ca2010-12-08 11:07:57 +053097 writel_relaxed(l2x0_way_mask, base + L2X0_INV_WAY);
98 ux500_cache_wait(base + L2X0_INV_WAY, l2x0_way_mask);
Per Franssonae694802010-09-08 21:21:40 +053099 ux500_cache_sync();
100}
101
Rabin Vincent178980f2010-05-03 07:39:02 +0100102static int ux500_l2x0_init(void)
103{
Rabin Vincent92389ca2010-12-08 11:07:57 +0530104 if (cpu_is_u5500())
105 l2x0_base = __io_address(U5500_L2CC_BASE);
106 else if (cpu_is_u8500())
107 l2x0_base = __io_address(U8500_L2CC_BASE);
108 else
109 ux500_unknown_soc();
Rabin Vincent178980f2010-05-03 07:39:02 +0100110
111 /* 64KB way size, 8 way associativity, force WA */
112 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
113
Per Franssonae694802010-09-08 21:21:40 +0530114 /* Override invalidate function */
115 outer_cache.disable = ux500_l2x0_disable;
116 outer_cache.inv_all = ux500_l2x0_inv_all;
117
Rabin Vincent178980f2010-05-03 07:39:02 +0100118 return 0;
119}
120early_initcall(ux500_l2x0_init);
121#endif
Rabin Vincent41ac3292010-05-03 08:28:05 +0100122
123static void __init ux500_timer_init(void)
124{
125#ifdef CONFIG_LOCAL_TIMERS
126 /* Setup the local timer base */
Rabin Vincent92389ca2010-12-08 11:07:57 +0530127 if (cpu_is_u5500())
128 twd_base = __io_address(U5500_TWD_BASE);
129 else if (cpu_is_u8500())
130 twd_base = __io_address(U8500_TWD_BASE);
Rabin Vincent41ac3292010-05-03 08:28:05 +0100131 else
Rabin Vincent92389ca2010-12-08 11:07:57 +0530132 ux500_unknown_soc();
133#endif
134 if (cpu_is_u5500())
135 mtu_base = __io_address(U5500_MTU0_BASE);
136 else if (cpu_is_u8500ed())
137 mtu_base = __io_address(U8500_MTU0_BASE_ED);
138 else if (cpu_is_u8500())
139 mtu_base = __io_address(U8500_MTU0_BASE);
140 else
141 ux500_unknown_soc();
Rabin Vincent41ac3292010-05-03 08:28:05 +0100142
143 nmdk_timer_init();
144}
145
146struct sys_timer ux500_timer = {
147 .init = ux500_timer_init,
148};