diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2014-09-03 16:51:06 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-11-24 01:44:59 -0500 |
commit | 8d602dd0f984e8488ab891344ebdb6e1f3128c4a (patch) | |
tree | 4bf080e55c985ef84980ba1193b5f9fa951d013a /arch/mips | |
parent | 4060bbe9931eca2ed3c2124022a070a75d507472 (diff) |
MIPS: BCM47XX: Get rid of calls to KSEG1ADDR
We should be using ioremap_nocache helper which handles remaps in a
smarter way.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Cc: linux-mips@linux-mips.org
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Patchwork: http://patchwork.linux-mips.org/patch/7611/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/bcm47xx/nvram.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c index 2bed73a684ae..e07976bbb739 100644 --- a/arch/mips/bcm47xx/nvram.c +++ b/arch/mips/bcm47xx/nvram.c | |||
@@ -23,13 +23,13 @@ | |||
23 | static char nvram_buf[NVRAM_SPACE]; | 23 | static char nvram_buf[NVRAM_SPACE]; |
24 | static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000}; | 24 | static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000}; |
25 | 25 | ||
26 | static u32 find_nvram_size(u32 end) | 26 | static u32 find_nvram_size(void __iomem *end) |
27 | { | 27 | { |
28 | struct nvram_header *header; | 28 | struct nvram_header __iomem *header; |
29 | int i; | 29 | int i; |
30 | 30 | ||
31 | for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) { | 31 | for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) { |
32 | header = (struct nvram_header *)KSEG1ADDR(end - nvram_sizes[i]); | 32 | header = (struct nvram_header *)(end - nvram_sizes[i]); |
33 | if (header->magic == NVRAM_HEADER) | 33 | if (header->magic == NVRAM_HEADER) |
34 | return nvram_sizes[i]; | 34 | return nvram_sizes[i]; |
35 | } | 35 | } |
@@ -38,35 +38,39 @@ static u32 find_nvram_size(u32 end) | |||
38 | } | 38 | } |
39 | 39 | ||
40 | /* Probe for NVRAM header */ | 40 | /* Probe for NVRAM header */ |
41 | static int nvram_find_and_copy(u32 base, u32 lim) | 41 | static int nvram_find_and_copy(void __iomem *iobase, u32 lim) |
42 | { | 42 | { |
43 | struct nvram_header *header; | 43 | struct nvram_header __iomem *header; |
44 | int i; | 44 | int i; |
45 | u32 off; | 45 | u32 off; |
46 | u32 *src, *dst; | 46 | u32 *src, *dst; |
47 | u32 size; | 47 | u32 size; |
48 | 48 | ||
49 | if (nvram_buf[0]) { | ||
50 | pr_warn("nvram already initialized\n"); | ||
51 | return -EEXIST; | ||
52 | } | ||
53 | |||
49 | /* TODO: when nvram is on nand flash check for bad blocks first. */ | 54 | /* TODO: when nvram is on nand flash check for bad blocks first. */ |
50 | off = FLASH_MIN; | 55 | off = FLASH_MIN; |
51 | while (off <= lim) { | 56 | while (off <= lim) { |
52 | /* Windowed flash access */ | 57 | /* Windowed flash access */ |
53 | size = find_nvram_size(base + off); | 58 | size = find_nvram_size(iobase + off); |
54 | if (size) { | 59 | if (size) { |
55 | header = (struct nvram_header *)KSEG1ADDR(base + off - | 60 | header = (struct nvram_header *)(iobase + off - size); |
56 | size); | ||
57 | goto found; | 61 | goto found; |
58 | } | 62 | } |
59 | off <<= 1; | 63 | off <<= 1; |
60 | } | 64 | } |
61 | 65 | ||
62 | /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */ | 66 | /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */ |
63 | header = (struct nvram_header *) KSEG1ADDR(base + 4096); | 67 | header = (struct nvram_header *)(iobase + 4096); |
64 | if (header->magic == NVRAM_HEADER) { | 68 | if (header->magic == NVRAM_HEADER) { |
65 | size = NVRAM_SPACE; | 69 | size = NVRAM_SPACE; |
66 | goto found; | 70 | goto found; |
67 | } | 71 | } |
68 | 72 | ||
69 | header = (struct nvram_header *) KSEG1ADDR(base + 1024); | 73 | header = (struct nvram_header *)(iobase + 1024); |
70 | if (header->magic == NVRAM_HEADER) { | 74 | if (header->magic == NVRAM_HEADER) { |
71 | size = NVRAM_SPACE; | 75 | size = NVRAM_SPACE; |
72 | goto found; | 76 | goto found; |
@@ -94,6 +98,22 @@ found: | |||
94 | return 0; | 98 | return 0; |
95 | } | 99 | } |
96 | 100 | ||
101 | static int bcm47xx_nvram_init_from_mem(u32 base, u32 lim) | ||
102 | { | ||
103 | void __iomem *iobase; | ||
104 | int err; | ||
105 | |||
106 | iobase = ioremap_nocache(base, lim); | ||
107 | if (!iobase) | ||
108 | return -ENOMEM; | ||
109 | |||
110 | err = nvram_find_and_copy(iobase, lim); | ||
111 | |||
112 | iounmap(iobase); | ||
113 | |||
114 | return err; | ||
115 | } | ||
116 | |||
97 | #ifdef CONFIG_BCM47XX_SSB | 117 | #ifdef CONFIG_BCM47XX_SSB |
98 | static int nvram_init_ssb(void) | 118 | static int nvram_init_ssb(void) |
99 | { | 119 | { |
@@ -109,7 +129,7 @@ static int nvram_init_ssb(void) | |||
109 | return -ENXIO; | 129 | return -ENXIO; |
110 | } | 130 | } |
111 | 131 | ||
112 | return nvram_find_and_copy(base, lim); | 132 | return bcm47xx_nvram_init_from_mem(base, lim); |
113 | } | 133 | } |
114 | #endif | 134 | #endif |
115 | 135 | ||
@@ -139,7 +159,7 @@ static int nvram_init_bcma(void) | |||
139 | return -ENXIO; | 159 | return -ENXIO; |
140 | } | 160 | } |
141 | 161 | ||
142 | return nvram_find_and_copy(base, lim); | 162 | return bcm47xx_nvram_init_from_mem(base, lim); |
143 | } | 163 | } |
144 | #endif | 164 | #endif |
145 | 165 | ||