Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * OMAP4 specific common source file. |
| 3 | * |
| 4 | * Copyright (C) 2010 Texas Instruments, Inc. |
| 5 | * Author: |
| 6 | * Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 7 | * |
| 8 | * |
| 9 | * This program is free software,you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/platform_device.h> |
| 18 | |
| 19 | #include <asm/hardware/gic.h> |
| 20 | #include <asm/hardware/cache-l2x0.h> |
| 21 | |
Tony Lindgren | 741e3a8 | 2011-05-17 03:51:26 -0700 | [diff] [blame] | 22 | #include <plat/irqs.h> |
| 23 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 24 | #include <mach/hardware.h> |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 25 | |
| 26 | #include "common.h" |
Santosh Shilimkar | 501f0c7 | 2011-01-01 19:56:04 +0530 | [diff] [blame^] | 27 | #include "omap4-sar-layout.h" |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 28 | |
| 29 | #ifdef CONFIG_CACHE_L2X0 |
Santosh Shilimkar | 02afe8a | 2011-03-03 18:03:25 +0530 | [diff] [blame] | 30 | static void __iomem *l2cache_base; |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 31 | #endif |
| 32 | |
Santosh Shilimkar | 501f0c7 | 2011-01-01 19:56:04 +0530 | [diff] [blame^] | 33 | static void __iomem *sar_ram_base; |
| 34 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 35 | void __init gic_init_irq(void) |
| 36 | { |
Marc Zyngier | ab65be2 | 2011-11-15 17:22:45 +0000 | [diff] [blame] | 37 | void __iomem *omap_irq_base; |
| 38 | void __iomem *gic_dist_base_addr; |
| 39 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 40 | /* Static mapping, never released */ |
| 41 | gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K); |
| 42 | BUG_ON(!gic_dist_base_addr); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 43 | |
| 44 | /* Static mapping, never released */ |
Tony Lindgren | 741e3a8 | 2011-05-17 03:51:26 -0700 | [diff] [blame] | 45 | omap_irq_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512); |
| 46 | BUG_ON(!omap_irq_base); |
Russell King | b580b89 | 2010-12-04 15:55:14 +0000 | [diff] [blame] | 47 | |
Tony Lindgren | 741e3a8 | 2011-05-17 03:51:26 -0700 | [diff] [blame] | 48 | gic_init(0, 29, gic_dist_base_addr, omap_irq_base); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | #ifdef CONFIG_CACHE_L2X0 |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 52 | |
Santosh Shilimkar | 02afe8a | 2011-03-03 18:03:25 +0530 | [diff] [blame] | 53 | void __iomem *omap4_get_l2cache_base(void) |
| 54 | { |
| 55 | return l2cache_base; |
| 56 | } |
| 57 | |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 58 | static void omap4_l2x0_disable(void) |
| 59 | { |
| 60 | /* Disable PL310 L2 Cache controller */ |
| 61 | omap_smc1(0x102, 0x0); |
| 62 | } |
| 63 | |
Santosh Shilimkar | 4bdb157 | 2011-02-22 10:00:44 +0100 | [diff] [blame] | 64 | static void omap4_l2x0_set_debug(unsigned long val) |
| 65 | { |
| 66 | /* Program PL310 L2 Cache controller debug register */ |
| 67 | omap_smc1(0x100, val); |
| 68 | } |
| 69 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 70 | static int __init omap_l2_cache_init(void) |
| 71 | { |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 72 | u32 aux_ctrl = 0; |
| 73 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 74 | /* |
| 75 | * To avoid code running on other OMAPs in |
| 76 | * multi-omap builds |
| 77 | */ |
| 78 | if (!cpu_is_omap44xx()) |
| 79 | return -ENODEV; |
| 80 | |
| 81 | /* Static mapping, never released */ |
| 82 | l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K); |
Santosh Shilimkar | 0db1803 | 2011-03-03 17:36:52 +0530 | [diff] [blame] | 83 | if (WARN_ON(!l2cache_base)) |
| 84 | return -ENOMEM; |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 85 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 86 | /* |
Santosh Shilimkar | a777b72 | 2010-09-16 18:44:47 +0530 | [diff] [blame] | 87 | * 16-way associativity, parity disabled |
| 88 | * Way size - 32KB (es1.0) |
| 89 | * Way size - 64KB (es2.0 +) |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 90 | */ |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 91 | aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) | |
| 92 | (0x1 << 25) | |
| 93 | (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) | |
| 94 | (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT)); |
| 95 | |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 96 | if (omap_rev() == OMAP4430_REV_ES1_0) { |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 97 | aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT; |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 98 | } else { |
| 99 | aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | |
Santosh Shilimkar | b0f20ff | 2010-11-19 23:01:05 +0530 | [diff] [blame] | 100 | (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 101 | (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) | |
Santosh Shilimkar | b89cd71 | 2010-11-19 23:01:06 +0530 | [diff] [blame] | 102 | (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | |
| 103 | (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT)); |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 104 | } |
| 105 | if (omap_rev() != OMAP4430_REV_ES1_0) |
| 106 | omap_smc1(0x109, aux_ctrl); |
| 107 | |
| 108 | /* Enable PL310 L2 Cache controller */ |
| 109 | omap_smc1(0x102, 0x1); |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 110 | |
| 111 | l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 112 | |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 113 | /* |
| 114 | * Override default outer_cache.disable with a OMAP4 |
| 115 | * specific one |
| 116 | */ |
| 117 | outer_cache.disable = omap4_l2x0_disable; |
Santosh Shilimkar | 4bdb157 | 2011-02-22 10:00:44 +0100 | [diff] [blame] | 118 | outer_cache.set_debug = omap4_l2x0_set_debug; |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 119 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 120 | return 0; |
| 121 | } |
| 122 | early_initcall(omap_l2_cache_init); |
| 123 | #endif |
Santosh Shilimkar | 501f0c7 | 2011-01-01 19:56:04 +0530 | [diff] [blame^] | 124 | |
| 125 | void __iomem *omap4_get_sar_ram_base(void) |
| 126 | { |
| 127 | return sar_ram_base; |
| 128 | } |
| 129 | |
| 130 | /* |
| 131 | * SAR RAM used to save and restore the HW |
| 132 | * context in low power modes |
| 133 | */ |
| 134 | static int __init omap4_sar_ram_init(void) |
| 135 | { |
| 136 | /* |
| 137 | * To avoid code running on other OMAPs in |
| 138 | * multi-omap builds |
| 139 | */ |
| 140 | if (!cpu_is_omap44xx()) |
| 141 | return -ENOMEM; |
| 142 | |
| 143 | /* Static mapping, never released */ |
| 144 | sar_ram_base = ioremap(OMAP44XX_SAR_RAM_BASE, SZ_16K); |
| 145 | if (WARN_ON(!sar_ram_base)) |
| 146 | return -ENOMEM; |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | early_initcall(omap4_sar_ram_init); |