aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorJared Hulbert <jaredeh@gmail.com>2008-04-30 02:26:49 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2008-05-01 13:59:11 -0400
commita98889f3d8882995b5aa2255b931cf0202325cc0 (patch)
tree686a1d3369143dc46c43709e0c40b2cc8ef619d7 /drivers/mtd/devices
parent27c72b040c0be8f3704ed0b6b84c12cbba24a7e8 (diff)
[MTD][NOR] Add physical address to point() method
Adding the ability to get a physical address from point() in addition to virtual address. This physical address is required for XIP of userspace code from flash. Signed-off-by: Jared Hulbert <jaredeh@gmail.com> Reviewed-by: Jörn Engel <joern@logfs.org> Acked-by: Nicolas Pitre <nico@cam.org> Acked-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/mtdram.c11
-rw-r--r--drivers/mtd/devices/phram.c13
-rw-r--r--drivers/mtd/devices/pmc551.c27
-rw-r--r--drivers/mtd/devices/slram.c15
4 files changed, 41 insertions, 25 deletions
diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c
index bf485ff49457..0399be178620 100644
--- a/drivers/mtd/devices/mtdram.c
+++ b/drivers/mtd/devices/mtdram.c
@@ -48,18 +48,21 @@ static int ram_erase(struct mtd_info *mtd, struct erase_info *instr)
48} 48}
49 49
50static int ram_point(struct mtd_info *mtd, loff_t from, size_t len, 50static int ram_point(struct mtd_info *mtd, loff_t from, size_t len,
51 size_t *retlen, u_char **mtdbuf) 51 size_t *retlen, void **virt, resource_size_t *phys)
52{ 52{
53 if (from + len > mtd->size) 53 if (from + len > mtd->size)
54 return -EINVAL; 54 return -EINVAL;
55 55
56 *mtdbuf = mtd->priv + from; 56 /* can we return a physical address with this driver? */
57 if (phys)
58 return -EINVAL;
59
60 *virt = mtd->priv + from;
57 *retlen = len; 61 *retlen = len;
58 return 0; 62 return 0;
59} 63}
60 64
61static void ram_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from, 65static void ram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
62 size_t len)
63{ 66{
64} 67}
65 68
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 5f960182da95..c7987b1c5e01 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -57,20 +57,21 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
57} 57}
58 58
59static int phram_point(struct mtd_info *mtd, loff_t from, size_t len, 59static int phram_point(struct mtd_info *mtd, loff_t from, size_t len,
60 size_t *retlen, u_char **mtdbuf) 60 size_t *retlen, void **virt, resource_size_t *phys)
61{ 61{
62 u_char *start = mtd->priv;
63
64 if (from + len > mtd->size) 62 if (from + len > mtd->size)
65 return -EINVAL; 63 return -EINVAL;
66 64
67 *mtdbuf = start + from; 65 /* can we return a physical address with this driver? */
66 if (phys)
67 return -EINVAL;
68
69 *virt = mtd->priv + from;
68 *retlen = len; 70 *retlen = len;
69 return 0; 71 return 0;
70} 72}
71 73
72static void phram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, 74static void phram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
73 size_t len)
74{ 75{
75} 76}
76 77
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index 7060a0895ce2..bc9981749064 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -134,7 +134,8 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
134 eoff_lo = end & (priv->asize - 1); 134 eoff_lo = end & (priv->asize - 1);
135 soff_lo = instr->addr & (priv->asize - 1); 135 soff_lo = instr->addr & (priv->asize - 1);
136 136
137 pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr); 137 pmc551_point(mtd, instr->addr, instr->len, &retlen,
138 (void **)&ptr, NULL);
138 139
139 if (soff_hi == eoff_hi || mtd->size == priv->asize) { 140 if (soff_hi == eoff_hi || mtd->size == priv->asize) {
140 /* The whole thing fits within one access, so just one shot 141 /* The whole thing fits within one access, so just one shot
@@ -154,7 +155,8 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
154 } 155 }
155 soff_hi += priv->asize; 156 soff_hi += priv->asize;
156 pmc551_point(mtd, (priv->base_map0 | soff_hi), 157 pmc551_point(mtd, (priv->base_map0 | soff_hi),
157 priv->asize, &retlen, &ptr); 158 priv->asize, &retlen,
159 (void **)&ptr, NULL);
158 } 160 }
159 memset(ptr, 0xff, eoff_lo); 161 memset(ptr, 0xff, eoff_lo);
160 } 162 }
@@ -170,7 +172,7 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
170} 172}
171 173
172static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, 174static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
173 size_t * retlen, u_char ** mtdbuf) 175 size_t *retlen, void **virt, resource_size_t *phys)
174{ 176{
175 struct mypriv *priv = mtd->priv; 177 struct mypriv *priv = mtd->priv;
176 u32 soff_hi; 178 u32 soff_hi;
@@ -188,6 +190,10 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
188 return -EINVAL; 190 return -EINVAL;
189 } 191 }
190 192
193 /* can we return a physical address with this driver? */
194 if (phys)
195 return -EINVAL;
196
191 soff_hi = from & ~(priv->asize - 1); 197 soff_hi = from & ~(priv->asize - 1);
192 soff_lo = from & (priv->asize - 1); 198 soff_lo = from & (priv->asize - 1);
193 199
@@ -198,13 +204,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
198 priv->curr_map0 = soff_hi; 204 priv->curr_map0 = soff_hi;
199 } 205 }
200 206
201 *mtdbuf = priv->start + soff_lo; 207 *virt = priv->start + soff_lo;
202 *retlen = len; 208 *retlen = len;
203 return 0; 209 return 0;
204} 210}
205 211
206static void pmc551_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from, 212static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
207 size_t len)
208{ 213{
209#ifdef CONFIG_MTD_PMC551_DEBUG 214#ifdef CONFIG_MTD_PMC551_DEBUG
210 printk(KERN_DEBUG "pmc551_unpoint()\n"); 215 printk(KERN_DEBUG "pmc551_unpoint()\n");
@@ -242,7 +247,7 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
242 soff_lo = from & (priv->asize - 1); 247 soff_lo = from & (priv->asize - 1);
243 eoff_lo = end & (priv->asize - 1); 248 eoff_lo = end & (priv->asize - 1);
244 249
245 pmc551_point(mtd, from, len, retlen, &ptr); 250 pmc551_point(mtd, from, len, retlen, (void **)&ptr, NULL);
246 251
247 if (soff_hi == eoff_hi) { 252 if (soff_hi == eoff_hi) {
248 /* The whole thing fits within one access, so just one shot 253 /* The whole thing fits within one access, so just one shot
@@ -263,7 +268,8 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
263 goto out; 268 goto out;
264 } 269 }
265 soff_hi += priv->asize; 270 soff_hi += priv->asize;
266 pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); 271 pmc551_point(mtd, soff_hi, priv->asize, retlen,
272 (void **)&ptr, NULL);
267 } 273 }
268 memcpy(copyto, ptr, eoff_lo); 274 memcpy(copyto, ptr, eoff_lo);
269 copyto += eoff_lo; 275 copyto += eoff_lo;
@@ -308,7 +314,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
308 soff_lo = to & (priv->asize - 1); 314 soff_lo = to & (priv->asize - 1);
309 eoff_lo = end & (priv->asize - 1); 315 eoff_lo = end & (priv->asize - 1);
310 316
311 pmc551_point(mtd, to, len, retlen, &ptr); 317 pmc551_point(mtd, to, len, retlen, (void **)&ptr, NULL);
312 318
313 if (soff_hi == eoff_hi) { 319 if (soff_hi == eoff_hi) {
314 /* The whole thing fits within one access, so just one shot 320 /* The whole thing fits within one access, so just one shot
@@ -329,7 +335,8 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
329 goto out; 335 goto out;
330 } 336 }
331 soff_hi += priv->asize; 337 soff_hi += priv->asize;
332 pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); 338 pmc551_point(mtd, soff_hi, priv->asize, retlen,
339 (void **)&ptr, NULL);
333 } 340 }
334 memcpy(ptr, copyfrom, eoff_lo); 341 memcpy(ptr, copyfrom, eoff_lo);
335 copyfrom += eoff_lo; 342 copyfrom += eoff_lo;
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index d293add1857c..cb86db746f28 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -76,8 +76,9 @@ static char *map;
76static slram_mtd_list_t *slram_mtdlist = NULL; 76static slram_mtd_list_t *slram_mtdlist = NULL;
77 77
78static int slram_erase(struct mtd_info *, struct erase_info *); 78static int slram_erase(struct mtd_info *, struct erase_info *);
79static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, u_char **); 79static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **,
80static void slram_unpoint(struct mtd_info *, u_char *, loff_t, size_t); 80 resource_size_t *);
81static void slram_unpoint(struct mtd_info *, loff_t, size_t);
81static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *); 82static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
82static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); 83static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
83 84
@@ -104,19 +105,23 @@ static int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
104} 105}
105 106
106static int slram_point(struct mtd_info *mtd, loff_t from, size_t len, 107static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
107 size_t *retlen, u_char **mtdbuf) 108 size_t *retlen, void **virt, resource_size_t *phys)
108{ 109{
109 slram_priv_t *priv = mtd->priv; 110 slram_priv_t *priv = mtd->priv;
110 111
112 /* can we return a physical address with this driver? */
113 if (phys)
114 return -EINVAL;
115
111 if (from + len > mtd->size) 116 if (from + len > mtd->size)
112 return -EINVAL; 117 return -EINVAL;
113 118
114 *mtdbuf = priv->start + from; 119 *virt = priv->start + from;
115 *retlen = len; 120 *retlen = len;
116 return(0); 121 return(0);
117} 122}
118 123
119static void slram_unpoint(struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) 124static void slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
120{ 125{
121} 126}
122 127