aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2010-10-01 03:06:07 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-10-07 19:21:15 -0400
commitf14362d1fe81cece6f1d78483e5bbfcf8cc497bf (patch)
treef7acfafcc2560c111783ae2db7c624ae621b62c0 /arch/powerpc
parent2548558445b43c1f18a61c0bd3629f92dffa612e (diff)
powerpc, of_serial: Endianness issues setting up the serial ports
The speed and clock of the serial ports is retrieved from the device tree in both the PowerPC legacy serial code and the Open Firmware serial driver, therefore they need to handle the fact that the device tree is always big endian, while the CPU may not be. Also fix other device tree references in the legacy serial code. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/legacy_serial.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index c1fd0f9658fd..c834757bebc0 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
52 phys_addr_t taddr, unsigned long irq, 52 phys_addr_t taddr, unsigned long irq,
53 upf_t flags, int irq_check_parent) 53 upf_t flags, int irq_check_parent)
54{ 54{
55 const u32 *clk, *spd; 55 const __be32 *clk, *spd;
56 u32 clock = BASE_BAUD * 16; 56 u32 clock = BASE_BAUD * 16;
57 int index; 57 int index;
58 58
59 /* get clock freq. if present */ 59 /* get clock freq. if present */
60 clk = of_get_property(np, "clock-frequency", NULL); 60 clk = of_get_property(np, "clock-frequency", NULL);
61 if (clk && *clk) 61 if (clk && *clk)
62 clock = *clk; 62 clock = be32_to_cpup(clk);
63 63
64 /* get default speed if present */ 64 /* get default speed if present */
65 spd = of_get_property(np, "current-speed", NULL); 65 spd = of_get_property(np, "current-speed", NULL);
@@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
109 legacy_serial_infos[index].taddr = taddr; 109 legacy_serial_infos[index].taddr = taddr;
110 legacy_serial_infos[index].np = of_node_get(np); 110 legacy_serial_infos[index].np = of_node_get(np);
111 legacy_serial_infos[index].clock = clock; 111 legacy_serial_infos[index].clock = clock;
112 legacy_serial_infos[index].speed = spd ? *spd : 0; 112 legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
113 legacy_serial_infos[index].irq_check_parent = irq_check_parent; 113 legacy_serial_infos[index].irq_check_parent = irq_check_parent;
114 114
115 printk(KERN_DEBUG "Found legacy serial port %d for %s\n", 115 printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
@@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
168static int __init add_legacy_isa_port(struct device_node *np, 168static int __init add_legacy_isa_port(struct device_node *np,
169 struct device_node *isa_brg) 169 struct device_node *isa_brg)
170{ 170{
171 const u32 *reg; 171 const __be32 *reg;
172 const char *typep; 172 const char *typep;
173 int index = -1; 173 int index = -1;
174 u64 taddr; 174 u64 taddr;
@@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
181 return -1; 181 return -1;
182 182
183 /* Verify it's an IO port, we don't support anything else */ 183 /* Verify it's an IO port, we don't support anything else */
184 if (!(reg[0] & 0x00000001)) 184 if (!(be32_to_cpu(reg[0]) & 0x00000001))
185 return -1; 185 return -1;
186 186
187 /* Now look for an "ibm,aix-loc" property that gives us ordering 187 /* Now look for an "ibm,aix-loc" property that gives us ordering
@@ -202,7 +202,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
202 taddr = 0; 202 taddr = 0;
203 203
204 /* Add port, irq will be dealt with later */ 204 /* Add port, irq will be dealt with later */
205 return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr, 205 return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
206 NO_IRQ, UPF_BOOT_AUTOCONF, 0); 206 NO_IRQ, UPF_BOOT_AUTOCONF, 0);
207 207
208} 208}
@@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
251 * we get to their "reg" property 251 * we get to their "reg" property
252 */ 252 */
253 if (np != pci_dev) { 253 if (np != pci_dev) {
254 const u32 *reg = of_get_property(np, "reg", NULL); 254 const __be32 *reg = of_get_property(np, "reg", NULL);
255 if (reg && (*reg < 4)) 255 if (reg && (be32_to_cpup(reg) < 4))
256 index = lindex = *reg; 256 index = lindex = be32_to_cpup(reg);
257 } 257 }
258 258
259 /* Local index means it's the Nth port in the PCI chip. Unfortunately 259 /* Local index means it's the Nth port in the PCI chip. Unfortunately
@@ -507,7 +507,7 @@ static int __init check_legacy_serial_console(void)
507 struct device_node *prom_stdout = NULL; 507 struct device_node *prom_stdout = NULL;
508 int i, speed = 0, offset = 0; 508 int i, speed = 0, offset = 0;
509 const char *name; 509 const char *name;
510 const u32 *spd; 510 const __be32 *spd;
511 511
512 DBG(" -> check_legacy_serial_console()\n"); 512 DBG(" -> check_legacy_serial_console()\n");
513 513
@@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
547 } 547 }
548 spd = of_get_property(prom_stdout, "current-speed", NULL); 548 spd = of_get_property(prom_stdout, "current-speed", NULL);
549 if (spd) 549 if (spd)
550 speed = *spd; 550 speed = be32_to_cpup(spd);
551 551
552 if (strcmp(name, "serial") != 0) 552 if (strcmp(name, "serial") != 0)
553 goto not_found; 553 goto not_found;