[linux-yocto] [PATCH 13/25] usb: chipidea: set usb otg capabilities

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Li Jun 

Init and update otg capabilities by DT, set gadget's otg capabilities
accordingly.

Acked-by: Peter Chen 
Reviewed-by: Roger Quadros 
Signed-off-by: Li Jun 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 79742351c89b76ebcf82b73103aed50f98ac2ee4)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/chipidea/core.c  | 15 +++
 drivers/usb/chipidea/udc.c   |  7 ++-
 include/linux/usb/chipidea.h |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3ad48e1..ab6212e 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -560,6 +560,8 @@ static irqreturn_t ci_irq(int irq, void *data)
 static int ci_get_platdata(struct device *dev,
struct ci_hdrc_platform_data *platdata)
 {
+   int ret;
+
if (!platdata->phy_mode)
platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
 
@@ -588,6 +590,19 @@ static int ci_get_platdata(struct device *dev,
of_usb_host_tpl_support(dev->of_node);
}
 
+   if (platdata->dr_mode == USB_DR_MODE_OTG) {
+   /* We can support HNP and SRP of OTG 2.0 */
+   platdata->ci_otg_caps.otg_rev = 0x0200;
+   platdata->ci_otg_caps.hnp_support = true;
+   platdata->ci_otg_caps.srp_support = true;
+
+   /* Update otg capabilities by DT properties */
+   ret = of_usb_update_otg_caps(dev->of_node,
+   &platdata->ci_otg_caps);
+   if (ret)
+   return ret;
+   }
+
if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
 
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 92937c1..b1265b5 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1848,6 +1848,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci)
 static int udc_start(struct ci_hdrc *ci)
 {
struct device *dev = ci->dev;
+   struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;
int retval = 0;
 
spin_lock_init(&ci->lock);
@@ -1855,8 +1856,12 @@ static int udc_start(struct ci_hdrc *ci)
ci->gadget.ops  = &usb_gadget_ops;
ci->gadget.speed= USB_SPEED_UNKNOWN;
ci->gadget.max_speed= USB_SPEED_HIGH;
-   ci->gadget.is_otg   = ci->is_otg ? 1 : 0;
ci->gadget.name = ci->platdata->name;
+   ci->gadget.otg_caps = otg_caps;
+
+   if (otg_caps->hnp_support || otg_caps->srp_support ||
+   otg_caps->adp_support)
+   ci->gadget.is_otg = 1;
 
INIT_LIST_HEAD(&ci->gadget.ep_list);
 
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index ab94f78..e10cefc 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -34,6 +34,7 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT   1
void(*notify_event) (struct ci_hdrc *ci, unsigned event);
struct regulator*reg_vbus;
+   struct usb_otg_caps ci_otg_caps;
booltpl_support;
 };
 
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 25/25] usb: dwc3: pci: add support for Intel Broxton SOC

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

PCI IDs for Broxton based platforms.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit b4c580a43d520b7812c0fd064fbab929ce2f1da0)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/dwc3-pci.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index ab26e1c..78835e6 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -34,6 +34,8 @@
 #define PCI_DEVICE_ID_INTEL_BSW0x22b7
 #define PCI_DEVICE_ID_INTEL_SPTLP  0x9d30
 #define PCI_DEVICE_ID_INTEL_SPTH   0xa130
+#define PCI_DEVICE_ID_INTEL_BXT0x0aaa
+#define PCI_DEVICE_ID_INTEL_APL0x5aaa
 
 static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
 static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
@@ -204,6 +206,8 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTLP), },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTH), },
+   { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
+   { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
{  }/* Terminating Entry */
 };
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 10/25] usb: dwc3: add ULPI interface support

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

Registers DWC3's ULPI interface with the ULPI bus when it's
available.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 88bc9d194ff69875a4d3c958d969ed2a053c8308)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/Kconfig  |  7 
 drivers/usb/dwc3/Makefile |  4 +++
 drivers/usb/dwc3/core.c   | 34 --
 drivers/usb/dwc3/core.h   | 14 
 drivers/usb/dwc3/ulpi.c   | 91 +++
 5 files changed, 147 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/dwc3/ulpi.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index 827c4f8..473bfaa 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -11,6 +11,13 @@ config USB_DWC3
 
 if USB_DWC3
 
+config USB_DWC3_ULPI
+   bool "Register ULPI PHY Interface"
+   depends on USB_ULPI_BUS=y || USB_ULPI_BUS=USB_DWC3
+   help
+ Select this if you have ULPI type PHY attached to your DWC3
+ controller.
+
 choice
bool "DWC3 Mode Selection"
default USB_DWC3_DUAL_ROLE if (USB && USB_GADGET)
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 46172f4..c7076e3 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -15,6 +15,10 @@ ifneq ($(filter y,$(CONFIG_USB_DWC3_GADGET) 
$(CONFIG_USB_DWC3_DUAL_ROLE)),)
dwc3-y  += gadget.o ep0.o
 endif
 
+ifneq ($(CONFIG_USB_DWC3_ULPI),)
+   dwc3-y  += ulpi.o
+endif
+
 ifneq ($(CONFIG_DEBUG_FS),)
dwc3-y  += debugfs.o
 endif
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e76ec1e..0fc9391 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -394,10 +394,15 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
 /**
  * dwc3_phy_setup - Configure USB PHY Interface of DWC3 Core
  * @dwc: Pointer to our controller context structure
+ *
+ * Returns 0 on success. The USB PHY interfaces are configured but not
+ * initialized. The PHY interfaces and the PHYs get initialized together with
+ * the core in dwc3_core_init.
  */
-static void dwc3_phy_setup(struct dwc3 *dwc)
+static int dwc3_phy_setup(struct dwc3 *dwc)
 {
u32 reg;
+   int ret;
 
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
 
@@ -443,13 +448,30 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   break;
} else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
} else {
dev_warn(dwc->dev, "HSPHY Interface not defined\n");
-   break;
+
+   /* Relying on default value. */
+   if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
+   break;
}
/* FALLTHROUGH */
+   case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
+   /* Making sure the interface and PHY are operational */
+   ret = dwc3_soft_reset(dwc);
+   if (ret)
+   return ret;
+
+   udelay(1);
+
+   ret = dwc3_ulpi_init(dwc);
+   if (ret)
+   return ret;
+   /* FALLTHROUGH */
default:
break;
}
@@ -467,6 +489,8 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
+
+   return 0;
 }
 
 /**
@@ -912,7 +936,9 @@ static int dwc3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc);
 
-   dwc3_phy_setup(dwc);
+   ret = dwc3_phy_setup(dwc);
+   if (ret)
+   goto err0;
 
ret = dwc3_core_get_phy(dwc);
if (ret)
@@ -1000,6 +1026,7 @@ err2:
 
 err1:
dwc3_free_event_buffers(dwc);
+   dwc3_ulpi_exit(dwc);
 
 err0:
/*
@@ -1035,6 +1062,7 @@ static int dwc3_remove(struct platform_device *pdev)
phy_power_off(dwc->usb3_generic_phy);
 
dwc3_core_exit(dwc);
+   dwc3_ulpi_exit(dwc);
 
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 8fb4ce0..1841dd0 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -664,6 +665,7 @@ struct dwc3_scratchpad_array {
  * @usb3_phy: pointer to USB3 PHY
  * @usb2_generic_phy: pointer to USB2 PHY
  * @usb3_generic_phy: pointer to USB3 PHY
+ * @ulpi: pointer to

[linux-yocto] [PATCH 23/25] usb: dwc3: Add dis_enblslpm_quirk

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: John Youn 

Add a quirk to clear the GUSB2PHYCFG.ENBLSLPM bit, which controls
whether the PHY receives the suspend signal from the controller.

Cc:  # v3.18+
Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
(cherry picked from commit ec791d149bca4511e7d3a6a92bb3b030c5a443f9)
Signed-off-by: Wan Ahmad Zainie 
---
 Documentation/devicetree/bindings/usb/dwc3.txt | 2 ++
 drivers/usb/dwc3/core.c| 6 ++
 drivers/usb/dwc3/core.h| 4 
 drivers/usb/dwc3/platform_data.h   | 1 +
 4 files changed, 13 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index 0815eac..e12f344 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -35,6 +35,8 @@ Optional properties:
LTSSM during USB3 Compliance mode.
  - snps,dis_u3_susphy_quirk: when set core will disable USB3 suspend phy.
  - snps,dis_u2_susphy_quirk: when set core will disable USB2 suspend phy.
+ - snps,dis_enblslpm_quirk: when set clears the enblslpm in GUSB2PHYCFG,
+   disabling the suspend signal to the PHY.
  - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
utmi_l1_suspend_n, false when asserts utmi_sleep_n
  - snps,hird-threshold: HIRD threshold
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 83500cf..1f79708 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -516,6 +516,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
if (dwc->dis_u2_susphy_quirk)
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
+   if (dwc->dis_enblslpm_quirk)
+   reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
 
return 0;
@@ -913,6 +916,8 @@ static int dwc3_probe(struct platform_device *pdev)
"snps,dis_u3_susphy_quirk");
dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
"snps,dis_u2_susphy_quirk");
+   dwc->dis_enblslpm_quirk = device_property_read_bool(dev,
+   "snps,dis_enblslpm_quirk");
 
dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
@@ -946,6 +951,7 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->rx_detect_poll_quirk = pdata->rx_detect_poll_quirk;
dwc->dis_u3_susphy_quirk = pdata->dis_u3_susphy_quirk;
dwc->dis_u2_susphy_quirk = pdata->dis_u2_susphy_quirk;
+   dwc->dis_enblslpm_quirk = pdata->dis_enblslpm_quirk;
 
dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
if (pdata->tx_de_emphasis)
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 0d65be7..36f1cb7 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -179,6 +179,7 @@
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
 #define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4)
+#define DWC3_GUSB2PHYCFG_ENBLSLPM  (1 << 8)
 
 /* Global USB2 PHY Vendor Control Register */
 #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
