[PATCH v2] dwc3: make LPM configurable in DT

2015-03-09 Thread Robert Baldyga
This patch removes Enable USB3 LPM Capability option from Kconfig
and adds snps,usb3_lpm_capable devicetree property instead of it.

USB3 LPM (Link Power Management) capability is hardware property, and
it's platform dependent, so if our hardware supports this feature, we
want rather to configure it in devicetree than having it as Kconfig option.

Signed-off-by: Robert Baldyga r.bald...@samsung.com
---

Changelog:

v2:
- addressed Felipe's comments

v1: https://lkml.org/lkml/2015/3/6/185

 Documentation/devicetree/bindings/usb/dwc3.txt | 1 +
 drivers/usb/dwc3/Kconfig   | 7 ---
 drivers/usb/dwc3/core.c| 3 +++
 drivers/usb/dwc3/core.h| 2 ++
 drivers/usb/dwc3/host.c| 4 +---
 drivers/usb/dwc3/platform_data.h   | 1 +
 6 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index cd7f045..5cc3643 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -14,6 +14,7 @@ Optional properties:
  - phys: from the *Generic PHY* bindings
  - phy-names: from the *Generic PHY* bindings
  - tx-fifo-resize: determines if the FIFO *has* to be reallocated.
+ - snps,usb3_lpm_capable: determines if platform is USB3 LPM capable
  - snps,disable_scramble_quirk: true when SW should disable data scrambling.
Only really useful for FPGA builds.
  - snps,has-lpm-erratum: true when DWC3 was configured with LPM Erratum enabled
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index edbf9c8..827c4f8 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -104,11 +104,4 @@ config USB_DWC3_DEBUG
help
  Say Y here to enable debugging messages on DWC3 Driver.
 
-config DWC3_HOST_USB3_LPM_ENABLE
-   bool Enable USB3 LPM Capability
-   depends on USB_DWC3_HOST=y || USB_DWC3_DUAL_ROLE=y
-   default n
-   help
- Select this when you want to enable USB3 LPM with dwc3 xhci host.
-
 endif
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 05b18ee..81b092b 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -808,6 +808,8 @@ static int dwc3_probe(struct platform_device *pdev)
snps,is-utmi-l1-suspend);
of_property_read_u8(node, snps,hird-threshold,
hird_threshold);
+   dwc-usb3_lpm_capable = of_property_read_bool(node,
+   snps,usb3_lpm_capable);
 
dwc-needs_fifo_resize = of_property_read_bool(node,
tx-fifo-resize);
@@ -848,6 +850,7 @@ static int dwc3_probe(struct platform_device *pdev)
hird_threshold = pdata-hird_threshold;
 
dwc-needs_fifo_resize = pdata-tx_fifo_resize;
+   dwc-usb3_lpm_capable = pdata-usb3_lpm_capable;
dwc-dr_mode = pdata-dr_mode;
 
