Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 1 | /* |
| 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 Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 9 | #include <linux/io.h> |
| 10 | #include <linux/clk.h> |
Linus Walleij | 650c2a2 | 2011-05-15 22:53:56 +0200 | [diff] [blame] | 11 | #include <linux/mfd/db8500-prcmu.h> |
Linus Walleij | 8317797 | 2011-05-03 18:14:48 +0200 | [diff] [blame] | 12 | #include <linux/mfd/db5500-prcmu.h> |
Mattias Wallin | 7ed00af | 2011-05-27 10:30:34 +0200 | [diff] [blame^] | 13 | #include <linux/clksrc-dbx500-prcmu.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 14 | |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 15 | #include <asm/cacheflush.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 16 | #include <asm/hardware/cache-l2x0.h> |
| 17 | #include <asm/hardware/gic.h> |
| 18 | #include <asm/mach/map.h> |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 19 | #include <asm/localtimer.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 20 | |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 21 | #include <plat/mtu.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 22 | #include <mach/hardware.h> |
| 23 | #include <mach/setup.h> |
Rabin Vincent | d48fd00 | 2010-05-03 07:46:56 +0100 | [diff] [blame] | 24 | #include <mach/devices.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 25 | |
| 26 | #include "clock.h" |
| 27 | |
Linus Walleij | 1187189 | 2011-03-29 16:53:29 +0200 | [diff] [blame] | 28 | void __iomem *_PRCMU_BASE; |
| 29 | |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 30 | #ifdef CONFIG_CACHE_L2X0 |
| 31 | static void __iomem *l2x0_base; |
| 32 | #endif |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 33 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 34 | void __init ux500_init_irq(void) |
| 35 | { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 36 | 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 Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Init clocks here so that they are available for system timer |
| 52 | * initialization. |
| 53 | */ |
Linus Walleij | 8317797 | 2011-05-03 18:14:48 +0200 | [diff] [blame] | 54 | if (cpu_is_u5500()) |
| 55 | db5500_prcmu_early_init(); |
Per Forlin | 9b04f8b | 2010-12-05 12:27:05 +0100 | [diff] [blame] | 56 | if (cpu_is_u8500()) |
| 57 | prcmu_early_init(); |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 58 | clk_init(); |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | #ifdef CONFIG_CACHE_L2X0 |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 62 | static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask) |
| 63 | { |
| 64 | /* wait for the operation to complete */ |
Per Fransson | ffc43ef | 2010-11-15 14:31:17 +0100 | [diff] [blame] | 65 | while (readl_relaxed(reg) & mask) |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 66 | ; |
| 67 | } |
| 68 | |
| 69 | static inline void ux500_cache_sync(void) |
| 70 | { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 71 | void __iomem *base = l2x0_base; |
| 72 | |
Per Fransson | ffc43ef | 2010-11-15 14:31:17 +0100 | [diff] [blame] | 73 | writel_relaxed(0, base + L2X0_CACHE_SYNC); |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 74 | 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 | */ |
| 81 | static 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 | */ |
| 92 | static void ux500_l2x0_inv_all(void) |
| 93 | { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 94 | void __iomem *base = l2x0_base; |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 95 | uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */ |
| 96 | |
| 97 | /* invalidate all ways */ |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 98 | writel_relaxed(l2x0_way_mask, base + L2X0_INV_WAY); |
| 99 | ux500_cache_wait(base + L2X0_INV_WAY, l2x0_way_mask); |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 100 | ux500_cache_sync(); |
| 101 | } |
| 102 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 103 | static int ux500_l2x0_init(void) |
| 104 | { |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 105 | 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 Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 111 | |
| 112 | /* 64KB way size, 8 way associativity, force WA */ |
| 113 | l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff); |
| 114 | |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 115 | /* Override invalidate function */ |
| 116 | outer_cache.disable = ux500_l2x0_disable; |
| 117 | outer_cache.inv_all = ux500_l2x0_inv_all; |
| 118 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | early_initcall(ux500_l2x0_init); |
| 122 | #endif |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 123 | |
| 124 | static void __init ux500_timer_init(void) |
| 125 | { |
| 126 | #ifdef CONFIG_LOCAL_TIMERS |
| 127 | /* Setup the local timer base */ |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 128 | 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 Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 132 | else |
Rabin Vincent | 92389ca | 2010-12-08 11:07:57 +0530 | [diff] [blame] | 133 | 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 Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 143 | |
Mattias Wallin | 7ed00af | 2011-05-27 10:30:34 +0200 | [diff] [blame^] | 144 | 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 Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 151 | nmdk_timer_init(); |
Mattias Wallin | 7ed00af | 2011-05-27 10:30:34 +0200 | [diff] [blame^] | 152 | clksrc_dbx500_prcmu_init(); |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | struct sys_timer ux500_timer = { |
| 156 | .init = ux500_timer_init, |
| 157 | }; |