@@ -720,6 +721,8 @@ struct dwc3_scratchpad_array {
  * @rx_detect_poll_quirk: set if we enable rx_detect to polling lfps quirk
  * @dis_u3_susphy_quirk: set if we disable usb3 suspend phy
  * @dis_u2_susphy_quirk: set if we disable usb2 suspend phy
+ * @dis_enblslpm_quirk: set if we clear enblslpm in GUSB2PHYCFG,
+ *  disabling the suspend signal to the PHY.
  * @tx_de_emphasis_quirk: set if we enable Tx de-emphasis quirk
  * @tx_de_emphasis: Tx de-emphasis value
  * 0   - -6dB de-emphasis
@@ -864,6 +867,7 @@ struct dwc3 {
unsignedrx_detect_poll_quirk:1;
unsigneddis_u3_susphy_quirk:1;
unsigneddis_u2_susphy_quirk:1;
+   unsigneddis_enblslpm_quirk:1;
 
unsignedtx_de_emphasis_quirk:1;
unsignedtx_de_emphasis:2;
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index 400b197..2bb4d3a 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -42,6 +42,7 @@ struct dwc3_platform_data {
unsigned rx_detect_poll_quirk:1;
unsigned dis_u3_susphy_quirk:1;
unsigned dis_u2_susphy_quirk:1;
+   unsigned dis_enblslpm_quirk:1;
 
unsigned tx_de_emphasis_quirk:1;
unsigned tx_de_emphasis:2;
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 24/25] usb: dwc3: pci: Set enblslpm quirk for Synopsys platforms

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: John Youn 

Certain Synopsys prototyping PHY boards are not able to meet timings
constraints for LPM. This allows the PHY to meet those timings by
leaving the PHY clock running during suspend.

Cc:  # v3.18+
Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 94218ee31ba56fb3a8625978b393124ad660408e)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/dwc3-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index c18baf4..ab26e1c 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -88,6 +88,7 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
memset(&pdata, 0, sizeof(pdata));
pdata.usb3_lpm_capable = true;
pdata.has_lpm_erratum = true;
+   pdata.dis_enblslpm_quirk = true;
 
return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
sizeof(pdata));
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 12/25] usb: common: add API to update usb otg capabilities by device tree

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Li Jun 

Check property of usb hardware to update otg version and disable SRP, HNP
and ADP if its disable flag is present.

Reviewed-by: Roger Quadros 
Signed-off-by: Li Jun 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 929412d94f2b75fe2a662afa2977bfb6a233c1c3)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/common/common.c | 56 +
 include/linux/usb/of.h  |  7 ++
 2 files changed, 63 insertions(+)

diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index b530fd4..9e39286 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -154,6 +154,62 @@ bool of_usb_host_tpl_support(struct device_node *np)
return false;
 }
 EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
+
+/**
+ * of_usb_update_otg_caps - to update usb otg capabilities according to
+ * the passed properties in DT.
+ * @np: Pointer to the given device_node
+ * @otg_caps: Pointer to the target usb_otg_caps to be set
+ *
+ * The function updates the otg capabilities
+ */
+int of_usb_update_otg_caps(struct device_node *np,
+   struct usb_otg_caps *otg_caps)
+{
+   u32 otg_rev;
+
+   if (!otg_caps)
+   return -EINVAL;
+
+   if (!of_property_read_u32(np, "otg-rev", &otg_rev)) {
+   switch (otg_rev) {
+   case 0x0100:
+   case 0x0120:
+   case 0x0130:
+   case 0x0200:
+   /* Choose the lesser one if it's already been set */
+   if (otg_caps->otg_rev)
+   otg_caps->otg_rev = min_t(u16, otg_rev,
+   otg_caps->otg_rev);
+   else
+   otg_caps->otg_rev = otg_rev;
+   break;
+   default:
+   pr_err("%s: unsupported otg-rev: 0x%x\n",
+   np->full_name, otg_rev);
+   return -EINVAL;
+   }
+   } else {
+   /*
+* otg-rev is mandatory for otg properties, if not passed
+* we set it to be 0 and assume it's a legacy otg device.
+* Non-dt platform can set it afterwards.
+*/
+   otg_caps->otg_rev = 0;
+   }
+
+   if (of_find_property(np, "hnp-disable", NULL))
+   otg_caps->hnp_support = false;
+   if (of_find_property(np, "srp-disable", NULL))
+   otg_caps->srp_support = false;
+   if (of_find_property(np, "adp-disable", NULL) ||
+   (otg_caps->otg_rev < 0x0200))
+   otg_caps->adp_support = false;
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(of_usb_update_otg_caps);
+
 #endif
 
 MODULE_LICENSE("GPL");
diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h
index cfe0528..8c5a818 100644
--- a/include/linux/usb/of.h
+++ b/include/linux/usb/of.h
@@ -15,6 +15,8 @@
 enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np);
 enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np);
 bool of_usb_host_tpl_support(struct device_node *np);
+int of_usb_update_otg_caps(struct device_node *np,
+   struct usb_otg_caps *otg_caps);
 #else
 static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
 {
@@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct 
device_node *np)
 {
return false;
 }
+static inline int of_usb_update_otg_caps(struct device_node *np,
+   struct usb_otg_caps *otg_caps)
+{
+   return 0;
+}
 #endif
 
 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT)
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 11/25] usb: dwc3: core: avoid NULL pointer dereference

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Felipe Balbi 

commit 3e10a2ce98d1 ("usb: dwc3: add hsphy_interface
property") introduced a possible NULL pointer
dereference because dwc->hsphy_interface can be
NULL.

In order to fix it, all we have to do is guard
strncmp() against a NULL argument.

Fixes: 3e10a2ce98d1 ("usb: dwc3: add hsphy_interface property")
Tested-by: Murali Karicheri 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 43cacb03aabe62158d8e5da876054c7d48fc9963)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0fc9391..946f27f 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -446,10 +446,12 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
/* Select the HS PHY interface */
switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
-   if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
+   if (dwc->hsphy_interface &&
+   !strncmp(dwc->hsphy_interface, "utmi", 4)) {
reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
break;
-   } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
+   } else if (dwc->hsphy_interface &&
+   !strncmp(dwc->hsphy_interface, "ulpi", 4)) {
reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
} else {
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 08/25] usb: dwc3: add hsphy_interface property

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

Platforms that have configured DWC_USB3_HSPHY_INTERFACE with
value 3, i.e. UTMI+ and ULPI, need to inform the driver of
the actual HSPHY interface type with the property. "utmi" if
the interface is UTMI+ or "ulpi" if the interface is ULPI.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 3e10a2ce98d1a57992a44ed40325af60ab7b0f5d)
Signed-off-by: Wan Ahmad Zainie 
---
 Documentation/devicetree/bindings/usb/dwc3.txt |  2 ++
 drivers/usb/dwc3/core.c| 20 
 drivers/usb/dwc3/core.h|  3 +++
 drivers/usb/dwc3/platform_data.h   |  2 ++
 4 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt 
b/Documentation/devicetree/bindings/usb/dwc3.txt
index 5cc3643..0815eac 100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -38,6 +38,8 @@ Optional properties:
  - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
utmi_l1_suspend_n, false when asserts utmi_sleep_n
  - snps,hird-threshold: HIRD threshold
+ - snps,hsphy_interface: High-Speed PHY interface selection between "utmi" for
+   UTMI+ and "ulpi" for ULPI when the DWC_USB3_HSPHY_INTERFACE has value 3.
 
 This is usually a subnode to DWC3 glue to which it is connected.
 
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 2bda3c7..e76ec1e 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -438,6 +438,22 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
 