dwc-disable_scramble_quirk = pdata-disable_scramble_quirk;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index d201910..fdab715 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -689,6 +689,7 @@ struct dwc3_scratchpad_array {
  * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround
  * @start_config_issued: true when StartConfig command has been issued
  * @three_stage_setup: set if we perform a three phase setup
+ * @usb3_lpm_capable: set if hadrware supports Link Power Management
  * @disable_scramble_quirk: set if we enable the disable scramble quirk
  * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk
  * @u2ss_inp3_quirk: set if we enable P3 OK for U2/SS Inactive quirk
@@ -812,6 +813,7 @@ struct dwc3 {
unsignedsetup_packet_pending:1;
unsignedstart_config_issued:1;
unsignedthree_stage_setup:1;
+   unsignedusb3_lpm_capable:1;
 
unsigneddisable_scramble_quirk:1;
unsignedu2exit_lfps_quirk:1;
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 12bfd3c..c679f63 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -49,9 +49,7 @@ int dwc3_host_init(struct dwc3 *dwc)
 
memset(pdata, 0, sizeof(pdata));
 
-#ifdef CONFIG_DWC3_HOST_USB3_LPM_ENABLE
-   pdata.usb3_lpm_capable = 1;
-#endif
+   pdata.usb3_lpm_capable = dwc-usb3_lpm_capable;
 
ret = platform_device_add_data(xhci, pdata, sizeof(pdata));
if (ret) {
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index a3a3b6d5..a2bd464 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -24,6 +24,7 @@ struct dwc3_platform_data {
enum usb_device_speed maximum_speed;
enum usb_dr_mode dr_mode;
 

[linux-usb] [UAC2] How to route pcm stream for UAC2 virtual sound card for lowest latency?

2015-03-09 Thread Xuebing Wang

Hi Community,

I am developing a commercial product based on Freescale iMX6SL + UAC2.

I can get UAC2 working for below command. 'hw:1,0' is the virtual sound 
card. 'hw:0,0' is the physical sound card.
export RATE=44100; arecord -D hw:1,0 -c 2 -r $RATE -f S16_LE | aplay -c 
2 -r $RATE -f S16_LE 


Any suggestions on what is the best way to get PCM stream from UAC2 
virtual sound card and feed to the physical sound card, for the lowest 
latency purpose?


Thanks.

--
Xuebing
--
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: EHCI/xHCI port switching issue

2015-03-09 Thread Adrian-Ken Rueegsegger
Hello,

On 01/23/2015 12:54 PM, Mathias Nyman wrote:
 I don't know what will happend if we try to write to xhci portswitching 
 registers
 on platforms with xhci only, so just removing the ehci check is a bit risky 
 considering future platforms.
 
 I need to ask around internally and see if we can detect the portswitching 
 feature from
 inside xhci, (digging around its pci config space before loading the driver), 
 or if there's
 any harm in always trying to do the portswitch on intel xhci controllers.

I was wondering if there has been any news or progress with regards to
EHCI/xHCI port switching or if there is anything I can do on my end to
help resolve the issue. Thanks for your time.

Regards,
Adrian
--
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: [linux-usb] [UAC2] How to route pcm stream for UAC2 virtual sound card for lowest latency?

2015-03-09 Thread Alan Stern
On Mon, 9 Mar 2015, Xuebing Wang wrote:

 Hi Community,
 
 I am developing a commercial product based on Freescale iMX6SL + UAC2.
 
 I can get UAC2 working for below command. 'hw:1,0' is the virtual sound 
 card. 'hw:0,0' is the physical sound card.
 export RATE=44100; arecord -D hw:1,0 -c 2 -r $RATE -f S16_LE | aplay -c 
 2 -r $RATE -f S16_LE 
 
 Any suggestions on what is the best way to get PCM stream from UAC2 
 virtual sound card and feed to the physical sound card, for the lowest 
 latency purpose?

Why did you post this message to the linux-usb mailing list?  Wouldn't 
it be more appropriate on the alsa-devel list?

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


Re: [PATCH] drivers: usb: gadget: udc: Fix NULL dereference

2015-03-09 Thread Felipe Balbi
On Wed, Mar 04, 2015 at 09:11:19AM +0800, Peter Chen wrote:
 On Tue, Mar 03, 2015 at 06:28:42PM +0530, Tapasweni Pathak wrote:
  This patch fixes multiple instances of null pointer dereference in this 
  code.
  
  ep-udc is assigned to udc. ep is just an offset from _ep. _ep is then
  checked for NULL. udc is dereferenced under the NULL check for _ep, making
  an invalid pointer reference.
  
  udc is then checked for NULL, if NULL, it is then dereferenced as
  udc-dev.
  
  To fix these issues, shift assignment of udc by dereferencing ep after
  null check for _ep, replace both dev_dbg statements with pr_debug.
  
  Found using Coccinelle.
  
  Signed-off-by: Tapasweni Pathak tapaswenipat...@gmail.com
  Suggested-by : Julia Lawall julia.law...@lip6.fr
  Reviewed-by : Julia Lawall julia.law...@lip6.fr
  ---
   drivers/usb/gadget/udc/lpc32xx_udc.c |7 +++
   1 file changed, 3 insertions(+), 4 deletions(-)
  
  diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c 
  b/drivers/usb/gadget/udc/lpc32xx_udc.c
  index 27fd413..6398539 100644
  --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
  +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
  @@ -1807,17 +1807,16 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
  !list_empty(req-queue))
  return -EINVAL;
  
  -   udc = ep-udc;
  -
  if (!_ep) {
  -   dev_dbg(udc-dev, invalid ep\n);
  +   pr_debug(invalid ep\n);
  return -EINVAL;
  }
  
  +   udc = ep-udc;
  
  if ((!udc) || (!udc-driver) ||
  (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
  -   dev_dbg(udc-dev, invalid device\n);
  +   pr_debug(invalid device\n);
  return -EINVAL;
  }
  
 
 It is driver code, we'd better use dev_dbg. If _ep exists,
 both ep and udc should exist. So, how about just checking
 _ep at the beginning:
 
 diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c 
 b/drivers/usb/gadget/udc/lpc32xx_udc.c
 index 27fd413..c65de0e 100644
 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
 +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
 @@ -1803,7 +1803,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
   req = container_of(_req, struct lpc32xx_request, req);
   ep = container_of(_ep, struct lpc32xx_ep, ep);
  
 - if (!_req || !_req-complete || !_req-buf ||
 + if (!_ep || !_req || !_req-complete || !_req-buf ||
   !list_empty(req-queue))
   return -EINVAL;
  
 @@ -1815,8 +1815,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
   }
  
  
 - if ((!udc) || (!udc-driver) ||
 - (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
 + if ((!udc-driver) || (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
   dev_dbg(udc-dev, invalid device\n);
   return -EINVAL;
   }

what's going to happen here ?

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 06/19] usb: dwc2: add external_id_pin_ctl core parameter

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

This is required due to an Intel specific hardware issue. Where id-
pin setup causes glitches on the interrupt line when CONIDSTSCHG
interrupt is enabled.

Specify external_id_pin_ctl when an external driver (for example phy)
can handle id change, so that CONIDSTSCHG interrupt can be disabled
from the controller.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/core.c | 22 +-
 drivers/usb/dwc2/core.h |  6 ++
 drivers/usb/dwc2/platform.c |  2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index e858062..e218a8a 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -453,8 +453,10 @@ static void dwc2_enable_common_interrupts(struct 
dwc2_hsotg *hsotg)
 
if (hsotg-core_params-dma_enable = 0)
intmsk |= GINTSTS_RXFLVL;
+   if (hsotg-core_params-external_id_pin_ctl = 0)
+   intmsk |= GINTSTS_CONIDSTSCHNG;
 
-   intmsk |= GINTSTS_CONIDSTSCHNG | GINTSTS_WKUPINT | GINTSTS_USBSUSP |
+   intmsk |= GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
 
writel(intmsk, hsotg-regs + GINTMSK);
@@ -2978,6 +2980,23 @@ static void dwc2_set_param_uframe_sched(struct 
dwc2_hsotg *hsotg, int val)
hsotg-core_params-uframe_sched = val;
 }
 
+static void dwc2_set_param_external_id_pin_ctl(struct dwc2_hsotg *hsotg,
+   int val)
+{
+   if (DWC2_OUT_OF_BOUNDS(val, 0, 1)) {
+   if (val = 0) {
+   dev_err(hsotg-dev,
+   '%d' invalid for parameter 
external_id_pin_ctl\n,
+   val);
+   dev_err(hsotg-dev, external_id_pin_ctl must be 0 or 
1\n);
+   }
+   val = 0;
+   dev_dbg(hsotg-dev, Setting external_id_pin_ctl to %d\n, val);
+   }
+
+   hsotg-core_params-external_id_pin_ctl = val;
+}
+
 /*
  * This function is called during module intialization to pass module 
parameters
  * for the DWC_otg core.
@@ -3022,6 +3041,7 @@ void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
dwc2_set_param_ahbcfg(hsotg, params-ahbcfg);
dwc2_set_param_otg_ver(hsotg, params-otg_ver);
dwc2_set_param_uframe_sched(hsotg, params-uframe_sched);
+   dwc2_set_param_external_id_pin_ctl(hsotg, params-external_id_pin_ctl);
 }
 
 /**
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index b14aa38..795e4ed 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -331,6 +331,11 @@ enum dwc2_ep0_state {
  *  by the driver and are ignored in this
  *  configuration value.
  * @uframe_sched:   True to enable the microframe scheduler
+ * @external_id_pin_ctl: Specifies whether ID pin is handled externally.
+ *  Disable CONIDSTSCHNG controller interrupt in such
+ *  case.
+ *  0 - No (default)
+ *  1 - Yes
  *
  * The following parameters may be specified when starting the module. These
  * parameters define how the DWC_otg controller should be configured. A
@@ -368,6 +373,7 @@ struct dwc2_core_params {
int reload_ctl;
int ahbcfg;
int uframe_sched;
+   int external_id_pin_ctl;
 };
 
 /**
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 4d41c01..f9b7d9f 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -77,6 +77,7 @@ static const struct dwc2_core_params params_bcm2835 = {
.reload_ctl = 0,
.ahbcfg = 0x10,
.uframe_sched   = 0,
+   .external_id_pin_ctl= -1,
 };
 
 static const struct dwc2_core_params params_rk3066 = {
@@ -105,6 +106,7 @@ static const struct dwc2_core_params params_rk3066 = {
.reload_ctl = -1,
.ahbcfg = 0x7, /* INCR16 */
.uframe_sched   = -1,
+   .external_id_pin_ctl= -1,
 };
 
 /**
-- 
1.9.1

--
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] dma: cppi41: add missing directions bitfield

2015-03-09 Thread Felipe Balbi
On Wed, Mar 04, 2015 at 06:13:23PM +0530, Vinod Koul wrote:
 On Wed, Feb 25, 2015 at 04:54:02PM -0600, Felipe Balbi wrote:
  Without those we will see a kernel WARN()
  when loading musb on am335x devices.
  
  Signed-off-by: Felipe Balbi ba...@ti.com
  ---
   drivers/dma/cppi41.c | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
  index 512cb8e2805e..4e9cc8e8100c 100644
  --- a/drivers/dma/cppi41.c
  +++ b/drivers/dma/cppi41.c
  @@ -926,6 +926,7 @@ static int cppi41_dma_probe(struct platform_device 
  *pdev)
  cdd-ddev.device_issue_pending = cppi41_dma_issue_pending;
  cdd-ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg;
  cdd-ddev.device_terminate_all = cppi41_stop_chan;
  +   cdd-ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
  cdd-ddev.dev = dev;
  INIT_LIST_HEAD(cdd-ddev.channels);
  cpp41_dma_info.dma_cap = cdd-ddev.cap_mask;
 Along with this please set src/dstn_addr_widths and residue_granularity
 please

will do.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] usb: isp1760: add peripheral/device controller chip id

2015-03-09 Thread Felipe Balbi
On Wed, Mar 04, 2015 at 03:56:12PM +, Sudeep Holla wrote:
 
 
 On 26/02/15 18:53, Laurent Pinchart wrote:
 Hi Sudeep,
 
 Thank you for the patch.
 
 On Thursday 26 February 2015 11:47:57 Sudeep Holla wrote:
 As per the SAF1761 data sheet[0], the DcChipID register represents
 the hardware version number (0001h) and the chip ID (1582h) for the
 Peripheral Controller.
 
 However as per the ISP1761 data sheet[1], the DcChipID register
 represents the hardware version number (0015h) and the chip ID (8210h)
 for the Peripheral Controller.
 
 This patch adds support for both the chip ID values.
 
 [0] http://www.nxp.com/documents/data_sheet/SAF1761.pdf
 [1] http://pdf.datasheetcatalog.com/datasheets2/74/742102_1.pdf
 
 Cc: Felipe Balbi ba...@ti.com
 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 
 
 Thanks. I assume Felipe will pick this up.

I will, but I need Laurent's Ack.

-- 
balbi


signature.asc
Description: Digital signature


[PATCH 09/19] usb: dwc2: gadget: ignore pm suspend/resume in L2

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Nothing to be done in pm suspend/resume when controller is in L2.
Don't disconnect or reset. State is already saved when putting
controller in hibernation and will be restored on USB bus resume.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index d528c02..539a3d4 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3672,6 +3672,9 @@ int s3c_hsotg_suspend(struct dwc2_hsotg *hsotg)
unsigned long flags;
int ret = 0;
 
+   if (hsotg-lx_state != DWC2_L0)
+   return ret;
+
mutex_lock(hsotg-init_mutex);
 
if (hsotg-driver) {
@@ -3712,6 +3715,9 @@ int s3c_hsotg_resume(struct dwc2_hsotg *hsotg)
unsigned long flags;
int ret = 0;
 
+   if (hsotg-lx_state == DWC2_L2)
+   return ret;
+
mutex_lock(hsotg-init_mutex);
 
if (hsotg-driver) {
-- 
1.9.1

--
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 15/19] usb: dwc2: host: add bus_suspend/bus_resume callback

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index a88a5df..fd02b43 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2305,6 +2305,22 @@ static void _dwc2_hcd_stop(struct usb_hcd *hcd)
usleep_range(1000, 3000);
 }
 
+static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
+{
+   struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+
+   hsotg-lx_state = DWC2_L2;
+   return 0;
+}
+
+static int _dwc2_hcd_resume(struct usb_hcd *hcd)
+{
+   struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd);
+
+   hsotg-lx_state = DWC2_L0;
+   return 0;
+}
+
 /* Returns the current frame number */
 static int _dwc2_hcd_get_frame_number(struct usb_hcd *hcd)
 {
@@ -2675,6 +2691,9 @@ static struct hc_driver dwc2_hc_driver = {
.hub_status_data = _dwc2_hcd_hub_status_data,
.hub_control = _dwc2_hcd_hub_control,
.clear_tt_buffer_complete = _dwc2_hcd_clear_tt_buffer_complete,
+
+   .bus_suspend = _dwc2_hcd_suspend,
+   .bus_resume = _dwc2_hcd_resume,
 };
 
 /*
-- 
1.9.1

--
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 02/19] usb: dwc2: debugfs: add support for complete register dump

2015-03-09 Thread Mian Yousaf Kaukab
Dump all registers to take a complete snapshot of dwc2 state.
Code is inspired by dwc3/debugfs.c

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/core.h|   1 +
 drivers/usb/dwc2/debugfs.c | 356 +
 2 files changed, 357 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 9e2bf4d..e60655f 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -613,6 +613,7 @@ struct dwc2_hsotg {
enum dwc2_lx_state lx_state;
 
struct dentry *debug_root;
+   struct debugfs_regset32 *regset;
 
/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a0x4f54271a
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index 6c3225c..b8b105e 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -391,9 +391,344 @@ static inline void s3c_hsotg_create_debug(struct 
dwc2_hsotg *hsotg) {}
 
 /* s3c_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */
 
+#define dump_register(nm)  \
+{  \
+   .name   = #nm,  \
+   .offset = nm,   \
+}
+
+static const struct debugfs_reg32 dwc2_regs[] = {
+   /*
+* Accessing registers like this can trigger mode mismatch interrupt.
+* However, according to dwc2 databook, the register access, in this
+* case, is completed on the processor bus but is ignored by the core
+* and does not affect its operation.
+*/
+   dump_register(GOTGCTL),
+   dump_register(GOTGINT),
+   dump_register(GAHBCFG),
+   dump_register(GUSBCFG),
+   dump_register(GRSTCTL),
+   dump_register(GINTSTS),
+   dump_register(GINTMSK),
+   dump_register(GRXSTSR),
+   dump_register(GRXSTSP),
+   dump_register(GRXFSIZ),
+   dump_register(GNPTXFSIZ),
+   dump_register(GNPTXSTS),
+   dump_register(GI2CCTL),
+   dump_register(GPVNDCTL),
+   dump_register(GGPIO),
+   dump_register(GUID),
+   dump_register(GSNPSID),
+   dump_register(GHWCFG1),
+   dump_register(GHWCFG2),
+   dump_register(GHWCFG3),
+   dump_register(GHWCFG4),
+   dump_register(GLPMCFG),
+   dump_register(GPWRDN),
+   dump_register(GDFIFOCFG),
+   dump_register(ADPCTL),
+   dump_register(HPTXFSIZ),
+   dump_register(DPTXFSIZN(1)),
+   dump_register(DPTXFSIZN(2)),
+   dump_register(DPTXFSIZN(3)),
+   dump_register(DPTXFSIZN(4)),
+   dump_register(DPTXFSIZN(5)),
+   dump_register(DPTXFSIZN(6)),
+   dump_register(DPTXFSIZN(7)),
+   dump_register(DPTXFSIZN(8)),
+   dump_register(DPTXFSIZN(9)),
+   dump_register(DPTXFSIZN(10)),
+   dump_register(DPTXFSIZN(11)),
+   dump_register(DPTXFSIZN(12)),
+   dump_register(DPTXFSIZN(13)),
+   dump_register(DPTXFSIZN(14)),
+   dump_register(DPTXFSIZN(15)),
+   dump_register(DCFG),
+   dump_register(DCTL),
+   dump_register(DSTS),
+   dump_register(DIEPMSK),
+   dump_register(DOEPMSK),
+   dump_register(DAINT),
+   dump_register(DAINTMSK),
+   dump_register(DTKNQR1),
+   dump_register(DTKNQR2),
+   dump_register(DTKNQR3),
+   dump_register(DTKNQR4),
+   dump_register(DVBUSDIS),
+   dump_register(DVBUSPULSE),
+   dump_register(DIEPCTL(0)),
+   dump_register(DIEPCTL(1)),
+   dump_register(DIEPCTL(2)),
+   dump_register(DIEPCTL(3)),
+   dump_register(DIEPCTL(4)),
+   dump_register(DIEPCTL(5)),
+   dump_register(DIEPCTL(6)),
+   dump_register(DIEPCTL(7)),
+   dump_register(DIEPCTL(8)),
+   dump_register(DIEPCTL(9)),
+   dump_register(DIEPCTL(10)),
+   dump_register(DIEPCTL(11)),
+   dump_register(DIEPCTL(12)),
+   dump_register(DIEPCTL(13)),
+   dump_register(DIEPCTL(14)),
+   dump_register(DIEPCTL(15)),
+   dump_register(DOEPCTL(0)),
+   dump_register(DOEPCTL(1)),
+   dump_register(DOEPCTL(2)),
+   dump_register(DOEPCTL(3)),
+   dump_register(DOEPCTL(4)),
+   dump_register(DOEPCTL(5)),
+   dump_register(DOEPCTL(6)),
+   dump_register(DOEPCTL(7)),
+   dump_register(DOEPCTL(8)),
+   dump_register(DOEPCTL(9)),
+   dump_register(DOEPCTL(10)),
+   dump_register(DOEPCTL(11)),
+   dump_register(DOEPCTL(12)),
+   dump_register(DOEPCTL(13)),
+   dump_register(DOEPCTL(14)),
+   dump_register(DOEPCTL(15)),
+   dump_register(DIEPINT(0)),
+   dump_register(DIEPINT(1)),
+   dump_register(DIEPINT(2)),
+   dump_register(DIEPINT(3)),
+   dump_register(DIEPINT(4)),
+   dump_register(DIEPINT(5)),
+   dump_register(DIEPINT(6)),
+   dump_register(DIEPINT(7)),
+   dump_register(DIEPINT(8)),
+   dump_register(DIEPINT(9)),
+   dump_register(DIEPINT(10)),
+   dump_register(DIEPINT(11)),
+   dump_register(DIEPINT(12)),
+   dump_register(DIEPINT(13)),
+   

[PATCH 12/19] usb: dwc2: gadget: enable otg flag in dual role configuration

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bb83826..2e27bfd 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3524,6 +3524,9 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
hsotg-gadget.max_speed = USB_SPEED_HIGH;
hsotg-gadget.ops = s3c_hsotg_gadget_ops;
hsotg-gadget.name = dev_name(dev);
+#if IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+   hsotg-gadget.is_otg = 1;
+#endif
 
/* reset the system */
 
-- 
1.9.1

--
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 03/19] usb: dwc2: add controller hibernation support

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

When suspending usb bus, phy driver may disable controller power.
In this case, registers need to be saved on suspend and restored
on resume.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/core.c | 376 
 drivers/usb/dwc2/core.h |  84 +++
 2 files changed, 460 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index d5197d4..e858062 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -56,6 +56,382 @@
 #include core.h
 #include hcd.h
 
+#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_backup_host_registers() - Backup controller host registers.
+ * When suspending usb bus, registers needs to be backuped
+ * if controller power is disabled once suspended.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
+{
+   struct hregs_backup *hr;
+   int i;
+
+   dev_dbg(hsotg-dev, %s\n, __func__);
+
+   /* Backup Host regs */
+   hr = hsotg-hr_backup;
+   if (!hr) {
+   hr = kmalloc(sizeof(*hr), GFP_KERNEL);
+   if (!hr) {
+   dev_err(hsotg-dev, %s: can't allocate host regs\n,
+   __func__);
+   return -ENOMEM;
+   }
+
+   hsotg-hr_backup = hr;
+   }
+   hr-hcfg = readl(hsotg-regs + HCFG);
+   hr-haintmsk = readl(hsotg-regs + HAINTMSK);
+   for (i = 0; i  hsotg-core_params-host_channels; ++i)
+   hr-hcintmsk[i] = readl(hsotg-regs + HCINTMSK(i));
+
+   hr-hprt0 = readl(hsotg-regs + HPRT0);
+   hr-hfir = readl(hsotg-regs + HFIR);
+   return 0;
+}
+
+/**
+ * dwc2_restore_host_registers() - Restore controller host registers.
+ * When resuming usb bus, device registers needs to be restored
+ * if controller power were disabled.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
+{
+   struct hregs_backup *hr;
+   int i;
+
+   dev_dbg(hsotg-dev, %s\n, __func__);
+
+   /* Restore host regs */
+   hr = hsotg-hr_backup;
+   if (!hr) {
+   dev_err(hsotg-dev, %s: no host registers to restore\n,
+   __func__);
+   return -EINVAL;
+   }
+
+   writel(hr-hcfg, hsotg-regs + HCFG);
+   writel(hr-haintmsk, hsotg-regs + HAINTMSK);
+
+   for (i = 0; i  hsotg-core_params-host_channels; ++i)
+   writel(hr-hcintmsk[i], hsotg-regs + HCINTMSK(i));
+
+   writel(hr-hprt0, hsotg-regs + HPRT0);
+   writel(hr-hfir, hsotg-regs + HFIR);
+
+   return 0;
+}
+#else
+static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
+{ return 0; }
+
+static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
+{ return 0; }
+#endif
+
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+   IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * dwc2_backup_device_registers() - Backup controller device registers.
+ * When suspending usb bus, registers needs to be backuped
+ * if controller power is disabled once suspended.
+ *
+ * @hsotg: Programming view of the DWC_otg controller
+ */
+static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
+{
+   struct dregs_backup *dr;
+   int i;
+
+   dev_dbg(hsotg-dev, %s\n, __func__);
+
+   /* Backup dev regs */
+   dr = hsotg-dr_backup;
+   if (!dr) {
+   dr = kmalloc(sizeof(*dr), GFP_KERNEL);
+   if (!dr) {
+   dev_err(hsotg-dev, %s: can't allocate device regs\n,
+   __func__);
+   return -ENOMEM;
+   }
+
+   hsotg-dr_backup = dr;
+   }
+
+   dr-dcfg = readl(hsotg-regs + DCFG);
+   dr-dctl = readl(hsotg-regs + DCTL);
+   dr-daintmsk = readl(hsotg-regs + DAINTMSK);
+   dr-diepmsk = readl(hsotg-regs + DIEPMSK);
+   dr-doepmsk = readl(hsotg-regs + DOEPMSK);
+
+   for (i = 0; i  hsotg-num_of_eps; i++) {
+   /* Backup IN EPs */
+   dr-diepctl[i] = readl(hsotg-regs + DIEPCTL(i));
+
+   /* Ensure DATA PID is correctly configured */
+   if (dr-diepctl[i]  DXEPCTL_DPID)
+   dr-diepctl[i] |= DXEPCTL_SETD1PID;
+   else
+   dr-diepctl[i] |= DXEPCTL_SETD0PID;
+
+   dr-dieptsiz[i] = readl(hsotg-regs + DIEPTSIZ(i));
+   dr-diepdma[i] = readl(hsotg-regs + DIEPDMA(i));
+
+   /* Backup OUT EPs */
+   dr-doepctl[i] = readl(hsotg-regs + DOEPCTL(i));
+
+   /* Ensure DATA PID is correctly configured */
+   if (dr-doepctl[i]  DXEPCTL_DPID)
+   dr-doepctl[i] |= DXEPCTL_SETD1PID;
+ 

[PATCH 18/19] usb: dwc2: host: don't use dma_alloc_coherent with irqs disabled

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Align buffer must be allocated using kmalloc since irqs are disabled.
Coherency is handled through dma_map_single which can be used with irqs
disabled.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd.c   |  7 ---
 drivers/usb/dwc2/hcd_intr.c  | 10 ++
 drivers/usb/dwc2/hcd_queue.c |  7 ---
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 011b679..7ebf6cc 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -710,9 +710,7 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
/* 3072 = 3 max-size Isoc packets */
buf_size = 3072;
 
-   qh-dw_align_buf = dma_alloc_coherent(hsotg-dev, buf_size,
- qh-dw_align_buf_dma,
- GFP_ATOMIC);
+   qh-dw_align_buf = kzalloc(buf_size, GFP_ATOMIC);
if (!qh-dw_align_buf)
return -ENOMEM;
qh-dw_align_buf_size = buf_size;
@@ -737,6 +735,9 @@ static int dwc2_hc_setup_align_buf(struct dwc2_hsotg 
*hsotg, struct dwc2_qh *qh,
}
}
 
+   qh-dw_align_buf_dma = dma_map_single(hsotg-dev,
+   qh-dw_align_buf, qh-dw_align_buf_size, DMA_TO_DEVICE);
+
chan-align_buf = qh-dw_align_buf_dma;
return 0;
 }
diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 6927bba..600f5ba 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -467,6 +467,8 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg,
 
/* Non DWORD-aligned buffer case handling */
if (chan-align_buf  xfer_length  chan-ep_is_in) {
+   dma_unmap_single(hsotg-dev, chan-qh-dw_align_buf_dma,
+   chan-qh-dw_align_buf_size, DMA_FROM_DEVICE);
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n, __func__);
memcpy(urb-buf + urb-actual_length, chan-qh-dw_align_buf,
   xfer_length);
@@ -559,6 +561,8 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n,
 __func__);
+   dma_unmap_single(hsotg-dev, chan-qh-dw_align_buf_dma,
+   chan-qh-dw_align_buf_size, DMA_FROM_DEVICE);
memcpy(urb-buf + frame_desc-offset +
   qtd-isoc_split_offset, chan-qh-dw_align_buf,
   frame_desc-actual_length);
@@ -588,6 +592,8 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state(
chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n,
 __func__);
+   dma_unmap_single(hsotg-dev, chan-qh-dw_align_buf_dma,
+   chan-qh-dw_align_buf_size, DMA_FROM_DEVICE);
memcpy(urb-buf + frame_desc-offset +
   qtd-isoc_split_offset, chan-qh-dw_align_buf,
   frame_desc-actual_length);
@@ -926,6 +932,8 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg 
*hsotg,
 
if (chan-align_buf) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n, __func__);
+   dma_unmap_single(hsotg-dev, chan-qh-dw_align_buf_dma,
+   chan-qh-dw_align_buf_size, DMA_FROM_DEVICE);
memcpy(qtd-urb-buf + frame_desc-offset +
   qtd-isoc_split_offset, chan-qh-dw_align_buf, len);
}
@@ -1155,6 +1163,8 @@ static void dwc2_update_urb_state_abn(struct dwc2_hsotg 
*hsotg,
/* Non DWORD-aligned buffer case handling */
if (chan-align_buf  xfer_length  chan-ep_is_in) {
dev_vdbg(hsotg-dev, %s(): non-aligned buffer\n, __func__);
+   dma_unmap_single(hsotg-dev, chan-qh-dw_align_buf_dma,
+   chan-qh-dw_align_buf_size, DMA_FROM_DEVICE);
memcpy(urb-buf + urb-actual_length, chan-qh-dw_align_buf,
   xfer_length);
}
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index 02103b66..5f206ab 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -231,9 +231,10 @@ void dwc2_hcd_qh_free(struct dwc2_hsotg *hsotg, struct 
dwc2_qh *qh)
 {
if (hsotg-core_params-dma_desc_enable  0)
dwc2_hcd_qh_free_ddma(hsotg, qh);
-   else if (qh-dw_align_buf)
-   dma_free_coherent(hsotg-dev, qh-dw_align_buf_size,
- qh-dw_align_buf, qh-dw_align_buf_dma);
+   else {
+   

[PATCH 14/19] usb: dwc2: host: register handle to the phy

2015-03-09 Thread Mian Yousaf Kaukab
If phy driver is present register hcd handle to it.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/hcd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 908fc8a..a88a5df 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2923,6 +2923,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
/* Don't support SG list at this point */
hcd-self.sg_tablesize = 0;
 
+   if (!IS_ERR_OR_NULL(hsotg-uphy))
+   otg_set_host(hsotg-uphy-otg, hcd-self);
+
/*
 * Finish generic HCD initialization and start the HCD. This function
 * allocates the DMA buffer pool, registers the USB bus, requests the
@@ -2976,6 +2979,9 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg)
return;
}
 
+   if (!IS_ERR_OR_NULL(hsotg-uphy))
+   otg_set_host(hsotg-uphy-otg, NULL);
+
usb_remove_hcd(hcd);
hsotg-priv = NULL;
dwc2_hcd_release(hsotg);
-- 
1.9.1

--
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 gadget: remove size limitation for storage cdrom

2015-03-09 Thread Alan Stern
On Mon, 9 Mar 2015, Dave Young wrote:

 On 03/08/15 at 11:29am, Alan Stern wrote:
  On Sun, 8 Mar 2015, Dave Young wrote:
  
   I used usb cdrom emulation to play video dvd for my daughter, but I got 
   below
   error:
   
   [dave@darkstar tmp]$ cat /mnt/sr1/VIDEO_TS/VTS_01_5.VOB /dev/null
   cat: /mnt/sr1/VIDEO_TS/VTS_01_5.VOB: Input/output error
   [dave@darkstar tmp]$ dmesg|tail -1
   [ 3349.371857] sr1: rw=0, want=8028824, limit=4607996
   
   The assumption of cdrom size is not right, we can create data dvd large 
   then
   4G, also mkisofs can create an iso with only one blank directory, the 
   size is
   less than 300 sectors. The size limit does not make sense, thus remove 
   them. 
   
   Signed-off-by: Dave Young dyo...@redhat.com
   ---
drivers/usb/gadget/function/storage_common.c |9 -
1 file changed, 9 deletions(-)
   
   --- linux.orig/drivers/usb/gadget/function/storage_common.c
   +++ linux/drivers/usb/gadget/function/storage_common.c
   @@ -247,15 +247,6 @@ int fsg_lun_open(struct fsg_lun *curlun,

 num_sectors = size  blkbits; /* File size in logic-block-size blocks 
   */
 min_sectors = 1;
   - if (curlun-cdrom) {
   - min_sectors = 300;  /* Smallest track is 300 frames */
   - if (num_sectors = 256*60*75) {
   - num_sectors = 256*60*75 - 1;
   - LINFO(curlun, file too big: %s\n, filename);
   - LINFO(curlun, using only first %d blocks\n,
   - (int) num_sectors);
   - }
   - }
 if (num_sectors  min_sectors) {
 LINFO(curlun, file too small: %s\n, filename);
 rc = -ETOOSMALL;
  
  NAK.  This patch is wrong, for a very simple reason.  You wrote:
  
   I used usb cdrom emulation to play video dvd for my daughter
  
  and this demonstrates the error quite plainly.  You can't use _CD_ 
  emulation to imitate a _DVD_ -- they are different sorts of media.  
  Just think of what happens when you try playing a DVD on a CD player.
  
  A more suitable approach would be to add DVD emulation to the driver.
  
 
 They are both iso9660 images, aren't they? So from data image point
 of view there's no difference, it is not worth to create another mode
 for dvd data.

There's more to emulation than just the image.  We have to emulate the 
hardware's response to all the applicable commands.  CD players have a 
different command set from DVD players (or at least, different from DVD 
players when a DVD is inserted).  For example, see the definition in 
the MSF format for READ TOC command.

 We should not emulate cd drive to support different cd media type,
 it is far more better to support just iso9660 volume no matter how
 large the size is as long as it is fit for iso9660 spec.
 
 OTOH, the size limitation is a bug:
 * isofs can be less than 300 sectors, the 300 sectors limitation is for
 music cd I think. Try mkisofs a blank directory and burn it.

You're thinking about this the wrong way.  We aren't emulating an 
iso9660 image; we are emulating a CD player.  (In principle we could 
even emulate an audio CD, but the driver doesn't support that.)

 * There's 99 minutes dics even for cdrom, see:
 http://en.wikipedia.org/wiki/CD-R 
 If we code to support different size discs, it will looks like a wrong way.

Look at the code you want to remove:

   - if (num_sectors = 256*60*75) {

That's 75 sectors/second * 60 seconds/minute * 256 minutes.  So the
driver already supports up to 256 minutes, which is way beyond the 99
minutes required by the spec.

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 01/19] usb: dwc2: move debugfs code to a separate file

2015-03-09 Thread Mian Yousaf Kaukab
Prepare to add more debug code. Moreover, don't save dentry * for
each file in struct dwc2_hsotg as clean up is done with
debugfs_remove_recursive(). s3c_hsotg_delete_debug() is removed
altogether for the same reason.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/Makefile   |   4 +
 drivers/usb/dwc2/core.h |   7 +-
 drivers/usb/dwc2/debug.h|  27 +++
 drivers/usb/dwc2/debugfs.c  | 414 
 drivers/usb/dwc2/gadget.c   | 405 +--
 drivers/usb/dwc2/pci.c  |   3 +
 drivers/usb/dwc2/platform.c |   3 +
 7 files changed, 456 insertions(+), 407 deletions(-)
 create mode 100644 drivers/usb/dwc2/debug.h
 create mode 100644 drivers/usb/dwc2/debugfs.c

diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile
index 8f75267..147d759 100644
--- a/drivers/usb/dwc2/Makefile
+++ b/drivers/usb/dwc2/Makefile
@@ -13,6 +13,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC2_PERIPHERAL) 
$(CONFIG_USB_DWC2_DUAL_ROLE)),)
dwc2-y  += gadget.o
 endif
 
+ifneq ($(CONFIG_DEBUG_FS),)
+   dwc2-y  += debugfs.o
+endif
+
 # NOTE: The previous s3c-hsotg peripheral mode only driver has been moved to
 # this location and renamed gadget.c. When building for dynamically linked
 # modules, dwc2.ko will get built for host mode, peripheral mode, and dual-role
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index f74304b..9e2bf4d 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -613,9 +613,6 @@ struct dwc2_hsotg {
enum dwc2_lx_state lx_state;
 
struct dentry *debug_root;
-   struct dentry *debug_file;
-   struct dentry *debug_testmode;
-   struct dentry *debug_fifo;
 
/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a0x4f54271a
@@ -1003,6 +1000,7 @@ extern void s3c_hsotg_core_init_disconnected(struct 
dwc2_hsotg *dwc2,
bool reset);
 extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
+extern int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
 #else
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -1016,6 +1014,9 @@ static inline void 
s3c_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
bool reset) {}
 static inline void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg) {}
 static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) {}
+static inline int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
+   int testmode)
+{ return 0; }
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/debug.h b/drivers/usb/dwc2/debug.h
new file mode 100644
index 000..12dbd1d
--- /dev/null
+++ b/drivers/usb/dwc2/debug.h
@@ -0,0 +1,27 @@
+/**
+ * debug.h - Designware USB2 DRD controller debug header
+ *
+ * Copyright (C) 2015 Intel Corporation
+ * Mian Yousaf Kaukab yousaf.kau...@intel.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include core.h
+
+#ifdef CONFIG_DEBUG_FS
+extern int dwc2_debugfs_init(struct dwc2_hsotg *);
+extern void dwc2_debugfs_exit(struct dwc2_hsotg *);
+#else
+static inline int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
+{  return 0;  }
+static inline void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
+{  }
+#endif
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
new file mode 100644
index 000..6c3225c
--- /dev/null
+++ b/drivers/usb/dwc2/debugfs.c
@@ -0,0 +1,414 @@
+/**
+ * debugfs.c - Designware USB2 DRD controller debugfs
+ *
+ * Copyright (C) 2015 Intel Corporation
+ * Mian Yousaf Kaukab yousaf.kau...@intel.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/spinlock.h
+#include linux/debugfs.h
+#include linux/seq_file.h
+#include linux/uaccess.h
+
+#include core.h
+#include debug.h
+
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+   IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
+/**
+ * testmode_write - debugfs: change 

[PATCH 17/19] usb: dwc2: host: spinlock urb_enqueue

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

During urb_enqueue, if the urb can't be queued to the endpoint,
the urb is freed without any spinlock protection.
This leads to memory corruption when concurrent urb_dequeue try to free
same urb-hcpriv.
Thus, ensure the whole urb_enqueue in spinlocked.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd.c   | 14 +++---
 drivers/usb/dwc2/hcd_queue.c |  6 --
 2 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index fd02b43..011b679 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -354,7 +354,6 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
gfp_t mem_flags)
 {
struct dwc2_qtd *qtd;
-   unsigned long flags;
u32 intr_mask;
int retval;
int dev_speed;
@@ -405,11 +404,9 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
 */
return 0;
 
-   spin_lock_irqsave(hsotg-lock, flags);
tr_type = dwc2_hcd_select_transactions(hsotg);
if (tr_type != DWC2_TRANSACTION_NONE)
dwc2_hcd_queue_transactions(hsotg, tr_type);
-   spin_unlock_irqrestore(hsotg-lock, flags);
}
 
return 0;
@@ -2424,6 +2421,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
void *buf;
unsigned long flags;
 
+   spin_lock_irqsave(hsotg-lock, flags);
if (dbg_urb(urb)) {
dev_vdbg(hsotg-dev, DWC OTG HCD URB Enqueue\n);
dwc2_dump_urb_info(hcd, urb, urb_enqueue);
@@ -2434,10 +2432,8 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
 
if (usb_pipetype(urb-pipe) == PIPE_ISOCHRONOUS ||
usb_pipetype(urb-pipe) == PIPE_INTERRUPT) {
-   spin_lock_irqsave(hsotg-lock, flags);
if (!dwc2_hcd_is_bandwidth_allocated(hsotg, ep))
alloc_bandwidth = 1;
-   spin_unlock_irqrestore(hsotg-lock, flags);
}
 
switch (usb_pipetype(urb-pipe)) {
@@ -2502,9 +2498,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
 
urb-hcpriv = dwc2_urb;
 
-   spin_lock_irqsave(hsotg-lock, flags);
retval = usb_hcd_link_urb_to_ep(hcd, urb);
-   spin_unlock_irqrestore(hsotg-lock, flags);
if (retval)
goto fail1;
 
@@ -2513,23 +2507,21 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
struct urb *urb,
goto fail2;
 
if (alloc_bandwidth) {
-   spin_lock_irqsave(hsotg-lock, flags);
dwc2_allocate_bus_bandwidth(hcd,
dwc2_hcd_get_ep_bandwidth(hsotg, ep),
urb);
-   spin_unlock_irqrestore(hsotg-lock, flags);
}
 
+   spin_unlock_irqrestore(hsotg-lock, flags);
return 0;
 
 fail2:
-   spin_lock_irqsave(hsotg-lock, flags);
dwc2_urb-priv = NULL;
usb_hcd_unlink_urb_from_ep(hcd, urb);
-   spin_unlock_irqrestore(hsotg-lock, flags);
 fail1:
urb-hcpriv = NULL;
kfree(dwc2_urb);
+   spin_unlock_irqrestore(hsotg-lock, flags);
 
return retval;
 }
diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c
index bb97838..02103b66 100644
--- a/drivers/usb/dwc2/hcd_queue.c
+++ b/drivers/usb/dwc2/hcd_queue.c
@@ -777,7 +777,6 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
 struct dwc2_qh **qh, gfp_t mem_flags)
 {
struct dwc2_hcd_urb *urb = qtd-urb;
-   unsigned long flags;
int allocated = 0;
int retval;
 
@@ -792,7 +791,6 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
allocated = 1;
}
 
