Re: [PATCH] usb: dwc3: gadget: only unmap requests from DMA if mapped

2017-09-08 Thread Felipe Balbi
Thinh Nguyen  writes:

> Hi Felipe,
>
> On 9/7/2017 12:16 AM, Felipe Balbi wrote:
>drivers/usb/dwc3/gadget.c | 8 +---
>1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 9e41605a..6b299c7 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -191,14 +191,16 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, 
> struct dwc3_request *req,
>
>   req->started = false;
>   list_del(&req->list);
> - req->trb = NULL;
>   req->remaining = 0;
>
>   if (req->request.status == -EINPROGRESS)
>   req->request.status = status;
>
> - usb_gadget_unmap_request_by_dev(dwc->sysdev,
> - &req->request, req->direction);
> + if (req->trb)
 This check does not account for control data transfer. TRBs for ep0 are
 not set to its req->trb. ep0out request needs to be unmapped, otherwise
 device will receive bogus data.

 Our internal test showed that the device failed to interpret control
 data from host. I bisected to this patch.
>> 
>> what was the testing? How can I reproduce it?
>
> This is a regression. The internal test found the issue when it does a 
> 3-stage Control Write Transfer. You can reproduce this issue with just 1 
> out data packet of size > 0. Read and check the data on control request 
> completion.

okay, is this enough to fix the problem for you?

modified   drivers/usb/dwc3/ep0.c
@@ -48,6 +48,9 @@ static void dwc3_ep0_prepare_one_trb(struct dwc3_ep *dep,
dwc = dep->dwc;
trb = &dwc->ep0_trb[dep->trb_enqueue];
 
+   if (!req->trb)
+   req->trb = trb;
+
if (chain)
dep->trb_enqueue++;
 
-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: dwc3: gadget: only unmap requests from DMA if mapped

2017-09-08 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
> Thinh Nguyen  writes:
>
>> Hi Felipe,
>>
>> On 9/7/2017 12:16 AM, Felipe Balbi wrote:
>>drivers/usb/dwc3/gadget.c | 8 +---
>>1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 9e41605a..6b299c7 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -191,14 +191,16 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, 
>> struct dwc3_request *req,
>>
>>  req->started = false;
>>  list_del(&req->list);
>> -req->trb = NULL;
>>  req->remaining = 0;
>>
>>  if (req->request.status == -EINPROGRESS)
>>  req->request.status = status;
>>
>> -usb_gadget_unmap_request_by_dev(dwc->sysdev,
>> -&req->request, req->direction);
>> +if (req->trb)
> This check does not account for control data transfer. TRBs for ep0 are
> not set to its req->trb. ep0out request needs to be unmapped, otherwise
> device will receive bogus data.
>
> Our internal test showed that the device failed to interpret control
> data from host. I bisected to this patch.
>>> 
>>> what was the testing? How can I reproduce it?
>>
>> This is a regression. The internal test found the issue when it does a 
>> 3-stage Control Write Transfer. You can reproduce this issue with just 1 
>> out data packet of size > 0. Read and check the data on control request 
>> completion.
>
> okay, is this enough to fix the problem for you?
>
> modified   drivers/usb/dwc3/ep0.c
> @@ -48,6 +48,9 @@ static void dwc3_ep0_prepare_one_trb(struct dwc3_ep *dep,
>   dwc = dep->dwc;
>   trb = &dwc->ep0_trb[dep->trb_enqueue];
>  
> + if (!req->trb)
> + req->trb = trb;
> +
>   if (chain)
>   dep->trb_enqueue++;

sorry, no. this is totally wrong :-) Here's a better version:

modified   drivers/usb/dwc3/ep0.c
@@ -990,6 +990,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
 DWC3_TRBCTL_CONTROL_DATA,
 true);
 
+   req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1];
+
/* Now prepare one extra TRB to align transfer size */
dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
 maxpacket - rem,
@@ -1015,6 +1017,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
 DWC3_TRBCTL_CONTROL_DATA,
 true);
 
+   req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1];
+
/* Now prepare one extra TRB to align transfer size */
dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
 0, DWC3_TRBCTL_CONTROL_DATA,
@@ -1029,6 +1033,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
dwc3_ep0_prepare_one_trb(dep, req->request.dma,
req->request.length, DWC3_TRBCTL_CONTROL_DATA,
false);
+
+   req->trb = &dwc->ep0_trb[dep->trb_enqueue];
+
ret = dwc3_ep0_start_trans(dep);
}

(didn't even compile test)
 
-- 
balbi


signature.asc
Description: PGP signature


Re: RH Bugzilla - Bug 1482649 - Logitech USB Unified Receiver+M570 need 'waking' up by click after kernel update

2017-09-08 Thread Jiri Kosina
On Fri, 8 Sep 2017, Mike Simms wrote:

> Thanks for getting back to me,
> 
> 4.11.11-300.fc26.x86_64 and 4.12.9-300.fc26.x86_64
>  are showing identical settings - autosuspend definitely on for
> device /sys/bus/usb/devices/2-1.3/2-1.3:1.0/0003:046D:C52B.0001/power
> 
> it shows in the powertop UI as good for both kernels and
> 
> Folder contents are autosuspend_delay_ms (can't open), control (auto),
> runtime_active_time (0), runtime_status (unsupported),
> runtime_suspended_time (0)

Alright, that means that both kernels are allowed to autosuspend the 
device, but apparently only 4.12 actually does so. Could you please 
confirm that with usbmon traces?

Thanks,

-- 
Jiri Kosina
SUSE Labs

--
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 v4] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Jeffrey Chu
Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB device 
IDs to ftdi_sio driver

Signed-off-by: Jeffrey Chu 
---
 drivers/usb/serial/ftdi_sio.c | 2 ++
 drivers/usb/serial/ftdi_sio_ids.h | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c 
index 1cec037..49d1b2d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = {
 { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
 { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
+{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
 { }/* Terminating entry */
 };

diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
b/drivers/usb/serial/ftdi_sio_ids.h
index 4fcf1ce..d58dc1b 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -692,6 +692,13 @@
 #define WICED_USB20706V2_PID0x6422

 /*
+ * Cypress WICED USB UART
+ */
+#define CYPRESS_VID0x04B4
+#define CYPRESS_WICED_BT_USB_PID0x009B
+#define CYPRESS_WICED_WL_USB_PID0xF900
+
+/*
  * Definitions for ID TECH (www.idt-net.com) devices
  */
 #define IDTECH_VID0x0ACD/* ID TECH Vendor ID */
--
2.7.4

This message and any attachments may contain confidential information from 
Cypress or its subsidiaries. If it has been received in error, please advise 
the sender and immediately delete this message.
--
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: [PATCH v4] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Greg KH
On Fri, Sep 08, 2017 at 12:27:41PM +, Jeffrey Chu wrote:
> Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB device 
> IDs to ftdi_sio driver

Please wrap your changelog at the proper colums (72).

> 
> Signed-off-by: Jeffrey Chu 
> ---
>  drivers/usb/serial/ftdi_sio.c | 2 ++
>  drivers/usb/serial/ftdi_sio_ids.h | 7 +++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c 
> index 1cec037..49d1b2d 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = 
> {
>  { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
>  { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
>  .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
> +{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
> +{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
>  { }/* Terminating entry */
>  };

Your patch is corrupted and can not be applied :(

Also always use scripts/get_maintainer.pl to determine who to cc: on the
patch (hint, you missed the maintainer of this subsystem...)

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 v5] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Jeffrey Chu
Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB
device IDs to ftdi_sio driver

Signed-off-by: Jeffrey Chu 
---
 drivers/usb/serial/ftdi_sio.c | 2 ++
 drivers/usb/serial/ftdi_sio_ids.h | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1cec037..49d1b2d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = {
 { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
 { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
+{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
 { }/* Terminating entry */
 };

diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
b/drivers/usb/serial/ftdi_sio_ids.h
index 4fcf1ce..d58dc1b 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -692,6 +692,13 @@
 #define WICED_USB20706V2_PID0x6422

 /*
+ * Cypress WICED USB UART
+ */
+#define CYPRESS_VID0x04B4
+#define CYPRESS_WICED_BT_USB_PID0x009B
+#define CYPRESS_WICED_WL_USB_PID0xF900
+
+/*
  * Definitions for ID TECH (www.idt-net.com) devices
  */
 #define IDTECH_VID0x0ACD/* ID TECH Vendor ID */
--
2.7.4


---
This message and any attachments may contain Cypress (or its
subsidiaries) confidential information. If it has been received
in error, please advise the sender and immediately delete this
message.
---


This message and any attachments may contain confidential information from 
Cypress or its subsidiaries. If it has been received in error, please advise 
the sender and immediately delete this message.
--
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: [PATCH v5] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Greg KH
On Fri, Sep 08, 2017 at 02:35:03PM +, Jeffrey Chu wrote:
> Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB
> device IDs to ftdi_sio driver
> 
> Signed-off-by: Jeffrey Chu 
> ---
>  drivers/usb/serial/ftdi_sio.c | 2 ++
>  drivers/usb/serial/ftdi_sio_ids.h | 7 +++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
> index 1cec037..49d1b2d 100644
> --- a/drivers/usb/serial/ftdi_sio.c
> +++ b/drivers/usb/serial/ftdi_sio.c
> @@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = 
> {
>  { USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
>  { USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
>  .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
> +{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
> +{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },

Patch is still corrupted :(

Please try sending it to yourself first to verify you have your email
client set up correctly.

Or just use git send-email, that will also "just work".

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


RE: [PATCH v5] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread David Laight
> To: Jeffrey Chu
..
> Patch is still corrupted :(
> 
> Please try sending it to yourself first to verify you have your email
> client set up correctly.

If you are forced to send from outlook, try copy & paste from wordpad.

David

--
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 v1 01/10] clk: at91: pmc: Wait for clocks when resuming

2017-09-08 Thread Romain Izard
Wait for the syncronization of all clocks when resuming, not only the
UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
when interrupts are masked, which is the case in here.

Signed-off-by: Romain Izard 
---
 drivers/clk/at91/pmc.c | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 775af473fe11..5c2b26de303e 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -107,10 +107,20 @@ static int pmc_suspend(void)
return 0;
 }
 
+static bool pmc_ready(unsigned int mask)
+{
+   unsigned int status;
+
+   regmap_read(pmcreg, AT91_PMC_SR, &status);
+
+   return ((status & mask) == mask) ? 1 : 0;
+}
+
 static void pmc_resume(void)
 {
-   int i, ret = 0;
+   int i;
u32 tmp;
+   u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
 
regmap_read(pmcreg, AT91_PMC_MCKR, &tmp);
if (pmc_cache.mckr != tmp)
@@ -134,13 +144,11 @@ static void pmc_resume(void)
 AT91_PMC_PCR_CMD);
}
 
-   if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
-   ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
-  !(tmp & AT91_PMC_LOCKU),
-  10, 5000);
-   if (ret)
-   pr_crit("USB PLL didn't lock when resuming\n");
-   }
+   if (pmc_cache.uckr & AT91_PMC_UPLLEN)
+   mask |= AT91_PMC_LOCKU;
+
+   while (!pmc_ready(mask))
+   cpu_relax();
 }
 
 static struct syscore_ops pmc_syscore_ops = {
-- 
2.11.0

--
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 v1 08/10] pwm: atmel-tcb: Support backup mode

2017-09-08 Thread Romain Izard
Save and restore registers for the PWM on suspend and resume, which
makes hibernation and backup modes possible.

Signed-off-by: Romain Izard 
---
 drivers/pwm/pwm-atmel-tcb.c | 63 +++--
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 75db585a2a94..acd3ce8ecf3f 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -37,11 +37,20 @@ struct atmel_tcb_pwm_device {
unsigned period;/* PWM period expressed in clk cycles */
 };
 
+struct atmel_tcb_channel {
+   u32 enabled;
+   u32 cmr;
+   u32 ra;
+   u32 rb;
+   u32 rc;
+};
+
 struct atmel_tcb_pwm_chip {
struct pwm_chip chip;
spinlock_t lock;
struct atmel_tc *tc;
struct atmel_tcb_pwm_device *pwms[NPWM];
+   struct atmel_tcb_channel bkup[NPWM / 2];
 };
 
 static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip)
@@ -175,12 +184,15 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, 
struct pwm_device *pwm)
 * Use software trigger to apply the new setting.
 * If both PWM devices in this group are disabled we stop the clock.
 */
-   if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
+   if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) {
__raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
 regs + ATMEL_TC_REG(group, CCR));
-   else
+   tcbpwmc->bkup[group].enabled = 1;
+   } else {
__raw_writel(ATMEL_TC_SWTRG, regs +
 ATMEL_TC_REG(group, CCR));
+   tcbpwmc->bkup[group].enabled = 0;
+   }
 
spin_unlock(&tcbpwmc->lock);
 }
@@ -263,6 +275,7 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, 
struct pwm_device *pwm)
/* Use software trigger to apply the new setting */
__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
 regs + ATMEL_TC_REG(group, CCR));
+   tcbpwmc->bkup[group].enabled = 1;
spin_unlock(&tcbpwmc->lock);
return 0;
 }
@@ -445,10 +458,56 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] = 
{
 };
 MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
 
+#ifdef CONFIG_PM_SLEEP
+static int atmel_tcb_pwm_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+   void __iomem *base = tcbpwm->tc->regs;
+   int i;
+
+   for (i = 0; i < (NPWM / 2); i++) {
+   struct atmel_tcb_channel *chan = &tcbpwm->bkup[i];
+
+   chan->cmr = readl(base + ATMEL_TC_REG(i, CMR));
+   chan->ra = readl(base + ATMEL_TC_REG(i, RA));
+   chan->rb = readl(base + ATMEL_TC_REG(i, RB));
+   chan->rc = readl(base + ATMEL_TC_REG(i, RC));
+   }
+   return 0;
+}
+
+static int atmel_tcb_pwm_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+   void __iomem *base = tcbpwm->tc->regs;
+   int i;
+
+   for (i = 0; i < (NPWM / 2); i++) {
+   struct atmel_tcb_channel *chan = &tcbpwm->bkup[i];
+
+   writel(chan->cmr, base + ATMEL_TC_REG(i, CMR));
+   writel(chan->ra, base + ATMEL_TC_REG(i, RA));
+   writel(chan->rb, base + ATMEL_TC_REG(i, RB));
+   writel(chan->rc, base + ATMEL_TC_REG(i, RC));
+   if (chan->enabled) {
+   writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
+   base + ATMEL_TC_REG(i, CCR));
+   }
+   }
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
+atmel_tcb_pwm_resume);
+
 static struct platform_driver atmel_tcb_pwm_driver = {
.driver = {
.name = "atmel-tcb-pwm",
.of_match_table = atmel_tcb_pwm_dt_ids,
+   .pm = &atmel_tcb_pwm_pm_ops,
},
.probe = atmel_tcb_pwm_probe,
.remove = atmel_tcb_pwm_remove,
-- 
2.11.0

--
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 v1 09/10] atmel_flexcom: Support backup mode

