diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-03-28 10:18:35 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-05-29 19:48:47 -0400 |
commit | ddf7d79bc739c44f7e7cdffc9eb5d94aa213f53e (patch) | |
tree | 839ff28f987ad01efc44f43e603a2d390d039ca6 /arch/arm/mm/cache-l2x0.c | |
parent | d9d1f3e2d71144348d73210cf9f1fe0b32481c79 (diff) |
ARM: l2c: move L2 cache register saving to a more sensible location
Move the L2 cache register saving to a more sensible location - after
the cache has been enabled, and fixups have been run. We move the
saving of the auxiliary control register into the ->save function as
well which makes everything operate in a sane and maintainable way.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mm/cache-l2x0.c')
-rw-r--r-- | arch/arm/mm/cache-l2x0.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c index 790343b2c13b..3a34db56827b 100644 --- a/arch/arm/mm/cache-l2x0.c +++ b/arch/arm/mm/cache-l2x0.c | |||
@@ -202,6 +202,11 @@ static void l2x0_disable(void) | |||
202 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); | 202 | raw_spin_unlock_irqrestore(&l2x0_lock, flags); |
203 | } | 203 | } |
204 | 204 | ||
205 | static void l2c_save(void __iomem *base) | ||
206 | { | ||
207 | l2x0_saved_regs.aux_ctrl = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); | ||
208 | } | ||
209 | |||
205 | /* | 210 | /* |
206 | * L2C-210 specific code. | 211 | * L2C-210 specific code. |
207 | * | 212 | * |
@@ -295,6 +300,7 @@ static const struct l2c_init_data l2c210_data __initconst = { | |||
295 | .way_size_0 = SZ_8K, | 300 | .way_size_0 = SZ_8K, |
296 | .num_lock = 1, | 301 | .num_lock = 1, |
297 | .enable = l2c_enable, | 302 | .enable = l2c_enable, |
303 | .save = l2c_save, | ||
298 | .outer_cache = { | 304 | .outer_cache = { |
299 | .inv_range = l2c210_inv_range, | 305 | .inv_range = l2c210_inv_range, |
300 | .clean_range = l2c210_clean_range, | 306 | .clean_range = l2c210_clean_range, |
@@ -439,6 +445,7 @@ static const struct l2c_init_data l2c220_data = { | |||
439 | .way_size_0 = SZ_8K, | 445 | .way_size_0 = SZ_8K, |
440 | .num_lock = 1, | 446 | .num_lock = 1, |
441 | .enable = l2c_enable, | 447 | .enable = l2c_enable, |
448 | .save = l2c_save, | ||
442 | .outer_cache = { | 449 | .outer_cache = { |
443 | .inv_range = l2c220_inv_range, | 450 | .inv_range = l2c220_inv_range, |
444 | .clean_range = l2c220_clean_range, | 451 | .clean_range = l2c220_clean_range, |
@@ -575,6 +582,8 @@ static void __init l2c310_save(void __iomem *base) | |||
575 | { | 582 | { |
576 | unsigned revision; | 583 | unsigned revision; |
577 | 584 | ||
585 | l2c_save(base); | ||
586 | |||
578 | l2x0_saved_regs.tag_latency = readl_relaxed(base + | 587 | l2x0_saved_regs.tag_latency = readl_relaxed(base + |
579 | L310_TAG_LATENCY_CTRL); | 588 | L310_TAG_LATENCY_CTRL); |
580 | l2x0_saved_regs.data_latency = readl_relaxed(base + | 589 | l2x0_saved_regs.data_latency = readl_relaxed(base + |
@@ -712,13 +721,6 @@ static void __init __l2c_init(const struct l2c_init_data *data, | |||
712 | unsigned way_size_bits, ways; | 721 | unsigned way_size_bits, ways; |
713 | u32 aux; | 722 | u32 aux; |
714 | 723 | ||
715 | /* | ||
716 | * It is strange to save the register state before initialisation, | ||
717 | * but hey, this is what the DT implementations decided to do. | ||
718 | */ | ||
719 | if (data->save) | ||
720 | data->save(l2x0_base); | ||
721 | |||
722 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); | 724 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); |
723 | 725 | ||
724 | aux &= aux_mask; | 726 | aux &= aux_mask; |
@@ -777,13 +779,17 @@ static void __init __l2c_init(const struct l2c_init_data *data, | |||
777 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) | 779 | if (!(readl_relaxed(l2x0_base + L2X0_CTRL) & L2X0_CTRL_EN)) |
778 | data->enable(l2x0_base, aux, data->num_lock); | 780 | data->enable(l2x0_base, aux, data->num_lock); |
779 | 781 | ||
780 | /* Re-read it in case some bits are reserved. */ | 782 | outer_cache = fns; |
781 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); | ||
782 | 783 | ||
783 | /* Save the value for resuming. */ | 784 | /* |
784 | l2x0_saved_regs.aux_ctrl = aux; | 785 | * It is strange to save the register state before initialisation, |
786 | * but hey, this is what the DT implementations decided to do. | ||
787 | */ | ||
788 | if (data->save) | ||
789 | data->save(l2x0_base); | ||
785 | 790 | ||
786 | outer_cache = fns; | 791 | /* Re-read it in case some bits are reserved. */ |
792 | aux = readl_relaxed(l2x0_base + L2X0_AUX_CTRL); | ||
787 | 793 | ||
788 | pr_info("%s cache controller enabled, %d ways, %d kB\n", | 794 | pr_info("%s cache controller enabled, %d ways, %d kB\n", |
789 | data->type, ways, l2x0_size >> 10); | 795 | data->type, ways, l2x0_size >> 10); |
@@ -865,6 +871,7 @@ static const struct l2c_init_data of_l2c210_data __initconst = { | |||
865 | .num_lock = 1, | 871 | .num_lock = 1, |
866 | .of_parse = l2x0_of_parse, | 872 | .of_parse = l2x0_of_parse, |
867 | .enable = l2c_enable, | 873 | .enable = l2c_enable, |
874 | .save = l2c_save, | ||
868 | .outer_cache = { | 875 | .outer_cache = { |
869 | .inv_range = l2c210_inv_range, | 876 | .inv_range = l2c210_inv_range, |
870 | .clean_range = l2c210_clean_range, | 877 | .clean_range = l2c210_clean_range, |
@@ -882,6 +889,7 @@ static const struct l2c_init_data of_l2c220_data __initconst = { | |||
882 | .num_lock = 1, | 889 | .num_lock = 1, |
883 | .of_parse = l2x0_of_parse, | 890 | .of_parse = l2x0_of_parse, |
884 | .enable = l2c_enable, | 891 | .enable = l2c_enable, |
892 | .save = l2c_save, | ||
885 | .outer_cache = { | 893 | .outer_cache = { |
886 | .inv_range = l2c220_inv_range, | 894 | .inv_range = l2c220_inv_range, |
887 | .clean_range = l2c220_clean_range, | 895 | .clean_range = l2c220_clean_range, |
@@ -1296,6 +1304,8 @@ static const struct l2c_init_data of_bcm_l2x0_data __initconst = { | |||
1296 | 1304 | ||
1297 | static void __init tauros3_save(void __iomem *base) | 1305 | static void __init tauros3_save(void __iomem *base) |
1298 | { | 1306 | { |
1307 | l2c_save(base); | ||
1308 | |||
1299 | l2x0_saved_regs.aux2_ctrl = | 1309 | l2x0_saved_regs.aux2_ctrl = |
1300 | readl_relaxed(base + TAUROS3_AUX2_CTRL); | 1310 | readl_relaxed(base + TAUROS3_AUX2_CTRL); |
1301 | l2x0_saved_regs.prefetch_ctrl = | 1311 | l2x0_saved_regs.prefetch_ctrl = |