[PATCH v3 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-22 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This series intend to fix driver, which was broken for a while.
It is used to create peripheral role device, which in coordination
with phy-usb-msm driver could provide USB2.0 gadget support for
Qualcomm targets.

Changes since version 2.

 - Rename devicetree description file to ci-hdrc-qcom.txt to be in-line
   with Freescale and Zevio naming scheme
 - Use better name for usb-phy phandle.
 - Make of_device_id structure const

[1] https://lkml.org/lkml/2014/2/18/209

Ivan T. Ivanov (3):
  usb: chipidea: msm: Add device tree binding information
  usb: chipidea: msm: Add device tree support
  usb: chipidea: msm: Initialize offset of the capability registers

 .../devicetree/bindings/usb/ci-hdrc-qcom.txt   | 17 +++
 drivers/usb/chipidea/ci_hdrc_msm.c | 24 +-
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/3] usb: chipidea: msm: Add device tree binding information

2014-04-22 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Document device tree binding information as required by
the Qualcomm USB controller.

Signed-off-by: Ivan T. Ivanov 
---
 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt 
b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt
new file mode 100644
index 000..7221072
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt
@@ -0,0 +1,17 @@
+Qualcomm CI13xxx (Chipidea) USB controllers
+
+Required properties:
+- compatible:   should contain "qcom,ci-hdrc"
+- reg:  offset and length of the register set in the memory map
+- interrupts:   interrupt-specifier for the controller interrupt.
+- usb-phy:  phandle for the PHY device
+- dr_mode:  Sould be "peripheral"
+
+Examples:
+   gadget@f9a55000 {
+   compatible = "qcom,ci-hdrc";
+   reg = <0xf9a55000 0x400>;
+   dr_mode = "peripheral";
+   interrupts = <0 134 0>;
+   usb-phy = <&usbphy0>;
+   };
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/3] usb: chipidea: msm: Add device tree support

2014-04-22 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allows controller to be specified via device tree.
Pass PHY phandle specified in DT to core driver.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 2d51d85..736aeb2 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -57,9 +57,21 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
 static int ci_hdrc_msm_probe(struct platform_device *pdev)
 {
struct platform_device *plat_ci;
+   struct usb_phy *phy;

dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n");

+   /*
+* OTG(PHY) driver takes care of PHY initialization, clock management,
+* powering up VBUS, mapping of registers address space and power
+* management.
+*/
+   phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0);
+   if (IS_ERR(phy))
+   return PTR_ERR(phy);
+
+   ci_hdrc_msm_platdata.phy = phy;
+
plat_ci = ci_hdrc_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
&ci_hdrc_msm_platdata);
@@ -86,10 +98,19 @@ static int ci_hdrc_msm_remove(struct platform_device *pdev)
return 0;
 }

+static const struct of_device_id msm_ci_dt_match[] = {
+   { .compatible = "qcom,ci-hdrc", },
+   { }
+};
+MODULE_DEVICE_TABLE(of, msm_ci_dt_match);
+
 static struct platform_driver ci_hdrc_msm_driver = {
.probe = ci_hdrc_msm_probe,
.remove = ci_hdrc_msm_remove,
-   .driver = { .name = "msm_hsusb", },
+   .driver = {
+   .name = "msm_hsusb",
+   .of_match_table = msm_ci_dt_match,
+   },
 };

 module_platform_driver(ci_hdrc_msm_driver);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/3] usb: chipidea: msm: Initialize offset of the capability registers

2014-04-22 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Since commit 62bb84e (usb: gadget: ci13xxx: convert to platform device)
start address of the capability registers is not passed correctly to
udc_probe(). Fix this.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 736aeb2..d72b9d2 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -47,6 +47,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, 
unsigned event)

 static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
.name   = "ci_hdrc_msm",
+   .capoffset  = DEF_CAPOFFSET,
.flags  = CI_HDRC_REGS_SHARED |
  CI_HDRC_REQUIRE_TRANSCEIVER |
  CI_HDRC_DISABLE_STREAMING,
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 01/19] usb: phy: msm: Make driver selectable on ARCH_QCOM

2014-04-22 Thread Ivan T. Ivanov

Hi, 

On Tue, 2014-04-22 at 09:57 -0500, Felipe Balbi wrote:
> On Tue, Apr 22, 2014 at 12:20:20PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" 
> > 
> > Controller could be found on APQ and MSM platforms,
> > make configuration description more generic.
> > 
> > Signed-off-by: Ivan T. Ivanov 
> > ---
> >  drivers/usb/phy/Kconfig | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> > index 416e0c8..0c668a3 100644
> > --- a/drivers/usb/phy/Kconfig
> > +++ b/drivers/usb/phy/Kconfig
> > @@ -171,11 +171,11 @@ config USB_ISP1301
> >   module will be called phy-isp1301.
> > 
> >  config USB_MSM_OTG
> > -   tristate "OTG support for Qualcomm on-chip USB controller"
> > -   depends on (USB || USB_GADGET) && ARCH_MSM
> > +   tristate "Qualcomm on-chip USB OTG controller support"
> > +   depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
> 
> I would actually drop USB || USB_GADGET dependency here just make it
> easier to enable the driver on Kconfig, other you have to enable
> USB_SUPPORT, then enable USB, go back one menu level, go down to PHY
> menu, and choose this driver.
> 

Because phy directory already depends on USB_SUPPORT?

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 03/19] usb: phy: msm: Move global regulators variables to driver state

2014-04-22 Thread Ivan T. Ivanov
On Tue, 2014-04-22 at 09:57 -0500, Felipe Balbi wrote:
> On Tue, Apr 22, 2014 at 12:20:22PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" 
> 
> #define ENOLOGENOCOMMIT
> 
> return -ENOLOG;
> 

#if SIMPLE_CHANGE
#define ENOLOG  0
#endif

Will fix it :-)

Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 1/3] usb: chipidea: msm: Add device tree binding information

2014-04-22 Thread Ivan T. Ivanov
On Tue, 2014-04-22 at 16:07 +0100, Srinivas Kandagatla wrote:
> 
> On 22/04/14 10:43, Ivan T. Ivanov wrote:
> > +- interrupts:   interrupt-specifier for the controller interrupt.
> > +- usb-phy:  phandle for the PHY device
> > +- dr_mode:  Sould be "peripheral"
> s/Sould/Should/
> > +

Thanks. will fix it.

Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 04/19] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-22 Thread Ivan T. Ivanov
On Tue, 2014-04-22 at 16:07 +0100, Srinivas Kandagatla wrote:
> 
> On 22/04/14 10:20, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" 
> >
> > Move memory, regulators, clocks and irq allocation to
> > devm_* variants. Properly check for valid clk handles.
> >
> >
> > -module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
> > +module_platform_driver(msm_otg_driver);
> 
> This change doesn’t match the log.

Right, I have erroneously assumed that devm_ functions are those 
which returns EPROBE_DEFER.

Will make it separate change.

Thanks,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 06/19] usb: phy: msm: Fix checkpatch.pl warnings

2014-04-22 Thread Ivan T. Ivanov

On Tue, 2014-04-22 at 16:30 +0100, Srinivas Kandagatla wrote:
> 
> On 22/04/14 10:20, Ivan T. Ivanov wrote:
> > @@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
> > init)
> > ret = regulator_set_voltage(motg->vddcx, 0,
> > USB_PHY_VDD_DIG_VOL_MAX);
> > if (ret)
> > -   dev_err(motg->phy.dev, "unable to set the voltage "
> > -   "for hsusb vddcx\n");
> > +   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
> 
> 
> > @@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg 
> > *motg, int on)
> > ret = regulator_set_optimum_mode(motg->v1p8,
> > USB_PHY_1P8_HPM_LOAD);
> > if (ret < 0) {
> > -   pr_err("%s: Unable to set HPM of the regulator "
> > -   "HSUSB_1p8\n", __func__);
> > +   pr_err("Could not set HPM for v1p8\n");
> > return ret;
> > }
> 
> 
> > @@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, 
> > int high)
> >
> > ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
> > if (ret) {
> > -   pr_err("%s: unable to set the voltage for regulator "
> > -   "HSUSB_VDDCX\n", __func__);
> > +   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
> > return ret;
> > }
> >
> 
> 
> I see some of pr_err not moved to dev_err?, while others have been moved.

Right, intention was to just shorten messages to fit one line, to make 
checkpatch.pl happy.

Thanks, 
Ivan

> Also noticed that the error messages are changed as part of this fix. 
> IMHO, changing an error message would have a side-effects on logging 
> tools, anyway Am not sure if its true in this case.
> 
> Thanks,
> srini
> --

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 11/19] usb: phy: msm: Add device tree support and binding information

2014-04-23 Thread Ivan T. Ivanov

Hi Srini,

On Tue, 2014-04-22 at 17:05 +0100, Srinivas Kandagatla wrote:
> Hi Ivan,
> 
> On 22/04/14 10:20, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov"
> >
> > Allows MSM OTG controller to be specified via device tree.
> >
> > Signed-off-by: Ivan T. Ivanov
> > ---
> >   .../devicetree/bindings/usb/msm-hsusb.txt  |  67 +
> >   drivers/usb/phy/phy-msm-usb.c  | 108 
> > +
> >   include/linux/usb/msm_hsusb.h  |   6 +-
> >   3 files changed, 159 insertions(+), 22 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
> > b/Documentation/devicetree/bindings/usb/msm-hsusb.txt



> > +Optional properties:
> > +- dr_mode:  One of "host", "peripheral" or "otg". Defaults to "otg"
> > +
> > +- qcom,phy-init-sequence: PHY configuration sequence values. This is 
> > related to Device
> > +Mode Eye Diagram test. Start address at which these values 
> > will be
> > +written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is 
> > reserved as
> > +"do not overwrite default value at this address".
> > +For example: qcom,phy-init-sequence = < -1 0x63 >;
> > +Will update only value at address ULPI_EXT_VENDOR_SPECIFIC 
> > + 1.
> 
> I don’t think DT maintainers will like the sound of it.
> Sorry If I missed some old discussion on this.
> But I don't this this is the correct way.
> 
> DT should describe the system hardware layout rather than initialization 
> sequence.
> 
> The initialization code with magic values should go directly into the 
> driver and depending on the dt-compatible driver should select the right 
> sequence.

While I agree in general, this sequence is board depended. It is related
to Eye diagrams tests.

> 
> /phy-msm-usb.c
> > +++ b/drivers/usb/phy/phy-msm-usb.c
> > @@ -30,9 +30,12 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> > +#include 
> >
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -217,16 +220,16 @@ static struct usb_phy_io_ops msm_otg_io_ops = {
> >   static void ulpi_init(struct msm_otg *motg)
> >   {
> > struct msm_otg_platform_data *pdata = motg->pdata;
> > -   int *seq = pdata->phy_init_seq;
> > +   int *seq = pdata->phy_init_seq, idx;
> > +   u32 addr = ULPI_EXT_VENDOR_SPECIFIC;
> >
> > -   if (!seq)
> > -   return;
> > +   for (idx = 0; idx < pdata->phy_init_sz; idx++) {
> > +   if (seq[idx] == -1)
> > +   continue;
> >
> > -   while (seq[0] >= 0) {
> > dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
> > -   seq[0], seq[1]);
> > -   ulpi_write(&motg->phy, seq[0], seq[1]);
> > -   seq += 2;
> > +   seq[idx], addr + idx);
> > +   ulpi_write(&motg->phy, seq[idx], addr + idx);
> > }
> >   }
> 
> How is above change related to device trees?

It is related to above "qcom,phy-init-sequence" parameter.

> >
> > @@ -1343,25 +1346,87 @@ static void msm_otg_debugfs_cleanup(void)
> > debugfs_remove(msm_otg_dbg_root);
> >   }
> >
> > +static struct of_device_id msm_otg_dt_match[] = {
> > +   {
> > +   .compatible = "qcom,usb-otg-ci",
> > +   .data = (void *) CI_45NM_INTEGRATED_PHY
> > +   }, {
> > +   .compatible = "qcom,usb-otg-snps",
> > +   .data = (void *) SNPS_28NM_INTEGRATED_PHY
> > +   }, {}
> > +};
> > +
> > +static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg 
> > *motg)
> > +{
> > +   struct msm_otg_platform_data *pdata;
> > +   const struct of_device_id *id;
> > +   struct device_node *node = pdev->dev.of_node;
> > +   struct property *prop;
> > +   int len, ret;
> > +   u32 val;
> > +
> > +   pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> > +   if (!pdata)
> > +   return -ENOMEM;
> > +
> > +   motg->pdata = pdata;
> > +
> > +   id = of_match_device(msm_otg_dt_match, &pdev->dev);
> > +   pdata->phy_type = (int) id->data;
> > +
> > +   pdata->mode = of_usb_get_dr_mode(node);
> > 

Re: [PATCH v6 01/19] usb: phy: msm: Make driver selectable on ARCH_QCOM

2014-04-23 Thread Ivan T. Ivanov
On Tue, 2014-04-22 at 10:24 -0500, Felipe Balbi wrote:
> On Tue, Apr 22, 2014 at 06:16:35PM +0300, Ivan T. Ivanov wrote:
> > 
> > Hi, 
> > 
> > On Tue, 2014-04-22 at 09:57 -0500, Felipe Balbi wrote:
> > > On Tue, Apr 22, 2014 at 12:20:20PM +0300, Ivan T. Ivanov wrote:
> > > > From: "Ivan T. Ivanov" 
> > > > 
> > > > Controller could be found on APQ and MSM platforms,
> > > > make configuration description more generic.
> > > > 
> > > > Signed-off-by: Ivan T. Ivanov 
> > > > ---
> > > >  drivers/usb/phy/Kconfig | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> > > > index 416e0c8..0c668a3 100644
> > > > --- a/drivers/usb/phy/Kconfig
> > > > +++ b/drivers/usb/phy/Kconfig
> > > > @@ -171,11 +171,11 @@ config USB_ISP1301
> > > >   module will be called phy-isp1301.
> > > > 
> > > >  config USB_MSM_OTG
> > > > -   tristate "OTG support for Qualcomm on-chip USB controller"
> > > > -   depends on (USB || USB_GADGET) && ARCH_MSM
> > > > +   tristate "Qualcomm on-chip USB OTG controller support"
> > > > +   depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
> > > 
> > > I would actually drop USB || USB_GADGET dependency here just make it
> > > easier to enable the driver on Kconfig, other you have to enable
> > > USB_SUPPORT, then enable USB, go back one menu level, go down to PHY
> > > menu, and choose this driver.
> > > 
> > 
> > Because phy directory already depends on USB_SUPPORT?
> 
> right

Build fails if USB and USB_GADGET are not selected. 
of_usb_get_dr_mode is part of USB_COMMON. 

...

if USB_SUPPORT

config USB_COMMON
tristate
default y
depends on USB || USB_GADGET

...

of_usb_get_dr_mode() is no part of this patch, but should I remove
dependency here and add it several patches later?

Regards,
Ivan


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/3] usb: chipidea: msm: Add device tree support

2014-04-23 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allows controller to be specified via device tree.
Pass PHY phandle specified in DT to core driver.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 23 ++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 2d51d85..736aeb2 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -57,9 +57,21 @@ static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
 static int ci_hdrc_msm_probe(struct platform_device *pdev)
 {
struct platform_device *plat_ci;
+   struct usb_phy *phy;

dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n");

+   /*
+* OTG(PHY) driver takes care of PHY initialization, clock management,
+* powering up VBUS, mapping of registers address space and power
+* management.
+*/
+   phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0);
+   if (IS_ERR(phy))
+   return PTR_ERR(phy);
+
+   ci_hdrc_msm_platdata.phy = phy;
+
plat_ci = ci_hdrc_add_device(&pdev->dev,
pdev->resource, pdev->num_resources,
&ci_hdrc_msm_platdata);
@@ -86,10 +98,19 @@ static int ci_hdrc_msm_remove(struct platform_device *pdev)
return 0;
 }

+static const struct of_device_id msm_ci_dt_match[] = {
+   { .compatible = "qcom,ci-hdrc", },
+   { }
+};
+MODULE_DEVICE_TABLE(of, msm_ci_dt_match);
+
 static struct platform_driver ci_hdrc_msm_driver = {
.probe = ci_hdrc_msm_probe,
.remove = ci_hdrc_msm_remove,
-   .driver = { .name = "msm_hsusb", },
+   .driver = {
+   .name = "msm_hsusb",
+   .of_match_table = msm_ci_dt_match,
+   },
 };

 module_platform_driver(ci_hdrc_msm_driver);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/3] usb: chipidea: msm: Add device tree binding information

2014-04-23 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Document device tree binding information as required by
the Qualcomm USB controller.

Signed-off-by: Ivan T. Ivanov 
---
 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt 
b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt
new file mode 100644
index 000..f2899b5
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt
@@ -0,0 +1,17 @@
+Qualcomm CI13xxx (Chipidea) USB controllers
+
+Required properties:
+- compatible:   should contain "qcom,ci-hdrc"
+- reg:  offset and length of the register set in the memory map
+- interrupts:   interrupt-specifier for the controller interrupt.
+- usb-phy:  phandle for the PHY device
+- dr_mode:  Should be "peripheral"
+
+Examples:
+   gadget@f9a55000 {
+   compatible = "qcom,ci-hdrc";
+   reg = <0xf9a55000 0x400>;
+   dr_mode = "peripheral";
+   interrupts = <0 134 0>;
+   usb-phy = <&usbphy0>;
+   };
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/3] usb: chipidea: msm: Initialize offset of the capability registers

2014-04-23 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Since commit 62bb84e (usb: gadget: ci13xxx: convert to platform device)
start address of the capability registers is not passed correctly to
udc_probe(). Fix this.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/chipidea/ci_hdrc_msm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c 
b/drivers/usb/chipidea/ci_hdrc_msm.c
index 736aeb2..d72b9d2 100644
--- a/drivers/usb/chipidea/ci_hdrc_msm.c
+++ b/drivers/usb/chipidea/ci_hdrc_msm.c
@@ -47,6 +47,7 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, 
unsigned event)

 static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = {
.name   = "ci_hdrc_msm",
+   .capoffset  = DEF_CAPOFFSET,
.flags  = CI_HDRC_REGS_SHARED |
  CI_HDRC_REQUIRE_TRANSCEIVER |
  CI_HDRC_DISABLE_STREAMING,
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-23 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This series intend to fix driver, which was broken for a while.
It is used to create peripheral role device, which in coordination
with phy-usb-msm driver could provide USB2.0 gadget support for
Qualcomm targets.

Changes since version 3.

 - Fix typo in devicetree description file.

Previews version can be found here:

https://lkml.org/lkml/2014/4/22/195

Ivan T. Ivanov (3):
  usb: chipidea: msm: Add device tree binding information
  usb: chipidea: msm: Add device tree support
  usb: chipidea: msm: Initialize offset of the capability registers

 .../devicetree/bindings/usb/ci-hdrc-qcom.txt   | 17 +++
 drivers/usb/chipidea/ci_hdrc_msm.c | 24 +-
 2 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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] mfd: pm8x41: add support for Qualcomm 8x41 PMICs

2014-04-23 Thread Ivan T. Ivanov

Hi,

On Tue, 2014-04-22 at 17:31 -0700, Courtney Cavin wrote:
> From: Josh Cartwright 
> 
> The Qualcomm 8941 and 8841 PMICs are components used with the Snapdragon
> 800 series SoC family.  This driver exists largely as a glue mfd component,
> it exists to be an owner of an SPMI regmap for children devices
> described in device tree.
> 

Thanks. This is exactly what I have planed to do :-)

> Signed-off-by: Josh Cartwright 
> Signed-off-by: Courtney Cavin 
> ---
>  drivers/mfd/Kconfig  | 13 +++
>  drivers/mfd/Makefile |  1 +
>  drivers/mfd/pm8x41.c | 63 
> 
>  3 files changed, 77 insertions(+)
>  create mode 100644 drivers/mfd/pm8x41.c
> 



