serial: 8250: 8250_dw changes and dmaengine support
Subsystems (4)
v3 cover serial: 8250: 8250_dw changes and dmaengine support
Changes since v2:
- ACPI support for 8250_dw.c
- dmaengine API support for 8250
It looks like there are a few UART drivers that are more or less identical with 8250.c except they include DMA support, so if we had DMA support in 8250.c there may be no need for them. Since dmaengine is now supported on most platforms, I decided to suggest this solution.
I tried to make the DMA support as simple as I could. Single transfers with single descriptors. This should be sufficient in most cases.
Heikki Krogerus (8):
serial: 8250: Allow drivers to deliver capabilities
serial: 8250_dw: Don't use UPF_FIXED_TYPE
serial: 8250_dw: Map IO memory
serial: 8250_dw: Move device tree code to separate function
serial: 8250_dw: Set FIFO size dynamically
serial: 8250_dw: Add ACPI 5.0 support
serial: 8250: Add support for dmaengine
serial: 8250_dw: Enable DMA support with ACPI
drivers/tty/serial/8250/8250.c | 53 ++++++-- drivers/tty/serial/8250/8250.h | 50 ++++++++ drivers/tty/serial/8250/8250_dma.c | 213 +++++++++++++++++++++++++++++++ drivers/tty/serial/8250/8250_dw.c | 248 ++++++++++++++++++++++++++++++------ drivers/tty/serial/8250/Kconfig | 10 +- drivers/tty/serial/8250/Makefile | 1 + include/linux/serial_8250.h | 4 + 7 files changed, 532 insertions(+), 47 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_dma.c
Signature · 1 line
1.7.10.4
PATCH v3 1/8 serial: 8250: Allow drivers to deliver capabilities
Modern UARTs are able to provide information about their capabilities such as FIFO size. This allows the drivers to deliver this information to 8250.c when they are registering ports.
--- drivers/tty/serial/8250/8250.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/tty/serial/8250/8250.c +16 -6
@@ -1980,9 +1980,12 @@ static int serial8250_startup(struct uart_port *port)if (port->type ==PORT_8250_CIR )return -ENODEV ; - port->fifosize = uart_config[up->port.type].fifo_size; - up->tx_loadsz = uart_config[up->port.type].tx_loadsz; - up->capabilities = uart_config[up->port.type].flags; +if (!port->fifosize) + port->fifosize = uart_config[port->type].fifo_size; +if (!up->tx_loadsz) + up->tx_loadsz = uart_config[port->type].tx_loadsz; +if (!up->capabilities) + up->capabilities = uart_config[port->type].flags; up->mcr =0 ;if (port->iotype != up->cur_iotype)
@@ -2815,9 +2818,12 @@ static void serial8250_init_fixed_type_port(struct uart_8250_port *up, unsigned int type) { up->port.type = type; - up->port.fifosize = uart_config[type].fifo_size; - up->capabilities = uart_config[type].flags; - up->tx_loadsz = uart_config[type].tx_loadsz; +if (!up->port.fifosize) + up->port.fifosize = uart_config[type].fifo_size; +if (!up->tx_loadsz) + up->tx_loadsz = uart_config[type].tx_loadsz; +if (!up->capabilities) + up->capabilities = uart_config[type].flags; } static void __init
@@ -3251,6 +3257,10 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->bugs = up->bugs; uart->port.mapbase = up->port.mapbase; uart->port.private_data = up->port.private_data; + uart->port.fifosize = up->port.fifosize; + uart->tx_loadsz = up->tx_loadsz; + uart->capabilities = up->capabilities; +if (up->port.dev) uart->port.dev = up->port.dev;
Signature · 1 line
1.7.10.4
PATCH v3 2/8 serial: 8250_dw: Don't use UPF_FIXED_TYPE
In reply to Heikki KrogerusAllow 8250.c to determine the port type for us. This allows the driver take advantage of FIFO on Designware UARTs that have it.
--- drivers/tty/serial/8250/8250_dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_dw.c +1 -1
@@ -112,7 +112,7 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.handle_irq = dw8250_handle_irq; uart.port.type =PORT_8250 ; uart.port.flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP | -UPF_FIXED_PORT |UPF_FIXED_TYPE ; +UPF_FIXED_PORT ; uart.port.dev = &pdev->dev; uart.port.iotype =UPIO_MEM ;
Signature · 1 line
1.7.10.4
PATCH v3 3/8 serial: 8250_dw: Map IO memory
In reply to Heikki KrogerusThis needs to be done in order to later access the Designware specific registers.
--- drivers/tty/serial/8250/8250_dw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_dw.c +5 -2
@@ -111,10 +111,13 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.irq = irq->start; uart.port.handle_irq = dw8250_handle_irq; uart.port.type =PORT_8250 ; - uart.port.flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_IOREMAP | -UPF_FIXED_PORT ; + uart.port.flags =UPF_SHARE_IRQ |UPF_BOOT_AUTOCONF |UPF_FIXED_PORT ; uart.port.dev = &pdev->dev; + uart.port.membase =ioremap (regs->start,resource_size (regs)); +if (!uart.port.membase) +return -ENOMEM ; + uart.port.iotype =UPIO_MEM ; uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out;
Signature · 1 line
1.7.10.4
PATCH v3 4/8 serial: 8250_dw: Move device tree code to separate function
In reply to Heikki KrogerusTrivial cleanup. This makes it easier to add different methods to enumerate the device, for example ACPI 5.0 enumeration.
--- drivers/tty/serial/8250/8250_dw.c | 78 ++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 31 deletions(-)
drivers/tty/serial/8250/8250_dw.c +47 -31
@@ -87,25 +87,51 @@ static int dw8250_handle_irq(struct uart_port *p)return 0 ; } +static int dw8250_probe_of (struct uart_port *p) +{ +struct device_node *np = p->dev->of_node; +u32 val; + +if (!of_property_read_u32 (np,"reg-io-width" , &val)) { +switch (val) { +case 1 : +break ; +case 4 : + p->iotype =UPIO_MEM32 ; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; +break ; +default : +dev_err (p->dev,"unsupported reg-io-width (%u)\n" , val); +return -EINVAL ; + } + } + +if (!of_property_read_u32 (np,"reg-shift" , &val)) + p->regshift = val; + +if (of_property_read_u32 (np,"clock-frequency" , &val)) { +dev_err (p->dev,"no clock-frequency property set\n" ); +return -EINVAL ; + } + p->uartclk = val; + +return 0 ; +} +static int dw8250_probe (struct platform_device *pdev) {struct uart_8250_port uart = {};struct resource *regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 );struct resource *irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -struct device_node *np = pdev->dev.of_node; -u32 val;struct dw8250_data *data; +int err;if (!regs || !irq) {dev_err (&pdev->dev,"no registers/irq defined\n" );return -EINVAL ; } - data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL ); -if (!data) -return -ENOMEM ; - uart.port.private_data = data; -spin_lock_init (&uart.port.lock); uart.port.mapbase = regs->start; uart.port.irq = irq->start;
@@ -121,30 +147,20 @@ static int dw8250_probe(struct platform_device *pdev) uart.port.iotype =UPIO_MEM ; uart.port.serial_in = dw8250_serial_in; uart.port.serial_out = dw8250_serial_out; -if (!of_property_read_u32 (np,"reg-io-width" , &val)) { -switch (val) { -case 1 : -break ; -case 4 : - uart.port.iotype =UPIO_MEM32 ; - uart.port.serial_in = dw8250_serial_in32; - uart.port.serial_out = dw8250_serial_out32; -break ; -default : -dev_err (&pdev->dev,"unsupported reg-io-width (%u)\n" , - val); -return -EINVAL ; - } + +if (pdev->dev.of_node) { + err =dw8250_probe_of (&uart.port); +if (err) +return err; + }else { +return -ENODEV ; } -if (!of_property_read_u32 (np,"reg-shift" , &val)) - uart.port.regshift = val; + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; -if (of_property_read_u32 (np,"clock-frequency" , &val)) { -dev_err (&pdev->dev,"no clock-frequency property set\n" ); -return -EINVAL ; - } - uart.port.uartclk = val; + uart.port.private_data = data; data->line =serial8250_register_8250_port (&uart);if (data->line <0 )
@@ -187,17 +203,17 @@ static int dw8250_resume(struct platform_device *pdev)#define dw8250_resume NULL#endif /* CONFIG_PM */ -static const struct of_device_id dw8250_match[] = { +static const struct of_device_id dw8250_of_match[] = { { .compatible ="snps,dw-apb-uart" }, {/* Sentinel */ } }; -MODULE_DEVICE_TABLE (of, dw8250_match); +MODULE_DEVICE_TABLE (of, dw8250_of_match);static struct platform_driver dw8250_platform_driver = { .driver = { .name ="dw-apb-uart" , .owner =THIS_MODULE , - .of_match_table = dw8250_match, + .of_match_table = dw8250_of_match, }, .probe = dw8250_probe, .remove = dw8250_remove,
Signature · 1 line
1.7.10.4
PATCH v3 5/8 serial: 8250_dw: Set FIFO size dynamically
In reply to Heikki KrogerusDesignware UART provides optional Component Parameter Register that lists most of the capabilities of the UART, including FIFO size. This uses that register to set FIFO size for the port before registering it.
--- drivers/tty/serial/8250/8250_dw.c | 57 ++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_dw.c +53 -4
@@ -25,6 +25,28 @@#include <linux/platform_device.h> #include <linux/slab.h> +/* Offsets for the DesignWare specific registers */ +#define DW_UART_USR 0x1f/* UART Status Register */ +#define DW_UART_CPR 0xf4/* Component Parameter Register */ +#define DW_UART_UCV 0xf8/* UART Component Version */ + +/* Component Parameter Register bits */ +#define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) +#define DW_UART_CPR_AFCE_MODE (1 << 4) +#define DW_UART_CPR_THRE_MODE (1 << 5) +#define DW_UART_CPR_SIR_MODE (1 << 6) +#define DW_UART_CPR_SIR_LP_MODE (1 << 7) +#define DW_UART_CPR_ADDITIONAL_FEATURES (1 << 8) +#define DW_UART_CPR_FIFO_ACCESS (1 << 9) +#define DW_UART_CPR_FIFO_STAT (1 << 10) +#define DW_UART_CPR_SHADOW (1 << 11) +#define DW_UART_CPR_ENCODED_PARMS (1 << 12) +#define DW_UART_CPR_DMA_EXTRA (1 << 13) +#define DW_UART_CPR_FIFO_MODE (0xff << 16) +/* Helper for fifo size calculation */ +#define DW_UART_CPR_FIFO_SIZE (a) (((a >> 16) & 0xff) * 16) + +struct dw8250_data {int last_lcr;int line;
@@ -66,9 +88,6 @@ static unsigned int dw8250_serial_in32(struct uart_port *p, int offset)return readl (p->membase + offset); } -/* Offset for the DesignWare's UART Status Register. */ -#define UART_USR 0x1f -static int dw8250_handle_irq (struct uart_port *p) {struct dw8250_data *d = p->private_data;
@@ -78,7 +97,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,UART_USR ); + (void )p->serial_in (p,DW_UART_USR ); p->serial_out (p, d->last_lcr,UART_LCR );return 1 ;
@@ -119,6 +138,34 @@ static int dw8250_probe_of(struct uart_port *p)return 0 ; } +static void dw8250_setup_port (struct uart_8250_port *up) +{ +struct uart_port *p = &up->port; +u32 reg =readl (p->membase +DW_UART_UCV ); + +/* +* If the Component Version Register returns zero, we know that +* ADDITIONAL_FEATURES are not enabled. No need to go any further. +*/ +if (!reg) +return ; + +dev_dbg_ratelimited (p->dev,"Designware UART version %c.%c%c\n" , + (reg >>24 ) &0xff , (reg >>16 ) &0xff , (reg >>8 ) &0xff ); + + reg =readl (p->membase +DW_UART_CPR ); +if (!reg) +return ; + +/* Select the type based on fifo */ +if (reg &DW_UART_CPR_FIFO_MODE ) { + p->type =PORT_16550A ; + p->flags |=UPF_FIXED_TYPE ; + p->fifosize =DW_UART_CPR_FIFO_SIZE (reg); + up->tx_loadsz = p->fifosize; + } +} +static int dw8250_probe (struct platform_device *pdev) {struct uart_8250_port uart = {};
@@ -156,6 +203,8 @@ static int dw8250_probe(struct platform_device *pdev)return -ENODEV ; } +dw8250_setup_port (&uart); + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;
Signature · 1 line
1.7.10.4
PATCH v3 6/8 serial: 8250_dw: Add ACPI 5.0 support
In reply to Heikki KrogerusThis adds support for ACPI 5.0 enumerated Designware UARTs. ACPI does not deliver information about uart clk, so delivering it with the driver_data.
--- drivers/tty/serial/8250/8250_dw.c | 41 +++++++++++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_dw.c +41 -0
@@ -2,6 +2,7 @@* Synopsys DesignWare 8250 driver. * * Copyright 2011 Picochip, Jamie Iles. +* Copyright 2013 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -24,12 +25,16 @@#include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/slab.h> +#include <linux/acpi.h> /* Offsets for the DesignWare specific registers */ #define DW_UART_USR 0x1f/* UART Status Register */ #define DW_UART_CPR 0xf4/* Component Parameter Register */ #define DW_UART_UCV 0xf8/* UART Component Version */ +/* Intel Low Power Subsystem specific */ +#define LPSS_PRV_CLOCK_PARAMS 0x800 +/* Component Parameter Register bits */ #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0)#define DW_UART_CPR_AFCE_MODE (1 << 4)
@@ -138,6 +143,30 @@ static int dw8250_probe_of(struct uart_port *p)return 0 ; } +static int dw8250_probe_acpi (struct uart_port *p) +{ +const struct acpi_device_id *id; +u32 reg; + + id =acpi_match_device (p->dev->driver->acpi_match_table, p->dev); +if (!id) +return -ENODEV ; + + p->iotype =UPIO_MEM32 ; + p->serial_in = dw8250_serial_in32; + p->serial_out = dw8250_serial_out32; + p->regshift =2 ; + p->uartclk = (unsigned int )id->driver_data; + +/* Fix Haswell issue where the clocks do not get enabled */ +if (!strcmp (id->id,"INT33C4" ) || !strcmp (id->id,"INT33C5" )) { + reg =readl (p->membase +LPSS_PRV_CLOCK_PARAMS ); +writel (reg |1 , p->membase +LPSS_PRV_CLOCK_PARAMS ); + } + +return 0 ; +} +static void dw8250_setup_port (struct uart_8250_port *up) {struct uart_port *p = &up->port;
@@ -199,6 +228,10 @@ static int dw8250_probe(struct platform_device *pdev) err =dw8250_probe_of (&uart.port);if (err)return err; + }else if (ACPI_HANDLE (&pdev->dev)) { + err =dw8250_probe_acpi (&uart.port); +if (err) +return err; }else {return -ENODEV ; }
@@ -258,11 +291,19 @@ static const struct of_device_id dw8250_of_match[] = { };MODULE_DEVICE_TABLE (of, dw8250_of_match); +static const struct acpi_device_id dw8250_acpi_match[] = { + {"INT33C4" ,100000000 }, + {"INT33C5" ,100000000 }, + { }, +}; +MODULE_DEVICE_TABLE (acpi, dw8250_acpi_match); +static struct platform_driver dw8250_platform_driver = { .driver = { .name ="dw-apb-uart" , .owner =THIS_MODULE , .of_match_table = dw8250_of_match, + .acpi_match_table =ACPI_PTR (dw8250_acpi_match), }, .probe = dw8250_probe, .remove = dw8250_remove,
drivers/tty/serial/8250/Kconfig +1 -1
@@ -265,7 +265,7 @@ config SERIAL_8250_FSL config SERIAL_8250_DW tristate "Support for Synopsys DesignWare 8250 quirks" - depends on SERIAL_8250 && OF + depends on SERIAL_8250 help Selecting this option will enable handling of the extra features present in the Synopsys DesignWare APB UART.
Signature · 1 line
1.7.10.4
PATCH v3 7/8 serial: 8250: Add support for dmaengine
In reply to Heikki KrogerusAdd support for dmaengine API. The drivers can implement the struct uart_8250_dma member in struct uart_8250_port and 8250.c can take care of the rest.
--- drivers/tty/serial/8250/8250.c | 31 +++++- drivers/tty/serial/8250/8250.h | 50 +++++++++ drivers/tty/serial/8250/8250_dma.c | 213 ++++++++++++++++++++++++++++++++++++ drivers/tty/serial/8250/Kconfig | 8 ++ drivers/tty/serial/8250/Makefile | 1 + include/linux/serial_8250.h | 4 + 6 files changed, 304 insertions(+), 3 deletions(-) create mode 100644 drivers/tty/serial/8250/8250_dma.c
drivers/tty/serial/8250/8250.c +28 -3
@@ -1335,7 +1335,9 @@ static void serial8250_start_tx(struct uart_port *port)struct uart_8250_port *up = container_of(port, struct uart_8250_port, port); -if (!(up->ier &UART_IER_THRI )) { +if (up->dma && !serial8250_tx_dma (up)) { +return ; + }else if (!(up->ier &UART_IER_THRI )) { up->ier |=UART_IER_THRI ;serial_port_out (port,UART_IER , up->ier);
@@ -1536,6 +1538,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)unsigned long flags;struct uart_8250_port *up = container_of(port, struct uart_8250_port, port); +int dma_err =0 ;if (iir &UART_IIR_NO_INT )return 0 ;
@@ -1546,8 +1549,13 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)DEBUG_INTR ("status = %x..." , status); -if (status & (UART_LSR_DR |UART_LSR_BI )) - status =serial8250_rx_chars (up, status); +if (status & (UART_LSR_DR |UART_LSR_BI )) { +if (up->dma) + dma_err =serial8250_rx_dma (up, iir); + +if (!up->dma || dma_err) + status =serial8250_rx_chars (up, status); + }serial8250_modem_status (up);if (status &UART_LSR_THRE )serial8250_tx_chars (up);
@@ -2190,6 +2198,18 @@ dont_test_tx_en: up->msr_saved_flags =0 ;/* +* Request DMA channels for both RX and TX. +*/ +if (up->dma) { + retval =serial8250_request_dma (up); +if (retval) { +pr_warn_ratelimited ("ttyS%d - failed to request DMA\n" , +serial_index (port)); + up->dma =NULL ; + } + } + +/* * Finally, enable interrupts. Note: Modem status interrupts * are set via set_termios(), which will be occurring imminently * anyway, so we don't enable them here.
@@ -2222,6 +2242,9 @@ static void serial8250_shutdown(struct uart_port *port) up->ier =0 ;serial_port_out (port,UART_IER ,0 ); +if (up->dma) +serial8250_release_dma (up); +spin_lock_irqsave (&port->lock, flags);if (port->flags &UPF_FOURPORT ) {/* reset interrupts on the AST Fourport board */
@@ -3286,6 +3309,8 @@ int serial8250_register_8250_port(struct uart_8250_port *up) uart->dl_read = up->dl_read;if (up->dl_write) uart->dl_write = up->dl_write; +if (up->dma) + uart->dma = up->dma;if (serial8250_isa_config !=NULL ) serial8250_isa_config(0, &uart->port,
drivers/tty/serial/8250/8250.h +50 -0
59 lines not on this page · raw message
drivers/tty/serial/8250/8250_dma.c new file +213 -0
213 lines not on this page · raw message
drivers/tty/serial/8250/Kconfig +8 -0
@@ -84,6 +84,14 @@ config SERIAL_8250_GSC depends on SERIAL_8250 && GSC default SERIAL_8250 +config SERIAL_8250_DMA + bool "DMA support for 16550 compatible UART controllers" if EXPERT + depends on SERIAL_8250 && DMADEVICES=y + default SERIAL_8250 + help + This builds DMA support that can be used with 8250/16650 + compatible UART controllers that support DMA signaling. + config SERIAL_8250_PCI tristate "8250/16550 PCI device support" if EXPERT depends on SERIAL_8250 && PCI
drivers/tty/serial/8250/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_SERIAL_8250) += 8250_core.o 8250_core-y := 8250.o 8250_core-$(CONFIG_SERIAL_8250_PNP) += 8250_pnp.o +8250_core-$(CONFIG_SERIAL_8250_DMA) += 8250_dma.o obj-$(CONFIG_SERIAL_8250_GSC) += 8250_gsc.o obj-$(CONFIG_SERIAL_8250_PCI) += 8250_pci.o obj-$(CONFIG_SERIAL_8250_HP300) += 8250_hp300.o
include/linux/serial_8250.h +4 -0
@@ -59,6 +59,8 @@ enum { PLAT8250_DEV_SM501, }; +struct uart_8250_dma ; +/* * This should be used by drivers which want to register * their own 8250 ports without registering their own
@@ -91,6 +93,8 @@ struct uart_8250_port {#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTAunsigned char msr_saved_flags; +struct uart_8250_dma *dma; +/* 8250 specific callbacks */ int (*dl_read)(struct uart_8250_port *);void (*dl_write)(struct uart_8250_port *,int );
Signature · 1 line
1.7.10.4
PATCH v3 8/8 serial: 8250_dw: Enable DMA support with ACPI
In reply to Heikki KrogerusWith ACPI 5.0 we can use the FixedDMA Resource Descriptor to extract the needed information for DMA support.
--- drivers/tty/serial/8250/8250_dw.c | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
drivers/tty/serial/8250/8250_dw.c +65 -0
@@ -27,6 +27,8 @@#include <linux/slab.h> #include <linux/acpi.h> +#include "8250.h" +/* Offsets for the DesignWare specific registers */ #define DW_UART_USR 0x1f/* UART Status Register */ #define DW_UART_CPR 0xf4/* Component Parameter Register */
@@ -143,9 +145,64 @@ static int dw8250_probe_of(struct uart_port *p)return 0 ; } +static bool dw8250_acpi_dma_filter (struct dma_chan *chan,void *parm) +{ +return chan->chan_id == *(int *)parm; +} + +static acpi_status +dw8250_acpi_walk_resource (struct acpi_resource *res,void *data) +{ +struct uart_port *p = data; +struct uart_8250_port *port; +struct uart_8250_dma *dma; +struct acpi_resource_fixed_dma *fixed_dma; +struct dma_slave_config *slave; + + port = container_of(p, struct uart_8250_port, port); + +switch (res->type) { +case ACPI_RESOURCE_TYPE_FIXED_DMA : + fixed_dma = &res->data.fixed_dma; + +/* TX comes first */ +if (!port->dma) { + dma =devm_kzalloc (p->dev,sizeof (*dma),GFP_KERNEL ); +if (!dma) +return AE_NO_MEMORY ; + + port->dma = dma; + slave = &dma->txconf; + + slave->direction =DMA_MEM_TO_DEV ; + slave->dst_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ; + slave->slave_id = fixed_dma->request_lines; + + dma->tx_chan_id = fixed_dma->channels; + dma->tx_param = &dma->tx_chan_id; + dma->fn = dw8250_acpi_dma_filter; + }else { + dma = port->dma; + slave = &dma->rxconf; + + slave->direction =DMA_DEV_TO_MEM ; + slave->src_addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ; + slave->slave_id = fixed_dma->request_lines; + + dma->rx_chan_id = fixed_dma->channels; + dma->rx_param = &dma->rx_chan_id; + } + +break ; + } + +return AE_OK ; +} +static int dw8250_probe_acpi (struct uart_port *p) {const struct acpi_device_id *id; +acpi_status status;u32 reg; id =acpi_match_device (p->dev->driver->acpi_match_table, p->dev);
@@ -158,6 +215,14 @@ static int dw8250_probe_acpi(struct uart_port *p) p->regshift =2 ; p->uartclk = (unsigned int )id->driver_data; + status =acpi_walk_resources (ACPI_HANDLE (p->dev),METHOD_NAME__CRS , + dw8250_acpi_walk_resource, p); +if (ACPI_FAILURE (status)) { +dev_err_ratelimited (p->dev,"%s failed \"%s\"\n" , __func__, +acpi_format_exception (status)); +return -ENODEV ; + } +/* Fix Haswell issue where the clocks do not get enabled */ if (!strcmp (id->id,"INT33C4" ) || !strcmp (id->id,"INT33C5" )) { reg =readl (p->membase +LPSS_PRV_CLOCK_PARAMS );
Signature · 1 line
1.7.10.4