+   /* Select the HS PHY interface */
+   switch (DWC3_GHWPARAMS3_HSPHY_IFC(dwc->hwparams.hwparams3)) {
+   case DWC3_GHWPARAMS3_HSPHY_IFC_UTMI_ULPI:
+   if (!strncmp(dwc->hsphy_interface, "utmi", 4)) {
+   reg &= ~DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   } else if (!strncmp(dwc->hsphy_interface, "ulpi", 4)) {
+   reg |= DWC3_GUSB2PHYCFG_ULPI_UTMI;
+   } else {
+   dev_warn(dwc->dev, "HSPHY Interface not defined\n");
+   break;
+   }
+   /* FALLTHROUGH */
+   default:
+   break;
+   }
+
/*
 * Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
 * '0' during coreConsultant configuration. So default value will
@@ -850,6 +866,8 @@ static int dwc3_probe(struct platform_device *pdev)
"snps,tx_de_emphasis_quirk");
of_property_read_u8(node, "snps,tx_de_emphasis",
&tx_de_emphasis);
+   of_property_read_string(node, "snps,hsphy_interface",
+   &dwc->hsphy_interface);
} else if (pdata) {
dwc->maximum_speed = pdata->maximum_speed;
dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -877,6 +895,8 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->tx_de_emphasis_quirk = pdata->tx_de_emphasis_quirk;
if (pdata->tx_de_emphasis)
tx_de_emphasis = pdata->tx_de_emphasis;
+
+   dwc->hsphy_interface = pdata->hsphy_interface;
}
 
/* default to superspeed if no maximum_speed passed */
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 92361c0..8fb4ce0 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -685,6 +685,7 @@ struct dwc3_scratchpad_array {
  * @test_mode_nr: test feature selector
  * @lpm_nyet_threshold: LPM NYET response threshold
  * @hird_threshold: HIRD threshold
+ * @hsphy_interface: "utmi" or "ulpi"
  * @delayed_status: true when gadget driver asks for delayed status
  * @ep0_bounced: true when we used bounce buffer
  * @ep0_expect_in: true when we expect a DATA IN transfer
@@ -827,6 +828,8 @@ struct dwc3 {
u8  lpm_nyet_threshold;
u8  hird_threshold;
 
+   const char  *hsphy_interface;
+
unsigneddelayed_status:1;
unsignedep0_bounced:1;
unsignedep0_expect_in:1;
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index a2bd464..d3614ec 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -45,4 +45,6 @@ struct dwc3_platform_data {
 
unsigned tx_de_emphasis_quirk:1;
unsigned tx_de_emphasis:2;
+
+   const char *hsphy_interface;
 };
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 22/25] usb: dwc3: pci: trivial: Formatting

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: John Youn 

Fix the alignment of the PCI device definitions. Also change the hex
digit capitalization of one constant to make it consistent with the
rest of the file and driver.

Signed-off-by: John Youn 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 9a5a0783e4910d9e2063e87184fbd9cac7161a16)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/dwc3-pci.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 5e7be53..c18baf4 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -26,14 +26,14 @@
 
 #include "platform_data.h"
 
-#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB30xabcd
-#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI 0xabce
-#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31 0xabcf
-#define PCI_DEVICE_ID_INTEL_BYT0x0f37
-#define PCI_DEVICE_ID_INTEL_MRFLD  0x119e
-#define PCI_DEVICE_ID_INTEL_BSW0x22B7
-#define PCI_DEVICE_ID_INTEL_SPTLP  0x9d30
-#define PCI_DEVICE_ID_INTEL_SPTH   0xa130
+#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB30xabcd
+#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI0xabce
+#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31   0xabcf
+#define PCI_DEVICE_ID_INTEL_BYT0x0f37
+#define PCI_DEVICE_ID_INTEL_MRFLD  0x119e
+#define PCI_DEVICE_ID_INTEL_BSW0x22b7
+#define PCI_DEVICE_ID_INTEL_SPTLP  0x9d30
+#define PCI_DEVICE_ID_INTEL_SPTH   0xa130
 
 static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
 static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 07/25] usb: dwc3: setup phys earlier

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

This allows dwc3_phy_setup() to be more useful later. There
is nothing preventing the PHY configuration registers from
being programmed early. They do not loose their context in
soft reset.

There are however other PHY related operations that should
be executed before the driver request handles to the PHYs,
such as registering DWC3's ULPI interface, which can now be
done in dwc3_phy_setup().

Also, if there ever was need for the two 100ms delays in
dwc3_phy_setup() there isn't anymore. The PHYs are now reset
after the PHY interfaces are setup.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 45bb7de213d86d491840e9c3ae139475ab3fa493)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index f1a998a..2bda3c7 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -436,8 +436,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
 
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
-   mdelay(100);
-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
 
/*
@@ -453,8 +451,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
-
-   mdelay(100);
 }
 
 /**
@@ -575,8 +571,6 @@ static int dwc3_core_init(struct dwc3 *dwc)
 
dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
-   dwc3_phy_setup(dwc);
-
ret = dwc3_alloc_scratch_buffers(dwc);
if (ret)
goto err1;
@@ -898,6 +892,8 @@ static int dwc3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dwc);
dwc3_cache_hwparams(dwc);
 
+   dwc3_phy_setup(dwc);
+
ret = dwc3_core_get_phy(dwc);
if (ret)
goto err0;
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 19/25] usb: common: of_usb_get_dr_mode to usb_get_dr_mode

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 06e7114f0d8297278eb24f4e9bee3393a94bd8ce)
Signed-off-by: Wan Ahmad Zainie 

Conflicts:
drivers/usb/musb/sunxi.c
Resolved. Deleted. This file does not exist in 4.1.y.
---
 drivers/usb/chipidea/core.c |  2 +-
 drivers/usb/common/common.c | 15 ---
 drivers/usb/dwc2/platform.c |  2 +-
 drivers/usb/dwc3/core.c |  2 +-
 drivers/usb/dwc3/dwc3-st.c  |  2 +-
 drivers/usb/musb/musb_dsps.c|  2 +-
 drivers/usb/phy/phy-msm-usb.c   |  2 +-
 drivers/usb/phy/phy-tegra-usb.c |  2 +-
 include/linux/usb/of.h  |  6 --
 include/linux/usb/otg.h |  9 +
 10 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 029859a..b0e79e6 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -566,7 +566,7 @@ static int ci_get_platdata(struct device *dev,
platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
 
if (!platdata->dr_mode)
-   platdata->dr_mode = of_usb_get_dr_mode(dev->of_node);
+   platdata->dr_mode = usb_get_dr_mode(dev);
 
if (platdata->dr_mode == USB_DR_MODE_UNKNOWN)
platdata->dr_mode = USB_DR_MODE_OTG;
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index b25a111..673d530 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -99,7 +99,6 @@ const char *usb_state_string(enum usb_device_state state)
 }
 EXPORT_SYMBOL_GPL(usb_state_string);
 
-#ifdef CONFIG_OF
 static const char *const usb_dr_modes[] = {
[USB_DR_MODE_UNKNOWN]   = "",
[USB_DR_MODE_HOST]  = "host",
@@ -107,19 +106,12 @@ static const char *const usb_dr_modes[] = {
[USB_DR_MODE_OTG]   = "otg",
 };
 
-/**
- * of_usb_get_dr_mode - Get dual role mode for given device_node
- * @np:Pointer to the given device_node
- *
- * The function gets phy interface string from property 'dr_mode',
- * and returns the correspondig enum usb_dr_mode
- */
-enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
+enum usb_dr_mode usb_get_dr_mode(struct device *dev)
 {
const char *dr_mode;
int err, i;
 
-   err = of_property_read_string(np, "dr_mode", &dr_mode);
+   err = device_property_read_string(dev, "dr_mode", &dr_mode);
if (err < 0)
return USB_DR_MODE_UNKNOWN;
 
@@ -129,8 +121,9 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
 
return USB_DR_MODE_UNKNOWN;
 }
-EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
+EXPORT_SYMBOL_GPL(usb_get_dr_mode);
 
+#ifdef CONFIG_OF
 /**
  * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
  * for given targeted hosts (non-PC hosts)
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 185663e..d6f620f 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -214,7 +214,7 @@ static int dwc2_driver_probe(struct platform_device *dev)
dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
(unsigned long)res->start, hsotg->regs);
 
-   hsotg->dr_mode = of_usb_get_dr_mode(dev->dev.of_node);
+   hsotg->dr_mode = usb_get_dr_mode(&dev->dev);
 
/*
 * Attempt to find a generic PHY, then look for an old style
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 43b8c1c..c649596 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -878,6 +878,7 @@ static int dwc3_probe(struct platform_device *pdev)
hird_threshold = 12;
 
dwc->maximum_speed = usb_get_maximum_speed(dev);
+   dwc->dr_mode = usb_get_dr_mode(dev);
 
if (node) {
dwc->has_lpm_erratum = of_property_read_bool(node,
@@ -893,7 +894,6 @@ static int dwc3_probe(struct platform_device *pdev)
 
dwc->needs_fifo_resize = of_property_read_bool(node,
"tx-fifo-resize");
-   dwc->dr_mode = of_usb_get_dr_mode(node);
 
dwc->disable_scramble_quirk = of_property_read_bool(node,
"snps,disable_scramble_quirk");
diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 8e66449..a3f3384 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -272,7 +272,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
goto undo_softreset;
}
 
-   dwc3_data->dr_mode = of_usb_get_dr_mode(child_pdev->dev.of_node);
+   dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
 
/*
 * Configure the USB port as device or host according to the static
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/mus

[linux-yocto] [PATCH 09/25] usb: dwc3: pci: add quirk for Baytrails

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

On some BYT platforms the USB2 PHY needs to be put into
operational mode by the controller driver with GPIOs
controlling the PHYs reset and cs signals.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit a89d977cc04c77d9aa45d426dbf8de9dd1326c77)
Signed-off-by: Wan Ahmad Zainie 

Conflicts:
drivers/usb/dwc3/dwc3-pci.c
Resolved. Conflicted due to commit
usb: dwc3: pci: Add platform data for Synopsys HAPS
---
 drivers/usb/dwc3/dwc3-pci.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 830f020..fcdbd13 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -21,6 +21,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "platform_data.h"
 
@@ -33,6 +35,15 @@
 #define PCI_DEVICE_ID_INTEL_SPTLP  0x9d30
 #define PCI_DEVICE_ID_INTEL_SPTH   0xa130
 
+static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
+static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
+
+static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
+   { "reset-gpios", &reset_gpios, 1 },
+   { "cs-gpios", &cs_gpios, 1 },
+   { },
+};
+
 static int dwc3_pci_quirks(struct pci_dev *pdev)
 {
if (pdev->vendor == PCI_VENDOR_ID_AMD &&
@@ -82,6 +93,30 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
sizeof(pdata));
}
 
+   if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+   pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
+   struct gpio_desc *gpio;
+
+   acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
+ acpi_dwc3_byt_gpios);
+
+   /* These GPIOs will turn on the USB2 PHY */
+   gpio = gpiod_get(&pdev->dev, "cs");
+   if (!IS_ERR(gpio)) {
+   gpiod_direction_output(gpio, 0);
+   gpiod_set_value_cansleep(gpio, 1);
+   gpiod_put(gpio);
+   }
+
+   gpio = gpiod_get(&pdev->dev, "reset");
+   if (!IS_ERR(gpio)) {
+   gpiod_direction_output(gpio, 0);
+   gpiod_set_value_cansleep(gpio, 1);
+   gpiod_put(gpio);
+   usleep_range(1, 11000);
+   }
+   }
+
return 0;
 }
 