> +
> +static int pm8x41_probe(struct spmi_device *sdev)
> +{
> + struct regmap *regmap;
> +
> + regmap = devm_regmap_init_spmi_ext(sdev, &pm8x41_regmap_config);
> + if (IS_ERR(regmap)) {
> + dev_dbg(&sdev->dev, "regmap creation failed.\n");
> + return PTR_ERR(regmap);
> + }
> +
> + return of_platform_populate(sdev->dev.of_node, NULL, NULL, &sdev->dev);

I think that this will not going to work. For example in this particular
case, both controllers have "qcom,qpnp-revid" peripheral which is
located at offset 0x100.

And the result is:

[0.963944] sysfs: cannot create duplicate filename 
'/bus/platform/devices/100.revid'

DT looks like this:

spmi {
compatible = "qcom,spmi-pmic-arb";
reg-names = "core", "intr", "cnfg";
reg = <0xfc4cf000 0x1000>,
  <0xfc4cb000 0x1000>,
  <0xfc4ca000 0x1000>;

interrupt-names = "periph_irq";
interrupts = <0 190 0>;

qcom,ee = <0>;
qcom,channel = <0>;

#address-cells = <2>;
#size-cells = <0>;

interrupt-controller;
#interrupt-cells = <4>;

pm8941@0 {
compatible = "qcom,pm8941";
reg = <0x0 SPMI_USID>;

#address-cells = <1>;
#size-cells = <0>;

revid@100 {
compatible = "qcom,qpnp-revid";
reg = <0x100 0x100>;
};
};

pm8841@4 {
compatible = "qcom,pm8941";
reg = <0x4 SPMI_USID>;

#address-cells = <1>;
#size-cells = <0>;

revid@100 {
compatible = "qcom,qpnp-revid";
reg = <0x100 0x100>;
};
};
};

Any suggestions?

Thanks, 
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 15/19] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-23 Thread Ivan T. Ivanov
Hi,

On Tue, 2014-04-22 at 17:09 +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 22-04-2014 13:20, Ivan T. Ivanov wrote:
> 
> > From: Tim Bird 
> 
> > Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB
> > controller.  This is a standard chipidea PORTSC definition, where
> > a PHY_TYPE of 10b (<<30) is ULPI and 11b (<<30) is SERIAL.
> > Fix the definitions and use them correctly in the driver code.
> 
> > Signed-off-by: Tim Bird 
> > ---
> >   drivers/usb/phy/phy-msm-usb.c| 8 +---
> >   include/linux/usb/msm_hsusb_hw.h | 5 +++--
> >   2 files changed, 8 insertions(+), 5 deletions(-)
> 
> > diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> > index dababf9..e83d13a 100644
> > --- a/drivers/usb/phy/phy-msm-usb.c
> > +++ b/drivers/usb/phy/phy-msm-usb.c
> > @@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg)
> > if (motg->phy_number)
> > writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
> >
> > +   /* put transciever in serial mode as part of reset */
> 
> s/transciever/transceiver/
> 
> [...]
> 
> > diff --git a/include/linux/usb/msm_hsusb_hw.h 
> > b/include/linux/usb/msm_hsusb_hw.h
> > index 575c743..98d3dd8 100644
> > --- a/include/linux/usb/msm_hsusb_hw.h
> > +++ b/include/linux/usb/msm_hsusb_hw.h
> > @@ -31,8 +31,9 @@
> >   #define USB_USBINTR  (MSM_USB_BASE + 0x0148)
> >
> >   #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
> > -#define PORTSC_PTS_MASK (3 << 30)
> > -#define PORTSC_PTS_ULPI (3 << 30)
> > +#define PORTSC_PTS_MASK(3 << 30)
> > +#define PORTSC_PTS_ULPI(2 << 30)
> > +#define PORTSC_PTS_SERIAL  (3 << 30)
> 
> Please use tabs, not spaces here.

Thanks, will fix and resend.

Ivan

> 
> WBR, Sergei
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 15/19] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-23 Thread Ivan T. Ivanov
On Wed, 2014-04-23 at 16:24 +0300, Ivan T. Ivanov wrote:

> > > --- a/include/linux/usb/msm_hsusb_hw.h
> > > +++ b/include/linux/usb/msm_hsusb_hw.h
> > > @@ -31,8 +31,9 @@
> > >   #define USB_USBINTR  (MSM_USB_BASE + 0x0148)
> > >
> > >   #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
> > > -#define PORTSC_PTS_MASK (3 << 30)
> > > -#define PORTSC_PTS_ULPI (3 << 30)
> > > +#define PORTSC_PTS_MASK(3 << 30)
> > > +#define PORTSC_PTS_ULPI(2 << 30)
> > > +#define PORTSC_PTS_SERIAL  (3 << 30)
> > 
> > Please use tabs, not spaces here.
> 
> Thanks, will fix and resend.

I answered too quickly. File contain tabs and spaces for
indentation of definitions. Should I still use tabs here?

Regards,
Ivan

> 
> Ivan
> 
> > 
> > WBR, Sergei
> > 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 15/19] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-23 Thread Ivan T. Ivanov
On Wed, 2014-04-23 at 17:45 +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 23-04-2014 17:35, Ivan T. Ivanov wrote:
> 
> >>>> --- a/include/linux/usb/msm_hsusb_hw.h
> >>>> +++ b/include/linux/usb/msm_hsusb_hw.h
> >>>> @@ -31,8 +31,9 @@
> >>>>#define USB_USBINTR  (MSM_USB_BASE + 0x0148)
> >>>>
> >>>>#define PORTSC_PHCD(1 << 23) /* phy suspend mode */
> >>>> -#define PORTSC_PTS_MASK (3 << 30)
> >>>> -#define PORTSC_PTS_ULPI (3 << 30)
> >>>> +#define PORTSC_PTS_MASK(3 << 30)
> >>>> +#define PORTSC_PTS_ULPI(2 << 30)
> >>>> +#define PORTSC_PTS_SERIAL  (3 << 30)
> 
> >>>  Please use tabs, not spaces here.
> 
> >> Thanks, will fix and resend.
> 
> > I answered too quickly. File contain tabs and spaces for
> > indentation of definitions.
> 
> You mean tabs and spaces on one line? Or sometimes tabs, sometimes spaces?

In this particular hunk, original code uses spaces.

Ivan

> 
> > Should I still use tabs here?
> 
> If they are already used, why not?
> 
> > Regards,
> > Ivan
> 
> WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 15/19] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-23 Thread Ivan T. Ivanov
On Wed, 2014-04-23 at 18:09 +0400, Sergei Shtylyov wrote:
> On 23-04-2014 17:53, Ivan T. Ivanov wrote:
> 
> >>>>>> --- a/include/linux/usb/msm_hsusb_hw.h
> >>>>>> +++ b/include/linux/usb/msm_hsusb_hw.h
> >>>>>> @@ -31,8 +31,9 @@
> >>>>>> #define USB_USBINTR  (MSM_USB_BASE + 0x0148)
> >>>>>>
> >>>>>> #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
> >>>>>> -#define PORTSC_PTS_MASK (3 << 30)
> >>>>>> -#define PORTSC_PTS_ULPI (3 << 30)
> >>>>>> +#define PORTSC_PTS_MASK(3 << 30)
> >>>>>> +#define PORTSC_PTS_ULPI(2 << 30)
> >>>>>> +#define PORTSC_PTS_SERIAL  (3 << 30)
> 
> >>>>>   Please use tabs, not spaces here.
> 
> >>>> Thanks, will fix and resend.
> 
> >>> I answered too quickly. File contain tabs and spaces for
> >>> indentation of definitions.
> 
> >>  You mean tabs and spaces on one line? Or sometimes tabs, sometimes 
> >> spaces?
> 
> > In this particular hunk, original code uses spaces.
> 
> That I saw. 8-)
> I was asking about this file in general.

Legacy :-) Could this be future cleanup? 

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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] mfd: pm8x41: add support for Qualcomm 8x41 PMICs

2014-04-23 Thread Ivan T. Ivanov

On Wed, 2014-04-23 at 11:16 -0700, Courtney Cavin wrote:
> On Wed, Apr 23, 2014 at 03:19:28PM +0200, Ivan T. Ivanov wrote:
> > 
> > Hi,
> > 
> > On Tue, 2014-04-22 at 17:31 -0700, Courtney Cavin wrote:
> > > From: Josh Cartwright 
> > > 
> > > The Qualcomm 8941 and 8841 PMICs are components used with the Snapdragon
> > > 800 series SoC family.  This driver exists largely as a glue mfd 
> > > component,
> > > it exists to be an owner of an SPMI regmap for children devices
> > > described in device tree.
> > > 
> > 
> > Thanks. This is exactly what I have planed to do :-)
> > 
> 
> Sorry if I usurped your work!

Noting to worry. I just was surprised how close it is to my vision ;-).

> 
> > > Signed-off-by: Josh Cartwright 
> > > Signed-off-by: Courtney Cavin 
> > > ---
> > >  drivers/mfd/Kconfig  | 13 +++
> > >  drivers/mfd/Makefile |  1 +
> > >  drivers/mfd/pm8x41.c | 63 
> > > 
> > >  3 files changed, 77 insertions(+)
> > >  create mode 100644 drivers/mfd/pm8x41.c
> > > 
> > 
> > 
> > 
> > > +
> > > +static int pm8x41_probe(struct spmi_device *sdev)
> > > +{
> > > + struct regmap *regmap;
> > > +
> > > + regmap = devm_regmap_init_spmi_ext(sdev, &pm8x41_regmap_config);
> > > + if (IS_ERR(regmap)) {
> > > + dev_dbg(&sdev->dev, "regmap creation failed.\n");
> > > + return PTR_ERR(regmap);
> > > + }
> > > +
> > > + return of_platform_populate(sdev->dev.of_node, NULL, NULL, &sdev->dev);
> > 
> > I think that this will not going to work. For example in this particular
> > case, both controllers have "qcom,qpnp-revid" peripheral which is
> > located at offset 0x100.
> > 
> > And the result is:
> > 
> > [0.963944] sysfs: cannot create duplicate filename 
> > '/bus/platform/devices/100.revid'
> > 
> [...]
> > 
> > Any suggestions?
> 
> That's expected behavior actually.  You have two nodes in DT named the
> same thing and at the same address.  This error is due to the fact that
> all devices are put in '/bus/platform/devices/' with a name made from
> the unit address and name specified in DT.  There's no other unique
> information used to differentiate the devices.
> 
> If you simply change the names in DT, it works.  

Sure, it will work. But they are part of different address spaces. 
Why we should add, IMHO, artificial requirement that names should
be unique? Is it possible to prefix child nodes with parent device 
address? As side note, why they should be registered on the platform
bus at all? To be honest I don't have solution.

Regards,
Ivan  

> [...] qcom,qpnp-revid 100.qcom,pm8841-revid: PM8841 v2.0 options: 0, 0, 2, 2
> [...] qcom,qpnp-revid 100.qcom,pm8941-revid: PM8941 v3.0 options: 2, 0, 0, 0
> 
> Whether this should be "fixed" in the device/bus/sysfs core, I don't
> know, but it isn't specifically an issue with this driver, and there's
> little-to-nothing I can do to fix it here.
> 
> -Courtney



--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-24 Thread Ivan T. Ivanov

Hi Peter, 

On Thu, 2014-04-24 at 08:38 +0800, Peter Chen wrote:
> On Wed, Apr 23, 2014 at 03:28:01PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" 
> > 
> > This series intend to fix driver, which was broken for a while.
> > It is used to create peripheral role device, which in coordination
> > with phy-usb-msm driver could provide USB2.0 gadget support for
> > Qualcomm targets.
> > 
> > Changes since version 3.
> > 
> >  - Fix typo in devicetree description file.
> > 
> > Previews version can be found here:
> 
> Since in your phy's patchset, you also access portsc which is in
> chipidea register region, it is not a standard way.
> In case, you will change something at chipidea driver in future
> when you re-work your next revision phy's patchset, I do not
> send this patchset to Greg right now.
> 

Did you see problems with _this_ particular patch set? There is no
direct dependency between PHY patches and these changes. 

Regards,
Ivan

> Once your phy's patchset has accepted, notify me. I will send
> this patchset to Greg.
> 
> Peter
> 
> > 
> > https://lkml.org/lkml/2014/4/22/195
> > 
> > Ivan T. Ivanov (3):
> >   usb: chipidea: msm: Add device tree binding information
> >   usb: chipidea: msm: Add device tree support
> >   usb: chipidea: msm: Initialize offset of the capability registers
> > 
> >  .../devicetree/bindings/usb/ci-hdrc-qcom.txt   | 17 +++
> >  drivers/usb/chipidea/ci_hdrc_msm.c | 24 
> > +-
> >  2 files changed, 40 insertions(+), 1 deletion(-)
> >  create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qcom.txt
> > 
> > --
> > 1.8.3.2
> > 
> > 
> > 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 03/20] usb: phy: msm: Move global regulators variables to driver state

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Eliminating global variables allows driver to handle multiple
device instances.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 82 ---
 include/linux/usb/msm_hsusb.h |  3 ++
 2 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6ae4d2f..6bae936 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -58,47 +58,43 @@
 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */

-static struct regulator *hsusb_3p3;
-static struct regulator *hsusb_1p8;
-static struct regulator *hsusb_vddcx;
-
 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
int ret = 0;

if (init) {
-   hsusb_vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(hsusb_vddcx)) {
+   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+   if (IS_ERR(motg->vddcx)) {
dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(hsusb_vddcx);
+   return PTR_ERR(motg->vddcx);
}

-   ret = regulator_set_voltage(hsusb_vddcx,
+   ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
return ret;
}

-   ret = regulator_enable(hsusb_vddcx);
+   ret = regulator_enable(motg->vddcx);
if (ret) {
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}
} else {
-   ret = regulator_set_voltage(hsusb_vddcx, 0,
+   ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   ret = regulator_disable(hsusb_vddcx);
+   ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");

-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}

return ret;
@@ -109,38 +105,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   hsusb_3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(hsusb_3p3)) {
+   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
+   if (IS_ERR(motg->v3p3)) {
dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(hsusb_3p3);
+   return PTR_ERR(motg->v3p3);
}

-   rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN,
+   rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
goto put_3p3;
}
-   rc = regulator_enable(hsusb_3p3);
+   rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
goto put_3p3;
}
-   hsusb_1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(hsusb_1p8)) {
+   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
+   if (IS_ERR(motg->v1p8)) {
dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(hsusb_1p8);
+   rc = PTR_ERR(motg->v1p8);
goto disable_3p3;
}
-   rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN,
+   rc = regulator_set_voltag

[PATCH v7 00/20] usb: phy: msm: Fixes, cleanups and DT support

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Hi,

This is a next version of patches posted earlier[1].

Hopefully comments from Felipe, Srinivas and Sergei have been addressed.

Changes since v6

 - New patch "Enable deferred driver probing"
 - Add log to patches wich did not have long description.
 - Revert several changes not related to commit message.

[1] http://www.spinics.net/lists/linux-usb/msg106158.html


Ivan T. Ivanov (18):
  usb: phy: msm: Make driver selectable on ARCH_QCOM
  usb: phy: msm: Remove __init macro from driver probe method
  usb: phy: msm: Move global regulators variables to driver state
  usb: phy: msm: Enable deferred driver probing
  usb: phy: msm: Migrate to Managed Device Resource allocation
  usb: phy: msm: Remove unnecessarily check for valid regulators.
  usb: phy: msm: Fix checkpatch.pl warnings
  usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
  usb: phy: msm: Remove unused pclk_src_name
  usb: phy: msm: Remove HSUSB prefix from regulator names
  usb: phy: msm: Properly check result from platform_get_irq()
  usb: phy: msm: Add device tree support and binding information
  usb: phy: msm: Use reset framework for LINK and PHY resets
  usb: phy: msm: Add support for secondary PHY control
  usb: phy: msm: Correct USB PHY Reset sequence for newer platform
  usb: phy: msm: Handle disconnect events
  usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX
  usb: phy: msm: Use usb_add_phy_dev() to register device

Tim Bird (2):
  usb: phy: msm: Fix PTS definitions for MSM USB controller
  usb: phy: msm: Select secondary PHY via TCSR

 .../devicetree/bindings/usb/msm-hsusb.txt  |  78 +++
 arch/arm/mach-msm/board-msm7x30.c  |   2 +-
 arch/arm/mach-msm/board-qsd8x50.c  |   2 +-
 drivers/usb/phy/Kconfig|   6 +-
 drivers/usb/phy/phy-msm-usb.c  | 705 -
 include/linux/usb/msm_hsusb.h  |  39 +-
 include/linux/usb/msm_hsusb_hw.h   |  14 +-
 7 files changed, 509 insertions(+), 337 deletions(-)

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 01/20] usb: phy: msm: Make driver selectable on ARCH_QCOM

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Controller could be found on APQ and MSM platforms,
make configuration description more generic.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 416e0c8..0c668a3 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -171,11 +171,11 @@ config USB_ISP1301
  module will be called phy-isp1301.
 
 config USB_MSM_OTG
-   tristate "OTG support for Qualcomm on-chip USB controller"
-   depends on (USB || USB_GADGET) && ARCH_MSM
+   tristate "Qualcomm on-chip USB OTG controller support"
+   depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
select USB_PHY
help
- Enable this to support the USB OTG transceiver on MSM chips. It
+ Enable this to support the USB OTG transceiver on Qualcomm chips. It
  handles PHY initialization, clock management, and workarounds
  required after resetting the hardware and power management.
  This driver is required even for peripheral only or host only
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 04/20] usb: phy: msm: Enable deferred driver probing

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using platform_driver_probe() prevent driver from requesting
probe deferral. Fix this.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6bae936..b7d73f2 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1736,6 +1736,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
 };

 static struct platform_driver msm_otg_driver = {
+   .probe = msm_otg_probe,
.remove = msm_otg_remove,
.driver = {
.name = DRIVER_NAME,
@@ -1744,7 +1745,7 @@ static struct platform_driver msm_otg_driver = {
},
 };

-module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
+module_platform_driver(msm_otg_driver);

 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM USB transceiver driver");
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 19/20] usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

New platform uses RBCPR hardware feature, with that voting for
absolute voltage of VDD CX is not required. Hence vote for corner of
VDD CX which uses nominal corner voltage on VDD CX.

Signed-off-by: Ivan T. Ivanov 
Cc: Mayank Rana 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  5 
 drivers/usb/phy/phy-msm-usb.c  | 35 +-
 include/linux/usb/msm_hsusb.h  |  1 +
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 0669667..2826f2a 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -65,6 +65,10 @@ Optional properties:
 Some platforms may have configuration to allow USB
 controller work with any of the two HSPHYs present.

+- qcom,vdd-levels: This property must be a list of three integer values
+(no, min, max) where each value represents either a voltage
+in microvolts or a value corresponding to voltage corner.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
@@ -87,4 +91,5 @@ Example HSUSB OTG controller device node:

 qcom,otg-control = <1>;
 qcom,phy-init-sequence = < -1 0x63 >;
+qcom,vdd-levels = <1 5 7>;
};
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 602e6c8..9240f5b 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -62,6 +62,13 @@

 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */
+#define USB_PHY_SUSP_DIG_VOL   50  /* uV */
+
+enum vdd_levels {
+   VDD_LEVEL_NONE = 0,
+   VDD_LEVEL_MIN,
+   VDD_LEVEL_MAX,
+};

 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
@@ -69,8 +76,8 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)

if (init) {
ret = regulator_set_voltage(motg->vddcx,
-   USB_PHY_VDD_DIG_VOL_MIN,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MIN],
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret) {
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
@@ -81,7 +88,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret)
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
@@ -435,17 +442,16 @@ static int msm_phy_init(struct usb_phy *phy)

 #ifdef CONFIG_PM