2017-09-08 Thread Romain Izard
The controller used by a flexcom module is configured at boot, and left
alone after this. As the configuration will be lost after backup mode,
restore the state of the flexcom driver on resume.

Signed-off-by: Romain Izard 
---
 drivers/mfd/atmel-flexcom.c | 65 ++---
 1 file changed, 50 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/atmel-flexcom.c b/drivers/mfd/atmel-flexcom.c
index 064bde9cff5a..ef1235c4a179 100644
--- a/drivers/mfd/atmel-flexcom.c
+++ b/drivers/mfd/atmel-flexcom.c
@@ -39,34 +39,44 @@
 #define FLEX_MR_OPMODE(opmode) (((opmode) << FLEX_MR_OPMODE_OFFSET) &  \
 FLEX_MR_OPMODE_MASK)
 
+struct atmel_flexcom {
+   void __iomem *base;
+   u32 opmode;
+   struct clk *clk;
+};
 
 static int atmel_flexcom_probe(struct platform_device *pdev)
 {
struct device_node *np = pdev->dev.of_node;
-   struct clk *clk;
struct resource *res;
-   void __iomem *base;
-   u32 opmode;
+   struct atmel_flexcom *afc;
int err;
+   u32 val;
+
+   afc = devm_kzalloc(&pdev->dev, sizeof(*afc), GFP_KERNEL);
+   if (!afc)
+   return -ENOMEM;
 
-   err = of_property_read_u32(np, "atmel,flexcom-mode", &opmode);
+   platform_set_drvdata(pdev, afc);
+
+   err = of_property_read_u32(np, "atmel,flexcom-mode", &afc->opmode);
if (err)
return err;
 
-   if (opmode < ATMEL_FLEXCOM_MODE_USART ||
-   opmode > ATMEL_FLEXCOM_MODE_TWI)
+   if (afc->opmode < ATMEL_FLEXCOM_MODE_USART ||
+   afc->opmode > ATMEL_FLEXCOM_MODE_TWI)
return -EINVAL;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   base = devm_ioremap_resource(&pdev->dev, res);
-   if (IS_ERR(base))
-   return PTR_ERR(base);
+   afc->base = devm_ioremap_resource(&pdev->dev, res);
+   if (IS_ERR(afc->base))
+   return PTR_ERR(afc->base);
 
-   clk = devm_clk_get(&pdev->dev, NULL);
-   if (IS_ERR(clk))
-   return PTR_ERR(clk);
+   afc->clk = devm_clk_get(&pdev->dev, NULL);
+   if (IS_ERR(afc->clk))
+   return PTR_ERR(afc->clk);
 
-   err = clk_prepare_enable(clk);
+   err = clk_prepare_enable(afc->clk);
if (err)
return err;
 
@@ -76,9 +86,10 @@ static int atmel_flexcom_probe(struct platform_device *pdev)
 * inaccessible and are read as zero. Also the external I/O lines of the
 * Flexcom are muxed to reach the selected device.
 */
-   writel(FLEX_MR_OPMODE(opmode), base + FLEX_MR);
+   val = FLEX_MR_OPMODE(afc->opmode);
+   writel(val, afc->base + FLEX_MR);
 
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(afc->clk);
 
return devm_of_platform_populate(&pdev->dev);
 }
@@ -89,10 +100,34 @@ static const struct of_device_id atmel_flexcom_of_match[] 
= {
 };
 MODULE_DEVICE_TABLE(of, atmel_flexcom_of_match);
 
+#ifdef CONFIG_PM_SLEEP
+static int atmel_flexcom_resume(struct device *dev)
+{
+   struct atmel_flexcom *afc = dev_get_drvdata(dev);
+   int err;
+   u32 val;
+
+   err = clk_prepare_enable(afc->clk);
+   if (err)
+   return err;
+
+   val = FLEX_MR_OPMODE(afc->opmode),
+   writel(val, afc->base + FLEX_MR);
+
+   clk_disable_unprepare(afc->clk);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_flexcom_pm_ops, NULL,
+atmel_flexcom_resume);
+
 static struct platform_driver atmel_flexcom_driver = {
.probe  = atmel_flexcom_probe,
.driver = {
.name   = "atmel_flexcom",
+   .pm = &atmel_flexcom_pm_ops,
.of_match_table = atmel_flexcom_of_match,
},
 };
-- 
2.11.0

--
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 v1 07/10] iio:adc:at91-sama5d2: Support backup mode

2017-09-08 Thread Romain Izard
Support the backup mode for platform suspend, by restoring the hardware
registers on resume.

Signed-off-by: Romain Izard 
---
 drivers/iio/adc/at91-sama5d2_adc.c | 71 --
 1 file changed, 61 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c 
b/drivers/iio/adc/at91-sama5d2_adc.c
index e10dca3ed74b..f9718c863363 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -200,6 +200,7 @@ struct at91_adc_state {
u32 conversion_value;
struct at91_adc_soc_infosoc_info;
wait_queue_head_t   wq_data_available;
+   unsigned intcurrent_rate;
/*
 * lock to prevent concurrent 'single conversion' requests through
 * sysfs.
@@ -269,6 +270,8 @@ static void at91_adc_setup_samp_freq(struct at91_adc_state 
*st, unsigned freq)
mr |= AT91_SAMA5D2_MR_PRESCAL(prescal);
at91_adc_writel(st, AT91_SAMA5D2_MR, mr);
 
+   st->current_rate = freq;
+
dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
freq, startup, prescal);
 }
@@ -375,7 +378,9 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
val > st->soc_info.max_sample_rate)
return -EINVAL;
 
+   mutex_lock(&st->lock);
at91_adc_setup_samp_freq(st, val);
+   mutex_unlock(&st->lock);
 
return 0;
 }
@@ -386,6 +391,21 @@ static const struct iio_info at91_adc_info = {
.driver_module = THIS_MODULE,
 };
 
+static void at91_adc_init_hw(struct at91_adc_state *st, unsigned int freq)
+{
+   at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
+   at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
+   /*
+* Transfer field must be set to 2 according to the datasheet and
+* allows different analog settings for each channel.
+*/
+   at91_adc_writel(st, AT91_SAMA5D2_MR,
+   AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
+
+   at91_adc_setup_samp_freq(st, freq);
+
+}
+
 static int at91_adc_probe(struct platform_device *pdev)
 {
struct iio_dev *indio_dev;
@@ -482,16 +502,7 @@ static int at91_adc_probe(struct platform_device *pdev)
goto vref_disable;
}
 
-   at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
-   at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
-   /*
-* Transfer field must be set to 2 according to the datasheet and
-* allows different analog settings for each channel.
-*/
-   at91_adc_writel(st, AT91_SAMA5D2_MR,
-   AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
-
-   at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
+   at91_adc_init_hw(st, st->soc_info.min_sample_rate);
 
ret = clk_prepare_enable(st->per_clk);
if (ret)
@@ -541,12 +552,52 @@ static const struct of_device_id at91_adc_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, at91_adc_dt_match);
 
+#ifdef CONFIG_PM_SLEEP
+static int at91_adc_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+   struct at91_adc_state *st = iio_priv(indio_dev);
+
+   clk_disable_unprepare(st->per_clk);
+
+   regulator_disable(st->vref);
+   regulator_disable(st->reg);
+
+   return 0;
+}
+
+static int at91_adc_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+   struct at91_adc_state *st = iio_priv(indio_dev);
+   int err;
+
+   err = regulator_enable(st->reg);
+   if (err)
+   return err;
+
+   err = regulator_enable(st->vref);
+   if (err)
+   return err;
+
+   at91_adc_init_hw(st, st->current_rate);
+
+   err = clk_prepare_enable(st->per_clk);
+   return err;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
+
 static struct platform_driver at91_adc_driver = {
.probe = at91_adc_probe,
.remove = at91_adc_remove,
.driver = {
.name = "at91-sama5d2_adc",
.of_match_table = at91_adc_dt_match,
+   .pm = &at91_adc_pm_ops,
},
 };
 module_platform_driver(at91_adc_driver)