@@ -145,6 +180,7 @@ err:
 
 static void dwc3_pci_remove(struct pci_dev *pci)
 {
+   acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
platform_device_unregister(pci_get_drvdata(pci));
 }
 
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 20/25] usb: dwc3: core: convert to unified device property interface

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

No functional affect on existing platforms, but the driver
is now ready to extract the properties also from ACPI tables
as well as from DT.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 3d128919b7e514f0e489ab863c572a1e7032276a)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 50 -
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index c649596..83500cf 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -807,7 +807,6 @@ static int dwc3_probe(struct platform_device *pdev)
 {
struct device   *dev = &pdev->dev;
struct dwc3_platform_data *pdata = dev_get_platdata(dev);
-   struct device_node  *node = dev->of_node;
struct resource *res;
struct dwc3 *dwc;
u8  lpm_nyet_threshold;
@@ -880,52 +879,51 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->maximum_speed = usb_get_maximum_speed(dev);
dwc->dr_mode = usb_get_dr_mode(dev);
 
-   if (node) {
-   dwc->has_lpm_erratum = of_property_read_bool(node,
+   dwc->has_lpm_erratum = device_property_read_bool(dev,
"snps,has-lpm-erratum");
-   of_property_read_u8(node, "snps,lpm-nyet-threshold",
+   device_property_read_u8(dev, "snps,lpm-nyet-threshold",
&lpm_nyet_threshold);
-   dwc->is_utmi_l1_suspend = of_property_read_bool(node,
+   dwc->is_utmi_l1_suspend = device_property_read_bool(dev,
"snps,is-utmi-l1-suspend");
-   of_property_read_u8(node, "snps,hird-threshold",
+   device_property_read_u8(dev, "snps,hird-threshold",
&hird_threshold);
-   dwc->usb3_lpm_capable = of_property_read_bool(node,
+   dwc->usb3_lpm_capable = device_property_read_bool(dev,
"snps,usb3_lpm_capable");
 
-   dwc->needs_fifo_resize = of_property_read_bool(node,
+   dwc->needs_fifo_resize = device_property_read_bool(dev,
"tx-fifo-resize");
 
-   dwc->disable_scramble_quirk = of_property_read_bool(node,
+   dwc->disable_scramble_quirk = device_property_read_bool(dev,
"snps,disable_scramble_quirk");
-   dwc->u2exit_lfps_quirk = of_property_read_bool(node,
+   dwc->u2exit_lfps_quirk = device_property_read_bool(dev,
"snps,u2exit_lfps_quirk");
-   dwc->u2ss_inp3_quirk = of_property_read_bool(node,
+   dwc->u2ss_inp3_quirk = device_property_read_bool(dev,
"snps,u2ss_inp3_quirk");
-   dwc->req_p1p2p3_quirk = of_property_read_bool(node,
+   dwc->req_p1p2p3_quirk = device_property_read_bool(dev,
"snps,req_p1p2p3_quirk");
-   dwc->del_p1p2p3_quirk = of_property_read_bool(node,
+   dwc->del_p1p2p3_quirk = device_property_read_bool(dev,
"snps,del_p1p2p3_quirk");
-   dwc->del_phy_power_chg_quirk = of_property_read_bool(node,
+   dwc->del_phy_power_chg_quirk = device_property_read_bool(dev,
"snps,del_phy_power_chg_quirk");
-   dwc->lfps_filter_quirk = of_property_read_bool(node,
+   dwc->lfps_filter_quirk = device_property_read_bool(dev,
"snps,lfps_filter_quirk");
-   dwc->rx_detect_poll_quirk = of_property_read_bool(node,
+   dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
"snps,rx_detect_poll_quirk");
-   dwc->dis_u3_susphy_quirk = of_property_read_bool(node,
+   dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
"snps,dis_u3_susphy_quirk");
-   dwc->dis_u2_susphy_quirk = of_property_read_bool(node,
+   dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
"snps,dis_u2_susphy_quirk");
 
-   dwc->tx_de_emphasis_quirk = of_property_read_bool(node,
+   dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
"snps,tx_de_emphasis_quirk");
-   of_property_read_u8(node, "snps,tx_de_emphasis",
+   device_property_read_u8(dev, "snps,tx_de_emphasis",
&tx_de_emphasis);
-   of_property_read_string(node, "snps,hsphy_interface",
-   &dwc->hsphy_interface);
-   of_property_read_u32(node,
-"snps,quirk-frame-length-adjustment",
-&fladj);
-   } else if (pdata) {
+   device_property_

[linux-yocto] [PATCH 21/25] usb: dwc3: pci: passing forward the ACPI companion

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

Sharing the ACPI companion with dwc3 core so it has access
to the properties defined for DWC3 in ACPI tables.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 9caeb06ebd4687bc40a67d94facabb2d31c702ce)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/dwc3-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index fcdbd13..5e7be53 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -165,6 +165,7 @@ static int dwc3_pci_probe(struct pci_dev *pci,
goto err;
 
dwc3->dev.parent = dev;
+   ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));
 
ret = platform_device_add(dwc3);
if (ret) {
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 14/25] usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Phil Edworthy 

These changes allow a PHY driver to trigger a VBUS interrupt and
to provide the value of VBUS.

Reviewed-by: Laurent Pinchart 
Signed-off-by: Phil Edworthy 
Signed-off-by: Felipe Balbi 
(cherry picked from commit b5a2875605cac14a7d7744ec8254547a26c02612)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/renesas_usbhs/mod_gadget.c | 62 ++
 1 file changed, 62 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index dc2aa32..494dfe0 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "common.h"
 
 /*
@@ -50,6 +51,8 @@ struct usbhsg_gpriv {
int  uep_size;
 
struct usb_gadget_driver*driver;
+   struct usb_phy  *transceiver;
+   bool vbus_active;
 
u32 status;
 #define USBHSG_STATUS_STARTED  (1 << 0)
@@ -873,6 +876,27 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 
status)
 }
 
 /*
+ * VBUS provided by the PHY
+ */
+static int usbhsm_phy_get_vbus(struct platform_device *pdev)
+{
+   struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+   struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
+
+   return  gpriv->vbus_active;
+}
+
+static void usbhs_mod_phy_mode(struct usbhs_priv *priv)
+{
+   struct usbhs_mod_info *info = &priv->mod_info;
+
+   info->irq_vbus  = NULL;
+   priv->pfunc.get_vbus= usbhsm_phy_get_vbus;
+
+   usbhs_irq_callback_update(priv, NULL);
+}
+
+/*
  *
  * linux usb function
  *
@@ -882,12 +906,28 @@ static int usbhsg_gadget_start(struct usb_gadget *gadget,
 {
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
+   struct device *dev = usbhs_priv_to_dev(priv);
+   int ret;
 
if (!driver ||
!driver->setup  ||
driver->max_speed < USB_SPEED_FULL)
return -EINVAL;
 
+   /* connect to bus through transceiver */
+   if (!IS_ERR_OR_NULL(gpriv->transceiver)) {
+   ret = otg_set_peripheral(gpriv->transceiver->otg,
+   &gpriv->gadget);
+   if (ret) {
+   dev_err(dev, "%s: can't bind to transceiver\n",
+   gpriv->gadget.name);
+   return ret;
+   }
+
+   /* get vbus using phy versions */
+   usbhs_mod_phy_mode(priv);
+   }
+
/* first hook up the driver ... */
gpriv->driver = driver;
 
@@ -900,6 +940,10 @@ static int usbhsg_gadget_stop(struct usb_gadget *gadget)
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
 
usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
+
+   if (!IS_ERR_OR_NULL(gpriv->transceiver))
+   otg_set_peripheral(gpriv->transceiver->otg, NULL);
+
gpriv->driver = NULL;
 
return 0;
@@ -947,12 +991,26 @@ static int usbhsg_set_selfpowered(struct usb_gadget 
*gadget, int is_self)
return 0;
 }
 
+static int usbhsg_vbus_session(struct usb_gadget *gadget, int is_active)
+{
+   struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
+   struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
+   struct platform_device *pdev = usbhs_priv_to_pdev(priv);
+
+   gpriv->vbus_active = !!is_active;
+
+   renesas_usbhs_call_notify_hotplug(pdev);
+
+   return 0;
+}
+
 static const struct usb_gadget_ops usbhsg_gadget_ops = {
.get_frame  = usbhsg_get_frame,
.set_selfpowered= usbhsg_set_selfpowered,
.udc_start  = usbhsg_gadget_start,
.udc_stop   = usbhsg_gadget_stop,
.pullup = usbhsg_pullup,
+   .vbus_session   = usbhsg_vbus_session,
 };
 
 static int usbhsg_start(struct usbhs_priv *priv)
@@ -994,6 +1052,10 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
goto usbhs_mod_gadget_probe_err_gpriv;
}
 
+   gpriv->transceiver = usb_get_phy(USB_PHY_TYPE_UNDEFINED);
+   dev_info(dev, "%stransceiver found\n",
+gpriv->transceiver ? "" : "no ");
+
/*
 * CAUTION
 *
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 06/25] usb: dwc3: soft reset to it's own function

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

So it can be called from other places later.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit c5cc74e8c12be67ef7f09f77c2b9df6faf7904f0)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 46 ++
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 786c66a..f1a998a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -117,6 +117,33 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc)
 }
 
 /**
+ * dwc3_soft_reset - Issue soft reset
+ * @dwc: Pointer to our controller context structure
+ */
+static int dwc3_soft_reset(struct dwc3 *dwc)
+{
+   unsigned long timeout;
+   u32 reg;
+
+   timeout = jiffies + msecs_to_jiffies(500);
+   dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
+   do {
+   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+   if (!(reg & DWC3_DCTL_CSFTRST))
+   break;
+
+   if (time_after(jiffies, timeout)) {
+   dev_err(dwc->dev, "Reset Timed Out\n");
+   return -ETIMEDOUT;
+   }
+
+   cpu_relax();
+   } while (true);
+
+   return 0;
+}
+
+/**
  * dwc3_free_one_event_buffer - Frees one event buffer
  * @dwc: Pointer to our controller context structure
  * @evt: Pointer to event buffer to be freed
@@ -438,7 +465,6 @@ static void dwc3_phy_setup(struct dwc3 *dwc)
  */
 static int dwc3_core_init(struct dwc3 *dwc)
 {
-   unsigned long   timeout;
u32 hwparams4 = dwc->hwparams.hwparams4;
u32 reg;
int ret;
@@ -472,21 +498,9 @@ static int dwc3_core_init(struct dwc3 *dwc)
}
 
/* issue device SoftReset too */
-   timeout = jiffies + msecs_to_jiffies(500);
-   dwc3_writel(dwc->regs, DWC3_DCTL, DWC3_DCTL_CSFTRST);
-   do {
-   reg = dwc3_readl(dwc->regs, DWC3_DCTL);
-   if (!(reg & DWC3_DCTL_CSFTRST))
-   break;
-
-   if (time_after(jiffies, timeout)) {
-   dev_err(dwc->dev, "Reset Timed Out\n");
-   ret = -ETIMEDOUT;
-   goto err0;
-   }
-
-   cpu_relax();
-   } while (true);
+   ret = dwc3_soft_reset(dwc);
+   if (ret)
+   goto err0;
 
ret = dwc3_core_soft_reset(dwc);
if (ret)
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 16/25] usb: dwc3: Add frame length adjustment quirk

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Nikhil Badola 

Add adjust_frame_length_quirk for writing to fladj register
which adjusts (micro)frame length to value provided by
"snps,quirk-frame-length-adjustment" property thus avoiding
USB 2.0 devices to time-out over a longer run

Signed-off-by: Nikhil Badola 
Signed-off-by: Felipe Balbi 
(cherry picked from commit db2be4e9e30c6e43e48c5749d3fc74cee0a6bbb3)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c  | 34 ++
 drivers/usb/dwc3/core.h  |  5 +
 drivers/usb/dwc3/platform_data.h |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 946f27f..deade78 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -143,6 +143,32 @@ static int dwc3_soft_reset(struct dwc3 *dwc)
return 0;
 }
 
+/*
+ * dwc3_frame_length_adjustment - Adjusts frame length if required
+ * @dwc3: Pointer to our controller context structure
+ * @fladj: Value of GFLADJ_30MHZ to adjust frame length
+ */
+static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj)
+{
+   u32 reg;
+   u32 dft;
+
+   if (dwc->revision < DWC3_REVISION_250A)
+   return;
+
+   if (fladj == 0)
+   return;
+
+   reg = dwc3_readl(dwc->regs, DWC3_GFLADJ);
+   dft = reg & DWC3_GFLADJ_30MHZ_MASK;
+   if (!dev_WARN_ONCE(dwc->dev, dft == fladj,
+   "request value same as default, ignoring\n")) {
+   reg &= ~DWC3_GFLADJ_30MHZ_MASK;
+   reg |= DWC3_GFLADJ_30MHZ_SDBND_SEL | fladj;
+   dwc3_writel(dwc->regs, DWC3_GFLADJ, reg);
+   }
+}
+
 /**
  * dwc3_free_one_event_buffer - Frees one event buffer
  * @dwc: Pointer to our controller context structure
@@ -787,6 +813,7 @@ static int dwc3_probe(struct platform_device *pdev)
u8  lpm_nyet_threshold;
u8  tx_de_emphasis;
u8  hird_threshold;
+   u32 fladj = 0;
 
int ret;
 
@@ -894,6 +921,9 @@ static int dwc3_probe(struct platform_device *pdev)
&tx_de_emphasis);
of_property_read_string(node, "snps,hsphy_interface",
&dwc->hsphy_interface);
+   of_property_read_u32(node,
+"snps,quirk-frame-length-adjustment",
+&fladj);
} else if (pdata) {
dwc->maximum_speed = pdata->maximum_speed;
dwc->has_lpm_erratum = pdata->has_lpm_erratum;
@@ -923,6 +953,7 @@ static int dwc3_probe(struct platform_device *pdev)
tx_de_emphasis = pdata->tx_de_emphasis;
 
dwc->hsphy_interface = pdata->hsphy_interface;
+   fladj = pdata->fladj_value;
}
 
/* default to superspeed if no maximum_speed passed */
@@ -979,6 +1010,9 @@ static int dwc3_probe(struct platform_device *pdev)
goto err1;
}
 
+   /* Adjust Frame Length */
+   dwc3_frame_length_adjustment(dwc, fladj);
+
usb_phy_set_suspend(dwc->usb2_phy, 0);
usb_phy_set_suspend(dwc->usb3_phy, 0);
ret = phy_power_on(dwc->usb2_generic_phy);
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 1841dd0..0d65be7 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -127,6 +127,7 @@
 #define DWC3_GEVNTCOUNT(n) (0xc40c + (n * 0x10))
 
 #define DWC3_GHWPARAMS80xc600
+#define DWC3_GFLADJ0xc630
 
 /* Device Registers */
 #define DWC3_DCFG  0xc700
@@ -237,6 +238,10 @@
 /* Global HWPARAMS6 Register */
 #define DWC3_GHWPARAMS6_EN_FPGA(1 << 7)
 
+/* Global Frame Length Adjustment Register */
+#define DWC3_GFLADJ_30MHZ_SDBND_SEL(1 << 7)
+#define DWC3_GFLADJ_30MHZ_MASK 0x3f
+
 /* Device Configuration Register */
 #define DWC3_DCFG_DEVADDR(addr)((addr) << 3)
 #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f)
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h
index d3614ec..400b197 100644
--- a/drivers/usb/dwc3/platform_data.h
+++ b/drivers/usb/dwc3/platform_data.h
@@ -46,5 +46,7 @@ struct dwc3_platform_data {
unsigned tx_de_emphasis_quirk:1;
unsigned tx_de_emphasis:2;
 
+   u32 fladj_value;
+
const char *hsphy_interface;
 };
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 17/25] usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

By using the unified device property interface, the function
can be made available for all platforms and not just the
ones using DT.

Signed-off-by: Heikki Krogerus 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 63863b988eeca2823ce76b28b104e0b8366cafec)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/chipidea/core.c  |  2 +-
 drivers/usb/common/common.c  | 44 ++--
 drivers/usb/dwc3/core.c  |  3 ++-
 drivers/usb/musb/musb_dsps.c |  2 +-
 include/linux/usb/ch9.h  | 11 ++-
 include/linux/usb/of.h   |  6 --
 6 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ab6212e..029859a 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -603,7 +603,7 @@ static int ci_get_platdata(struct device *dev,
return ret;
}
 
-   if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL)
+   if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
 
return 0;
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index 9e39286..b25a111 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -60,6 +60,24 @@ const char *usb_speed_string(enum usb_device_speed speed)
 }
 EXPORT_SYMBOL_GPL(usb_speed_string);
 
+enum usb_device_speed usb_get_maximum_speed(struct device *dev)
+{
+   const char *maximum_speed;
+   int err;
+   int i;
+
+   err = device_property_read_string(dev, "maximum-speed", &maximum_speed);
+   if (err < 0)
+   return USB_SPEED_UNKNOWN;
+
+   for (i = 0; i < ARRAY_SIZE(speed_names); i++)
+   if (strcmp(maximum_speed, speed_names[i]) == 0)
+   return i;
+
+   return USB_SPEED_UNKNOWN;
+}
+EXPORT_SYMBOL_GPL(usb_get_maximum_speed);
+
 const char *usb_state_string(enum usb_device_state state)
 {
static const char *const names[] = {
@@ -114,32 +132,6 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np)
 EXPORT_SYMBOL_GPL(of_usb_get_dr_mode);
 
 /**
- * of_usb_get_maximum_speed - Get maximum requested speed for a given USB
- * controller.
- * @np: Pointer to the given device_node
- *
- * The function gets the maximum speed string from property "maximum-speed",
- * and returns the corresponding enum usb_device_speed.
- */
-enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np)
-{
-   const char *maximum_speed;
-   int err;
-   int i;
-
-   err = of_property_read_string(np, "maximum-speed", &maximum_speed);
-   if (err < 0)
-   return USB_SPEED_UNKNOWN;
-
-   for (i = 0; i < ARRAY_SIZE(speed_names); i++)
-   if (strcmp(maximum_speed, speed_names[i]) == 0)
-   return i;
-
-   return USB_SPEED_UNKNOWN;
-}
-EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed);
-
-/**
  * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported
  * for given targeted hosts (non-PC hosts)
  * @np: Pointer to the given device_node
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index deade78..43b8c1c 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -877,8 +877,9 @@ static int dwc3_probe(struct platform_device *pdev)
 */
hird_threshold = 12;
 
+   dwc->maximum_speed = usb_get_maximum_speed(dev);
+
if (node) {
-   dwc->maximum_speed = of_usb_get_maximum_speed(node);
dwc->has_lpm_erratum = of_property_read_bool(node,
"snps,has-lpm-erratum");
of_property_read_u8(node, "snps,lpm-nyet-threshold",
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 20e7b7d..85b694f 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -747,7 +747,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
if (!ret && val)
config->multipoint = true;
 
-   config->maximum_speed = of_usb_get_maximum_speed(dn);
+   config->maximum_speed = usb_get_maximum_speed(&parent->dev);
switch (config->maximum_speed) {
case USB_SPEED_LOW:
case USB_SPEED_FULL:
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 27603bc..6cc96bb 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -32,9 +32,9 @@
 #ifndef __LINUX_USB_CH9_H
 #define __LINUX_USB_CH9_H
 
+#include 
 #include 
 
-
 /**
  * usb_speed_string() - Returns human readable-name of the speed.
  * @speed: The speed to return human-readable name for.  If it's not
@@ -43,6 +43,15 @@
  */
 extern const char *usb_speed_string(enum usb_device_speed speed);
 
+/**
+ * usb_get_maximum_speed - Get maximum requested speed for a given USB
+ * controller.
+ * @dev: Pointer to the given USB controller device
+ *
+ * The function gets the maximum sp

[linux-yocto] [PATCH 18/25] usb: dwc3: st: prepare the driver for generic usb_get_dr_mode function

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

of_usb_get_dr_mode will be converted into more generic
usb_get_dr_mode function that will take struct device
instead of struct device_node as its parameter.

To make the conversion possible later, waiting for the
platform device for dwc3 to be populated before calling
of_usb_get_dr_mode.

Signed-off-by: Heikki Krogerus 
CC: Giuseppe Cavallaro 
CC: Peter Griffin 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 666472733b8ce20716037c0d866395db54aa8c1d)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/dwc3-st.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
index 4a1a543..8e66449 100644
--- a/drivers/usb/dwc3/dwc3-st.c
+++ b/drivers/usb/dwc3/dwc3-st.c
@@ -199,6 +199,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
struct resource *res;
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node, *child;
+   struct platform_device *child_pdev;
struct regmap *regmap;
int ret;
 
@@ -257,8 +258,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
goto undo_softreset;
}
 
-   dwc3_data->dr_mode = of_usb_get_dr_mode(child);
-
/* Allocate and initialize the core */
ret = of_platform_populate(node, NULL, NULL, dev);
if (ret) {
@@ -266,6 +265,15 @@ static int st_dwc3_probe(struct platform_device *pdev)
goto undo_softreset;
}
 
+   child_pdev = of_find_device_by_node(child);
+   if (!child_pdev) {
+   dev_err(dev, "failed to find dwc3 core device\n");
+   ret = -ENODEV;
+   goto undo_softreset;
+   }
+
+   dwc3_data->dr_mode = of_usb_get_dr_mode(child_pdev->dev.of_node);
+
/*
 * Configure the USB port as device or host according to the static
 * configuration passed from DT.
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 15/25] usb: musb: dsps: control musb speed based on dts setting

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Bin Liu 

Set musb config->maximum_speed based on the dts setting to control musb
speed.

By default musb works in high-speed mode. Adding

maximum-speed = "full-speed";

to dts usb node will force musb to full-speed mode.

Signed-off-by: Bin Liu 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 41932b9b8adc14b5650e8909f66d5bd08619b81c)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/musb/musb_dsps.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index dcac5e7..20e7b7d 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -747,6 +747,19 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
if (!ret && val)
config->multipoint = true;
 
+   config->maximum_speed = of_usb_get_maximum_speed(dn);
+   switch (config->maximum_speed) {
+   case USB_SPEED_LOW:
+   case USB_SPEED_FULL:
+   break;
+   case USB_SPEED_SUPER:
+   dev_warn(dev, "ignore incorrect maximum_speed "
+   "(super-speed) setting in dts");
+   /* fall through */
+   default:
+   config->maximum_speed = USB_SPEED_HIGH;
+   }
+
ret = platform_device_add_data(musb, &pdata, sizeof(pdata));
if (ret) {
dev_err(dev, "failed to add platform_data\n");
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 05/25] usb: dwc3: cache hwparams earlier

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

So they are available when ULPI interface support is added.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 2917e7181589f859ac1e00ba1b3decbbfc2549bb)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index ab198ed..786c66a 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -882,6 +882,7 @@ static int dwc3_probe(struct platform_device *pdev)
| (dwc->is_utmi_l1_suspend << 4);
 
platform_set_drvdata(pdev, dwc);
+   dwc3_cache_hwparams(dwc);
 
ret = dwc3_core_get_phy(dwc);
if (ret)
@@ -899,8 +900,6 @@ static int dwc3_probe(struct platform_device *pdev)
pm_runtime_get_sync(dev);
pm_runtime_forbid(dev);
 
-   dwc3_cache_hwparams(dwc);
-
ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE);
if (ret) {
dev_err(dwc->dev, "failed to allocate event buffers\n");
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 04/25] usb: dwc3: store driver data earlier

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

We need to store it before phys are handled, so we can later
use it in ULPI interface support code.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 6c89cce0476f309689549c74717445e624e0de04)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 8e9518f..ab198ed 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -881,12 +881,13 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->hird_threshold = hird_threshold
| (dwc->is_utmi_l1_suspend << 4);
 
+   platform_set_drvdata(pdev, dwc);
+
ret = dwc3_core_get_phy(dwc);
if (ret)
goto err0;
 
spin_lock_init(&dwc->lock);
-   platform_set_drvdata(pdev, dwc);
 
if (!dev->dma_mask) {
dev->dma_mask = dev->parent->dma_mask;
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 03/25] usb: dwc3: ULPI or UTMI+ select

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

Make selection between ULPI and UTMI+ interfaces possible by
providing definition for the bit in Global USB2 PHY
Configuration Register that controls it.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit f699b94789a64bec66e45c2dc39f06ae1208d852)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 1438b48..92361c0 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -176,6 +176,7 @@
 /* Global USB2 PHY Configuration Register */
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
+#define DWC3_GUSB2PHYCFG_ULPI_UTMI (1 << 4)
 
 /* Global USB2 PHY Vendor Control Register */
 #define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 02/25] usb: dwc3: USB2 PHY register access bits

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

Definitions for Global USB2 PHY Vendor Control Register
bits. We will need them to access ULPI PHY registers later.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit b569968f7667f200b05f57bcf8124ddba9fc)
Signed-off-by: Wan Ahmad Zainie 
---
 drivers/usb/dwc3/core.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 173edd4..1438b48 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -177,6 +177,14 @@
 #define DWC3_GUSB2PHYCFG_PHYSOFTRST(1 << 31)
 #define DWC3_GUSB2PHYCFG_SUSPHY(1 << 6)
 