-#define USB_PHY_SUSP_DIG_VOL  50
 static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
 {
-   int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
+   int max_vol = motg->vdd_levels[VDD_LEVEL_MAX];
int min_vol;
int ret;

if (high)
-   min_vol = USB_PHY_VDD_DIG_VOL_MIN;
+   min_vol = motg->vdd_levels[VDD_LEVEL_MIN];
else
-   min_vol = USB_PHY_SUSP_DIG_VOL;
+   min_vol = motg->vdd_levels[VDD_LEVEL_NONE];

ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
@@ -1441,7 +1447,7 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
struct device_node *node = pdev->dev.of_node;
struct property *prop;
int len, ret, words;
-   u32 val;
+   u32 val, tmp[3];

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
@@ -1472,6 +1478,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
motg->phy_number = val;

+   motg->vdd_levels[VDD_LEVEL_NONE] = USB_PHY_SUSP_DIG_VOL;
+   motg->vdd_levels[VDD_LEVEL_MIN] = USB_PHY_VDD_DIG_VOL_MIN;
+   motg->vdd_levels[VDD_LEVEL_MAX] = USB_PHY_VDD_DIG_VOL_MAX;
+
+   if (of_get_property(node, "qcom,vdd-levels", &len) &&
+   len == sizeof(tmp)) {
+   of_property_read_u32_array(node, "qcom,vdd-levels",
+  tmp, len / sizeof(*tmp));
+   motg->vdd_levels[VDD_LEVEL_NONE] = tmp[VDD_LEVEL_NONE];
+   motg->vdd_levels[VDD_L

[PATCH v7 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

They could be more than one USB2.0 PHY's on the platform.
This will allow all of them to be registred successfuly.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 9240f5b..7283005 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1668,6 +1668,7 @@ static int msm_otg_probe(struct platform_device *pdev)
phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
phy->notify_disconnect = msm_phy_notify_disconnect;
+   phy->type = USB_PHY_TYPE_USB2;

phy->io_ops = &msm_otg_io_ops;

@@ -1677,7 +1678,7 @@ static int msm_otg_probe(struct platform_device *pdev)

msm_usb_reset(phy);

-   ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
+   ret = usb_add_phy_dev(&motg->phy);
if (ret) {
dev_err(&pdev->dev, "usb_add_phy failed\n");
goto disable_ldo;
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 18/20] usb: phy: msm: Handle disconnect events

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Put the transceiver in non-driving mode. Otherwise host
may not detect soft-disconnection.

Signed-off-by: Ivan T. Ivanov 
Cc: Pavankumar Kondeti 
---
 drivers/usb/phy/phy-msm-usb.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 1554f69..602e6c8 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -235,6 +235,23 @@ static void ulpi_init(struct msm_otg *motg)
}
 }

+static int msm_phy_notify_disconnect(struct usb_phy *phy,
+  enum usb_device_speed speed)
+{
+   int val;
+
+   /*
+* Put the transceiver in non-driving mode. Otherwise host
+* may not detect soft-disconnection.
+*/
+   val = ulpi_read(phy, ULPI_FUNC_CTRL);
+   val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
+   val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
+   ulpi_write(phy, val, ULPI_FUNC_CTRL);
+
+   return 0;
+}
+
 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
int ret;
@@ -1631,6 +1648,7 @@ static int msm_otg_probe(struct platform_device *pdev)

phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
+   phy->notify_disconnect = msm_phy_notify_disconnect;

phy->io_ops = &msm_otg_io_ops;

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 14/20] usb: phy: msm: Add support for secondary PHY control

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allow support to use 2nd HSPHY with USB2 Core.
Some platforms may have configuration to allow USB controller
work with any of the two HSPHYs present. By default driver
configures USB core to use primary HSPHY. Add support to allow
user select 2nd HSPHY using DT parameter.

Signed-off-by: Ivan T. Ivanov 
Cc: Manu Gautam 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  6 ++
 drivers/usb/phy/phy-msm-usb.c  | 24 --
 include/linux/usb/msm_hsusb.h  |  1 +
 include/linux/usb/msm_hsusb_hw.h   |  1 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index ee4123d..0669667 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -59,6 +59,12 @@ Optional properties:
 For example: qcom,phy-init-sequence = < -1 0x63 >;
 Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.

+- qcom,phy-num: Select number of pyco-phy to use, can be one of
+0 - PHY one, default
+1 - Second PHY
+Some platforms may have configuration to allow USB
+controller work with any of the two HSPHYs present.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6ad1396..c3877ec 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -314,6 +314,9 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
if (!retries)
return -ETIMEDOUT;

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
dev_info(motg->phy.dev, "phy_reset: success\n");
return 0;
 }
@@ -368,6 +371,9 @@ static int msm_otg_reset(struct usb_phy *phy)
ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL);
}

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
return 0;
 }

@@ -404,6 +410,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
struct msm_otg_platform_data *pdata = motg->pdata;
+   void __iomem *addr;
int cnt = 0;

if (atomic_read(&motg->in_lpm))
@@ -463,9 +470,13 @@ static int msm_otg_suspend(struct msm_otg *motg)
 */
writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);

+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL)
-   writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) | PHY_RETEN, addr);

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
@@ -495,6 +506,7 @@ static int msm_otg_resume(struct msm_otg *motg)
 {
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
+   void __iomem *addr;
int cnt = 0;
unsigned temp;

@@ -508,9 +520,14 @@ static int msm_otg_resume(struct msm_otg *motg)

if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
msm_hsusb_ldo_set_mode(motg, 1);
msm_hsusb_config_vddcx(motg, 1);
-   writel(readl(USB_PHY_CTRL) & ~PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) & ~PHY_RETEN, addr);
}

temp = readl(USB_USBCMD);
@@ -1399,6 +1416,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (val == OTG_PMIC_CONTROL)
pdata->otg_control = val;

+   if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
+   motg->phy_number = val;
+
prop = of_find_property(node, "qcom,phy-init-sequence", &len);
if (!prop || !len)
return 0;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 4e5d916..4628f1a 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -158,6 +158,7 @@ struct msm_otg {
atomic_t in_lpm;
int async_int;
unsigned cur_power;
+   int phy_number;
struct delayed_work chg_work;
enum usb_chg_state chg_state;
enum usb_chg_type chg

[PATCH v7 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference 
from the variable msm_otg_driver to the function .init.text:msm_otg_probe()
The variable msm_otg_driver references
the function __init msm_otg_probe()

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 5b37b81..6ae4d2f 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1406,7 +1406,7 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_remove(msm_otg_dbg_root);
 }
 
-static int __init msm_otg_probe(struct platform_device *pdev)
+static int msm_otg_probe(struct platform_device *pdev)
 {
int ret = 0;
struct resource *res;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 15/20] usb: phy: msm: Correct USB PHY Reset sequence for newer platform

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

On few legacy platforms, USB PHY is having dedicated reset clk.
It is used to reset USB PHY after putting USB PHY into low power
mode and for calibration of USB PHY. Putting USB PHY into low
power mode is causing ulpi read/write timeout as expected. USB PHY
reset clk is not available on newer platform.

For 28nm PHY, reset USB PHY after resestting USB LINK.
Also reset USB PHY using USB_PHY_PON bit with USB_OTG_HS_PHY_CTRL
register after programming USB PHY Override registers as suggested
with hardware programming guidelines.

Signed-off-by: Ivan T. Ivanov 
Signed-off-by: Tim Bird 
Cc: Mayank Rana 
---
 drivers/usb/phy/phy-msm-usb.c| 140 ---
 include/linux/usb/msm_hsusb_hw.h |   5 ++
 2 files changed, 93 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c3877ec..d949018 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -48,6 +48,7 @@
 #define DRIVER_NAME"msm_otg"

 #define ULPI_IO_TIMEOUT_USEC   (10 * 1000)
+#define LINK_RESET_TIMEOUT_USEC(250 * 1000)

 #define USB_PHY_3P3_VOL_MIN305 /* uV */
 #define USB_PHY_3P3_VOL_MAX330 /* uV */
@@ -267,77 +268,35 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg)
return ret;
 }

-static int msm_otg_phy_reset(struct msm_otg *motg)
+static int msm_link_reset(struct msm_otg *motg)
 {
u32 val;
int ret;
-   int retries;

ret = msm_otg_link_clk_reset(motg, 1);
if (ret)
return ret;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   ret = msm_otg_link_clk_reset(motg, 0);
-   if (ret)
-   return ret;

-   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
-
-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_write(&motg->phy, ULPI_FUNC_CTRL_SUSPENDM,
-   ULPI_CLR(ULPI_FUNC_CTRL));
-   if (!ret)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
+   /* wait for 1ms delay as suggested in HPG. */
+   usleep_range(1000, 1200);

-   /* This reset calibrates the phy, if the above write succeeded */
-   ret = msm_otg_phy_clk_reset(motg);
+   ret = msm_otg_link_clk_reset(motg, 0);
if (ret)
return ret;

-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_read(&motg->phy, ULPI_DEBUG);
-   if (ret != -ETIMEDOUT)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
-
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

-   dev_info(motg->phy.dev, "phy_reset: success\n");
+   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
+   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+
return 0;
 }

-#define LINK_RESET_TIMEOUT_USEC(250 * 1000)
 static int msm_otg_reset(struct usb_phy *phy)
 {
struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
-   struct msm_otg_platform_data *pdata = motg->pdata;
int cnt = 0;
-   int ret;
-   u32 val = 0;
-   u32 ulpi_val = 0;
-
-   ret = msm_otg_phy_reset(motg);
-   if (ret) {
-   dev_err(phy->dev, "phy_reset failed\n");
-   return ret;
-   }
-
-   ulpi_init(motg);

writel(USBCMD_RESET, USB_USBCMD);
while (cnt < LINK_RESET_TIMEOUT_USEC) {
@@ -351,11 +310,86 @@ static int msm_otg_reset(struct usb_phy *phy)

/* select ULPI phy */
writel(0x8000, USB_PORTSC);
+   writel(0x0, USB_AHBBURST);
+   writel(0x08, USB_AHBMODE);
+
+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+   return 0;
+}
+
+static void msm_phy_reset(struct msm_otg *motg)
+{
+   void __iomem *addr;
+
+   if (motg->pdata->phy_type != SNPS_28NM_INTEGRATED_PHY) {
+   msm_otg_phy_clk_reset(motg);
+   return;
+   }
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
+   /* Assert USB PHY_POR */
+   writel(readl(addr) | PHY_POR_ASSERT, addr);
+
+   /*
+* wait for minimum 10 microseconds as suggested in HPG.
+* Use a slightly larger value since the exact value didn't
+* work 100% of the time.
+*/
+   udelay(12);
+
+   /* Deassert USB PHY_POR */
+   writel(readl(addr) & ~PHY_POR_ASSERT, addr);
+}
+
+

[PATCH v7 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-24 Thread Ivan T. Ivanov
From: Tim Bird 

Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB
controller.  This is a standard chipidea PORTSC definition, where
a PHY_TYPE of 10b (<<30) is ULPI and 11b (<<30) is SERIAL.
Fix the definitions and use them correctly in the driver code.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 8 +---
 include/linux/usb/msm_hsusb_hw.h | 5 +++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index d949018..06d79c1 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg)
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

+   /* put transceiver in serial mode as part of reset */
val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+   writel(val | PORTSC_PTS_SERIAL, USB_PORTSC);

return 0;
 }
@@ -308,8 +309,9 @@ static int msm_otg_reset(struct usb_phy *phy)
if (cnt >= LINK_RESET_TIMEOUT_USEC)
return -ETIMEDOUT;

-   /* select ULPI phy */
-   writel(0x8000, USB_PORTSC);
+   /* select ULPI phy and clear other status/control bits in PORTSC */
+   writel(PORTSC_PTS_ULPI, USB_PORTSC);
+
writel(0x0, USB_AHBBURST);
writel(0x08, USB_AHBMODE);

diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 575c743..98d3dd8 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -31,8 +31,9 @@
 #define USB_USBINTR  (MSM_USB_BASE + 0x0148)

 #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
-#define PORTSC_PTS_MASK (3 << 30)
-#define PORTSC_PTS_ULPI (3 << 30)
+#define PORTSC_PTS_MASK(3 << 30)
+#define PORTSC_PTS_ULPI(2 << 30)
+#define PORTSC_PTS_SERIAL  (3 << 30)

 #define USB_ULPI_VIEWPORT(MSM_USB_BASE + 0x0170)
 #define ULPI_RUN  (1 << 30)
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 13/20] usb: phy: msm: Use reset framework for LINK and PHY resets

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using reset framework eliminate need of platform specific
callbacks and enable reset lines to be specified in DT files.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 29 +
 include/linux/usb/msm_hsusb.h |  3 +++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 4ed1ded..6ad1396 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg)

 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->link_clk_reset)
-   return ret;
+   if (motg->pdata->link_clk_reset)
+   ret = motg->pdata->link_clk_reset(motg->clk, assert);
+   else if (assert)
+   ret = reset_control_assert(motg->link_rst);
+   else
+   ret = reset_control_deassert(motg->link_rst);

-   ret = motg->pdata->link_clk_reset(motg->clk, assert);
if (ret)
dev_err(motg->phy.dev, "usb link clk reset %s failed\n",
assert ? "assert" : "deassert");
@@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, 
bool assert)

 static int msm_otg_phy_clk_reset(struct msm_otg *motg)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->phy_clk_reset)
-   return ret;
+   if (motg->pdata->phy_clk_reset)
+   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
+   else
+   ret = reset_control_reset(motg->phy_rst);

-   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
dev_err(motg->phy.dev, "usb phy clk reset failed\n");

@@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
id = of_match_device(msm_otg_dt_match, &pdev->dev);
pdata->phy_type = (int) id->data;

+   motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
+   if (IS_ERR(motg->link_rst))
+   return PTR_ERR(motg->link_rst);
+
+   motg->phy_rst = devm_reset_control_get(&pdev->dev, "phy");
+   if (IS_ERR(motg->phy_rst))
+   return PTR_ERR(motg->phy_rst);
+
pdata->mode = of_usb_get_dr_mode(node);
if (pdata->mode == USB_DR_MODE_UNKNOWN)
pdata->mode = USB_DR_MODE_OTG;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index bd68299..4e5d916 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -165,6 +165,9 @@ struct msm_otg {
struct regulator *v3p3;
struct regulator *v1p8;
struct regulator *vddcx;
+
+   struct reset_control *phy_rst;
+   struct reset_control *link_rst;
 };

 #endif
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 17/20] usb: phy: msm: Select secondary PHY via TCSR

2014-04-24 Thread Ivan T. Ivanov
From: Tim Bird 

Select the secondary PHY using the TCSR register, if phy-num=1
in the DTS (or phy_number is set in the platform data).  The
SOC has 2 PHYs which can be used with the OTG port, and this
code allows configuring the correct one.

Note: This resolves the problem I was seeing where I couldn't
get the USB driver working at all on a dragonboard, from cold
boot.  This patch depends on patch 5/14 from Ivan's msm USB
patch set.  It does not use DT for the register address, as
there's no evidence that this address changes between SoC
versions.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 14 ++
 include/linux/usb/msm_hsusb_hw.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 06d79c1..1554f69 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1488,6 +1488,7 @@ static int msm_otg_probe(struct platform_device *pdev)
struct resource *res;
struct msm_otg *motg;
struct usb_phy *phy;
+   void __iomem *phy_select;

motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
if (!motg) {
@@ -1552,6 +1553,19 @@ static int msm_otg_probe(struct platform_device *pdev)
if (IS_ERR(motg->regs))
return PTR_ERR(motg->regs);

+   /*
+* NOTE: The PHYs can be multiplexed between the chipidea controller
+* and the dwc3 controller, using a single bit. It is important that
+* the dwc3 driver does not set this bit in an incompatible way.
+*/
+   if (motg->phy_number) {
+   phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
+   if (IS_ERR(phy_select))
+   return PTR_ERR(phy_select);
+   /* Enable second PHY with the OTG port */
+   writel_relaxed(0x1, phy_select);
+   }
+
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 98d3dd8..a29f603 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -16,6 +16,9 @@
 #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__
 #define __LINUX_USB_GADGET_MSM72K_UDC_H__

+/* USB phy selector - in TCSR address range */
+#define USB2_PHY_SEL 0xfd4ab000
+
 #define USB_AHBBURST (MSM_USB_BASE + 0x0090)
 #define USB_AHBMODE  (MSM_USB_BASE + 0x0098)
 #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 11/20] usb: phy: msm: Properly check result from platform_get_irq()

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Function return negative code on error.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 5d64038..8a7a324 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1412,7 +1412,7 @@ static int msm_otg_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
-   if (!motg->irq) {
+   if (motg->irq < 0) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
return motg->irq;
}
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 12/20] usb: phy: msm: Add device tree support and binding information

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allows controller to be specified via device tree.

Signed-off-by: Ivan T. Ivanov 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  67 
 drivers/usb/phy/phy-msm-usb.c  | 113 +
 include/linux/usb/msm_hsusb.h  |   6 +-
 3 files changed, 165 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 5ea26c6..ee4123d 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -15,3 +15,70 @@ Example EHCI controller device node:
usb-phy = <&usb_otg>;
};

+USB PHY with optional OTG:
+
+Required properties:
+- compatible:   Should contain:
+  "qcom,usb-otg-ci" for chipsets with ChipIdea 45nm PHY
+  "qcom,usb-otg-snps" for chipsets with Synopsys 28nm PHY
+
+- regs: Offset and length of the register set in the memory map
+- interrupts:   interrupt-specifier for the OTG interrupt.
+
+- clocks:   A list of phandle + clock-specifier pairs for the
+clocks listed in clock-names
+- clock-names:  Should contain the following:
+  "phy" USB PHY reference clock
+  "core"Protocol engine clock
+  "iface"   Interface bus clock
+  "alt_core"Protocol engine clock for targets with asynchronous
+reset methodology. (optional)
+
+- vdccx-supply: phandle to the regulator for the vdd supply for
+digital circuit operation.
+- v1p8-supply:  phandle to the regulator for the 1.8V supply
+- v3p3-supply:  phandle to the regulator for the 3.3V supply
+
+- resets:   A list of phandle + reset-specifier pairs for the
+resets listed in reset-names
+- reset-names:  Should contain the following:
+  "phy" USB PHY controller reset
+  "link"USB LINK controller reset
+
+- qcom,otg-control: OTG control (VBUS and ID notifications) can be one of
+1 - PHY control
+2 - PMIC control
+
+Optional properties:
+- dr_mode:  One of "host", "peripheral" or "otg". Defaults to "otg"
+
+- qcom,phy-init-sequence: PHY configuration sequence values. This is related 
to Device
+Mode Eye Diagram test. Start address at which these values 
will be
+written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as
+"do not overwrite default value at this address".
+For example: qcom,phy-init-sequence = < -1 0x63 >;
+Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.
+
+Example HSUSB OTG controller device node:
+
+usb@f9a55000 {
+compatible = "qcom,usb-otg-snps";
+reg = <0xf9a55000 0x400>;
+interrupts = <0 134 0>;
+dr_mode = "peripheral";
+
+clocks = <&gcc GCC_XO_CLK>, <&gcc GCC_USB_HS_SYSTEM_CLK>,
+<&gcc GCC_USB_HS_AHB_CLK>;
+
+clock-names = "phy", "core", "iface";
+
+vddcx-supply = <&pm8841_s2_corner>;
+v1p8-supply = <&pm8941_l6>;
+v3p3-supply = <&pm8941_l24>;
+
+resets = <&gcc GCC_USB2A_PHY_BCR>, <&gcc GCC_USB_HS_BCR>;
+reset-names = "phy", "link";
+
+qcom,otg-control = <1>;
+qcom,phy-init-sequence = < -1 0x63 >;
+   };
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8a7a324..4ed1ded 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -30,9 +30,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,16 +220,16 @@ static struct usb_phy_io_ops msm_otg_io_ops = {
 static void ulpi_init(struct msm_otg *motg)
 {
struct msm_otg_platform_data *pdata = motg->pdata;
-   int *seq = pdata->phy_init_seq;
+   int *seq = pdata->phy_init_seq, idx;
+   u32 addr = ULPI_EXT_VENDOR_SPECIFIC;

-   if (!seq)
-   return;
+   for (idx = 0; idx < pdata->phy_init_sz; idx++) {
+   if (seq[idx] == -1)
+   continue;

-   while (seq[0] >= 0) {
dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
-   seq[0], seq[1]);
-   ulpi_write(&motg->phy, seq[0], seq[1]);
-   seq += 2;
+   seq[idx], addr + idx);
+   ulpi_write(&motg->phy, seq[idx], addr + idx);
}
 }

@@ -1343,25 +1346,95 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_r

[PATCH v7 09/20] usb: phy: msm: Remove unused pclk_src_name

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

There are no references to 'pclk_src_name' in plaform code,
so it is unused.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 26 +-
 include/linux/usb/msm_hsusb.h |  5 -
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index a67c8a2..8b84821 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -464,9 +464,6 @@ static int msm_otg_suspend(struct msm_otg *motg)
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
msm_hsusb_ldo_set_mode(motg, 0);
@@ -496,9 +493,6 @@ static int msm_otg_resume(struct msm_otg *motg)
if (!atomic_read(&motg->in_lpm))
return 0;

-   if (!IS_ERR(motg->pclk_src))
-   clk_prepare_enable(motg->pclk_src);
-
clk_prepare_enable(motg->pclk);
clk_prepare_enable(motg->clk);
if (!IS_ERR(motg->core_clk))
@@ -1395,17 +1389,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 * If USB Core is running its protocol engine based on CORE CLK,
 * CORE CLK  must be running at >55Mhz for correct HSUSB
 * operation and USB core cannot tolerate frequency changes on
-* CORE CLK. For such USB cores, vote for maximum clk frequency
-* on pclk source
+* CORE CLK.
 */
-motg->pclk_src = ERR_PTR(-ENOENT);
-if (motg->pdata->pclk_src_name) {
-   motg->pclk_src = devm_clk_get(&pdev->dev,
-   motg->pdata->pclk_src_name);
-   if (IS_ERR(motg->pclk_src))
-   return PTR_ERR(motg->pclk_src);
-   }
-
motg->pclk = devm_clk_get(&pdev->dev, "usb_hs_pclk");
if (IS_ERR(motg->pclk)) {
dev_err(&pdev->dev, "failed to get usb_hs_pclk\n");
@@ -1451,10 +1436,6 @@ static int msm_otg_probe(struct platform_device *pdev)
}

clk_set_rate(motg->clk, 6000);
-   if (!IS_ERR(motg->pclk_src)) {
-   clk_set_rate(motg->pclk_src, INT_MAX);
-   clk_prepare_enable(motg->pclk_src);
-   }

clk_prepare_enable(motg->clk);
clk_prepare_enable(motg->pclk);
@@ -1530,8 +1511,6 @@ disable_clks:
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
return ret;
 }

@@ -1576,9 +1555,6 @@ static int msm_otg_remove(struct platform_device *pdev)
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
msm_hsusb_ldo_init(motg, 0);

pm_runtime_set_suspended(&pdev->dev);
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 72c5830..262ed80 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -106,8 +106,6 @@ enum usb_chg_type {
  * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  * @mode: Supported mode (OTG/peripheral/host).
  * @otg_control: OTG switch controlled by user/Id pin
- * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
- *  dfab_usb_hs_clk in case of 8660 and 8960.
  */
 struct msm_otg_platform_data {
int *phy_init_seq;
@@ -117,7 +115,6 @@ struct msm_otg_platform_data {
enum otg_control_type otg_control;
enum msm_usb_phy_type phy_type;
void (*setup_gpio)(enum usb_otg_state state);
-   char *pclk_src_name;
int (*link_clk_reset)(struct clk *link_clk, bool assert);
int (*phy_clk_reset)(struct clk *phy_clk);
 };
@@ -129,7 +126,6 @@ struct msm_otg_platform_data {
  * @irq: IRQ number assigned for HSUSB controller.
  * @clk: clock struct of usb_hs_clk.
  * @pclk: clock struct of usb_hs_pclk.
- * @pclk_src: pclk source for voting.
  * @phy_reset_clk: clock struct of usb_phy_clk.
  * @core_clk: clock struct of usb_hs_core_clk.
  * @regs: ioremapped register base address.
@@ -150,7 +146,6 @@ struct msm_otg {
int irq;
struct clk *clk;
struct clk *pclk;
-   struct clk *pclk_src;
struct clk *phy_reset_clk;
struct clk *core_clk;
void __iomem *regs;
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 08/20] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Use enum usb_dr_mode and drop default usb_dr_mode from platform data.

USB DT bindings states: dr_mode: "...In case this attribute isn't
passed via DT, USB DRD controllers should default to OTG...",
so remove redundand field.

Signed-off-by: Ivan T. Ivanov 
Acked-by: David Brown 
---
 arch/arm/mach-msm/board-msm7x30.c |  2 +-
 arch/arm/mach-msm/board-qsd8x50.c |  2 +-
 drivers/usb/phy/phy-msm-usb.c | 41 ---
 include/linux/usb/msm_hsusb.h | 20 +--
 4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-msm/board-msm7x30.c 
b/arch/arm/mach-msm/board-msm7x30.c
index 46de789..0c4c200 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/arch/arm/mach-msm/board-qsd8x50.c 
b/arch/arm/mach-msm/board-qsd8x50.c
index 9169ec3..4c74861 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 3855217..a67c8a2 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -348,10 +348,10 @@ static int msm_otg_reset(struct usb_phy *phy)

if (pdata->otg_control == OTG_PHY_CONTROL) {
val = readl(USB_OTGSC);
-   if (pdata->mode == USB_OTG) {
+   if (pdata->mode == USB_DR_MODE_OTG) {
ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID;
val |= OTGSC_IDIE | OTGSC_BSVIE;
-   } else if (pdata->mode == USB_PERIPHERAL) {
+   } else if (pdata->mode == USB_DR_MODE_PERIPHERAL) {
ulpi_val = ULPI_INT_SESS_VALID;
val |= OTGSC_BSVIE;
}
@@ -637,7 +637,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Fail host registration if this board can support
 * only peripheral configuration.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
dev_info(otg->phy->dev, "Host mode is not supported\n");
return -ENODEV;
}
@@ -666,7 +666,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Kick the state machine work, if peripheral is not supported
 * or peripheral is already registered with us.
 */
-   if (motg->pdata->mode == USB_HOST || otg->gadget) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -710,7 +710,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Fail peripheral registration if this board can support
 * only host configuration.
 */
-   if (motg->pdata->mode == USB_HOST) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST) {
dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
return -ENODEV;
}
@@ -735,7 +735,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Kick the state machine work, if host is not supported
 * or host is already registered with us.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL || otg->host) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -1056,7 +1056,7 @@ static void msm_otg_init_sm(struct msm_otg *motg)
u32 otgsc = readl(USB_OTGSC);

switch (pdata->mode) {
-   case USB_OTG:
+   case USB_DR_MODE_OTG:
if (pdata->otg_control == OTG_PHY_CONTROL) {
if (otgsc & OTGSC_ID)
set_bit(ID, &motg->inpu

[PATCH v7 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Move memory, regulators, clocks and irq allocation to
devm_* variants. Properly check for valid clk handles.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 192 --
 1 file changed, 73 insertions(+), 119 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index b7d73f2..67cac96 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
int ret = 0;

if (init) {
-   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(motg->vddcx)) {
-   dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(motg->vddcx);
-   }
-
ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(motg->vddcx);
return ret;
}

ret = regulator_enable(motg->vddcx);
-   if (ret) {
+   if (ret)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(motg->vddcx);
-   }
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
-
-   regulator_put(motg->vddcx);
}

return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(motg->v3p3)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(motg->v3p3);
-   }
-
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
-   goto put_3p3;
+   goto exit;
}
rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
-   goto put_3p3;
-   }
-   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(motg->v1p8)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(motg->v1p8);
-   goto disable_3p3;
+   goto exit;
}
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}

return 0;
}

regulator_disable(motg->v1p8);
-put_1p8:
-   regulator_put(motg->v1p8);
 disable_3p3:
regulator_disable(motg->v3p3);
-put_3p3:
-   regulator_put(motg->v3p3);
+exit:
return rc;
 }

@@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg)

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
-   if (motg->core_clk)
+   if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

if (!IS_ERR(motg->pclk_src))
@@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg)

clk_prepare_enable(motg->pclk

[PATCH v7 06/20] usb: phy: msm: Remove unnecessarily check for valid regulators.

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Whether regulators are available or not is checked at driver
probe. If they are not available driver will refuse to load,
so no need to check them again.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 67cac96..4045301 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -133,16 +133,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
 {
int ret = 0;

-   if (!motg->v1p8 || IS_ERR(motg->v1p8)) {
-   pr_err("%s: HSUSB_1p8 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
-   if (!motg->v3p3 || IS_ERR(motg->v3p3)) {
-   pr_err("%s: HSUSB_3p3 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
if (on) {
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 10/20] usb: phy: msm: Remove HSUSB prefix from regulator names

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Prefix did not bring any useful information. Currently none
of the MSM platforms define these regulators, so it is safe
to rename them.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8b84821..5d64038 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1417,19 +1417,19 @@ static int msm_otg_probe(struct platform_device *pdev)
return motg->irq;
}

-   motg->vddcx = devm_regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+   motg->vddcx = devm_regulator_get(motg->phy.dev, "vddcx");
if (IS_ERR(motg->vddcx)) {
dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
return PTR_ERR(motg->vddcx);
}

-   motg->v3p3 = devm_regulator_get(motg->phy.dev, "HSUSB_3p3");
+   motg->v3p3 = devm_regulator_get(motg->phy.dev, "v3p3");
if (IS_ERR(motg->v3p3)) {
dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
return PTR_ERR(motg->v3p3);
}

-   motg->v1p8 = devm_regulator_get(motg->phy.dev, "HSUSB_1p8");
+   motg->v1p8 = devm_regulator_get(motg->phy.dev, "v1p8");
if (IS_ERR(motg->v1p8)) {
dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
return PTR_ERR(motg->v1p8);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 07/20] usb: phy: msm: Fix checkpatch.pl warnings

2014-04-24 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: quoted string split across lines
WARNING: Prefer seq_puts to seq_printf

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 4045301..3855217 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
}

@@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
@@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 3p3\n");
+   dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
goto exit;
}
rc = regulator_enable(motg->v3p3);
@@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 1p8\n");
+   dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
@@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set HPM for v1p8\n");
return ret;
}
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set HPM for v3p3\n");
regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
return ret;
@@ -154,13 +148,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set LPM for v1p8\n");
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set LPM for v3p3\n");
}

pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
@@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int 
high)

ret = regulator_set_voltage(motg->vddcx, 

[RFC PATCH] mfd: pm8x41: Naive function devices registration

2014-04-25 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Currently functions that exist in both the controller at the
same address offset can not be specified with the same names.

Adding Unique Slave ID device address to prefix function
device names fixes this.

Function devices are SPMI devices, so register them on
SPMI bus.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/mfd/pm8x41.c | 61 
 1 file changed, 57 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/pm8x41.c b/drivers/mfd/pm8x41.c
index c85e0d6..29bc1e7 100644
--- a/drivers/mfd/pm8x41.c
+++ b/drivers/mfd/pm8x41.c
@@ -11,9 +11,10 @@
  */
 #include 
 #include 
-#include 
+#include 
 #include 
-#include 
+#include 
+#include 

 static const struct regmap_config pm8x41_regmap_config = {
.reg_bits   = 16,
@@ -23,7 +24,7 @@ static const struct regmap_config pm8x41_regmap_config = {

 static int pm8x41_remove_child(struct device *dev, void *unused)
 {
-   platform_device_unregister(to_platform_device(dev));
+   device_unregister(dev);
return 0;
 }

@@ -32,9 +33,40 @@ static void pm8x41_remove(struct spmi_device *sdev)
device_for_each_child(&sdev->dev, NULL, pm8x41_remove_child);
 }

+static struct spmi_device *pm8x41_function_alloc(struct spmi_controller *ctrl,
+  struct spmi_device *parent,
+  struct device_node *node)
+{
+   struct spmi_device *function;
+   u32 reg;
+   int err;
+
+   err = of_property_read_u32(node, "reg", ®);
+   if (err) {
+   dev_err(&parent->dev,
+   "node %s err (%d) does not have 'reg' property\n",
+   node->full_name, err);
+   return NULL;
+   }
+
+   function = spmi_device_alloc(ctrl);
+   if (!function)
+   return NULL;
+
+   function->dev.parent = &parent->dev;
+   function->dev.of_node = node;
+   function->usid = parent->usid;
+
+   dev_set_name(&function->dev, "%02x-%04x", function->usid, reg);
+
+   return function;
+}
+
 static int pm8x41_probe(struct spmi_device *sdev)
 {
+   struct device_node *node;
struct regmap *regmap;
+   int err = 0;

regmap = devm_regmap_init_spmi_ext(sdev, &pm8x41_regmap_config);
if (IS_ERR(regmap)) {
@@ -42,7 +74,24 @@ static int pm8x41_probe(struct spmi_device *sdev)
return PTR_ERR(regmap);
}

-   return of_platform_populate(sdev->dev.of_node, NULL, NULL, &sdev->dev);
+   for_each_available_child_of_node(sdev->dev.of_node, node) {
+   struct spmi_device *function;
+
+   dev_dbg(&sdev->dev, "adding child %s\n", node->full_name);
+
+   function = pm8x41_function_alloc(sdev->ctrl, sdev, node);
+   if (!function)
+   continue;
+
+   err = device_add(&function->dev);
+   if (err < 0) {
+   dev_err(&function->dev, "Can't add %s, status %d\n",
+   dev_name(&function->dev), err);
+   break;
+   }
+   }
+
+   return err;
 }

 static const struct of_device_id pm8x41_id_table[] = {
@@ -61,3 +110,7 @@ static struct spmi_driver pm8x41_driver = {
},
 };
 module_spmi_driver(pm8x41_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Qualcomm SPMI PMIC core driver");
+MODULE_ALIAS("spmi:pm8x41");
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] mfd: pm8x41: Naive function devices registration

2014-04-25 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 08:00 -0500, Rob Herring wrote:
> On Fri, Apr 25, 2014 at 7:32 AM, Ivan T. Ivanov  wrote:
> > From: "Ivan T. Ivanov" 
> >
> > Currently functions that exist in both the controller at the
> > same address offset can not be specified with the same names.
> >
> > Adding Unique Slave ID device address to prefix function
> > device names fixes this.
> >
> > Function devices are SPMI devices, so register them on
> > SPMI bus.
> >
> > Signed-off-by: Ivan T. Ivanov 
> > ---
> >  drivers/mfd/pm8x41.c | 61 
> > 
> 
> No, this should be fixed in the core, not the driver.

I think that at core level they are no issues. 
There is no name clashes with "top level" devices.

spmi@...{
...
child@0 {
compatible = "qcom,pm8941";
reg = <0x0 SPMI_USID>;

#address-cells = <1>;
#size-cells = <0>;

revid@100 {
compatible = "qcom,qpnp-revid";
reg = <0x100>;
};
};

child@4 {
compatible = "qcom,pm8841";
reg = <0x4 SPMI_USID>;

#address-cells = <1>;
#size-cells = <0>;

revid@100 {
compatible = "qcom,qpnp-revid";
reg = <0x100>;
};
};
};

I don't have experience with SPMI devices, but it looks
like address partitioning is specific to this "PMIC"
controllers.

Regards,
Ivan

> 
> Rob


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] mfd: pm8x41: Naive function devices registration

2014-04-25 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 08:43 -0500, Rob Herring wrote:
> On Fri, Apr 25, 2014 at 8:29 AM, Ivan T. Ivanov  wrote:
> > On Fri, 2014-04-25 at 08:00 -0500, Rob Herring wrote:
> >> On Fri, Apr 25, 2014 at 7:32 AM, Ivan T. Ivanov  wrote:
> >> > From: "Ivan T. Ivanov" 
> >> >
> >> > Currently functions that exist in both the controller at the
> >> > same address offset can not be specified with the same names.
> >> >
> >> > Adding Unique Slave ID device address to prefix function
> >> > device names fixes this.
> >> >
> >> > Function devices are SPMI devices, so register them on
> >> > SPMI bus.
> >> >
> >> > Signed-off-by: Ivan T. Ivanov 
> >> > ---
> >> >  drivers/mfd/pm8x41.c | 61 
> >> > 
> >>
> >> No, this should be fixed in the core, not the driver.
> >
> > I think that at core level they are no issues.
> 
> By core, I mean the device naming conventions used by the DT platform
> device code. There is a problem and it should be handled.
> 
> As I mentioned in the other thread, either we should not use the
> address on non-translatable addresses like this or append the parent
> address.

Ok, I see.

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH] mfd: pm8x41: Naive function devices registration

2014-04-25 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 09:15 -0500, Josh Cartwright wrote:
> On Fri, Apr 25, 2014 at 03:32:51PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" 
> > 
> > Currently functions that exist in both the controller at the
> > same address offset can not be specified with the same names.
> 
> The terminology here is a bit confusing.  When I read "controller", I
> hear "SPMI controller", 

Yes, it is badly worded.

> but this is really not a limitation of the SPMI
> core, but rather a limitation of of_platform_populate() used by this
> particular SPMI slave MFD driver.
> 
> > Adding Unique Slave ID device address to prefix function
> > device names fixes this.
> > 
> > Function devices are SPMI devices, so register them on
> > SPMI bus.
> 
> This is a step backwards.  The PMIC functions are not individually
> addressable SPMI slaves, and as such should not be represented as
> independent devices to the SPMI core.
> 
> They really are subfunctions of a particular SPMI slave, and should be
> modeled as children of that slave device.  With this driver, we've
> chosen to model the child devices as platform devices, but it could
> also be a separate bus type.

I tend to agree. My reasoning was that they are part of the 
device which sits on the SPMI bus, so they should also be part
of this bus.

Regards,
Ivan

> 
>   Josh
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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] mfd: pm8x41: add support for Qualcomm 8x41 PMICs

2014-04-28 Thread Ivan T. Ivanov

Hi Frank,

On Fri, 2014-04-25 at 17:28 -0700, Frank Rowand wrote:
> On 4/23/2014 6:19 AM, Ivan T. Ivanov wrote:



> > spmi {
> > compatible = "qcom,spmi-pmic-arb";
> > reg-names = "core", "intr", "cnfg";
> > reg = <0xfc4cf000 0x1000>,
> >   <0xfc4cb000 0x1000>,
> >   <0xfc4ca000 0x1000>;
> > 
> > interrupt-names = "periph_irq";
> > interrupts = <0 190 0>;
> > 
> > qcom,ee = <0>;
> > qcom,channel = <0>;
> > 
> > #address-cells = <2>;
> > #size-cells = <0>;
> > 
> > interrupt-controller;
> > #interrupt-cells = <4>;
> > 
> > pm8941@0 {
> > compatible = "qcom,pm8941";
> > reg = <0x0 SPMI_USID>;
> > 
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > revid@100 {
> > compatible = "qcom,qpnp-revid";
> > reg = <0x100 0x100>;

This should be just reg = <0x100>;

> > };
> > };
> > 
> > pm8841@4 {
> 
>   typo nit - that should be pm8941@4.
>   The nit does not change what you reported though.
> 
> > compatible = "qcom,pm8941";

Actually this one is incorrect, it should be "qcom,pm8841", 
but as you say it doesn't make difference in the end result.

> > reg = <0x4 SPMI_USID>;
> > 
> > #address-cells = <1>;
> > #size-cells = <0>;
> > 
> > revid@100 {
> > compatible = "qcom,qpnp-revid";
> > reg = <0x100 0x100>;

also here.

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote:
> On Thu, Apr 24, 2014 at 01:49:38PM -0300, Fabio Estevam wrote:
> > On Thu, Apr 24, 2014 at 12:48 PM, Ivan T. Ivanov  wrote:
> > 
> > > +   motg->vddcx = devm_regulator_get(motg->phy.dev, "HSUSB_VDDCX");
> > > +   if (IS_ERR(motg->vddcx)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
> > > +   return PTR_ERR(motg->vddcx);
> > > +   }
> > > +
> > > +   motg->v3p3 = devm_regulator_get(motg->phy.dev, "HSUSB_3p3");
> > > +   if (IS_ERR(motg->v3p3)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
> > > +   return PTR_ERR(motg->v3p3);
> > > +   }
> > > +
> > > +   motg->v1p8 = devm_regulator_get(motg->phy.dev, "HSUSB_1p8");
> > > +   if (IS_ERR(motg->v1p8)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
> > > +   return PTR_ERR(motg->v1p8);
> > > +   }
> > 
> > It seems that calling devm_regulator_bulk_get() here would simplify
> > the code here.

Sure. 

> 
> any comments here ?? Should I expect a new version ?


Will fix rest of the comments and send updated patch set.

Regards,
Ivan
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote:
> On Thu, Apr 24, 2014 at 09:06:24PM +0400, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 04/24/2014 07:48 PM, Ivan T. Ivanov wrote:
> > 
> > >From: "Ivan T. Ivanov" 
> > 
> > >They could be more than one USB2.0 PHY's on the platform.
> > 
> >s/They/There/
> > 
> > >This will allow all of them to be registred successfuly.
> > 
> >s/registred successfuly/registered successfully/

Ouch. will fix it.

Regards,
Ivan


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 10/20] usb: phy: msm: Remove HSUSB prefix from regulator names

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Prefix did not bring any useful information. Currently none
of the MSM platforms define these regulators, so it is safe
to rename them.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c2361bf..bd9e286 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1418,9 +1418,9 @@ static int msm_otg_probe(struct platform_device *pdev)
return motg->irq;
}

-   regs[0].supply = "HSUSB_VDDCX";
-   regs[1].supply = "HSUSB_3p3";
-   regs[2].supply = "HSUSB_1p8";
+   regs[0].supply = "vddcx";
+   regs[1].supply = "v3p3";
+   regs[2].supply = "v1p8";

ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(regs), regs);
if (ret)
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 14/20] usb: phy: msm: Add support for secondary PHY control

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allow support to use 2nd HSPHY with USB2 Core.
Some platforms may have configuration to allow USB controller
work with any of the two HSPHYs present. By default driver
configures USB core to use primary HSPHY. Add support to allow
user select 2nd HSPHY using DT parameter.

Signed-off-by: Ivan T. Ivanov 
Cc: Manu Gautam 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  6 ++
 drivers/usb/phy/phy-msm-usb.c  | 24 --
 include/linux/usb/msm_hsusb.h  |  1 +
 include/linux/usb/msm_hsusb_hw.h   |  1 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index ee4123d..0669667 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -59,6 +59,12 @@ Optional properties:
 For example: qcom,phy-init-sequence = < -1 0x63 >;
 Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.

+- qcom,phy-num: Select number of pyco-phy to use, can be one of
+0 - PHY one, default
+1 - Second PHY
+Some platforms may have configuration to allow USB
+controller work with any of the two HSPHYs present.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index a6abb1b..8d57045 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -314,6 +314,9 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
if (!retries)
return -ETIMEDOUT;

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
dev_info(motg->phy.dev, "phy_reset: success\n");
return 0;
 }
@@ -368,6 +371,9 @@ static int msm_otg_reset(struct usb_phy *phy)
ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL);
}

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
return 0;
 }

@@ -404,6 +410,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
struct msm_otg_platform_data *pdata = motg->pdata;
+   void __iomem *addr;
int cnt = 0;

if (atomic_read(&motg->in_lpm))
@@ -463,9 +470,13 @@ static int msm_otg_suspend(struct msm_otg *motg)
 */
writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);

+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL)
-   writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) | PHY_RETEN, addr);

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
@@ -495,6 +506,7 @@ static int msm_otg_resume(struct msm_otg *motg)
 {
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
+   void __iomem *addr;
int cnt = 0;
unsigned temp;

@@ -508,9 +520,14 @@ static int msm_otg_resume(struct msm_otg *motg)

if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
msm_hsusb_ldo_set_mode(motg, 1);
msm_hsusb_config_vddcx(motg, 1);
-   writel(readl(USB_PHY_CTRL) & ~PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) & ~PHY_RETEN, addr);
}

temp = readl(USB_USBCMD);
@@ -1399,6 +1416,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (val == OTG_PMIC_CONTROL)
pdata->otg_control = val;

+   if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
+   motg->phy_number = val;
+
prop = of_find_property(node, "qcom,phy-init-sequence", &len);
if (!prop || !len)
return 0;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 4e5d916..4628f1a 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -158,6 +158,7 @@ struct msm_otg {
atomic_t in_lpm;
int async_int;
unsigned cur_power;
+   int phy_number;
struct delayed_work chg_work;
enum usb_chg_state chg_state;
enum usb_chg_type chg

[PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference 
from the variable msm_otg_driver to the function .init.text:msm_otg_probe()
The variable msm_otg_driver references
the function __init msm_otg_probe()

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 5b37b81..6ae4d2f 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1406,7 +1406,7 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_remove(msm_otg_dbg_root);
 }

-static int __init msm_otg_probe(struct platform_device *pdev)
+static int msm_otg_probe(struct platform_device *pdev)
 {
int ret = 0;
struct resource *res;
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

There could be more than one USB2.0 PHY's on the platform.
This will allow all of them to be registered successfully.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8e7956e..9dc7918 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1663,6 +1663,7 @@ static int msm_otg_probe(struct platform_device *pdev)
phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
phy->notify_disconnect = msm_phy_notify_disconnect;
+   phy->type = USB_PHY_TYPE_USB2;

phy->io_ops = &msm_otg_io_ops;

@@ -1672,7 +1673,7 @@ static int msm_otg_probe(struct platform_device *pdev)

msm_usb_reset(phy);

-   ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
+   ret = usb_add_phy_dev(&motg->phy);
if (ret) {
dev_err(&pdev->dev, "usb_add_phy failed\n");
goto disable_ldo;
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 17/20] usb: phy: msm: Select secondary PHY via TCSR

2014-04-28 Thread Ivan T. Ivanov
From: Tim Bird 

Select the secondary PHY using the TCSR register, if phy-num=1
in the DTS (or phy_number is set in the platform data).  The
SOC has 2 PHYs which can be used with the OTG port, and this
code allows configuring the correct one.

Note: This resolves the problem I was seeing where I couldn't
get the USB driver working at all on a dragonboard, from cold
boot.  This patch depends on patch 5/14 from Ivan's msm USB
patch set.  It does not use DT for the register address, as
there's no evidence that this address changes between SoC
versions.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 14 ++
 include/linux/usb/msm_hsusb_hw.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index db8d963..9437bcf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1489,6 +1489,7 @@ static int msm_otg_probe(struct platform_device *pdev)
struct resource *res;
struct msm_otg *motg;
struct usb_phy *phy;
+   void __iomem *phy_select;

motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
if (!motg) {
@@ -1553,6 +1554,19 @@ static int msm_otg_probe(struct platform_device *pdev)
if (IS_ERR(motg->regs))
return PTR_ERR(motg->regs);

+   /*
+* NOTE: The PHYs can be multiplexed between the chipidea controller
+* and the dwc3 controller, using a single bit. It is important that
+* the dwc3 driver does not set this bit in an incompatible way.
+*/
+   if (motg->phy_number) {
+   phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
+   if (IS_ERR(phy_select))
+   return PTR_ERR(phy_select);
+   /* Enable second PHY with the OTG port */
+   writel_relaxed(0x1, phy_select);
+   }
+
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 98d3dd8..a29f603 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -16,6 +16,9 @@
 #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__
 #define __LINUX_USB_GADGET_MSM72K_UDC_H__

+/* USB phy selector - in TCSR address range */
+#define USB2_PHY_SEL 0xfd4ab000
+
 #define USB_AHBBURST (MSM_USB_BASE + 0x0090)
 #define USB_AHBMODE  (MSM_USB_BASE + 0x0098)
 #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-28 Thread Ivan T. Ivanov
From: Tim Bird 

Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB
controller.  This is a standard chipidea PORTSC definition, where
a PHY_TYPE of 10b (<<30) is ULPI and 11b (<<30) is SERIAL.
Fix the definitions and use them correctly in the driver code.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 8 +---
 include/linux/usb/msm_hsusb_hw.h | 5 +++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index bb33996..db8d963 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg)
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

+   /* put transceiver in serial mode as part of reset */
val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+   writel(val | PORTSC_PTS_SERIAL, USB_PORTSC);

return 0;
 }
@@ -308,8 +309,9 @@ static int msm_otg_reset(struct usb_phy *phy)
if (cnt >= LINK_RESET_TIMEOUT_USEC)
return -ETIMEDOUT;

-   /* select ULPI phy */
-   writel(0x8000, USB_PORTSC);
+   /* select ULPI phy and clear other status/control bits in PORTSC */
+   writel(PORTSC_PTS_ULPI, USB_PORTSC);
+
writel(0x0, USB_AHBBURST);
writel(0x08, USB_AHBMODE);

diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 575c743..98d3dd8 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -31,8 +31,9 @@
 #define USB_USBINTR  (MSM_USB_BASE + 0x0148)

 #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
-#define PORTSC_PTS_MASK (3 << 30)
-#define PORTSC_PTS_ULPI (3 << 30)
+#define PORTSC_PTS_MASK(3 << 30)
+#define PORTSC_PTS_ULPI(2 << 30)
+#define PORTSC_PTS_SERIAL  (3 << 30)

 #define USB_ULPI_VIEWPORT(MSM_USB_BASE + 0x0170)
 #define ULPI_RUN  (1 << 30)
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 18/20] usb: phy: msm: Handle disconnect events

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Put the transceiver in non-driving mode. Otherwise host
may not detect soft-disconnection.

Signed-off-by: Ivan T. Ivanov 
Cc: Pavankumar Kondeti 
---
 drivers/usb/phy/phy-msm-usb.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 9437bcf..366527e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -235,6 +235,23 @@ static void ulpi_init(struct msm_otg *motg)
}
 }

+static int msm_phy_notify_disconnect(struct usb_phy *phy,
+  enum usb_device_speed speed)
+{
+   int val;
+
+   /*
+* Put the transceiver in non-driving mode. Otherwise host
+* may not detect soft-disconnection.
+*/
+   val = ulpi_read(phy, ULPI_FUNC_CTRL);
+   val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
+   val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
+   ulpi_write(phy, val, ULPI_FUNC_CTRL);
+
+   return 0;
+}
+
 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
int ret;
@@ -1626,6 +1643,7 @@ static int msm_otg_probe(struct platform_device *pdev)

phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
+   phy->notify_disconnect = msm_phy_notify_disconnect;

phy->io_ops = &msm_otg_io_ops;

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 19/20] usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

New platform uses RBCPR hardware feature, with that voting for
absolute voltage of VDD CX is not required. Hence vote for corner of
VDD CX which uses nominal corner voltage on VDD CX.

Signed-off-by: Ivan T. Ivanov 
Cc: Mayank Rana 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  5 
 drivers/usb/phy/phy-msm-usb.c  | 35 +-
 include/linux/usb/msm_hsusb.h  |  1 +
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 0669667..2826f2a 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -65,6 +65,10 @@ Optional properties:
 Some platforms may have configuration to allow USB
 controller work with any of the two HSPHYs present.

+- qcom,vdd-levels: This property must be a list of three integer values
+(no, min, max) where each value represents either a voltage
+in microvolts or a value corresponding to voltage corner.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
@@ -87,4 +91,5 @@ Example HSUSB OTG controller device node:

 qcom,otg-control = <1>;
 qcom,phy-init-sequence = < -1 0x63 >;
+qcom,vdd-levels = <1 5 7>;
};
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 366527e..8e7956e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -62,6 +62,13 @@

 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */
+#define USB_PHY_SUSP_DIG_VOL   50  /* uV */
+
+enum vdd_levels {
+   VDD_LEVEL_NONE = 0,
+   VDD_LEVEL_MIN,
+   VDD_LEVEL_MAX,
+};

 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
@@ -69,8 +76,8 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)

if (init) {
ret = regulator_set_voltage(motg->vddcx,
-   USB_PHY_VDD_DIG_VOL_MIN,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MIN],
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret) {
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
@@ -81,7 +88,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret)
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
@@ -435,17 +442,16 @@ static int msm_phy_init(struct usb_phy *phy)

 #ifdef CONFIG_PM

-#define USB_PHY_SUSP_DIG_VOL  50
 static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
 {
-   int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
+   int max_vol = motg->vdd_levels[VDD_LEVEL_MAX];
int min_vol;
int ret;

if (high)
-   min_vol = USB_PHY_VDD_DIG_VOL_MIN;
+   min_vol = motg->vdd_levels[VDD_LEVEL_MIN];
else
-   min_vol = USB_PHY_SUSP_DIG_VOL;
+   min_vol = motg->vdd_levels[VDD_LEVEL_NONE];

ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
@@ -1441,7 +1447,7 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
struct device_node *node = pdev->dev.of_node;
struct property *prop;
int len, ret, words;
-   u32 val;
+   u32 val, tmp[3];

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
@@ -1472,6 +1478,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
motg->phy_number = val;

+   motg->vdd_levels[VDD_LEVEL_NONE] = USB_PHY_SUSP_DIG_VOL;
+   motg->vdd_levels[VDD_LEVEL_MIN] = USB_PHY_VDD_DIG_VOL_MIN;
+   motg->vdd_levels[VDD_LEVEL_MAX] = USB_PHY_VDD_DIG_VOL_MAX;
+
+   if (of_get_property(node, "qcom,vdd-levels", &len) &&
+   len == sizeof(tmp)) {
+   of_property_read_u32_array(node, "qcom,vdd-levels",
+  tmp, len / sizeof(*tmp));
+   motg->vdd_levels[VDD_LEVEL_NONE] = tmp[VDD_LEVEL_NONE];
+   motg->vdd_levels[VDD_L

[PATCH v8 09/20] usb: phy: msm: Remove unused pclk_src_name

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

There are no references to 'pclk_src_name' in plaform code,
so it is unused.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 26 +-
 include/linux/usb/msm_hsusb.h |  5 -
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7eb2abf..c2361bf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -464,9 +464,6 @@ static int msm_otg_suspend(struct msm_otg *motg)
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
msm_hsusb_ldo_set_mode(motg, 0);
@@ -496,9 +493,6 @@ static int msm_otg_resume(struct msm_otg *motg)
if (!atomic_read(&motg->in_lpm))
return 0;

-   if (!IS_ERR(motg->pclk_src))
-   clk_prepare_enable(motg->pclk_src);
-
clk_prepare_enable(motg->pclk);
clk_prepare_enable(motg->clk);
if (!IS_ERR(motg->core_clk))
@@ -1396,17 +1390,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 * If USB Core is running its protocol engine based on CORE CLK,
 * CORE CLK  must be running at >55Mhz for correct HSUSB
 * operation and USB core cannot tolerate frequency changes on
-* CORE CLK. For such USB cores, vote for maximum clk frequency
-* on pclk source
+* CORE CLK.
 */
-motg->pclk_src = ERR_PTR(-ENOENT);
-if (motg->pdata->pclk_src_name) {
-   motg->pclk_src = devm_clk_get(&pdev->dev,
-   motg->pdata->pclk_src_name);
-   if (IS_ERR(motg->pclk_src))
-   return PTR_ERR(motg->pclk_src);
-   }
-
motg->pclk = devm_clk_get(&pdev->dev, "usb_hs_pclk");
if (IS_ERR(motg->pclk)) {
dev_err(&pdev->dev, "failed to get usb_hs_pclk\n");
@@ -1446,10 +1431,6 @@ static int msm_otg_probe(struct platform_device *pdev)
motg->v1p8  = regs[2].consumer;

clk_set_rate(motg->clk, 6000);
-   if (!IS_ERR(motg->pclk_src)) {
-   clk_set_rate(motg->pclk_src, INT_MAX);
-   clk_prepare_enable(motg->pclk_src);
-   }

clk_prepare_enable(motg->clk);
clk_prepare_enable(motg->pclk);
@@ -1525,8 +1506,6 @@ disable_clks:
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
return ret;
 }

@@ -1571,9 +1550,6 @@ static int msm_otg_remove(struct platform_device *pdev)
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
msm_hsusb_ldo_init(motg, 0);

pm_runtime_set_suspended(&pdev->dev);
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 72c5830..262ed80 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -106,8 +106,6 @@ enum usb_chg_type {
  * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  * @mode: Supported mode (OTG/peripheral/host).
  * @otg_control: OTG switch controlled by user/Id pin
- * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
- *  dfab_usb_hs_clk in case of 8660 and 8960.
  */
 struct msm_otg_platform_data {
int *phy_init_seq;
@@ -117,7 +115,6 @@ struct msm_otg_platform_data {
enum otg_control_type otg_control;
enum msm_usb_phy_type phy_type;
void (*setup_gpio)(enum usb_otg_state state);
-   char *pclk_src_name;
int (*link_clk_reset)(struct clk *link_clk, bool assert);
int (*phy_clk_reset)(struct clk *phy_clk);
 };
@@ -129,7 +126,6 @@ struct msm_otg_platform_data {
  * @irq: IRQ number assigned for HSUSB controller.
  * @clk: clock struct of usb_hs_clk.
  * @pclk: clock struct of usb_hs_pclk.
- * @pclk_src: pclk source for voting.
  * @phy_reset_clk: clock struct of usb_phy_clk.
  * @core_clk: clock struct of usb_hs_core_clk.
  * @regs: ioremapped register base address.
@@ -150,7 +146,6 @@ struct msm_otg {
int irq;
struct clk *clk;
struct clk *pclk;
-   struct clk *pclk_src;
struct clk *phy_reset_clk;
struct clk *core_clk;
void __iomem *regs;
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 11/20] usb: phy: msm: Properly check result from platform_get_irq()

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Function return negative code on error.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index bd9e286..7e968aa 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1413,7 +1413,7 @@ static int msm_otg_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
-   if (!motg->irq) {
+   if (motg->irq < 0) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
return motg->irq;
}
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 07/20] usb: phy: msm: Fix checkpatch.pl warnings

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: quoted string split across lines
WARNING: Prefer seq_puts to seq_printf

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index d7b8360..874c51a 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
}

@@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
@@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 3p3\n");
+   dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
goto exit;
}
rc = regulator_enable(motg->v3p3);
@@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 1p8\n");
+   dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
@@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set HPM for v1p8\n");
return ret;
}
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set HPM for v3p3\n");
regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
return ret;
@@ -154,13 +148,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set LPM for v1p8\n");
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set LPM for v3p3\n");
}

pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
@@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int 
high)

ret = regulator_set_voltage(motg->vddcx, 

[PATCH v8 13/20] usb: phy: msm: Use reset framework for LINK and PHY resets

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using reset framework eliminate need of platform specific
callbacks and enable reset lines to be specified in DT files.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 29 +
 include/linux/usb/msm_hsusb.h |  3 +++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 1bf2d4e..a6abb1b 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg)

 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->link_clk_reset)
-   return ret;
+   if (motg->pdata->link_clk_reset)
+   ret = motg->pdata->link_clk_reset(motg->clk, assert);
+   else if (assert)
+   ret = reset_control_assert(motg->link_rst);
+   else
+   ret = reset_control_deassert(motg->link_rst);

-   ret = motg->pdata->link_clk_reset(motg->clk, assert);
if (ret)
dev_err(motg->phy.dev, "usb link clk reset %s failed\n",
assert ? "assert" : "deassert");
@@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, 
bool assert)

 static int msm_otg_phy_clk_reset(struct msm_otg *motg)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->phy_clk_reset)
-   return ret;
+   if (motg->pdata->phy_clk_reset)
+   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
+   else
+   ret = reset_control_reset(motg->phy_rst);

-   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
dev_err(motg->phy.dev, "usb phy clk reset failed\n");

@@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
id = of_match_device(msm_otg_dt_match, &pdev->dev);
pdata->phy_type = (int) id->data;

+   motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
+   if (IS_ERR(motg->link_rst))
+   return PTR_ERR(motg->link_rst);
+
+   motg->phy_rst = devm_reset_control_get(&pdev->dev, "phy");
+   if (IS_ERR(motg->phy_rst))
+   return PTR_ERR(motg->phy_rst);
+
pdata->mode = of_usb_get_dr_mode(node);
if (pdata->mode == USB_DR_MODE_UNKNOWN)
pdata->mode = USB_DR_MODE_OTG;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index bd68299..4e5d916 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -165,6 +165,9 @@ struct msm_otg {
struct regulator *v3p3;
struct regulator *v1p8;
struct regulator *vddcx;
+
+   struct reset_control *phy_rst;
+   struct reset_control *link_rst;
 };

 #endif
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 12/20] usb: phy: msm: Add device tree support and binding information

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allows controller to be specified via device tree.

Signed-off-by: Ivan T. Ivanov 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  67 
 drivers/usb/phy/phy-msm-usb.c  | 113 +
 include/linux/usb/msm_hsusb.h  |   6 +-
 3 files changed, 165 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 5ea26c6..ee4123d 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -15,3 +15,70 @@ Example EHCI controller device node:
usb-phy = <&usb_otg>;
};

+USB PHY with optional OTG:
+
+Required properties:
+- compatible:   Should contain:
+  "qcom,usb-otg-ci" for chipsets with ChipIdea 45nm PHY
+  "qcom,usb-otg-snps" for chipsets with Synopsys 28nm PHY
+
+- regs: Offset and length of the register set in the memory map
+- interrupts:   interrupt-specifier for the OTG interrupt.
+
+- clocks:   A list of phandle + clock-specifier pairs for the
+clocks listed in clock-names
+- clock-names:  Should contain the following:
+  "phy" USB PHY reference clock
+  "core"Protocol engine clock
+  "iface"   Interface bus clock
+  "alt_core"Protocol engine clock for targets with asynchronous
+reset methodology. (optional)
+
+- vdccx-supply: phandle to the regulator for the vdd supply for
+digital circuit operation.
+- v1p8-supply:  phandle to the regulator for the 1.8V supply
+- v3p3-supply:  phandle to the regulator for the 3.3V supply
+
+- resets:   A list of phandle + reset-specifier pairs for the
+resets listed in reset-names
+- reset-names:  Should contain the following:
+  "phy" USB PHY controller reset
+  "link"USB LINK controller reset
+
+- qcom,otg-control: OTG control (VBUS and ID notifications) can be one of
+1 - PHY control
+2 - PMIC control
+
+Optional properties:
+- dr_mode:  One of "host", "peripheral" or "otg". Defaults to "otg"
+
+- qcom,phy-init-sequence: PHY configuration sequence values. This is related 
to Device
+Mode Eye Diagram test. Start address at which these values 
will be
+written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as
+"do not overwrite default value at this address".
+For example: qcom,phy-init-sequence = < -1 0x63 >;
+Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.
+
+Example HSUSB OTG controller device node:
+
+usb@f9a55000 {
+compatible = "qcom,usb-otg-snps";
+reg = <0xf9a55000 0x400>;
+interrupts = <0 134 0>;
+dr_mode = "peripheral";
+
+clocks = <&gcc GCC_XO_CLK>, <&gcc GCC_USB_HS_SYSTEM_CLK>,
+<&gcc GCC_USB_HS_AHB_CLK>;
+
+clock-names = "phy", "core", "iface";
+
+vddcx-supply = <&pm8841_s2_corner>;
+v1p8-supply = <&pm8941_l6>;
+v3p3-supply = <&pm8941_l24>;
+
+resets = <&gcc GCC_USB2A_PHY_BCR>, <&gcc GCC_USB_HS_BCR>;
+reset-names = "phy", "link";
+
+qcom,otg-control = <1>;
+qcom,phy-init-sequence = < -1 0x63 >;
+   };
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7e968aa..1bf2d4e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -30,9 +30,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,16 +220,16 @@ static struct usb_phy_io_ops msm_otg_io_ops = {
 static void ulpi_init(struct msm_otg *motg)
 {
struct msm_otg_platform_data *pdata = motg->pdata;
-   int *seq = pdata->phy_init_seq;
+   int *seq = pdata->phy_init_seq, idx;
+   u32 addr = ULPI_EXT_VENDOR_SPECIFIC;

-   if (!seq)
-   return;
+   for (idx = 0; idx < pdata->phy_init_sz; idx++) {
+   if (seq[idx] == -1)
+   continue;

-   while (seq[0] >= 0) {
dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
-   seq[0], seq[1]);
-   ulpi_write(&motg->phy, seq[0], seq[1]);
-   seq += 2;
+   seq[idx], addr + idx);
+   ulpi_write(&motg->phy, seq[idx], addr + idx);
}
 }

@@ -1343,26 +1346,96 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_r

[PATCH v8 00/20] usb: phy: msm: Fixes, cleanups and DT support

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Hi,

This is a new version of patches posted earlier[1].

Changes since v7

 - Use bulk regulator request function in patch #05
 - Fix errors in patch #20 commit message

[1] http://www.spinics.net/lists/linux-arm-msm/msg08997.html

Ivan T. Ivanov (18):
  usb: phy: msm: Make driver selectable on ARCH_QCOM
  usb: phy: msm: Remove __init macro from driver probe method
  usb: phy: msm: Move global regulators variables to driver state
  usb: phy: msm: Enable deferred driver probing
  usb: phy: msm: Migrate to Managed Device Resource allocation
  usb: phy: msm: Remove unnecessarily check for valid regulators.
  usb: phy: msm: Fix checkpatch.pl warnings
  usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
  usb: phy: msm: Remove unused pclk_src_name
  usb: phy: msm: Remove HSUSB prefix from regulator names
  usb: phy: msm: Properly check result from platform_get_irq()
  usb: phy: msm: Add device tree support and binding information
  usb: phy: msm: Use reset framework for LINK and PHY resets
  usb: phy: msm: Add support for secondary PHY control
  usb: phy: msm: Correct USB PHY Reset sequence for newer platform
  usb: phy: msm: Handle disconnect events
  usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX
  usb: phy: msm: Use usb_add_phy_dev() to register device

Tim Bird (2):
  usb: phy: msm: Fix PTS definitions for MSM USB controller
  usb: phy: msm: Select secondary PHY via TCSR

 .../devicetree/bindings/usb/msm-hsusb.txt  |  78 +++
 arch/arm/mach-msm/board-msm7x30.c  |   2 +-
 arch/arm/mach-msm/board-qsd8x50.c  |   2 +-
 drivers/usb/phy/Kconfig|   6 +-
 drivers/usb/phy/phy-msm-usb.c  | 700 -
 include/linux/usb/msm_hsusb.h  |  39 +-
 include/linux/usb/msm_hsusb_hw.h   |  14 +-
 7 files changed, 504 insertions(+), 337 deletions(-)

--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 15/20] usb: phy: msm: Correct USB PHY Reset sequence for newer platform

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

On few legacy platforms, USB PHY is having dedicated reset clk.
It is used to reset USB PHY after putting USB PHY into low power
mode and for calibration of USB PHY. Putting USB PHY into low
power mode is causing ulpi read/write timeout as expected. USB PHY
reset clk is not available on newer platform.

For 28nm PHY, reset USB PHY after resetting USB LINK.
Also reset USB PHY using USB_PHY_PON bit with USB_OTG_HS_PHY_CTRL
register after programming USB PHY Override registers as suggested
with hardware programming guidelines.

Signed-off-by: Ivan T. Ivanov 
Signed-off-by: Tim Bird 
Cc: Mayank Rana 
---
 drivers/usb/phy/phy-msm-usb.c| 140 ---
 include/linux/usb/msm_hsusb_hw.h |   5 ++
 2 files changed, 93 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8d57045..bb33996 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -48,6 +48,7 @@
 #define DRIVER_NAME"msm_otg"

 #define ULPI_IO_TIMEOUT_USEC   (10 * 1000)
+#define LINK_RESET_TIMEOUT_USEC(250 * 1000)

 #define USB_PHY_3P3_VOL_MIN305 /* uV */
 #define USB_PHY_3P3_VOL_MAX330 /* uV */
@@ -267,77 +268,35 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg)
return ret;
 }

-static int msm_otg_phy_reset(struct msm_otg *motg)
+static int msm_link_reset(struct msm_otg *motg)
 {
u32 val;
int ret;
-   int retries;

ret = msm_otg_link_clk_reset(motg, 1);
if (ret)
return ret;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   ret = msm_otg_link_clk_reset(motg, 0);
-   if (ret)
-   return ret;

-   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
-
-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_write(&motg->phy, ULPI_FUNC_CTRL_SUSPENDM,
-   ULPI_CLR(ULPI_FUNC_CTRL));
-   if (!ret)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
+   /* wait for 1ms delay as suggested in HPG. */
+   usleep_range(1000, 1200);

-   /* This reset calibrates the phy, if the above write succeeded */
-   ret = msm_otg_phy_clk_reset(motg);
+   ret = msm_otg_link_clk_reset(motg, 0);
if (ret)
return ret;

-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_read(&motg->phy, ULPI_DEBUG);
-   if (ret != -ETIMEDOUT)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
-
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

-   dev_info(motg->phy.dev, "phy_reset: success\n");
+   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
+   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+
return 0;
 }

-#define LINK_RESET_TIMEOUT_USEC(250 * 1000)
 static int msm_otg_reset(struct usb_phy *phy)
 {
struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
-   struct msm_otg_platform_data *pdata = motg->pdata;
int cnt = 0;
-   int ret;
-   u32 val = 0;
-   u32 ulpi_val = 0;
-
-   ret = msm_otg_phy_reset(motg);
-   if (ret) {
-   dev_err(phy->dev, "phy_reset failed\n");
-   return ret;
-   }
-
-   ulpi_init(motg);

writel(USBCMD_RESET, USB_USBCMD);
while (cnt < LINK_RESET_TIMEOUT_USEC) {
@@ -351,11 +310,86 @@ static int msm_otg_reset(struct usb_phy *phy)

/* select ULPI phy */
writel(0x8000, USB_PORTSC);
+   writel(0x0, USB_AHBBURST);
+   writel(0x08, USB_AHBMODE);
+
+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+   return 0;
+}
+
+static void msm_phy_reset(struct msm_otg *motg)
+{
+   void __iomem *addr;
+
+   if (motg->pdata->phy_type != SNPS_28NM_INTEGRATED_PHY) {
+   msm_otg_phy_clk_reset(motg);
+   return;
+   }
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
+   /* Assert USB PHY_POR */
+   writel(readl(addr) | PHY_POR_ASSERT, addr);
+
+   /*
+* wait for minimum 10 microseconds as suggested in HPG.
+* Use a slightly larger value since the exact value didn't
+* work 100% of the time.
+*/
+   udelay(12);
+
+   /* Deassert USB PHY_POR */
+   writel(readl(addr) & ~PHY_POR_ASSERT, addr);
+}
+
+

[PATCH v8 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Move memory, regulators, clocks and irq allocation to
devm_* variants. Properly check for valid clk handles.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 187 +++---
 1 file changed, 68 insertions(+), 119 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index b7d73f2..67705fc 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
int ret = 0;

if (init) {
-   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(motg->vddcx)) {
-   dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(motg->vddcx);
-   }
-
ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(motg->vddcx);
return ret;
}

ret = regulator_enable(motg->vddcx);
-   if (ret) {
+   if (ret)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(motg->vddcx);
-   }
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
-
-   regulator_put(motg->vddcx);
}

return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(motg->v3p3)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(motg->v3p3);
-   }
-
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
-   goto put_3p3;
+   goto exit;
}
rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
-   goto put_3p3;
-   }
-   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(motg->v1p8)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(motg->v1p8);
-   goto disable_3p3;
+   goto exit;
}
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}

return 0;
}

regulator_disable(motg->v1p8);
-put_1p8:
-   regulator_put(motg->v1p8);
 disable_3p3:
regulator_disable(motg->v3p3);
-put_3p3:
-   regulator_put(motg->v3p3);
+exit:
return rc;
 }

@@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg)

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
-   if (motg->core_clk)
+   if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

if (!IS_ERR(motg->pclk_src))
@@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg)

clk_prepare_enable(motg->pclk);
cl

[PATCH v8 08/20] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Use enum usb_dr_mode and drop default usb_dr_mode from platform data.

USB DT bindings states: dr_mode: "...In case this attribute isn't
passed via DT, USB DRD controllers should default to OTG...",
so remove redundand field.

Signed-off-by: Ivan T. Ivanov 
Acked-by: David Brown 
---
 arch/arm/mach-msm/board-msm7x30.c |  2 +-
 arch/arm/mach-msm/board-qsd8x50.c |  2 +-
 drivers/usb/phy/phy-msm-usb.c | 41 ---
 include/linux/usb/msm_hsusb.h | 20 +--
 4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-msm/board-msm7x30.c 
b/arch/arm/mach-msm/board-msm7x30.c
index 46de789..0c4c200 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/arch/arm/mach-msm/board-qsd8x50.c 
b/arch/arm/mach-msm/board-qsd8x50.c
index 9169ec3..4c74861 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 874c51a..7eb2abf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -348,10 +348,10 @@ static int msm_otg_reset(struct usb_phy *phy)

if (pdata->otg_control == OTG_PHY_CONTROL) {
val = readl(USB_OTGSC);
-   if (pdata->mode == USB_OTG) {
+   if (pdata->mode == USB_DR_MODE_OTG) {
ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID;
val |= OTGSC_IDIE | OTGSC_BSVIE;
-   } else if (pdata->mode == USB_PERIPHERAL) {
+   } else if (pdata->mode == USB_DR_MODE_PERIPHERAL) {
ulpi_val = ULPI_INT_SESS_VALID;
val |= OTGSC_BSVIE;
}
@@ -637,7 +637,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Fail host registration if this board can support
 * only peripheral configuration.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
dev_info(otg->phy->dev, "Host mode is not supported\n");
return -ENODEV;
}
@@ -666,7 +666,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Kick the state machine work, if peripheral is not supported
 * or peripheral is already registered with us.
 */
-   if (motg->pdata->mode == USB_HOST || otg->gadget) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -710,7 +710,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Fail peripheral registration if this board can support
 * only host configuration.
 */
-   if (motg->pdata->mode == USB_HOST) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST) {
dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
return -ENODEV;
}
@@ -735,7 +735,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Kick the state machine work, if host is not supported
 * or host is already registered with us.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL || otg->host) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -1056,7 +1056,7 @@ static void msm_otg_init_sm(struct msm_otg *motg)
u32 otgsc = readl(USB_OTGSC);

switch (pdata->mode) {
-   case USB_OTG:
+   case USB_DR_MODE_OTG:
if (pdata->otg_control == OTG_PHY_CONTROL) {
if (otgsc & OTGSC_ID)
set_bit(ID, &motg->inpu

[PATCH v8 01/20] usb: phy: msm: Make driver selectable on ARCH_QCOM

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Controller could be found on APQ and MSM platforms,
make configuration description more generic.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 416e0c8..0c668a3 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -171,11 +171,11 @@ config USB_ISP1301
  module will be called phy-isp1301.

 config USB_MSM_OTG
-   tristate "OTG support for Qualcomm on-chip USB controller"
-   depends on (USB || USB_GADGET) && ARCH_MSM
+   tristate "Qualcomm on-chip USB OTG controller support"
+   depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
select USB_PHY
help
- Enable this to support the USB OTG transceiver on MSM chips. It
+ Enable this to support the USB OTG transceiver on Qualcomm chips. It
  handles PHY initialization, clock management, and workarounds
  required after resetting the hardware and power management.
  This driver is required even for peripheral only or host only
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 03/20] usb: phy: msm: Move global regulators variables to driver state

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Eliminating global variables allows driver to handle multiple
device instances.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 82 ---
 include/linux/usb/msm_hsusb.h |  3 ++
 2 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6ae4d2f..6bae936 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -58,47 +58,43 @@
 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */

-static struct regulator *hsusb_3p3;
-static struct regulator *hsusb_1p8;
-static struct regulator *hsusb_vddcx;
-
 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
int ret = 0;

if (init) {
-   hsusb_vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(hsusb_vddcx)) {
+   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+   if (IS_ERR(motg->vddcx)) {
dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(hsusb_vddcx);
+   return PTR_ERR(motg->vddcx);
}

-   ret = regulator_set_voltage(hsusb_vddcx,
+   ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
return ret;
}

-   ret = regulator_enable(hsusb_vddcx);
+   ret = regulator_enable(motg->vddcx);
if (ret) {
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}
} else {
-   ret = regulator_set_voltage(hsusb_vddcx, 0,
+   ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   ret = regulator_disable(hsusb_vddcx);
+   ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");

-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}

return ret;
@@ -109,38 +105,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   hsusb_3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(hsusb_3p3)) {
+   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
+   if (IS_ERR(motg->v3p3)) {
dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(hsusb_3p3);
+   return PTR_ERR(motg->v3p3);
}

-   rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN,
+   rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
goto put_3p3;
}
-   rc = regulator_enable(hsusb_3p3);
+   rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
goto put_3p3;
}
-   hsusb_1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(hsusb_1p8)) {
+   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
+   if (IS_ERR(motg->v1p8)) {
dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(hsusb_1p8);
+   rc = PTR_ERR(motg->v1p8);
goto disable_3p3;
}
-   rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN,
+   rc = regulator_set_voltag

[PATCH v8 04/20] usb: phy: msm: Enable deferred driver probing

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using platform_driver_probe() prevent driver from requesting
probe deferral. Fix this.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6bae936..b7d73f2 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1736,6 +1736,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
 };

 static struct platform_driver msm_otg_driver = {
+   .probe = msm_otg_probe,
.remove = msm_otg_remove,
.driver = {
.name = DRIVER_NAME,
@@ -1744,7 +1745,7 @@ static struct platform_driver msm_otg_driver = {
},
 };

-module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
+module_platform_driver(msm_otg_driver);

 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM USB transceiver driver");
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 06/20] usb: phy: msm: Remove unnecessarily check for valid regulators.

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Whether regulators are available or not is checked at driver
probe. If they are not available driver will refuse to load,
so no need to check them again.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 67705fc..d7b8360 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -133,16 +133,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
 {
int ret = 0;

-   if (!motg->v1p8 || IS_ERR(motg->v1p8)) {
-   pr_err("%s: HSUSB_1p8 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
-   if (!motg->v3p3 || IS_ERR(motg->v3p3)) {
-   pr_err("%s: HSUSB_3p3 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
if (on) {
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
--
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 03:10 +, Peter Chen wrote:
>  
> > 
> > On Thu, 2014-04-24 at 08:38 +0800, Peter Chen wrote:
> > > On Wed, Apr 23, 2014 at 03:28:01PM +0300, Ivan T. Ivanov wrote:
> > > > From: "Ivan T. Ivanov" 
> > > >
> > > > This series intend to fix driver, which was broken for a while.
> > > > It is used to create peripheral role device, which in coordination
> > > > with phy-usb-msm driver could provide USB2.0 gadget support for
> > > > Qualcomm targets.
> > > >
> > > > Changes since version 3.
> > > >
> > > >  - Fix typo in devicetree description file.
> > > >
> > > > Previews version can be found here:
> > >
> > > Since in your phy's patchset, you also access portsc which is in
> > > chipidea register region, it is not a standard way.
> > > In case, you will change something at chipidea driver in future when
> > > you re-work your next revision phy's patchset, I do not send this
> > > patchset to Greg right now.
> > >
> > 
> > Did you see problems with _this_ particular patch set? There is no direct
> > dependency between PHY patches and these changes.
> > 
>  
> I have not seen problems for this patch set, if you make sure the current
> phy operation (eg, "phy_type) at chipidea core does not affect you,
> I am glad to accept this.

You mean phy_mode? Peripheral functionality is tested on top of
current linus/master and it looks fine.

Regards,
Ivan

> 
> Peter
> NrybXǧv^)޺{.n+{zXܨ}Ơz&j:+vzZ++zfh~izw?&)ߢf^jǫym@Aa0hi


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote:
> On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote:
> > 
> > >From: "Ivan T. Ivanov" 
> > 
> > >This fixes following:
> > 
> > >WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in 
> > >reference from the variable msm_otg_driver to the function 
> > >.init.text:msm_otg_probe()
> > >The variable msm_otg_driver references
> > >the function __init msm_otg_probe()
> > 
> >Hm, this warning shouldn't occur before patch #4, no?
> 
> good catch, this could probably be merged there.

True. Should I resend it?

Regards,
Ivan


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
On Mon, 2014-04-28 at 12:54 -0500, Felipe Balbi wrote:
> On Mon, Apr 28, 2014 at 08:52:48PM +0300, Ivan T. Ivanov wrote:
> > On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote:
> > > On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote:
> > > > Hello.
> > > > 
> > > > On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote:
> > > > 
> > > > >From: "Ivan T. Ivanov" 
> > > > 
> > > > >This fixes following:
> > > > 
> > > > >WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in 
> > > > >reference from the variable msm_otg_driver to the function 
> > > > >.init.text:msm_otg_probe()
> > > > >The variable msm_otg_driver references
> > > > >the function __init msm_otg_probe()
> > > > 
> > > >Hm, this warning shouldn't occur before patch #4, no?
> > > 
> > > good catch, this could probably be merged there.
> > 
> > True. Should I resend it?
> 
> hold on, that's simple enough to sort out while applying. Unless there
> are any other big comments with your series, no need to resend.

Sure, I will wait for more comments.

Thanks,
Ivan

> 
> cheers
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-28 Thread Ivan T. Ivanov
On Tue, 2014-04-29 at 08:45 +0800, Peter Chen wrote:

> 
> Applied, thanks

Thank you,
Ivan



--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v7 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-05-01 Thread Ivan T. Ivanov
On Wed, 2014-04-30 at 11:27 -0500, Felipe Balbi wrote:
> On Thu, Apr 24, 2014 at 06:48:11PM +0300, Ivan T. Ivanov wrote:
> > From: Tim Bird 
> > 
> > Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB
> > controller.  This is a standard chipidea PORTSC definition, where
> > a PHY_TYPE of 10b (<<30) is ULPI and 11b (<<30) is SERIAL.
> > Fix the definitions and use them correctly in the driver code.
> > 
> > Signed-off-by: Tim Bird 
> 
> since you're the one sending the patch, you must add your signed-off-by
> too. If you reply with your SoB I'll add to proper patches.
> 

Sure. 

Signed-of-by: Ivan T. Ivanov 

Thanks.


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: qup: Fix pm_runtime_get_sync usage

2014-05-02 Thread Ivan T. Ivanov
On Fri, 2014-05-02 at 20:54 -0500, Andy Gross wrote:
> This patch corrects the error check on the call to pm_runtime_get_sync.
> 
> Signed-off-by: Andy Gross 


Reviewed-by: Ivan T. Ivanov 

> ---
>  drivers/i2c/busses/i2c-qup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index 1b4cf14..2a5efb5 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -479,7 +479,7 @@ static int qup_i2c_xfer(struct i2c_adapter *adap,
>   int ret, idx;
>  
>   ret = pm_runtime_get_sync(qup->dev);
> - if (ret)
> + if (ret < 0)
>   goto out;
>  
>   writel(1, qup->base + QUP_SW_RESET);


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 17/20] usb: phy: msm: Select secondary PHY via TCSR

2014-05-02 Thread Ivan T. Ivanov
On Mon, 2014-04-28 at 16:34 +0300, Ivan T. Ivanov wrote:
> From: Tim Bird 
> 
> Select the secondary PHY using the TCSR register, if phy-num=1
> in the DTS (or phy_number is set in the platform data).  The
> SOC has 2 PHYs which can be used with the OTG port, and this
> code allows configuring the correct one.
> 
> Note: This resolves the problem I was seeing where I couldn't
> get the USB driver working at all on a dragonboard, from cold
> boot.  This patch depends on patch 5/14 from Ivan's msm USB
> patch set.  It does not use DT for the register address, as
> there's no evidence that this address changes between SoC
> versions.
> 
> Signed-off-by: Tim Bird 

Missed this:

Signed-of-by: Ivan T. Ivanov 

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/3] usb: phy: msm: cast to unsigned long int

2014-05-02 Thread Ivan T. Ivanov
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote:
> this solves the following build warning found when
> running compile tests.
> 
> drivers/usb/phy/phy-msm-usb.c: In function ‘msm_otg_read_dt’:
> drivers/usb/phy/phy-msm-usb.c:1459:20: warning: cast from pointer \
>   to integer of different size [-Wpointer-to-int-cast]
>   pdata->phy_type = (int) id->data;
> ^
> Signed-off-by: Felipe Balbi 
> ---
> 
> all patches are on top of Ivan's 20 patch series.
> 
>  drivers/usb/phy/phy-msm-usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index 9dc7918..c9963c8 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -1456,7 +1456,7 @@ static int msm_otg_read_dt(struct platform_device 
> *pdev, struct msm_otg *motg)
>   motg->pdata = pdata;
>  
>   id = of_match_device(msm_otg_dt_match, &pdev->dev);
> - pdata->phy_type = (int) id->data;
> + pdata->phy_type = (unsigned long int) id->data;

Probably cast to enum msm_usb_phy_type will be better.

Regards,
Ivan

>  
>   motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
>   if (IS_ERR(motg->link_rst))


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] usb: phy: msm: switch over to writel()

2014-05-02 Thread Ivan T. Ivanov
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote:
> Remove that single instance of writel_relaxed()
> call which is only available on ARM architecture.
> 
> This will let us build test this driver on all
> different architectures.
> 
> Signed-off-by: Felipe Balbi 

Reviewed-by: Ivan T. Ivanov 

> ---
>  drivers/usb/phy/phy-msm-usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index c9963c8..13b59ad 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -1600,7 +1600,7 @@ static int msm_otg_probe(struct platform_device *pdev)
>   if (IS_ERR(phy_select))
>   return PTR_ERR(phy_select);
>   /* Enable second PHY with the OTG port */
> - writel_relaxed(0x1, phy_select);
> + writel(0x1, phy_select);
>   }
>  
>   dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] usb: phy: msm: enable build on other architectures

2014-05-03 Thread Ivan T. Ivanov
On Wed, 2014-04-30 at 11:38 -0500, Felipe Balbi wrote:
> By adding COMPILE_TEST to the list of dependencies
> we can build test this driver on all other architectures
> which is very valuable for maintainers applying patches
> and to find silly mistakes during development.
> 
> Signed-off-by: Felipe Balbi 

Reviewed-by: Ivan T. Ivanov 

> ---
>  drivers/usb/phy/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
> index 0c668a3..fbbced8 100644
> --- a/drivers/usb/phy/Kconfig
> +++ b/drivers/usb/phy/Kconfig
> @@ -172,7 +172,7 @@ config USB_ISP1301
>  
>  config USB_MSM_OTG
>   tristate "Qualcomm on-chip USB OTG controller support"
> - depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
> + depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM || 
> COMPILE_TEST)
>   select USB_PHY
>   help
> Enable this to support the USB OTG transceiver on Qualcomm chips. It


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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] mfd: pm8x41: add support for Qualcomm 8x41 PMICs

2014-05-09 Thread Ivan T. Ivanov

Hi, 

On Thu, 2014-04-24 at 13:18 -0500, Josh Cartwright wrote:
> On Wed, Apr 23, 2014 at 04:36:22PM -0700, Courtney Cavin wrote:
> > On Wed, Apr 23, 2014 at 11:46:26PM +0200, Josh Cartwright wrote:
> > > On Tue, Apr 22, 2014 at 05:31:49PM -0700, Courtney Cavin wrote:
> [..]


> 
>   $ git grep spmi-slave-container arch/arm/boot/dts
>   arch/arm/boot/dts/qcom/msm-pm8019.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8019.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8110.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8110.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8226.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8226.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8841.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8841.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8916.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8916.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8941.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pm8941.dtsi: spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pma8084.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pma8084.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmd9635.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmd9635.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmi8962.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmi8962.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmiplutonium.dtsi:   
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmiplutonium.dtsi:   
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmplutonium.dtsi:
> spmi-slave-container;
>   arch/arm/boot/dts/qcom/msm-pmplutonium.dtsi:
> spmi-slave-container;
> 
> [..]
> > > > +static const struct of_device_id pm8x41_id_table[] = {
> > > > +   { .compatible = "qcom,pm8841", },
> > > > +   { .compatible = "qcom,pm8941", },
> > > > +   {},
> > > > +};
> > > > +MODULE_DEVICE_TABLE(of, pm8x41_id_table);
> > > 
> > > I'm thinking we should probably have a generic compatible entry as well,
> > > "qcom,pmic-qpnp" or similar.  We should still specify in the binding
> > > that PMIC slaves specify a version-specific string as well as the
> > > generic string.  That is, a slave should have:
> > > 
> > >   compatible = "qcom,pm8841", "qcom,pmic-qpnp";
> > > 
> > > ...in case we would ever need to differentiate in the future.
> > > 
> > > (I recall that in a previous version I had done this, but I don't
> > > remember why I had changed it..)
> >
> > I gave this some thought but came to the conclusion that there is no
> > benefit of adding a generic compatible to a new binding.  Please clarify
> > a use-case where this would be ... useful.
> 
> Having a generic compatible entry allows for easily supporting new PMICs
> without having to add yet another vacuous entry in the ID table.  In
> this case I think it's perfectly acceptable given that this driver isn't
> really defining a programming model for a specific device, but rather
> acting much more like a bus.
> 
> Requiring a specific PMIC listed before a generic one allows us an
> escape hatch in the future if for some reason we need to add a quirk for
> a specific PMIC.

Is there a conclusion on this issue? I am voting for generic name :-)
"qcom,pm-qpnp".

Further complication is that several sub function drivers expect to
runtime detect the exact version of the controller ("qcom, qpnp-iadc",
"qcom, qpnp-vadc", "qcom, qpnp-linear-charger").  This is realized by the
exported function of the driver "qcom, qpnp-revid". Would it be good
idea to merge qpnp-revid and "qcom,pm-qpnp" driver?

Regards,
Ivan

> 
>   Josh
> 
> [1]: git://codeaurora.org/quic/la/kernel/msm-3.10#msm-3.10
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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] mfd: pm8x41: add support for Qualcomm 8x41 PMICs

2014-05-10 Thread Ivan T. Ivanov

Hi Courtney,

On Fri, 2014-05-09 at 13:30 -0700, Courtney Cavin wrote:

> > > Requiring a specific PMIC listed before a generic one allows us an
> > > escape hatch in the future if for some reason we need to add a quirk for
> > > a specific PMIC.
> > 
> > Is there a conclusion on this issue? I am voting for generic name :-)
> > "qcom,pm-qpnp".
> 
> Josh and I have discussed this offline, and I think we have come to the
> conclusion that this should be a generic driver with only a generic
> binding.  The current proposed name is "spmi-ext", as there is specific
> functional relation to Qualcomm, PMICs or QPNP.
> 
> Further, the binding documentation should be specific to pm8[89]41 as
> 'mfd/pm8x41.txt', and should contain the compatibles:
>   - "qcom,pm8941", "spmi-ext"
>   - "qcom,pm8841", "spmi-ext"
> 
> This naming has been discussed to death, so a few more shed color
> suggestions can't possibly hurt.

I am fine with this. Thanks.

> 
> > Further complication is that several sub function drivers expect to
> > runtime detect the exact version of the controller ("qcom, qpnp-iadc",
> > "qcom, qpnp-vadc", "qcom, qpnp-linear-charger").  This is realized by the
> > exported function of the driver "qcom, qpnp-revid". Would it be good
> > idea to merge qpnp-revid and "qcom,pm-qpnp" driver?
> 
> Each block within the PMICs have--undocumented--version registers, so a
> global version number is not particularly useful.  A good example of
> this is the ADC code [1], as you mentioned.

Do you happen to know how to match local subdevices revisions to global 
PMIC revision? Earlier mentioned drivers are using global chip revision. 

I will not be surprised if local subdevice version is not changed, but
instead global version is changed, when only subdevice functionality is 
changed ;-)

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] spi: qup: Correct selection of FIFO/Block mode

2014-05-19 Thread Ivan T. Ivanov
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch fixes the calculation for determining whether to use FIFO or BLOCK
> mode.



> @@ -368,7 +368,7 @@ static int spi_qup_io_config(struct spi_device *spi, 
> struct spi_transfer *xfer)
>   n_words = xfer->len / w_size;
>   controller->w_size = w_size;
>  
> - if (n_words <= controller->in_fifo_sz) {
> + if (n_words <= (controller->in_fifo_sz / sizeof(u32))) {

Wouldn't be better to divide by w_size? Probably will not make
too much difference, but..

>   mode = QUP_IO_M_MODE_FIFO;

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/4] spi: qup: Remove chip select function

2014-05-19 Thread Ivan T. Ivanov

Hi Andy,

On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch removes the chip select function.  Chip select should instead be
> supported using GPIOs, defining the DT entry "cs-gpios", and letting the SPI
> core assert/deassert the chip select as it sees fit.
> 
> Signed-off-by: Andy Gross 



> +- num-cs:total number of chipselects

My understanding is that "num-cs" have to be parsed by
master driver, not by core SPI driver.

> -
> - /* Disable auto CS toggle and use manual */
> - iocontol &= ~SPI_IO_C_MX_CS_MODE;

Probably we should keep this?

Regards,
Ivan

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] spi: qup: Add support for v1.1.1

2014-05-19 Thread Ivan T. Ivanov
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch adds support for v1.1.1 of the SPI QUP controller.
> 
> Signed-off-by: Andy Gross 

Except Stephen comment this looks fine. Thank you.

Acked-by: Ivan T. Ivanov 


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] spi: qup: Fix order of spi_register_master

2014-05-19 Thread Ivan T. Ivanov
On Tue, 2014-05-13 at 16:34 -0500, Andy Gross wrote:
> This patch moves the devm_spi_register_master below the initialization of the
> runtime_pm.  If done in the wrong order, the spi_register_master fails if any
> probed slave devices issue SPI transactions.
> 
> Signed-off-by: Andy Gross 

Thank you.

Acked-by: Ivan T. Ivanov 

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] arm: msm: remove board file for Nexus One (ie. mahimahi)

2014-05-19 Thread Ivan T. Ivanov
On Mon, 2014-05-19 at 14:30 +, dwal...@fifo99.com wrote:
> On Mon, May 19, 2014 at 01:53:28PM +0200, Paul Bolle wrote:



> 
> > Even the most dubious of code in drivers/staging is expected to "compile
> > properly"!
> 
> But mach-msm isn't staging, different rules apply there.

Heh, different rules you say: "Please send me a patches 
which even didn't compile". This is most relaxed reading
of Documentation/SubmittingPatches that I have heard :-)

Ivan

> 
> Daniel


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 4/4] ARM: debug: qcom: Add APQ8084 DEBUG_LL UART support

2014-05-21 Thread Ivan T. Ivanov
Hi, 

On Wed, 2014-05-21 at 17:18 +0200, Arnd Bergmann wrote:
> On Wednesday 21 May 2014 17:57:05 Georgi Djakov wrote:

> >  
> > +#ifdef CONFIG_DEBUG_APQ8084_UART
> > +#define MSM_DEBUG_UART_BASE0xFA75E000
> > +#define MSM_DEBUG_UART_PHYS0xF995E000
> > +#endif
> > +

> Maybe we should move debug/msm.S over to use
> CONFIG_DEBUG_UART_PHYS/CONFIG_DEBUG_UART_VIRT now?
> 

There is patch which do this [1]. It was reviewed 
by Stephen Boyd [2].

Regards,
Ivan


[1] https://lkml.org/lkml/2014/4/14/312
[2] https://lkml.org/lkml/2014/4/14/542



--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] spi: qup: Add SPI_CPOL configuration support

2014-12-16 Thread Ivan T. Ivanov
Device support SPI_CPOL, but driver have missed to add
support for this configuration.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/spi/spi-qup.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
index 390ed71..1c3329c 100644
--- a/drivers/spi/spi-qup.c
+++ b/drivers/spi/spi-qup.c
@@ -337,7 +337,7 @@ static irqreturn_t spi_qup_qup_irq(int irq, void *dev_id)
 static int spi_qup_io_config(struct spi_device *spi, struct spi_transfer *xfer)
 {
struct spi_qup *controller = spi_master_get_devdata(spi->master);
-   u32 config, iomode, mode;
+   u32 config, iomode, mode, control;
int ret, n_words, w_size;
 
if (spi->mode & SPI_LOOP && xfer->len > controller->in_fifo_sz) {
@@ -392,6 +392,15 @@ static int spi_qup_io_config(struct spi_device *spi, 
struct spi_transfer *xfer)
 
writel_relaxed(iomode, controller->base + QUP_IO_M_MODES);
 
+   control = readl_relaxed(controller->base + SPI_IO_CONTROL);
+
+   if (spi->mode & SPI_CPOL)
+   control |= SPI_IO_C_CLK_IDLE_HIGH;
+   else
+   control &= ~SPI_IO_C_CLK_IDLE_HIGH;
+
+   writel_relaxed(control, controller->base + SPI_IO_CONTROL);
+
config = readl_relaxed(controller->base + SPI_CONFIG);
 
if (spi->mode & SPI_LOOP)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/4] Support qcom GDSC hardware

2014-12-19 Thread Ivan T. Ivanov

On Tue, 2014-04-15 at 10:56 -0700, Stephen Boyd wrote:
> On 04/04/14 11:45, Stephen Boyd wrote:
> > These patches add support for the multimedia GDSCs on the
> > apq8074 dragonboard. The first two patches (and potentially the last)
> > should go through Mike's tree and the DTS patch should go through
> > the qcom tree. Patches are based on v3.14. The probe will conflict with
> > patches I sent to consolidate things. I'll rework these patches on top of
> > that if the gdsc.c file is acked/reviewed.
> 
> Any comments?
> 

Hi,

It will nice if we can progress on this. They are several drivers posted 
already which depends on these regulators, USB3.0 and PCIe, at least.

Thank you.
Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] leds: add Qualcomm PM8941 WLED driver

2014-12-19 Thread Ivan T. Ivanov

On Thu, 2014-12-18 at 15:43 -0800, Bjorn wrote:
> On Tue 16 Dec 16:54 PST 2014, Bryan Wu wrote:
> 
> > On Mon, Dec 8, 2014 at 4:22 PM, Bjorn Andersson
> 
> [..]
> 
> > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> 
> [..]
> 
> > > +config LEDS_PM8941_WLED
> > > +   tristate "LED support for the Qualcomm PM8941 WLED block"
> > > +   depends on LEDS_CLASS
> > > +   depends on REGMAP
> > Here should be "select REGMAP"
> > 
> 
> Thanks
> > > 


If not mistaken the correct way was:

depends on SPMI
select REGMAP_SPMI

or
depends on MFD_SPMI_PMIC

Regards,
Ivan

https://patchwork.kernel.org/patch/4566591/

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] spmi: pmic_arb: add support for hw version 2

2015-01-21 Thread Ivan T. Ivanov
Hi Gilad,

Just few comments.

On Mon, 2015-01-19 at 18:10 -0700, Gilad Avidov wrote:
> Qualcomm PMIC Arbiter version-2 changes from version-1 are:
> 
> - Some diffrent register offsets.
> - New channel register space, one per PMIC peripheral (ppid).
>   All tx tarffic uses these channels.
> - New observer register space. All rx trafic uses this space.
> - Diffrent command format for spmi command registers.
> 
> Signed-off-by: Gilad Avidov 
> Acked-by: Sagar Dharia 
> ---



> 
> +struct pmic_arb_ver;
> +

Is there a better name for this structure. Ok it contain version
information, but.

>  /**
>   * spmi_pmic_arb_dev - SPMI PMIC Arbiter object
>   *
> - * @base:  address of the PMIC Arbiter core registers.
> + * @rd_base:   on v1 "core", on v2 "observer" register base off DT.
> + * @rd_base:   on v1 "core", on v2 "chnls"register base off DT.

s/rd/wr/

>   * @intr:  address of the SPMI interrupt control registers.
>   * @cnfg:  address of the PMIC Arbiter configuration registers.
>   * @lock:  lock to synchronize accesses.
> - * @channel:   which channel to use for accesses.
> + * @channel:   which ee channel to use for accesses.
>   * @irq:   PMIC ARB interrupt.
>   * @ee:the current Execution Environment
>   * @min_apid:  minimum APID (used for bounding IRQ search)
> @@ -114,9 +121,11 @@ enum pmic_arb_cmd_op_code {
>   * @domain:irq domain object for PMIC IRQ domain
>   * @spmic: SPMI controller object
>   * @apid_to_ppid:  cached mapping from APID to PPID
> + * @ppid_to_chan   cached mapping from APID to channel number, v2 only.
>   */
>  struct spmi_pmic_arb_dev {
> -   void __iomem*base;
> +   void __iomem*rd_base;
> +   void __iomem*wr_base;
> void __iomem*intr;
> void __iomem*cnfg;
> raw_spinlock_tlock;
> @@ -129,17 +138,61 @@ struct spmi_pmic_arb_dev {
> struct irq_domain*domain;
> struct spmi_controller*spmic;
> u16 apid_to_ppid[256];
> +   const struct pmic_arb_ver *ver;
> +   u8  *ppid_to_chan;
> +};
> +
> +/**
> + * pmic_arb_ver: version dependent functionality and values.
> + *
> + * @non_data_cmd:  on v1 issues an spmi non-data command.
> + * on v2 no HW support, returns -EOPNOTSUPP.
> + * @offset:on v1 offset of per-ee channel.
> + * on v2 offset of per-ee and per-ppid channel.
> + * @fmt_cmd:   formats a GENI/SPMI command.
> + * @owner_acc_status:  on v1 offset of PMIC_ARB_SPMI_PIC_OWNERm_ACC_STATUSn
> + * on v2 offset of SPMI_PIC_OWNERm_ACC_STATUSn.
> + * @acc_enable:on v1 offset of PMIC_ARB_SPMI_PIC_ACC_ENABLEn
> + * on v2 offset of SPMI_PIC_ACC_ENABLEn.
> + * @irq_status:on v1 offset of PMIC_ARB_SPMI_PIC_IRQ_STATUSn
> + * on v2 offset of SPMI_PIC_IRQ_STATUSn.
> + * @irq_clear: on v1 offset of PMIC_ARB_SPMI_PIC_IRQ_CLEARn
> + * on v2 offset of SPMI_PIC_IRQ_CLEARn.
> + * @geni_ctrl: PMIC_ARB_GENI_CTRL offset.
> + * @geni_status:   PMIC_ARB_GENI_STATUS offset.
> + * @protocol_irq_status: PMIC_ARB_PROTOCOL_IRQ_STATUS offset.
> + */
> +struct pmic_arb_ver {
> +   int (*non_data_cmd)(struct spmi_controller *ctrl, u8 opc, u8 sid);
> +   /* SPMI commands (including data) related functionality */
> +   off_t   (*offset)(struct spmi_pmic_arb_dev *dev, u8 sid, u16 addr);
> +   u32 (*fmt_cmd)(u8 opc, u8 sid, u16 addr, u8 bc);
> +   /* Interrupts related functionality (offset of PIC registers) */
> +   off_t   (*owner_acc_status)(u8 m, u8 n);
> +   off_t   (*acc_enable)(u8 n);
> +   off_t   (*irq_status)(u8 n);
> +   off_t   (*irq_clear)(u8 n);
> +   /* Register offsets */
> +   off_t   geni_ctrl;
> +   off_t   geni_status;
> +   off_t   protocol_irq_status;
>  };
> 
> 



> +
> +/* Non-data command */
> +static int pmic_arb_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid)
> +{
> +   struct spmi_pmic_arb_dev *pmic_arb = 
> spmi_controller_get_drvdata(ctrl);
> +
> +   pr_debug("op:0x%x sid:%d\n", opc, sid);
> 

Please use dev_dbg.


> +static const struct pmic_arb_ver pmic_arb_v1 = {
> +   .non_data_cmd= pmic_arb_non_data_cmd_v1,

Missing space before =

> +   .offset = pmic_arb_offset_v1,
> +   .fmt_cmd  = pmic_arb_fmt_cmd_v1,

Bad indentation... and bellow

> +   .owner_acc_status= pmic_arb_owner_acc_status_v1,
> +   .acc_enable= pmic_arb_acc_enable_v1,
> +   .irq_status= pmic_arb_irq_status_v1,
> +   .irq_clear= pmic_arb_irq_clear_v1,
> +   .geni_ctrl= 0x24,
> +   .geni_status= 0x28,
> +   .protocol_irq_status= (0x700 + 0x820),
> +};
> +
> +static const struct pmic_arb_ver pmic_arb_v2 = {
> +   .non_dat

Re: [PATCH v5 0/2] Initial support for voltage ADC

2015-01-28 Thread Ivan T. Ivanov

On Tue, 2015-01-20 at 12:15 +0200, Ivan T. Ivanov wrote:
> This type of volatage ADC could be found in Qualcomm's SPMI PMIC's.
> I'm sorry that it took me so long to send the updated version.
> 
> Changes since v4.
> - Addressed review comments from Hartmut Knaack and Jonathan Cameron:
>   Fixed spelling errors in DT description files.
>   Removed unused structure member.
>   Access to hardware during conversion is protected with mutex.
>   Measuring reference points moved at driver probe time.
> 
> Patches are based on current iio/testing branch.

Hi, 

Are there any comments on these patches?

Regards,
Ivan

> 
> v4 could be found here: https://lkml.org/lkml/2014/11/3/425
> 
> Stanimir Varbanov (2):
>   DT: iio: vadc: document dt binding
>   iio: vadc: Qualcomm SPMI PMIC voltage ADC driver
> 
>  .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt |  129 +++
>  drivers/iio/adc/Kconfig|   14 +
>  drivers/iio/adc/Makefile   |1 +
>  drivers/iio/adc/qcom-spmi-vadc.c   | 1016 
> 
>  include/dt-bindings/iio/qcom,spmi-vadc.h   |  119 +++
>  5 files changed, 1279 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
>  create mode 100644 drivers/iio/adc/qcom-spmi-vadc.c
>  create mode 100644 include/dt-bindings/iio/qcom,spmi-vadc.h
> 
> --
> 1.9.1
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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 2/2] leds: add Qualcomm PM8941 WLED driver

2015-01-29 Thread Ivan T. Ivanov

Hi Bjorn,

Just few nitpick comments. 

On Fri, 2015-01-23 at 16:54 -0800, Bjorn Andersson wrote:
> From: Courtney Cavin ca...@sonymobile.com>
> 
> This adds support for the WLED ('White' LED) block on Qualcomm's
> PM8941 PMICs.
> 
> Signed-off-by: Courtney Cavin ca...@sonymobile.com>
> Signed-off-by: Bjorn Andersson anders...@sonymobile.com>
> ---
>  drivers/leds/Kconfig|   8 +
>  drivers/leds/Makefile   |   1 +
>  drivers/leds/leds-pm8941-wled.c | 459 
> 
>  3 files changed, 468 insertions(+)
>  create mode 100644 drivers/leds/leds-pm8941-wled.c
> 



> +
> +#define PM8941_WLED_REG_VAL_BASE   0x40
> +#define  PM8941_WLED_REG_VAL_MAX   0xFFF
> +
> +#define PM8941_WLED_REG_MOD_EN 0x46
> +#define  PM8941_WLED_REG_MOD_EN_BITBIT(7)
> +#define  PM8941_WLED_REG_MOD_EN_MASK   BIT(7)

Is it possible bit definitions to have same indentation like registers offsets?

> 
> +struct pm8941_wled_config {
> +   u32 i_boost_limit;
> +   u32 ovp;
> +   u32 switch_freq;
> +   u32 num_strings;
> +   u32 i_limit;
> +   bool cs_out_en;
> +   bool ext_gen;
> +   bool cabc_en;
> +};
> +

Could this be further squashed to bellow structure?

> +struct pm8941_wled {
> +   struct regmap *regmap;
> +   u16 addr;
> +
> +   struct led_classdev cdev;
> +
> +   struct pm8941_wled_config cfg;
> +};
> +
> 



> +static void pm8941_wled_set_brightness(struct led_classdev *cdev,
> + 
>   enum 
> led_brightness value)
> +{
> +   if (pm8941_wled_set(cdev, value)) {

pm8941_wled_set() is used only here, could it be merged into this function?
 
> +   dev_err(cdev->dev, "Unable to set brightness\n");
> +   return;
> +   }
> +   cdev->brightness = value;
> +}
> +
> 

Otherwise it looks good. Driver is loaded and device is detected
properly (i have added readings for type and subtype registers).
Do you know where I can measure result from changing brightness 
sysfs entry. I am using 8074 dragonboard?

Thank you,
Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] thermal: Add msm tsens thermal sensor driver

2015-01-30 Thread Ivan T. Ivanov

On Thu, 2015-01-29 at 18:39 -0400, Eduardo Valentin wrote:
> On Mon, Jan 26, 2015 at 08:09:46PM -0800, Narendran Rajan wrote:
> > TSENS supports reading temperature from multiple thermal
> > sensors present in QCOM SOCs.
> > TSENS HW is enabled only when the main sensor is requested.
> > The TSENS block is disabled if the main senors is disabled
> > irrespective of any other sensors that are being enabled.
> > TSENS driver supports configurable threshold for temperature
> > monitoring in which case it can generate an interrupt when specific
> > thresholds are reached
> > 
> > Based on code by Siddartha Mohanadoss and Stephen Boyd.
> > 
> > Cc: Siddartha Mohanadoss 
> > Cc: Stephen Boyd 
> > Signed-off-by: Narendran Rajan  
> 
> I know this might not be completely related, but since you are sending
> QCOM code, can you please check my comments on your PMIC thermal code?
> https://patchwork.kernel.org/patch/5013021/
> 
> Ivan seams to have disappeared.



Mm no, sorry, just distracted by other tasks. PMIC thermal driver is in the
road map. I will try to accelerate rework.

Regards,
Ivan
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4] thermal: Add QPNP PMIC temperature alarm driver

2015-02-02 Thread Ivan T. Ivanov
Add support for the temperature alarm peripheral found inside
Qualcomm plug-and-play (QPNP) PMIC chips. The temperature alarm
peripheral outputs a pulse on an interrupt line whenever the
thermal over temperature stage value changes.

Register a thermal sensor. The temperature reported by this thermal
sensor device should reflect the actual PMIC die temperature if an
ADC is present on the given PMIC. If no ADC is present, then the
reported temperature should be estimated from the over temperature
stage value.

Cc: David Collins 
Signed-off-by: Ivan T. Ivanov 
---

Changes since v3:

- Driver register thermal sensor instead thermal zone. Device thermal zone
  should be properly described in DT files according thermal.txt document.
- Dropped support for software override PMIC shutdown sequence and related
  bit definitions. If software did not take action for clean device shutdown,
  until critical temperature is reached, PMIC chip will execute internal
  pre-programed shutdown sequence.

v3: http://comments.gmane.org/gmane.linux.ports.arm.msm/10071

 .../bindings/thermal/qcom-spmi-temp-alarm.txt  |  57 
 drivers/thermal/Kconfig|  11 +
 drivers/thermal/Makefile   |   1 +
 drivers/thermal/qcom-spmi-temp-alarm.c | 311 +
 4 files changed, 380 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
 create mode 100644 drivers/thermal/qcom-spmi-temp-alarm.c

diff --git a/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt 
b/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
new file mode 100644
index 000..290ec06
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
@@ -0,0 +1,57 @@
+Qualcomm QPNP PMIC Temperature Alarm
+
+QPNP temperature alarm peripherals are found inside of Qualcomm PMIC chips
+that utilize the Qualcomm SPMI implementation. These peripherals provide an
+interrupt signal and status register to identify high PMIC die temperature.
+
+Required properties:
+- compatible:  Should contain "qcom,spmi-temp-alarm".
+- reg: Specifies the SPMI address and length of the controller's
+   registers.
+- interrupts:  PMIC temperature alarm interrupt.
+- #thermal-sensor-cells: Should be 0. See thermal.txt for a description.
+
+Optional properties:
+- io-channels: Should contain IIO channel specifier for the ADC channel,
+   which report chip die temperature.
+- io-channel-names: Should contain "thermal".
+
+Example:
+
+   pm8941_temp: thermal-alarm@2400 {
+   compatible = "qcom,spmi-temp-alarm";
+   reg = <0x2400 0x100>;
+   interrupts = <0 0x24 0 IRQ_TYPE_EDGE_RISING>;
+   #thermal-sensor-cells = <0>;
+
+   io-channels = <&pm8941_vadc VADC_DIE_TEMP>;
+   io-channel-names = "thermal";
+   };
+
+   thermal-zones {
+   pm8941 {
+   polling-delay-passive = <250>;
+   polling-delay = <1000>;
+
+   thermal-sensors = <&pm8941_temp>;
+
+   trips {
+   passive {
+   temperature = <105>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+   alert {
+   temperature = <125000>;
+   hysteresis = <2000>;
+   type = "hot";
+   };
+   crit {
+   temperature = <145000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index af40db0..30aee81 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -299,4 +299,15 @@ depends on ARCH_STI && OF
 source "drivers/thermal/st/Kconfig"
 endmenu

+config QCOM_SPMI_TEMP_ALARM
+   tristate "Qualcomm SPMI PMIC Temperature Alarm"
+   depends on OF && SPMI && IIO
+   select REGMAP_SPMI
+   help
+ This enables a thermal sysfs driver for Qualcomm plug-and-play (QPNP)
+ PMIC devices. It shows up in sysfs as a thermal sensor with multiple
+ trip points. The temperature reported by the thermal sensor reflects 
the
+ real time die temperature if an ADC is present or an estimate of the
+ 

Re: [PATCH v4] thermal: Add QPNP PMIC temperature alarm driver

2015-02-03 Thread Ivan T. Ivanov

On Mon, 2015-02-02 at 17:38 +0200, Stanimir Varbanov wrote:
> 
> > +
> > +   chip->tz_dev = thermal_zone_of_sensor_register(&pdev->dev, 0, chip,
> > +   
> > &qpnp_tm_sensor_ops);
> > +   if (IS_ERR(chip->tz_dev)) {
> > +   dev_err(&pdev->dev, "failed to register sensor\n");
> > +   ret = PTR_ERR(chip->tz_dev);
> > +   goto fail;
> > +   }
> > +
> > +   ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qpnp_tm_isr,
> > +   IRQF_ONESHOT, node->name, chip);
> > +   if (ret < 0)
> > +   goto unreg;
> > +
> > +   return 0;
> > +
> > +unreg:
> > +   thermal_zone_of_sensor_unregister(&pdev->dev, chip->tz_dev);
> 
> Any problem to request_irq before thermal_zone_of_sensor_register? It
> will avoid having thermal sensor unregister call.

Right, will reorder the calls. 

Ivan

> 
> > +fail:
> > +   if (!IS_ERR(chip->adc))
> > +   iio_channel_release(chip->adc);
> > +
> > +   return ret;
> > +}
> 
> 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] thermal: Add QPNP PMIC temperature alarm driver

2015-02-03 Thread Ivan T. Ivanov

Hi Eduardo,

On Mon, 2015-02-02 at 14:14 -0400, Eduardo Valentin wrote:
> Ivan,
> 
> On Mon, Feb 02, 2015 at 05:19:30PM +0200, Ivan T. Ivanov wrote:
> > Add support for the temperature alarm peripheral found inside
> > Qualcomm plug-and-play (QPNP) PMIC chips. The temperature alarm
> > peripheral outputs a pulse on an interrupt line whenever the
> > thermal over temperature stage value changes.
> > 
> > Register a thermal sensor. The temperature reported by this thermal
> > sensor device should reflect the actual PMIC die temperature if an
> > ADC is present on the given PMIC. If no ADC is present, then the
> > reported temperature should be estimated from the over temperature
> > stage value.
> > 
> > Cc: David Collins 
> > Signed-off-by: Ivan T. Ivanov 
> > ---
> > 
> > Changes since v3:
> > 
> > - Driver register thermal sensor instead thermal zone. Device thermal zone
> >   should be properly described in DT files according thermal.txt document.
> 
> Thanks a lot for keeping this up. I believe the driver looks smaller and
> cleaner now, don't you agree?

Yep.

> 
> > - Dropped support for software override PMIC shutdown sequence and related
> >   bit definitions. If software did not take action for clean device 
> > shutdown,
> >   until critical temperature is reached, PMIC chip will execute internal
> >   pre-programed shutdown sequence.
> > 
> 
> OK. Let me know if this functionality is crucial and needs further
> discussion.

Unless I miss something, I think that this functionality is
used only for the purpose of debugging.

> 
> 
> I have two very minor comments as follows.
> 
> 
> > v3: http://comments.gmane.org/gmane.linux.ports.arm.msm/10071
> > 
> >  .../bindings/thermal/qcom-spmi-temp-alarm.txt  |  57 
> >  drivers/thermal/Kconfig|  11 +
> >  drivers/thermal/Makefile   |   1 +
> >  drivers/thermal/qcom-spmi-temp-alarm.c | 311 
> > +
> >  4 files changed, 380 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
> >  create mode 100644 drivers/thermal/qcom-spmi-temp-alarm.c
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt 
> > b/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
> > new file mode 100644
> > index 000..290ec06
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/thermal/qcom-spmi-temp-alarm.txt
> > @@ -0,0 +1,57 @@
> > +Qualcomm QPNP PMIC Temperature Alarm
> > +
> > +QPNP temperature alarm peripherals are found inside of Qualcomm PMIC chips
> > +that utilize the Qualcomm SPMI implementation. These peripherals provide an
> > +interrupt signal and status register to identify high PMIC die temperature.
> > +
> > +Required properties:
> > +- compatible:  Should contain "qcom,spmi-temp-alarm".
> > +- reg: Specifies the SPMI address and length of the 
> > controller's
> > +   registers.
> > +- interrupts:  PMIC temperature alarm interrupt.
> > +- #thermal-sensor-cells: Should be 0. See thermal.txt for a description.
> > +
> > +Optional properties:
> > +- io-channels: Should contain IIO channel specifier for the ADC 
> > channel,
> > +   which report chip die temperature.
> > +- io-channel-names: Should contain "thermal".
> > +
> > +Example:
> > +
> > +   pm8941_temp: thermal-alarm@2400 {
> > +   compatible = "qcom,spmi-temp-alarm";
> > +   reg = <0x2400 0x100>;
> > +   interrupts = <0 0x24 0 IRQ_TYPE_EDGE_RISING>;
> > +   #thermal-sensor-cells = <0>;
> > +
> > +   io-channels = <&pm8941_vadc VADC_DIE_TEMP>;
> > +   io-channel-names = "thermal";
> > +   };
> > +
> > +   thermal-zones {
> > +   pm8941 {
> > +   polling-delay-passive = <250>;
> > +   polling-delay = <1000>;
> > +
> > +   thermal-sensors = <&pm8941_temp>;
> > +
> > +   trips {
> > +   passive {
> > +   temperature = <105>;
> > +   hysteresis = <2000>;
> > + 

[PATCH 1/3] ARM: dts: qcom: Add SPMI PMIC Arbiter nodes for APQ8084 and MSM8974

2015-02-03 Thread Ivan T. Ivanov
Add SPMI PMIC Arbiter configuration nodes for APQ8084 and MSM8974.

Signed-off-by: Ivan T. Ivanov 
---
 arch/arm/boot/dts/qcom-apq8084.dtsi | 16 
 arch/arm/boot/dts/qcom-msm8974.dtsi | 16 
 2 files changed, 32 insertions(+)

diff --git a/arch/arm/boot/dts/qcom-apq8084.dtsi 
b/arch/arm/boot/dts/qcom-apq8084.dtsi
index 1f130bc..dbedf64 100644
--- a/arch/arm/boot/dts/qcom-apq8084.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8084.dtsi
@@ -226,5 +226,21 @@
clock-names = "core", "iface";
status = "disabled";
};
+
+   spmi_bus: spmi@fc4cf000 {
+   compatible = "qcom,spmi-pmic-arb";
+   reg-names = "core", "intr", "cnfg";
+   reg = <0xfc4cf000 0x1000>,
+ <0xfc4cb000 0x1000>,
+ <0xfc4ca000 0x1000>;
+   interrupt-names = "periph_irq";
+   interrupts = <0 190 0>;
+   qcom,ee = <0>;
+   qcom,channel = <0>;
+   #address-cells = <2>;
+   #size-cells = <0>;
+   interrupt-controller;
+   #interrupt-cells = <4>;
+   };
};
 };
diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
b/arch/arm/boot/dts/qcom-msm8974.dtsi
index e265ec1..2d11641 100644
--- a/arch/arm/boot/dts/qcom-msm8974.dtsi
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -247,5 +247,21 @@
#address-cells = <1>;
#size-cells = <0>;
};
+
+   spmi_bus: spmi@fc4cf000 {
+   compatible = "qcom,spmi-pmic-arb";
+   reg-names = "core", "intr", "cnfg";
+   reg = <0xfc4cf000 0x1000>,
+ <0xfc4cb000 0x1000>,
+ <0xfc4ca000 0x1000>;
+   interrupt-names = "periph_irq";
+   interrupts = <0 190 0>;
+   qcom,ee = <0>;
+   qcom,channel = <0>;
+   #address-cells = <2>;
+   #size-cells = <0>;
+   interrupt-controller;
+   #interrupt-cells = <4>;
+   };
};
 };
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2   3   4   5   6   7   >