Re: 3.14.12 and USB option_instat_callback with 3G DONGLE
On Sat, Jul 19, 2014 at 03:11:22PM +1000, ress...@ausics.net wrote: > Since upgrading from 3.12.24 kernel to 3.14.10, and today, .12 kernel log > and dmesg are flooded with constant messages > > option1 ttyUSB0: option_instat_callback: error -2 > > The device still works, it sends and receives SMS's as well, > I tried setting verbose usb debug to see if it offers any more explanations, > but it shows nothing more. > > The device is Huawei E160, but is identified as (and always has been) an > E620 > > ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem > > Did somthing break between 3.12 and 3.14? Rather annoying at how fast and > large kernel.log is geting. Any chance you can use 'git bisect' to try to find the problem commit in the kernel tree? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] gpio:gpio-pl2303: add gpio driver for GPIOs on PL2303
PL2303HX has two GPIOs, this patch add driver for it. Signed-off-by: Wang YanQing --- MAINTAINERS | 5 + drivers/gpio/Kconfig| 7 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-pl2303.c | 238 drivers/usb/serial/pl2303.c | 19 5 files changed, 270 insertions(+) create mode 100644 drivers/gpio/gpio-pl2303.c diff --git a/MAINTAINERS b/MAINTAINERS index 53feaaf..4a9d764 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6903,6 +6903,11 @@ F: drivers/i2c/busses/i2c-puv3.c F: drivers/video/fb-puv3.c F: drivers/rtc/rtc-puv3.c +PL2303 GPIO DRIVER +M: Wang YanQing +S: Maintained +F: drivers/gpio/gpio-pl2303.c + PMBUS HARDWARE MONITORING DRIVERS M: Guenter Roeck L: lm-sens...@lm-sensors.org diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 4a1b511..0f90950 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -110,6 +110,13 @@ config GPIO_DA9055 config GPIO_MAX730X tristate +config GPIO_PL2303 + tristate "USB Prolific 2303 gpio support" + depends on USB_SERIAL_PL2303 + help + Enable support for GPIOs on USB Prolific 2303 + It support two GPIOs on PL2303HX currently. + comment "Memory mapped GPIO drivers:" config GPIO_CLPS711X diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index d10f6a9..4ff59f6 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -101,3 +101,4 @@ obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o +obj-$(CONFIG_GPIO_PL2303) += gpio-pl2303.o diff --git a/drivers/gpio/gpio-pl2303.c b/drivers/gpio/gpio-pl2303.c new file mode 100644 index 000..a703440 --- /dev/null +++ b/drivers/gpio/gpio-pl2303.c @@ -0,0 +1,238 @@ +/* + * PL2303 GPIO driver + * + * Copyright (C) 2014 Wang YanQing + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Check pl2303.c for further details. + */ + +#include +#include +#include +#include +#include +#include + +#define VENDOR_READ_REQUEST_TYPE 0xc0 +#define VENDOR_READ_REQUEST0x01 + +#define VENDOR_WRITE_REQUEST_TYPE 0x40 +#define VENDOR_WRITE_REQUEST 0x01 + +struct pl2303_gpio_data { + struct usb_device *pl2303; + /* +* 0..3: unknown (zero) +* 4: gp0 output enable (1: gp0 pin is output, 0: gp0 pin is input) +* 5: gp1 output enable (1: gp1 pin is output, 0: gp1 pin is input) +* 6: gp0 pin value +* 7: gp1 pin value +*/ + u8 index; + struct gpio_chip gpio_chip; +}; + +static inline struct pl2303_gpio_data *to_pl2303_gpio(struct gpio_chip *chip) +{ + return container_of(chip, struct pl2303_gpio_data, gpio_chip); +} + +static int pl2303_gpio_read(struct gpio_chip *chip, unsigned char buf[1]) +{ + struct pl2303_gpio_data *pl2303_gpio = to_pl2303_gpio(chip); + struct usb_device *pl2303 = pl2303_gpio->pl2303; + struct device *dev = chip->dev; + int res; + + res = usb_control_msg(pl2303, usb_rcvctrlpipe(pl2303, 0), + VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, + 0x0081, 0, buf, 1, 100); + if (res != 1) { + dev_err(dev, "%s - failed to read [%04x]: %d\n", __func__, + 0x0081, res); + if (res >= 0) + res = -EIO; + + return res; + } + + dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, 0x0081, buf[0]); + + return 0; +} + +static int pl2303_gpio_write(struct gpio_chip *chip) +{ + struct pl2303_gpio_data *pl2303_gpio = to_pl2303_gpio(chip); + struct usb_device *pl2303 = pl2303_gpio->pl2303; + struct device *dev = chip->dev; + int res; + + dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, 1, pl2303_gpio->index); + + res = usb_control_msg(pl2303, usb_sndctrlpipe(pl2303, 0), + VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, + 1, pl2303_gpio->index, NULL, 0, 100); + if (res) { + dev_err(dev, "%s - failed to write [%04x] = %02x: %d\n", __func__, + 1, pl2303_gpio->index, res); + return res; + } + + return 0; +} + +static int pl2303_gpio_direction_in(struct gpio_chip *chip, unsigned offset) +{ + struct pl2303_gpio_data *pl2303_gpio = to_pl2303_gpio(chip); + + if (offset == 0) + pl2303_gpio->index &= ~0x10; + else if (offset == 1) + pl2303_gpio->index &= ~0x20; + else + return -EINVAL; + + pl2303_gpio_wr
Re: [PATCH] gpio:gpio-pl2303: add gpio driver for GPIOs on PL2303
On Sun, Jul 20, 2014 at 08:01:31AM +0800, Wang YanQing wrote: > PL2303HX has two GPIOs, this patch add driver for it. > > Signed-off-by: Wang YanQing > --- > MAINTAINERS | 5 + > drivers/gpio/Kconfig| 7 ++ > drivers/gpio/Makefile | 1 + > drivers/gpio/gpio-pl2303.c | 238 > > drivers/usb/serial/pl2303.c | 19 > 5 files changed, 270 insertions(+) > create mode 100644 drivers/gpio/gpio-pl2303.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 53feaaf..4a9d764 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -6903,6 +6903,11 @@ F: drivers/i2c/busses/i2c-puv3.c > F: drivers/video/fb-puv3.c > F: drivers/rtc/rtc-puv3.c > > +PL2303 GPIO DRIVER > +M: Wang YanQing > +S: Maintained > +F: drivers/gpio/gpio-pl2303.c > + > PMBUS HARDWARE MONITORING DRIVERS > M: Guenter Roeck > L: lm-sens...@lm-sensors.org > diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig > index 4a1b511..0f90950 100644 > --- a/drivers/gpio/Kconfig > +++ b/drivers/gpio/Kconfig > @@ -110,6 +110,13 @@ config GPIO_DA9055 > config GPIO_MAX730X > tristate > > +config GPIO_PL2303 > + tristate "USB Prolific 2303 gpio support" > + depends on USB_SERIAL_PL2303 > + help > + Enable support for GPIOs on USB Prolific 2303 > + It support two GPIOs on PL2303HX currently. > + > comment "Memory mapped GPIO drivers:" > > config GPIO_CLPS711X > diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile > index d10f6a9..4ff59f6 100644 > --- a/drivers/gpio/Makefile > +++ b/drivers/gpio/Makefile > @@ -101,3 +101,4 @@ obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o > obj-$(CONFIG_GPIO_XILINX)+= gpio-xilinx.o > obj-$(CONFIG_GPIO_XTENSA)+= gpio-xtensa.o > obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o > +obj-$(CONFIG_GPIO_PL2303)+= gpio-pl2303.o > diff --git a/drivers/gpio/gpio-pl2303.c b/drivers/gpio/gpio-pl2303.c > new file mode 100644 > index 000..a703440 > --- /dev/null > +++ b/drivers/gpio/gpio-pl2303.c > @@ -0,0 +1,238 @@ > +/* > + * PL2303 GPIO driver > + * > + * Copyright (C) 2014 Wang YanQing > + * > + * 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 > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * > + * Check pl2303.c for further details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VENDOR_READ_REQUEST_TYPE 0xc0 > +#define VENDOR_READ_REQUEST 0x01 > + > +#define VENDOR_WRITE_REQUEST_TYPE0x40 > +#define VENDOR_WRITE_REQUEST 0x01 > + > +struct pl2303_gpio_data { > + struct usb_device *pl2303; > + /* > + * 0..3: unknown (zero) > + * 4: gp0 output enable (1: gp0 pin is output, 0: gp0 pin is input) > + * 5: gp1 output enable (1: gp1 pin is output, 0: gp1 pin is input) > + * 6: gp0 pin value > + * 7: gp1 pin value > + */ > + u8 index; > + struct gpio_chip gpio_chip; > +}; > + > +static inline struct pl2303_gpio_data *to_pl2303_gpio(struct gpio_chip *chip) > +{ > + return container_of(chip, struct pl2303_gpio_data, gpio_chip); > +} > + > +static int pl2303_gpio_read(struct gpio_chip *chip, unsigned char buf[1]) > +{ > + struct pl2303_gpio_data *pl2303_gpio = to_pl2303_gpio(chip); > + struct usb_device *pl2303 = pl2303_gpio->pl2303; > + struct device *dev = chip->dev; > + int res; > + > + res = usb_control_msg(pl2303, usb_rcvctrlpipe(pl2303, 0), > + VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, > + 0x0081, 0, buf, 1, 100); > + if (res != 1) { > + dev_err(dev, "%s - failed to read [%04x]: %d\n", __func__, > + 0x0081, res); > + if (res >= 0) > + res = -EIO; > + > + return res; > + } > + > + dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, 0x0081, buf[0]); > + > + return 0; > +} > + > +static int pl2303_gpio_write(struct gpio_chip *chip) > +{ > + struct pl2303_gpio_data *pl2303_gpio = to_pl2303_gpio(chip); > + struct usb_device *pl2303 = pl2303_gpio->pl2303; > + struct device *dev = chip->dev; > + int res; > + > + dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, 1, pl2303_gpio->index); > + > + res = usb_control_msg(pl2303, usb_sndctrlpipe(pl2303, 0), > + VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, > + 1, pl2303_gpio->index, NULL, 0, 100); > + if (res) { > + dev_err(dev, "%s - failed to write [%04x] = %02x: %d\n", > __func__, > + 1, pl2303_gpio->index, res); > + return res; > + } > + > + return 0; > +} > + > +static int pl2303_gpio_direction_in(struct gpio_chip *chip, unsigned offset) > +{ > + struct pl2303_gpio_data *pl2303_gp
[PATCH] usb: phy: msm: Fix return value check in msm_otg_probe()
From: Wei Yongjun In case of error, the function devm_ioremap_nocache() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Signed-off-by: Wei Yongjun --- drivers/usb/phy/phy-msm-usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index ced34f3..4843158 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -1599,8 +1599,8 @@ static int msm_otg_probe(struct platform_device *pdev) */ if (motg->phy_number) { phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4); - if (IS_ERR(phy_select)) - return PTR_ERR(phy_select); + if (!phy_select) + return -ENOMEM; /* Enable second PHY with the OTG port */ writel(0x1, phy_select); } -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH -next] usb: gadget: Fix return value check in r8a66597_probe()
From: Wei Yongjun In case of error, the function devm_ioremap_resource() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun --- drivers/usb/gadget/udc/r8a66597-udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 4600842..de2a871 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1868,8 +1868,8 @@ static int r8a66597_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg = devm_ioremap_resource(&pdev->dev, res); - if (!reg) - return -ENODEV; + if (IS_ERR(reg)) + return PTR_ERR(reg); ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0); irq = ires->start; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH -next] usb: gadget: Fix return value check in ep_write()
From: Wei Yongjun In case of error, the function memdup_user() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun --- drivers/usb/gadget/legacy/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c index 2e4ce77..e96077b 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -440,7 +440,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) value = -ENOMEM; kbuf = memdup_user(buf, len); - if (!kbuf) { + if (IS_ERR(kbuf)) { value = PTR_ERR(kbuf); goto free1; } -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: 3.14.12 and USB option_instat_callback with 3G DONGLE
On 2014-07-20 03:21, Greg KH wrote: On Sat, Jul 19, 2014 at 03:11:22PM +1000, ress...@ausics.net wrote: Since upgrading from 3.12.24 kernel to 3.14.10, and today, .12 kernel log and dmesg are flooded with constant messages option1 ttyUSB0: option_instat_callback: error -2 The device still works, it sends and receives SMS's as well, I tried setting verbose usb debug to see if it offers any more explanations, but it shows nothing more. The device is Huawei E160, but is identified as (and always has been) an E620 ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem Did somthing break between 3.12 and 3.14? Rather annoying at how fast and large kernel.log is geting. Any chance you can use 'git bisect' to try to find the problem commit in the kernel tree? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html There has only been one change to the option driver (apart from added device id's) and that is Johan Hovolds [PATCH 21/63] USB: option: fix runtime PM handling commit 5ff2117cf81c53f2b1e3e47a38451c792da4b330 His two other patches: [PATCH 22/63] USB: option: fix line-control pipe direction [PATCH 23/63] USB: option: add missing usb_mark_last_busy seems to have taken a detour, they are still not in stable or LTS Johan? -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: 3.14.12 and USB option_instat_callback with 3G DONGLE
On Sun, Jul 20, 2014 at 10:43:44AM +0700, Lars Melin wrote: > On 2014-07-20 03:21, Greg KH wrote: > >On Sat, Jul 19, 2014 at 03:11:22PM +1000, ress...@ausics.net wrote: > >>Since upgrading from 3.12.24 kernel to 3.14.10, and today, .12 kernel log > >>and dmesg are flooded with constant messages > >> > >>option1 ttyUSB0: option_instat_callback: error -2 > >> > >>The device still works, it sends and receives SMS's as well, > >>I tried setting verbose usb debug to see if it offers any more explanations, > >>but it shows nothing more. > >> > >>The device is Huawei E160, but is identified as (and always has been) an > >>E620 > >> > >>ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem > >> > >>Did somthing break between 3.12 and 3.14? Rather annoying at how fast and > >>large kernel.log is geting. > >Any chance you can use 'git bisect' to try to find the problem commit in > >the kernel tree? > > > >thanks, > > > >greg k-h > >-- > >To unsubscribe from this list: send the line "unsubscribe linux-usb" in > >the body of a message to majord...@vger.kernel.org > >More majordomo info at http://vger.kernel.org/majordomo-info.html > There has only been one change to the option driver (apart from added device > id's) and that is > Johan Hovolds > [PATCH 21/63] USB: option: fix runtime PM handling > commit 5ff2117cf81c53f2b1e3e47a38451c792da4b330 > > His two other patches: > [PATCH 22/63] USB: option: fix line-control pipe direction > [PATCH 23/63] USB: option: add missing usb_mark_last_busy > > seems to have taken a detour, they are still not in stable or LTS > Johan? Johan's on vacation, what are the git commit ids of these patches in Linus's tree? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH -next] usb: chipidea: debug: fix sparse non static symbol warnings
From: Wei Yongjun Fixes the following sparse warnings: drivers/usb/chipidea/debug.c:211:5: warning: symbol 'ci_otg_show' was not declared. Should it be static? drivers/usb/chipidea/debug.c:334:5: warning: symbol 'ci_registers_show' was not declared. Should it be static? Signed-off-by: Wei Yongjun --- drivers/usb/chipidea/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 7cccab6..795d653 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -208,7 +208,7 @@ static const struct file_operations ci_requests_fops = { .release= single_release, }; -int ci_otg_show(struct seq_file *s, void *unused) +static int ci_otg_show(struct seq_file *s, void *unused) { struct ci_hdrc *ci = s->private; struct otg_fsm *fsm; @@ -331,7 +331,7 @@ static const struct file_operations ci_role_fops = { .release= single_release, }; -int ci_registers_show(struct seq_file *s, void *unused) +static int ci_registers_show(struct seq_file *s, void *unused) { struct ci_hdrc *ci = s->private; u32 tmp_reg; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: 3.14.12 and USB option_instat_callback with 3G DONGLE
On 2014-07-20 11:10, Greg KH wrote: On Sun, Jul 20, 2014 at 10:43:44AM +0700, Lars Melin wrote: On 2014-07-20 03:21, Greg KH wrote: On Sat, Jul 19, 2014 at 03:11:22PM +1000, ress...@ausics.net wrote: Since upgrading from 3.12.24 kernel to 3.14.10, and today, .12 kernel log and dmesg are flooded with constant messages option1 ttyUSB0: option_instat_callback: error -2 The device still works, it sends and receives SMS's as well, I tried setting verbose usb debug to see if it offers any more explanations, but it shows nothing more. The device is Huawei E160, but is identified as (and always has been) an E620 ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem Did somthing break between 3.12 and 3.14? Rather annoying at how fast and large kernel.log is geting. Any chance you can use 'git bisect' to try to find the problem commit in the kernel tree? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html There has only been one change to the option driver (apart from added device id's) and that is Johan Hovolds [PATCH 21/63] USB: option: fix runtime PM handling commit 5ff2117cf81c53f2b1e3e47a38451c792da4b330 His two other patches: [PATCH 22/63] USB: option: fix line-control pipe direction [PATCH 23/63] USB: option: add missing usb_mark_last_busy seems to have taken a detour, they are still not in stable or LTS Johan? Johan's on vacation, what are the git commit ids of these patches in Linus's tree? thanks, greg k-h Aah, all 3 patches are taken in 3.16-rc1 http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/diff/drivers/usb/serial/option.c?id=e5c4ecdc55b6d824365ba7964bcd3185223f9688 and the runtime PM patch 21/63 also went to stable, so only one one culprit then. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb:serial:pl2303: add GPIOs interface on PL2303
PL2303HX has two GPIOs, this patch add interface for it. Signed-off-by: Wang YanQing --- Changes v1-v2: 1:drop gpio-pl2303.c and relation stuff 2:hang gpio stuff off of pl2303.c drivers/usb/serial/Kconfig | 7 ++ drivers/usb/serial/pl2303.c | 153 2 files changed, 160 insertions(+) diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 3ce5c74..099ff05 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig @@ -516,6 +516,13 @@ config USB_SERIAL_PL2303 To compile this driver as a module, choose M here: the module will be called pl2303. +config USB_SERIAL_PL2303_GPIO + bool "USB Prolific 2303 Single Port GPIOs support" + depends on USB_SERIAL_PL2303 + help + Say Y here if you want to use the GPIOs on PL2303 USB Serial single port + adapter from Prolific. + config USB_SERIAL_OTI6858 tristate "USB Ours Technology Inc. OTi-6858 USB To RS232 Bridge Controller" help diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index b3d5a35..1fbd338 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -28,6 +28,9 @@ #include #include #include +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO +#include +#endif #include "pl2303.h" @@ -143,9 +146,27 @@ struct pl2303_type_data { unsigned long quirks; }; +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO +struct pl2303_gpio { + /* +* 0..3: unknown (zero) +* 4: gp0 output enable (1: gp0 pin is output, 0: gp0 pin is input) +* 5: gp1 output enable (1: gp1 pin is output, 0: gp1 pin is input) +* 6: gp0 pin value +* 7: gp1 pin value +*/ + u8 index; + struct usb_serial *serial; + struct gpio_chip gpio_chip; +}; +#endif + struct pl2303_serial_private { const struct pl2303_type_data *type; unsigned long quirks; +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO + struct pl2303_gpio *gpio; +#endif }; struct pl2303_private { @@ -213,6 +234,100 @@ static int pl2303_probe(struct usb_serial *serial, return 0; } +#ifdef CONFIG_USB_SERIAL_PL2303_GPIO +static inline struct pl2303_gpio *to_pl2303_gpio(struct gpio_chip *chip) +{ + return container_of(chip, struct pl2303_gpio, gpio_chip); +} + +static int pl2303_gpio_direction_in(struct gpio_chip *chip, unsigned offset) +{ + struct pl2303_gpio *gpio = to_pl2303_gpio(chip); + + if (offset == 0) + gpio->index &= ~0x10; + else if (offset == 1) + gpio->index &= ~0x20; + else + return -EINVAL; + + pl2303_vendor_write(gpio->serial, 1, gpio->index); + return 0; +} + +static int pl2303_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) +{ + struct pl2303_gpio *gpio = to_pl2303_gpio(chip); + + if (offset == 0) { + gpio->index |= 0x10; + if (value) + gpio->index |= 0x40; + else + gpio->index &= ~0x40; + } else if (offset == 1) { + gpio->index |= 0x20; + if (value) + gpio->index |= 0x80; + else + gpio->index &= ~0x80; + } else { + return -EINVAL; + } + + pl2303_vendor_write(gpio->serial, 1, gpio->index); + return 0; +} + +static void pl2303_gpio_set(struct gpio_chip *chip, unsigned offset, int value) +{ + struct pl2303_gpio *gpio = to_pl2303_gpio(chip); + + if (offset == 0) { + if (value) + gpio->index |= 0x40; + else + gpio->index &= ~0x40; + } else if (offset == 1) { + if (value) + gpio->index |= 0x80; + else + gpio->index &= ~0x80; + } else { + return; + } + + pl2303_vendor_write(gpio->serial, 1, gpio->index); +} + +static int pl2303_gpio_get(struct gpio_chip *chip, unsigned offset) +{ + struct pl2303_gpio *gpio = to_pl2303_gpio(chip); + unsigned char buf[1]; + int value = 0; + + if(pl2303_vendor_read(gpio->serial, 0x0081, buf) < 1) + return -EIO; + if (offset == 0) + value = buf[0] & 0x40; + else if (offset == 1) + value = buf[0] & 0x80; + else + value = -EINVAL; + return value; +} + +static struct gpio_chip template_chip = { + .label = "pl2303-gpio", + .owner = THIS_MODULE, + .direction_input= pl2303_gpio_direction_in, + .get= pl2303_gpio_get, + .direction_output = pl2303_gpio_direction_out, + .set= pl2303_gpio_set, + .can_sleep = 1, +}; +#endif + static int pl2303_startup(struct usb_serial