-   spin_lock_irqsave(hsotg-lock, flags);
 
retval = dwc2_hcd_qh_add(hsotg, *qh);
if (retval)
@@ -800,7 +798,6 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct 
dwc2_qtd *qtd,
 
qtd-qh = *qh;
list_add_tail(qtd-qtd_list_entry, (*qh)-qtd_list);
-   spin_unlock_irqrestore(hsotg-lock, flags);
 
return 0;
 
@@ -817,10 +814,7 @@ fail:
 qtd_list_entry)
dwc2_hcd_qtd_unlink_and_free(hsotg, qtd2, qh_tmp);
 
-   spin_unlock_irqrestore(hsotg-lock, flags);
dwc2_hcd_qh_free(hsotg, qh_tmp);
-   } else {
-   spin_unlock_irqrestore(hsotg-lock, flags);
}
 
return retval;
-- 
1.9.1

--
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 04/19] usb: dwc2: implement hibernation during bus suspend/resume

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Allow controller to enter in hibernation during usb bus suspend and
inform both phy and gadget about the suspended state.
While in hibernation, the controller can't detect the resume condition.
An external mechanism must call usb_phy_set_suspend on resume.
Exit hibernation when controller gets the resume interrupt and inform
only gadget driver about it.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/core.h  |  2 ++
 drivers/usb/dwc2/core_intr.c | 32 
 2 files changed, 34 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index d62b904..b14aa38 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1086,6 +1086,7 @@ extern void s3c_hsotg_core_init_disconnected(struct 
dwc2_hsotg *dwc2,
 extern void s3c_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2);
 extern int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
+#define dwc2_is_device_connected(hsotg) (hsotg-connected)
 #else
 static inline int s3c_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -1102,6 +1103,7 @@ static inline void s3c_hsotg_disconnect(struct dwc2_hsotg 
*dwc2) {}
 static inline int s3c_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
int testmode)
 { return 0; }
+#define dwc2_is_device_connected(hsotg) (0)
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 02e3e2d..42f2fd5 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -334,6 +334,7 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg 
*hsotg)
  */
 static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg)
 {
+   int ret;
dev_dbg(hsotg-dev, ++Resume or Remote Wakeup Detected Interrupt++\n);
dev_dbg(hsotg-dev, %s lxstate = %d\n, __func__, hsotg-lx_state);
 
@@ -345,6 +346,11 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
/* Clear Remote Wakeup Signaling */
dctl = ~DCTL_RMTWKUPSIG;
writel(dctl, hsotg-regs + DCTL);
+   ret = dwc2_exit_hibernation(hsotg, true);
+   if (ret)
+   dev_err(hsotg-dev, exit hibernation 
failed\n);
+
+   call_gadget(hsotg, resume);
}
/* Change to L0 state */
hsotg-lx_state = DWC2_L0;
@@ -394,6 +400,7 @@ static void dwc2_handle_disconnect_intr(struct dwc2_hsotg 
*hsotg)
 static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg)
 {
u32 dsts;
+   int ret;
 
dev_dbg(hsotg-dev, USB SUSPEND\n);
 
@@ -408,6 +415,30 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n,
!!(dsts  DSTS_SUSPSTS),
hsotg-hw_params.power_optimized);
+   if ((dsts  DSTS_SUSPSTS)  hsotg-hw_params.power_optimized) {
+   /* Ignore suspend request before enumeration */
+   if (!dwc2_is_device_connected(hsotg)) {
+   dev_dbg(hsotg-dev,
+   ignore suspend request before 
enumeration\n);
+   goto clear_int;
+   }
+
+   ret = dwc2_enter_hibernation(hsotg);
+   if (ret) {
+   dev_err(hsotg-dev,
+   enter hibernation failed\n);
+   goto skip_power_saving;
+   }
+
+   udelay(100);
+
+   /* Ask phy to be suspended */
+   if (!IS_ERR_OR_NULL(hsotg-uphy))
+   usb_phy_set_suspend(hsotg-uphy, true);
+skip_power_saving:
+   /* Call gadget suspend callback */
+   call_gadget(hsotg, suspend);
+   }
} else {
if (hsotg-op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg-dev, a_peripheral-a_host\n);
@@ -423,6 +454,7 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
/* Change to L2 (suspend) state */
hsotg-lx_state = DWC2_L2;
 
+clear_int:
/* Clear interrupt */
writel(GINTSTS_USBSUSP, hsotg-regs + GINTSTS);
 }
-- 
1.9.1

--
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 11/19] usb: dwc2: gadget: powerup controller if needed

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

During vbus session, usb controller needs to exit hibernation if it was
previously in suspend state.
Since controller will be resetted and configured, there is no need
to restore registers.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 72df171..bb83826 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3205,6 +3205,14 @@ static int s3c_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
spin_lock_irqsave(hsotg-lock, flags);
 
if (is_active) {
+   /*
+* If controller is hibernated, it must exit from hibernation
+* before being initialized
+*/
+   if (hsotg-lx_state == DWC2_L2) {
+   dwc2_exit_hibernation(hsotg, false);
+   hsotg-lx_state = DWC2_L0;
+   }
/* Kill any ep0 requests as controller will be reinitialized */
kill_all_requests(hsotg, hsotg-eps_out[0], -ECONNRESET);
s3c_hsotg_core_init_disconnected(hsotg, false);
-- 
1.9.1

--
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 13/19] usb: dwc2: gadget: remove s3c_hsotg_ep_disable_force

2015-03-09 Thread Mian Yousaf Kaukab
Force argument is not used anymore. Clean up leftovers from
https://lkml.org/lkml/2014/12/9/283

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/gadget.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 2e27bfd..7a83940 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2763,7 +2763,7 @@ error:
  * s3c_hsotg_ep_disable - disable given endpoint
  * @ep: The endpoint to disable.
  */
-static int s3c_hsotg_ep_disable_force(struct usb_ep *ep, bool force)
+static int s3c_hsotg_ep_disable(struct usb_ep *ep)
 {
struct s3c_hsotg_ep *hs_ep = our_ep(ep);
struct dwc2_hsotg *hsotg = hs_ep-parent;
@@ -2806,10 +2806,6 @@ static int s3c_hsotg_ep_disable_force(struct usb_ep *ep, 
bool force)
return 0;
 }
 
-static int s3c_hsotg_ep_disable(struct usb_ep *ep)
-{
-   return s3c_hsotg_ep_disable_force(ep, false);
-}
 /**
  * on_list - check request is on the given endpoint
  * @ep: The endpoint to check.
-- 
1.9.1

--
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 08/19] usb: dwc2: gadget: use reset detect interrupt

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

ResetDet interrupt is used to detect a reset of the bus
while the controller is suspended.
This may happens for example when using Command Verifier.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bed56dc..d528c02 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2308,8 +2308,9 @@ void s3c_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
writel(GINTSTS_ERLYSUSP | GINTSTS_SESSREQINT |
GINTSTS_GOUTNAKEFF | GINTSTS_GINNAKEFF |
GINTSTS_CONIDSTSCHNG | GINTSTS_USBRST |
-   GINTSTS_ENUMDONE | GINTSTS_OTGINT |
-   GINTSTS_USBSUSP | GINTSTS_WKUPINT,
+   GINTSTS_RESETDET | GINTSTS_ENUMDONE |
+   GINTSTS_OTGINT | GINTSTS_USBSUSP |
+   GINTSTS_WKUPINT,
hsotg-regs + GINTMSK);
 
if (using_dma(hsotg))
@@ -2475,7 +2476,19 @@ irq_retry:
}
}
 
-   if (gintsts  GINTSTS_USBRST) {
+   if (gintsts  GINTSTS_RESETDET) {
+   dev_dbg(hsotg-dev, %s: USBRstDet\n, __func__);
+
+   writel(GINTSTS_RESETDET, hsotg-regs + GINTSTS);
+
+   /* This event must be used only if controller is suspended */
+   if (hsotg-lx_state == DWC2_L2) {
+   dwc2_exit_hibernation(hsotg, true);
+   hsotg-lx_state = DWC2_L0;
+   }
+   }
+
+   if ((gintsts  GINTSTS_USBRST) || (gintsts  GINTSTS_RESETDET)) {
 
u32 usb_status = readl(hsotg-regs + GOTGCTL);
 
-- 
1.9.1

--
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 05/19] usb: dwc2: controller must update lx_state before releasing lock

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

During suspend, there could a race condition between ep_queue and
suspend interrupt if lx_state is updated after releasing spinlock in
call_gadget(hsotg, suspend).

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/core_intr.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 42f2fd5..f5ef26e 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -436,6 +436,12 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
if (!IS_ERR_OR_NULL(hsotg-uphy))
usb_phy_set_suspend(hsotg-uphy, true);
 skip_power_saving:
+   /*
+* Change to L2 (suspend) state before releasing
+* spinlock
+*/
+   hsotg-lx_state = DWC2_L2;
+
/* Call gadget suspend callback */
call_gadget(hsotg, suspend);
}
@@ -443,6 +449,8 @@ skip_power_saving:
if (hsotg-op_state == OTG_STATE_A_PERIPHERAL) {
dev_dbg(hsotg-dev, a_peripheral-a_host\n);
 
+   /* Change to L2 (suspend) state */
+   hsotg-lx_state = DWC2_L2;
/* Clear the a_peripheral flag, back to a_host */
spin_unlock(hsotg-lock);
dwc2_hcd_start(hsotg);
@@ -451,9 +459,6 @@ skip_power_saving:
}
}
 
-   /* Change to L2 (suspend) state */
-   hsotg-lx_state = DWC2_L2;
-
 clear_int:
/* Clear interrupt */
writel(GINTSTS_USBSUSP, hsotg-regs + GINTSTS);
-- 
1.9.1

--
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 19/19] usb: dwc2: host: implement test mode

2015-03-09 Thread Mian Yousaf Kaukab
From: Jingwu Lin jingwu@intel.com

Add support for SetPortFeature(PORT_TEST) for root port.

Signed-off-by: Jingwu Lin jingwu@intel.com
---
 drivers/usb/dwc2/hcd.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 7ebf6cc..c46b863 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -1764,6 +1764,15 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg 
*hsotg, u16 typereq,
/* Not supported */
break;
 
+   case USB_PORT_FEAT_TEST:
+   hprt0 = dwc2_read_hprt0(hsotg);
+   dev_dbg(hsotg-dev,
+   SetPortFeature - USB_PORT_FEAT_TEST\n);
+   hprt0 = ~HPRT0_TSTCTL_MASK;
+   hprt0 |= (windex  8)  HPRT0_TSTCTL_SHIFT;
+   writel(hprt0, hsotg-regs + HPRT0);
+   break;
+
default:
retval = -EINVAL;
dev_err(hsotg-dev,
-- 
1.9.1

--
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 16/19] usb: dwc2: host: resume root hub on port connect

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

Once hub is runtime suspended, dwc2 must resume it
on port connect event.
Else, roothub will stay in suspended state and will
not resume transfers.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/hcd_intr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index 551ba87..6927bba 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -350,6 +350,9 @@ static void dwc2_port_intr(struct dwc2_hsotg *hsotg)
dev_vdbg(hsotg-dev,
 --Port Interrupt HPRT0=0x%08x Port Connect 
Detected--\n,
 hprt0);
+   if (hsotg-lx_state != DWC2_L0)
+   usb_hcd_resume_root_hub(hsotg-priv);
+
hsotg-flags.b.port_connect_status_change = 1;
hsotg-flags.b.port_connect_status = 1;
hprt0_modify |= HPRT0_CONNDET;
-- 
1.9.1

--
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 10/19] usb: dwc2: gadget: prevent new request submission during suspend

2015-03-09 Thread Mian Yousaf Kaukab
From: Gregory Herrero gregory.herr...@intel.com

If usb controller is in partial power down, any write to registers may
cause unpredictable behavior.
Thus, prevent any new request submission once controller is in partial
power down.

Signed-off-by: Gregory Herrero gregory.herr...@intel.com
---
 drivers/usb/dwc2/gadget.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 539a3d4..72df171 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -790,6 +790,13 @@ static int s3c_hsotg_ep_queue(struct usb_ep *ep, struct 
usb_request *req,
ep-name, req, req-length, req-buf, req-no_interrupt,
req-zero, req-short_not_ok);
 
+   /* Prevent new request submission when controller is suspended */
+   if (hs-lx_state == DWC2_L2) {
+   dev_dbg(hs-dev, %s: don't submit request while suspended\n,
+   __func__);
+   return -EAGAIN;
+   }
+
/* initialise status of the request */
INIT_LIST_HEAD(hs_req-queue);
req-actual = 0;
-- 
1.9.1

--
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 07/19] usb: dwc2: set parameter values in probe function

2015-03-09 Thread Mian Yousaf Kaukab
So the parameters can be used in both host and gadget modes.

Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
---
 drivers/usb/dwc2/core.h |  3 +--
 drivers/usb/dwc2/hcd.c  | 18 +-
 drivers/usb/dwc2/hcd.h  |  3 +--
 drivers/usb/dwc2/pci.c  | 17 -
 drivers/usb/dwc2/platform.c | 18 +-
 5 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 795e4ed..9098749 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1123,8 +1123,7 @@ static inline int dwc2_hcd_get_frame_number(struct 
dwc2_hsotg *hsotg)
 static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
 static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
 static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
-static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
-   const struct dwc2_core_params *params)
+static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 { return 0; }
 #endif
 
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index c78c874..908fc8a 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -2775,8 +2775,7 @@ EXPORT_SYMBOL_GPL(dwc2_set_all_params);
  * USB bus with the core and calls the hc_driver-start() function. It returns
  * a negative error on failure.
  */
-int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
- const struct dwc2_core_params *params)
+int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
 {
struct usb_hcd *hcd;
struct dwc2_host_chan *channel;
@@ -2789,12 +2788,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 
dev_dbg(hsotg-dev, DWC OTG HCD INIT\n);
 
-   /* Detect config values from hardware */
-   retval = dwc2_get_hwparams(hsotg);
-
-   if (retval)
-   return retval;
-
retval = -ENOMEM;
 
hcfg = readl(hsotg-regs + HCFG);
@@ -2813,15 +2806,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
hsotg-last_frame_num = HFNUM_MAX_FRNUM;
 #endif
 
-   hsotg-core_params = kzalloc(sizeof(*hsotg-core_params), GFP_KERNEL);
-   if (!hsotg-core_params)
-   goto error1;
-
-   dwc2_set_all_params(hsotg-core_params, -1);
-
-   /* Validate parameter values */
-   dwc2_set_parameters(hsotg, params);
-
/* Check if the bus driver or platform code has setup a dma_mask */
if (hsotg-core_params-dma_enable  0 
hsotg-dev-dma_mask == NULL) {
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
index e69a843..cd803ae 100644
--- a/drivers/usb/dwc2/hcd.h
+++ b/drivers/usb/dwc2/hcd.h
@@ -451,8 +451,7 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
dwc2_hcd_pipe_info *pipe)
return !dwc2_hcd_is_pipe_in(pipe);
 }
 
-extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
-const struct dwc2_core_params *params);
+extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq);
 extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
 extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
