aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mm
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2014-03-15 19:26:24 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-05-29 19:48:34 -0400
commit0493aef4da8231b4b2f2da8dc1784c265e610a7d (patch)
tree9b565efb93215d3f95f5245bf85445e440ac39a5 /arch/arm/mm
parent5f47c38704e15f9db356dd799391bc9f9efc4e0c (diff)
ARM: l2c: move way size calculation data into l2c_init_data
Move the way size calculation data (base of way size) out of the switch statement into the provided initialisation data. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm')
-rw-r--r--arch/arm/mm/cache-l2x0.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 69a18316b239..b4d373ab1a5c 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -30,6 +30,7 @@
30 30
31struct l2c_init_data { 31struct l2c_init_data {
32 const char *type; 32 const char *type;
33 unsigned way_size_0;
33 unsigned num_lock; 34 unsigned num_lock;
34 void (*of_parse)(const struct device_node *, u32 *, u32 *); 35 void (*of_parse)(const struct device_node *, u32 *, u32 *);
35 void (*enable)(void __iomem *, u32, unsigned); 36 void (*enable)(void __iomem *, u32, unsigned);
@@ -276,6 +277,7 @@ static void l2c210_resume(void)
276 277
277static const struct l2c_init_data l2c210_data __initconst = { 278static const struct l2c_init_data l2c210_data __initconst = {
278 .type = "L2C-210", 279 .type = "L2C-210",
280 .way_size_0 = SZ_8K,
279 .num_lock = 1, 281 .num_lock = 1,
280 .enable = l2c_enable, 282 .enable = l2c_enable,
281 .outer_cache = { 283 .outer_cache = {
@@ -419,6 +421,7 @@ static void l2c220_sync(void)
419 421
420static const struct l2c_init_data l2c220_data = { 422static const struct l2c_init_data l2c220_data = {
421 .type = "L2C-220", 423 .type = "L2C-220",
424 .way_size_0 = SZ_8K,
422 .num_lock = 1, 425 .num_lock = 1,
423 .enable = l2c_enable, 426 .enable = l2c_enable,
424 .outer_cache = { 427 .outer_cache = {
@@ -654,6 +657,7 @@ static void __init l2c310_fixup(void __iomem *base, u32 cache_id,
654 657
655static const struct l2c_init_data l2c310_init_fns __initconst = { 658static const struct l2c_init_data l2c310_init_fns __initconst = {
656 .type = "L2C-310", 659 .type = "L2C-310",
660 .way_size_0 = SZ_8K,
657 .num_lock = 8, 661 .num_lock = 8,
658 .enable = l2c_enable, 662 .enable = l2c_enable,
659 .fixup = l2c310_fixup, 663 .fixup = l2c310_fixup,
@@ -674,10 +678,8 @@ static void __init __l2c_init(const struct l2c_init_data *data,
674 u32 aux_val, u32 aux_mask, u32 cache_id) 678 u32 aux_val, u32 aux_mask, u32 cache_id)
675{ 679{
676 struct outer_cache_fns fns; 680 struct outer_cache_fns fns;
681 unsigned way_size_bits, ways;
677 u32 aux; 682 u32 aux;
678 u32 way_size = 0;
679 int ways;
680 int way_size_shift = L2X0_WAY_SIZE_SHIFT;
681 683
682 /* 684 /*
683 * It is strange to save the register state before initialisation, 685 * It is strange to save the register state before initialisation,
@@ -708,7 +710,6 @@ static void __init __l2c_init(const struct l2c_init_data *data,
708 case AURORA_CACHE_ID: 710 case AURORA_CACHE_ID:
709 ways = (aux >> 13) & 0xf; 711 ways = (aux >> 13) & 0xf;
710 ways = 2 << ((ways + 1) >> 2); 712 ways = 2 << ((ways + 1) >> 2);
711 way_size_shift = AURORA_WAY_SIZE_SHIFT;
712 break; 713 break;
713 714
714 default: 715 default:
@@ -720,12 +721,15 @@ static void __init __l2c_init(const struct l2c_init_data *data,
720 l2x0_way_mask = (1 << ways) - 1; 721 l2x0_way_mask = (1 << ways) - 1;
721 722
722 /* 723 /*
723 * L2 cache Size = Way size * Number of ways 724 * way_size_0 is the size that a way_size value of zero would be
725 * given the calculation: way_size = way_size_0 << way_size_bits.
726 * So, if way_size_bits=0 is reserved, but way_size_bits=1 is 16k,
727 * then way_size_0 would be 8k.
728 *
729 * L2 cache size = number of ways * way size.
724 */ 730 */
725 way_size = (aux & L2X0_AUX_CTRL_WAY_SIZE_MASK) >> 17; 731 way_size_bits = (aux & L2X0_AUX_CTRL_WAY_SIZE_MASK) >> 17;
726 way_size = 1 << (way_size + way_size_shift); 732 l2x0_size = ways * (data->way_size_0 << way_size_bits);
727
728 l2x0_size = ways * way_size * SZ_1K;
729 733
730 fns = data->outer_cache; 734 fns = data->outer_cache;
731 if (data->fixup) 735 if (data->fixup)
@@ -822,6 +826,7 @@ static void __init l2x0_of_parse(const struct device_node *np,
822 826
823static const struct l2c_init_data of_l2c210_data __initconst = { 827static const struct l2c_init_data of_l2c210_data __initconst = {
824 .type = "L2C-210", 828 .type = "L2C-210",
829 .way_size_0 = SZ_8K,
825 .num_lock = 1, 830 .num_lock = 1,
826 .of_parse = l2x0_of_parse, 831 .of_parse = l2x0_of_parse,
827 .enable = l2c_enable, 832 .enable = l2c_enable,
@@ -838,6 +843,7 @@ static const struct l2c_init_data of_l2c210_data __initconst = {
838 843
839static const struct l2c_init_data of_l2c220_data __initconst = { 844static const struct l2c_init_data of_l2c220_data __initconst = {
840 .type = "L2C-220", 845 .type = "L2C-220",
846 .way_size_0 = SZ_8K,
841 .num_lock = 1, 847 .num_lock = 1,
842 .of_parse = l2x0_of_parse, 848 .of_parse = l2x0_of_parse,
843 .enable = l2c_enable, 849 .enable = l2c_enable,
@@ -888,6 +894,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
888 894
889static const struct l2c_init_data of_l2c310_data __initconst = { 895static const struct l2c_init_data of_l2c310_data __initconst = {
890 .type = "L2C-310", 896 .type = "L2C-310",
897 .way_size_0 = SZ_8K,
891 .num_lock = 8, 898 .num_lock = 8,
892 .of_parse = l2c310_of_parse, 899 .of_parse = l2c310_of_parse,
893 .enable = l2c_enable, 900 .enable = l2c_enable,
@@ -1067,6 +1074,7 @@ static void __init aurora_of_parse(const struct device_node *np,
1067 1074
1068static const struct l2c_init_data of_aurora_with_outer_data __initconst = { 1075static const struct l2c_init_data of_aurora_with_outer_data __initconst = {
1069 .type = "Aurora", 1076 .type = "Aurora",
1077 .way_size_0 = SZ_4K,
1070 .num_lock = 4, 1078 .num_lock = 4,
1071 .of_parse = aurora_of_parse, 1079 .of_parse = aurora_of_parse,
1072 .enable = l2c_enable, 1080 .enable = l2c_enable,
@@ -1085,6 +1093,7 @@ static const struct l2c_init_data of_aurora_with_outer_data __initconst = {
1085 1093
1086static const struct l2c_init_data of_aurora_no_outer_data __initconst = { 1094static const struct l2c_init_data of_aurora_no_outer_data __initconst = {
1087 .type = "Aurora", 1095 .type = "Aurora",
1096 .way_size_0 = SZ_4K,
1088 .num_lock = 4, 1097 .num_lock = 4,
1089 .of_parse = aurora_of_parse, 1098 .of_parse = aurora_of_parse,
1090 .enable = aurora_enable_no_outer, 1099 .enable = aurora_enable_no_outer,
@@ -1234,6 +1243,7 @@ static void bcm_flush_range(unsigned long start, unsigned long end)
1234/* Broadcom L2C-310 start from ARMs R3P2 or later, and require no fixups */ 1243/* Broadcom L2C-310 start from ARMs R3P2 or later, and require no fixups */
1235static const struct l2c_init_data of_bcm_l2x0_data __initconst = { 1244static const struct l2c_init_data of_bcm_l2x0_data __initconst = {
1236 .type = "BCM-L2C-310", 1245 .type = "BCM-L2C-310",
1246 .way_size_0 = SZ_8K,
1237 .num_lock = 8, 1247 .num_lock = 8,
1238 .of_parse = l2c310_of_parse, 1248 .of_parse = l2c310_of_parse,
1239 .enable = l2c_enable, 1249 .enable = l2c_enable,
@@ -1273,6 +1283,7 @@ static void tauros3_resume(void)
1273 1283
1274static const struct l2c_init_data of_tauros3_data __initconst = { 1284static const struct l2c_init_data of_tauros3_data __initconst = {
1275 .type = "Tauros3", 1285 .type = "Tauros3",
1286 .way_size_0 = SZ_8K,
1276 .num_lock = 8, 1287 .num_lock = 8,
1277 .enable = l2c_enable, 1288 .enable = l2c_enable,
1278 .save = tauros3_save, 1289 .save = tauros3_save,