+/* Global USB2 PHY Vendor Control Register */
+#define DWC3_GUSB2PHYACC_NEWREGREQ (1 << 25)
+#define DWC3_GUSB2PHYACC_BUSY  (1 << 23)
+#define DWC3_GUSB2PHYACC_WRITE (1 << 22)
+#define DWC3_GUSB2PHYACC_ADDR(n)   (n << 16)
+#define DWC3_GUSB2PHYACC_EXTEND_ADDR(n)(n << 8)
+#define DWC3_GUSB2PHYACC_DATA(n)   (n & 0xff)
+
 /* Global USB3 PIPE Control Register */
 #define DWC3_GUSB3PIPECTL_PHYSOFTRST   (1 << 31)
 #define DWC3_GUSB3PIPECTL_U2SSINP3OK   (1 << 29)
-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


[linux-yocto] [PATCH 01/25] usb: add bus type for USB ULPI

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Heikki Krogerus 

UTMI+ Low Pin Interface (ULPI) is a commonly used PHY
interface for USB 2.0. The ULPI specification describes a
standard set of registers which the vendors can extend for
their specific needs. ULPI PHYs provide often functions
such as charger detection and ADP sensing and probing.

There are two major issues that the bus type is meant to
tackle:

Firstly, ULPI registers are accessed from the controller.
The bus provides convenient method for the controller
drivers to share that access with the actual PHY drivers.