const struct dwc2_core_params *params);
diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
index e5e6ab9..2e82268 100644
--- a/drivers/usb/dwc2/pci.c
+++ b/drivers/usb/dwc2/pci.c
@@ -147,8 +147,23 @@ static int dwc2_driver_probe(struct pci_dev *dev,
if (retval)
return retval;
 
+   /* Detect config values from hardware */
+   retval = dwc2_get_hwparams(hsotg);
+   if (retval)
+   return retval;
+
+   hsotg-core_params = devm_kzalloc(dev-dev,
+   sizeof(*hsotg-core_params), GFP_KERNEL);
+   if (!hsotg-core_params)
+   return -ENOMEM;
+
+   dwc2_set_all_params(hsotg-core_params, -1);
+
+   /* Validate parameter values */
+   dwc2_set_parameters(hsotg, dwc2_module_params);
+
spin_lock_init(hsotg-lock);
-   retval = dwc2_hcd_init(hsotg, dev-irq, dwc2_module_params);
+   retval = dwc2_hcd_init(hsotg, dev-irq);
if (retval) {
pci_disable_device(dev);
return retval;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index f9b7d9f..a6d4b43 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -237,10 +237,26 @@ static int dwc2_driver_probe(struct platform_device *dev)
 
spin_lock_init(hsotg-lock);
mutex_init(hsotg-init_mutex);
+
+   /* Detect config values from hardware */
+   retval = dwc2_get_hwparams(hsotg);
+   if (retval)
+   return retval;
+
+   hsotg-core_params = devm_kzalloc(dev-dev,
+   sizeof(*hsotg-core_params), GFP_KERNEL);
+   if (!hsotg-core_params)
+   return -ENOMEM;
+
+   dwc2_set_all_params(hsotg-core_params, -1);
+
+   /* Validate parameter values */
+ 

[PATCH 00/19] usb: third series of updates for dwc2 driver

2015-03-09 Thread Mian Yousaf Kaukab
Hi,
This patchset consists of some bug fixes and feature enhancements for
the dwc2 driver. All the patches are verified on dwc2 v3.0a with
dedicated fifos. Main focus of testing was with dma enabled. Although
basic testing without dma was also done.

This is based on testing/next branch in Felipe's git.

Thank you,

Best regards,
Yousaf

Gregory Herrero (13):
  usb: dwc2: add controller hibernation support
  usb: dwc2: implement hibernation during bus suspend/resume
  usb: dwc2: controller must update lx_state before releasing lock
  usb: dwc2: add external_id_pin_ctl core parameter
  usb: dwc2: gadget: use reset detect interrupt
  usb: dwc2: gadget: ignore pm suspend/resume in L2
  usb: dwc2: gadget: prevent new request submission during suspend
  usb: dwc2: gadget: powerup controller if needed
  usb: dwc2: gadget: enable otg flag in dual role configuration
  usb: dwc2: host: add bus_suspend/bus_resume callback
  usb: dwc2: host: resume root hub on port connect
  usb: dwc2: host: spinlock urb_enqueue
  usb: dwc2: host: don't use dma_alloc_coherent with irqs disabled

Jingwu Lin (1):
  usb: dwc2: host: implement test mode

Mian Yousaf Kaukab (5):
  usb: dwc2: move debugfs code to a separate file
  usb: dwc2: debugfs: add support for complete register dump
  usb: dwc2: set parameter values in probe function
  usb: dwc2: gadget: remove s3c_hsotg_ep_disable_force
  usb: dwc2: host: register handle to the phy

 drivers/usb/dwc2/Makefile|   4 +
 drivers/usb/dwc2/core.c  | 398 +-
 drivers/usb/dwc2/core.h  | 103 +-
 drivers/usb/dwc2/core_intr.c |  43 ++-
 drivers/usb/dwc2/debug.h |  27 ++
 drivers/usb/dwc2/debugfs.c   | 770 +++
 drivers/usb/dwc2/gadget.c| 454 +++--
 drivers/usb/dwc2/hcd.c   |  73 ++--
 drivers/usb/dwc2/hcd.h   |   3 +-
 drivers/usb/dwc2/hcd_intr.c  |  13 +
 drivers/usb/dwc2/hcd_queue.c |  13 +-
 drivers/usb/dwc2/pci.c   |  20 +-
 drivers/usb/dwc2/platform.c  |  23 +-
 13 files changed, 1479 insertions(+), 465 deletions(-)
 create mode 100644 drivers/usb/dwc2/debug.h
 create mode 100644 drivers/usb/dwc2/debugfs.c

-- 
1.9.1

--
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 gadget: remove size limitation for storage cdrom

2015-03-09 Thread Alan Stern
On Mon, 9 Mar 2015, Alan Stern wrote:

  They are both iso9660 images, aren't they? So from data image point
  of view there's no difference, it is not worth to create another mode
  for dvd data.
 
 There's more to emulation than just the image.  We have to emulate the 
 hardware's response to all the applicable commands.  CD players have a 
 different command set from DVD players (or at least, different from DVD 
 players when a DVD is inserted).  For example, see the definition in 
 the MSF format for READ TOC command.

Or to put it another way: The change you want to make would break the
store_cdrom_address() routine in storage_common.c.

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


Re: [PATCH v2] usb: isp1760: add peripheral/device controller chip id

2015-03-09 Thread Sudeep Holla

Hi Filipe,

On 09/03/15 15:49, Felipe Balbi wrote:

On Wed, Mar 04, 2015 at 03:56:12PM +, Sudeep Holla wrote:



On 26/02/15 18:53, Laurent Pinchart wrote:

Hi Sudeep,

Thank you for the patch.

On Thursday 26 February 2015 11:47:57 Sudeep Holla wrote:

As per the SAF1761 data sheet[0], the DcChipID register represents
the hardware version number (0001h) and the chip ID (1582h) for the
Peripheral Controller.

However as per the ISP1761 data sheet[1], the DcChipID register
represents the hardware version number (0015h) and the chip ID (8210h)
for the Peripheral Controller.

This patch adds support for both the chip ID values.

[0] http://www.nxp.com/documents/data_sheet/SAF1761.pdf
[1] http://pdf.datasheetcatalog.com/datasheets2/74/742102_1.pdf

Cc: Felipe Balbi ba...@ti.com
Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
Signed-off-by: Sudeep Holla sudeep.ho...@arm.com


Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com



Thanks. I assume Felipe will pick this up.


I will, but I need Laurent's Ack.



I am confused, Laurent has already Ack-ed(see above) this patch[0]
as well as [1].

Regards,
Sudeep

[0] https://lkml.org/lkml/2015/2/26/525
[1] https://lkml.org/lkml/2015/3/5/209

--
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] extcon: otg_gpio: add driver for USB OTG port controlled by GPIO(s)

2015-03-09 Thread Felipe Balbi
On Sat, Mar 07, 2015 at 09:06:22PM +0100, Linus Walleij wrote:
 On Fri, Feb 20, 2015 at 8:17 PM, David Cohen
 david.a.co...@linux.intel.com wrote:
  On Fri, Feb 20, 2015 at 10:53:44AM +0100, Linus Walleij wrote:
 
  I would put this adjacent to the phy driver somewhere in drivers/usb/*
  and make the actual USB-driver thing handle its GPIOs directly.
  But I guess David and Felipe have already discussed that as we're
  seeing this patch?
 
  - The mux functions would be controlled by a possible new pinctrl-gpio
  driver (Linus, your input here would be nice :)
 
 I don't understand what this means, does it mean a pin control function
 somewhere else controlled by a GPIO pin?
 
 Or do you mean a new combined pin control and GPIO driver (we have
 plenty of these).
 
 If you elaborate on what you need to do in that driver I might
 understand it better.

there's a discrete mux (not something integrated in the SoC) whose
select signal is tied to a GPIO (in some cases, more than one, but
usually people use 2-state muxes).

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] usb: isp1760: add peripheral/device controller chip id

2015-03-09 Thread Felipe Balbi
On Mon, Mar 09, 2015 at 03:58:06PM +, Sudeep Holla wrote:
 Hi Filipe,
 
 On 09/03/15 15:49, Felipe Balbi wrote:
 On Wed, Mar 04, 2015 at 03:56:12PM +, Sudeep Holla wrote:
 
 
 On 26/02/15 18:53, Laurent Pinchart wrote:
 Hi Sudeep,
 
 Thank you for the patch.
 
 On Thursday 26 February 2015 11:47:57 Sudeep Holla wrote:
 As per the SAF1761 data sheet[0], the DcChipID register represents
 the hardware version number (0001h) and the chip ID (1582h) for the
 Peripheral Controller.
 
 However as per the ISP1761 data sheet[1], the DcChipID register
 represents the hardware version number (0015h) and the chip ID (8210h)
 for the Peripheral Controller.
 
 This patch adds support for both the chip ID values.
 
 [0] http://www.nxp.com/documents/data_sheet/SAF1761.pdf
 [1] http://pdf.datasheetcatalog.com/datasheets2/74/742102_1.pdf
 
 Cc: Felipe Balbi ba...@ti.com
 Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com
 Signed-off-by: Sudeep Holla sudeep.ho...@arm.com
 
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 
 
 Thanks. I assume Felipe will pick this up.
 
 I will, but I need Laurent's Ack.
 
 
 I am confused, Laurent has already Ack-ed(see above) this patch[0]
 as well as [1].

yeah, just came back from vacations, going through my inbox.

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH v3] usb: dwc2: gadget reuse ahbcfg assigned from platform

2015-03-09 Thread Kaukab, Yousaf

 -Original Message-
 From: John Youn [mailto:john.y...@synopsys.com]
 Sent: Tuesday, February 24, 2015 3:27 AM
 To: zhangfei; John Youn; ba...@ti.com; Kaukab, Yousaf
 Cc: linux-usb@vger.kernel.org
 Subject: Re: [PATCH v3] usb: dwc2: gadget reuse ahbcfg assigned from platform
 
 On 2/20/2015 7:26 PM, zhangfei wrote:
  Hi, John
 
  On 02/21/2015 08:35 AM, John Youn wrote:
  On 2/15/2015 5:50 AM, Zhangfei Gao wrote:
  Reuse ahbcfg if assigned from platform
 
  Input from John:
  AHB_SINGLE, NOTI_ALL_DMA_WRIT, REM_MEM_SUPP, HBSTLEN, and
  INV_DESC_ENDIANNESS only apply in DMA mode and are ignored in slave
  mode operation.
 
  Signed-off-by: Zhangfei Gao zhangfei@linaro.org
  ---
drivers/usb/dwc2/gadget.c | 11 ---
1 file changed, 8 insertions(+), 3 deletions(-)
 
  diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
  index 15aa578..5726fbe 100644
  --- a/drivers/usb/dwc2/gadget.c
  +++ b/drivers/usb/dwc2/gadget.c
  @@ -2314,14 +2314,19 @@ void s3c_hsotg_core_init_disconnected(struct
 dwc2_hsotg *hsotg,
GINTSTS_USBSUSP | GINTSTS_WKUPINT,
hsotg-regs + GINTMSK);
 
  + if (hsotg-core_params  hsotg-core_params-ahbcfg != -1)
  + val = hsotg-core_params-ahbcfg 
 ~GAHBCFG_CTRL_MASK;
  + else
  + val = 0;
  +
if (using_dma(hsotg))
writel(GAHBCFG_GLBL_INTR_EN |
 GAHBCFG_DMA_EN |
  -(GAHBCFG_HBSTLEN_INCR4 
 GAHBCFG_HBSTLEN_SHIFT),
  -hsotg-regs + GAHBCFG);
  +(val ? val : GAHBCFG_HBSTLEN_INCR4 
  +GAHBCFG_HBSTLEN_SHIFT), hsotg-regs +
 GAHBCFG);
else
writel(((hsotg-dedicated_fifos) ?
 (GAHBCFG_NP_TXF_EMP_LVL |
 
   GAHBCFG_P_TXF_EMP_LVL) : 0) |
  -GAHBCFG_GLBL_INTR_EN,
  +GAHBCFG_GLBL_INTR_EN | val,
   hsotg-regs + GAHBCFG);
 
/*
 
 
  Hi Zhangfei,
 
  It looks like currently that the hsotg-core_params structure is not 
  designed
 to be accessed by the gadget part (or this structure was overlooked during the
 integration of these drivers). It is only initialized in the host mode and 
 this
 should crash if host mode is not configured.
 
  If dwc2_hcd_init only called in host mode, hsotg-core_params = NULL.
  So add judgement if (hsotg-core_params) here to prevent crash.
 
 Yes you're right. However core_params is documented as both a device and
 host accessible member but it is only ever initialized and used in host mode. 
 I
 think it should be fixed to always have valid and initialized values in device
 mode as well.

http://permalink.gmane.org/gmane.linux.usb.general/123272 should fix this.

 
 John
 
 

BR,
Yousaf


Re: [PATCH v2] Remove deprecated IRQF_DISABLED flag entirely

2015-03-09 Thread Felipe Balbi
Hi,

On Thu, Mar 05, 2015 at 03:23:08PM +0100, Valentin Rothberg wrote:
 The IRQF_DISABLED is a NOOP and has been scheduled for removal since
 Linux v2.6.36 by commit 6932bf37bed4 (genirq: Remove IRQF_DISABLED from
 core code).
 
 According to commit e58aa3d2d0cc (genirq: Run irq handlers with
 interrupts disabled) running IRQ handlers with interrupts enabled can
 cause stack overflows when the interrupt line of the issuing device is
 still active.
 
 This patch ends the grace period for IRQF_DISABLED (i.e., SA_INTERRUPT
 in older versions of Linux) and removes the definition and all remaining
 usages of this flag.
 
 Signed-off-by: Valentin Rothberg valentinrothb...@gmail.com
 ---
 The bigger hunk in Documentation/scsi/ncr53c8xx.txt is removed entirely
 as IRQF_DISABLED is gone now; the usage in older kernel versions
 (including the old SA_INTERRUPT flag) should be discouraged.  The
 trouble of using IRQF_SHARED is a general problem and not specific to
 any driver.
 
 I left the reference in Documentation/PCI/MSI-HOWTO.txt untouched since
 it has already been removed in linux-next by commit b0e1ee8e1405
 (MSI-HOWTO.txt: remove reference on IRQF_DISABLED).
 
 All remaining references are changelogs that I suggest to keep.
 
 Changelog
 
 v2: Correct previous change to drivers/mtd/nand/hisi504_nand.c that
 broke compilation.  Reported by Dan Carpenter.
 ---
  drivers/usb/isp1760/isp1760-core.c   |  3 +--
  drivers/usb/isp1760/isp1760-udc.c|  4 ++--

I have a commit in my tree for isp1760:

https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing/fixesid=80b4a0f8feeb6ee7fa4430a2b4ae1155ed923bd2

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2] Remove deprecated IRQF_DISABLED flag entirely

2015-03-09 Thread Valentin Rothberg
On Mon, Mar 9, 2015 at 5:52 PM, Felipe Balbi ba...@ti.com wrote:
 Hi,

 On Thu, Mar 05, 2015 at 03:23:08PM +0100, Valentin Rothberg wrote:
 The IRQF_DISABLED is a NOOP and has been scheduled for removal since
 Linux v2.6.36 by commit 6932bf37bed4 (genirq: Remove IRQF_DISABLED from
 core code).

 According to commit e58aa3d2d0cc (genirq: Run irq handlers with
 interrupts disabled) running IRQ handlers with interrupts enabled can
 cause stack overflows when the interrupt line of the issuing device is
 still active.

 This patch ends the grace period for IRQF_DISABLED (i.e., SA_INTERRUPT
 in older versions of Linux) and removes the definition and all remaining
 usages of this flag.

 Signed-off-by: Valentin Rothberg valentinrothb...@gmail.com
 ---
 The bigger hunk in Documentation/scsi/ncr53c8xx.txt is removed entirely
 as IRQF_DISABLED is gone now; the usage in older kernel versions
 (including the old SA_INTERRUPT flag) should be discouraged.  The
 trouble of using IRQF_SHARED is a general problem and not specific to
 any driver.

 I left the reference in Documentation/PCI/MSI-HOWTO.txt untouched since
 it has already been removed in linux-next by commit b0e1ee8e1405
 (MSI-HOWTO.txt: remove reference on IRQF_DISABLED).

 All remaining references are changelogs that I suggest to keep.

 Changelog

 v2: Correct previous change to drivers/mtd/nand/hisi504_nand.c that
 broke compilation.  Reported by Dan Carpenter.
 ---
  drivers/usb/isp1760/isp1760-core.c   |  3 +--
  drivers/usb/isp1760/isp1760-udc.c|  4 ++--

 I have a commit in my tree for isp1760:

 https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing/fixesid=80b4a0f8feeb6ee7fa4430a2b4ae1155ed923bd2

I am sorry, but I did not receive an email that it has been applied.
Andrew asked me to do this patch, so I replied to the one you
mentioned to avoid this conflict:

http://comments.gmane.org/gmane.linux.kernel/1896211

Kind regards,
 Valentin
--
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] Remove deprecated IRQF_DISABLED flag entirely

2015-03-09 Thread Felipe Balbi
On Mon, Mar 09, 2015 at 06:24:29PM +0100, Valentin Rothberg wrote:
 On Mon, Mar 9, 2015 at 5:52 PM, Felipe Balbi ba...@ti.com wrote:
  Hi,
 
  On Thu, Mar 05, 2015 at 03:23:08PM +0100, Valentin Rothberg wrote:
  The IRQF_DISABLED is a NOOP and has been scheduled for removal since
  Linux v2.6.36 by commit 6932bf37bed4 (genirq: Remove IRQF_DISABLED from
  core code).
 
  According to commit e58aa3d2d0cc (genirq: Run irq handlers with
  interrupts disabled) running IRQ handlers with interrupts enabled can
  cause stack overflows when the interrupt line of the issuing device is
  still active.
 
  This patch ends the grace period for IRQF_DISABLED (i.e., SA_INTERRUPT
  in older versions of Linux) and removes the definition and all remaining
  usages of this flag.
 
  Signed-off-by: Valentin Rothberg valentinrothb...@gmail.com
  ---
  The bigger hunk in Documentation/scsi/ncr53c8xx.txt is removed entirely
  as IRQF_DISABLED is gone now; the usage in older kernel versions
  (including the old SA_INTERRUPT flag) should be discouraged.  The
  trouble of using IRQF_SHARED is a general problem and not specific to
  any driver.
 
  I left the reference in Documentation/PCI/MSI-HOWTO.txt untouched since
  it has already been removed in linux-next by commit b0e1ee8e1405
  (MSI-HOWTO.txt: remove reference on IRQF_DISABLED).
 
  All remaining references are changelogs that I suggest to keep.
 
  Changelog
 
  v2: Correct previous change to drivers/mtd/nand/hisi504_nand.c that
  broke compilation.  Reported by Dan Carpenter.
  ---
   drivers/usb/isp1760/isp1760-core.c   |  3 +--
   drivers/usb/isp1760/isp1760-udc.c|  4 ++--
 
  I have a commit in my tree for isp1760:
 
  https://git.kernel.org/cgit/linux/kernel/git/balbi/usb.git/commit/?h=testing/fixesid=80b4a0f8feeb6ee7fa4430a2b4ae1155ed923bd2
 
 I am sorry, but I did not receive an email that it has been applied.
 Andrew asked me to do this patch, so I replied to the one you
 mentioned to avoid this conflict:

it's still in my testing/fixes, it'll be moved to fixes after I finish
testing that branch, then you'll receive an email

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Bin Liu
On Mon, Mar 9, 2015 at 4:20 PM, Tony Lindgren t...@atomide.com wrote:
 * Bin Liu binml...@gmail.com [150309 14:17]:
 On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
  On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
  Hi,
 
  On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
   Add a minimal driver for dm816x USB. Otherwise we can just use
   the existing musb_am335x and musb_dsps on dm816x.
 
  dm816x has the almost identical usbss as that in am335x, we should be
  able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
 
  Tony's using the same musb glue layers, this is just a phy driver,
  right ?

 Can the current am335x phy driver be adopted too? I remember it is
 under drivers/usb/phy/.

 Yes this is just the phy, other than that things work the same.

 I believe this is different from the am335x phy, and more similar to
 what we have in old drivers/usb/musb/davinci.c. Chances are dm814x
 is same as am335x phy.

Alright, I only played the dm814x board a few times, but never with
dm816x, and thought dm816x and dm814x usbss are the same and very
close to am335x - am335x came out later than dm81xx and has some
improvement in usbss.


 But yeah, we really should do a proper phy driver for am335x too
 along the same lines. Might even be be able to combine those drivers
 with just different compatible values to set the quirks and the
 enable/disable functions.

Ok, I agreed we can make dm816x working first, then gradually move
am335x aligned to the framework.

Regards,
-Bin.


 Regards,

 Tony
--
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] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Felipe Balbi
On Mon, Mar 09, 2015 at 04:17:29PM -0500, Bin Liu wrote:
 On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
  On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
  Hi,
 
  On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
   Add a minimal driver for dm816x USB. Otherwise we can just use
   the existing musb_am335x and musb_dsps on dm816x.
 
  dm816x has the almost identical usbss as that in am335x, we should be
  able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
 
  Tony's using the same musb glue layers, this is just a phy driver,
  right ?
 
 Can the current am335x phy driver be adopted too? I remember it is
 under drivers/usb/phy/.

Tony will be best to answer, but according to our IRC discussions, it's
too different. Tony ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Tony Lindgren
* Felipe Balbi ba...@ti.com [150309 14:21]:
 On Mon, Mar 09, 2015 at 04:17:29PM -0500, Bin Liu wrote:
  On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
   On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
   Hi,
  
   On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
Add a minimal driver for dm816x USB. Otherwise we can just use
the existing musb_am335x and musb_dsps on dm816x.
  
   dm816x has the almost identical usbss as that in am335x, we should be
   able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
  
   Tony's using the same musb glue layers, this is just a phy driver,
   right ?
  
  Can the current am335x phy driver be adopted too? I remember it is
  under drivers/usb/phy/.
 
 Tony will be best to answer, but according to our IRC discussions, it's
 too different. Tony ?

Well we should check again between dm814x and am335x documentation
against the $subject driver as the dm816x docs were buggy and I may
have gotten a wrong idea initially. 

Regards,

Tony
--
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 00/15] musb: Add support for the Allwinner sunxi musb controller

2015-03-09 Thread Arnd Bergmann
On Monday 09 March 2015 21:40:13 Hans de Goede wrote:
 Hi All,
 
 This patch set has been a while in the making, so I'm very happy to present
 the end result here, and I hope everyone likes it.

Awesome work!

 Before talking about merging this there are 2 things which I would like to
 point out:
 
 a) The musb controller in the sunxi SoCs uses some SRAM which needs to be
 mapped to the musb controller by poking some bits in the SRAM controller,
 just like the EMAC patches which were send a while back I've chosen to use
 syscon for this, actually 2 of the patches in this set come directly from the
 SRAM mapping patchset for the EMAC.
 
 I know that Maxime is not 100% in favor of using syscon:
 http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/320221.html
 
 But I disagree with his arguments for writing a special driver for the SRAM
 controller:
 1) syscon was specifically designed for global system control registers like
 this and is fine to use as long as there are no conflicts where 1 bit is of
 interest to multiple drivers, and there is no such conflict here
 2) Maxime's other arguments seem to boil down to it would be nice / prettier
 to have a specific driver for this, without really proving a hard need for
 such a driver. But writing such a driver is going to be a lot of work, and
 we've a ton of other work to do, and as said there is no real need for a
 separate driver, syscon works fine for this.
 3) I actually believe that having a specific driver for this is a bad idea,
 because that means inventing a whole new cross driver API for this, and
 getting those right is, hard, a lot of work, and even then one is still likely
 to get it wrong. We can avoid all this by going with the proven syscon 
 solution.
 
 Maxime, can we please have your ack for moving forward with this using syscon?
 (see above for my arguments why)

I'd like to understand here why we can't use the existing SRAM DT binding
instead of the syscon binding.

Arnd
--
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] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Tony Lindgren
* Bin Liu binml...@gmail.com [150309 14:35]:
 On Mon, Mar 9, 2015 at 4:26 PM, Tony Lindgren t...@atomide.com wrote:
  * Felipe Balbi ba...@ti.com [150309 14:21]:
  On Mon, Mar 09, 2015 at 04:17:29PM -0500, Bin Liu wrote:
   On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
Hi,
   
On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com 
wrote:
 Add a minimal driver for dm816x USB. Otherwise we can just use
 the existing musb_am335x and musb_dsps on dm816x.
   
dm816x has the almost identical usbss as that in am335x, we should be
able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
   
Tony's using the same musb glue layers, this is just a phy driver,
right ?
  
   Can the current am335x phy driver be adopted too? I remember it is
   under drivers/usb/phy/.
 
  Tony will be best to answer, but according to our IRC discussions, it's
  too different. Tony ?
 
  Well we should check again between dm814x and am335x documentation
  against the $subject driver as the dm816x docs were buggy and I may
  have gotten a wrong idea initially.
 
 Will it make our life a little easier by comparing the usb drivers for
 dm81xx and am335x in previous TI kernel releases? I cam dig out the
 source code if that helps.

Yeah that probably helps if you've dealt with dm814x earlier :)
Just don't look at the dm816x trm, only the errata pdf works for
dm816x phy.

Note that we still are missing basic support for dm814x in mainline,
I'm planning to tackle that at some point but I don't know when I'm
going to get to it..

Regards,

Tony
--
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 02/15] phy-sun4i-usb: Add a helper function to update the iscr register

2015-03-09 Thread Hans de Goede
Add sun4i_usb_phy_update_iscr() helper function to allow the otg driver to
update the sun4i usb phy0 Interface Status and Control Register.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/phy/phy-sun4i-usb.c   | 13 +
 include/linux/phy/phy-sun4i-usb.h | 26 ++
 2 files changed, 39 insertions(+)
 create mode 100644 include/linux/phy/phy-sun4i-usb.h

diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index a2b08f3c..4742d5a 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -79,6 +79,19 @@ struct sun4i_usb_phy_data {
 #define to_sun4i_usb_phy_data(phy) \
container_of((phy), struct sun4i_usb_phy_data, phys[(phy)-index])
 
+void sun4i_usb_phy_update_iscr(struct phy *_phy, u32 clr, u32 set)
+{
+   struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
+   struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
+   u32 iscr;
+
+   iscr = readl(data-base + REG_ISCR);
+   iscr = ~clr;
+   iscr |= set;
+   writel(iscr, data-base + REG_ISCR);
+}
+EXPORT_SYMBOL(sun4i_usb_phy_update_iscr);
+
 static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data,
int len)
 {
diff --git a/include/linux/phy/phy-sun4i-usb.h 
b/include/linux/phy/phy-sun4i-usb.h
new file mode 100644
index 000..f69e784
--- /dev/null
+++ b/include/linux/phy/phy-sun4i-usb.h
@@ -0,0 +1,26 @@
+/*
+ * Allwinner sun4i USB phy header
+ *
+ * Copyright (C) 2015 Hans de Goede hdego...@redhat.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __PHY_SUN4I_USB_H
+#define __PHY_SUN4I_USB_H
+
+#include linux/phy/phy.h
+
+/**
+ * sun4i_usb_phy_update_iscr() - Update sun4i usb phy0 Interface Status and
+ * Control bits
+ * @phy: Reference to sun4i usb phy0
+ * @clr: bits to clear in the ISCR register
+ * @set: bits to set in the ISCR register
+ */
+void sun4i_usb_phy_update_iscr(struct phy *phy, u32 clr, u32 set);
+
+#endif
-- 
2.3.1

--
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 14/15] ARM: dts: sun7i: Enable USB DRC on Cubietruck

2015-03-09 Thread Hans de Goede
From: Roman Byshko rbys...@gmail.com

Enable the otg/drc usb controller on the cubietruck.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun7i-a20-cubietruck.dts | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts 
b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
index 8111b0c..ac8ff33 100644
--- a/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
+++ b/arch/arm/boot/dts/sun7i-a20-cubietruck.dts
@@ -227,6 +227,20 @@
allwinner,drive = SUN4I_PINCTRL_10_MA;
allwinner,pull = SUN4I_PINCTRL_NO_PULL;
};
+
+   usb0_id_detect_pin: usb0_id_detect_pin@0 {
+   allwinner,pins = PH19;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_NO_PULL;
+   };
+
+   usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 {
+   allwinner,pins = PH22;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_NO_PULL;
+   };
 };
 
 pwm {
@@ -288,6 +302,16 @@
status = okay;
 };
 
+usb_otg {
+   pinctrl-names = default;
+   pinctrl-0 = usb0_id_detect_pin
+   usb0_vbus_detect_pin;
+   dr_mode = otg;
+   id_det-gpios = pio 7 19 GPIO_ACTIVE_HIGH; /* PH19 */
+   vbus_det-gpios = pio 7 22 GPIO_ACTIVE_HIGH; /* PH22 */
+   status = okay;
+};
+
 usbphy {
usb0_vbus-supply = reg_usb0_vbus;
usb1_vbus-supply = reg_usb1_vbus;
-- 
2.3.1

--
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] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Bin Liu
Hi,

On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
 Add a minimal driver for dm816x USB. Otherwise we can just use
 the existing musb_am335x and musb_dsps on dm816x.

