blob: c0e4593f77190db225f4e4b6a8abce0cbaabf0f9 [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>
Mattias Wallin7ed00af2011-05-27 10:30:34 +020013#include <linux/clksrc-dbx500-prcmu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010014
Per Franssonae694802010-09-08 21:21:40 +053015#include <asm/cacheflush.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010016#include <asm/hardware/cache-l2x0.h>
17#include <asm/hardware/gic.h>
18#include <asm/mach/map.h>
Rabin Vincent41ac3292010-05-03 08:28:05 +010019#include <asm/localtimer.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010020
Rabin Vincent41ac3292010-05-03 08:28:05 +010021#include <plat/mtu.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010022#include <mach/hardware.h>
23#include <mach/setup.h>
Rabin Vincentd48fd002010-05-03 07:46:56 +010024#include <mach/devices.h>
Rabin Vincent178980f2010-05-03 07:39:02 +010025
26#include "clock.h"
27
Linus Walleij11871892011-03-29 16:53:29 +020028void __iomem *_PRCMU_BASE;
29
Rabin Vincent92389ca2010-12-08 11:07:57 +053030#ifdef CONFIG_CACHE_L2X0
31static void __iomem *l2x0_base;
32#endif
Rabin Vincent178980f2010-05-03 07:39:02 +010033
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 */
Linus Walleij83177972011-05-03 18:14:48 +020054 if (cpu_is_u5500())
55 db5500_prcmu_early_init();
Per Forlin9b04f8b2010-12-05 12:27:05 +010056 if (cpu_is_u8500())
57 prcmu_early_init();
Linus Walleijba327b12010-05-26 07:38:54 +010058 clk_init();
Rabin Vincent178980f2010-05-03 07:39:02 +010059}
60
61#ifdef CONFIG_CACHE_L2X0
Per Franssonae694802010-09-08 21:21:40 +053062static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask)
63{
64 /* wait for the operation to complete */
Per Franssonffc43ef2010-11-15 14:31:17 +010065 while (readl_relaxed(reg) & mask)
Per Franssonae694802010-09-08 21:21:40 +053066 ;
67}
68
69static inline void ux500_cache_sync(void)
70{
Rabin Vincent92389ca2010-12-08 11:07:57 +053071 void __iomem *base = l2x0_base;
72
Per Franssonffc43ef2010-11-15 14:31:17 +010073 writel_relaxed(0, base + L2X0_CACHE_SYNC);
Per Franssonae694802010-09-08 21:21:40 +053074 ux500_cache_wait(base + L2X0_CACHE_SYNC, 1);
75}
76
77/*
78 * The L2 cache cannot be turned off in the non-secure world.
79 * Dummy until a secure service is in place.
80 */
81static void ux500_l2x0_disable(void)
82{
83}
84
85/*
86 * This is only called when doing a kexec, just after turning off the L2
87 * and L1 cache, and it is surrounded by a spinlock in the generic version.
88 * However, we're not really turning off the L2 cache right now and the
89 * PL310 does not support exclusive accesses (used to implement the spinlock).
90 * So, the invalidation needs to be done without the spinlock.
91 */
92static void ux500_l2x0_inv_all(void)
93{
Rabin Vincent92389ca2010-12-08 11:07:57 +053094 void __iomem *base = l2x0_base;
Per Franssonae694802010-09-08 21:21:40 +053095 uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */
96
97 /* invalidate all ways */
Rabin Vincent92389ca2010-12-08 11:07:57 +053098 writel_relaxed(l2x0_way_mask, base + L2X0_INV_WAY);
99 ux500_cache_wait(base + L2X0_INV_WAY, l2x0_way_mask);
Per Franssonae694802010-09-08 21:21:40 +0530100 ux500_cache_sync();
101}
102
Rabin Vincent178980f2010-05-03 07:39:02 +0100103static int ux500_l2x0_init(void)
104{
Rabin Vincent92389ca2010-12-08 11:07:57 +0530105 if (cpu_is_u5500())
106 l2x0_base = __io_address(U5500_L2CC_BASE);
107 else if (cpu_is_u8500())
108 l2x0_base = __io_address(U8500_L2CC_BASE);
109 else
110 ux500_unknown_soc();
Rabin Vincent178980f2010-05-03 07:39:02 +0100111
112 /* 64KB way size, 8 way associativity, force WA */
113 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
114
Per Franssonae694802010-09-08 21:21:40 +0530115 /* Override invalidate function */
116 outer_cache.disable = ux500_l2x0_disable;
117 outer_cache.inv_all = ux500_l2x0_inv_all;
118
Rabin Vincent178980f2010-05-03 07:39:02 +0100119 return 0;
120}
121early_initcall(ux500_l2x0_init);
122#endif
Rabin Vincent41ac3292010-05-03 08:28:05 +0100123
124static void __init ux500_timer_init(void)
125{
126#ifdef CONFIG_LOCAL_TIMERS
127 /* Setup the local timer base */
Rabin Vincent92389ca2010-12-08 11:07:57 +0530128 if (cpu_is_u5500())
129 twd_base = __io_address(U5500_TWD_BASE);
130 else if (cpu_is_u8500())
131 twd_base = __io_address(U8500_TWD_BASE);
Rabin Vincent41ac3292010-05-03 08:28:05 +0100132 else
Rabin Vincent92389ca2010-12-08 11:07:57 +0530133 ux500_unknown_soc();
134#endif
135 if (cpu_is_u5500())
136 mtu_base = __io_address(U5500_MTU0_BASE);
137 else if (cpu_is_u8500ed())
138 mtu_base = __io_address(U8500_MTU0_BASE_ED);
139 else if (cpu_is_u8500())
140 mtu_base = __io_address(U8500_MTU0_BASE);
141 else
142 ux500_unknown_soc();
Rabin Vincent41ac3292010-05-03 08:28:05 +0100143
Mattias Wallin7ed00af2011-05-27 10:30:34 +0200144 if (cpu_is_u8500())
145 clksrc_dbx500_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
146 else if (cpu_is_u5500())
147 clksrc_dbx500_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
148 else
149 ux500_unknown_soc();
150
Rabin Vincent41ac3292010-05-03 08:28:05 +0100151 nmdk_timer_init();
Mattias Wallin7ed00af2011-05-27 10:30:34 +0200152 clksrc_dbx500_prcmu_init();
Rabin Vincent41ac3292010-05-03 08:28:05 +0100153}
154
155struct sys_timer ux500_timer = {
156 .init = ux500_timer_init,
157};