-- 
2.11.0

--
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 v1 10/10] tty/serial: atmel: Prevent a warning on suspend

2017-09-08 Thread Romain Izard
The atmel serial port driver reported the following warning on suspend:
atmel_usart f802.serial: ttyS1: Unable to drain transmitter

As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared
when the transmitter is disabled, we need to know the transmitter's
state to return the real fifo state. And as ATMEL_US_CR is write-only,
it is necessary to save the state of the transmitter in a local
variable, and update the variable when TXEN and TXDIS is written in
ATMEL_US_CR.

After those changes, atmel_tx_empty can return "empty" on suspend, the
warning in uart_suspend_port disappears, and suspending is 20ms shorter
for each enabled Atmel serial port.

Signed-off-by: Romain Izard 
---
 drivers/tty/serial/atmel_serial.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/tty/serial/atmel_serial.c 
b/drivers/tty/serial/atmel_serial.c
index 7551cab438ff..195c0d1b594e 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -171,6 +171,7 @@ struct atmel_uart_port {
boolhas_hw_timer;
struct timer_list   uart_timer;
 
+   booltx_stopped;
boolsuspended;
unsigned intpending;
unsigned intpending_status;
@@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,
  */
 static u_int atmel_tx_empty(struct uart_port *port)
 {
+   struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+   if (atmel_port->tx_stopped)
+   return TIOCSER_TEMT;
return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
TIOCSER_TEMT :
0;
@@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)
 * is fully transmitted.
 */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
+   atmel_port->tx_stopped = true;
 
/* Disable interrupts */
atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
@@ -492,6 +498,7 @@ static void atmel_stop_tx(struct uart_port *port)
if ((port->rs485.flags & SER_RS485_ENABLED) &&
!(port->rs485.flags & SER_RS485_RX_DURING_TX))
atmel_start_rx(port);
+
 }
 
 /*
@@ -521,6 +528,7 @@ static void atmel_start_tx(struct uart_port *port)
 
/* re-enable the transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+   atmel_port->tx_stopped = false;
 }
 
 /*
@@ -1866,6 +1874,7 @@ static int atmel_startup(struct uart_port *port)
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
/* enable xmit & rcvr */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
setup_timer(&atmel_port->uart_timer,
atmel_uart_timer_callback,
@@ -2122,6 +2131,7 @@ static void atmel_set_termios(struct uart_port *port, 
struct ktermios *termios,
 
/* disable receiver and transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
+   atmel_port->tx_stopped = true;
 
/* mode */
if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -2207,6 +2217,7 @@ static void atmel_set_termios(struct uart_port *port, 
struct ktermios *termios,
atmel_uart_writel(port, ATMEL_US_BRGR, quot);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
/* restore interrupts */
atmel_uart_writel(port, ATMEL_US_IER, imr);
@@ -2450,6 +2461,7 @@ static void atmel_console_write(struct console *co, const 
char *s, u_int count)
 
/* Make sure that tx path is actually able to send characters */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+   atmel_port->tx_stopped = false;
 
uart_console_write(port, s, count, atmel_console_putchar);
 
@@ -2528,6 +2540,7 @@ static int __init atmel_console_setup(struct console *co, 
char *options)
atmel_uart_writel(port, ATMEL_US_IDR, -1);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+   atmel_port->tx_stopped = false;
 
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
-- 
2.11.0

--
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 v1 04/10] mtd: nand: atmel: Avoid ECC errors when leaving backup mode

2017-09-08 Thread Romain Izard
During backup mode, the contents of all registers will be cleared as the
SoC will be completely powered down. For a product that boots on NAND
Flash memory, the bootloader will obviously use the related controller
to read the Flash and correct any detected error in the memory, before
handling back control to the kernel's resuming entry point.

In normal devices, it is up to the driver's suspend/resume code to
restore the registers in a valid state. But the PMECC is not a regular
device in the driver model when used with the legacy device tree binding
for the Atmel NAND controller, and suspend/resume code is not called.

As in my case the bootloader leaves the PMECC controller in a programmed
state, and the controller is only reset at boot or after a NAND access,
the first NAND Flash access with the Atmel controller will report
uncorrectable ECC errors.

To avoid this, systematically reset the PMECC controller before using
it.

Signed-off-by: Romain Izard 
---
 drivers/mtd/nand/atmel/pmecc.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c
index 8c210a5776bc..8d1208f38025 100644
--- a/drivers/mtd/nand/atmel/pmecc.c
+++ b/drivers/mtd/nand/atmel/pmecc.c
@@ -777,6 +777,9 @@ int atmel_pmecc_enable(struct atmel_pmecc_user *user, int 
op)
 
mutex_lock(&user->pmecc->lock);
 
+   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
+   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
+
cfg = user->cache.cfg;
if (op == NAND_ECC_WRITE)
cfg |= PMECC_CFG_WRITE_OP;
@@ -797,10 +800,6 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable);
 
 void atmel_pmecc_disable(struct atmel_pmecc_user *user)
 {
-   struct atmel_pmecc *pmecc = user->pmecc;
-
-   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
-   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
mutex_unlock(&user->pmecc->lock);
 }
 EXPORT_SYMBOL_GPL(atmel_pmecc_disable);
@@ -856,10 +855,6 @@ static struct atmel_pmecc *atmel_pmecc_create(struct 
platform_device *pdev,
/* Disable all interrupts before registering the PMECC handler. */
writel(0x, pmecc->regs.base + ATMEL_PMECC_IDR);
 
-   /* Reset the ECC engine */
-   writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
-   writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
-
return pmecc;
 }
 
-- 
2.11.0

--
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 v1 06/10] ehci-atmel: Power down during suspend is normal

2017-09-08 Thread Romain Izard
When an Atmel SoC is suspended with the backup mode, the USB bus will be
powered down. As this is expected, do not return an error to the driver
core when ehci_resume detects it.

Signed-off-by: Romain Izard 
---
 drivers/usb/host/ehci-atmel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 7440722bfbf0..2a8b9bdc0e57 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -205,7 +205,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct 
device *dev)
struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
 
atmel_start_clock(atmel_ehci);
-   return ehci_resume(hcd, false);
+   ehci_resume(hcd, false);
+   return 0;
 }
 
 #ifdef CONFIG_OF
-- 
2.11.0

--
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 v1 05/10] mtd: nand: atmel: Report PMECC failures as errors

2017-09-08 Thread Romain Izard
It is not normal for the PMECC to fail when trying to fix ECC errors.
Report these cases as errors.

Signed-off-by: Romain Izard 
---
 drivers/mtd/nand/atmel/pmecc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c
index 8d1208f38025..2a23f1ff945f 100644
--- a/drivers/mtd/nand/atmel/pmecc.c
+++ b/drivers/mtd/nand/atmel/pmecc.c
@@ -687,6 +687,8 @@ static int atmel_pmecc_err_location(struct atmel_pmecc_user 
*user)
 * Number of roots does not match the degree of smu
 * unable to correct error.
 */
+   dev_err(pmecc->dev,
+   "PMECC: Impossible to calculate error location.\n");
return -EBADMSG;
 }
 
@@ -729,7 +731,7 @@ int atmel_pmecc_correct_sector(struct atmel_pmecc_user 
*user, int sector,
ptr = ecc + byte - sectorsize;
area = "ECC";
} else {
-   dev_dbg(pmecc->dev,
+   dev_err(pmecc->dev,
"Invalid errpos value (%d, max is %d)\n",
errpos, (sectorsize + eccbytes) * 8);
return -EINVAL;
-- 
2.11.0

--
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 v1 03/10] clk: at91: pmc: Support backup for programmable clocks

2017-09-08 Thread Romain Izard
From: Romain Izard 

Save and restore the System Clock and Programmable Clock register for
the backup use case.

Signed-off-by: Romain Izard 
---
 drivers/clk/at91/pmc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 07dc2861ad3f..5421b03553ec 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -66,6 +66,7 @@ static struct
u32 pcr[PMC_MAX_IDS];
u32 audio_pll0;
u32 audio_pll1;
+   u32 pckr[3];
 } pmc_cache;
 
 void pmc_register_id(u8 id)
@@ -103,6 +104,8 @@ static int pmc_suspend(void)
regmap_read(pmcreg, AT91_PMC_PCR,
&pmc_cache.pcr[registered_ids[i]]);
}
+   for (i = 0; i < 3; i++)
+   regmap_read(pmcreg, AT91_PMC_PCKR(i), &pmc_cache.pckr[i]);
 
return 0;
 }
@@ -143,6 +146,8 @@ static void pmc_resume(void)
 pmc_cache.pcr[registered_ids[i]] |
 AT91_PMC_PCR_CMD);
}
+   for (i = 0; i < 3; i++)
+   regmap_write(pmcreg, AT91_PMC_PCKR(i), pmc_cache.pckr[i]);
 
if (pmc_cache.uckr & AT91_PMC_UPLLEN)
mask |= AT91_PMC_LOCKU;
-- 
2.11.0

--
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 v1 00/10] Various patches for SAMA5D2 backup mode

2017-09-08 Thread Romain Izard
While the core of the backup mode for SAMA5D2 has been integrated in
v4.13, it is far from complete. Individual controllers in the chip have
drivers that do not support the reset of the registers during suspend,
and they need to be adapted to handle it.

The first patch uses the clock wakeup code from the prototype backup
mode instead of the version integrated in the mainline, as the mainline
version is not stable. During a test loop with two-second backup
suspend, the mainline version will hang in less than one day, whereas
the prototype version has been running the same test for more than a
week without hanging.