dm816x has the almost identical usbss as that in am335x, we should be
able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?

Regards,
-Bin.


 Cc: Brian Hutchinson b.hutch...@gmail.com
 Cc: Felipe Balbi ba...@ti.com
 Signed-off-by: Tony Lindgren t...@atomide.com

 --- /dev/null
 +++ b/Documentation/devicetree/bindings/phy/dm816x-phy.txt
 @@ -0,0 +1,24 @@
 +Device tree binding documentation for am816x USB PHY
 +=
 +
 +Required properties:
 +- compatible : should be ti,dm816x-usb-phy
 +- reg : offset and length of the PHY register set.
 +- reg-names : name for the phy registers
 +- clocks : phandle to the clock
 +- clock-names : name of the clock
 +- syscon: phandle for the syscon node to access misc registers
 +- #phy-cells : from the generic PHY bindings, must be 1
 +- syscon: phandle for the syscon node to access misc registers
 +
 +Example:
 +
 +usb_phy0: usb-phy@20 {
 +   compatible = ti,dm8168-usb-phy;
 +   reg = 0x20 0x8;
 +   reg-names = phy;
 +   clocks = main_fapll 6;
 +   clock-names = refclk;
 +   #phy-cells = 0;
 +   syscon = scm_conf;
 +};
 --- a/drivers/phy/Kconfig
 +++ b/drivers/phy/Kconfig
 @@ -35,6 +35,13 @@ config ARMADA375_USBCLUSTER_PHY
 depends on OF
 select GENERIC_PHY

 +config PHY_DM816X_USB
 +   tristate TI dm816x USB PHY driver
 +   depends on ARCH_OMAP2PLUS
 +   select GENERIC_PHY
 +   help
 + Enable this for dm81xx USB to work.
 +
  config PHY_EXYNOS_MIPI_VIDEO
 tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
 depends on HAS_IOMEM
 --- a/drivers/phy/Makefile
 +++ b/drivers/phy/Makefile
 @@ -5,6 +5,7 @@
  obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
  obj-$(CONFIG_PHY_BERLIN_USB)   += phy-berlin-usb.o
  obj-$(CONFIG_PHY_BERLIN_SATA)  += phy-berlin-sata.o
 +obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
  obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
  obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
  obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 --- /dev/null
 +++ b/drivers/phy/phy-dm816x-usb.c
 @@ -0,0 +1,295 @@
 +/*
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + */
 +
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include linux/regmap.h
 +
 +#include linux/slab.h
 +#include linux/of.h
 +#include linux/io.h
 +#include linux/usb/phy_companion.h
 +#include linux/clk.h
 +#include linux/err.h
 +#include linux/pm_runtime.h
 +#include linux/delay.h
 +#include linux/phy/phy.h
 +#include linux/of_platform.h
 +
 +#include linux/mfd/syscon.h
 +
 +/*
 + * TRM has two sets of USB_CTRL registers.. The correct register bits
 + * are in TRM section 24.9.8.2 USB_CTRL Register.
 + */
 +#define DM816X_USB_CTRL_PHYCLKSRC  BIT(8)  /* 1 = PLL ref clock */
 +#define DM816X_USB_CTRL_PHYSLEEP1  BIT(1)
 +#define DM816X_USB_CTRL_PHYSLEEP0  BIT(0)
 +
 +#define DM816X_USBPHY_CTRL_TXRISETUNE  1
 +#define DM816X_USBPHY_CTRL_TXVREFTUNE  0xc
 +#define DM816X_USBPHY_CTRL_TXPREEMTUNE 0x2
 +
 +struct dm816x_usb_phy {
 +   struct regmap *syscon;
 +   struct device *dev;
 +   unsigned int instance;
 +   struct clk *refclk;
 +   struct usb_phy phy;
 +   unsigned int usb_ctrl;  /* Shared between phy0 and phy1 */
 +   unsigned int usbphy_ctrl;
 +};
 +
 +static int dm816x_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
 +{
 +   otg-host = host;
 +   if (!host)
 +   otg-state = OTG_STATE_UNDEFINED;
 +
 +   return 0;
 +}
 +
 +static int dm816x_usb_phy_set_peripheral(struct usb_otg *otg,
 +struct usb_gadget *gadget)
 +{
 +   otg-gadget = gadget;
 +   if (!gadget)
 +   otg-state = OTG_STATE_UNDEFINED;
 +
 +   return 0;
 +}
 +
 +static int dm816x_usb_phy_power_off(struct phy *x)
 +{
 +   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
 +
 +   pm_runtime_put(phy-dev);
 +
 +   return 0;
 +}
 +
 +static int dm816x_usb_phy_power_on(struct phy *x)
 +{
 +   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
 +
 +   return pm_runtime_get_sync(phy-dev);
 +}
 +
 +static int dm816x_usb_phy_init(struct phy *x)
 +{
 +   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
 +   

Re: [PATCH 05/15] musb: Do not use musb_read[b|w] / _write[b|w] wrappers in generic fifo functions

2015-03-09 Thread Arnd Bergmann
On Monday 09 March 2015 21:40:18 Hans de Goede wrote:
 The generic fifo functions already use non wrapped accesses in various
 cases through the iowrite#_rep functions, and all platforms which override
 the default musb_read[b|w] / _write[b|w] functions also provide their own
 fifo access functions, so we can safely drop the unnecessary indirection
 from the fifo access functions.
 
 Signed-off-by: Hans de Goede hdego...@redhat.com
 

The patch looks reasonably, but the description seem misleading.
I believe the real reason why it's ok to use __raw_writew for the
FIFO is that a FIFO by definition is using CPU endian access for
copying byte streams from memory, which is unlike any other MMIO
register that requires fixed-endian accessors.

Arnd
--
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 15/15] ARM: dts: sun7i: Enable USB DRC on A20-OLinuxIno-Lime

2015-03-09 Thread Hans de Goede
Enable the otg/drc usb controller on the A20-OLinuxIno-Lime.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dts | 29 ++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dts 
b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dts
index 68efd2f..b3fda82 100644
--- a/arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dts
+++ b/arch/arm/boot/dts/sun7i-a20-olinuxino-lime.dts
@@ -146,6 +146,20 @@
allwinner,drive = SUN4I_PINCTRL_20_MA;
allwinner,pull = SUN4I_PINCTRL_NO_PULL;
};
+
+   usb0_id_detect_pin: usb0_id_detect_pin@0 {
+   allwinner,pins = PH4;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_UP;
+   };
+
+   usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 {
+   allwinner,pins = PH5;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_DOWN;
+   };
 };
 
 reg_ahci_5v {
@@ -154,6 +168,10 @@
status = okay;
 };
 
+reg_usb0_vbus {
+   status = okay;
+};
+
 reg_usb1_vbus {
status = okay;
 };
@@ -168,7 +186,18 @@
status = okay;
 };
 
+usb_otg {
+   pinctrl-names = default;
+   pinctrl-0 = usb0_id_detect_pin
+usb0_vbus_detect_pin;
+   id_det-gpio = pio 7 4 GPIO_ACTIVE_HIGH; /* PH4 */
+   vbus_det-gpio = pio 7 5 GPIO_ACTIVE_HIGH; /* PH5 */
+   dr_mode = otg;
+   status = okay;
+};
+
 usbphy {
+   usb0_vbus-supply = reg_usb0_vbus;
usb1_vbus-supply = reg_usb1_vbus;
usb2_vbus-supply = reg_usb2_vbus;
status = okay;
-- 
2.3.1

--
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 12/15] ARM: dts: sun4i: Enable USB DRC on Chuwi V7 CW0825

2015-03-09 Thread Hans de Goede
Enable the otg/drc usb controller on the Chuwi V7 CW0825 tablet.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dts | 31 +
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dts 
b/arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dts
index 97fca89..034396c 100644
--- a/arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dts
+++ b/arch/arm/boot/dts/sun4i-a10-chuwi-v7-cw0825.dts
@@ -111,6 +111,26 @@
status = okay;
 };
 
+pio {
+   usb0_id_detect_pin: usb0_id_detect_pin@0 {
+   allwinner,pins = PH4;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_UP;
+   };
+
+   usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 {
+   allwinner,pins = PH5;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_DOWN;
+   };
+};
+
+reg_usb0_vbus {
+   status = okay;
+};
+
 reg_usb2_vbus {
status = okay;
 };
@@ -121,7 +141,18 @@
status = okay;
 };
 
+usb_otg {
+   pinctrl-names = default;
+   pinctrl-0 = usb0_id_detect_pin
+usb0_vbus_detect_pin;
+   id_det-gpio = pio 7 4 GPIO_ACTIVE_HIGH; /* PH4 */
+   vbus_det-gpio = pio 7 5 GPIO_ACTIVE_HIGH; /* PH5 */
+   dr_mode = otg;
+   status = okay;
+};
+
 usbphy {
+   usb0_vbus-supply = reg_usb0_vbus;
usb2_vbus-supply = reg_usb2_vbus;
status = okay;
 };
-- 
2.3.1

--
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 03/15] musb: Make musb_write_rxfun* and musb_write_rxhub* work like their tx versions

2015-03-09 Thread Hans de Goede
For some reason the musb_write_rxfun* and musb_write_rxhub* functions had
a different function prototype and some extra magic needed on the caller side
compared to their tx counterparts, this commit makes them work the same as
their tx counterparts.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/musb/musb_core.c | 11 +++
 drivers/usb/musb/musb_core.h |  2 --
 drivers/usb/musb/musb_host.c | 12 ++--
 drivers/usb/musb/musb_regs.h | 31 ---
 4 files changed, 21 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index e6f4cbf..2c43b59 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1546,7 +1546,6 @@ static int musb_core_init(u16 musb_type, struct musb 
*musb)
 #endif
 
hw_ep-regs = musb-io.ep_offset(i, 0) + mbase;
-   hw_ep-target_regs = musb_read_target_reg_base(i, mbase);
hw_ep-rx_reinit = 1;
hw_ep-tx_reinit = 1;
 
@@ -2332,7 +2331,6 @@ static void musb_restore_context(struct musb *musb)
 {
int i;
void __iomem *musb_base = musb-mregs;
-   void __iomem *ep_target_regs;
void __iomem *epio;
u8 power;
 
@@ -2400,14 +2398,11 @@ static void musb_restore_context(struct musb *musb)
musb_write_txhubport(musb_base, i,
musb-context.index_regs[i].txhubport);
 
-   ep_target_regs =
-   musb_read_target_reg_base(i, musb_base);
-
-   musb_write_rxfunaddr(ep_target_regs,
+   musb_write_rxfunaddr(musb_base, i,
musb-context.index_regs[i].rxfunaddr);
-   musb_write_rxhubaddr(ep_target_regs,
+   musb_write_rxhubaddr(musb_base, i,
musb-context.index_regs[i].rxhubaddr);
-   musb_write_rxhubport(ep_target_regs,
+   musb_write_rxhubport(musb_base, i,
musb-context.index_regs[i].rxhubport);
}
musb_writeb(musb_base, MUSB_INDEX, musb-context.index);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 5e65958..a31d709 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -240,8 +240,6 @@ struct musb_hw_ep {
void __iomem*fifo_sync_va;
 #endif
 
-   void __iomem*target_regs;
-
/* currently scheduled peripheral endpoint */
struct musb_qh  *in_qh;
struct musb_qh  *out_qh;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 883a9ad..77006ee 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -555,8 +555,9 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 
epnum, u8 iso_err)
  * the busy/not-empty tests are basically paranoia.
  */
 static void
-musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
+musb_rx_reinit(struct musb *musb, struct musb_qh *qh, u8 epnum)
 {
+   struct musb_hw_ep *ep = musb-endpoints + epnum;
u16 csr;
 
/* NOTE:  we know the rx fifo reinit never triggers for ep0.
@@ -594,10 +595,9 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, 
struct musb_hw_ep *ep)
 
/* target addr and (for multipoint) hub addr/port */
if (musb-is_multipoint) {
-   musb_write_rxfunaddr(ep-target_regs, qh-addr_reg);
-   musb_write_rxhubaddr(ep-target_regs, qh-h_addr_reg);
-   musb_write_rxhubport(ep-target_regs, qh-h_port_reg);
-
+   musb_write_rxfunaddr(musb-mregs, epnum, qh-addr_reg);
+   musb_write_rxhubaddr(musb-mregs, epnum, qh-h_addr_reg);
+   musb_write_rxhubport(musb-mregs, epnum, qh-h_port_reg);
} else
musb_writeb(musb-mregs, MUSB_FADDR, qh-addr_reg);
 
@@ -875,7 +875,7 @@ finish:
u16 csr;
 
if (hw_ep-rx_reinit) {
-   musb_rx_reinit(musb, qh, hw_ep);
+   musb_rx_reinit(musb, qh, epnum);
 
/* init new state: toggle and NYET, maybe DMA later */
if (usb_gettoggle(urb-dev, qh-epnum, 0))
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index 11f0be0..edfc730 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -364,27 +364,25 @@ static inline u16 musb_read_hwvers(void __iomem *mbase)
return musb_readw(mbase, MUSB_HWVERS);
 }
 
-static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem 
*mbase)
-{
-   return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
-}
-
-static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
+static inline void musb_write_rxfunaddr(void __iomem *mbase, u8 epnum,
u8 qh_addr_reg)
 {
-   musb_writeb(ep_target_regs, MUSB_RXFUNCADDR, qh_addr_reg);
+   

[PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Tony Lindgren
Add a minimal driver for dm816x USB. Otherwise we can just use
the existing musb_am335x and musb_dsps on dm816x.

Cc: Brian Hutchinson b.hutch...@gmail.com
Cc: Felipe Balbi ba...@ti.com
Signed-off-by: Tony Lindgren t...@atomide.com

--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/dm816x-phy.txt
@@ -0,0 +1,24 @@
+Device tree binding documentation for am816x USB PHY
+=
+
+Required properties:
+- compatible : should be ti,dm816x-usb-phy
+- reg : offset and length of the PHY register set.
+- reg-names : name for the phy registers
+- clocks : phandle to the clock
+- clock-names : name of the clock
+- syscon: phandle for the syscon node to access misc registers
+- #phy-cells : from the generic PHY bindings, must be 1
+- syscon: phandle for the syscon node to access misc registers
+
+Example:
+
+usb_phy0: usb-phy@20 {
+   compatible = ti,dm8168-usb-phy;
+   reg = 0x20 0x8;
+   reg-names = phy;
+   clocks = main_fapll 6;
+   clock-names = refclk;
+   #phy-cells = 0;
+   syscon = scm_conf;
+};
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -35,6 +35,13 @@ config ARMADA375_USBCLUSTER_PHY
depends on OF
select GENERIC_PHY
 
+config PHY_DM816X_USB
+   tristate TI dm816x USB PHY driver
+   depends on ARCH_OMAP2PLUS
+   select GENERIC_PHY
+   help
+ Enable this for dm81xx USB to work.
+
 config PHY_EXYNOS_MIPI_VIDEO
tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
depends on HAS_IOMEM
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -5,6 +5,7 @@
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
 obj-$(CONFIG_PHY_BERLIN_USB)   += phy-berlin-usb.o
 obj-$(CONFIG_PHY_BERLIN_SATA)  += phy-berlin-sata.o
+obj-$(CONFIG_PHY_DM816X_USB)   += phy-dm816x-usb.o
 obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
--- /dev/null
+++ b/drivers/phy/phy-dm816x-usb.c
@@ -0,0 +1,295 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/regmap.h
+
+#include linux/slab.h
+#include linux/of.h
+#include linux/io.h
+#include linux/usb/phy_companion.h
+#include linux/clk.h
+#include linux/err.h
+#include linux/pm_runtime.h
+#include linux/delay.h
+#include linux/phy/phy.h
+#include linux/of_platform.h
+
+#include linux/mfd/syscon.h
+
+/*
+ * TRM has two sets of USB_CTRL registers.. The correct register bits
+ * are in TRM section 24.9.8.2 USB_CTRL Register.
+ */
+#define DM816X_USB_CTRL_PHYCLKSRC  BIT(8)  /* 1 = PLL ref clock */
+#define DM816X_USB_CTRL_PHYSLEEP1  BIT(1)
+#define DM816X_USB_CTRL_PHYSLEEP0  BIT(0)
+
+#define DM816X_USBPHY_CTRL_TXRISETUNE  1
+#define DM816X_USBPHY_CTRL_TXVREFTUNE  0xc
+#define DM816X_USBPHY_CTRL_TXPREEMTUNE 0x2
+
+struct dm816x_usb_phy {
+   struct regmap *syscon;
+   struct device *dev;
+   unsigned int instance;
+   struct clk *refclk;
+   struct usb_phy phy;
+   unsigned int usb_ctrl;  /* Shared between phy0 and phy1 */
+   unsigned int usbphy_ctrl;
+};
+
+static int dm816x_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
+{
+   otg-host = host;
+   if (!host)
+   otg-state = OTG_STATE_UNDEFINED;
+
+   return 0;
+}
+
+static int dm816x_usb_phy_set_peripheral(struct usb_otg *otg,
+struct usb_gadget *gadget)
+{
+   otg-gadget = gadget;
+   if (!gadget)
+   otg-state = OTG_STATE_UNDEFINED;
+
+   return 0;
+}
+
+static int dm816x_usb_phy_power_off(struct phy *x)
+{
+   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
+
+   pm_runtime_put(phy-dev);
+
+   return 0;
+}
+
+static int dm816x_usb_phy_power_on(struct phy *x)
+{
+   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
+
+   return pm_runtime_get_sync(phy-dev);
+}
+
+static int dm816x_usb_phy_init(struct phy *x)
+{
+   struct dm816x_usb_phy *phy = phy_get_drvdata(x);
+   unsigned int val;
+   int error;
+
+   error = pm_runtime_get_sync(phy-dev);
+   if (error)
+   return error;
+
+   if (clk_get_rate(phy-refclk) != 2400)
+   dev_warn(phy-dev, nonstandard phy refclk\n);
+
+   /* Set PLL ref clock and put phys to sleep */
+   error = regmap_update_bits(phy-syscon, phy-usb_ctrl,
+

Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Bin Liu
On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
 On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
 Hi,

 On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
  Add a minimal driver for dm816x USB. Otherwise we can just use
  the existing musb_am335x and musb_dsps on dm816x.

 dm816x has the almost identical usbss as that in am335x, we should be
 able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?

 Tony's using the same musb glue layers, this is just a phy driver,
 right ?

Can the current am335x phy driver be adopted too? I remember it is
under drivers/usb/phy/.

Regards,
-Bin.


 --
 balbi
--
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 02/15] phy-sun4i-usb: Add a helper function to update the iscr register

2015-03-09 Thread Arnd Bergmann
On Monday 09 March 2015 21:40:15 Hans de Goede wrote:
 +void sun4i_usb_phy_update_iscr(struct phy *_phy, u32 clr, u32 set)
 +{
 +   struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
 +   struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
 +   u32 iscr;
 +
 +   iscr = readl(data-base + REG_ISCR);
 +   iscr = ~clr;
 +   iscr |= set;
 +   writel(iscr, data-base + REG_ISCR);
 +}
 +EXPORT_SYMBOL(sun4i_usb_phy_update_iscr);
 +
 

I would generally consider this a bad design. What is the purpose of
calling sun4i_usb_phy_update_iscr() and why can't there be a high-level
PHY API for this?

The only other phy driver with exports like this is the OMAP driver,
and that has caused problems in the past.

Arnd
--
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 10/15] ARM: dts: sun5i: Add USB Dual Role Controller

2015-03-09 Thread Hans de Goede
Add a node for the otg/drc usb controller to sun5i-a1*.dtsi.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun5i.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sun5i.dtsi b/arch/arm/boot/dts/sun5i.dtsi
index 97b4eb1..cf730d4 100644
--- a/arch/arm/boot/dts/sun5i.dtsi
+++ b/arch/arm/boot/dts/sun5i.dtsi
@@ -384,6 +384,18 @@
status = disabled;
};
 
+   usb_otg: usb@01c13000 {
+   compatible = allwinner,sun4i-a10-musb;
+   reg = 0x01c13000 0x0400;
+   clocks = ahb_gates 0;
+   interrupts = 38;
+   interrupt-names = mc;
+   phys = usbphy 0;
+   phy-names = usb;
+   syscons = syscon;
+   status = disabled;
+   };
+
usbphy: phy@01c13400 {
#phy-cells = 1;
compatible = allwinner,sun5i-a13-usb-phy;
-- 
2.3.1

--
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 06/15] musb: Fix platform code being unable to override ep access ops

2015-03-09 Thread Hans de Goede
musb-core was setting the ops to the default indexed or flat handlers after
checking for platform overrides. Reverse the order of this so that platform
overrides actually work.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/musb/musb_core.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 47c1a0a..374d181 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2019,13 +2019,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
if (musb-ops-quirks)
musb-io.quirks = musb-ops-quirks;
 
-   /* At least tusb6010 has it's own offsets.. */
-   if (musb-ops-ep_offset)
-   musb-io.ep_offset = musb-ops-ep_offset;
-   if (musb-ops-ep_select)
-   musb-io.ep_select = musb-ops-ep_select;
-
-   /* ..and some devices use indexed offset or flat offset */
+   /* Set default ep access to indexed offset or flat offset ops */
if (musb-io.quirks  MUSB_INDEXED_EP) {
musb-io.ep_offset = musb_indexed_ep_offset;
musb-io.ep_select = musb_indexed_ep_select;
@@ -2033,6 +2027,11 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
musb-io.ep_offset = musb_flat_ep_offset;
musb-io.ep_select = musb_flat_ep_select;
}
+   /* And override them with platform specific ops if specified. */
+   if (musb-ops-ep_offset)
+   musb-io.ep_offset = musb-ops-ep_offset;
+   if (musb-ops-ep_select)
+   musb-io.ep_select = musb-ops-ep_select;
 
if (musb-ops-fifo_mode)
fifo_mode = musb-ops-fifo_mode;
-- 
2.3.1

--
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 11/15] ARM: dts: sun7i: Add USB Dual Role Controller

2015-03-09 Thread Hans de Goede
From: Roman Byshko rbys...@gmail.com

Add a node for the otg/drc usb controller to sun7i-a20.dtsi

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun7i-a20.dtsi | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index fb56a1d..1d0b9ac 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -653,6 +653,18 @@
status = disabled;
};
 
+   usb_otg: usb@01c13000 {
+   compatible = allwinner,sun4i-a10-musb;
+   reg = 0x01c13000 0x0400;
+   clocks = ahb_gates 0;
+   interrupts = 0 38 4;
+   interrupt-names = mc;
+   phys = usbphy 0;
+   phy-names = usb;
+   syscons = syscon;
+   status = disabled;
+   };
+
usbphy: phy@01c13400 {
#phy-cells = 1;
compatible = allwinner,sun7i-a20-usb-phy;
-- 
2.3.1

--
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 13/15] ARM: dts: sun5i: Enable USB DRC on UTOO P66

2015-03-09 Thread Hans de Goede
Enable the OTG controller on the UTOO P66 tablet.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun5i-a13-utoo-p66.dts | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts 
b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
index d1d4d30..8b44874 100644
--- a/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
+++ b/arch/arm/boot/dts/sun5i-a13-utoo-p66.dts
@@ -160,6 +160,20 @@
allwinner,pull = SUN4I_PINCTRL_PULL_UP;
};
 
+   usb0_vbus_detect_pin: usb0_vbus_detect_pin@0 {
+   allwinner,pins = PG1;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_DOWN;
+   };
+
+   usb0_id_detect_pin: usb0_id_detect_pin@0 {
+   allwinner,pins = PG2;
+   allwinner,function = gpio_in;
+   allwinner,drive = SUN4I_PINCTRL_10_MA;
+   allwinner,pull = SUN4I_PINCTRL_PULL_UP;
+   };
+
i2c_lcd_pins: i2c_lcd_pin@0 {
allwinner,pins = PG10, PG12;
allwinner,function = gpio_out;
@@ -218,6 +232,15 @@
status = okay;
 };
 
+usb_otg {
+   pinctrl-names = default;
+   pinctrl-0 = usb0_id_detect_pin, usb0_vbus_detect_pin;
+   id_det-gpio = pio 6 2 GPIO_ACTIVE_HIGH; /* PG2 */
+   vbus_det-gpio = pio 6 1 GPIO_ACTIVE_HIGH; /* PG1 */
+   dr_mode = otg;
+   status = okay;
+};
+
 usbphy {
usb0_vbus-supply = reg_usb0_vbus;
usb1_vbus-supply = reg_ldo3;
-- 
2.3.1

--
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 07/15] musb: Add support for the Allwinner sunxi musb controller

2015-03-09 Thread Hans de Goede
This is based on initial code to get the Allwinner sunxi musb controller
supported by Chen-Yu Tsai and Roman Byshko.

This adds support for the Allwinner sunxi musb controller in both host only
and otg mode. Peripheral only mode is not supported, as no boards use that.

This has been tested on a cubietruck (A20 SoC) and an UTOO P66 tablet
(A13 SoC) with a variety of devices in host mode and with the g_serial gadget
driver in peripheral mode, plugging otg / host cables in/out a lot of times
in all possible imaginable plug orders.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 .../bindings/usb/allwinner,sun4i-a10-musb.txt  |  27 +
 drivers/usb/musb/Kconfig   |   9 +-
 drivers/usb/musb/Makefile  |   1 +
 drivers/usb/musb/musb_core.h   |   1 +
 drivers/usb/musb/musb_gadget.c |   6 +
 drivers/usb/musb/musb_virthub.c|   6 +
 drivers/usb/musb/sunxi.c   | 788 +
 7 files changed, 837 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
 create mode 100644 drivers/usb/musb/sunxi.c

diff --git a/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt 
b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
new file mode 100644
index 000..22b6887
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/allwinner,sun4i-a10-musb.txt
@@ -0,0 +1,27 @@
+Allwinner sun4i A10 musb DRC/OTG controller
+---
+
+Required properties:
+ - compatible  : allwinner,sun4i-a10-musb
+ - reg : mmio address range of the musb controller
+ - clocks  : clock specifier for the musb controller ahb gate clock
+ - interrupts  : interrupt to which the musb controller is connected
+ - interrupt-names : must be mc
+ - phys: phy specifier for the otg phy
+ - phy-names   : must be usb
+ - syscons : syscon specifier
+ - dr_mode : Dual-Role mode must be host or otg
+
+Example:
+
+   usb_otg: usb@01c13000 {
+   compatible = allwinner,sun4i-a10-musb;
+   reg = 0x01c13000 0x0400;
+   clocks = ahb_gates 0;
+   interrupts = 38;
+   interrupt-names = mc;
+   phys = usbphy 0;
+   phy-names = usb;
+   syscons = syscon;
+   status = disabled;
+   };
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 14e1628..8180a3a 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -5,7 +5,7 @@
 
 # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
 config USB_MUSB_HDRC
-   tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
+   tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, AW, ...)'
depends on (USB || USB_GADGET)
help
  Say Y here if your system has a dual role high speed USB