Secondly, there are already platforms that assume ULPI PHYs
are runtime detected, such as many Intel Baytrail based
platforms. They do not provide any kind of hardware
description for the ULPI PHYs like separate ACPI device
object that could be used to enumerate a device from.

Signed-off-by: Heikki Krogerus 
Acked-by: David Cohen 
Signed-off-by: Felipe Balbi 
(cherry picked from commit 289fcff4bcdb1dcc0ce8788b7ea0f58a9e4a495f)
Signed-off-by: Wan Ahmad Zainie 
---
 MAINTAINERS   |   7 ++
 drivers/usb/common/Makefile   |   1 +
 drivers/usb/common/ulpi.c | 255 ++
 drivers/usb/core/Kconfig  |  20 +++
 include/linux/mod_devicetable.h   |   6 +
 include/linux/ulpi/driver.h   |  60 +
 include/linux/ulpi/interface.h|  23 
 include/linux/ulpi/regs.h | 130 +++
 include/linux/usb/ulpi.h  | 134 +---
 scripts/mod/devicetable-offsets.c |   4 +
 scripts/mod/file2alias.c  |  13 ++
 11 files changed, 521 insertions(+), 132 deletions(-)
 create mode 100644 drivers/usb/common/ulpi.c
 create mode 100644 include/linux/ulpi/driver.h
 create mode 100644 include/linux/ulpi/interface.h
 create mode 100644 include/linux/ulpi/regs.h

