Re: [PATCH] serial: 8250: add gpio support to exar
Hi Sudip, [auto build test ERROR on tty/tty-testing] [also build test ERROR on next-20151218] [cannot apply to v4.4-rc5] url: https://github.com/0day-ci/linux/commits/Sudip-Mukherjee/serial-8250-add-gpio-support-to-exar/20151219-161216 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: i386-randconfig-s1-201550 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/built-in.o: In function `pci_xr17v35x_exit': >> 8250_pci.c:(.text+0x182f19): undefined reference to `xr17v35x_gpio_exit' drivers/built-in.o: In function `pci_xr17v35x_setup': >> 8250_pci.c:(.text+0x183189): undefined reference to `xr17v35x_gpio_init' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
Re: [PATCH] serial: 8250: add gpio support to exar
Hi Sudip, [auto build test WARNING on tty/tty-testing] [also build test WARNING on next-20151218] [cannot apply to v4.4-rc5] url: https://github.com/0day-ci/linux/commits/Sudip-Mukherjee/serial-8250-add-gpio-support-to-exar/20151219-161216 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: m32r-m32104ut_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=m32r All warnings (new ones prefixed by >>): In file included from drivers/tty/serial/8250/8250_core.c:46:0: >> drivers/tty/serial/8250/8250.h:226:17: warning: 'struct pci_dev' declared >> inside parameter list struct uart_8250_port *port) ^ >> drivers/tty/serial/8250/8250.h:226:17: warning: its scope is only this >> definition or declaration, which is probably not what you want drivers/tty/serial/8250/8250.h:231:13: warning: 'xr17v35x_gpio_exit' defined but not used [-Wunused-function] static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } ^ vim +226 drivers/tty/serial/8250/8250.h 210 serial_out(up, 0x04, status); 211 } 212 return 1; 213 } 214 215 static inline int serial_index(struct uart_port *port) 216 { 217 return port->minor - 64; 218 } 219 220 #ifdef CONFIG_GPIOLIB 221 int xr17v35x_gpio_init(struct pci_dev *dev, 222 struct uart_8250_port *port); 223 void xr17v35x_gpio_exit(struct uart_8250_port *port); 224 #else 225 static inline int xr17v35x_gpio_init(struct pci_dev *dev, > 226 struct uart_8250_port *port) 227 { 228 return 0; 229 } 230 231 static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } 232 #endif 233 234 #if 0 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH] serial: 8250: add gpio support to exar
Exar XR17V352/354/358 chips have 16 multi-purpose inputs/outputs which can be controlled using gpio interface. Add support to use these pins and select GPIO_SYSFS also so that these pins can be used from the userspace through sysfs. Tested-by: Rob Groner Signed-off-by: Sudip Mukherjee --- drivers/tty/serial/8250/8250.h | 14 ++ drivers/tty/serial/8250/8250_gpio.c | 276 drivers/tty/serial/8250/8250_pci.c | 26 +++- drivers/tty/serial/8250/Kconfig | 8 ++ drivers/tty/serial/8250/Makefile| 1 + 5 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/tty/serial/8250/8250_gpio.c diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index d54dcd8..507447d 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -217,6 +217,20 @@ static inline int serial_index(struct uart_port *port) return port->minor - 64; } +#ifdef CONFIG_GPIOLIB +int xr17v35x_gpio_init(struct pci_dev *dev, + struct uart_8250_port *port); +void xr17v35x_gpio_exit(struct uart_8250_port *port); +#else +static inline int xr17v35x_gpio_init(struct pci_dev *dev, +struct uart_8250_port *port) +{ + return 0; +} + +static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } +#endif + #if 0 #define DEBUG_INTR(fmt...) printk(fmt) #else diff --git a/drivers/tty/serial/8250/8250_gpio.c b/drivers/tty/serial/8250/8250_gpio.c new file mode 100644 index 000..1b14dd2 --- /dev/null +++ b/drivers/tty/serial/8250/8250_gpio.c @@ -0,0 +1,276 @@ +/* + * GPIO driver for Exar XR17V35X chip + * + * Copyright (C) 2015 Sudip Mukherjee + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include +#include +#include +#include "8250.h" + +#define EXAR_OFFSET_MPIOLVL_LO 0x90 +#define EXAR_OFFSET_MPIOSEL_LO 0x93 +#define EXAR_OFFSET_MPIOLVL_HI 0x96 +#define EXAR_OFFSET_MPIOSEL_HI 0x99 + +static LIST_HEAD(exar_list); +static DEFINE_MUTEX(exar_mtx); /* lock while manipulating the list */ + +struct exar_gpio_chip { + struct gpio_chip gpio_chip; + struct mutex lock; + struct uart_8250_port *port; + struct list_head list; + int index; + void __iomem *regs; +}; + +#define to_exar_chip(n) container_of(n, struct exar_gpio_chip, gpio_chip) + +static inline unsigned int read_exar_reg(struct exar_gpio_chip *chip, +int offset) +{ + if (!chip) { + pr_err("%s exar_gpio is NULL\n", __func__); + return -ENOMEM; + } + pr_debug("%s regs=%p offset=%x\n", __func__, chip->regs, offset); + + return readb(chip->regs + offset); +} + +static inline void write_exar_reg(struct exar_gpio_chip *chip, int offset, + int value) +{ + if (!chip) { + pr_err("%s exar_gpio is NULL\n", __func__); + return; + } + pr_debug("%s regs=%p value=%x offset=%x\n", __func__, chip->regs, +value, offset); + + writeb(value, chip->regs + offset); +} + +void xr17v35x_gpio_exit(struct uart_8250_port *port) +{ + struct exar_gpio_chip *exar_gpio, *exar_temp1, *exar_temp2; + + if (!port) + return; + + exar_gpio = port->port.private_data; + if (!exar_gpio) + return; + + mutex_lock(_mtx); + list_for_each_entry_safe(exar_temp1, exar_temp2, _list, list) { + if (exar_temp1->index == exar_gpio->index) { + list_del(_temp1->list); + break; + } + } + mutex_unlock(_mtx); + + gpiochip_remove(_gpio->gpio_chip); + mutex_destroy(_gpio->lock); + iounmap(exar_gpio->regs); +} +EXPORT_SYMBOL(xr17v35x_gpio_exit); + +static void exar_set(struct gpio_chip *chip, unsigned int reg, int val, +unsigned int offset) +{ + struct exar_gpio_chip *exar_gpio = to_exar_chip(chip); + int temp; + + mutex_lock(_gpio->lock); + temp = read_exar_reg(exar_gpio, reg); + temp &= ~(1 << offset); + temp |= val << offset; + write_exar_reg(exar_gpio, reg, temp); + mutex_unlock(_gpio->lock); +} + +static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, +int value) +{ + if (offset < 8) + exar_set(chip, EXAR_OFFSET_MPIOSEL_LO, 0, offset); + else + exar_set(chip, EXAR_OFFSET_MPIOSEL_HI, 0, offset - 8); + return 0; +} + +static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) +{ + if (offset < 8) + exar_set(chip, EXAR_OFFSET_MPIOSEL_LO, 1,
Re: [PATCH] serial: 8250: add gpio support to exar
Hi Sudip, [auto build test WARNING on tty/tty-testing] [also build test WARNING on next-20151218] [cannot apply to v4.4-rc5] url: https://github.com/0day-ci/linux/commits/Sudip-Mukherjee/serial-8250-add-gpio-support-to-exar/20151219-161216 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: m32r-m32104ut_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=m32r All warnings (new ones prefixed by >>): In file included from drivers/tty/serial/8250/8250_core.c:46:0: >> drivers/tty/serial/8250/8250.h:226:17: warning: 'struct pci_dev' declared >> inside parameter list struct uart_8250_port *port) ^ >> drivers/tty/serial/8250/8250.h:226:17: warning: its scope is only this >> definition or declaration, which is probably not what you want drivers/tty/serial/8250/8250.h:231:13: warning: 'xr17v35x_gpio_exit' defined but not used [-Wunused-function] static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } ^ vim +226 drivers/tty/serial/8250/8250.h 210 serial_out(up, 0x04, status); 211 } 212 return 1; 213 } 214 215 static inline int serial_index(struct uart_port *port) 216 { 217 return port->minor - 64; 218 } 219 220 #ifdef CONFIG_GPIOLIB 221 int xr17v35x_gpio_init(struct pci_dev *dev, 222 struct uart_8250_port *port); 223 void xr17v35x_gpio_exit(struct uart_8250_port *port); 224 #else 225 static inline int xr17v35x_gpio_init(struct pci_dev *dev, > 226 struct uart_8250_port *port) 227 { 228 return 0; 229 } 230 231 static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } 232 #endif 233 234 #if 0 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data
[PATCH] serial: 8250: add gpio support to exar
Exar XR17V352/354/358 chips have 16 multi-purpose inputs/outputs which can be controlled using gpio interface. Add support to use these pins and select GPIO_SYSFS also so that these pins can be used from the userspace through sysfs. Tested-by: Rob GronerSigned-off-by: Sudip Mukherjee --- drivers/tty/serial/8250/8250.h | 14 ++ drivers/tty/serial/8250/8250_gpio.c | 276 drivers/tty/serial/8250/8250_pci.c | 26 +++- drivers/tty/serial/8250/Kconfig | 8 ++ drivers/tty/serial/8250/Makefile| 1 + 5 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/tty/serial/8250/8250_gpio.c diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h index d54dcd8..507447d 100644 --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h @@ -217,6 +217,20 @@ static inline int serial_index(struct uart_port *port) return port->minor - 64; } +#ifdef CONFIG_GPIOLIB +int xr17v35x_gpio_init(struct pci_dev *dev, + struct uart_8250_port *port); +void xr17v35x_gpio_exit(struct uart_8250_port *port); +#else +static inline int xr17v35x_gpio_init(struct pci_dev *dev, +struct uart_8250_port *port) +{ + return 0; +} + +static void xr17v35x_gpio_exit(struct uart_8250_port *port) { } +#endif + #if 0 #define DEBUG_INTR(fmt...) printk(fmt) #else diff --git a/drivers/tty/serial/8250/8250_gpio.c b/drivers/tty/serial/8250/8250_gpio.c new file mode 100644 index 000..1b14dd2 --- /dev/null +++ b/drivers/tty/serial/8250/8250_gpio.c @@ -0,0 +1,276 @@ +/* + * GPIO driver for Exar XR17V35X chip + * + * Copyright (C) 2015 Sudip Mukherjee + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include +#include +#include +#include "8250.h" + +#define EXAR_OFFSET_MPIOLVL_LO 0x90 +#define EXAR_OFFSET_MPIOSEL_LO 0x93 +#define EXAR_OFFSET_MPIOLVL_HI 0x96 +#define EXAR_OFFSET_MPIOSEL_HI 0x99 + +static LIST_HEAD(exar_list); +static DEFINE_MUTEX(exar_mtx); /* lock while manipulating the list */ + +struct exar_gpio_chip { + struct gpio_chip gpio_chip; + struct mutex lock; + struct uart_8250_port *port; + struct list_head list; + int index; + void __iomem *regs; +}; + +#define to_exar_chip(n) container_of(n, struct exar_gpio_chip, gpio_chip) + +static inline unsigned int read_exar_reg(struct exar_gpio_chip *chip, +int offset) +{ + if (!chip) { + pr_err("%s exar_gpio is NULL\n", __func__); + return -ENOMEM; + } + pr_debug("%s regs=%p offset=%x\n", __func__, chip->regs, offset); + + return readb(chip->regs + offset); +} + +static inline void write_exar_reg(struct exar_gpio_chip *chip, int offset, + int value) +{ + if (!chip) { + pr_err("%s exar_gpio is NULL\n", __func__); + return; + } + pr_debug("%s regs=%p value=%x offset=%x\n", __func__, chip->regs, +value, offset); + + writeb(value, chip->regs + offset); +} + +void xr17v35x_gpio_exit(struct uart_8250_port *port) +{ + struct exar_gpio_chip *exar_gpio, *exar_temp1, *exar_temp2; + + if (!port) + return; + + exar_gpio = port->port.private_data; + if (!exar_gpio) + return; + + mutex_lock(_mtx); + list_for_each_entry_safe(exar_temp1, exar_temp2, _list, list) { + if (exar_temp1->index == exar_gpio->index) { + list_del(_temp1->list); + break; + } + } + mutex_unlock(_mtx); + + gpiochip_remove(_gpio->gpio_chip); + mutex_destroy(_gpio->lock); + iounmap(exar_gpio->regs); +} +EXPORT_SYMBOL(xr17v35x_gpio_exit); + +static void exar_set(struct gpio_chip *chip, unsigned int reg, int val, +unsigned int offset) +{ + struct exar_gpio_chip *exar_gpio = to_exar_chip(chip); + int temp; + + mutex_lock(_gpio->lock); + temp = read_exar_reg(exar_gpio, reg); + temp &= ~(1 << offset); + temp |= val << offset; + write_exar_reg(exar_gpio, reg, temp); + mutex_unlock(_gpio->lock); +} + +static int exar_direction_output(struct gpio_chip *chip, unsigned int offset, +int value) +{ + if (offset < 8) + exar_set(chip, EXAR_OFFSET_MPIOSEL_LO, 0, offset); + else + exar_set(chip, EXAR_OFFSET_MPIOSEL_HI, 0, offset - 8); + return 0; +} + +static int exar_direction_input(struct gpio_chip *chip, unsigned int offset) +{ + if
Re: [PATCH] serial: 8250: add gpio support to exar
Hi Sudip, [auto build test ERROR on tty/tty-testing] [also build test ERROR on next-20151218] [cannot apply to v4.4-rc5] url: https://github.com/0day-ci/linux/commits/Sudip-Mukherjee/serial-8250-add-gpio-support-to-exar/20151219-161216 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: i386-randconfig-s1-201550 (attached as .config) reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/built-in.o: In function `pci_xr17v35x_exit': >> 8250_pci.c:(.text+0x182f19): undefined reference to `xr17v35x_gpio_exit' drivers/built-in.o: In function `pci_xr17v35x_setup': >> 8250_pci.c:(.text+0x183189): undefined reference to `xr17v35x_gpio_init' --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data