@@ -20,6 +20,8 @@ config USB_MUSB_HDRC
  Analog Devices parts using this IP include Blackfin BF54x,
  BF525 and BF527.
 
+ Allwinner SoCs using this IP include A10, A13, A20, ...
+
  If you do not know what this is, please say N.
 
  To compile this driver as a module, choose M here; the
@@ -60,6 +62,11 @@ endchoice
 
 comment Platform Glue Layer
 
+config USB_MUSB_SUNXI
+   tristate Allwinner (sunxi)
+   depends on ARCH_SUNXI
+   select GENERIC_PHY
+
 config USB_MUSB_DAVINCI
tristate DaVinci
depends on ARCH_DAVINCI_DMx
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index ba49501..f95befe 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_USB_MUSB_DA8XX)  += da8xx.o
 obj-$(CONFIG_USB_MUSB_BLACKFIN)+= blackfin.o
 obj-$(CONFIG_USB_MUSB_UX500)   += ux500.o
 obj-$(CONFIG_USB_MUSB_JZ4740)  += jz4740.o
+obj-$(CONFIG_USB_MUSB_SUNXI)   += sunxi.o
 
 
 obj-$(CONFIG_USB_MUSB_AM335X_CHILD)+= musb_am335x.o
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index ba8dd78..444b936 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -166,6 +166,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_SUN4I BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
 #define MUSB_DMA_CPPI  BIT(4)
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index b2d9040..7d13eb9 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -2041,6 +2041,12 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(musb-lock);
}
 
+   /* On sunxi ep0 FADDR must be 0 when (re)entering peripheral mode */
+   if (musb-io.quirks  MUSB_SUN4I) {
+  

Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Bin Liu
On Mon, Mar 9, 2015 at 4:26 PM, Tony Lindgren t...@atomide.com wrote:
 * Felipe Balbi ba...@ti.com [150309 14:21]:
 On Mon, Mar 09, 2015 at 04:17:29PM -0500, Bin Liu wrote:
  On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
   On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
   Hi,
  
   On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
Add a minimal driver for dm816x USB. Otherwise we can just use
the existing musb_am335x and musb_dsps on dm816x.
  
   dm816x has the almost identical usbss as that in am335x, we should be
   able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
  
   Tony's using the same musb glue layers, this is just a phy driver,
   right ?
 
  Can the current am335x phy driver be adopted too? I remember it is
  under drivers/usb/phy/.

 Tony will be best to answer, but according to our IRC discussions, it's
 too different. Tony ?

 Well we should check again between dm814x and am335x documentation
 against the $subject driver as the dm816x docs were buggy and I may
 have gotten a wrong idea initially.

Will it make our life a little easier by comparing the usb drivers for
dm81xx and am335x in previous TI kernel releases? I cam dig out the
source code if that helps.

Regards,
-Bin,


 Regards,

 Tony
--
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 09/15] ARM: dts: sun4i: Add USB Dual Role Controller

2015-03-09 Thread Hans de Goede
Add a node for the otg/drc usb controller to sun4i-a10.dtsi.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun4i-a10.dtsi | 12 
 drivers/usb/musb/Kconfig |  1 +
 2 files changed, 13 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index 2f792b6..e550415 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -574,6 +574,18 @@
status = disabled;
};
 
+   usb_otg: usb@01c13000 {
+   compatible = allwinner,sun4i-a10-musb;
+   reg = 0x01c13000 0x0400;
+   clocks = ahb_gates 0;
+   interrupts = 38;
+   interrupt-names = mc;
+   phys = usbphy 0;
+   phy-names = usb;
+   syscons = syscon;
+   status = disabled;
+   };
+
usbphy: phy@01c13400 {
#phy-cells = 1;
compatible = allwinner,sun4i-a10-usb-phy;
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 8180a3a..fab8e9a 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -65,6 +65,7 @@ comment Platform Glue Layer
 config USB_MUSB_SUNXI
tristate Allwinner (sunxi)
depends on ARCH_SUNXI
+   depends on NOP_USB_XCEIV
select GENERIC_PHY
 
 config USB_MUSB_DAVINCI
-- 
2.3.1

--
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 05/15] musb: Do not use musb_read[b|w] / _write[b|w] wrappers in generic fifo functions

2015-03-09 Thread Hans de Goede
The generic fifo functions already use non wrapped accesses in various
cases through the iowrite#_rep functions, and all platforms which override
the default musb_read[b|w] / _write[b|w] functions also provide their own
fifo access functions, so we can safely drop the unnecessary indirection
from the fifo access functions.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/musb/musb_core.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index b71d310..47c1a0a 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -313,7 +313,7 @@ static void musb_default_write_fifo(struct musb_hw_ep 
*hw_ep, u16 len,
index += len  ~0x03;
}
if (len  0x02) {
-   musb_writew(fifo, 0, *(u16 *)src[index]);
+   __raw_writew(*(u16 *)src[index], fifo);
index += 2;
}
} else {
@@ -323,7 +323,7 @@ static void musb_default_write_fifo(struct musb_hw_ep 
*hw_ep, u16 len,
}
}
if (len  0x01)
-   musb_writeb(fifo, 0, src[index]);
+   __raw_writeb(src[index], fifo);
} else  {
/* byte aligned */
iowrite8_rep(fifo, src, len);
@@ -355,7 +355,7 @@ static void musb_default_read_fifo(struct musb_hw_ep 
*hw_ep, u16 len, u8 *dst)
index = len  ~0x03;
}
if (len  0x02) {
-   *(u16 *)dst[index] = musb_readw(fifo, 0);
+   *(u16 *)dst[index] = __raw_readw(fifo);
index += 2;
}
} else {
@@ -365,7 +365,7 @@ static void musb_default_read_fifo(struct musb_hw_ep 
*hw_ep, u16 len, u8 *dst)
}
}
if (len  0x01)
-   dst[index] = musb_readb(fifo, 0);
+   dst[index] = __raw_readb(fifo);
} else  {
/* byte aligned */
ioread8_rep(fifo, dst, len);
-- 
2.3.1

--
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 08/15] ARM: dts: sunxi: Add syscon node for controlling SRAM mapping

2015-03-09 Thread Hans de Goede
From: Chen-Yu Tsai w...@csie.org

Allwinner SoCs have a system controller module that controls whether
SRAM blocks are mapped to the CPU memory or specific peripherals.

Signed-off-by: Chen-Yu Tsai w...@csie.org
[jensku...@gmail.com: duplicate syscon node to sun4i and sun5i]
Signed-off-by: Jens Kuske jensku...@gmail.com
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 arch/arm/boot/dts/sun4i-a10.dtsi | 5 +
 arch/arm/boot/dts/sun5i.dtsi | 5 +
 arch/arm/boot/dts/sun7i-a20.dtsi | 5 +
 3 files changed, 15 insertions(+)

diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi
index c66352b..2f792b6 100644
--- a/arch/arm/boot/dts/sun4i-a10.dtsi
+++ b/arch/arm/boot/dts/sun4i-a10.dtsi
@@ -457,6 +457,11 @@
#size-cells = 1;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = allwinner,sun4i-a10-syscon, syscon;
+   reg = 0x01c0 0x8;
+   };
+
dma: dma-controller@01c02000 {
compatible = allwinner,sun4i-a10-dma;
reg = 0x01c02000 0x1000;
diff --git a/arch/arm/boot/dts/sun5i.dtsi b/arch/arm/boot/dts/sun5i.dtsi
index 244d896..97b4eb1 100644
--- a/arch/arm/boot/dts/sun5i.dtsi
+++ b/arch/arm/boot/dts/sun5i.dtsi
@@ -298,6 +298,11 @@
#size-cells = 1;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = allwinner,sun4i-a10-syscon, syscon;
+   reg = 0x01c0 0x8;
+   };
+
dma: dma-controller@01c02000 {
compatible = allwinner,sun4i-a10-dma;
reg = 0x01c02000 0x1000;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index 8df77f5..fb56a1d 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -528,6 +528,11 @@
#size-cells = 1;
ranges;
 
+   syscon: syscon@01c0 {
+   compatible = allwinner,sun4i-a10-syscon, syscon;
+   reg = 0x01c0 0x8;
+   };
+
nmi_intc: interrupt-controller@01c00030 {
compatible = allwinner,sun7i-a20-sc-nmi;
interrupt-controller;
-- 
2.3.1

--
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 04/15] musb: Make busctl_offset an io-op rather then a define

2015-03-09 Thread Hans de Goede
The Allwinner (sunxi) implementation of the musb has its busctl registers
indexed by the MUSB_INDEX register rather then in a flat address space.

This commit turns MUSB_BUSCTL_OFFSET from a macro into an io-op which can
be overridden from the platform ops.

Signed-off-by: Hans de Goede hdego...@redhat.com
---
 drivers/usb/musb/musb_core.c | 34 +++-
 drivers/usb/musb/musb_core.h |  5 +++-
 drivers/usb/musb/musb_host.c | 12 -
 drivers/usb/musb/musb_io.h   |  2 ++
 drivers/usb/musb/musb_regs.h | 63 
 5 files changed, 68 insertions(+), 48 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2c43b59..b71d310 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -250,6 +250,11 @@ static u32 musb_indexed_ep_offset(u8 epnum, u16 offset)
return 0x10 + offset;
 }
 
+static u32 musb_default_busctl_offset(u8 epnum, u16 offset)
+{
+   return 0x80 + (0x08 * epnum) + offset;
+}
+
 static u8 musb_default_readb(const void __iomem *addr, unsigned offset)
 {
return __raw_readb(addr + offset);
@@ -2039,6 +2044,11 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
else
musb-io.fifo_offset = musb_default_fifo_offset;
 
+   if (musb-ops-busctl_offset)
+   musb-io.busctl_offset = musb-ops-busctl_offset;
+   else
+   musb-io.busctl_offset = musb_default_busctl_offset;
+
if (musb-ops-readb)
musb_readb = musb-ops-readb;
if (musb-ops-writeb)
@@ -2312,18 +2322,18 @@ static void musb_save_context(struct musb *musb)
musb_readb(epio, MUSB_RXINTERVAL);
 
musb-context.index_regs[i].txfunaddr =
-   musb_read_txfunaddr(musb_base, i);
+   musb_read_txfunaddr(musb, i);
musb-context.index_regs[i].txhubaddr =
-   musb_read_txhubaddr(musb_base, i);
+   musb_read_txhubaddr(musb, i);
musb-context.index_regs[i].txhubport =
-   musb_read_txhubport(musb_base, i);
+   musb_read_txhubport(musb, i);
 
musb-context.index_regs[i].rxfunaddr =
-   musb_read_rxfunaddr(musb_base, i);
+   musb_read_rxfunaddr(musb, i);
musb-context.index_regs[i].rxhubaddr =
-   musb_read_rxhubaddr(musb_base, i);
+   musb_read_rxhubaddr(musb, i);
musb-context.index_regs[i].rxhubport =
-   musb_read_rxhubport(musb_base, i);
+   musb_read_rxhubport(musb, i);
}
 }
 
@@ -2391,18 +2401,18 @@ static void musb_restore_context(struct musb *musb)
musb_writeb(epio, MUSB_RXINTERVAL,
 
musb-context.index_regs[i].rxinterval);
-   musb_write_txfunaddr(musb_base, i,
+   musb_write_txfunaddr(musb, i,
musb-context.index_regs[i].txfunaddr);
-   musb_write_txhubaddr(musb_base, i,
+   musb_write_txhubaddr(musb, i,
musb-context.index_regs[i].txhubaddr);
-   musb_write_txhubport(musb_base, i,
+   musb_write_txhubport(musb, i,
musb-context.index_regs[i].txhubport);
 
-   musb_write_rxfunaddr(musb_base, i,
+   musb_write_rxfunaddr(musb, i,
musb-context.index_regs[i].rxfunaddr);
-   musb_write_rxhubaddr(musb_base, i,
+   musb_write_rxhubaddr(musb, i,
musb-context.index_regs[i].rxhubaddr);
-   musb_write_rxhubport(musb_base, i,
+   musb_write_rxhubport(musb, i,
musb-context.index_regs[i].rxhubport);
}
musb_writeb(musb_base, MUSB_INDEX, musb-context.index);
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index a31d709..ba8dd78 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -67,7 +67,6 @@ struct musb_ep;
 #include musb_dma.h
 
 #include musb_io.h
-#include musb_regs.h
 
 #include musb_gadget.h
 #include linux/usb/hcd.h
@@ -186,6 +185,7 @@ struct musb_platform_ops {
void(*ep_select)(void __iomem *mbase, u8 epnum);
u16 fifo_mode;
u32 (*fifo_offset)(u8 epnum);
+   u32 (*busctl_offset)(u8 epnum, u16 offset);
u8  (*readb)(const void __iomem *addr, unsigned offset);
void(*writeb)(void __iomem *addr, unsigned offset, u8 data);
u16 (*readw)(const void __iomem *addr, unsigned offset);
@@ -435,6 +435,9 @@ struct musb {
 #endif
 };
 
+/* This must be included after struct musb is defined */
+#include musb_regs.h
+
 static inline struct musb *gadget_to_musb(struct 

[PATCH 01/15] ARM: sunxi: Add register bit definitions for SRAM mapping syscon

2015-03-09 Thread Hans de Goede
From: Chen-Yu Tsai w...@csie.org

Signed-off-by: Chen-Yu Tsai w...@csie.org
Signed-off-by: Jens Kuske jensku...@gmail.com
Acked-by: Lee Jones lee.jo...@linaro.org
Signed-off-by: Hans de Goede hdego...@redhat.com
---
 include/linux/mfd/syscon/sun4i-sc.h | 42 +
 1 file changed, 42 insertions(+)
 create mode 100644 include/linux/mfd/syscon/sun4i-sc.h

diff --git a/include/linux/mfd/syscon/sun4i-sc.h 
b/include/linux/mfd/syscon/sun4i-sc.h
new file mode 100644
index 000..fb970d9
--- /dev/null
+++ b/include/linux/mfd/syscon/sun4i-sc.h
@@ -0,0 +1,42 @@
+/**
+ * sun4i-sc.h - Allwinner sun4i system control register bit definitions
+ *
+ * Copyright (C) 2014 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai  w...@csie.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __LINUX_SUN4I_SC_H
+#define __LINUX_SUN4I_SC_H
+
+#include linux/bitops.h
+
+/* Registers */
+#define SUN4I_SC0  0x00
+#define SUN4I_SC1  0x04
+
+/* SRAM control register 0 bits */
+#define SUN4I_SC0_SRAM_C1_MAP_VE   0x7fff
+
+/* SRAM control register 1 bits */
+#define SUN4I_SC1_BIST_NDMA_CTRL_SEL   BIT(31)
+#define SUN4I_SC1_SRAM_C3_MAP_ISP  BIT(12)
+#define SUN4I_SC1_SRAM_C2_MAP_MASK 0x0300
+#define SUN4I_SC1_SRAM_C2_MAP_AE   0x0100
+#define SUN4I_SC1_SRAM_C2_MAP_CE   0x0200
+#define SUN4I_SC1_SRAM_C2_MAP_ACE  0x0300
+#define SUN4I_SC1_SRAM_A3_A4_MAP_MASK  0x0030
+#define SUN4I_SC1_SRAM_A3_A4_MAP_EMAC  0x0010
+#define SUN4I_SC1_SRAM_D_MAP_USB0  BIT(0)
+
+#endif /* __LINUX_SUN4I_SC_H */
-- 
2.3.1

--
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 00/15] musb: Add support for the Allwinner sunxi musb controller

2015-03-09 Thread Hans de Goede
Hi All,

This patch set has been a while in the making, so I'm very happy to present
the end result here, and I hope everyone likes it.

Before talking about merging this there are 2 things which I would like to
point out:

a) The musb controller in the sunxi SoCs uses some SRAM which needs to be
mapped to the musb controller by poking some bits in the SRAM controller,
just like the EMAC patches which were send a while back I've chosen to use
syscon for this, actually 2 of the patches in this set come directly from the
SRAM mapping patchset for the EMAC.

I know that Maxime is not 100% in favor of using syscon:
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/320221.html

But I disagree with his arguments for writing a special driver for the SRAM
controller:
1) syscon was specifically designed for global system control registers like
this and is fine to use as long as there are no conflicts where 1 bit is of
interest to multiple drivers, and there is no such conflict here
2) Maxime's other arguments seem to boil down to it would be nice / prettier
to have a specific driver for this, without really proving a hard need for
such a driver. But writing such a driver is going to be a lot of work, and
we've a ton of other work to do, and as said there is no real need for a
separate driver, syscon works fine for this.
3) I actually believe that having a specific driver for this is a bad idea,
because that means inventing a whole new cross driver API for this, and
getting those right is, hard, a lot of work, and even then one is still likely
to get it wrong. We can avoid all this by going with the proven syscon solution.

Maxime, can we please have your ack for moving forward with this using syscon?
(see above for my arguments why)


b) If you look closely at the new drivers/usb/musb/sunxi.c file you will see
that there is some register address translation happening in the
sunxi_musb_readb() function and related functions. This is necessary because
the registermap of the sunxi musb implementation is different from the other
musb implementation and sunxi uses multi-platform kernels.

I've considered adding full dynamic register map support to musb but I've
chosen not to. The problem is that the way the musb code currently works is
that there are 4 different address spaces used within the musb code:

1) musb-regs, the base address of the controller used for general control
register access like the DEVCTL and POWER regs

