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 | |
| 22 | #include <mach/hardware.h> |
| 23 | #include <mach/omap4-common.h> |
| 24 | |
| 25 | #ifdef CONFIG_CACHE_L2X0 |
| 26 | void __iomem *l2cache_base; |
| 27 | #endif |
| 28 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 29 | void __iomem *gic_dist_base_addr; |
| 30 | |
| 31 | |
| 32 | void __init gic_init_irq(void) |
| 33 | { |
Russell King | ff2e27a | 2010-12-04 16:13:29 +0000 | [diff] [blame] | 34 | void __iomem *gic_cpu_base; |
| 35 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 36 | /* Static mapping, never released */ |
| 37 | gic_dist_base_addr = ioremap(OMAP44XX_GIC_DIST_BASE, SZ_4K); |
| 38 | BUG_ON(!gic_dist_base_addr); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 39 | |
| 40 | /* Static mapping, never released */ |
Russell King | ff2e27a | 2010-12-04 16:13:29 +0000 | [diff] [blame] | 41 | gic_cpu_base = ioremap(OMAP44XX_GIC_CPU_BASE, SZ_512); |
| 42 | BUG_ON(!gic_cpu_base); |
Russell King | b580b89 | 2010-12-04 15:55:14 +0000 | [diff] [blame] | 43 | |
Russell King | ff2e27a | 2010-12-04 16:13:29 +0000 | [diff] [blame] | 44 | gic_init(0, 29, gic_dist_base_addr, gic_cpu_base); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | #ifdef CONFIG_CACHE_L2X0 |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 48 | |
| 49 | static void omap4_l2x0_disable(void) |
| 50 | { |
| 51 | /* Disable PL310 L2 Cache controller */ |
| 52 | omap_smc1(0x102, 0x0); |
| 53 | } |
| 54 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 55 | static int __init omap_l2_cache_init(void) |
| 56 | { |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 57 | u32 aux_ctrl = 0; |
| 58 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 59 | /* |
| 60 | * To avoid code running on other OMAPs in |
| 61 | * multi-omap builds |
| 62 | */ |
| 63 | if (!cpu_is_omap44xx()) |
| 64 | return -ENODEV; |
| 65 | |
| 66 | /* Static mapping, never released */ |
| 67 | l2cache_base = ioremap(OMAP44XX_L2CACHE_BASE, SZ_4K); |
| 68 | BUG_ON(!l2cache_base); |
| 69 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 70 | /* |
Santosh Shilimkar | a777b72 | 2010-09-16 18:44:47 +0530 | [diff] [blame] | 71 | * 16-way associativity, parity disabled |
| 72 | * Way size - 32KB (es1.0) |
| 73 | * Way size - 64KB (es2.0 +) |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 74 | */ |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 75 | aux_ctrl = ((1 << L2X0_AUX_CTRL_ASSOCIATIVITY_SHIFT) | |
| 76 | (0x1 << 25) | |
| 77 | (0x1 << L2X0_AUX_CTRL_NS_LOCKDOWN_SHIFT) | |
| 78 | (0x1 << L2X0_AUX_CTRL_NS_INT_CTRL_SHIFT)); |
| 79 | |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 80 | if (omap_rev() == OMAP4430_REV_ES1_0) { |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 81 | aux_ctrl |= 0x2 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT; |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 82 | } else { |
| 83 | aux_ctrl |= ((0x3 << L2X0_AUX_CTRL_WAY_SIZE_SHIFT) | |
Santosh Shilimkar | b0f20ff | 2010-11-19 23:01:05 +0530 | [diff] [blame] | 84 | (1 << L2X0_AUX_CTRL_SHARE_OVERRIDE_SHIFT) | |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 85 | (1 << L2X0_AUX_CTRL_DATA_PREFETCH_SHIFT) | |
Santosh Shilimkar | b89cd71 | 2010-11-19 23:01:06 +0530 | [diff] [blame] | 86 | (1 << L2X0_AUX_CTRL_INSTR_PREFETCH_SHIFT) | |
| 87 | (1 << L2X0_AUX_CTRL_EARLY_BRESP_SHIFT)); |
Mans Rullgard | 11e0264 | 2010-11-19 23:01:04 +0530 | [diff] [blame] | 88 | } |
| 89 | if (omap_rev() != OMAP4430_REV_ES1_0) |
| 90 | omap_smc1(0x109, aux_ctrl); |
| 91 | |
| 92 | /* Enable PL310 L2 Cache controller */ |
| 93 | omap_smc1(0x102, 0x1); |
Santosh Shilimkar | 1773e60 | 2010-11-19 23:01:03 +0530 | [diff] [blame] | 94 | |
| 95 | l2x0_init(l2cache_base, aux_ctrl, L2X0_AUX_CTRL_MASK); |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 96 | |
Santosh Shilimkar | 4e803c4 | 2010-07-31 21:40:10 +0530 | [diff] [blame] | 97 | /* |
| 98 | * Override default outer_cache.disable with a OMAP4 |
| 99 | * specific one |
| 100 | */ |
| 101 | outer_cache.disable = omap4_l2x0_disable; |
| 102 | |
Santosh Shilimkar | fbc9be1 | 2010-05-14 12:05:26 -0700 | [diff] [blame] | 103 | return 0; |
| 104 | } |
| 105 | early_initcall(omap_l2_cache_init); |
| 106 | #endif |