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> |
| 11 | |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 12 | #include <asm/cacheflush.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 13 | #include <asm/hardware/cache-l2x0.h> |
| 14 | #include <asm/hardware/gic.h> |
| 15 | #include <asm/mach/map.h> |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 16 | #include <asm/localtimer.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 17 | |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 18 | #include <plat/mtu.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 19 | #include <mach/hardware.h> |
| 20 | #include <mach/setup.h> |
Rabin Vincent | d48fd00 | 2010-05-03 07:46:56 +0100 | [diff] [blame] | 21 | #include <mach/devices.h> |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 22 | #include <mach/prcmu.h> |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 23 | |
| 24 | #include "clock.h" |
| 25 | |
| 26 | static struct map_desc ux500_io_desc[] __initdata = { |
| 27 | __IO_DEV_DESC(UX500_UART0_BASE, SZ_4K), |
| 28 | __IO_DEV_DESC(UX500_UART2_BASE, SZ_4K), |
| 29 | |
| 30 | __IO_DEV_DESC(UX500_GIC_CPU_BASE, SZ_4K), |
| 31 | __IO_DEV_DESC(UX500_GIC_DIST_BASE, SZ_4K), |
| 32 | __IO_DEV_DESC(UX500_L2CC_BASE, SZ_4K), |
| 33 | __IO_DEV_DESC(UX500_TWD_BASE, SZ_4K), |
| 34 | __IO_DEV_DESC(UX500_SCU_BASE, SZ_4K), |
| 35 | |
| 36 | __IO_DEV_DESC(UX500_CLKRST1_BASE, SZ_4K), |
| 37 | __IO_DEV_DESC(UX500_CLKRST2_BASE, SZ_4K), |
| 38 | __IO_DEV_DESC(UX500_CLKRST3_BASE, SZ_4K), |
| 39 | __IO_DEV_DESC(UX500_CLKRST5_BASE, SZ_4K), |
| 40 | __IO_DEV_DESC(UX500_CLKRST6_BASE, SZ_4K), |
| 41 | |
| 42 | __IO_DEV_DESC(UX500_MTU0_BASE, SZ_4K), |
| 43 | __IO_DEV_DESC(UX500_MTU1_BASE, SZ_4K), |
| 44 | |
| 45 | __IO_DEV_DESC(UX500_BACKUPRAM0_BASE, SZ_8K), |
| 46 | }; |
| 47 | |
| 48 | void __init ux500_map_io(void) |
| 49 | { |
| 50 | iotable_init(ux500_io_desc, ARRAY_SIZE(ux500_io_desc)); |
| 51 | } |
| 52 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 53 | void __init ux500_init_irq(void) |
| 54 | { |
| 55 | gic_dist_init(0, __io_address(UX500_GIC_DIST_BASE), 29); |
| 56 | gic_cpu_init(0, __io_address(UX500_GIC_CPU_BASE)); |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 57 | |
| 58 | /* |
| 59 | * Init clocks here so that they are available for system timer |
| 60 | * initialization. |
| 61 | */ |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 62 | prcmu_early_init(); |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 63 | clk_init(); |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | #ifdef CONFIG_CACHE_L2X0 |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 67 | static inline void ux500_cache_wait(void __iomem *reg, unsigned long mask) |
| 68 | { |
| 69 | /* wait for the operation to complete */ |
Per Fransson | ffc43ef | 2010-11-15 14:31:17 +0100 | [diff] [blame] | 70 | while (readl_relaxed(reg) & mask) |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 71 | ; |
| 72 | } |
| 73 | |
| 74 | static inline void ux500_cache_sync(void) |
| 75 | { |
| 76 | void __iomem *base = __io_address(UX500_L2CC_BASE); |
Per Fransson | ffc43ef | 2010-11-15 14:31:17 +0100 | [diff] [blame] | 77 | writel_relaxed(0, base + L2X0_CACHE_SYNC); |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 78 | ux500_cache_wait(base + L2X0_CACHE_SYNC, 1); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * The L2 cache cannot be turned off in the non-secure world. |
| 83 | * Dummy until a secure service is in place. |
| 84 | */ |
| 85 | static void ux500_l2x0_disable(void) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * This is only called when doing a kexec, just after turning off the L2 |
| 91 | * and L1 cache, and it is surrounded by a spinlock in the generic version. |
| 92 | * However, we're not really turning off the L2 cache right now and the |
| 93 | * PL310 does not support exclusive accesses (used to implement the spinlock). |
| 94 | * So, the invalidation needs to be done without the spinlock. |
| 95 | */ |
| 96 | static void ux500_l2x0_inv_all(void) |
| 97 | { |
| 98 | void __iomem *l2x0_base = __io_address(UX500_L2CC_BASE); |
| 99 | uint32_t l2x0_way_mask = (1<<16) - 1; /* Bitmask of active ways */ |
| 100 | |
| 101 | /* invalidate all ways */ |
Per Fransson | ffc43ef | 2010-11-15 14:31:17 +0100 | [diff] [blame] | 102 | writel_relaxed(l2x0_way_mask, l2x0_base + L2X0_INV_WAY); |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 103 | ux500_cache_wait(l2x0_base + L2X0_INV_WAY, l2x0_way_mask); |
| 104 | ux500_cache_sync(); |
| 105 | } |
| 106 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 107 | static int ux500_l2x0_init(void) |
| 108 | { |
| 109 | void __iomem *l2x0_base; |
| 110 | |
| 111 | l2x0_base = __io_address(UX500_L2CC_BASE); |
| 112 | |
| 113 | /* 64KB way size, 8 way associativity, force WA */ |
| 114 | l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff); |
| 115 | |
Per Fransson | ae69480 | 2010-09-08 21:21:40 +0530 | [diff] [blame] | 116 | /* Override invalidate function */ |
| 117 | outer_cache.disable = ux500_l2x0_disable; |
| 118 | outer_cache.inv_all = ux500_l2x0_inv_all; |
| 119 | |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 120 | return 0; |
| 121 | } |
| 122 | early_initcall(ux500_l2x0_init); |
| 123 | #endif |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 124 | |
| 125 | static void __init ux500_timer_init(void) |
| 126 | { |
| 127 | #ifdef CONFIG_LOCAL_TIMERS |
| 128 | /* Setup the local timer base */ |
| 129 | twd_base = __io_address(UX500_TWD_BASE); |
| 130 | #endif |
| 131 | /* Setup the MTU base */ |
| 132 | if (cpu_is_u8500ed()) |
| 133 | mtu_base = __io_address(U8500_MTU0_BASE_ED); |
| 134 | else |
| 135 | mtu_base = __io_address(UX500_MTU0_BASE); |
| 136 | |
| 137 | nmdk_timer_init(); |
| 138 | } |
| 139 | |
| 140 | struct sys_timer ux500_timer = { |
| 141 | .init = ux500_timer_init, |
| 142 | }; |