2) The address space at the offset returned by musb_io.ep_offset, which
contains ep control registers, this may be a different offset per endpoint,
or indexed by the INDEX register

3) The address space at the offset returned by musb_io.fifo_offset, which
contains the endpoint fifo data register, this is a different offset per ep.

4) The address space at the offset returned by MUSB_BUSCTL_OFFSET macro
(which gets repaced by musb_io.busctl_offset in this patchset), this may be a
different offset per endpoint, or indexed by the INDEX register

Turning this into something using dynamic register mapping is quite hard, esp.
since some parts of the address range are per endpoint and the number of
endpoints varies from one implementation to the next.

Besides this there also is the issue that I lack hardware to test invasive
changes like this for all different musb variants. So I've chosen to do the
necessary address translation (which really is only necessary for the general
control registers) in a sunxi specific readb  friends implementation, avoiding
the need to make invasive chances elsewhere and thus hopefully avoiding any
regressions.

Note that some small core changes are still necessary, mostly to rationalize
the busctl register handling, and make it more generic as sunxi has indexed
busctl registers.


So with that all said lets talk about getting this merged upstream, assuming
that the code passes review :)

The first patch in the set adds a header with defines for the sun4i syscon
registers. Since this has already been acked by one of the MFD maintainers,
I suggest we simply merge this through the musb maintainer together with all
the other musb patches, as this introduces a new file without changing any
other files collisions are impossible.

The second patch makes some minimal changes to the phy-sun4i-usb driver,
I believe it is best to merge this through the musb maintainer too, so that
all buildtime deps go in through one tree. Kishon can you review this patch
please and let us know if it is ok to merge this through the musb tree?

Then we get 5 musb patches, 4 preparation patches and 1 adding the actual
sunxi musb support, which should go through the musb tree obviously.

So assuming everyone agrees this means that patches 1 - 7 should be merged
through Felipe's tree. Felipe, is that ok with you and can you review these
patches please?

That leaves us with patches 8 - 15 which are all sunxi dts patches and as such
should go upstream through Maxime's tree once patches 1 - 7 

Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Felipe Balbi
On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
 Hi,
 
 On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
  Add a minimal driver for dm816x USB. Otherwise we can just use
  the existing musb_am335x and musb_dsps on dm816x.
 
 dm816x has the almost identical usbss as that in am335x, we should be
 able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?

Tony's using the same musb glue layers, this is just a phy driver,
right ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] phy: Add a driver for dm816x USB PHY

2015-03-09 Thread Tony Lindgren
* Bin Liu binml...@gmail.com [150309 14:17]:
 On Mon, Mar 9, 2015 at 4:13 PM, Felipe Balbi ba...@ti.com wrote:
  On Mon, Mar 09, 2015 at 04:11:28PM -0500, Bin Liu wrote:
  Hi,
 
  On Mon, Mar 9, 2015 at 3:51 PM, Tony Lindgren t...@atomide.com wrote:
   Add a minimal driver for dm816x USB. Otherwise we can just use
   the existing musb_am335x and musb_dsps on dm816x.
 
  dm816x has the almost identical usbss as that in am335x, we should be
  able to adopt musb_am335x and musb_dsps for dm816x, and dm814x too?
 
  Tony's using the same musb glue layers, this is just a phy driver,
  right ?
 
 Can the current am335x phy driver be adopted too? I remember it is
 under drivers/usb/phy/.

Yes this is just the phy, other than that things work the same.

I believe this is different from the am335x phy, and more similar to
what we have in old drivers/usb/musb/davinci.c. Chances are dm814x
is same as am335x phy.

But yeah, we really should do a proper phy driver for am335x too
along the same lines. Might even be be able to combine those drivers
with just different compatible values to set the quirks and the
enable/disable functions.

Regards,

Tony
--
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: dwc2: host: fix dwc2 disconnect bug

2015-03-09 Thread Vincent Palatin
On Thu, Mar 5, 2015 at 11:17 PM, Yunzhi Li l...@rock-chips.com wrote:
 When dwc2 controller detects a disconnect interrupt,
 dwc2_hcd_disconnect() should be called immediately to do clean-up
 jobs and set port_connect_status_change flag to notify usb hub
 driver disconnect status.

 Signed-off-by: Yunzhi Li l...@rock-chips.com
 ---
  drivers/usb/dwc2/core_intr.c | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
 index 02e3e2d..6cf0478 100644
 --- a/drivers/usb/dwc2/core_intr.c
 +++ b/drivers/usb/dwc2/core_intr.c
 @@ -377,6 +377,9 @@ static void dwc2_handle_disconnect_intr(struct dwc2_hsotg 
 *hsotg)
 dwc2_is_host_mode(hsotg) ? Host : Device,
 dwc2_op_state_str(hsotg));

 +   if (hsotg-op_state == OTG_STATE_A_HOST)
 +   dwc2_hcd_disconnect(hsotg);
 +
 /* Change to L3 (OFF) state */
 hsotg-lx_state = DWC2_L3;

 --
 2.0.0

Tested-by: Vincent Palatin vpala...@chromium.org

It's fixing real issues on my DWC2-based system where the USB device
lock was staying busy for minutes after a hub disconnection.

-- 
Vincent
--
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 0/5] Rename regulator_set_optimum_mode

2015-03-09 Thread Mark Brown
On Wed, Feb 11, 2015 at 07:35:26PM -0800, Bjorn Andersson wrote:
 Changing the name of the regulator_set_optimum_mode() to
 regulator_set_load() better reflects that the API is doing.

Applied all, thanks.


signature.asc
Description: Digital signature


Re: [PATCH v2] extcon: otg_gpio: add driver for USB OTG port controlled by GPIO(s)

2015-03-09 Thread David Cohen
Hi Linus,

On Mon, Mar 09, 2015 at 11:16:08AM -0500, Felipe Balbi wrote:
 On Sat, Mar 07, 2015 at 09:06:22PM +0100, Linus Walleij wrote:
  On Fri, Feb 20, 2015 at 8:17 PM, David Cohen
  david.a.co...@linux.intel.com wrote:
   On Fri, Feb 20, 2015 at 10:53:44AM +0100, Linus Walleij wrote:
  
   I would put this adjacent to the phy driver somewhere in drivers/usb/*
   and make the actual USB-driver thing handle its GPIOs directly.
   But I guess David and Felipe have already discussed that as we're
   seeing this patch?
  
   - The mux functions would be controlled by a possible new pinctrl-gpio
   driver (Linus, your input here would be nice :)
  
  I don't understand what this means, does it mean a pin control function
  somewhere else controlled by a GPIO pin?
  
  Or do you mean a new combined pin control and GPIO driver (we have
  plenty of these).
  
  If you elaborate on what you need to do in that driver I might
  understand it better.

This is a virtual ACPI device. Long story short we've 3 GPIOs
controlling the state of an USB OTG port. Neither of the hw components
controlled by these GPIOs are connected to a bus.
The ACPI table was implemented in such way that it considers this USB
port as a single device giving all 3 GPIOs to it.

When upstreaming this driver, the feedback I got is to split this driver
into simpler and more generic ones. FWIW ACPI tables are constructed
considering a valid Linux API during its implementation and are quite
difficult to change after product is released. The solution would be to
use MFD subsystem: this driver would create simpler children platform
devices.

But at least on ACPI case, GPIO API blocks the ability to create
children platform devices that require GPIO as platform data, despite
we've many drivers on upstream that expect this behavior: e.g. extcon-gpio.c

Are we considering those driver deprecated from the GPIO point of view?
If yes, we need to provide an update for them (we can't let upstreamed
drivers broken). If no, we need to provide a way to move forward the
GPIO to children devices.

BR, David

 
 there's a discrete mux (not something integrated in the SoC) whose
 select signal is tied to a GPIO (in some cases, more than one, but
 usually people use 2-state muxes).
 
 -- 
 balbi


--
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/7] fsl/otg: Add controller version based ULPI and UTMI phy

2015-03-09 Thread Felipe Balbi
On Wed, Jun 11, 2014 at 06:32:53PM +0530, Ramneek Mehresh wrote:
 Add controller version based ULPI and UTMI phy initialization for
 otg driver
 
 Signed-off-by: Shengzhou Liu shengzhou@freescale.com
 Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com
 Reviewed-by: Fleming Andrew-AFLEMING aflem...@freescale.com
 Tested-by: Fleming Andrew-AFLEMING aflem...@freescale.com

please resend with proper Cc list. I had lost this patch set because I
was not in Cc. And Alan Stern probably didn't see your changes on
ehci-fsl either.

scripts/get_maintainer.pl helps a lot

-- 
balbi


signature.asc
Description: Digital signature


Re: [linux-sunxi] [PATCH 09/15] ARM: dts: sun4i: Add USB Dual Role Controller

2015-03-09 Thread Julian Calaby
Hi Hans,

On Tue, Mar 10, 2015 at 7:40 AM, Hans de Goede hdego...@redhat.com wrote:
 Add a node for the otg/drc usb controller to sun4i-a10.dtsi.

 Signed-off-by: Hans de Goede hdego...@redhat.com
 ---
  arch/arm/boot/dts/sun4i-a10.dtsi | 12 
  drivers/usb/musb/Kconfig |  1 +
  2 files changed, 13 insertions(+)

 diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
 index 8180a3a..fab8e9a 100644
 --- a/drivers/usb/musb/Kconfig
 +++ b/drivers/usb/musb/Kconfig
 @@ -65,6 +65,7 @@ comment Platform Glue Layer
  config USB_MUSB_SUNXI
 tristate Allwinner (sunxi)
 depends on ARCH_SUNXI
 +   depends on NOP_USB_XCEIV

Shouldn't this be in a different patch?

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
--
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] xhci: fix reporting of 0-sized URBs in control endpoint

2015-03-09 Thread Mathias Nyman
On 06.03.2015 21:05, Aleksander Morgado wrote:
 On Fri, Mar 6, 2015 at 7:08 PM, Sergei Shtylyov
 sergei.shtyl...@cogentembedded.com wrote:
 Hello.

 On 03/06/2015 06:14 PM, Mathias Nyman wrote:

 From: Aleksander Morgado aleksan...@aleksander.es


 When a control transfer has a short data stage, the xHCI controller
 generates
 two transfer events: a COMP_SHORT_TX event that specifies the
 untransferred
 amount, and a COMP_SUCCESS event. But when the data stage is not short,
 only the
 COMP_SUCCESS event occurs. Therefore, xhci-hcd must set urb-actual_length
 to
 urb-transfer_buffer_length while processing the COMP_SUCCESS event,
 unless
 urb-actual_length was set already by a previous COMP_SHORT_TX event.


 The driver checks this by seeing whether urb-actual_length == 0, but this
 alone
 is the wrong test, as it is entirely possible for a short transfer to have
 an
 urb-actual_length = 0.


 This patch changes the xhci driver to rely on a new td-urb_length_set
 flag,
 which is set to true when a COMP_SHORT_TX event is received and the URB
 length
 updated at that stage.


 This fixes a bug which affected the HSO plugin, which relies on URBs with
 urb-actual_length == 0 to halt re-submitting the RX URB in the control
 endpoint.


 Cc: sta...@vger.kernel.org
 Signed-off-by: Aleksander Morgado aleksan...@aleksander.es
 Signed-off-by: Mathias Nyman mathias.ny...@linux.intel.com


 [...]

 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
 index 3b97f05..d066393 100644
 --- a/drivers/usb/host/xhci.h
 +++ b/drivers/usb/host/xhci.h
 @@ -1,3 +1,4 @@
 +
   /*
* xHCI host controller driver
*


Hm, I thought you've dropped this new line...

 
 Ouch; sorry for that. How do I fix that now? Submit another patch just
 removing it? Or resubmit a v6 of the patch? I think Greg already
 cherry-picked it to his branch.
 

I can clean up the extra empty line later in some generic code cleanup patch.
Don't worry about it

-Mathias
--
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 01/19] usb: dwc2: move debugfs code to a separate file

2015-03-09 Thread John Youn
On 3/9/2015 8:04 AM, Mian Yousaf Kaukab wrote:
 +
 +int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
 +{
 + int ret;
 +
 + hsotg-debug_root = debugfs_create_dir(dev_name(hsotg-dev), NULL);
 + if (!hsotg-debug_root) {
 + ret = -ENOMEM;
 + goto err0;
 + }
 +
 + /* Add gadget debugfs nodes */
 + s3c_hsotg_create_debug(hsotg);
 +err0:
 + return ret;
 +}

Need export for this function when dwc2-platform is configured as a module.

 +
 +void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg)
 +{
 + debugfs_remove_recursive(hsotg-debug_root);
 + hsotg-debug_root = NULL;
 +}

This doesn't seem to be called from anywhere.

John


--
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 03/19] usb: dwc2: add controller hibernation support

2015-03-09 Thread John Youn
On 3/9/2015 8:04 AM, Mian Yousaf Kaukab wrote:
 From: Gregory Herrero gregory.herr...@intel.com
 
 When suspending usb bus, phy driver may disable controller power.
 In this case, registers need to be saved on suspend and restored
 on resume.
 
 Signed-off-by: Gregory Herrero gregory.herr...@intel.com
 ---
  drivers/usb/dwc2/core.c | 376 
 
  drivers/usb/dwc2/core.h |  84 +++
  2 files changed, 460 insertions(+)
 
 diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
 index d5197d4..e858062 100644
 --- a/drivers/usb/dwc2/core.c
 +++ b/drivers/usb/dwc2/core.c
 @@ -56,6 +56,382 @@
  #include core.h
  #include hcd.h
  
 +#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
 +/**
 + * dwc2_backup_host_registers() - Backup controller host registers.
 + * When suspending usb bus, registers needs to be backuped
 + * if controller power is disabled once suspended.
 + *
 + * @hsotg: Programming view of the DWC_otg controller
 + */
 +static int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
 +{
 + struct hregs_backup *hr;
 + int i;
 +
 + dev_dbg(hsotg-dev, %s\n, __func__);
 +
 + /* Backup Host regs */
 + hr = hsotg-hr_backup;
 + if (!hr) {
 + hr = kmalloc(sizeof(*hr), GFP_KERNEL);
 + if (!hr) {
 + dev_err(hsotg-dev, %s: can't allocate host regs\n,
 + __func__);
 + return -ENOMEM;
 + }
 +
 + hsotg-hr_backup = hr;
 + }
 + hr-hcfg = readl(hsotg-regs + HCFG);
 + hr-haintmsk = readl(hsotg-regs + HAINTMSK);
 + for (i = 0; i  hsotg-core_params-host_channels; ++i)
 + hr-hcintmsk[i] = readl(hsotg-regs + HCINTMSK(i));
 +
 + hr-hprt0 = readl(hsotg-regs + HPRT0);
 + hr-hfir = readl(hsotg-regs + HFIR);
 + return 0;
 +}
 +
 +/**
 + * dwc2_restore_host_registers() - Restore controller host registers.
 + * When resuming usb bus, device registers needs to be restored
 + * if controller power were disabled.
 + *
 + * @hsotg: Programming view of the DWC_otg controller
 + */
 +static int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
 +{
 + struct hregs_backup *hr;
 + int i;
 +
 + dev_dbg(hsotg-dev, %s\n, __func__);
 +
 + /* Restore host regs */
 + hr = hsotg-hr_backup;
 + if (!hr) {
 + dev_err(hsotg-dev, %s: no host registers to restore\n,
 + __func__);
 + return -EINVAL;
 + }
 +
 + writel(hr-hcfg, hsotg-regs + HCFG);
 + writel(hr-haintmsk, hsotg-regs + HAINTMSK);
 +
 + for (i = 0; i  hsotg-core_params-host_channels; ++i)
 + writel(hr-hcintmsk[i], hsotg-regs + HCINTMSK(i));
 +
 + writel(hr-hprt0, hsotg-regs + HPRT0);
 + writel(hr-hfir, hsotg-regs + HFIR);
 +
 + return 0;
 +}
 +#else
 +static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg)
 +{ return 0; }
 +
 +static inline int dwc2_restore_host_registers(struct dwc2_hsotg *hsotg)
 +{ return 0; }
 +#endif
 +
 +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
 + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
 +/**
 + * dwc2_backup_device_registers() - Backup controller device registers.
 + * When suspending usb bus, registers needs to be backuped
 + * if controller power is disabled once suspended.
 + *
 + * @hsotg: Programming view of the DWC_otg controller
 + */
 +static int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
 +{
 + struct dregs_backup *dr;
 + int i;
 +
 + dev_dbg(hsotg-dev, %s\n, __func__);
 +
 + /* Backup dev regs */
 + dr = hsotg-dr_backup;
 + if (!dr) {
 + dr = kmalloc(sizeof(*dr), GFP_KERNEL);
 + if (!dr) {
 + dev_err(hsotg-dev, %s: can't allocate device regs\n,
 + __func__);
 + return -ENOMEM;
 + }
 +
 + hsotg-dr_backup = dr;
 + }
 +
 + dr-dcfg = readl(hsotg-regs + DCFG);
 + dr-dctl = readl(hsotg-regs + DCTL);
 + dr-daintmsk = readl(hsotg-regs + DAINTMSK);
 + dr-diepmsk = readl(hsotg-regs + DIEPMSK);
 + dr-doepmsk = readl(hsotg-regs + DOEPMSK);
 +
 + for (i = 0; i  hsotg-num_of_eps; i++) {
 + /* Backup IN EPs */
 + dr-diepctl[i] = readl(hsotg-regs + DIEPCTL(i));
 +
 + /* Ensure DATA PID is correctly configured */
 + if (dr-diepctl[i]  DXEPCTL_DPID)
 + dr-diepctl[i] |= DXEPCTL_SETD1PID;
 + else
 + dr-diepctl[i] |= DXEPCTL_SETD0PID;
 +
 + dr-dieptsiz[i] = readl(hsotg-regs + DIEPTSIZ(i));
 + dr-diepdma[i] = readl(hsotg-regs + DIEPDMA(i));
 +
 + /* Backup OUT EPs */
 + dr-doepctl[i] = readl(hsotg-regs + DOEPCTL(i));
 +
 + /* Ensure DATA PID is correctly configured */
 + if (dr-doepctl[i]  DXEPCTL_DPID)
 +   

RE: [PATCH] drivers: usb: gadget: udc: Fix NULL dereference

2015-03-09 Thread Peter Chen
 
 On Tue, Mar 10, 2015 at 02:02:44AM +, Peter Chen wrote:
 
--- a/drivers/usb/gadget/udc/lpc32xx_udc.c
+++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
@@ -1803,7 +1803,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
req = container_of(_req, struct lpc32xx_request, req);
ep = container_of(_ep, struct lpc32xx_ep, ep);
   
-   if (!_req || !_req-complete || !_req-buf ||
+   if (!_ep || !_req || !_req-complete || !_req-buf ||
!list_empty(req-queue))
return -EINVAL;
   
@@ -1815,8 +1815,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
}
   
   
-   if ((!udc) || (!udc-driver) ||
-   (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
+   if ((!udc-driver) || (udc-gadget.speed == USB_SPEED_UNKNOWN))
   {
dev_dbg(udc-dev, invalid device\n);
return -EINVAL;
}
  
   what's going to happen here ?
  
 
  I just changed the current code, in fact, udc-driver is impossible to
  NULL which is cleared at .udc_stop.
 
  The speed is possible for unknown if the reset has occurred at that time.
 
 oh, alright.

Do you need me or Tapasweni send patch for this?

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] phy: twl4030-usb: Remove redundant assignment for twl-linkstat

2015-03-09 Thread Axel Lin
It's pointless to set twl-linkstat twice.

Signed-off-by: Axel Lin axel@ingics.com
---
Resend with linux-usb in Cc.
 drivers/phy/phy-twl4030-usb.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 8e87f54..bc42d6a 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -666,7 +666,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl-dev= pdev-dev;
twl-irq= platform_get_irq(pdev, 0);
twl-vbus_supplied  = false;
-   twl-linkstat   = -EINVAL;
twl-linkstat   = OMAP_MUSB_UNKNOWN;
 
twl-phy.dev= twl-dev;
-- 
1.9.1



--
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 00/15] musb: Add support for the Allwinner sunxi musb controller

2015-03-09 Thread Chen-Yu Tsai
Hi Arnd,

On Tue, Mar 10, 2015 at 5:44 AM, Arnd Bergmann a...@arndb.de wrote:
 On Monday 09 March 2015 21:40:13 Hans de Goede wrote:
 Hi All,

 This patch set has been a while in the making, so I'm very happy to present
 the end result here, and I hope everyone likes it.

 Awesome work!

 Before talking about merging this there are 2 things which I would like to
 point out:

 a) The musb controller in the sunxi SoCs uses some SRAM which needs to be
 mapped to the musb controller by poking some bits in the SRAM controller,
 just like the EMAC patches which were send a while back I've chosen to use
 syscon for this, actually 2 of the patches in this set come directly from the
 SRAM mapping patchset for the EMAC.

 I know that Maxime is not 100% in favor of using syscon:
 http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/320221.html

 But I disagree with his arguments for writing a special driver for the SRAM
 controller:
 1) syscon was specifically designed for global system control registers like
 this and is fine to use as long as there are no conflicts where 1 bit is of
 interest to multiple drivers, and there is no such conflict here
 2) Maxime's other arguments seem to boil down to it would be nice / prettier
 to have a specific driver for this, without really proving a hard need for
 such a driver. But writing such a driver is going to be a lot of work, and
 we've a ton of other work to do, and as said there is no real need for a
 separate driver, syscon works fine for this.
 3) I actually believe that having a specific driver for this is a bad idea,
 because that means inventing a whole new cross driver API for this, and
 getting those right is, hard, a lot of work, and even then one is still 
 likely
 to get it wrong. We can avoid all this by going with the proven syscon 
 solution.

 Maxime, can we please have your ack for moving forward with this using 
 syscon?
 (see above for my arguments why)

 I'd like to understand here why we can't use the existing SRAM DT binding
 instead of the syscon binding.

I believe you are talking about mmio-sram?

The syscon here represents a switch, to toggle whether a block of SRAM is
mapped into the CPU memory space, or to a specific devices private address
space. It is not the actual SRAM.

The SRAM DT binding is orthogonal to this, if not irrelevant when the block
is mapped privately, as it is no longer visible from the DT's PoV.