diff --git a/MAINTAINERS b/MAINTAINERS
index feac5ea..632e406 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10506,6 +10506,13 @@ S: Maintained
 F: Documentation/video4linux/zr364xx.txt
 F: drivers/media/usb/zr364xx/
 
+ULPI BUS
+M: Heikki Krogerus 
+L: linux-...@vger.kernel.org
+S: Maintained
+F: drivers/usb/common/ulpi.c
+F: include/linux/ulpi/
+
 USER-MODE LINUX (UML)
 M: Jeff Dike 
 M: Richard Weinberger 
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index ca2f8bd..6bbb3ec 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -7,3 +7,4 @@ usb-common-y  += common.o
 usb-common-$(CONFIG_USB_LED_TRIG) += led.o
 
 obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
+obj-$(CONFIG_USB_ULPI_BUS) += ulpi.o
diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
new file mode 100644
index 000..0e6f968
--- /dev/null
+++ b/drivers/usb/common/ulpi.c
@@ -0,0 +1,255 @@
+/**
+ * ulpi.c - USB ULPI PHY bus
+ *
+ * Copyright (C) 2015 Intel Corporation
+ *
+ * Author: Heikki Krogerus 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* -- 
*/
+
+int ulpi_read(struct ulpi *ulpi, u8 addr)
+{
+   return ulpi->ops->read(ulpi->ops, addr);
+}
+EXPORT_SYMBOL_GPL(ulpi_read);
+
+int ulpi_write(struct ulpi *ulpi, u8 addr, u8 val)
+{
+   return ulpi->ops->write(ulpi->ops, addr, val);
+}
+EXPORT_SYMBOL_GPL(ulpi_write);
+
+/* -- 
*/
+
+static int ulpi_match(struct device *dev, struct device_driver *driver)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(driver);
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+   const struct ulpi_device_id *id;
+
+   for (id = drv->id_table; id->vendor; id++)
+   if (id->vendor == ulpi->id.vendor &&
+   id->product == ulpi->id.product)
+   return 1;
+
+   return 0;
+}
+
+static int ulpi_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+   struct ulpi *ulpi = to_ulpi_dev(dev);
+
+   if (add_uevent_var(env, "MODALIAS=ulpi:v%04xp%04x",
+  ulpi->id.vendor, ulpi->id.product))
+   return -ENOMEM;
+   return 0;
+}
+
+static int ulpi_probe(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   return drv->probe(to_ulpi_dev(dev));
+}
+
+static int ulpi_remove(struct device *dev)
+{
+   struct ulpi_driver *drv = to_ulpi_driver(dev->driver);
+
+   if (drv->remove)
+   drv->remove(to_ulpi_dev(dev));
+
+   return 0;
+}
+
+static struct bus_type ulpi_bus = {
+   .name = "ulpi",
+   .match = ulpi_match,
+   .uevent = ulpi_uevent,
+   .probe = ulpi_probe,
+   .remove = ulpi_remove,
+};
+
+/* --

[linux-yocto] [PATCH 00/25] Backport some USB patches to 4.1

2016-03-10 Thread wan . ahmad . zainie . wan . mohamad
From: Wan Ahmad Zainie 

Hi Bruce.

These patches are the USB backports for Apollo Lake/Broxton,
upstreamed to the mainline Linux kernel by Heikki Krogerus.

The patch usb: dwc3: core: avoid NULL pointer dereference is to
guard against a possible NULL pointer dereference in patch
usb: dwc3: add hsphy_interface property.

The rest of the patches are dependency patches, to ensure the
above patches applied cleanly to the branch.

The patches are targetted for linux-yocto-4.1 on standard/base
branch.

Thank you.

Best regards,
Zainie

Bin Liu (1):
  usb: musb: dsps: control musb speed based on dts setting

Felipe Balbi (1):
  usb: dwc3: core: avoid NULL pointer dereference

Heikki Krogerus (16):
  usb: add bus type for USB ULPI
  usb: dwc3: USB2 PHY register access bits
  usb: dwc3: ULPI or UTMI+ select
  usb: dwc3: store driver data earlier
  usb: dwc3: cache hwparams earlier
  usb: dwc3: soft reset to it's own function
  usb: dwc3: setup phys earlier
  usb: dwc3: add hsphy_interface property
  usb: dwc3: pci: add quirk for Baytrails
  usb: dwc3: add ULPI interface support
  usb: common: of_usb_get_maximum_speed to usb_get_maximum_speed
  usb: dwc3: st: prepare the driver for generic usb_get_dr_mode function
  usb: common: of_usb_get_dr_mode to usb_get_dr_mode
  usb: dwc3: core: convert to unified device property interface
  usb: dwc3: pci: passing forward the ACPI companion
  usb: dwc3: pci: add support for Intel Broxton SOC

John Youn (3):
  usb: dwc3: pci: trivial: Formatting
  usb: dwc3: Add dis_enblslpm_quirk
  usb: dwc3: pci: Set enblslpm quirk for Synopsys platforms

Li Jun (2):
  usb: common: add API to update usb otg capabilities by device tree
  usb: chipidea: set usb otg capabilities

Nikhil Badola (1):
  usb: dwc3: Add frame length adjustment quirk

Phil Edworthy (1):
  usb: renesas_usbhs: Allow an OTG PHY driver to provide VBUS

 Documentation/devicetree/bindings/usb/dwc3.txt |   4 +
 MAINTAINERS|   7 +
 drivers/usb/chipidea/core.c|  19 +-
 drivers/usb/chipidea/udc.c |   7 +-
 drivers/usb/common/Makefile|   1 +
 drivers/usb/common/common.c| 115 +++
 drivers/usb/common/ulpi.c  | 255 +
 drivers/usb/core/Kconfig   |  20 ++
 drivers/usb/dwc2/platform.c|   2 +-
 drivers/usb/dwc3/Kconfig   |   7 +
 drivers/usb/dwc3/Makefile  |   4 +
 drivers/usb/dwc3/core.c| 195 ++-
 drivers/usb/dwc3/core.h|  35 
 drivers/usb/dwc3/dwc3-pci.c|  58 +-
 drivers/usb/dwc3/dwc3-st.c |  12 +-
 drivers/usb/dwc3/platform_data.h   |   5 +
 drivers/usb/dwc3/ulpi.c|  91 +
 drivers/usb/musb/musb_dsps.c   |  15 +-
 drivers/usb/phy/phy-msm-usb.c  |   2 +-
 drivers/usb/phy/phy-tegra-usb.c|   2 +-
 drivers/usb/renesas_usbhs/mod_gadget.c |  62 ++
 include/linux/mod_devicetable.h|   6 +
 include/linux/ulpi/driver.h|  60 ++
 include/linux/ulpi/interface.h |  23 +++
 include/linux/ulpi/regs.h  | 130 +
 include/linux/usb/ch9.h|  11 +-
 include/linux/usb/chipidea.h   |   1 +
 include/linux/usb/of.h |  19 +-
 include/linux/usb/otg.h|   9 +
 include/linux/usb/ulpi.h   | 134 +
 scripts/mod/devicetable-offsets.c  |   4 +
 scripts/mod/file2alias.c   |  13 ++
 32 files changed, 1081 insertions(+), 247 deletions(-)
 create mode 100644 drivers/usb/common/ulpi.c
 create mode 100644 drivers/usb/dwc3/ulpi.c
 create mode 100644 include/linux/ulpi/driver.h
 create mode 100644 include/linux/ulpi/interface.h
 create mode 100644 include/linux/ulpi/regs.h

-- 
1.9.1

-- 
___
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto


Re: [linux-yocto] [PATCH] gpio-pca953x: add "drive" property

2016-03-10 Thread Bruce Ashfield

On 2016-03-10 2:58 PM, Saul Wold wrote:

From: Jussi Laako 

Galileo gen 2 has support for setting GPIO modes. Expose these
properties through the GPIO sysfs interface. This approach is bit hacky,
since it changes the interface semantics.

The original patch was by Josef Ahmad  and
made on top of kernel 3.8.


merged, and I just sent the SRCREV update.

Bruce



Signed-off-by: Ismo Puustinen 
Signed-off-by: Jussi Laako 
Signed-off-by: Saul Wold 
---
  drivers/gpio/gpio-pca953x.c   | 57 +++
  drivers/gpio/gpiolib-sysfs.c  | 78 +++
  drivers/gpio/gpiolib.c| 18 ++
  drivers/gpio/gpiolib.h|  4 +++
  include/asm-generic/gpio.h|  5 +++
  include/linux/gpio.h  | 10 ++
  include/linux/gpio/consumer.h | 11 ++
  include/linux/gpio/driver.h   |  2 ++
  8 files changed, 178 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index f23a4b4..f99706f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -39,6 +39,9 @@
  #define PCA957X_MSK   6
  #define PCA957X_INTS  7

+#define PCA953X_PUPD_EN35
+#define PCA953X_PUPD_SEL   36
+
  #define PCA_GPIO_MASK 0x00FF
  #define PCA_INT   0x0100
  #define PCA953X_TYPE  0x1000
@@ -375,6 +378,43 @@ exit:
mutex_unlock(&chip->i2c_lock);
  }

+static int pca953x_gpio_set_drive(struct gpio_chip *gc,
+unsigned off, unsigned mode)
+{
+   struct pca953x_chip *chip;
+   int ret = 0;
+   int val;
+
+   chip = container_of(gc, struct pca953x_chip, gpio_chip);
+
+   if (chip->chip_type != PCA953X_TYPE)
+   return -EINVAL;
+
+   mutex_lock(&chip->i2c_lock);
+
+   switch (mode) {
+   case GPIOF_DRIVE_PULLUP:
+   ret = pca953x_write_single(chip, PCA953X_PUPD_EN, 1, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 1, 
off);
+   break;
+   case GPIOF_DRIVE_PULLDOWN:
+   ret = pca953x_write_single(chip, PCA953X_PUPD_EN, 1, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 0, 
off);
+   break;
+   case GPIOF_DRIVE_STRONG:
+   case GPIOF_DRIVE_HIZ:
+   ret = pca953x_read_single(chip, PCA953X_PUPD_EN, &val, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_EN, 0, 
off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 
val, off);
+   break;
+   default:
+   ret = -EINVAL;
+   }
+
+   mutex_unlock(&chip->i2c_lock);
+   return ret;
+}
+
  static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
  {
struct gpio_chip *gc;
@@ -393,6 +433,9 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, 
int gpios)
gc->dev = &chip->client->dev;
gc->owner = THIS_MODULE;
gc->names = chip->names;
+
+   if (chip->chip_type == PCA953X_TYPE)
+   gc->set_drive = pca953x_gpio_set_drive;
  }

  #ifdef CONFIG_GPIO_PCA953X_IRQ
@@ -552,7 +595,7 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
  }

  static int pca953x_irq_setup(struct pca953x_chip *chip,
-int irq_base)
+int irq_base)
  {
struct i2c_client *client = chip->client;
int ret, i, offset = 0;
@@ -595,10 +638,10 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
}

ret =  gpiochip_irqchip_add(&chip->gpio_chip,
-   &pca953x_irq_chip,
-   irq_base,
-   handle_simple_irq,
-   IRQ_TYPE_NONE);
+   &pca953x_irq_chip,
+   irq_base,
+   handle_simple_irq,
+   IRQ_TYPE_NONE);
if (ret) {
dev_err(&client->dev,
"could not connect irqchip to gpiochip\n");
@@ -615,7 +658,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,

  #else /* CONFIG_GPIO_PCA953X_IRQ */
  static int pca953x_irq_setup(struct pca953x_chip *chip,
-int irq_base)
+int irq_base)
  {
struct i2c_client *client = chip->client;

@@ -636,7 +679,7 @@ static int device_pca953x_init(struct pca953x_chip *chip, 
u32 invert)
goto out;

ret = pca953x_read_regs(chip, PCA953X_DIRECTION,
-  chip->reg_direction);
+  chip->reg_direction);
if (ret)
goto out;

