aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot
diff options
context:
space:
mode:
authorLaurent Pinchart <laurentp@cse-semaphore.com>2008-04-10 11:03:04 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-04-17 02:01:37 -0400
commitda0a5f0c65913e4ec0a70a5019ce0a7bcaab21c9 (patch)
tree6aab633690a25acaf46d61416cff6a808deaad8d /arch/powerpc/boot
parentd464df2667cf181419604e656773f80996cf0470 (diff)
[POWERPC] Add bootwrapper function to get virtual reg from the device tree.
This patch adds a new generic device tree processing function that retrieves virtual reg addresses from the device tree to the bootwrapper code. It also updates the bootwrapper code to use the new function. dt_get_virtual_reg() retrieves the virtual reg addresses from the "virtual-reg" property. If the property can't be found, it uses the "reg" property and walks the tree to translate it to absolute addresses. Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com> Acked-by: Scott Wood <scottwood@freescale.com> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r--arch/powerpc/boot/cpm-serial.c34
-rw-r--r--arch/powerpc/boot/devtree.c20
-rw-r--r--arch/powerpc/boot/mpc52xx-psc.c9
-rw-r--r--arch/powerpc/boot/ns16550.c10
-rw-r--r--arch/powerpc/boot/ops.h1
5 files changed, 31 insertions, 43 deletions
diff --git a/arch/powerpc/boot/cpm-serial.c b/arch/powerpc/boot/cpm-serial.c
index 28296facb2ae..1f6225aad298 100644
--- a/arch/powerpc/boot/cpm-serial.c
+++ b/arch/powerpc/boot/cpm-serial.c
@@ -177,7 +177,6 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
177{ 177{
178 void *reg_virt[2]; 178 void *reg_virt[2];
179 int is_smc = 0, is_cpm2 = 0, n; 179 int is_smc = 0, is_cpm2 = 0, n;
180 unsigned long reg_phys;
181 void *parent, *muram; 180 void *parent, *muram;
182 181
183 if (dt_is_compatible(devp, "fsl,cpm1-smc-uart")) { 182 if (dt_is_compatible(devp, "fsl,cpm1-smc-uart")) {
@@ -206,15 +205,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
206 if (n < 4) 205 if (n < 4)
207 return -1; 206 return -1;
208 207
209 n = getprop(devp, "virtual-reg", reg_virt, sizeof(reg_virt)); 208 if (dt_get_virtual_reg(devp, reg_virt, 2) < 2)
210 if (n < (int)sizeof(reg_virt)) { 209 return -1;
211 for (n = 0; n < 2; n++) {
212 if (!dt_xlate_reg(devp, n, &reg_phys, NULL))
213 return -1;
214
215 reg_virt[n] = (void *)reg_phys;
216 }
217 }
218 210
219 if (is_smc) 211 if (is_smc)
220 smc = reg_virt[0]; 212 smc = reg_virt[0];
@@ -227,15 +219,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
227 if (!parent) 219 if (!parent)
228 return -1; 220 return -1;
229 221
230 n = getprop(parent, "virtual-reg", reg_virt, sizeof(reg_virt)); 222 if (dt_get_virtual_reg(parent, &cpcr, 1) < 1)
231 if (n < (int)sizeof(reg_virt)) { 223 return -1;
232 if (!dt_xlate_reg(parent, 0, &reg_phys, NULL))
233 return -1;
234
235 reg_virt[0] = (void *)reg_phys;
236 }
237
238 cpcr = reg_virt[0];
239 224
240 muram = finddevice("/soc/cpm/muram/data"); 225 muram = finddevice("/soc/cpm/muram/data");
241 if (!muram) 226 if (!muram)
@@ -246,15 +231,8 @@ int cpm_console_init(void *devp, struct serial_console_data *scdp)
246 * is one for both parent and child. 231 * is one for both parent and child.
247 */ 232 */
248 233
249 n = getprop(muram, "virtual-reg", reg_virt, sizeof(reg_virt)); 234 if (dt_get_virtual_reg(muram, (void **)&muram_start, 1) < 1)
250 if (n < (int)sizeof(reg_virt)) { 235 return -1;
251 if (!dt_xlate_reg(muram, 0, &reg_phys, NULL))
252 return -1;
253
254 reg_virt[0] = (void *)reg_phys;
255 }
256
257 muram_start = reg_virt[0];
258 236
259 n = getprop(muram, "reg", &muram_offset, 4); 237 n = getprop(muram, "reg", &muram_offset, 4);
260 if (n < 4) 238 if (n < 4)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index 60f561e307a9..5d12336dc360 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -350,3 +350,23 @@ int dt_is_compatible(void *node, const char *compat)
350 350
351 return 0; 351 return 0;
352} 352}
353
354int dt_get_virtual_reg(void *node, void **addr, int nres)
355{
356 unsigned long xaddr;
357 int n;
358
359 n = getprop(node, "virtual-reg", addr, nres * 4);
360 if (n > 0)
361 return n / 4;
362
363 for (n = 0; n < nres; n++) {
364 if (!dt_xlate_reg(node, n, &xaddr, NULL))
365 break;
366
367 addr[n] = (void *)xaddr;
368 }
369
370 return n;
371}
372
diff --git a/arch/powerpc/boot/mpc52xx-psc.c b/arch/powerpc/boot/mpc52xx-psc.c
index 1074626e6a37..d4cb4e4e0938 100644
--- a/arch/powerpc/boot/mpc52xx-psc.c
+++ b/arch/powerpc/boot/mpc52xx-psc.c
@@ -51,14 +51,9 @@ static unsigned char psc_getc(void)
51 51
52int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp) 52int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp)
53{ 53{
54 int n;
55
56 /* Get the base address of the psc registers */ 54 /* Get the base address of the psc registers */
57 n = getprop(devp, "virtual-reg", &psc, sizeof(psc)); 55 if (dt_get_virtual_reg(devp, &psc, 1) < 1)
58 if (n != sizeof(psc)) { 56 return -1;
59 if (!dt_xlate_reg(devp, 0, (void *)&psc, NULL))
60 return -1;
61 }
62 57
63 scdp->open = psc_open; 58 scdp->open = psc_open;
64 scdp->putc = psc_putc; 59 scdp->putc = psc_putc;
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
index f8f1b2f31412..aef3bdc89160 100644
--- a/arch/powerpc/boot/ns16550.c
+++ b/arch/powerpc/boot/ns16550.c
@@ -55,15 +55,9 @@ static u8 ns16550_tstc(void)
55int ns16550_console_init(void *devp, struct serial_console_data *scdp) 55int ns16550_console_init(void *devp, struct serial_console_data *scdp)
56{ 56{
57 int n; 57 int n;
58 unsigned long reg_phys;
59 58
60 n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base)); 59 if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1)
61 if (n != sizeof(reg_base)) { 60 return -1;
62 if (!dt_xlate_reg(devp, 0, &reg_phys, NULL))
63 return -1;
64
65 reg_base = (void *)reg_phys;
66 }
67 61
68 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift)); 62 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
69 if (n != sizeof(reg_shift)) 63 if (n != sizeof(reg_shift))
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 4b0544b03c64..321e2f5afe71 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -95,6 +95,7 @@ int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
95int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr); 95int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
96int dt_is_compatible(void *node, const char *compat); 96int dt_is_compatible(void *node, const char *compat);
97void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize); 97void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize);
98int dt_get_virtual_reg(void *node, void **addr, int nres);
98 99
99static inline void *finddevice(const char *name) 100static inline void *finddevice(const char *name)
100{ 101{