Coincidentally, on the A23 this is no longer needed. The SRAM for the FIFO
is wholly owned by MUSB and not available to the CPU.


ChenYu
--
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] drivers: usb: gadget: udc: Fix NULL dereference

2015-03-09 Thread Peter Chen
 
  --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
  +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
  @@ -1803,7 +1803,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
  req = container_of(_req, struct lpc32xx_request, req);
  ep = container_of(_ep, struct lpc32xx_ep, ep);
 
  -   if (!_req || !_req-complete || !_req-buf ||
  +   if (!_ep || !_req || !_req-complete || !_req-buf ||
  !list_empty(req-queue))
  return -EINVAL;
 
  @@ -1815,8 +1815,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
  }
 
 
  -   if ((!udc) || (!udc-driver) ||
  -   (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
  +   if ((!udc-driver) || (udc-gadget.speed == USB_SPEED_UNKNOWN))
 {
  dev_dbg(udc-dev, invalid device\n);
  return -EINVAL;
  }
 
 what's going to happen here ?
 

I just changed the current code, in fact, udc-driver is impossible to NULL 
which
is cleared at .udc_stop. 

The speed is possible for unknown if the reset has occurred at that time.

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


Re: [PATCH 07/19] usb: dwc2: set parameter values in probe function

2015-03-09 Thread John Youn
On 3/9/2015 8:04 AM, Mian Yousaf Kaukab wrote:
 So the parameters can be used in both host and gadget modes.
 
 Signed-off-by: Mian Yousaf Kaukab yousaf.kau...@intel.com
 ---
  drivers/usb/dwc2/core.h |  3 +--
  drivers/usb/dwc2/hcd.c  | 18 +-
  drivers/usb/dwc2/hcd.h  |  3 +--
  drivers/usb/dwc2/pci.c  | 17 -
  drivers/usb/dwc2/platform.c | 18 +-
  5 files changed, 36 insertions(+), 23 deletions(-)
 
 diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
 index 795e4ed..9098749 100644
 --- a/drivers/usb/dwc2/core.h
 +++ b/drivers/usb/dwc2/core.h
 @@ -1123,8 +1123,7 @@ static inline int dwc2_hcd_get_frame_number(struct 
 dwc2_hsotg *hsotg)
  static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) {}
  static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {}
  static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {}
 -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 - const struct dwc2_core_params *params)
 +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
  { return 0; }
  #endif
  
 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
 index c78c874..908fc8a 100644
 --- a/drivers/usb/dwc2/hcd.c
 +++ b/drivers/usb/dwc2/hcd.c
 @@ -2775,8 +2775,7 @@ EXPORT_SYMBOL_GPL(dwc2_set_all_params);
   * USB bus with the core and calls the hc_driver-start() function. It 
 returns
   * a negative error on failure.
   */
 -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 -   const struct dwc2_core_params *params)
 +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq)
  {
   struct usb_hcd *hcd;
   struct dwc2_host_chan *channel;
 @@ -2789,12 +2788,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
  
   dev_dbg(hsotg-dev, DWC OTG HCD INIT\n);
  
 - /* Detect config values from hardware */
 - retval = dwc2_get_hwparams(hsotg);
 -
 - if (retval)
 - return retval;
 -
   retval = -ENOMEM;
  
   hcfg = readl(hsotg-regs + HCFG);
 @@ -2813,15 +2806,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
   hsotg-last_frame_num = HFNUM_MAX_FRNUM;
  #endif
  
 - hsotg-core_params = kzalloc(sizeof(*hsotg-core_params), GFP_KERNEL);
 - if (!hsotg-core_params)
 - goto error1;
 -
 - dwc2_set_all_params(hsotg-core_params, -1);
 -
 - /* Validate parameter values */
 - dwc2_set_parameters(hsotg, params);
 -
   /* Check if the bus driver or platform code has setup a dma_mask */
   if (hsotg-core_params-dma_enable  0 
   hsotg-dev-dma_mask == NULL) {
 diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h
 index e69a843..cd803ae 100644
 --- a/drivers/usb/dwc2/hcd.h
 +++ b/drivers/usb/dwc2/hcd.h
 @@ -451,8 +451,7 @@ static inline u8 dwc2_hcd_is_pipe_out(struct 
 dwc2_hcd_pipe_info *pipe)
   return !dwc2_hcd_is_pipe_in(pipe);
  }
  
 -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
 -  const struct dwc2_core_params *params);
 +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq);
  extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
  extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg,
   const struct dwc2_core_params *params);
 diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c
 index e5e6ab9..2e82268 100644
 --- a/drivers/usb/dwc2/pci.c
 +++ b/drivers/usb/dwc2/pci.c
 @@ -147,8 +147,23 @@ static int dwc2_driver_probe(struct pci_dev *dev,
   if (retval)
   return retval;
  
 + /* Detect config values from hardware */
 + retval = dwc2_get_hwparams(hsotg);
 + if (retval)
 + return retval;
 +
 + hsotg-core_params = devm_kzalloc(dev-dev,
 + sizeof(*hsotg-core_params), GFP_KERNEL);
 + if (!hsotg-core_params)
 + return -ENOMEM;
 +
 + dwc2_set_all_params(hsotg-core_params, -1);
 +
 + /* Validate parameter values */
 + dwc2_set_parameters(hsotg, dwc2_module_params);
 +
   spin_lock_init(hsotg-lock);
 - retval = dwc2_hcd_init(hsotg, dev-irq, dwc2_module_params);
 + retval = dwc2_hcd_init(hsotg, dev-irq);
   if (retval) {
   pci_disable_device(dev);
   return retval;
 diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
 index f9b7d9f..a6d4b43 100644
 --- a/drivers/usb/dwc2/platform.c
 +++ b/drivers/usb/dwc2/platform.c
 @@ -237,10 +237,26 @@ static int dwc2_driver_probe(struct platform_device 
 *dev)
  
   spin_lock_init(hsotg-lock);
   mutex_init(hsotg-init_mutex);
 +
 + /* Detect config values from hardware */
 + retval = dwc2_get_hwparams(hsotg);
 + if (retval)
 + return retval;
 +
 + hsotg-core_params = devm_kzalloc(dev-dev,
 + sizeof(*hsotg-core_params), GFP_KERNEL);
 + if (!hsotg-core_params)
 + return -ENOMEM;
 +
 + 

Re: [PATCH] drivers: usb: gadget: udc: Fix NULL dereference

2015-03-09 Thread Felipe Balbi
On Tue, Mar 10, 2015 at 02:02:44AM +, Peter Chen wrote:
  
   --- a/drivers/usb/gadget/udc/lpc32xx_udc.c
   +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c
   @@ -1803,7 +1803,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
 req = container_of(_req, struct lpc32xx_request, req);
 ep = container_of(_ep, struct lpc32xx_ep, ep);
  
   - if (!_req || !_req-complete || !_req-buf ||
   + if (!_ep || !_req || !_req-complete || !_req-buf ||
 !list_empty(req-queue))
 return -EINVAL;
  
   @@ -1815,8 +1815,7 @@ static int lpc32xx_ep_queue(struct usb_ep *_ep,
 }
  
  
   - if ((!udc) || (!udc-driver) ||
   - (udc-gadget.speed == USB_SPEED_UNKNOWN)) {
   + if ((!udc-driver) || (udc-gadget.speed == USB_SPEED_UNKNOWN))
  {
 dev_dbg(udc-dev, invalid device\n);
 return -EINVAL;
 }
  
  what's going to happen here ?
  
 
 I just changed the current code, in fact, udc-driver is impossible to NULL 
 which
 is cleared at .udc_stop. 
 
 The speed is possible for unknown if the reset has occurred at that time.

oh, alright.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH 17/19] usb: dwc2: host: spinlock urb_enqueue

2015-03-09 Thread John Youn
On 3/9/2015 8:05 AM, Mian Yousaf Kaukab wrote:
 From: Gregory Herrero gregory.herr...@intel.com
 
 During urb_enqueue, if the urb can't be queued to the endpoint,
 the urb is freed without any spinlock protection.
 This leads to memory corruption when concurrent urb_dequeue try to free
 same urb-hcpriv.
 Thus, ensure the whole urb_enqueue in spinlocked.
 
 Signed-off-by: Gregory Herrero gregory.herr...@intel.com
 ---
  drivers/usb/dwc2/hcd.c   | 14 +++---
  drivers/usb/dwc2/hcd_queue.c |  6 --
  2 files changed, 3 insertions(+), 17 deletions(-)
 
 diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
 index fd02b43..011b679 100644
 --- a/drivers/usb/dwc2/hcd.c
 +++ b/drivers/usb/dwc2/hcd.c
 @@ -354,7 +354,6 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
   gfp_t mem_flags)
  {
   struct dwc2_qtd *qtd;
 - unsigned long flags;
   u32 intr_mask;
   int retval;
   int dev_speed;
 @@ -405,11 +404,9 @@ static int dwc2_hcd_urb_enqueue(struct dwc2_hsotg *hsotg,
*/
   return 0;
  
 - spin_lock_irqsave(hsotg-lock, flags);
   tr_type = dwc2_hcd_select_transactions(hsotg);
   if (tr_type != DWC2_TRANSACTION_NONE)
   dwc2_hcd_queue_transactions(hsotg, tr_type);
 - spin_unlock_irqrestore(hsotg-lock, flags);
   }
  
   return 0;
 @@ -2424,6 +2421,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, 
 struct urb *urb,
   void *buf;
   unsigned long flags;
  
 + spin_lock_irqsave(hsotg-lock, flags);


Missing a couple places where this will not be unlocked in this
function.

Also, seems like you could hold off on locking until just before
usb_hcd_link_urb_to_ep().


John


--
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] Remove deprecated IRQF_DISABLED flag entirely

2015-03-09 Thread Valentin Rothberg
On Fri, Mar 6, 2015 at 8:41 PM, Dmitry Torokhov
dmitry.torok...@gmail.com wrote:
 On Thu, Mar 5, 2015 at 5:11 AM, Hannes Reinecke h...@suse.de wrote:
 On 03/05/2015 01:59 PM, Valentin Rothberg wrote:
 The IRQF_DISABLED is a NOOP and has been scheduled for removal since
 Linux v2.6.36 by commit 6932bf37bed4 (genirq: Remove IRQF_DISABLED from
 core code).

 According to commit e58aa3d2d0cc (genirq: Run irq handlers with
 interrupts disabled) running IRQ handlers with interrupts enabled can
 cause stack overflows when the interrupt line of the issuing device is
 still active.

 This patch ends the grace period for IRQF_DISABLED (i.e., SA_INTERRUPT
 in older versions of Linux) and removes the definition and all remaining
 usages of this flag.

 Signed-off-by: Valentin Rothberg valentinrothb...@gmail.com
 ---
 The bigger hunk in Documentation/scsi/ncr53c8xx.txt is removed entirely
 as IRQF_DISABLED is gone now; the usage in older kernel versions
 (including the old SA_INTERRUPT flag) should be discouraged.  The
 trouble of using IRQF_SHARED is a general problem and not specific to
 any driver.

 I left the reference in Documentation/PCI/MSI-HOWTO.txt untouched since
 it has already been removed in linux-next by commit b0e1ee8e1405
 (MSI-HOWTO.txt: remove reference on IRQF_DISABLED).

 All remaining references are changelogs that I suggest to keep.

 While you're at it: having '0x0' as a value for the irq flags looks
 a bit silly, and makes you wonder what the parameter is for.

 I would rather like to have

 #define IRQF_NONE 0x0

 and use it for these cases.
 That way the scope of that parameter is clear.

 No, that would imply that IRQ never triggers whereas passing 0 means
 we keep triggers that have been set by the platform.

Are you against introducing a new flag or just don't like 'IRQF_NONE'?
 I think that passing 0 could mean anything when one does not know the
semantics.  Combining yours and Hannes' proposal could look like this:

#define IRQF_PLAT 0x0 - keep triggers that have been set by the platform

I wrote a Coccinelle script to check for such 0-flags and find 758
cases in current Linus' mainline.  The script only checks function
calls to {devm_}request_{threaded_}IRQ() but does not find flags
passed to wrapper functions or flags that are stored in a struct etc.

Kind regards,
 Valentin
--
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 5/7] usb: chipidea: otg_fsm: add HNP polling support

2015-03-09 Thread Peter Chen
On Mon, Mar 09, 2015 at 10:09:21AM +0800, Li Jun wrote:
 From: Li Jun b47...@freescale.com
 
 Add a dedicataed normal timer for HNP polling since it's cyclical, while
 in peripheral mode, change a/b_bus_req to be 1 will make it response
 to host request flag with 1, then role switch will be started.

use a_bus_req/b_bus_req

Why hnp polling timer can't use chipidea fsm hrtimer list?

 
 Signed-off-by: Li Jun jun...@freescale.com
 ---
  drivers/usb/chipidea/ci.h  |4 
  drivers/usb/chipidea/otg_fsm.c |   49 
 +---
  drivers/usb/chipidea/otg_fsm.h |2 ++
  3 files changed, 52 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
 index aeec5f0..3192a44 100644
 --- a/drivers/usb/chipidea/ci.h
 +++ b/drivers/usb/chipidea/ci.h
 @@ -166,6 +166,8 @@ struct hw_bank {
   * @hr_timeouts: time out list for active otg fsm timers
   * @enabled_otg_timer_bits: bits of enabled otg timers
   * @next_otg_timer: next nearest enabled timer to be expired
 + * @hnp_polling_timer: cyclical timer for hnp polling
 + * @hnp_polling_req: indicates there is hnp polling request
   * @work: work for role changing
   * @wq: workqueue thread
   * @qh_pool: allocation pool for queue heads
 @@ -212,6 +214,8 @@ struct ci_hdrc {
   ktime_t hr_timeouts[NUM_OTG_FSM_TIMERS];
   unsignedenabled_otg_timer_bits;
   enum otg_fsm_timer  next_otg_timer;
 + struct timer_list   hnp_polling_timer;
 + boolhnp_polling_req;
   struct work_struct  work;
   struct workqueue_struct *wq;
  
 diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
 index 083acf4..ed79ae7 100644
 --- a/drivers/usb/chipidea/otg_fsm.c
 +++ b/drivers/usb/chipidea/otg_fsm.c
 @@ -66,6 +66,11 @@ set_a_bus_req(struct device *dev, struct device_attribute 
 *attr,
   return count;
   }
   ci-fsm.a_bus_req = 1;
 + if (ci-fsm.otg-state == OTG_STATE_A_PERIPHERAL) {
 + ci-gadget.host_request_flag = 1;
 + mutex_unlock(ci-fsm.lock);
 + return count;
 + }
   }
  
   ci_otg_queue_work(ci);
 @@ -144,8 +149,14 @@ set_b_bus_req(struct device *dev, struct 
 device_attribute *attr,
   mutex_lock(ci-fsm.lock);
   if (buf[0] == '0')
   ci-fsm.b_bus_req = 0;
 - else if (buf[0] == '1')
 + else if (buf[0] == '1') {
   ci-fsm.b_bus_req = 1;
 + if (ci-fsm.otg-state == OTG_STATE_B_PERIPHERAL) {
 + ci-gadget.host_request_flag = 1;
 + mutex_unlock(ci-fsm.lock);
 + return count;
 + }
 + }
  
   ci_otg_queue_work(ci);
   mutex_unlock(ci-fsm.lock);
 @@ -203,6 +214,7 @@ static unsigned otg_timer_ms[] = {
   0,
   TB_DATA_PLS,
   TB_SSEND_SRP,
 + 0,
  };
  
  /*
 @@ -358,6 +370,7 @@ static int (*otg_timer_handlers[])(struct ci_hdrc *) = {
   NULL,   /* A_WAIT_ENUM */
   b_data_pls_tmout,   /* B_DATA_PLS */
   b_ssend_srp_tmout,  /* B_SSEND_SRP */
 + NULL,   /* HNP_POLLING */
  };
  
  /*
 @@ -404,15 +417,32 @@ static enum hrtimer_restart ci_otg_hrtimer_func(struct 
 hrtimer *t)
   return HRTIMER_NORESTART;
  }
  
 +static void hnp_polling_timer_work(unsigned long arg)
 +{
 + struct ci_hdrc *ci = (struct ci_hdrc *)arg;
 +
 + ci-hnp_polling_req = true;
 + ci_otg_queue_work(ci);
 +}
 +
  /* Initialize timers */
  static int ci_otg_init_timers(struct ci_hdrc *ci)
  {
   hrtimer_init(ci-otg_fsm_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
   ci-otg_fsm_hrtimer.function = ci_otg_hrtimer_func;
  
 + setup_timer(ci-hnp_polling_timer, hnp_polling_timer_work,
 + (unsigned long)ci);
 +
   return 0;
  }
  
 +static void ci_otg_add_hnp_polling_timer(struct ci_hdrc *ci)
 +{
 + mod_timer(ci-hnp_polling_timer,
 + jiffies + msecs_to_jiffies(T_HOST_REQ_POLL));
 +}
 +
  /* -*/
  /* Operations that will be called from OTG Finite State Machine */
  /* -*/
 @@ -420,8 +450,12 @@ static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, 
 enum otg_fsm_timer t)
  {
   struct ci_hdrc  *ci = container_of(fsm, struct ci_hdrc, fsm);
  
 - if (t  NUM_OTG_FSM_TIMERS)
 - ci_otg_add_timer(ci, t);
 + if (t  NUM_OTG_FSM_TIMERS) {
 + if (t == HNP_POLLING)
 + ci_otg_add_hnp_polling_timer(ci);
 + else
 + ci_otg_add_timer(ci, t);
 + }
   return;
  }
  
 @@ -569,6 +603,14 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
   return 0;
  

Re: [PATCH 4/7] usb: chipidea: udc: add OTG status request handling

2015-03-09 Thread Peter Chen
On Mon, Mar 09, 2015 at 10:09:20AM +0800, Li Jun wrote:
 From: Li Jun b47...@freescale.com
 
 Peripheral answers OTG status selector request from host according to
 host_request_flag of gadget, length is 1.
 
 Signed-off-by: Li Jun jun...@freescale.com
 ---
  drivers/usb/chipidea/udc.c |   28 +++-
  1 file changed, 23 insertions(+), 5 deletions(-)
 
 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
 index 4254792..eed66bc 100644
 --- a/drivers/usb/chipidea/udc.c
 +++ b/drivers/usb/chipidea/udc.c
 @@ -831,7 +831,17 @@ __acquires(hwep-lock)
   return -ENOMEM;
  
   req-complete = isr_get_status_complete;
 - req-length   = 2;
 + if (setup-wIndex == OTG_STS_SELECTOR) {
 + if (ci_otg_is_fsm_mode(ci)) {
 + req-length = 1;
 + } else {
 + retval = -ENOTSUPP;
 + goto err_free_req;
 + }
 + } else {
 + req-length = 2;
 + }
 +
   req-buf  = kzalloc(req-length, gfp_flags);
   if (req-buf == NULL) {
   retval = -ENOMEM;
 @@ -839,8 +849,15 @@ __acquires(hwep-lock)
   }
  
   if ((setup-bRequestType  USB_RECIP_MASK) == USB_RECIP_DEVICE) {
 - *(u16 *)req-buf = (ci-remote_wakeup  1) |
 - ci-gadget.is_selfpowered;
 + if (setup-wIndex == OTG_STS_SELECTOR) {
 + if (ci-gadget.host_request_flag)
 + *(u8 *)req-buf = HOST_REQUEST_FLAG;
 + else
 + *(u8 *)req-buf = 0;
 + } else {
 + *(u16 *)req-buf = (ci-remote_wakeup  1) |
 + ci-gadget.is_selfpowered;
 + }
   } else if ((setup-bRequestType  USB_RECIP_MASK) \
  == USB_RECIP_ENDPOINT) {
   dir = (le16_to_cpu(setup-wIndex)  USB_ENDPOINT_DIR_MASK) ?
 @@ -1018,8 +1035,9 @@ __acquires(ci-lock)
   type != (USB_DIR_IN|USB_RECIP_ENDPOINT) 
   type != (USB_DIR_IN|USB_RECIP_INTERFACE))
   goto delegate;
 - if (le16_to_cpu(req.wLength) != 2 ||
 - le16_to_cpu(req.wValue)  != 0)
 + if ((le16_to_cpu(req.wLength) != 2 
 + le16_to_cpu(req.wLength) != 1) ||
 + le16_to_cpu(req.wValue) != 0)
   break;
   err = isr_get_status_response(ci, req);
   break;
 -- 
 1.7.9.5
 

Is it possible for applying this to common code, like composite.c?

-- 

Best Regards,
Peter Chen
--
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/7] usb: gadget: add host_requestf_flag in usb_gadget for OTG HNP

2015-03-09 Thread Peter Chen
On Mon, Mar 09, 2015 at 10:09:17AM +0800, Li Jun wrote:
 From: Li Jun b47...@freescale.com
 
 Adds host_request_flag for gadget to store host request information from 
 application, which can be used to response to HNP polling from host.
 
 Signed-off-by: Li Jun jun...@freescale.com
 ---
  include/linux/usb/gadget.h |1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
 index e2f00fd..5508c48 100644
 --- a/include/linux/usb/gadget.h
 +++ b/include/linux/usb/gadget.h
 @@ -563,6 +563,7 @@ struct usb_gadget {
   unsignedb_hnp_enable:1;
   unsigneda_hnp_support:1;
   unsigneda_alt_hnp_support:1;
 + unsignedhost_request_flag:1;
   unsignedquirk_ep_out_aligned_size:1;
   unsignedis_selfpowered:1;
  };
 -- 
 1.7.9.5
 

Add kernel-doc too.

-- 

Best Regards,
Peter Chen
--
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: Driver problem with USB chipset VIA VL812-B2

2015-03-09 Thread Warren Severin
Have just tested 4.0-rc3 and the problem persists as before. Unable to get
desktop environment and so unable to use gnome-system-monitor for names of
processes and %cpu, but command line utility htop says it's almost totally
ksoftirqd thread(s) and not so much kworker thread(s). Still, 25% of total
CPU, which is 100% of one CPU.

Problem exists with both of the external USB 3.0 hubs that I have which have
different chipsets.

If there are any nightly builds that you'd like me to check just let me know.


--
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