diff --git a/drivers/gpio/gpiolib

[linux-yocto] [PATCH] gpio-pca953x: add "drive" property

2016-03-10 Thread Saul Wold
From: Jussi Laako 

Galileo gen 2 has support for setting GPIO modes. Expose these
properties through the GPIO sysfs interface. This approach is bit hacky,
since it changes the interface semantics.

The original patch was by Josef Ahmad  and
made on top of kernel 3.8.

Signed-off-by: Ismo Puustinen 
Signed-off-by: Jussi Laako 
Signed-off-by: Saul Wold 
---
 drivers/gpio/gpio-pca953x.c   | 57 +++
 drivers/gpio/gpiolib-sysfs.c  | 78 +++
 drivers/gpio/gpiolib.c| 18 ++
 drivers/gpio/gpiolib.h|  4 +++
 include/asm-generic/gpio.h|  5 +++
 include/linux/gpio.h  | 10 ++
 include/linux/gpio/consumer.h | 11 ++
 include/linux/gpio/driver.h   |  2 ++
 8 files changed, 178 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index f23a4b4..f99706f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -39,6 +39,9 @@
 #define PCA957X_MSK6
 #define PCA957X_INTS   7
 
+#define PCA953X_PUPD_EN35
+#define PCA953X_PUPD_SEL   36
+
 #define PCA_GPIO_MASK  0x00FF
 #define PCA_INT0x0100
 #define PCA953X_TYPE   0x1000
@@ -375,6 +378,43 @@ exit:
mutex_unlock(&chip->i2c_lock);
 }
 
+static int pca953x_gpio_set_drive(struct gpio_chip *gc,
+unsigned off, unsigned mode)
+{
+   struct pca953x_chip *chip;
+   int ret = 0;
+   int val;
+
+   chip = container_of(gc, struct pca953x_chip, gpio_chip);
+
+   if (chip->chip_type != PCA953X_TYPE)
+   return -EINVAL;
+
+   mutex_lock(&chip->i2c_lock);
+
+   switch (mode) {
+   case GPIOF_DRIVE_PULLUP:
+   ret = pca953x_write_single(chip, PCA953X_PUPD_EN, 1, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 1, 
off);
+   break;
+   case GPIOF_DRIVE_PULLDOWN:
+   ret = pca953x_write_single(chip, PCA953X_PUPD_EN, 1, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 0, 
off);
+   break;
+   case GPIOF_DRIVE_STRONG:
+   case GPIOF_DRIVE_HIZ:
+   ret = pca953x_read_single(chip, PCA953X_PUPD_EN, &val, off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_EN, 0, 
off) ||
+   pca953x_write_single(chip, PCA953X_PUPD_SEL, 
val, off);
+   break;
+   default:
+   ret = -EINVAL;
+   }
+
+   mutex_unlock(&chip->i2c_lock);
+   return ret;
+}
+
 static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
 {
struct gpio_chip *gc;
@@ -393,6 +433,9 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, 
int gpios)
gc->dev = &chip->client->dev;
gc->owner = THIS_MODULE;
gc->names = chip->names;
+
+   if (chip->chip_type == PCA953X_TYPE)
+   gc->set_drive = pca953x_gpio_set_drive;
 }
 
 #ifdef CONFIG_GPIO_PCA953X_IRQ
@@ -552,7 +595,7 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 }
 
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-int irq_base)
+int irq_base)
 {
struct i2c_client *client = chip->client;
int ret, i, offset = 0;
@@ -595,10 +638,10 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
}
 
ret =  gpiochip_irqchip_add(&chip->gpio_chip,
-   &pca953x_irq_chip,
-   irq_base,
-   handle_simple_irq,
-   IRQ_TYPE_NONE);
+   &pca953x_irq_chip,
+   irq_base,
+   handle_simple_irq,
+   IRQ_TYPE_NONE);
if (ret) {
dev_err(&client->dev,
"could not connect irqchip to gpiochip\n");
@@ -615,7 +658,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-int irq_base)
+int irq_base)
 {
struct i2c_client *client = chip->client;
 
@@ -636,7 +679,7 @@ static int device_pca953x_init(struct pca953x_chip *chip, 
u32 invert)
goto out;
 
ret = pca953x_read_regs(chip, PCA953X_DIRECTION,
-  chip->reg_direction);
+  chip->reg_direction);
if (ret)
goto out;
 
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index b57ed8e..b60e477 100644
--- a/drivers/gpio/gpiolib-sysfs.c
++