Romain Izard (10):
  clk: at91: pmc: Wait for clocks when resuming
  clk: at91: pmc: Save SCSR during suspend
  clk: at91: pmc: Support backup for programmable clocks
  mtd: nand: atmel: Avoid ECC errors when leaving backup mode
  mtd: nand: atmel: Report PMECC failures as errors
  ehci-atmel: Power down during suspend is normal
  iio:adc:at91-sama5d2: Support backup mode
  pwm: atmel-tcb: Support backup mode
  atmel_flexcom: Support backup mode
  tty/serial: atmel: Prevent a warning on suspend

 drivers/clk/at91/pmc.c | 33 --
 drivers/iio/adc/at91-sama5d2_adc.c | 71 --
 drivers/mfd/atmel-flexcom.c| 65 ++
 drivers/mtd/nand/atmel/pmecc.c | 15 
 drivers/pwm/pwm-atmel-tcb.c| 63 +++--
 drivers/tty/serial/atmel_serial.c  | 13 +++
 drivers/usb/host/ehci-atmel.c  |  3 +-
 7 files changed, 216 insertions(+), 47 deletions(-)

-- 
2.11.0

--
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 v1 02/10] clk: at91: pmc: Save SCSR during suspend

2017-09-08 Thread Romain Izard
The contents of the System Clock Status Register (SCSR) needs to be
restored into the System Clock Enable Register (SCER).

As the bootloader will restore some clocks by itself, the issue can be
missed as only the USB controller, the LCD controller, the Image Sensor
controller and the programmable clocks will be impacted.

Fix the obvious typo in the suspend/resume code, as the IMR register
does not need to be saved twice.

Signed-off-by: Romain Izard 
---
 drivers/clk/at91/pmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 5c2b26de303e..07dc2861ad3f 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -86,7 +86,7 @@ static int pmc_suspend(void)
 {
int i;
 
-   regmap_read(pmcreg, AT91_PMC_IMR, &pmc_cache.scsr);
+   regmap_read(pmcreg, AT91_PMC_SCSR, &pmc_cache.scsr);
regmap_read(pmcreg, AT91_PMC_PCSR, &pmc_cache.pcsr0);
regmap_read(pmcreg, AT91_CKGR_UCKR, &pmc_cache.uckr);
regmap_read(pmcreg, AT91_CKGR_MOR, &pmc_cache.mor);
@@ -129,7 +129,7 @@ static void pmc_resume(void)
if (pmc_cache.pllar != tmp)
pr_warn("PLLAR was not configured properly by the firmware\n");
 
-   regmap_write(pmcreg, AT91_PMC_IMR, pmc_cache.scsr);
+   regmap_write(pmcreg, AT91_PMC_SCER, pmc_cache.scsr);
regmap_write(pmcreg, AT91_PMC_PCER, pmc_cache.pcsr0);
regmap_write(pmcreg, AT91_CKGR_UCKR, pmc_cache.uckr);
regmap_write(pmcreg, AT91_CKGR_MOR, pmc_cache.mor);
-- 
2.11.0

--
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 1/2] mux: add mux_control_get_optional() API

2017-09-08 Thread Peter Rosin
From: Stephen Boyd 

Sometimes drivers only use muxes under certain scenarios. For
example, the chipidea usb controller may be connected to a usb
switch on some platforms, and connected directly to a usb port on
others. The driver won't know one way or the other though, so add
a mux_control_get_optional() API that allows the driver to
differentiate errors getting the mux from there not being a mux
for the driver to use at all.
---
 Documentation/driver-model/devres.txt |   1 +
 drivers/mux/core.c| 104 +++---
 include/linux/mux/consumer.h  |   4 ++
 3 files changed, 89 insertions(+), 20 deletions(-)

I haven't tested this patch, and hence I have not signed it and I also
removed the sign-off from Stephen...

Cheers,
peda

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index 30e04f7a690d..4fdd3e63ff8b 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -342,6 +342,7 @@ MUX
   devm_mux_chip_alloc()
   devm_mux_chip_register()
   devm_mux_control_get()
+  devm_mux_control_get_optional()
 
 PER-CPU MEM
   devm_alloc_percpu()
diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 2260063b0ea8..2eb234300669 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -289,6 +289,9 @@ EXPORT_SYMBOL_GPL(devm_mux_chip_register);
  */
 unsigned int mux_control_states(struct mux_control *mux)
 {
+   if (!mux)
+   return 0;
+
return mux->states;
 }
 EXPORT_SYMBOL_GPL(mux_control_states);
