MIPS/tty/8250: Use standard 8250 drivers for OCTEON
Subsystems (4)
cover MIPS/tty/8250: Use standard 8250 drivers for OCTEON
From: David Daney <[email protected]>
Get rid of the custom OCTEON UART probe code and use 8250_dw instead.
The first patch just gets rid of Ralf's Kconfig workarounds for the real problem, which is OCTEON's inclomplete serial support.
Then we just make minor patches to 8250_dw, and rip out all this OCTEON code.
Since the patches are all interdependent, we might want to merge them via a single tree (perhaps Ralf's MIPS tree).
David Daney (5):
Revert "MIPS: Octeon: Fix build error if CONFIG_SERIAL_8250=n"
MIPS: OCTEON: Set proper UART clock in internal device trees. tty/8250_dw: Add support for OCTEON UARTS.
MIPS: OCTEON: Remove custom serial setup code.
MIPS: Update cavium_octeon_defconfig
arch/mips/cavium-octeon/Makefile | 1 - arch/mips/cavium-octeon/octeon-platform.c | 9 ++- arch/mips/cavium-octeon/serial.c | 109 ------------------------------ arch/mips/configs/cavium_octeon_defconfig | 4 +- drivers/tty/serial/8250/8250_dw.c | 45 ++++++++++-- 5 files changed, 48 insertions(+), 120 deletions(-) delete mode 100644 arch/mips/cavium-octeon/serial.c
Signature · 1 line
1.7.11.7
PATCH 1/5 Revert "MIPS: Octeon: Fix build error if CONFIG_SERIAL_8250=n"
From: David Daney <[email protected]>
This reverts commit fc0fcde2ea9740944acf6134d2c84983d1297bc1.
--- arch/mips/cavium-octeon/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/mips/cavium-octeon/Makefile +1 -2
@@ -12,13 +12,12 @@ CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt -obj-y := cpu.o setup.o octeon-platform.o octeon-irq.o csrc-octeon.o +obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o obj-y += dma-octeon.o obj-y += octeon-memcpy.o obj-y += executive/ obj-$(CONFIG_MTD) += flash_setup.o -obj-$(CONFIG_SERIAL_8250) += serial.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_OCTEON_ILM) += oct_ilm.o
Signature · 1 line
1.7.11.7
PATCH 2/5 MIPS: OCTEON: Set proper UART clock in internal device trees.
In reply to David DaneyFrom: David Daney <[email protected]>
Following patch to use generic 8250 drivers will need proper clock information. So when using the internal device tree, populate the "clock-frequency" property with the correct value.
--- arch/mips/cavium-octeon/octeon-platform.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/mips/cavium-octeon/octeon-platform.c +8 -1
@@ -490,8 +490,15 @@ int __init octeon_prune_device_tree(void)if (alias_prop) { uart =fdt_path_offset (initial_boot_params, alias_prop); -if (uart_mask & (1 << i)) +if (uart_mask & (1 << i)) { +__be32 f; + + f =cpu_to_be32 (octeon_get_io_clock_rate ()); +fdt_setprop_inplace (initial_boot_params, + uart,"clock-frequency" , + &f,sizeof (f));continue ; + }pr_debug ("Deleting uart%d\n" , i);fdt_nop_node (initial_boot_params, uart); fdt_nop_property(initial_boot_params, aliases,
Signature · 1 line
1.7.11.7
PATCH 3/5 tty/8250_dw: Add support for OCTEON UARTS.
In reply to David DaneyFrom: David Daney <[email protected]>
A few differences needed by OCTEON:
o These are DWC UARTS, but have USR at a different offset.
o OCTEON must have 64-bit wide register accesses, so we have OCTEON specific register accessors.
o No UCV register, so we hard code some properties.
--- drivers/tty/serial/8250/8250_dw.c | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250_dw.c +39 -6
@@ -57,8 +57,30 @@ struct dw8250_data {int last_lcr;int line;struct clk *clk; +u8 usr_reg; +bool no_ucv; }; +static unsigned int dw8250_serial_inq (struct uart_port *p,int offset) +{ + offset <<= p->regshift; + +return (u8 )__raw_readq (p->membase + offset); +} + +static void dw8250_serial_outq (struct uart_port *p,int offset,int value) +{ +struct dw8250_data *d = p->private_data; + +if (offset ==UART_LCR ) + d->last_lcr = value; + + offset <<= p->regshift; +__raw_writeq (value, p->membase + offset); +dw8250_serial_inq (p,UART_LCR ); +} + +static void dw8250_serial_out (struct uart_port *p,int offset,int value) {struct dw8250_data *d = p->private_data;
@@ -104,7 +126,7 @@ static int dw8250_handle_irq(struct uart_port *p)return 1 ; }else if ((iir &UART_IIR_BUSY ) ==UART_IIR_BUSY ) {/* Clear the USR and write the LCR again. */ - (void )p->serial_in (p,DW_UART_USR ); + (void )p->serial_in (p, d->usr_reg); p->serial_out (p,UART_LCR , d->last_lcr);return 1 ;
@@ -125,12 +147,20 @@ dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)pm_runtime_put_sync_suspend (port->dev); } -static int dw8250_probe_of (struct uart_port *p) +static int dw8250_probe_of (struct uart_port *p, +struct dw8250_data *data) {struct device_node *np = p->dev->of_node;u32 val; -if (!of_property_read_u32 (np,"reg-io-width" , &val)) { +if (of_device_is_compatible (np,"cavium,octeon-3860-uart" )) { + p->serial_in = dw8250_serial_inq; + p->serial_out = dw8250_serial_outq; + p->flags =ASYNC_SKIP_TEST |UPF_SHARE_IRQ |UPF_FIXED_TYPE ; + p->type =PORT_OCTEON ; + data->usr_reg =0x27 ; + data->no_ucv = true; + }else if (!of_property_read_u32 (np,"reg-io-width" , &val)) {switch (val) {case 1 :break ;
@@ -259,6 +289,7 @@ static int dw8250_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; + data->usr_reg =DW_UART_USR ; data->clk =devm_clk_get (&pdev->dev,NULL );if (!IS_ERR (data->clk)) {clk_prepare_enable (data->clk);
@@ -270,10 +301,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_out = dw8250_serial_out; uart.port.private_data = data; -dw8250_setup_port (&uart); -if (pdev->dev.of_node) { - err =dw8250_probe_of (&uart.port); + err =dw8250_probe_of (&uart.port, data);if (err)return err; }else if (ACPI_HANDLE (&pdev->dev)) {
@@ -284,6 +313,9 @@ static int dw8250_probe(struct platform_device *pdev)return -ENODEV ; } +if (!data->no_ucv) +dw8250_setup_port (&uart); + data->line =serial8250_register_8250_port (&uart);if (data->line <0 )return data->line;
@@ -362,6 +394,7 @@ static const struct dev_pm_ops dw8250_pm_ops = {static const struct of_device_id dw8250_of_match[] = { { .compatible ="snps,dw-apb-uart" }, + { .compatible ="cavium,octeon-3860-uart" }, {/* Sentinel */ } };MODULE_DEVICE_TABLE (of, dw8250_of_match);
Signature · 1 line
1.7.11.7
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
Quoted 9 lines · David Daney
From: David Daney <[email protected]>
A few differences needed by OCTEON:
o These are DWC UARTS, but have USR at a different offset.
o OCTEON must have 64-bit wide register accesses, so we have OCTEON specific register accessors.
Quoted 6 lines
o No UCV register, so we hard code some properties.
Signed-off-by David Daney <[email protected]>--- drivers/tty/serial/8250/8250_dw.c | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-)
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
In reply to David DaneyQuoted 8 lines · On Tuesday 18 June 2013 12:12:53 David Daney wrote:
drivers/tty/serial/8250/8250_dw.c +8
-0+static unsigned int dw8250_serial_inq (struct uart_port *p,int offset) +{ + offset <<= p->regshift; + +return (u8 )__raw_readq (p->membase + offset); +} + +static void dw8250_serial_outq (struct uart_port *p,int offset,int value)
drivers/tty/serial/8250/8250_dw.c struct dw8250_data { · line 81
Quoted 10 lines
drivers/tty/serial/8250/8250_dw.c +10
-0+{ +struct dw8250_data *d = p->private_data; + +if (offset ==UART_LCR ) + d->last_lcr = value; + + offset <<= p->regshift; +__raw_writeq (value, p->membase + offset); +dw8250_serial_inq (p,UART_LCR ); +}
This breaks building on 32 bit architectures as I found on my daily ARM
builds: __raw_writeq cannot be defined on architectures that don't have native 64 bit data access instructions. It's also wrong to use the __raw_* variant, which is not guaranteed to be atomic and is not endian-safe.
Arnd
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
Quoted 5 lines · Arnd Bergmann
This breaks building on 32 bit architectures as I found on my daily ARM
builds:__raw_writeqcannot be defined on architectures that don't have native 64 bit data access instructions. It's also wrong to use the __raw_* variant, which is not guaranteed to be atomic and is not endian-safe.
I've dequeued the series from the mips-next tree until David has a chance to fix this.
Ralf
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
In reply to Arnd BergmannQuoted 15 lines · Arnd Bergmann
Quoted 14 lines · On Tuesday 18 June 2013 12:12:53 David Daney wrote:
drivers/tty/serial/8250/8250_dw.c +14
-0+static unsigned int dw8250_serial_inq (struct uart_port *p,int offset) +{ + offset <<= p->regshift; + +return (u8 )__raw_readq (p->membase + offset); +} + +static void dw8250_serial_outq (struct uart_port *p,int offset,int value) +{ +struct dw8250_data *d = p->private_data; + +if (offset ==UART_LCR ) + d->last_lcr = value; +
Quoted 8 lines
drivers/tty/serial/8250/8250_dw.c struct dw8250_data { · line 81
Quoted 4 lines
drivers/tty/serial/8250/8250_dw.c +4
-0+ offset <<= p->regshift; +__raw_writeq (value, p->membase + offset); +dw8250_serial_inq (p,UART_LCR ); +}This breaks building on 32 bit architectures as I found on my daily ARM
builds:__raw_writeqcannot be defined on architectures that don't have native 64 bit data access instructions.
I will rework the patch to avoid this problem.
Quoted 3 lines
It's also wrong to use the
__raw_* variant, which is not guaranteed to be atomic and is not endian-safe.
We do runtime probing and only use this function on platforms where it is appropriate, so atomicity is not an issue. As for endianess, I used the __raw_ variant precisely because it is correct for both big and little endian kernels.
David Daney
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
Quoted 10 lines · David Daney
Quoted 3 lines · Arnd Bergmann
It's also wrong to use the
__raw_* variant, which is not guaranteed to be atomic and is not endian-safe.We do runtime probing and only use this function on platforms where it is appropriate, so atomicity is not an issue. As for endianess, I used the
__raw_variant precisely because it is correct for both big and little endian kernels.
You don't know what the compiler turns a __raw_writeq into, it could always to eight byte wise stores, that's why typically writeq is an inline assembly while __raw_writeq is just a pointer dereference.
__raw_* never do endian swaps, so it will be wrong on either big-endian CPUs or on little-endian CPUs, depending on what the MMIO register needs.
Arnd
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · David Daney
Quoted 3 lines · Arnd Bergmann
It's also wrong to use the
__raw_* variant, which is not guaranteed to be atomic and is not endian-safe.
Quoted 8 lines
Quoted 4 lines
We do runtime probing and only use this function on platforms where it is appropriate, so atomicity is not an issue. As for endianess, I used the
__raw_variant precisely because it is correct for both big and little endian kernels.You don't know what the compiler turns a
__raw_writeqinto, it could always to eight byte wise stores, that's why typically writeq is an inline assembly while__raw_writeqis just a pointer dereference.
Well, I do know that for the cases of interest, it will be a single load or store, but it is moot, as I rewrote that part.
Quoted 2 lines
__raw_* never do endian swaps,
Yes, I know that.
Quoted 3 lines
so it will be wrong on either big-endian
CPUs or on little-endian CPUs, depending on what the MMIO register needs.
Please see the instruction set reference manual (MD00087-2B-MIPS64BIS-AFP-03.51 or similar) available at:
http://www.mips.com/products/architectures/mips64/#specifications
... for why you are mistaken. Pay particular attention to the low order address bit scrambling on narrow loads and stores and how this results in uniform (not affected by processor endian mode) load and store results for aligned 64-bit accesses. In effect, it is magic, and __raw_writeq yields correct results in both big and little endian modes of operation.
David Daney.
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
In reply to David DaneyQuoted 10 lines · David Daney
A few differences needed by OCTEON:
o These are DWC UARTS, but have USR at a different offset.
o OCTEON must have 64-bit wide register accesses, so we have OCTEON specific register accessors.
o No UCV register, so we hard code some properties.
Signed-off-by David Daney <[email protected]>
<snip>
Quoted 13 lines
drivers/tty/serial/8250/8250_dw.c +1
-3@@ -270,10 +301,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_out = dw8250_serial_out; uart.port.private_data = data; -dw8250_setup_port (&uart); -if (pdev->dev.of_node) { - err =dw8250_probe_of (&uart.port); + err =dw8250_probe_of (&uart.port, data);if (err)return err; }else if (ACPI_HANDLE (&pdev->dev)) {
drivers/tty/serial/8250/8250_dw.c static int dw8250_probe(struct platform_device *pdev) · line 317
Quoted 5 lines
drivers/tty/serial/8250/8250_dw.c +2
-0@@ -284,6 +313,9 @@ static int dw8250_probe(struct platform_device *pdev)return -ENODEV ; } +if (!data->no_ucv) +dw8250_setup_port (&uart);
Moving the dw8250_setup_port() call here breaks dw8250_probe_acpi(). It expects values from the CPR register for the DMA burst size calculation.
The DMA support can be moved to a separate function. This way it can be called after this point, and it will then be available for both DT and ACPI. I can make a patch tomorrow. That should solve this issue.
Thanks,
Signature · 1 line
heikki
Re: [PATCH 3/5] tty/8250_dw: Add support for OCTEON UARTS.
Quoted 36 lines · Heikki Krogerus
Quoted 10 lines · David Daney
A few differences needed by OCTEON:
o These are DWC UARTS, but have USR at a different offset.
o OCTEON must have 64-bit wide register accesses, so we have OCTEON specific register accessors.
o No UCV register, so we hard code some properties.
Signed-off-by David Daney <[email protected]><snip>
Quoted 13 lines
drivers/tty/serial/8250/8250_dw.c +1
-3@@ -270,10 +301,8 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.serial_out = dw8250_serial_out; uart.port.private_data = data; -dw8250_setup_port (&uart); -if (pdev->dev.of_node) { - err =dw8250_probe_of (&uart.port); + err =dw8250_probe_of (&uart.port, data);if (err)return err; }else if (ACPI_HANDLE (&pdev->dev)) {drivers/tty/serial/8250/8250_dw.c static int dw8250_probe(struct platform_device *pdev) · line 317
Quoted 5 lines
drivers/tty/serial/8250/8250_dw.c +2
-0@@ -284,6 +313,9 @@ static int dw8250_probe(struct platform_device *pdev)return -ENODEV ; } +if (!data->no_ucv) +dw8250_setup_port (&uart);Moving the
dw8250_setup_port()call here breaksdw8250_probe_acpi(). It expects values from the CPR register for the DMA burst size calculation.
Quoted 4 lines
The DMA support can be moved to a separate function. This way it can be called after this point, and it will then be available for both DT and ACPI. I can make a patch tomorrow. That should solve this issue.
I am reworking the patch because other problems were found. I will try to get this part right in the next version.
David Daney
PATCH 4/5 MIPS: OCTEON: Remove custom serial setup code.
In reply to David DaneyFrom: David Daney <[email protected]>
We will use 8250_dw instead.
--- arch/mips/cavium-octeon/Makefile | 2 +- arch/mips/cavium-octeon/serial.c | 109 --------------------------------------- 2 files changed, 1 insertion(+), 110 deletions(-) delete mode 100644 arch/mips/cavium-octeon/serial.c
arch/mips/cavium-octeon/Makefile +1 -1
@@ -12,7 +12,7 @@ CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt -obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o +obj-y := cpu.o setup.o octeon-platform.o octeon-irq.o csrc-octeon.o obj-y += dma-octeon.o obj-y += octeon-memcpy.o obj-y += executive/
arch/mips/cavium-octeon/serial.c deleted +0 -109
109 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 5/5 MIPS: Update cavium_octeon_defconfig
In reply to David DaneyFrom: David Daney <[email protected]>
The serial port changes make it advisable to enable the proper UART drivers.
--- arch/mips/configs/cavium_octeon_defconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/mips/configs/cavium_octeon_defconfig +1 -3
@@ -1,13 +1,11 @@ CONFIG_CAVIUM_OCTEON_SOC=y CONFIG_CAVIUM_CN63XXP1=y CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE=2 -CONFIG_SPARSEMEM_MANUAL=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_SMP=y CONFIG_NR_CPUS=32 CONFIG_HZ_100=y CONFIG_PREEMPT=y -CONFIG_EXPERIMENTAL=y CONFIG_SYSVIPC=y CONFIG_POSIX_MQUEUE=y CONFIG_BSD_PROCESS_ACCT=y
@@ -50,7 +48,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" # CONFIG_FW_LOADER is not set CONFIG_MTD=y # CONFIG_MTD_OF_PARTS is not set -CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_AMDSTD=y
@@ -114,6 +111,7 @@ CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_NR_UARTS=2 CONFIG_SERIAL_8250_RUNTIME_UARTS=2 +CONFIG_SERIAL_8250_DW=y # CONFIG_HW_RANDOM is not set CONFIG_I2C=y CONFIG_I2C_OCTEON=y
Signature · 1 line
1.7.11.7
Greg Kroah-Hartman
maintainerQuoted 4 lines · David Daney
From: David Daney <[email protected]>
Get rid of the custom OCTEON UART probe code and use 8250_dw instead.
Quoted 8 lines
The first patch just gets rid of Ralf's
Kconfigworkarounds for the real problem, which is OCTEON's inclomplete serial support.Then we just make minor patches to 8250_dw, and rip out all this OCTEON code.
Since the patches are all interdependent, we might want to merge them via a single tree (perhaps Ralf's MIPS tree).
That's fine with me, I've acked the tty driver changes so feel free to take all of these through the mips tree.
thanks,
greg k-h
Quoted 4 lines · David Daney
From: David Daney <[email protected]>
Get rid of the custom OCTEON UART probe code and use 8250_dw instead.
Quoted 8 lines
The first patch just gets rid of Ralf's
Kconfigworkarounds for the real problem, which is OCTEON's inclomplete serial support.Then we just make minor patches to 8250_dw, and rip out all this OCTEON code.
Since the patches are all interdependent, we might want to merge them via a single tree (perhaps Ralf's MIPS tree).
Looks good - I was trying to come up with a kludge good enough for 3.10; this may be a bit too large ...
Ralf
Quoted 9 lines · Ralf Baechle
Quoted 7 lines · David Daney
From: David Daney <[email protected]>
Get rid of the custom OCTEON UART probe code and use 8250_dw instead.
The first patch just gets rid of Ralf's
Kconfigworkarounds for the real problem, which is OCTEON's inclomplete serial support.
Quoted 9 lines
Quoted 5 lines
Then we just make minor patches to 8250_dw, and rip out all this OCTEON code.
Since the patches are all interdependent, we might want to merge them via a single tree (perhaps Ralf's MIPS tree).
Looks good - I was trying to come up with a kludge good enough for 3.10; this may be a bit too large ...
At this point I think it is fine if some random configs for OCTEON fail to build in v3.10.
I was thinking that this would be for 3.11
David Daney
Quoted 4 lines · David Daney
From: David Daney <[email protected]>
Get rid of the custom OCTEON UART probe code and use 8250_dw instead.
Quoted 8 lines
The first patch just gets rid of Ralf's
Kconfigworkarounds for the real problem, which is OCTEON's inclomplete serial support.Then we just make minor patches to 8250_dw, and rip out all this OCTEON code.
Since the patches are all interdependent, we might want to merge them via a single tree (perhaps Ralf's MIPS tree).
Looks good!
for the series.
Thanks,
Jamie