From 878fbb91399df0d37e0183890b0ad6aeb63590fe Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 6 Dec 2013 10:59:51 +0100 Subject: serial: sh-sci: Remove platform data scbrr_algo_id field The field isn't set by any board, remote it. Signed-off-by: Laurent Pinchart Acked-by: Greg Kroah-Hartman Signed-off-by: Simon Horman --- drivers/tty/serial/sh-sci.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'drivers/tty') diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e4bf0e435af6..96d26d7f8031 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1757,17 +1757,6 @@ static unsigned int sci_scbrr_calc(struct sci_port *s, unsigned int bps, if (s->sampling_rate) return DIV_ROUND_CLOSEST(freq, s->sampling_rate * bps) - 1; - switch (s->cfg->scbrr_algo_id) { - case SCBRR_ALGO_1: - return freq / (16 * bps); - case SCBRR_ALGO_2: - return DIV_ROUND_CLOSEST(freq, 32 * bps) - 1; - case SCBRR_ALGO_3: - return freq / (8 * bps); - case SCBRR_ALGO_4: - return DIV_ROUND_CLOSEST(freq, 16 * bps) - 1; - } - /* Warn, but use a safe default */ WARN_ON(1); @@ -2176,17 +2165,12 @@ static int sci_init_single(struct platform_device *dev, break; } - /* Set the sampling rate if the baud rate calculation algorithm isn't - * specified. + /* SCIFA on sh7723 and sh7724 need a custom sampling rate that doesn't + * match the SoC datasheet, this should be investigated. Let platform + * data override the sampling rate for now. */ - if (p->scbrr_algo_id == SCBRR_ALGO_NONE) { - /* SCIFA on sh7723 and sh7724 need a custom sampling rate that - * doesn't match the SoC datasheet, this should be investigated. - * Let platform data override the sampling rate for now. - */ - sci_port->sampling_rate = p->sampling_rate ? p->sampling_rate - : sampling_rate; - } + sci_port->sampling_rate = p->sampling_rate ? p->sampling_rate + : sampling_rate; if (!early) { sci_port->iclk = clk_get(&dev->dev, "sci_ick"); -- cgit v1.2.3 From 89b5c1ab94a1cea921d8a280de0a483d71af5091 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 6 Dec 2013 10:59:52 +0100 Subject: serial: sh-sci: Remove platform data mapbase and irqs fields The fields are not used anymore by board files, remove them. Signed-off-by: Laurent Pinchart Acked-by: Greg Kroah-Hartman Signed-off-by: Simon Horman --- drivers/tty/serial/sh-sci.c | 60 +++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'drivers/tty') diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 96d26d7f8031..c4111162ec5e 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -58,6 +58,23 @@ #include "sh-sci.h" +/* Offsets into the sci_port->irqs array */ +enum { + SCIx_ERI_IRQ, + SCIx_RXI_IRQ, + SCIx_TXI_IRQ, + SCIx_BRI_IRQ, + SCIx_NR_IRQS, + + SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */ +}; + +#define SCIx_IRQ_IS_MUXED(port) \ + ((port)->irqs[SCIx_ERI_IRQ] == \ + (port)->irqs[SCIx_RXI_IRQ]) || \ + ((port)->irqs[SCIx_ERI_IRQ] && \ + ((port)->irqs[SCIx_RXI_IRQ] < 0)) + struct sci_port { struct uart_port port; @@ -2094,36 +2111,27 @@ static int sci_init_single(struct platform_device *dev, port->iotype = UPIO_MEM; port->line = index; - if (dev->num_resources) { - /* Device has resources, use them. */ - res = platform_get_resource(dev, IORESOURCE_MEM, 0); - if (res == NULL) - return -ENOMEM; + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + if (res == NULL) + return -ENOMEM; - port->mapbase = res->start; + port->mapbase = res->start; - for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i) - sci_port->irqs[i] = platform_get_irq(dev, i); + for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i) + sci_port->irqs[i] = platform_get_irq(dev, i); - /* The SCI generates several interrupts. They can be muxed - * together or connected to different interrupt lines. In the - * muxed case only one interrupt resource is specified. In the - * non-muxed case three or four interrupt resources are - * specified, as the BRI interrupt is optional. - */ - if (sci_port->irqs[0] < 0) - return -ENXIO; + /* The SCI generates several interrupts. They can be muxed together or + * connected to different interrupt lines. In the muxed case only one + * interrupt resource is specified. In the non-muxed case three or four + * interrupt resources are specified, as the BRI interrupt is optional. + */ + if (sci_port->irqs[0] < 0) + return -ENXIO; - if (sci_port->irqs[1] < 0) { - sci_port->irqs[1] = sci_port->irqs[0]; - sci_port->irqs[2] = sci_port->irqs[0]; - sci_port->irqs[3] = sci_port->irqs[0]; - } - } else { - /* No resources, use old-style platform data. */ - port->mapbase = p->mapbase; - for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i) - sci_port->irqs[i] = p->irqs[i] ? p->irqs[i] : -ENXIO; + if (sci_port->irqs[1] < 0) { + sci_port->irqs[1] = sci_port->irqs[0]; + sci_port->irqs[2] = sci_port->irqs[0]; + sci_port->irqs[3] = sci_port->irqs[0]; } if (p->regtype == SCIx_PROBE_REGTYPE) { -- cgit v1.2.3 From 20bdcab8268cb05702e12ae9013be96ecc7ec3a6 Mon Sep 17 00:00:00 2001 From: Bastian Hecht Date: Fri, 6 Dec 2013 10:59:54 +0100 Subject: serial: sh-sci: Add OF support Extend the driver to with support for SCIx device tree bindings. A minimal set of features is supported, additional properties can be added later should the need to describe more device features arise. Signed-off-by: Bastian Hecht Signed-off-by: Laurent Pinchart Acked-by: Simon Horman Acked-by: Greg Kroah-Hartman Signed-off-by: Simon Horman --- drivers/tty/serial/sh-sci.c | 101 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 3 deletions(-) (limited to 'drivers/tty') diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index c4111162ec5e..be33d2b0613b 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -2415,6 +2416,83 @@ static int sci_remove(struct platform_device *dev) return 0; } +struct sci_port_info { + unsigned int type; + unsigned int regtype; +}; + +static const struct of_device_id of_sci_match[] = { + { + .compatible = "renesas,scif", + .data = (void *)&(const struct sci_port_info) { + .type = PORT_SCIF, + .regtype = SCIx_SH4_SCIF_REGTYPE, + }, + }, { + .compatible = "renesas,scifa", + .data = (void *)&(const struct sci_port_info) { + .type = PORT_SCIFA, + .regtype = SCIx_SCIFA_REGTYPE, + }, + }, { + .compatible = "renesas,scifb", + .data = (void *)&(const struct sci_port_info) { + .type = PORT_SCIFB, + .regtype = SCIx_SCIFB_REGTYPE, + }, + }, { + .compatible = "renesas,hscif", + .data = (void *)&(const struct sci_port_info) { + .type = PORT_HSCIF, + .regtype = SCIx_HSCIF_REGTYPE, + }, + }, { + /* Terminator */ + }, +}; +MODULE_DEVICE_TABLE(of, of_sci_match); + +static struct plat_sci_port * +sci_parse_dt(struct platform_device *pdev, unsigned int *dev_id) +{ + struct device_node *np = pdev->dev.of_node; + const struct of_device_id *match; + const struct sci_port_info *info; + struct plat_sci_port *p; + int id; + + if (!IS_ENABLED(CONFIG_OF) || !np) + return NULL; + + match = of_match_node(of_sci_match, pdev->dev.of_node); + if (!match) + return NULL; + + info = match->data; + + p = devm_kzalloc(&pdev->dev, sizeof(struct plat_sci_port), GFP_KERNEL); + if (!p) { + dev_err(&pdev->dev, "failed to allocate DT config data\n"); + return NULL; + } + + /* Get the line number for the aliases node. */ + id = of_alias_get_id(np, "serial"); + if (id < 0) { + dev_err(&pdev->dev, "failed to get alias id (%d)\n", id); + return NULL; + } + + *dev_id = id; + + p->flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF; + p->type = info->type; + p->regtype = info->regtype; + p->scscr = SCSCR_RE | SCSCR_TE; + + return p; +} + static int sci_probe_single(struct platform_device *dev, unsigned int index, struct plat_sci_port *p, @@ -2447,8 +2525,9 @@ static int sci_probe_single(struct platform_device *dev, static int sci_probe(struct platform_device *dev) { - struct plat_sci_port *p = dev_get_platdata(&dev->dev); - struct sci_port *sp = &sci_ports[dev->id]; + struct plat_sci_port *p; + struct sci_port *sp; + unsigned int dev_id; int ret; /* @@ -2459,9 +2538,24 @@ static int sci_probe(struct platform_device *dev) if (is_early_platform_device(dev)) return sci_probe_earlyprintk(dev); + if (dev->dev.of_node) { + p = sci_parse_dt(dev, &dev_id); + if (p == NULL) + return -EINVAL; + } else { + p = dev->dev.platform_data; + if (p == NULL) { + dev_err(&dev->dev, "no platform data supplied\n"); + return -EINVAL; + } + + dev_id = dev->id; + } + + sp = &sci_ports[dev_id]; platform_set_drvdata(dev, sp); - ret = sci_probe_single(dev, dev->id, p, sp); + ret = sci_probe_single(dev, dev_id, p, sp); if (ret) return ret; @@ -2513,6 +2607,7 @@ static struct platform_driver sci_driver = { .name = "sh-sci", .owner = THIS_MODULE, .pm = &sci_dev_pm_ops, + .of_match_table = of_match_ptr(of_sci_match), }, }; -- cgit v1.2.3 From c0f8a48723d1e7ec48f65c72f880bc49edea9a4a Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Mon, 30 Dec 2013 13:15:29 -0800 Subject: tty: serial: Limit msm_serial_hs driver to platforms that use it The msm_serial_hs driver uses mach specific dma APIs. This is not compatible with the multi-platform ARM effort. Let's only compile this driver on MSM devices that are prepared to support it; allowing the DT based MSM devices to enter the multi-platform ARM build. Acked-by: Greg Kroah-Hartman Signed-off-by: Stephen Boyd Signed-off-by: Olof Johansson --- drivers/tty/serial/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/tty') diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index a3817ab8602f..a53159cd62f9 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1035,7 +1035,7 @@ config SERIAL_MSM_CONSOLE config SERIAL_MSM_HS tristate "MSM UART High Speed: Serial Driver" - depends on ARCH_MSM + depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50 select SERIAL_CORE help If you have a machine based on MSM family of SoCs, you -- cgit v1.2.3