| From 861cb580245b6d19b116575e828849373d86d159 Mon Sep 17 00:00:00 2001 |
| From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> |
| Date: Wed, 11 Jan 2017 16:43:40 +0200 |
| Subject: [PATCH 226/255] serial: sh-sci: Compute the regshift value for SCI |
| ports |
| |
| SCI instances found in SH SoCs have different spacing between registers |
| depending on the SoC. The platform data contains a regshift field that |
| tells the driver by how many bits to shift the register offset to |
| compute its address. We can compute the regshift value automatically |
| based on the memory resource size, there's no need to pass the value |
| through platform data. |
| |
| Fix the sh7750 SCI and sh7760 SIM port memory resources length to ensure |
| proper computation of the regshift value. |
| |
| Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> |
| Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| (cherry picked from commit dfc80387aefb78161f83732804c6d01c89c24595) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| |
| Conflicts: |
| arch/sh/kernel/cpu/sh4/setup-sh7760.c |
| --- |
| arch/sh/kernel/cpu/sh3/setup-sh770x.c | 1 - |
| arch/sh/kernel/cpu/sh4/setup-sh7750.c | 3 +-- |
| arch/sh/kernel/cpu/sh4/setup-sh7760.c | 10 ++++++++-- |
| drivers/tty/serial/sh-sci.c | 8 +++++++- |
| include/linux/serial_sci.h | 1 - |
| 5 files changed, 16 insertions(+), 7 deletions(-) |
| |
| --- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c |
| +++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c |
| @@ -113,7 +113,6 @@ static struct plat_sci_port scif0_platfo |
| .scscr = SCSCR_TE | SCSCR_RE, |
| .type = PORT_SCI, |
| .ops = &sh770x_sci_port_ops, |
| - .regshift = 1, |
| }; |
| |
| static struct resource scif0_resources[] = { |
| --- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c |
| +++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c |
| @@ -41,11 +41,10 @@ static struct plat_sci_port sci_platform |
| .flags = UPF_BOOT_AUTOCONF, |
| .scscr = SCSCR_TE | SCSCR_RE, |
| .type = PORT_SCI, |
| - .regshift = 2, |
| }; |
| |
| static struct resource sci_resources[] = { |
| - DEFINE_RES_MEM(0xffe00000, 0x100), |
| + DEFINE_RES_MEM(0xffe00000, 0x20), |
| DEFINE_RES_IRQ(evt2irq(0x4e0)), |
| }; |
| |
| --- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c |
| +++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c |
| @@ -205,12 +205,18 @@ static struct platform_device scif2_devi |
| static struct plat_sci_port scif3_platform_data = { |
| .flags = UPF_BOOT_AUTOCONF, |
| .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE, |
| + /* |
| + * This is actually a SIM card module serial port, based on an SCI with |
| + * additional registers. The sh-sci driver doesn't support the SIM port |
| + * type, declare it as a SCI. Don't declare the additional registers in |
| + * the memory resource or the driver will compute an incorrect regshift |
| + * value. |
| + */ |
| .type = PORT_SCI, |
| - .regshift = 2, |
| }; |
| |
| static struct resource scif3_resources[] = { |
| - DEFINE_RES_MEM(0xfe480000, 0x100), |
| + DEFINE_RES_MEM(0xfe480000, 0x10), |
| DEFINE_RES_IRQ(evt2irq(0xc00)), |
| DEFINE_RES_IRQ(evt2irq(0xc20)), |
| DEFINE_RES_IRQ(evt2irq(0xc40)), |
| --- a/drivers/tty/serial/sh-sci.c |
| +++ b/drivers/tty/serial/sh-sci.c |
| @@ -2594,9 +2594,15 @@ static int sci_init_single(struct platfo |
| |
| port->type = p->type; |
| port->flags = UPF_FIXED_PORT | UPF_BOOT_AUTOCONF | p->flags; |
| - port->regshift = p->regshift; |
| port->fifosize = sci_port->params->fifosize; |
| |
| + if (port->type == PORT_SCI) { |
| + if (sci_port->reg_size >= 0x20) |
| + port->regshift = 2; |
| + else |
| + port->regshift = 1; |
| + } |
| + |
| /* |
| * The UART port needs an IRQ value, so we peg this to the RX IRQ |
| * for the multi-IRQ ports, which is where we are primarily |
| --- a/include/linux/serial_sci.h |
| +++ b/include/linux/serial_sci.h |
| @@ -56,7 +56,6 @@ struct plat_sci_port { |
| /* |
| * Platform overrides if necessary, defaults otherwise. |
| */ |
| - unsigned char regshift; |
| unsigned char regtype; |
| |
| struct plat_sci_port_ops *ops; |