@@ -338,6 +341,9 @@ int mux_control_select(struct mux_control *mux, unsigned 
int state)
 {
int ret;
 
+   if (!mux)
+   return 0;
+
ret = down_killable(&mux->lock);
if (ret < 0)
return ret;
@@ -370,6 +376,9 @@ int mux_control_try_select(struct mux_control *mux, 
unsigned int state)
 {
int ret;
 
+   if (!mux)
+   return 0;
+
if (down_trylock(&mux->lock))
return -EBUSY;
 
@@ -398,6 +407,9 @@ int mux_control_deselect(struct mux_control *mux)
 {
int ret = 0;
 
+   if (!mux)
+   return 0;
+
if (mux->idle_state != MUX_IDLE_AS_IS &&
mux->idle_state != mux->cached_state)
ret = mux_control_set(mux, mux->idle_state);
@@ -422,14 +434,8 @@ static struct mux_chip *of_find_mux_chip_by_node(struct 
device_node *np)
return dev ? to_mux_chip(dev) : NULL;
 }
 
-/**
- * mux_control_get() - Get the mux-control for a device.
- * @dev: The device that needs a mux-control.
- * @mux_name: The name identifying the mux-control.
- *
- * Return: A pointer to the mux-control, or an ERR_PTR with a negative errno.
- */
-struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
+static struct mux_control *
+__mux_control_get(struct device *dev, const char *mux_name, bool optional)
 {
struct device_node *np = dev->of_node;
struct of_phandle_args args;
@@ -441,16 +447,22 @@ struct mux_control *mux_control_get(struct device *dev, 
const char *mux_name)
if (mux_name) {
index = of_property_match_string(np, "mux-control-names",
 mux_name);
+   if ((index == -EINVAL || index == -ENODATA) && optional)
+   return NULL;
if (index < 0) {
dev_err(dev, "mux controller '%s' not found\n",
mux_name);
return ERR_PTR(index);
}
+   /* OF does point to a mux, so it's no longer optional */
+   optional = false;
}
 
ret = of_parse_phandle_with_args(np,
 "mux-controls", "#mux-control-cells",
 index, &args);
+   if (ret == -ENOENT && optional)
+   return NULL;
if (ret) {
dev_err(dev, "%pOF: failed to get mux-control %s(%i)\n",
np, mux_name ?: "", index);
@@ -482,9 +494,36 @@ struct mux_control *mux_control_get(struct device *dev, 
const char *mux_name)
get_device(&mux_chip->dev);
return &mux_chip->mux[controller];
 }
+
+/**
+ * mux_control_get() - Get the mux-control for a device.
+ * @dev: The device that needs a mux-control.
+ * @mux_name: The name identifying the mux-control.
+ *
+ * Return: A pointer to the mux-control, or an ERR_PTR with a negative errno.
+ */
+struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
+{
+   return __mux_control_get(dev, mux_name, false);
+}
 EXPORT_SYMBOL_GPL(mux_control_get);
 
 /**
+ * mux_control_get_optional() - Get the optional mux-control for a device.
+ * @dev: The device that needs a mux-control.
+ * @mux_name: The name identifying the mux-control.
+ *
+ * Return: NULL if no mux with the provided name is found, a pointer to
+ * the name

Re: [PATCH v2 05/11] mux: Add Intel Cherrytrail USB mux driver

2017-09-08 Thread Peter Rosin
On 2017-09-05 18:42, Hans de Goede wrote:
> Intel Cherrytrail SoCs have an internal USB mux for muxing the otg-port
> USB data lines between the xHCI host controller and the dwc3 gadget
> controller. On some Cherrytrail systems this mux is controlled through
> AML code reacting on a GPIO IRQ connected to the USB OTG id pin (through
> an _AIE ACPI method) so things just work.
> 
> But on other Cherrytrail systems we need to control the mux ourselves
> this driver exports the mux through the mux subsys, so that other drivers
> can control it if necessary.
> 
> This driver also updates the vbus-valid reporting to the dwc3 gadget
> controller, as this uses the same registers as the mux. This is needed
> for gadget/device mode to work properly (even on systems which control
> the mux from their AML code).
> 
> Note this depends on the xhci driver registering a platform device
> named "intel_cht_usb_mux", which has an IOMEM resource 0 which points
> to the Intel Vendor Defined XHCI extended capabilities region.
> 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2:
> -Complete rewrite as a stand-alone platform-driver rather then as a phy
>  driver, since this is just a mux, not a phy
> 
> Changes in v3:
> -Make this a mux subsys driver instead of listening to USB_HOST extcon
>  cable events and responding to those
> 
> Changes in v4 (of patch, v2 of new mux based series):
> -Rename C-file to use - in name
> -Add MAINTAINERS entry
> -Various code-style fixes
> ---
>  MAINTAINERS |   5 +
>  drivers/mux/Kconfig |  11 ++
>  drivers/mux/Makefile|  10 +-
>  drivers/mux/intel-cht-usb-mux.c | 257 
> 
>  4 files changed, 279 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/mux/intel-cht-usb-mux.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 14a2fd905217..dfaed958db85 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8991,6 +8991,11 @@ F: include/linux/dt-bindings/mux/
>  F:   include/linux/mux/
>  F:   drivers/mux/
>  
> +MULTIPLEXER SUBSYSTEM INTEL CHT USB MUX DRIVER
> +M:   Hans de Goede 
> +S:   Maintained
> +F:   drivers/mix/intel-cht-usb-mux.c

s/mix/mux/

(also in patch 06/11)

> +
>  MULTISOUND SOUND DRIVER
>  M:   Andrew Veliath 
>  S:   Maintained
> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> index 19e4e904c9bf..947cfd7af02a 100644
> --- a/drivers/mux/Kconfig
> +++ b/drivers/mux/Kconfig
> @@ -34,6 +34,17 @@ config MUX_GPIO
> To compile the driver as a module, choose M here: the module will
> be called mux-gpio.
>  
> +config MUX_INTEL_CHT_USB_MUX
> + tristate "Intel Cherrytrail USB Multiplexer"
> + depends on ACPI && X86 && EXTCON
> + help
> +   This driver adds support for the internal USB mux for muxing the OTG
> +   USB data lines between the xHCI host controller and the dwc3 gadget
> +   controller found on Intel Cherrytrail SoCs.
> +
> +   To compile the driver as a module, choose M here: the module will
> +   be called mux-intel_cht_usb_mux.

s/_/-/g

> +
>  config MUX_MMIO
>   tristate "MMIO register bitfield-controlled Multiplexer"
>   depends on (OF && MFD_SYSCON) || COMPILE_TEST
> diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
> index 0e1e59760e3f..6cf41be2754f 100644
> --- a/drivers/mux/Makefile
> +++ b/drivers/mux/Makefile
> @@ -5,9 +5,11 @@
>  mux-core-objs:= core.o
>  mux-adg792a-objs := adg792a.o
>  mux-gpio-objs:= gpio.o
> +mux-intel-cht-usb-mux-objs   := intel-cht-usb-mux.o
>  mux-mmio-objs:= mmio.o
>  
> -obj-$(CONFIG_MULTIPLEXER)+= mux-core.o
> -obj-$(CONFIG_MUX_ADG792A)+= mux-adg792a.o
> -obj-$(CONFIG_MUX_GPIO)   += mux-gpio.o
> -obj-$(CONFIG_MUX_MMIO)   += mux-mmio.o
> +obj-$(CONFIG_MULTIPLEXER)+= mux-core.o
> +obj-$(CONFIG_MUX_ADG792A)+= mux-adg792a.o
> +obj-$(CONFIG_MUX_GPIO)   += mux-gpio.o
> +obj-$(CONFIG_MUX_INTEL_CHT_USB_MUX)  += mux-intel-cht-usb-mux.o
> +obj-$(CONFIG_MUX_MMIO)   += mux-mmio.o
> diff --git a/drivers/mux/intel-cht-usb-mux.c b/drivers/mux/intel-cht-usb-mux.c
> new file mode 100644
> index ..9cd1a1f5027f
> --- /dev/null
> +++ b/drivers/mux/intel-cht-usb-mux.c
> @@ -0,0 +1,257 @@
> +/*
> + * Intel Cherrytrail USB OTG MUX driver
> + *
> + * Copyright (c) 2016 Hans de Goede 

2017?

> + *
> + * Loosely based on android x86 kernel code which is:
> + *
> + * Copyright (C) 2014 Intel Corp.
> + *
> + * Author: Wu, Hao
> + *
> + * 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, or (at your option)
> + * any later version.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +

Re: [PATCH v2 04/11] usb: xhci: Add Intel cherrytrail extended cap / otg phy mux handling

2017-09-08 Thread Peter Rosin
On 2017-09-05 18:42, Hans de Goede wrote:
> The Intel cherrytrail xhci controller has an extended cap mmio-range
> which contains registers to control the muxing to the xhci (host mode)
> or the dwc3 (device mode) and vbus-detection for the otg usb-phy.
> 
> Having a mux driver included in the xhci code (or under drivers/usb/host)
> is not desirable. So this commit adds a simple handler for this extended
> capability, which creates a platform device with the caps mmio region as
> resource, this allows us to write a separate platform mux driver for the
> mux.
> 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2:
> -Check xHCI controller PCI device-id instead of only checking for the
>  Intel Extended capability ID, as the Extended capability ID is used on
>  other model Intel xHCI controllers too
> ---
>  drivers/usb/host/Makefile|  2 +-
>  drivers/usb/host/xhci-intel-quirks.c | 85 
> 
>  drivers/usb/host/xhci-pci.c  |  4 ++
>  drivers/usb/host/xhci.h  |  2 +
>  4 files changed, 92 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/usb/host/xhci-intel-quirks.c
> 
> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
> index cf2691fffcc0..441edf82eb1c 100644
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -63,7 +63,7 @@ obj-$(CONFIG_USB_OHCI_HCD_DAVINCI)  += ohci-da8xx.o
>  obj-$(CONFIG_USB_UHCI_HCD)   += uhci-hcd.o
>  obj-$(CONFIG_USB_FHCI_HCD)   += fhci.o
>  obj-$(CONFIG_USB_XHCI_HCD)   += xhci-hcd.o
> -obj-$(CONFIG_USB_XHCI_PCI)   += xhci-pci.o
> +obj-$(CONFIG_USB_XHCI_PCI)   += xhci-pci.o xhci-intel-quirks.o
>  obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
>  obj-$(CONFIG_USB_XHCI_MTK)   += xhci-mtk.o
>  obj-$(CONFIG_USB_XHCI_TEGRA) += xhci-tegra.o
> diff --git a/drivers/usb/host/xhci-intel-quirks.c 
> b/drivers/usb/host/xhci-intel-quirks.c
> new file mode 100644
> index ..819f5f9da9ee
> --- /dev/null
> +++ b/drivers/usb/host/xhci-intel-quirks.c
> @@ -0,0 +1,85 @@
> +/*
> + * Intel Vendor Defined XHCI extended capability handling
> + *
> + * Copyright (c) 2016) Hans de Goede 

2017? And drop the stray bracket.

Cheers,
Peter
--
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 2/2] mux: add explicit hook to leave the mux as-is on init/registration

2017-09-08 Thread Peter Rosin
A board may need a mux controller to stay as-is for a while longer, e.g.
if setting the normally preferred idle state destroys booting.

The mechanism provided here is not perfect in two ways.
1. As soon as the mux controller is registered, some mux consumer can
   access it and set a state that destroys booting all the same.
2. The mux controller might linger in a state that is not the
   preferred idle state indefinitely, if no mux consumer ever selects
   and then deselects the mux.
---
 drivers/mux/core.c | 3 +++
 include/linux/mux/driver.h | 4 
 2 files changed, 7 insertions(+)

Untested -> no sign-off, and I'm also really unsure about it because of
the imperfections mentioned in the commit message.

Cheers,
peda

diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 2eb234300669..c81db7d4f9c8 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -155,6 +155,9 @@ int mux_chip_register(struct mux_chip *mux_chip)
for (i = 0; i < mux_chip->controllers; ++i) {
struct mux_control *mux = &mux_chip->mux[i];
 
+   if (mux->init_as_is)
+   continue;
+
if (mux->idle_state == mux->cached_state)
continue;
 
diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h
index 35c3579c3304..21cf6041a962 100644
--- a/include/linux/mux/driver.h
+++ b/include/linux/mux/driver.h
@@ -36,6 +36,9 @@ struct mux_control_ops {
  * @states:The number of mux controller states.
  * @idle_state:The mux controller state to use when inactive, 
or one
  * of MUX_IDLE_AS_IS and MUX_IDLE_DISCONNECT.
+ * @init_as_is:Set to true to have the core leave the mux 
controller
+ * state as-is until first selection. If @idle_state is
+ * MUX_IDLE_AS_IS, @init_as_is is irrelevant.
  *
  * Mux drivers may only change @states and @idle_state, and may only do so
  * between allocation and registration of the mux controller. Specifically,
@@ -50,6 +53,7 @@ struct mux_control {
 
unsigned int states;
int idle_state;
+   bool init_as_is;
 };
 
 /**
-- 
2.11.0

--
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: [PATCH v2 03/11] mux: core: Add usb.h header with MUX_USB_* and and MUX_TYPEC_* state constants

2017-09-08 Thread Peter Rosin
On 2017-09-05 18:42, Hans de Goede wrote:
> Add MUX_USB_* and MUX_TYPEC_* state constant defines, which can be used by
> USB device/host, resp. Type-C polarity/role/altmode mux drivers and
> consumers to ensure that they agree on the meaning of the
> mux_control_select() state argument.
> 
> Signed-off-by: Hans de Goede 
> ---
> Changes in v2:
> -Start numbering of defines at 0 not 1
> -Use a new usb.h header, rather then adding these to consumer.h
> -Add separate MUX_USB_* and MUX_TYPEC_* defines
> ---
>  include/linux/mux/usb.h | 32 
>  1 file changed, 32 insertions(+)
>  create mode 100644 include/linux/mux/usb.h
> 
> diff --git a/include/linux/mux/usb.h b/include/linux/mux/usb.h
> new file mode 100644
> index ..44df5eca5256
> --- /dev/null
> +++ b/include/linux/mux/usb.h
> @@ -0,0 +1,32 @@
> +/*
> + * mux/usb.h - definitions for USB multiplexers
> + *
> + * Copyright (C) 2017 Hans de Goede 
> + *
> + * 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.
> + */
> +#ifndef _LINUX_MUX_USB_H
> +#define _LINUX_MUX_USB_H
> +
> +/* Mux state values for USB device/host role muxes */
> +#define MUX_USB_DEVICE   (0) /* USB device mode */
> +#define MUX_USB_HOST (1) /* USB host mode */
> +#define MUX_USB_STATES   (2)
> +
> +/*
> + * Mux state values for Type-C polarity/role/altmode muxes.
> + *
> + * MUX_TYPEC_POLARITY_INV may be or-ed together with any other mux-state as
> + * inverted-polarity (Type-C plugged in upside down) can happen with any
> + * other mux-state.
> + */
> +#define MUX_TYPEC_POLARITY_INV   BIT(0)   /* Polarity inverted 
> bit */
> +#define MUX_TYPEC_DEVICE (0 << 1) /* USB device mode */
> +#define MUX_TYPEC_HOST   (1 << 1) /* USB host mode */
> +#define MUX_TYPEC_HOST_AND_DP_SRC(2 << 1) /* USB host + 2 lanes DP src */
> +#define MUX_TYPEC_DP_SRC (3 << 1) /* 4 lanes Display Port src */
> +#define MUX_TYPEC_STATES (4 << 1)

But USB Type-C muxes need not support just these states If I read it right?
USB Type-C seems to be usable for a variety of protocols and the above list
seems pretty much like a special case for this mux (and perhaps a set of
other similar muxes). But when someone with a USB Type-C mux for different
protocols shows up, that person will probably be frustrated by these
defines, no? Or is there something I don't see that limits USB-C to DP?

Cheers,
Peter

> +
> +#endif /* _LINUX_MUX_TYPEC_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


Re: [PATCH 1/2] mux: add mux_control_get_optional() API

2017-09-08 Thread Peter Rosin
On 2017-09-08 17:45, Peter Rosin wrote:
> From: Stephen Boyd 
> 
> Sometimes drivers only use muxes under certain scenarios. For
> example, the chipidea usb controller may be connected to a usb
> switch on some platforms, and connected directly to a usb port on
> others. The driver won't know one way or the other though, so add
> a mux_control_get_optional() API that allows the driver to
> differentiate errors getting the mux from there not being a mux
> for the driver to use at all.
> ---
>  Documentation/driver-model/devres.txt |   1 +
>  drivers/mux/core.c| 104 
> +++---
>  include/linux/mux/consumer.h  |   4 ++
>  3 files changed, 89 insertions(+), 20 deletions(-)
> 
> I haven't tested this patch, and hence I have not signed it and I also
> removed the sign-off from Stephen...

Huh, I definitely intended to mention that this patch is based on [1]
from Stephen, but that I've made changes according to the comments in
that thread (and more). And those changes are what made me remove the
sign-off from Stephen...

Sorry for the noise,
Peter

[1] https://lkml.org/lkml/2017/7/14/655
--
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: [PATCH v1 07/10] iio:adc:at91-sama5d2: Support backup mode

2017-09-08 Thread Nicolas Ferre
On 08/09/2017 at 17:36, Romain Izard wrote:
> Support the backup mode for platform suspend, by restoring the hardware
> registers on resume.
> 
> Signed-off-by: Romain Izard 

Romain,

Thanks for your series: definitively some of your patches need to be
integrated (I've merged some of them in our current linux-4.9-at91 branch.
However, It seems that some of your additions have already been
submitted and/or accepted by maintainers.
For instance an equivalent of this one seems already in Linus' tree:
500a2eefd6b16ba141a8fb777ea6962d2eb65e3b ("iio: adc: at91-sama5d2_adc:
add support for suspend/resume functionality").

Please tell us if it fits what your observed on this driver (or others).

Regards,

> ---
>  drivers/iio/adc/at91-sama5d2_adc.c | 71 
> --
>  1 file changed, 61 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c 
> b/drivers/iio/adc/at91-sama5d2_adc.c
> index e10dca3ed74b..f9718c863363 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
> @@ -200,6 +200,7 @@ struct at91_adc_state {
>   u32 conversion_value;
>   struct at91_adc_soc_infosoc_info;
>   wait_queue_head_t   wq_data_available;
> + unsigned intcurrent_rate;
>   /*
>* lock to prevent concurrent 'single conversion' requests through
>* sysfs.
> @@ -269,6 +270,8 @@ static void at91_adc_setup_samp_freq(struct 
> at91_adc_state *st, unsigned freq)
>   mr |= AT91_SAMA5D2_MR_PRESCAL(prescal);
>   at91_adc_writel(st, AT91_SAMA5D2_MR, mr);
>  
> + st->current_rate = freq;
> +
>   dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
>   freq, startup, prescal);
>  }
> @@ -375,7 +378,9 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
>   val > st->soc_info.max_sample_rate)
>   return -EINVAL;
>  
> + mutex_lock(&st->lock);
>   at91_adc_setup_samp_freq(st, val);
> + mutex_unlock(&st->lock);
>  
>   return 0;
>  }
> @@ -386,6 +391,21 @@ static const struct iio_info at91_adc_info = {
>   .driver_module = THIS_MODULE,
>  };
>  
> +static void at91_adc_init_hw(struct at91_adc_state *st, unsigned int freq)
> +{
> + at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
> + at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
> + /*
> +  * Transfer field must be set to 2 according to the datasheet and
> +  * allows different analog settings for each channel.
> +  */
> + at91_adc_writel(st, AT91_SAMA5D2_MR,
> + AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
> +
> + at91_adc_setup_samp_freq(st, freq);
> +
> +}
> +
>  static int at91_adc_probe(struct platform_device *pdev)
>  {
>   struct iio_dev *indio_dev;
> @@ -482,16 +502,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>   goto vref_disable;
>   }
>  
> - at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
> - at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
> - /*
> -  * Transfer field must be set to 2 according to the datasheet and
> -  * allows different analog settings for each channel.
> -  */
> - at91_adc_writel(st, AT91_SAMA5D2_MR,
> - AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
> -
> - at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
> + at91_adc_init_hw(st, st->soc_info.min_sample_rate);
>  
>   ret = clk_prepare_enable(st->per_clk);
>   if (ret)
> @@ -541,12 +552,52 @@ static const struct of_device_id at91_adc_dt_match[] = {
>  };
>  MODULE_DEVICE_TABLE(of, at91_adc_dt_match);
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int at91_adc_suspend(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct at91_adc_state *st = iio_priv(indio_dev);
> +
> + clk_disable_unprepare(st->per_clk);
> +
> + regulator_disable(st->vref);
> + regulator_disable(st->reg);
> +
> + return 0;
> +}
> +
> +static int at91_adc_resume(struct device *dev)
> +{
> + struct platform_device *pdev = to_platform_device(dev);
> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> + struct at91_adc_state *st = iio_priv(indio_dev);
> + int err;
> +
> + err = regulator_enable(st->reg);
> + if (err)
> + return err;
> +
> + err = regulator_enable(st->vref);
> + if (err)
> + return err;
> +
> + at91_adc_init_hw(st, st->current_rate);
> +
> + err = clk_prepare_enable(st->per_clk);
> + return err;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
> +
>  static struct platform_driver at91_adc_driver = {
>   .probe = at91_adc_probe,
>   .remove = at91_adc_remove,
>   .driver = {
>   .nam

Re: [PATCH v1 07/10] iio:adc:at91-sama5d2: Support backup mode

2017-09-08 Thread Romain Izard
2017-09-08 18:03 GMT+02:00 Nicolas Ferre :
> On 08/09/2017 at 17:36, Romain Izard wrote:
>> Support the backup mode for platform suspend, by restoring the hardware
>> registers on resume.
>>
>> Signed-off-by: Romain Izard 
>
> Romain,
>
> Thanks for your series: definitively some of your patches need to be
> integrated (I've merged some of them in our current linux-4.9-at91 branch.
> However, It seems that some of your additions have already been
> submitted and/or accepted by maintainers.
> For instance an equivalent of this one seems already in Linus' tree:
> 500a2eefd6b16ba141a8fb777ea6962d2eb65e3b ("iio: adc: at91-sama5d2_adc:
> add support for suspend/resume functionality").
>
> Please tell us if it fits what your observed on this driver (or others).
>
> Regards,
>
>> ---
>>  drivers/iio/adc/at91-sama5d2_adc.c | 71 
>> --
>>  1 file changed, 61 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c 
>> b/drivers/iio/adc/at91-sama5d2_adc.c
>> index e10dca3ed74b..f9718c863363 100644
>> --- a/drivers/iio/adc/at91-sama5d2_adc.c
>> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
>> @@ -200,6 +200,7 @@ struct at91_adc_state {
>>   u32 conversion_value;
>>   struct at91_adc_soc_infosoc_info;
>>   wait_queue_head_t   wq_data_available;
>> + unsigned intcurrent_rate;
>>   /*
>>* lock to prevent concurrent 'single conversion' requests through
>>* sysfs.
>> @@ -269,6 +270,8 @@ static void at91_adc_setup_samp_freq(struct 
>> at91_adc_state *st, unsigned freq)
>>   mr |= AT91_SAMA5D2_MR_PRESCAL(prescal);
>>   at91_adc_writel(st, AT91_SAMA5D2_MR, mr);
>>
>> + st->current_rate = freq;
>> +
>>   dev_dbg(&indio_dev->dev, "freq: %u, startup: %u, prescal: %u\n",
>>   freq, startup, prescal);
>>  }
>> @@ -375,7 +378,9 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev,
>>   val > st->soc_info.max_sample_rate)
>>   return -EINVAL;
>>
>> + mutex_lock(&st->lock);
>>   at91_adc_setup_samp_freq(st, val);
>> + mutex_unlock(&st->lock);
>>
>>   return 0;
>>  }
>> @@ -386,6 +391,21 @@ static const struct iio_info at91_adc_info = {
>>   .driver_module = THIS_MODULE,
>>  };
>>
>> +static void at91_adc_init_hw(struct at91_adc_state *st, unsigned int freq)
>> +{
>> + at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
>> + at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
>> + /*
>> +  * Transfer field must be set to 2 according to the datasheet and
>> +  * allows different analog settings for each channel.
>> +  */
>> + at91_adc_writel(st, AT91_SAMA5D2_MR,
>> + AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
>> +
>> + at91_adc_setup_samp_freq(st, freq);
>> +
>> +}
>> +
>>  static int at91_adc_probe(struct platform_device *pdev)
>>  {
>>   struct iio_dev *indio_dev;
>> @@ -482,16 +502,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>>   goto vref_disable;
>>   }
>>
>> - at91_adc_writel(st, AT91_SAMA5D2_CR, AT91_SAMA5D2_CR_SWRST);
>> - at91_adc_writel(st, AT91_SAMA5D2_IDR, 0x);
>> - /*
>> -  * Transfer field must be set to 2 according to the datasheet and
>> -  * allows different analog settings for each channel.
>> -  */
>> - at91_adc_writel(st, AT91_SAMA5D2_MR,
>> - AT91_SAMA5D2_MR_TRANSFER(2) | AT91_SAMA5D2_MR_ANACH);
>> -
>> - at91_adc_setup_samp_freq(st, st->soc_info.min_sample_rate);
>> + at91_adc_init_hw(st, st->soc_info.min_sample_rate);
>>
>>   ret = clk_prepare_enable(st->per_clk);
>>   if (ret)
>> @@ -541,12 +552,52 @@ static const struct of_device_id at91_adc_dt_match[] = 
>> {
>>  };
>>  MODULE_DEVICE_TABLE(of, at91_adc_dt_match);
>>
>> +#ifdef CONFIG_PM_SLEEP
>> +static int at91_adc_suspend(struct device *dev)
>> +{
>> + struct platform_device *pdev = to_platform_device(dev);
>> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>> + struct at91_adc_state *st = iio_priv(indio_dev);
>> +
>> + clk_disable_unprepare(st->per_clk);
>> +
>> + regulator_disable(st->vref);
>> + regulator_disable(st->reg);
>> +
>> + return 0;
>> +}
>> +
>> +static int at91_adc_resume(struct device *dev)
>> +{
>> + struct platform_device *pdev = to_platform_device(dev);
>> + struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>> + struct at91_adc_state *st = iio_priv(indio_dev);
>> + int err;
>> +
>> + err = regulator_enable(st->reg);
>> + if (err)
>> + return err;
>> +
>> + err = regulator_enable(st->vref);
>> + if (err)
>> + return err;
>> +
>> + at91_adc_init_hw(st, st->current_rate);
>> +
>> + err = clk_prepare_enable(st->per_clk);
>> + return err;
>> +}
>> +#endif
>> +
>> +static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, 

RE: Outlook Web app for Staff

2017-09-08 Thread Sam Rasheed-Hiscoke



From: Sam Rasheed-Hiscoke
Sent: Saturday, 9 September 2017 2:00 a.m.
To: Sam Rasheed-Hiscoke
Subject: Outlook Web app for Staff

Welcome to the new outlook web app for Staff

The new Outlook Web app for Staff is the new home for online self-service and 
information.
Click on Login 
here and 
login to:
· Access the new staff directory
· Access your pay slips and P60s
· Update your ID photo
· E-mail and Calendar Flexibility
· Connect mobile number to e-mail for Voicemail.
This email may contain privileged or confidential information. If you are not 
the intended recipient please delete the message, and any attachments, and 
notify the sender. Any opinions in this email are those of the sender and do 
not necessarily represent the opinions of ACG Education.
--
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: [PATCH v2 03/11] mux: core: Add usb.h header with MUX_USB_* and and MUX_TYPEC_* state constants

2017-09-08 Thread Hans de Goede

Hi,

On 08-09-17 17:47, Peter Rosin wrote:

On 2017-09-05 18:42, Hans de Goede wrote:

Add MUX_USB_* and MUX_TYPEC_* state constant defines, which can be used by
USB device/host, resp. Type-C polarity/role/altmode mux drivers and
consumers to ensure that they agree on the meaning of the
mux_control_select() state argument.

Signed-off-by: Hans de Goede 
---
Changes in v2:
-Start numbering of defines at 0 not 1
-Use a new usb.h header, rather then adding these to consumer.h
-Add separate MUX_USB_* and MUX_TYPEC_* defines
---
  include/linux/mux/usb.h | 32 
  1 file changed, 32 insertions(+)
  create mode 100644 include/linux/mux/usb.h

diff --git a/include/linux/mux/usb.h b/include/linux/mux/usb.h
new file mode 100644
index ..44df5eca5256
--- /dev/null
+++ b/include/linux/mux/usb.h
@@ -0,0 +1,32 @@
+/*
+ * mux/usb.h - definitions for USB multiplexers
+ *
+ * Copyright (C) 2017 Hans de Goede 
+ *
+ * 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.
+ */
+#ifndef _LINUX_MUX_USB_H
+#define _LINUX_MUX_USB_H
+
+/* Mux state values for USB device/host role muxes */
+#define MUX_USB_DEVICE (0) /* USB device mode */
+#define MUX_USB_HOST   (1) /* USB host mode */
+#define MUX_USB_STATES (2)
+
+/*
+ * Mux state values for Type-C polarity/role/altmode muxes.
+ *
+ * MUX_TYPEC_POLARITY_INV may be or-ed together with any other mux-state as
+ * inverted-polarity (Type-C plugged in upside down) can happen with any
+ * other mux-state.
+ */
+#define MUX_TYPEC_POLARITY_INV BIT(0)   /* Polarity inverted bit */
+#define MUX_TYPEC_DEVICE   (0 << 1) /* USB device mode */
+#define MUX_TYPEC_HOST (1 << 1) /* USB host mode */
+#define MUX_TYPEC_HOST_AND_DP_SRC  (2 << 1) /* USB host + 2 lanes DP src */
+#define MUX_TYPEC_DP_SRC   (3 << 1) /* 4 lanes Display Port src */
+#define MUX_TYPEC_STATES   (4 << 1)


But USB Type-C muxes need not support just these states If I read it right?
USB Type-C seems to be usable for a variety of protocols and the above list
seems pretty much like a special case for this mux (and perhaps a set of
other similar muxes). But when someone with a USB Type-C mux for different
protocols shows up, that person will probably be frustrated by these
defines, no? Or is there something I don't see that limits USB-C to DP?


In general almost all hardware is limited to the above (+ analog audio over
the 2 Sideband use pins, but I expect that to have a separate mux).

You're right, theoretically there might be other cases, e.g. there is a spec
for HDMI over Type-C (wishful thinking from the HDMI group, no one uses this),
but:

1) I expect most muxes to implement the above set, that is what all
hardware out there supports (well that or less).

2) We can always add extra defines here, that means that a Type-C mux may
not implement all states and return -EINVAL when asked for something it
does not implement, which I understand is a bit weird from a mux subsys
pov. But that can be the case anyways because even though the mux supports
these options, the board it is used on does no necessarily have to support
these options, e.g. there may be only 2 lanes of DP hooked up to the mux
(or no DP at all, but then I would them to expect a different mux).

So the Type-C Port Manager already needs to be passed some platform
data describing which features the board has and keep that in mind
when negotiation with the dongle attached to the Type-C port, so if
we do get boards which do HDMI and no DP, then the TCPM would simply
never use the MUX_TYPEC_HOST_AND_DP_SRC and MUX_TYPEC_DP_SRC states.

Regards,

Hans
--
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: xhci bandwidth problem with isochronous endpoints

2017-09-08 Thread Curt Meyers

On 09/05/2017 02:56 PM, Curt Meyers wrote:

On 09/04/2017 04:13 AM, Mathias Nyman wrote:

On 04.09.2017 13:46, Felipe Balbi wrote:


Hi,

Mathias Nyman  writes:
Unfortunately config endpoint command doesn't log endpoint context 
in this log,
it should call  trace_xhci_handle_cmd_config_ep(ep_ctx), I don't 
know why it's missing.


That's called conditionally:

case TRB_CONFIG_EP:
if (!cmd->completion)
xhci_handle_cmd_config_ep(xhci, slot_id, event,
  cmd_comp_code);


Yep, need to change the tracing so we get it for every config 
endpoint command




But later on at Set TR Dequeue Pointer Command it logs the endpiont 
context:


259.147237: xhci_handle_cmd_set_deq: RS 0 super-speed Ctx 
Entries 7 MEL 512 us Port# 19/0 [TT Slot 0 Port# 0 TTT 0 Intr 0] 
Addr 1 State configured
259.147238: xhci_handle_cmd_set_deq_ep: State stopped mult 1 max P. 
Streams 0 interval 125 us max ESIT payload 201326592 CErr 0 Type 
Isoc IN burst 2 maxp 1024 deq 0003f9fd6510 avg trb len 3072


This looks odd,  201326592 bytes per ESIT, way too much. So much 
that I suspect tracing decodes it wrong


try this:

modified   drivers/usb/host/xhci.h
@@ -2540,9 +2540,7 @@ static inline const char 
*xhci_decode_ep_context(u32 info, u32 info2, u64 deq,

  u8 lsa;
  u8 hid;

-esit = EP_MAX_ESIT_PAYLOAD_HI(info) << 16 |
-EP_MAX_ESIT_PAYLOAD_LO(tx_info);
-
+esit = CTX_TO_MAX_ESIT_PAYLOAD(info);
  ep_state = info & EP_STATE_MASK;
  max_pstr = info & EP_MAXPSTREAMS_MASK;
  interval = CTX_TO_EP_INTERVAL(info);



Yes, I noticed the same, and there's also a high ESIT bit field for 
new hosts,

I pushed a fix to my for-usb-linus branch for that

+#define CTX_TO_MAX_ESIT_PAYLOAD_HI(p)  (((p) >> 24) & 0xff)

...

-   esit = EP_MAX_ESIT_PAYLOAD_HI(info) << 16 |
-   EP_MAX_ESIT_PAYLOAD_LO(tx_info);
+   esit = CTX_TO_MAX_ESIT_PAYLOAD_HI(info) << 16 |
+   CTX_TO_MAX_ESIT_PAYLOAD(tx_info);

-Mathias

Hi Mathias,

I have made the above suggested changed and produced a new trace file. 
I hope this helps out.


Curt

Would it help if I sent you a couple of these USB camera devices to 
speed up debugging?


Curt
--
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] HID: usbhid: get/put around clearing needs_remote_wakeup

2017-09-08 Thread Dmitry Torokhov
From: Benson Leung 

usbhid->intf->needs_remote_wakeup is set when a device is opened, and is
cleared when a device is closed.

In usbhid_open, usb_autopm_get_interface is called before setting the
needs_remote_wakeup flag, and usb_autopm_put_interface is called after
hid_start_in. However, when the device is closed in usbhid_close, we
simply reset the flag and the device stays awake even though it could be
suspended.

This patch adds calls to usb_autopm_get_interface and
usb_autopm_put_interface when we reset usbhid->intf->needs_remote_wakeup
flag, giving the system chance to put the device to sleep.

Signed-off-by: Benson Leung 
Signed-off-by: Dmitry Torokhov 
---
 drivers/hid/usbhid/hid-core.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 089bad8a9a21..174d87f0e3e6 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -729,6 +729,7 @@ static int usbhid_open(struct hid_device *hid)
 static void usbhid_close(struct hid_device *hid)
 {
struct usbhid_device *usbhid = hid->driver_data;
+   int autopm_error;
 
/*
 * Make sure we don't restart data acquisition due to
@@ -745,8 +746,14 @@ static void usbhid_close(struct hid_device *hid)
return;
 
hid_cancel_delayed_stuff(usbhid);
+
+   autopm_error = usb_autopm_get_interface(usbhid->intf);
+
usb_kill_urb(usbhid->urbin);
usbhid->intf->needs_remote_wakeup = 0;
+
+   if (!autopm_error)
+   usb_autopm_put_interface(usbhid->intf);
 }
 
 /*
@@ -1176,13 +1183,18 @@ static int usbhid_start(struct hid_device *hid)
 static void usbhid_stop(struct hid_device *hid)
 {
struct usbhid_device *usbhid = hid->driver_data;
+   int autopm_error;
 
if (WARN_ON(!usbhid))
return;
 
if (hid->quirks & HID_QUIRK_ALWAYS_POLL) {
clear_bit(HID_IN_POLLING, &usbhid->iofl);
+
+   autopm_error = usb_autopm_get_interface(usbhid->intf);
usbhid->intf->needs_remote_wakeup = 0;
+   if (!autopm_error)
+   usb_autopm_put_interface(usbhid->intf);
}
 
clear_bit(HID_STARTED, &usbhid->iofl);
-- 
2.14.1.581.gf28d330327-goog


-- 
Dmitry
--
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 v7] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Jeffrey Chu



This message and any attachments may contain confidential information from 
Cypress or its subsidiaries. If it has been received in error, please advise 
the sender and immediately delete this message.
>From 891fe3887b53d2bad35d3f94c845ecb89ab58509 Mon Sep 17 00:00:00 2001
From: Jeffrey Chu 
Date: Thu, 10 Aug 2017 15:15:17 -0400
Subject: [PATCH v7] usb: serial: add vid:pid for Cypress WICED dev board

Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB
device IDs to ftdi_sio driver

Signed-off-by: Jeffrey Chu 
---
 drivers/usb/serial/ftdi_sio.c | 2 ++
 drivers/usb/serial/ftdi_sio_ids.h | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1cec037..49d1b2d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = {
 	{ USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
 	{ USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
 		.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+	{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
+	{ USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
 	{ }	/* Terminating entry */
 };
 
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 4fcf1ce..d58dc1b 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -692,6 +692,13 @@
 #define WICED_USB20706V2_PID	0x6422
 
 /*
+ * Cypress WICED USB UART
+ */
+#define CYPRESS_VID		0x04B4
+#define CYPRESS_WICED_BT_USB_PID	0x009B
+#define CYPRESS_WICED_WL_USB_PID	0xF900
+
+/*
  * Definitions for ID TECH (www.idt-net.com) devices
  */
 #define IDTECH_VID		0x0ACD	/* ID TECH Vendor ID */
-- 
2.7.4



Re: [PATCH v7] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Greg Kroah-Hartman
On Fri, Sep 08, 2017 at 10:03:37AM -0400, Jeffrey Chu wrote:
> 
> 
> This message and any attachments may contain confidential information from 
> Cypress or its subsidiaries. If it has been received in error, please advise 
> the sender and immediately delete this message.

I'm advising you that I'm deleting this email.
--
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


T230 and T230C DVB-C broken on Linux 4.12>

2017-09-08 Thread François
The device isn't able to scan any DVB-C channel anymore, and the
following error appears:
usb 1-7: DVB: adapter 0 frontend 0 frequency 0 out of range

The cable is fine (tried a few others as well), it just impossible to
get any signal.

I think the device is hard bricket, don't recommend upgrading when
using this device.
--
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: [PATCH v7] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Jeffrey Chu
You did not receive this email message in error.  You are the intended 
recipient of this email message.  Everything included in this email message do 
not contain confidential information from Cypress or its subsidiaries.

Regards,

-Jeffrey

-Original Message-
From: linux-usb-ow...@vger.kernel.org [mailto:linux-usb-ow...@vger.kernel.org] 
On Behalf Of Greg Kroah-Hartman
Sent: Friday, September 8, 2017 3:13 PM
To: Jeffrey Chu 
Cc: Johan Hovold ; linux-usb@vger.kernel.org; 
linux-ker...@vger.kernel.org
Subject: Re: [PATCH v7] usb: serial: add vid:pid for Cypress WICED dev board

On Fri, Sep 08, 2017 at 10:03:37AM -0400, Jeffrey Chu wrote:
>
>
> This message and any attachments may contain confidential information from 
> Cypress or its subsidiaries. If it has been received in error, please advise 
> the sender and immediately delete this message.

I'm advising you that I'm deleting this email.
--
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

This message and any attachments may contain confidential information from 
Cypress or its subsidiaries. If it has been received in error, please advise 
the sender and immediately delete this message.
--
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: RH Bugzilla - Bug 1482649 - Logitech USB Unified Receiver+M570 need 'waking' up by click after kernel update

2017-09-08 Thread Alan Stern
On Fri, 8 Sep 2017, Jiri Kosina wrote:

> On Fri, 8 Sep 2017, Mike Simms wrote:
> 
> > Thanks for getting back to me,
> > 
> > 4.11.11-300.fc26.x86_64 and 4.12.9-300.fc26.x86_64
> >  are showing identical settings - autosuspend definitely on for
> > device /sys/bus/usb/devices/2-1.3/2-1.3:1.0/0003:046D:C52B.0001/power
> > 
> > it shows in the powertop UI as good for both kernels and
> > 
> > Folder contents are autosuspend_delay_ms (can't open), control (auto),
> > runtime_active_time (0), runtime_status (unsupported),

The "unsupported" means that runtime suspend is disabled.  (Don't ask 
me why it doesn't say "disabled" instead.)  That is suspicious in 
itself.  Drivers don't normally disable runtime suspend for more than 
very short time intervals.

Does the runtime_status file really say "unsupported" in both kernels?

> > runtime_suspended_time (0)
> 
> Alright, that means that both kernels are allowed to autosuspend the 
> device, but apparently only 4.12 actually does so. Could you please 
> confirm that with usbmon traces?

In addition to usbmon traces, it would be good to look at the settings 
under /sys/bus/usb/devices/2-1.3/2-1.3:1.0/power/.  It's unlikely that 
they have changed between 4.11 and 4.12, but it doesn't hurt to check.

Alan Stern

--
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 v9] usb: serial: add vid:pid for Cypress WICED dev board

2017-09-08 Thread Jeffrey Chu
From: Jeffrey Chu 

Add CYPRESS_VID vid and CYPRESS_WICED_BT_USB and CYPRESS_WICED_WL_USB
device IDs to ftdi_sio driver

Signed-off-by: Jeffrey Chu 
---
 drivers/usb/serial/ftdi_sio.c | 2 ++
 drivers/usb/serial/ftdi_sio_ids.h | 7 +++
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 1cec037..49d1b2d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1015,6 +1015,8 @@ static const struct usb_device_id id_table_combined[] = {
{ USB_DEVICE(WICED_VID, WICED_USB20706V2_PID) },
{ USB_DEVICE(TI_VID, TI_CC3200_LAUNCHPAD_PID),
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
+   { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_BT_USB_PID) },
+   { USB_DEVICE(CYPRESS_VID, CYPRESS_WICED_WL_USB_PID) },
{ } /* Terminating entry */
 };

diff --git a/drivers/usb/serial/ftdi_sio_ids.h 
b/drivers/usb/serial/ftdi_sio_ids.h
index 4fcf1ce..d58dc1b 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -692,6 +692,13 @@
 #define WICED_USB20706V2_PID   0x6422

 /*
+ * Cypress WICED USB UART
+ */
+#define CYPRESS_VID0x04B4
+#define CYPRESS_WICED_BT_USB_PID   0x009B
+#define CYPRESS_WICED_WL_USB_PID   0xF900
+
+/*
  * Definitions for ID TECH (www.idt-net.com) devices
  */
 #define IDTECH_VID 0x0ACD  /* ID TECH Vendor ID */
--
2.7.4


This message and any attachments may contain confidential information from 
Cypress or its subsidiaries. If it has been received in error, please advise 
the sender and immediately delete this message.
--
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


HID: Add quirk for Lenovo Yoga 910 with ITE Chipset

2017-09-08 Thread Javier Marcet
Hi,

I've been using a Lenovo Yoga 910 with convertible for the last few
months. Its sensors need a quirk to work, which may be should be
generalized to all Yogas, the new 920 probably needs one too.

Anyhow, I have been using this myself for the last few months and I
would appreciate being able to use generic distro kernels again with
full functionality.


-- 
Javier Marcet 
From 86b61f93c47994c5116797b73d4ffee7a482a7ec Mon Sep 17 00:00:00 2001
From: Javier Marcet 
Date: Thu, 27 Jul 2017 15:56:34 +0200
Subject: [PATCH] HID: Add quirk for Lenovo Yoga 910 with ITE Chipset

Signed-off-by: Javier Marcet 
---
 drivers/hid/hid-ids.h| 1 +
 drivers/hid/hid-sensor-hub.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index c9ba4c6db74c..183175f7ea09 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -573,6 +573,7 @@
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA   0x8386
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA2  0x8350
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA900	0x8396
+#define USB_DEVICE_ID_ITE_LENOVO_YOGA910	0x8186
 #define USB_DEVICE_ID_ITE8595		0x8595
 
 #define USB_VENDOR_ID_JABRA		0x0b0e
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 4ef73374a8f9..85b8425483bd 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -820,6 +820,9 @@ static const struct hid_device_id sensor_hub_devices[] = {
 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
 			USB_DEVICE_ID_ITE_LENOVO_YOGA900),
 			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
+	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
+			USB_DEVICE_ID_ITE_LENOVO_YOGA910),
+			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_0,
 			0x22D8),
 			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
-- 
2.14.1



Re: HID: Add quirk for Lenovo Yoga 910 with ITE Chipset

2017-09-08 Thread Javier Marcet
Hi,

I just saw in master it has been superseded by a general fix which
removed all quirks. So no need for it, it seems.


On Sat, Sep 9, 2017 at 1:52 AM, Javier Marcet  wrote:
> Hi,
>
> I've been using a Lenovo Yoga 910 with convertible for the last few
> months. Its sensors need a quirk to work, which may be should be
> generalized to all Yogas, the new 920 probably needs one too.
>
> Anyhow, I have been using this myself for the last few months and I
> would appreciate being able to use generic distro kernels again with
> full functionality.
>
>
> --
> Javier Marcet 



-- 
Javier Marcet 
--
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: [PATCH] usb: dwc3: gadget: only unmap requests from DMA if mapped

2017-09-08 Thread Thinh Nguyen
Hi,

On 9/8/2017 2:34 AM, Felipe Balbi wrote:
> Felipe Balbi  writes:
>> Thinh Nguyen  writes:
>>
>>> Hi Felipe,
>>>
>>> On 9/7/2017 12:16 AM, Felipe Balbi wrote:
>>> drivers/usb/dwc3/gadget.c | 8 +---
>>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 9e41605a..6b299c7 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -191,14 +191,16 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, 
>>> struct dwc3_request *req,
>>> 
>>> req->started = false;
>>> list_del(&req->list);
>>> -   req->trb = NULL;
>>> req->remaining = 0;
>>> 
>>> if (req->request.status == -EINPROGRESS)
>>> req->request.status = status;
>>> 
>>> -   usb_gadget_unmap_request_by_dev(dwc->sysdev,
>>> -   &req->request, req->direction);
>>> +   if (req->trb)
>> This check does not account for control data transfer. TRBs for ep0 are
>> not set to its req->trb. ep0out request needs to be unmapped, otherwise
>> device will receive bogus data.
>>
>> Our internal test showed that the device failed to interpret control
>> data from host. I bisected to this patch.

 what was the testing? How can I reproduce it?
>>>
>>> This is a regression. The internal test found the issue when it does a
>>> 3-stage Control Write Transfer. You can reproduce this issue with just 1
>>> out data packet of size > 0. Read and check the data on control request
>>> completion.
>>
>> okay, is this enough to fix the problem for you?
>>
>> modified   drivers/usb/dwc3/ep0.c
>> @@ -48,6 +48,9 @@ static void dwc3_ep0_prepare_one_trb(struct dwc3_ep *dep,
>>  dwc = dep->dwc;
>>  trb = &dwc->ep0_trb[dep->trb_enqueue];
>>   
>> +if (!req->trb)
>> +req->trb = trb;
>> +
>>  if (chain)
>>  dep->trb_enqueue++;
> 
> sorry, no. this is totally wrong :-) Here's a better version:
> 
> modified   drivers/usb/dwc3/ep0.c
> @@ -990,6 +990,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
>DWC3_TRBCTL_CONTROL_DATA,
>true);
>   
> + req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1]; > +
>   /* Now prepare one extra TRB to align transfer size */
>   dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
>maxpacket - rem,
> @@ -1015,6 +1017,8 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
>DWC3_TRBCTL_CONTROL_DATA,
>true);
>   
> + req->trb = &dwc->ep0_trb[dep->trb_enqueue - 1]; > +
>   /* Now prepare one extra TRB to align transfer size */
>   dwc3_ep0_prepare_one_trb(dep, dwc->bounce_addr,
>0, DWC3_TRBCTL_CONTROL_DATA,
> @@ -1029,6 +1033,9 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
>   dwc3_ep0_prepare_one_trb(dep, req->request.dma,
>   req->request.length, DWC3_TRBCTL_CONTROL_DATA,
>   false);
> +
> + req->trb = &dwc->ep0_trb[dep->trb_enqueue];
> +
>   ret = dwc3_ep0_start_trans(dep);
>   }
> 
> (didn't even compile test)
>   
> 

Yes this works.

Thanks,
Thinh
--
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: T230 and T230C DVB-C broken on Linux 4.12>

2017-09-08 Thread Greg KH
On Fri, Sep 08, 2017 at 09:27:51PM +0200, François wrote:
> The device isn't able to scan any DVB-C channel anymore, and the
> following error appears:
> usb 1-7: DVB: adapter 0 frontend 0 frequency 0 out of range
> 
> The cable is fine (tried a few others as well), it just impossible to
> get any signal.
> 
> I think the device is hard bricket, don't recommend upgrading when
> using this device.

Does it work on older versions of the kernel?  If so, can you use 'git
bisect' to find the offending commit?

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