* [PATCH v3 08/10] gpio: exar: Refactor address and bit calculations
From: Jan Kiszka @ 2017-05-26 16:02 UTC (permalink / raw)
To: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot
Cc: Linux Kernel Mailing List, linux-serial, linux-gpio,
Sudip Mukherjee, Andy Shevchenko, Sascha Weisenberger
In-Reply-To: <cover.1495814557.git.jan.kiszka@siemens.com>
Make the address and bit calculation more friendly for introducing a
"first pin" offset later on. The new form is also more compact and
regular.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
drivers/gpio/gpio-exar.c | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index 1a629831d45b..d13bf20b8639 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -51,11 +51,11 @@ static void exar_update(struct gpio_chip *chip, unsigned int reg, int val,
static int exar_set_direction(struct gpio_chip *chip, int direction,
unsigned int offset)
{
- unsigned int bank = offset / 8;
- unsigned int addr;
+ unsigned int addr = offset / 8 ?
+ EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
+ unsigned int bit = offset % 8;
- addr = bank ? EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
- exar_update(chip, addr, direction, offset % 8);
+ exar_update(chip, addr, direction, bit);
return 0;
}
@@ -73,36 +73,30 @@ static int exar_get(struct gpio_chip *chip, unsigned int reg)
static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
{
- unsigned int bank = offset / 8;
- unsigned int addr;
- int val;
+ unsigned int addr = offset / 8 ?
+ EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
+ unsigned int bit = offset % 8;
- addr = bank ? EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
- val = exar_get(chip, addr) & BIT(offset % 8);
-
- return !!val;
+ return !!(exar_get(chip, addr) & BIT(bit));
}
static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
{
- unsigned int bank = offset / 8;
- unsigned int addr;
- int val;
-
- addr = bank ? EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
- val = exar_get(chip, addr) & BIT(offset % 8);
+ unsigned int addr = offset / 8 ?
+ EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
+ unsigned int bit = offset % 8;
- return !!val;
+ return !!(exar_get(chip, addr) & BIT(bit));
}
static void exar_set_value(struct gpio_chip *chip, unsigned int offset,
int value)
{
- unsigned int bank = offset / 8;
- unsigned int addr;
+ unsigned int addr = offset / 8 ?
+ EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
+ unsigned int bit = offset % 8;
- addr = bank ? EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
- exar_update(chip, addr, value, offset % 8);
+ exar_update(chip, addr, value, bit);
}
static int exar_direction_output(struct gpio_chip *chip, unsigned int offset,
--
2.12.0
^ permalink raw reply related
* [PATCH v3 09/10] gpio-exar/8250-exar: Make set of exported GPIOs configurable
From: Jan Kiszka @ 2017-05-26 16:02 UTC (permalink / raw)
To: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot
Cc: Linux Kernel Mailing List, linux-serial, linux-gpio,
Sudip Mukherjee, Andy Shevchenko, Sascha Weisenberger
In-Reply-To: <cover.1495814557.git.jan.kiszka@siemens.com>
On the SIMATIC, IOT2040 only a single pin is exportable as GPIO, the
rest is required to operate the UART. To allow modeling this case,
expand the platform device data structure to specify a (consecutive) pin
subset for exporting by the gpio-exar driver.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
drivers/gpio/gpio-exar.c | 29 ++++++++++++++++++++---------
drivers/tty/serial/8250/8250_exar.c | 14 +++++++++++---
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
index d13bf20b8639..8970f50e681e 100644
--- a/drivers/gpio/gpio-exar.c
+++ b/drivers/gpio/gpio-exar.c
@@ -31,6 +31,7 @@ struct exar_gpio_chip {
int index;
void __iomem *regs;
char name[20];
+ unsigned int first_pin;
};
static void exar_update(struct gpio_chip *chip, unsigned int reg, int val,
@@ -51,9 +52,10 @@ static void exar_update(struct gpio_chip *chip, unsigned int reg, int val,
static int exar_set_direction(struct gpio_chip *chip, int direction,
unsigned int offset)
{
- unsigned int addr = offset / 8 ?
+ struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip);
+ unsigned int addr = (offset + exar_gpio->first_pin) / 8 ?
EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
- unsigned int bit = offset % 8;
+ unsigned int bit = (offset + exar_gpio->first_pin) % 8;
exar_update(chip, addr, direction, bit);
return 0;
@@ -73,18 +75,20 @@ static int exar_get(struct gpio_chip *chip, unsigned int reg)
static int exar_get_direction(struct gpio_chip *chip, unsigned int offset)
{
- unsigned int addr = offset / 8 ?
+ struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip);
+ unsigned int addr = (offset + exar_gpio->first_pin) / 8 ?
EXAR_OFFSET_MPIOSEL_HI : EXAR_OFFSET_MPIOSEL_LO;
- unsigned int bit = offset % 8;
+ unsigned int bit = (offset + exar_gpio->first_pin) % 8;
return !!(exar_get(chip, addr) & BIT(bit));
}
static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
{
- unsigned int addr = offset / 8 ?
+ struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip);
+ unsigned int addr = (offset + exar_gpio->first_pin) / 8 ?
EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
- unsigned int bit = offset % 8;
+ unsigned int bit = (offset + exar_gpio->first_pin) % 8;
return !!(exar_get(chip, addr) & BIT(bit));
}
@@ -92,9 +96,10 @@ static int exar_get_value(struct gpio_chip *chip, unsigned int offset)
static void exar_set_value(struct gpio_chip *chip, unsigned int offset,
int value)
{
- unsigned int addr = offset / 8 ?
+ struct exar_gpio_chip *exar_gpio = gpiochip_get_data(chip);
+ unsigned int addr = (offset + exar_gpio->first_pin) / 8 ?
EXAR_OFFSET_MPIOLVL_HI : EXAR_OFFSET_MPIOLVL_LO;
- unsigned int bit = offset % 8;
+ unsigned int bit = (offset + exar_gpio->first_pin) % 8;
exar_update(chip, addr, value, bit);
}
@@ -115,6 +120,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
{
struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent);
struct exar_gpio_chip *exar_gpio;
+ u32 first_pin, npins;
void __iomem *p;
int index, ret;
@@ -126,6 +132,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
if (!p)
return -ENOMEM;
+ if (device_property_read_u32(&pdev->dev, "first_pin", &first_pin) < 0 ||
+ device_property_read_u32(&pdev->dev, "npins", &npins) < 0)
+ return -EINVAL;
+
exar_gpio = devm_kzalloc(&pdev->dev, sizeof(*exar_gpio), GFP_KERNEL);
if (!exar_gpio)
return -ENOMEM;
@@ -143,9 +153,10 @@ static int gpio_exar_probe(struct platform_device *pdev)
exar_gpio->gpio_chip.get = exar_get_value;
exar_gpio->gpio_chip.set = exar_set_value;
exar_gpio->gpio_chip.base = -1;
- exar_gpio->gpio_chip.ngpio = 16;
+ exar_gpio->gpio_chip.ngpio = npins;
exar_gpio->regs = p;
exar_gpio->index = index;
+ exar_gpio->first_pin = first_pin;
ret = devm_gpiochip_add_data(&pdev->dev,
&exar_gpio->gpio_chip, exar_gpio);
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index ee4b142f3ed0..42e7c5149c07 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -14,6 +14,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/property.h>
#include <linux/serial_core.h>
#include <linux/serial_reg.h>
#include <linux/slab.h>
@@ -196,8 +197,14 @@ static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
}
static void *
-xr17v35x_register_gpio(struct pci_dev *pcidev)
+xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
+ unsigned int npins)
{
+ struct property_entry properties[] = {
+ PROPERTY_ENTRY_U32("first_pin", first_pin),
+ PROPERTY_ENTRY_U32("npins", npins),
+ { }
+ };
struct platform_device *pdev;
pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO);
@@ -207,7 +214,8 @@ xr17v35x_register_gpio(struct pci_dev *pcidev)
pdev->dev.parent = &pcidev->dev;
ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev));
- if (platform_device_add(pdev) < 0) {
+ if (platform_device_add_properties(pdev, properties) < 0 ||
+ platform_device_add(pdev) < 0) {
platform_device_put(pdev);
return NULL;
}
@@ -250,7 +258,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
port->port.private_data =
- xr17v35x_register_gpio(pcidev);
+ xr17v35x_register_gpio(pcidev, 0, 16);
}
return 0;
--
2.12.0
^ permalink raw reply related
* [PATCH v3 10/10] serial: exar: Add support for IOT2040 device
From: Jan Kiszka @ 2017-05-26 16:02 UTC (permalink / raw)
To: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot
Cc: Linux Kernel Mailing List, linux-serial, linux-gpio,
Sudip Mukherjee, Andy Shevchenko, Sascha Weisenberger
In-Reply-To: <cover.1495814557.git.jan.kiszka@siemens.com>
This implements the setup of RS232 and the switch-over to RS485 or RS422
for the Siemens IOT2040. That uses an EXAR XR17V352 with external logic
to switch between the different modes. The external logic is controlled
via MPIO pins of the EXAR controller.
Only pin 10 can be exported as GPIO on the IOT2040. It is connected to
an LED.
As the XR17V352 used on the IOT2040 is not equipped with an external
EEPROM, it cannot present itself as IOT2040-variant via subvendor/
subdevice IDs. Thus, we have to check via DMI for the target platform.
Co-developed with Sascha Weisenberger.
Signed-off-by: Sascha Weisenberger <sascha.weisenberger@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
drivers/tty/serial/8250/8250_exar.c | 154 ++++++++++++++++++++++++++++++++++--
1 file changed, 148 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 42e7c5149c07..625284f96aba 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -10,6 +10,7 @@
* the Free Software Foundation; either version 2 of the License.
*/
#include <linux/acpi.h>
+#include <linux/dmi.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -62,8 +63,50 @@
#define UART_EXAR_MPIOSEL_15_8 0x99 /* MPIOSEL[15:8] */
#define UART_EXAR_MPIOOD_15_8 0x9a /* MPIOOD[15:8] */
+#define UART_EXAR_RS485_DLY(x) ((x) << 4)
+
+/*
+ * IOT2040 MPIO wiring semantics:
+ *
+ * MPIO Port Function
+ * ---- ---- --------
+ * 0 2 Mode bit 0
+ * 1 2 Mode bit 1
+ * 2 2 Terminate bus
+ * 3 - <reserved>
+ * 4 3 Mode bit 0
+ * 5 3 Mode bit 1
+ * 6 3 Terminate bus
+ * 7 - <reserved>
+ * 8 2 Enable
+ * 9 3 Enable
+ * 10 - Red LED
+ * 11..15 - <unused>
+ */
+
+/* IOT2040 MPIOs 0..7 */
+#define IOT2040_UART_MODE_RS232 0x01
+#define IOT2040_UART_MODE_RS485 0x02
+#define IOT2040_UART_MODE_RS422 0x03
+#define IOT2040_UART_TERMINATE_BUS 0x04
+
+#define IOT2040_UART1_MASK 0x0f
+#define IOT2040_UART2_SHIFT 4
+
+#define IOT2040_UARTS_DEFAULT_MODE 0x11 /* both RS232 */
+#define IOT2040_UARTS_GPIO_LO_MODE 0x88 /* reserved pins as input */
+
+/* IOT2040 MPIOs 8..15 */
+#define IOT2040_UARTS_ENABLE 0x03
+#define IOT2040_UARTS_GPIO_HI_MODE 0xF8 /* enable & LED as outputs */
+
struct exar8250;
+struct exar8250_platform {
+ int (*rs485_config)(struct uart_port *, struct serial_rs485 *);
+ int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
+};
+
/**
* struct exar8250_board - board information
* @num_ports: number of serial ports
@@ -197,8 +240,8 @@ static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p)
}
static void *
-xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
- unsigned int npins)
+__xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
+ unsigned int npins)
{
struct property_entry properties[] = {
PROPERTY_ENTRY_U32("first_pin", first_pin),
@@ -223,17 +266,118 @@ xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
return pdev;
}
+static int xr17v35x_register_gpio(struct pci_dev *pcidev,
+ struct uart_8250_port *port)
+{
+ if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
+ port->port.private_data =
+ __xr17v35x_register_gpio(pcidev, 0, 16);
+
+ return 0;
+}
+
+static int iot2040_rs485_config(struct uart_port *port,
+ struct serial_rs485 *rs485)
+{
+ bool is_rs485 = !!(rs485->flags & SER_RS485_ENABLED);
+ u8 __iomem *p = port->membase;
+ u8 mask = IOT2040_UART1_MASK;
+ u8 mode, value;
+
+ if (is_rs485) {
+ if (rs485->flags & SER_RS485_RX_DURING_TX)
+ mode = IOT2040_UART_MODE_RS422;
+ else
+ mode = IOT2040_UART_MODE_RS485;
+
+ if (rs485->flags & SER_RS485_TERMINATE_BUS)
+ mode |= IOT2040_UART_TERMINATE_BUS;
+ } else {
+ mode = IOT2040_UART_MODE_RS232;
+ }
+
+ if (port->line == 3) {
+ mask <<= IOT2040_UART2_SHIFT;
+ mode <<= IOT2040_UART2_SHIFT;
+ }
+
+ value = readb(p + UART_EXAR_MPIOLVL_7_0);
+ value &= ~mask;
+ value |= mode;
+ writeb(value, p + UART_EXAR_MPIOLVL_7_0);
+
+ value = readb(p + UART_EXAR_FCTR);
+ if (is_rs485)
+ value |= UART_FCTR_EXAR_485;
+ else
+ value &= ~UART_FCTR_EXAR_485;
+ writeb(value, p + UART_EXAR_FCTR);
+
+ if (is_rs485)
+ writeb(UART_EXAR_RS485_DLY(4), p + UART_MSR);
+
+ port->rs485 = *rs485;
+
+ return 0;
+}
+
+static int iot2040_register_gpio(struct pci_dev *pcidev,
+ struct uart_8250_port *port)
+{
+ u8 __iomem *p = port->port.membase;
+
+ writeb(IOT2040_UARTS_DEFAULT_MODE, p + UART_EXAR_MPIOLVL_7_0);
+ writeb(IOT2040_UARTS_GPIO_LO_MODE, p + UART_EXAR_MPIOSEL_7_0);
+ writeb(IOT2040_UARTS_ENABLE, p + UART_EXAR_MPIOLVL_15_8);
+ writeb(IOT2040_UARTS_GPIO_HI_MODE, p + UART_EXAR_MPIOSEL_15_8);
+
+ port->port.private_data = __xr17v35x_register_gpio(pcidev, 10, 1);
+
+ return 0;
+}
+
+static const struct exar8250_platform exar8250_default_platform = {
+ .register_gpio = xr17v35x_register_gpio,
+};
+
+static const struct exar8250_platform iot2040_platform = {
+ .rs485_config = iot2040_rs485_config,
+ .register_gpio = iot2040_register_gpio,
+};
+
+static const struct dmi_system_id exar_platforms[] = {
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_BOARD_NAME, "SIMATIC IOT2000"),
+ DMI_EXACT_MATCH(DMI_BOARD_ASSET_TAG,
+ "6ES7647-0AA00-1YA2"),
+ },
+ .driver_data = (void *)&iot2040_platform,
+ },
+ {}
+};
+
static int
pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
struct uart_8250_port *port, int idx)
{
const struct exar8250_board *board = priv->board;
+ const struct exar8250_platform *platform;
+ const struct dmi_system_id *dmi_match;
unsigned int offset = idx * 0x400;
unsigned int baud = 7812500;
u8 __iomem *p;
int ret;
+ dmi_match = dmi_first_match(exar_platforms);
+ if (dmi_match)
+ platform = dmi_match->driver_data;
+ else
+ platform = &exar8250_default_platform;
+
port->port.uartclk = baud * 16;
+ port->port.rs485_config = platform->rs485_config;
+
/*
* Setup the uart clock for the devices on expansion slot to
* half the clock speed of the main chip (which is 125MHz)
@@ -256,12 +400,10 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
/* Setup Multipurpose Input/Output pins. */
setup_gpio(pcidev, p);
- if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
- port->port.private_data =
- xr17v35x_register_gpio(pcidev, 0, 16);
+ ret = platform->register_gpio(pcidev, port);
}
- return 0;
+ return ret;
}
static void pci_xr17v35x_exit(struct pci_dev *pcidev)
--
2.12.0
^ permalink raw reply related
* Re: [PATCH 1/8] serial: exar: Preconfigure xr17v35x MPIOs as output
From: Greg Kroah-Hartman @ 2017-05-26 18:38 UTC (permalink / raw)
To: Jan Kiszka
Cc: Linus Walleij, Alexandre Courbot, Linux Kernel Mailing List,
linux-serial, linux-gpio, Sudip Mukherjee, Andy Shevchenko,
Sascha Weisenberger
In-Reply-To: <9bb8d972-6535-1611-8fa7-f5fe89760531@siemens.com>
On Fri, May 26, 2017 at 03:04:26PM +0200, Jan Kiszka wrote:
> Greg,
>
> On 2017-05-13 09:28, Jan Kiszka wrote:
> > This is the safe default for GPIOs with unknown external wiring.
> >
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> > ---
> > drivers/tty/serial/8250/8250_exar.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> > index 1270ff163f63..b4fa585156c7 100644
> > --- a/drivers/tty/serial/8250/8250_exar.c
> > +++ b/drivers/tty/serial/8250/8250_exar.c
> > @@ -177,13 +177,13 @@ static void setup_gpio(u8 __iomem *p)
> > writeb(0x00, p + UART_EXAR_MPIOLVL_7_0);
> > writeb(0x00, p + UART_EXAR_MPIO3T_7_0);
> > writeb(0x00, p + UART_EXAR_MPIOINV_7_0);
> > - writeb(0x00, p + UART_EXAR_MPIOSEL_7_0);
> > + writeb(0xff, p + UART_EXAR_MPIOSEL_7_0);
> > writeb(0x00, p + UART_EXAR_MPIOOD_7_0);
> > writeb(0x00, p + UART_EXAR_MPIOINT_15_8);
> > writeb(0x00, p + UART_EXAR_MPIOLVL_15_8);
> > writeb(0x00, p + UART_EXAR_MPIO3T_15_8);
> > writeb(0x00, p + UART_EXAR_MPIOINV_15_8);
> > - writeb(0x00, p + UART_EXAR_MPIOSEL_15_8);
> > + writeb(0xff, p + UART_EXAR_MPIOSEL_15_8);
> > writeb(0x00, p + UART_EXAR_MPIOOD_15_8);
> > }
> >
> >
>
> Please drop from this tty-next, it may break Commtech adapters. I have
> an update ready.
>
> I may also send a fix on top if that is preferred, just let me know.
I need a fixup patch, I can't drop a patch, only revert it.
thanks,
greg k-h
^ permalink raw reply
* [GIT PULL] TTY/Serial fixes for 4.12-rc3
From: Greg KH @ 2017-05-27 10:01 UTC (permalink / raw)
To: Linus Torvalds, Jiri Slaby
Cc: Stephen Rothwell, Andrew Morton, linux-kernel, linux-serial
The following changes since commit 2ea659a9ef488125eb46da6eb571de5eae5c43f6:
Linux 4.12-rc1 (2017-05-13 13:19:49 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git/ tags/tty-4.12-rc3
for you to fetch changes up to 59fe2cc8b1c32dd139da80fc8222b5b3290b7a09:
serial: altera_uart: call iounmap() at driver remove (2017-05-25 14:36:37 +0200)
----------------------------------------------------------------
TTY/Serial fixes for 4.12-rc3
Here are some serial and tty fixes for 4.12-rc3. They are a bit
"bigger" than normal, which is why I had them "bake" in linux-next for a
few weeks and didn't send them to you for -rc2.
They revert a few of the serdev patches from 4.12-rc1, and bring things
back to how they were in 4.11, to try to make things a bit more stable
there. Rob and Johan both agree that this is the way forward, so this
isn't people squabbling over semantics. Other than that, just a few
minor serial driver fixes that people have had problems with.
All of these have been in linux-next for a few weeks with no reported
issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
----------------------------------------------------------------
Alexey Khoroshilov (1):
serial: altera_jtaguart: adding iounmap()
Ard Biesheuvel (1):
drivers/tty: 8250: only call fintek_8250_probe when doing port I/O
Christophe JAILLET (1):
serial: efm32: Fix parity management in 'efm32_uart_console_get_options()'
Guilherme G. Piccoli (1):
MAINTAINERS/serial: Change maintainer of jsm driver
Jan Kiszka (1):
serial: exar: Fix stuck MSIs
Johan Hovold (6):
Revert "tty_port: register tty ports with serdev bus"
serdev: fix tty-port client deregistration
serial: ifx6x60: fix use-after-free on module unload
tty: ehv_bytechan: clean up init error handling
tty/serdev: add serdev registration interface
serial: enable serdev support
Lucas Stach (1):
serial: core: fix crash in uart_suspend_port
Stefan Wahren (1):
serdev: Restore serdev_device_write_buf for atomic context
Tobias Klauser (1):
serial: altera_uart: call iounmap() at driver remove
Uwe Kleine-König (1):
serial: imx: ensure UCR3 and UFCR are setup correctly
Vegard Nossum (1):
tty: fix port buffer locking
MAINTAINERS | 2 +-
drivers/tty/ehv_bytechan.c | 17 ++++----
drivers/tty/serdev/core.c | 12 ++++++
drivers/tty/serdev/serdev-ttyport.c | 21 ++++++----
drivers/tty/serial/8250/8250_port.c | 21 +++++-----
drivers/tty/serial/altera_jtaguart.c | 1 +
drivers/tty/serial/altera_uart.c | 1 +
drivers/tty/serial/efm32-uart.c | 11 ++++--
drivers/tty/serial/ifx6x60.c | 2 +-
drivers/tty/serial/imx.c | 14 ++++++-
drivers/tty/serial/serial_core.c | 6 +--
drivers/tty/tty_port.c | 75 +++++++++++++++++++++++++++++++++---
include/linux/serdev.h | 19 +++++----
include/linux/tty.h | 9 +++++
14 files changed, 162 insertions(+), 49 deletions(-)
^ permalink raw reply
* Re: [PATCH v3 02/10] gpio-exar/8250-exar: Do not even instantiate a GPIO device for Commtech cards
From: Andy Shevchenko @ 2017-05-27 13:40 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <096688442ac54d85b6a3e0577592bc2a6891569b.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Commtech adapters need the MPIOs for internal purposes, and the
> gpio-exar driver already refused to pick them up. But there is actually
> no point in even creating the underlying platform device.
FWIW:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> drivers/gpio/gpio-exar.c | 3 ---
> drivers/tty/serial/8250/8250_exar.c | 4 +++-
> 2 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index 081076771217..006a9a67c2a4 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -124,9 +124,6 @@ static int gpio_exar_probe(struct platform_device *pdev)
> void __iomem *p;
> int index, ret;
>
> - if (pcidev->vendor != PCI_VENDOR_ID_EXAR)
> - return -ENODEV;
> -
> /*
> * Map the pci device to get the register addresses.
> * We will need to read and write those registers to control
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 8984e8b2d524..c29c7e675890 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -245,7 +245,9 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
> /* Setup Multipurpose Input/Output pins. */
> setup_gpio(pcidev, p);
>
> - port->port.private_data = xr17v35x_register_gpio(pcidev);
> + if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
> + port->port.private_data =
> + xr17v35x_register_gpio(pcidev);
> }
>
> return 0;
> --
> 2.12.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 03/10] gpio-exar/8250-exar: Fix passing in of parent PCI device
From: Andy Shevchenko @ 2017-05-27 13:41 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <272048835491193427a32c442627be985eeba649.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> This fixes reloading of the GPIO driver for the same platform device
> instance as created by the exar UART driver: First of all, the driver
> sets drvdata to its own value during probing and does not restore the
> original value on exit. But this won't help anyway as the core clears
> drvdata after the driver left.
>
> Set the platform device parent instead.
Now this one looks much better than first efforts.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> drivers/gpio/gpio-exar.c | 2 +-
> drivers/tty/serial/8250/8250_exar.c | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index 006a9a67c2a4..da4550bb9939 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -119,7 +119,7 @@ static int exar_direction_input(struct gpio_chip *chip, unsigned int offset)
>
> static int gpio_exar_probe(struct platform_device *pdev)
> {
> - struct pci_dev *pcidev = platform_get_drvdata(pdev);
> + struct pci_dev *pcidev = to_pci_dev(pdev->dev.parent);
> struct exar_gpio_chip *exar_gpio;
> void __iomem *p;
> int index, ret;
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index c29c7e675890..0f4b236d7e68 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -203,7 +203,8 @@ xr17v35x_register_gpio(struct pci_dev *pcidev)
> if (!pdev)
> return NULL;
>
> - platform_set_drvdata(pdev, pcidev);
> + pdev->dev.parent = &pcidev->dev;
> +
> if (platform_device_add(pdev) < 0) {
> platform_device_put(pdev);
> return NULL;
> --
> 2.12.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 07/10] gpio-exar/8250-exar: Rearrange gpiochip parenthood
From: Andy Shevchenko @ 2017-05-27 13:43 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <375d76dc3fe344f5168e8155211422de59f0efa0.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Set the parent of the exar gpiochip to its platform device, like other
> gpiochips are doing it. In order to keep the relationship discoverable
> for ACPI systems, set the platform device companion to the PCI device.
>
Setting companion is a right thing to do (like it's done in other similar cases)
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> drivers/gpio/gpio-exar.c | 2 +-
> drivers/tty/serial/8250/8250_exar.c | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-exar.c b/drivers/gpio/gpio-exar.c
> index f3585a184f39..1a629831d45b 100644
> --- a/drivers/gpio/gpio-exar.c
> +++ b/drivers/gpio/gpio-exar.c
> @@ -142,7 +142,7 @@ static int gpio_exar_probe(struct platform_device *pdev)
>
> sprintf(exar_gpio->name, "exar_gpio%d", index);
> exar_gpio->gpio_chip.label = exar_gpio->name;
> - exar_gpio->gpio_chip.parent = &pcidev->dev;
> + exar_gpio->gpio_chip.parent = &pdev->dev;
> exar_gpio->gpio_chip.direction_output = exar_direction_output;
> exar_gpio->gpio_chip.direction_input = exar_direction_input;
> exar_gpio->gpio_chip.get_direction = exar_get_direction;
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 0f4b236d7e68..ee4b142f3ed0 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -9,6 +9,7 @@
> * it under the terms of the GNU General Public License as published by
> * the Free Software Foundation; either version 2 of the License.
> */
> +#include <linux/acpi.h>
> #include <linux/io.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> @@ -204,6 +205,7 @@ xr17v35x_register_gpio(struct pci_dev *pcidev)
> return NULL;
>
> pdev->dev.parent = &pcidev->dev;
> + ACPI_COMPANION_SET(&pdev->dev, ACPI_COMPANION(&pcidev->dev));
>
> if (platform_device_add(pdev) < 0) {
> platform_device_put(pdev);
> --
> 2.12.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 08/10] gpio: exar: Refactor address and bit calculations
From: Andy Shevchenko @ 2017-05-27 13:44 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <ee7ffa22693e844c76f30ce2e96123aefe217e3a.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Make the address and bit calculation more friendly for introducing a
> "first pin" offset later on. The new form is also more compact and
> regular.
I think this should be folded to patch 9 since the latter touches near
all lines you touched here.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 09/10] gpio-exar/8250-exar: Make set of exported GPIOs configurable
From: Andy Shevchenko @ 2017-05-27 13:48 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <1f047bc2a36a3808170cb32e18f272109e675d0c.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> On the SIMATIC, IOT2040 only a single pin is exportable as GPIO, the
> rest is required to operate the UART. To allow modeling this case,
> expand the platform device data structure to specify a (consecutive) pin
> subset for exporting by the gpio-exar driver.
> + unsigned int first_pin;
> + if (device_property_read_u32(&pdev->dev, "first_pin", &first_pin) < 0 ||
And again, we need to follow the rules of the device property
bindings. (No underscores - use dashes; name should be registered).
Without Rafael's / Mika's and Rob's opinions I would not go with a
such name even for internal property.
DWC3 (USB) for example is still using "linux," prefix. I dunno if it's
the case here, I mean can or can't we use similar approach.
> + device_property_read_u32(&pdev->dev, "npins", &npins) < 0)
"ngpios"
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 10/10] serial: exar: Add support for IOT2040 device
From: Andy Shevchenko @ 2017-05-27 13:52 UTC (permalink / raw)
To: Jan Kiszka
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <8d2c0204ee4ab6040787cb953b30284940eaa2bc.1495814557.git.jan.kiszka@siemens.com>
On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> This implements the setup of RS232 and the switch-over to RS485 or RS422
> for the Siemens IOT2040. That uses an EXAR XR17V352 with external logic
> to switch between the different modes. The external logic is controlled
> via MPIO pins of the EXAR controller.
>
> Only pin 10 can be exported as GPIO on the IOT2040. It is connected to
> an LED.
>
> As the XR17V352 used on the IOT2040 is not equipped with an external
> EEPROM, it cannot present itself as IOT2040-variant via subvendor/
> subdevice IDs. Thus, we have to check via DMI for the target platform.
> static void *
> -xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
> - unsigned int npins)
> +__xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
> + unsigned int npins)
> +static int xr17v35x_register_gpio(struct pci_dev *pcidev,
> + struct uart_8250_port *port)
> +{
> + if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
> + port->port.private_data =
> + __xr17v35x_register_gpio(pcidev, 0, 16);
> +
> + return 0;
> +}
> - if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
> - port->port.private_data =
> - xr17v35x_register_gpio(pcidev, 0, 16);
> + ret = platform->register_gpio(pcidev, port);
> }
Can't you move at least some of this to the patch where you move the check?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH 6/6] tty: serial: lpuart: add a more accurate baud rate calculation method
From: Andy Shevchenko @ 2017-05-28 0:04 UTC (permalink / raw)
To: Dong Aisheng
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm Mailing List, Greg Kroah-Hartman, Jiri Slaby,
fugang.duan, Stefan Agner, Mingkai.Hu, yangbo.lu
In-Reply-To: <1494316248-24052-7-git-send-email-aisheng.dong@nxp.com>
On Tue, May 9, 2017 at 10:50 AM, Dong Aisheng <aisheng.dong@nxp.com> wrote:
> On new LPUART versions, the oversampling ratio for the receiver can be
> changed from 4x (00011) to 32x (11111) which could help us get a more
> accurate baud rate divider.
>
> The idea is to use the best OSR (over-sampling rate) possible.
> Note, OSR is typically hard-set to 16 in other LPUART instantiations.
> Loop to find the best OSR value possible, one that generates minimum
> baud diff iterate through the rest of the supported values of OSR.
> +lpuart32_serial_setbrg(struct lpuart_port *sport, unsigned int baudrate)
> +{
> + u32 sbr, osr, baud_diff, tmp_osr, tmp_sbr, tmp_diff, tmp;
> + u32 clk = sport->port.uartclk;
> +
> + /*
> + * The idea is to use the best OSR (over-sampling rate) possible.
> + * Note, OSR is typically hard-set to 16 in other LPUART instantiations.
> + * Loop to find the best OSR value possible, one that generates minimum
> + * baud_diff iterate through the rest of the supported values of OSR.
> + *
> + * Calculation Formula:
> + * Baud Rate = baud clock / ((OSR+1) × SBR)
> + */
> + baud_diff = baudrate;
> + osr = 0;
> + sbr = 0;
> +
> + for (tmp_osr = 4; tmp_osr <= 32; tmp_osr++) {
I _think_ you may simplify this and avoid for-loop if you reconsider approach.
> + /* calculate the temporary sbr value */
> + tmp_sbr = (clk / (baudrate * tmp_osr));
> + if (tmp_sbr == 0)
> + tmp_sbr = 1;
> +
> + /*
> + * calculate the baud rate difference based on the temporary
> + * osr and sbr values
> + */
> + tmp_diff = clk / (tmp_osr * tmp_sbr) - baudrate;
(32 - 4 + 1) times division is called...
> +
> + /* select best values between sbr and sbr+1 */
> + tmp = clk / (tmp_osr * (tmp_sbr + 1));
> + if (tmp_diff > (baudrate - tmp)) {
> + tmp_diff = baudrate - tmp;
> + tmp_sbr++;
> + }
> +
> + if (tmp_diff <= baud_diff) {
> + baud_diff = tmp_diff;
> + osr = tmp_osr;
> + sbr = tmp_sbr;
> + }
> + }
> + /* handle buadrate outside acceptable rate */
> + if (baud_diff > ((baudrate / 100) * 3))
> + dev_warn(sport->port.dev,
> + "unacceptable baud rate difference of more than 3%%\n");
Shouldn't you fall back to previous setting?
> +
> + tmp = lpuart32_read(sport->port.membase + UARTBAUD);
> +
> + if ((osr > 3) && (osr < 8))
Isn't it
if (osr ^ BIT(2) < BIT(2))
?
> + tmp |= UARTBAUD_BOTHEDGE;
> +}
> + if (of_device_is_compatible(port->dev->of_node, "fsl,imx7ulp-lpuart")) {
> + lpuart32_serial_setbrg(sport, baud);
> + } else {
> + sbr = sport->port.uartclk / (16 * baud);
> + bd &= ~UARTBAUD_SBR_MASK;
> + bd |= sbr & UARTBAUD_SBR_MASK;
> + bd |= UARTBAUD_BOTHEDGE;
> + bd &= ~(UARTBAUD_TDMAE | UARTBAUD_RDMAE);
> + lpuart32_write(bd, sport->port.membase + UARTBAUD);
> + }
Perhaps it makes sense to split this to a helper function as well (in
a separate patch).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 09/10] gpio-exar/8250-exar: Make set of exported GPIOs configurable
From: Jan Kiszka @ 2017-05-28 16:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <CAHp75Vdory-NsFRo5OFv7+G5dF315Yr10kEoVsgzod5mwMgqhA@mail.gmail.com>
On 2017-05-27 15:48, Andy Shevchenko wrote:
> On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> On the SIMATIC, IOT2040 only a single pin is exportable as GPIO, the
>> rest is required to operate the UART. To allow modeling this case,
>> expand the platform device data structure to specify a (consecutive) pin
>> subset for exporting by the gpio-exar driver.
>
>> + unsigned int first_pin;
>
>> + if (device_property_read_u32(&pdev->dev, "first_pin", &first_pin) < 0 ||
>
> And again, we need to follow the rules of the device property
> bindings. (No underscores - use dashes; name should be registered).
>
> Without Rafael's / Mika's and Rob's opinions I would not go with a
> such name even for internal property.
>
> DWC3 (USB) for example is still using "linux," prefix. I dunno if it's
> the case here, I mean can or can't we use similar approach.
>
>> + device_property_read_u32(&pdev->dev, "npins", &npins) < 0)
>
> "ngpios"
>
Yeah, forgot to change all this before reposting. Will make the names
DT-alike.
But there is nothing to register: DT shall stay away from this device.
Jan
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply
* Re: [PATCH v3 10/10] serial: exar: Add support for IOT2040 device
From: Jan Kiszka @ 2017-05-28 16:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Linus Walleij, Alexandre Courbot,
Linux Kernel Mailing List, linux-serial@vger.kernel.org,
linux-gpio@vger.kernel.org, Sudip Mukherjee, Sascha Weisenberger
In-Reply-To: <CAHp75VeH-3+k+xvMw--vk1DBtYj6Qdnczh7z77H3fboDzMScRQ@mail.gmail.com>
On 2017-05-27 15:52, Andy Shevchenko wrote:
> On Fri, May 26, 2017 at 7:02 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
>> This implements the setup of RS232 and the switch-over to RS485 or RS422
>> for the Siemens IOT2040. That uses an EXAR XR17V352 with external logic
>> to switch between the different modes. The external logic is controlled
>> via MPIO pins of the EXAR controller.
>>
>> Only pin 10 can be exported as GPIO on the IOT2040. It is connected to
>> an LED.
>>
>> As the XR17V352 used on the IOT2040 is not equipped with an external
>> EEPROM, it cannot present itself as IOT2040-variant via subvendor/
>> subdevice IDs. Thus, we have to check via DMI for the target platform.
>
>> static void *
>> -xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
>> - unsigned int npins)
>> +__xr17v35x_register_gpio(struct pci_dev *pcidev, unsigned int first_pin,
>> + unsigned int npins)
>
>> +static int xr17v35x_register_gpio(struct pci_dev *pcidev,
>> + struct uart_8250_port *port)
>> +{
>> + if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
>> + port->port.private_data =
>> + __xr17v35x_register_gpio(pcidev, 0, 16);
>> +
>> + return 0;
>> +}
>
>> - if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
>> - port->port.private_data =
>> - xr17v35x_register_gpio(pcidev, 0, 16);
>> + ret = platform->register_gpio(pcidev, port);
>> }
>
> Can't you move at least some of this to the patch where you move the check?
>
This change is unrelated to that patch.
What I can offer is a separate patch to factor this out, but I'm not
sure it would buy us much.
Jan
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply
* Re: [PATCH v2] serial: 8250_of: Add reset support
From: Philipp Zabel @ 2017-05-29 9:43 UTC (permalink / raw)
To: Joel Stanley
Cc: Greg Kroah-Hartman, Rob Herring, Mark Rutland,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20170526015519.11865-1-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
Hi Joel,
On Fri, 2017-05-26 at 11:55 +1000, Joel Stanley wrote:
> This adds the hooks for an optional reset controller in the 8250 device
> tree node.
>
> Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
>
> ---
> v2:
> Address Philipp's comments. Thanks for the review!
> - use _shared variant
> - remove unnecessary error handling
>
> Documentation/devicetree/bindings/serial/8250.txt | 1 +
> drivers/tty/serial/8250/8250_of.c | 10 ++++++++++
> 2 files changed, 11 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt
> index 10276a46ecef..63e32393f82b 100644
> --- a/Documentation/devicetree/bindings/serial/8250.txt
> +++ b/Documentation/devicetree/bindings/serial/8250.txt
> @@ -45,6 +45,7 @@ Optional properties:
> property.
> - tx-threshold: Specify the TX FIFO low water indication for parts with
> programmable TX FIFO thresholds.
> +- resets : phandle + reset specifier pairs
>
> Note:
> * fsl,ns16550:
> diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
> index 1cbadafc6889..e95cc9698c32 100644
> --- a/drivers/tty/serial/8250/8250_of.c
> +++ b/drivers/tty/serial/8250/8250_of.c
> @@ -19,11 +19,13 @@
> #include <linux/of_irq.h>
> #include <linux/of_platform.h>
> #include <linux/clk.h>
> +#include <linux/reset.h>
>
> #include "8250.h"
>
> struct of_serial_info {
> struct clk *clk;
> + struct reset_control *rst;
> int type;
> int line;
> };
> @@ -132,6 +134,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
> }
> }
>
> + info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
> + if (IS_ERR(info->rst))
> + goto out;
> + ret = reset_control_deassert(info->rst);
> + if (ret)
> + goto out;
> +
> port->type = type;
> port->uartclk = clk;
> port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
> @@ -231,6 +240,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
>
> if (info->clk)
> clk_disable_unprepare(info->clk);
> + reset_control_assert(info->rst);
The clock is enabled before the reset is deasserted in
of_platform_serial_setup, I'd disable it after asserting the reset in
of_platform_serial_remove. Other than that,
Reviewed-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
regards
Philipp
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v2] serial: 8250_of: Add reset support
From: Joel Stanley @ 2017-05-29 9:57 UTC (permalink / raw)
To: Philipp Zabel
Cc: Greg Kroah-Hartman, Rob Herring, Mark Rutland,
linux-serial-u79uwXL29TY76Z2rM5mHXA, devicetree,
Linux Kernel Mailing List
In-Reply-To: <1496051002.17695.34.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
On Mon, May 29, 2017 at 7:13 PM, Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> wrote:
> Hi Joel,
>
> On Fri, 2017-05-26 at 11:55 +1000, Joel Stanley wrote:
>> This adds the hooks for an optional reset controller in the 8250 device
>> tree node.
>>
>> Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
>>
>> ---
>> v2:
>> Address Philipp's comments. Thanks for the review!
>> - use _shared variant
>> - remove unnecessary error handling
>>
>> Documentation/devicetree/bindings/serial/8250.txt | 1 +
>> drivers/tty/serial/8250/8250_of.c | 10 ++++++++++
>> 2 files changed, 11 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt
>> index 10276a46ecef..63e32393f82b 100644
>> --- a/Documentation/devicetree/bindings/serial/8250.txt
>> +++ b/Documentation/devicetree/bindings/serial/8250.txt
>> @@ -45,6 +45,7 @@ Optional properties:
>> property.
>> - tx-threshold: Specify the TX FIFO low water indication for parts with
>> programmable TX FIFO thresholds.
>> +- resets : phandle + reset specifier pairs
>>
>> Note:
>> * fsl,ns16550:
>> diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
>> index 1cbadafc6889..e95cc9698c32 100644
>> --- a/drivers/tty/serial/8250/8250_of.c
>> +++ b/drivers/tty/serial/8250/8250_of.c
>> @@ -19,11 +19,13 @@
>> #include <linux/of_irq.h>
>> #include <linux/of_platform.h>
>> #include <linux/clk.h>
>> +#include <linux/reset.h>
>>
>> #include "8250.h"
>>
>> struct of_serial_info {
>> struct clk *clk;
>> + struct reset_control *rst;
>> int type;
>> int line;
>> };
>> @@ -132,6 +134,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
>> }
>> }
>>
>> + info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
>> + if (IS_ERR(info->rst))
>> + goto out;
>> + ret = reset_control_deassert(info->rst);
>> + if (ret)
>> + goto out;
>> +
>> port->type = type;
>> port->uartclk = clk;
>> port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
>> @@ -231,6 +240,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
>>
>> if (info->clk)
>> clk_disable_unprepare(info->clk);
>> + reset_control_assert(info->rst);
>
> The clock is enabled before the reset is deasserted in
> of_platform_serial_setup, I'd disable it after asserting the reset in
> of_platform_serial_remove. Other than that,
>
> Reviewed-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Doh, I'll send a v3 with your reviewed-by attached.
Thanks!
Joel
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v3] serial: 8250_of: Add reset support
From: Joel Stanley @ 2017-05-29 9:57 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rob Herring, Mark Rutland, Philipp Zabel
Cc: linux-serial-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
This adds the hooks for an optional reset controller in the 8250 device
tree node.
Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
Reviewed-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
v3:
- deassert reset after disabling clock in _remove to to match _setup
order
v2:
Address Philipp's comments. Thanks for the review!
- use _shared variant
- remove unnecessary error handling
Documentation/devicetree/bindings/serial/8250.txt | 1 +
drivers/tty/serial/8250/8250_of.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt
index 10276a46ecef..63e32393f82b 100644
--- a/Documentation/devicetree/bindings/serial/8250.txt
+++ b/Documentation/devicetree/bindings/serial/8250.txt
@@ -45,6 +45,7 @@ Optional properties:
property.
- tx-threshold: Specify the TX FIFO low water indication for parts with
programmable TX FIFO thresholds.
+- resets : phandle + reset specifier pairs
Note:
* fsl,ns16550:
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 1cbadafc6889..0cf95fddccfc 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -19,11 +19,13 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/clk.h>
+#include <linux/reset.h>
#include "8250.h"
struct of_serial_info {
struct clk *clk;
+ struct reset_control *rst;
int type;
int line;
};
@@ -132,6 +134,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
}
}
+ info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
+ if (IS_ERR(info->rst))
+ goto out;
+ ret = reset_control_deassert(info->rst);
+ if (ret)
+ goto out;
+
port->type = type;
port->uartclk = clk;
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
@@ -229,6 +238,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
serial8250_unregister_port(info->line);
+ reset_control_assert(info->rst);
if (info->clk)
clk_disable_unprepare(info->clk);
kfree(info);
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v8 net-next 00/17] net: qualcomm: add QCA7000 UART driver
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
The Qualcomm QCA7000 HomePlug GreenPHY supports two interfaces:
UART and SPI. This patch series adds the missing support for UART.
This driver based on the Qualcomm code [1], but contains some changes:
* use random MAC address per default
* use net_device_stats from device
* share frame decoding between SPI and UART driver
* improve error handling
* reimplement tty_wakeup with work queue (based on slcan)
* use new serial device bus instead of ldisc
The patches 1 - 3 are just for clean up and are not related to
the UART support. Patch 4 adds SET_NETDEV_DEV() to qca_spi.
Patches 5 - 16 prepare the existing QCA7000 code for UART support.
The last patch contains the new driver.
The code itself has been tested on a Freescale i.MX28 board and
a Raspberry Pi Zero.
Changes in v8:
* add necessary header includes to qca_7k.c in order to reflect
dependencies
Changes in v7:
* fix race between tx workqueue and device deregistration (reported by Lino)
Changes in v6:
* rebase to current linux-next
* use SET_NETDEV_DEV() for qca_spi and qca_uart
* rename binding to qca,qca7000.txt
* use qca,qca7000 compatible for both driver
* handle error cases in qca_uart_probe properly
* fix skb leak in error path of qcauart_netdev_init
* use dev_kfree_skb_any instead of kfree_skb
* take care of tx_work on close / remove
* use devm_kmalloc for tx buffer
* minor cleanups
Changes in v5:
* rebase to current linux-next
* fix alignment issues in rx path
* fix buffer overrun with big ethernet frames
* fix init of UART decoding fsm
* add device UART settings to Kconfig help
* add current-speed to slave-device binding
* merge SPI and UART binding document
* rename qca_common to qca_7k_common
* drop patch for retrieving UART settings
* several cleanups
Changes in v4:
* rebase to current linux-next
* use parameter -M for git format-patch
* change order of local variables where possible
* implement basic serdev support (without hardware flow control)
Changes in v3:
* rebase to current net-next
Changes in v2:
* fix build issue by using netif_trans_update() and dev_trans_start()
[1] - https://github.com/IoE/qca7000
Stefan Wahren (17):
net: qualcomm: qca_7k: clean up header includes
net: qca_framing: use u16 for frame offset
net: qca_7k: Use BIT macro
net: qca_spi: Use SET_NETDEV_DEV()
net: qualcomm: use net_device_ops instead of direct call
net: qualcomm: Improve readability of length defines
net: qca_spi: remove QCASPI_MTU
net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
net: qca_spi: Clarify MODULE_DESCRIPTION
net: qualcomm: rename qca_framing.c to qca_7k_common.c
net: qualcomm: prepare frame decoding for UART driver
net: qualcomm: make qca_7k_common a separate kernel module
dt-bindings: qca7000-spi: Rework binding
dt-bindings: qca7000: rename binding
dt-bindings: slave-device: add current-speed property
dt-bindings: qca7000: append UART interface to binding
net: qualcomm: add QCA7000 UART driver
.../devicetree/bindings/net/qca,qca7000.txt | 88 +++++
.../devicetree/bindings/net/qca-qca7000-spi.txt | 47 ---
.../devicetree/bindings/serial/slave-device.txt | 9 +
drivers/net/ethernet/qualcomm/Kconfig | 24 +-
drivers/net/ethernet/qualcomm/Makefile | 7 +-
drivers/net/ethernet/qualcomm/qca_7k.c | 30 +-
drivers/net/ethernet/qualcomm/qca_7k.h | 15 +-
.../qualcomm/{qca_framing.c => qca_7k_common.c} | 26 +-
.../qualcomm/{qca_framing.h => qca_7k_common.h} | 24 +-
drivers/net/ethernet/qualcomm/qca_debug.c | 5 +-
drivers/net/ethernet/qualcomm/qca_spi.c | 48 ++-
drivers/net/ethernet/qualcomm/qca_spi.h | 5 +-
drivers/net/ethernet/qualcomm/qca_uart.c | 423 +++++++++++++++++++++
13 files changed, 632 insertions(+), 119 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/qca,qca7000.txt
delete mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
rename drivers/net/ethernet/qualcomm/{qca_framing.c => qca_7k_common.c} (85%)
rename drivers/net/ethernet/qualcomm/{qca_framing.h => qca_7k_common.h} (86%)
create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c
--
2.1.4
^ permalink raw reply
* [PATCH v8 net-next 01/17] net: qualcomm: qca_7k: clean up header includes
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
Currently the includes doesn't reflect the dependencies. So
fix this up by removing all unnecessary entries and add the
necessary ones explicit.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_7k.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index f0066fb..e9162e1 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -23,11 +23,9 @@
* kernel-based SPI device.
*/
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
#include <linux/spi/spi.h>
-#include <linux/version.h>
#include "qca_7k.h"
--
2.1.4
^ permalink raw reply related
* [PATCH v8 net-next 02/17] net: qca_framing: use u16 for frame offset
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
It doesn't make sense to use a signed variable for offset here, so
fix it up.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_framing.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.h b/drivers/net/ethernet/qualcomm/qca_framing.h
index d5e795d..8b385e6 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.h
+++ b/drivers/net/ethernet/qualcomm/qca_framing.h
@@ -103,7 +103,7 @@ struct qcafrm_handle {
enum qcafrm_state state;
/* Offset in buffer (borrowed for length too) */
- s16 offset;
+ u16 offset;
/* Frame length as kept by this module */
u16 len;
--
2.1.4
^ permalink raw reply related
* [PATCH v8 net-next 03/17] net: qca_7k: Use BIT macro
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
Use the BIT macro for the CONFIG and INT register values.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_7k.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.h b/drivers/net/ethernet/qualcomm/qca_7k.h
index 1cad851..4047f0a 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.h
+++ b/drivers/net/ethernet/qualcomm/qca_7k.h
@@ -54,15 +54,15 @@
#define SPI_REG_ACTION_CTRL 0x1B00
/* SPI_CONFIG register definition; */
-#define QCASPI_SLAVE_RESET_BIT (1 << 6)
+#define QCASPI_SLAVE_RESET_BIT BIT(6)
/* INTR_CAUSE/ENABLE register definition. */
-#define SPI_INT_WRBUF_BELOW_WM (1 << 10)
-#define SPI_INT_CPU_ON (1 << 6)
-#define SPI_INT_ADDR_ERR (1 << 3)
-#define SPI_INT_WRBUF_ERR (1 << 2)
-#define SPI_INT_RDBUF_ERR (1 << 1)
-#define SPI_INT_PKT_AVLBL (1 << 0)
+#define SPI_INT_WRBUF_BELOW_WM BIT(10)
+#define SPI_INT_CPU_ON BIT(6)
+#define SPI_INT_ADDR_ERR BIT(3)
+#define SPI_INT_WRBUF_ERR BIT(2)
+#define SPI_INT_RDBUF_ERR BIT(1)
+#define SPI_INT_PKT_AVLBL BIT(0)
void qcaspi_spi_error(struct qcaspi *qca);
int qcaspi_read_register(struct qcaspi *qca, u16 reg, u16 *result);
--
2.1.4
^ permalink raw reply related
* [PATCH v8 net-next 04/17] net: qca_spi: Use SET_NETDEV_DEV()
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
Use SET_NETDEV_DEV() in qca_spi to create the "/sys/class/net/<if>/device"
symlink.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_spi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 24ca7df..0c3fdee 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -894,6 +894,7 @@ qca_spi_probe(struct spi_device *spi)
return -ENOMEM;
qcaspi_netdev_setup(qcaspi_devs);
+ SET_NETDEV_DEV(qcaspi_devs, &spi->dev);
qca = netdev_priv(qcaspi_devs);
if (!qca) {
--
2.1.4
^ permalink raw reply related
* [PATCH v8 net-next 05/17] net: qualcomm: use net_device_ops instead of direct call
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
There is no need to export qcaspi_netdev_open and qcaspi_netdev_close
because they are also accessible via the net_device_ops.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_debug.c | 5 +++--
drivers/net/ethernet/qualcomm/qca_spi.c | 4 ++--
drivers/net/ethernet/qualcomm/qca_spi.h | 3 ---
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index d145df9..92b6be9 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -275,6 +275,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
static int
qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
struct qcaspi *qca = netdev_priv(dev);
if ((ring->rx_pending) ||
@@ -283,13 +284,13 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
return -EINVAL;
if (netif_running(dev))
- qcaspi_netdev_close(dev);
+ ops->ndo_stop(dev);
qca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN);
qca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN);
if (netif_running(dev))
- qcaspi_netdev_open(dev);
+ ops->ndo_open(dev);
return 0;
}
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 0c3fdee..7e039e3 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -603,7 +603,7 @@ qcaspi_intr_handler(int irq, void *data)
return IRQ_HANDLED;
}
-int
+static int
qcaspi_netdev_open(struct net_device *dev)
{
struct qcaspi *qca = netdev_priv(dev);
@@ -640,7 +640,7 @@ qcaspi_netdev_open(struct net_device *dev)
return 0;
}
-int
+static int
qcaspi_netdev_close(struct net_device *dev)
{
struct qcaspi *qca = netdev_priv(dev);
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 6e31a0e..064853d 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -108,7 +108,4 @@ struct qcaspi {
u16 burst_len;
};
-int qcaspi_netdev_open(struct net_device *dev);
-int qcaspi_netdev_close(struct net_device *dev);
-
#endif /* _QCA_SPI_H */
--
2.1.4
^ permalink raw reply related
* [PATCH v8 net-next 06/17] net: qualcomm: Improve readability of length defines
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>
In order to avoid mixing things up, make the MTU and frame length
defines easier to read.
Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
drivers/net/ethernet/qualcomm/qca_framing.c | 2 +-
drivers/net/ethernet/qualcomm/qca_framing.h | 8 ++++----
drivers/net/ethernet/qualcomm/qca_spi.c | 12 ++++++------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.c b/drivers/net/ethernet/qualcomm/qca_framing.c
index faa924c..2341f2b 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.c
+++ b/drivers/net/ethernet/qualcomm/qca_framing.c
@@ -117,7 +117,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
break;
case QCAFRM_WAIT_RSVD_BYTE2:
len = handle->offset;
- if (len > buf_len || len < QCAFRM_ETHMINLEN) {
+ if (len > buf_len || len < QCAFRM_MIN_LEN) {
ret = QCAFRM_INVLEN;
handle->state = QCAFRM_HW_LEN0;
} else {
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.h b/drivers/net/ethernet/qualcomm/qca_framing.h
index 8b385e6..5df7c65 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.h
+++ b/drivers/net/ethernet/qualcomm/qca_framing.h
@@ -44,12 +44,12 @@
#define QCAFRM_INVFRAME (QCAFRM_ERR_BASE - 4)
/* Min/Max Ethernet MTU: 46/1500 */
-#define QCAFRM_ETHMINMTU (ETH_ZLEN - ETH_HLEN)
-#define QCAFRM_ETHMAXMTU ETH_DATA_LEN
+#define QCAFRM_MIN_MTU (ETH_ZLEN - ETH_HLEN)
+#define QCAFRM_MAX_MTU ETH_DATA_LEN
/* Min/Max frame lengths */
-#define QCAFRM_ETHMINLEN (QCAFRM_ETHMINMTU + ETH_HLEN)
-#define QCAFRM_ETHMAXLEN (QCAFRM_ETHMAXMTU + VLAN_ETH_HLEN)
+#define QCAFRM_MIN_LEN (QCAFRM_MIN_MTU + ETH_HLEN)
+#define QCAFRM_MAX_LEN (QCAFRM_MAX_MTU + VLAN_ETH_HLEN)
/* QCA7K header len */
#define QCAFRM_HEADER_LEN 8
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 7e039e3..f155548 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -69,7 +69,7 @@ static int qcaspi_pluggable = QCASPI_PLUGGABLE_MIN;
module_param(qcaspi_pluggable, int, 0);
MODULE_PARM_DESC(qcaspi_pluggable, "Pluggable SPI connection (yes/no).");
-#define QCASPI_MTU QCAFRM_ETHMAXMTU
+#define QCASPI_MTU QCAFRM_MAX_MTU
#define QCASPI_TX_TIMEOUT (1 * HZ)
#define QCASPI_QCA7K_REBOOT_TIME_MS 1000
@@ -403,7 +403,7 @@ qcaspi_tx_ring_has_space(struct tx_ring *txr)
if (txr->skb[txr->tail])
return 0;
- return (txr->size + QCAFRM_ETHMAXLEN < QCASPI_HW_BUF_LEN) ? 1 : 0;
+ return (txr->size + QCAFRM_MAX_LEN < QCASPI_HW_BUF_LEN) ? 1 : 0;
}
/* Flush the tx ring. This function is only safe to
@@ -667,8 +667,8 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
struct sk_buff *tskb;
u8 pad_len = 0;
- if (skb->len < QCAFRM_ETHMINLEN)
- pad_len = QCAFRM_ETHMINLEN - skb->len;
+ if (skb->len < QCAFRM_MIN_LEN)
+ pad_len = QCAFRM_MIN_LEN - skb->len;
if (qca->txr.skb[qca->txr.tail]) {
netdev_warn(qca->net_dev, "queue was unexpectedly full!\n");
@@ -805,8 +805,8 @@ qcaspi_netdev_setup(struct net_device *dev)
dev->tx_queue_len = 100;
/* MTU range: 46 - 1500 */
- dev->min_mtu = QCAFRM_ETHMINMTU;
- dev->max_mtu = QCAFRM_ETHMAXMTU;
+ dev->min_mtu = QCAFRM_MIN_MTU;
+ dev->max_mtu = QCAFRM_MAX_MTU;
qca = netdev_priv(dev);
memset(qca, 0, sizeof(struct qcaspi));
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v8 net-next 07/17] net: qca_spi: remove QCASPI_MTU
From: Stefan Wahren @ 2017-05-29 11:57 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1496059045-13572-1-git-send-email-stefan.wahren@i2se.com>
There is no need for an additional MTU define.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_spi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index f155548..7464628 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -69,7 +69,6 @@ static int qcaspi_pluggable = QCASPI_PLUGGABLE_MIN;
module_param(qcaspi_pluggable, int, 0);
MODULE_PARM_DESC(qcaspi_pluggable, "Pluggable SPI connection (yes/no).");
-#define QCASPI_MTU QCAFRM_MAX_MTU
#define QCASPI_TX_TIMEOUT (1 * HZ)
#define QCASPI_QCA7K_REBOOT_TIME_MS 1000
@@ -746,7 +745,7 @@ qcaspi_netdev_init(struct net_device *dev)
{
struct qcaspi *qca = netdev_priv(dev);
- dev->mtu = QCASPI_MTU;
+ dev->mtu = QCAFRM_MAX_MTU;
dev->type = ARPHRD_ETHER;
qca->clkspeed = qcaspi_clkspeed;
qca->burst_len = qcaspi_burst_len;
--
2.1.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox