Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/legacy_serial: Support MVME5100 UARTS with shifted registers

This patch adds support to legacy serial for
UARTS with shifted registers.

The MVME5100 Single Board Computer is a PowerPC platform
that has 16550 style UARTS with register addresses that are
16 bytes apart (shifted by 4).

Commit 309257484cc1a592e8ac5fbdd8cd661be2b80bf8
"powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs"
added support to udbg_16550 for shifted registers by adding a "stride"
parameter to the initialisation operations for Programmed IO and
Memory Mapped IO.

As a consequence it is now possible to use the services of legacy serial
to provide early serial console messages for the MVME5100.

An added benefit of this is that the serial console will always be
"ttyS0" irrespective of whether the computer is fitted with extra
PCI 8250 interface boards or not.

I have tested this patch using the four PowerPC platforms available to me:

MVME5100 - shifted registers,
SAM440EP - unshifted registers,
MPC8349 - unshifted registers,
MVME4100 - unshifted registers.

Signed-off-by: Stephen Chivers <schivers@csc.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Stephen Chivers and committed by
Benjamin Herrenschmidt
13ae4037 147c0516

+16 -6
+15 -6
arch/powerpc/kernel/legacy_serial.c
··· 71 71 phys_addr_t taddr, unsigned long irq, 72 72 upf_t flags, int irq_check_parent) 73 73 { 74 - const __be32 *clk, *spd; 74 + const __be32 *clk, *spd, *rs; 75 75 u32 clock = BASE_BAUD * 16; 76 + u32 shift = 0; 76 77 int index; 77 78 78 79 /* get clock freq. if present */ ··· 83 82 84 83 /* get default speed if present */ 85 84 spd = of_get_property(np, "current-speed", NULL); 85 + 86 + /* get register shift if present */ 87 + rs = of_get_property(np, "reg-shift", NULL); 88 + if (rs && *rs) 89 + shift = be32_to_cpup(rs); 86 90 87 91 /* If we have a location index, then try to use it */ 88 92 if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS) ··· 132 126 legacy_serial_ports[index].uartclk = clock; 133 127 legacy_serial_ports[index].irq = irq; 134 128 legacy_serial_ports[index].flags = flags; 129 + legacy_serial_ports[index].regshift = shift; 135 130 legacy_serial_infos[index].taddr = taddr; 136 131 legacy_serial_infos[index].np = of_node_get(np); 137 132 legacy_serial_infos[index].clock = clock; ··· 170 163 if (of_get_property(np, "clock-frequency", NULL) == NULL) 171 164 return -1; 172 165 173 - /* if reg-shift or offset, don't try to use it */ 174 - if ((of_get_property(np, "reg-shift", NULL) != NULL) || 175 - (of_get_property(np, "reg-offset", NULL) != NULL)) 166 + /* if reg-offset don't try to use it */ 167 + if ((of_get_property(np, "reg-offset", NULL) != NULL)) 176 168 return -1; 177 169 178 170 /* if rtas uses this device, don't try to use it as well */ ··· 321 315 struct legacy_serial_info *info = &legacy_serial_infos[console]; 322 316 struct plat_serial8250_port *port = &legacy_serial_ports[console]; 323 317 void __iomem *addr; 318 + unsigned int stride; 319 + 320 + stride = 1 << port->regshift; 324 321 325 322 /* Check if a translated MMIO address has been found */ 326 323 if (info->taddr) { 327 324 addr = ioremap(info->taddr, 0x1000); 328 325 if (addr == NULL) 329 326 return; 330 - udbg_uart_init_mmio(addr, 1); 327 + udbg_uart_init_mmio(addr, stride); 331 328 } else { 332 329 /* Check if it's PIO and we support untranslated PIO */ 333 330 if (port->iotype == UPIO_PORT && isa_io_special) 334 - udbg_uart_init_pio(port->iobase, 1); 331 + udbg_uart_init_pio(port->iobase, stride); 335 332 else 336 333 return; 337 334 }
+1
arch/powerpc/platforms/embedded6xx/Kconfig
··· 65 65 select PPC_INDIRECT_PCI 66 66 select PPC_I8259 67 67 select PPC_NATIVE 68 + select PPC_UDBG_16550 68 69 help 69 70 This option enables support for the Motorola (now Emerson) MVME5100 70 71 board.