[PATCH 2/3 v4] Fix Internal error: : 808 [#1] ARM related to STS flag

2013-12-03 Thread Chris Ruehl
Fix Internal error: : 808 [#1] ARM related to STS flag

* init the sts flag to 0 (missed)
* fix write the real bit not sts value
* Set PORTCS_STS and DEVLC_STS only if sts = 1
 (prefered solution by Mr. Peter Chen, Maintainer of ChipIdea subsystem)

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
---
 drivers/usb/chipidea/core.c |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 9a5ef20..2834801 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -243,7 +243,7 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem 
*base)
 
 static void hw_phymode_configure(struct ci_hdrc *ci)
 {
-   u32 portsc, lpm, sts;
+   u32 portsc, lpm, sts = 0;
 
switch (ci-platdata-phy_mode) {
case USBPHY_INTERFACE_MODE_UTMI:
@@ -273,10 +273,12 @@ static void hw_phymode_configure(struct ci_hdrc *ci)
 
if (ci-hw_bank.lpm) {
hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm);
-   hw_write(ci, OP_DEVLC, DEVLC_STS, sts);
+   if (sts)
+   hw_write(ci, OP_DEVLC, DEVLC_STS, DEVLC_STS);
} else {
hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc);
-   hw_write(ci, OP_PORTSC, PORTSC_STS, sts);
+   if (sts)
+   hw_write(ci, OP_PORTSC, PORTSC_STS, PORTSC_STS);
}
 }
 
-- 
1.7.10.4

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


[PATCH 1/3 v4] usb: chipidea: Reallocate regmap only if lpm is detected

2013-12-03 Thread Chris Ruehl
usb: chipidea: Reallocate regmap only if lpm is detected

The regmap only needs to reallocate if the hw_read on the CAP register shows
lpm is used. Therefore the if() statement check the change.

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/core.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5d8981c..9a5ef20 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void __iomem 
*base)
reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
__ffs(HCCPARAMS_LEN);
ci-hw_bank.lpm  = reg;
-   hw_alloc_regmap(ci, !!reg);
+   if (reg)
+   hw_alloc_regmap(ci, !!reg);
ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
ci-hw_bank.size += OP_LAST;
ci-hw_bank.size /= sizeof(u32);
@@ -642,6 +643,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
: CI_ROLE_GADGET;
}
 
+   /* only update vbus status for peripheral */
+   if (ci-role == CI_ROLE_GADGET)
+   ci_handle_vbus_change(ci);
+
ret = ci_role_start(ci, ci-role);
if (ret) {
dev_err(dev, can't start %s role\n, ci_role(ci)-name);
-- 
1.7.10.4

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


[PATCH 3/3 v4] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-12-03 Thread Chris Ruehl
usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init
hw_phymode_configure configures the PORTSC registers and allow the
following phy_inits to operate on the right parameters. This fix a problem
where the UPLI (ISP1504) could not detected, because the Viewport was not
available and read the viewport return 0's only.

Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
Acked-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/chipidea/core.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 2834801..43897dd 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -564,6 +564,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return -ENODEV;
}
 
+   hw_phymode_configure(ci);
+
ret = ci_usb_phy_init(ci);
if (ret) {
dev_err(dev, unable to init phy: %d\n, ret);
@@ -581,8 +583,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
ci_get_otg_capable(ci);
 
-   hw_phymode_configure(ci);
-
dr_mode = ci-platdata-dr_mode;
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
-- 
1.7.10.4

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


[PATCH v4 03/17] usb: phy-mxs: Add auto clock and power setting

2013-12-03 Thread Peter Chen
With the auto setting, the PHY's clock and power can be
recovered correctly from low power mode, it is ganranteed by IC logic.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   20 +---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index f6cbc78..70b084d 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,11 @@
 
 #define BM_USBPHY_CTRL_SFTRST  BIT(31)
 #define BM_USBPHY_CTRL_CLKGATE BIT(30)
+#define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS   BIT(26)
+#define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25)
+#define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD   BIT(20)
+#define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE   BIT(19)
+#define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18)
 #define BM_USBPHY_CTRL_ENUTMILEVEL3BIT(15)
 #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
@@ -96,9 +101,18 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
/* Power up the PHY */
writel(0, base + HW_USBPHY_PWD);
 
-   /* enable FS/LS device */
-   writel(BM_USBPHY_CTRL_ENUTMILEVEL2 |
-  BM_USBPHY_CTRL_ENUTMILEVEL3,
+   /*
+* USB PHY Ctrl Setting
+* - Auto clock/power on
+* - Enable full/low speed support
+*/
+   writel(BM_USBPHY_CTRL_ENAUTOSET_USBCLKS |
+   BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE |
+   BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD |
+   BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE |
+   BM_USBPHY_CTRL_ENAUTO_PWRON_PLL |
+   BM_USBPHY_CTRL_ENUTMILEVEL2 |
+   BM_USBPHY_CTRL_ENUTMILEVEL3,
   base + HW_USBPHY_CTRL_SET);
 
return 0;
-- 
1.7.8


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


[PATCH v4 01/17] usb: doc: phy-mxs: Add more compatible strings

2013-12-03 Thread Peter Chen
Add fsl,imx6q-usbphy for imx6dq and imx6dl, add
fsl,imx6sl-usbphy for imx6sl.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt 
b/Documentation/devicetree/bindings/usb/mxs-phy.txt
index 5835b27..d850e55 100644
--- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
+++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
@@ -1,7 +1,8 @@
 * Freescale MXS USB Phy Device
 
 Required properties:
-- compatible: Should be fsl,imx23-usbphy
+- compatible: fsl,imx23-usbphy for imx23 and imx28, fsl,imx6q-usbphy
+for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl
 - reg: Should contain registers location and length
 - interrupts: Should contain phy interrupt
 
-- 
1.7.8


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


[PATCH v4 02/17] usb: phy-mxs: Add platform judgement code

2013-12-03 Thread Peter Chen
The mxs-phy has several bugs and features at different
versions, the driver code can get it through of_device_id.data.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   58 ++--
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 545844b..f6cbc78 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012-2013 Freescale Semiconductor, Inc.
  * Copyright (C) 2012 Marek Vasut ma...@denx.de
  * on behalf of DENX Software Engineering GmbH
  *
@@ -20,6 +20,7 @@
 #include linux/delay.h
 #include linux/err.h
 #include linux/io.h
+#include linux/of_device.h
 
 #define DRIVER_NAME mxs_phy
 
@@ -34,13 +35,55 @@
 #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
 
+#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
+
+/* Do disconnection between PHY and controller without vbus */
+#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS   BIT(0)
+
+/*
+ * The PHY will be in messy if there is an wakeup after putting
+ * bus to suspend (set portsc.suspendM) but before setting PHY to low
+ * power mode (set portsc.phcd).
+ */
+#define MXS_PHY_ABNORAML_IN_SUSPENDBIT(1)
+
+/*
+ * The SOF sends too fast after resuming, it will cause disconnection
+ * between host and high speed device.
+ */
+#define MXS_PHY_SENDING_SOF_TOO_FAST   BIT(2)
+
+struct mxs_phy_data {
+   unsigned int flags;
+};
+
+static const struct mxs_phy_data imx23_phy_data = {
+   .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
+};
+
+static const struct mxs_phy_data imx6q_phy_data = {
+   .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
+   MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+};
+
+static const struct mxs_phy_data imx6sl_phy_data = {
+   .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+};
+
+static const struct of_device_id mxs_phy_dt_ids[] = {
+   { .compatible = fsl,imx6sl-usbphy, .data = imx6sl_phy_data, },
+   { .compatible = fsl,imx6q-usbphy, .data = imx6q_phy_data, },
+   { .compatible = fsl,imx23-usbphy, .data = imx23_phy_data, },
+   { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
+
 struct mxs_phy {
struct usb_phy phy;
struct clk *clk;
+   const struct mxs_phy_data *data;
 };
 
-#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
-
 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 {
int ret;
@@ -131,6 +174,8 @@ static int mxs_phy_probe(struct platform_device *pdev)
struct clk *clk;
struct mxs_phy *mxs_phy;
int ret;
+   const struct of_device_id *of_id =
+   of_match_device(mxs_phy_dt_ids, pdev-dev);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(pdev-dev, res);
@@ -163,6 +208,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
ATOMIC_INIT_NOTIFIER_HEAD(mxs_phy-phy.notifier);
 
mxs_phy-clk = clk;
+   mxs_phy-data = of_id-data;
 
platform_set_drvdata(pdev, mxs_phy);
 
@@ -182,12 +228,6 @@ static int mxs_phy_remove(struct platform_device *pdev)
return 0;
 }
 
-static const struct of_device_id mxs_phy_dt_ids[] = {
-   { .compatible = fsl,imx23-usbphy, },
-   { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
-
 static struct platform_driver mxs_phy_driver = {
.probe = mxs_phy_probe,
.remove = mxs_phy_remove,
-- 
1.7.8


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


[PATCH v4 00/17] Add power management support for mxs phy

2013-12-03 Thread Peter Chen
Hi Felipe  Shawn,

The serial adds power management support for MXS PHY, it includes:

- Add three common PHY APIs, .set_wakeup, .notify_suspend, notify_resume.
- Related above API implementation at mxs phy driver
- misc changes and bug fixes for mxs phy to support low power mode and wakeup.

It is based on Greg's usb-next, 3.13-rc1.

Changes for v4:
- Using MXS_PHY_HAS_ANATOP to indicate which platform has anatop module
- Using mxs_phy_data to instead of mxs_phy_platform_flag
- Create is_xxx_phy() MACRO
- Add imx6sl support, and pass the test [5/17]
- Add one additional binding doc for compatible string [1/17]
- Introduce controller id to access un-regulator register region
[14/17] [15/17]
- Add waiting stable time before phy clock switches to AHB clock
(from 32K) [13/17]
- Fix one problem that only using the 1st controller register
at mxs_phy_disconnect_line [16/17]
- Fix one problem for low speed connection at very rare cases [17/17]
- Some typos


Changes for v3:
- Using flag bit to indicate SoC features/bugs, so we can remove
platform_device_id.
- Remove 3 unnecessary dts/doc patches due to above change
- Several comment change

Changes for v2:

- Add missing patches which introduce platform judgement code [1/14,2/14]
- re-order the patch sequence, like doc-dts-source file,
the reviewers can know the meaning of dt properties before review source
- Add description of two IC problems exsiting at mxs PHY; change
high speed to HS and non-high speed to FS/LS [5/14]
- Change the dt property disconnect-line-without-vbus
that the separator should be - not the _, meanwhile, related source
code has changed.
- Using one local variable to get the function return val to avoid long
condition statement. [13/14]

Peter Chen (17):
  usb: doc: phy-mxs: Add more compatible strings
  usb: phy-mxs: Add platform judgement code
  usb: phy-mxs: Add auto clock and power setting
  usb: doc: phy-mxs: update binding for adding anatop phandle
  ARM: dts: imx6: add anatop phandle for usbphy
  usb: phy-mxs: Add anatop regmap
  usb: phy: add notify suspend and resume callback
  usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  usb: phy-mxs: Enable IC fixes for related SoCs
  usb: phy: Add set_wakeup API
  usb: phy-mxs: Add implementation of set_wakeup
  usb: phy-mxs: Add system suspend/resume API
  usb: phy-mxs: Add sync time after controller clear phcd
  ARM: dts: imx: add mxs phy controller id
  usb: phy-mxs: add controller id
  usb: phy-mxs: fix the problem by only using 1st controller's register
  usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

 Documentation/devicetree/bindings/usb/mxs-phy.txt |5 +-
 arch/arm/boot/dts/imx23.dtsi  |1 +
 arch/arm/boot/dts/imx28.dtsi  |2 +
 arch/arm/boot/dts/imx6qdl.dtsi|4 +
 arch/arm/boot/dts/imx6sl.dtsi |4 +
 drivers/usb/phy/phy-mxs-usb.c |  398 -
 include/linux/usb/phy.h   |   39 ++
 7 files changed, 437 insertions(+), 16 deletions(-)

-- 
1.7.8


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


[PATCH v4 13/17] usb: phy-mxs: Add sync time after controller clear phcd

2013-12-03 Thread Peter Chen
After clear portsc.phcd, PHY needs 200us stable time for switch
32K clock to AHB clock.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 3e25c3d..52e80d9 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -139,6 +139,15 @@ static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
return mxs_phy-data == imx6sl_phy_data;
 }
 
+/*
+ * PHY needs some 32K cycles to switch from 32K clock to
+ * bus (such as AHB/AXI, etc) clock.
+ */
+static void mxs_phy_clock_switch(void)
+{
+   usleep_range(300, 400);
+}
+
 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 {
int ret;
@@ -234,6 +243,7 @@ static int mxs_phy_init(struct usb_phy *phy)
 {
struct mxs_phy *mxs_phy = to_mxs_phy(phy);
 
+   mxs_phy_clock_switch();
clk_prepare_enable(mxs_phy-clk);
return mxs_phy_hw_init(mxs_phy);
 }
@@ -258,6 +268,7 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
   x-io_priv + HW_USBPHY_CTRL_SET);
clk_disable_unprepare(mxs_phy-clk);
} else {
+   mxs_phy_clock_switch();
clk_prepare_enable(mxs_phy-clk);
writel(BM_USBPHY_CTRL_CLKGATE,
   x-io_priv + HW_USBPHY_CTRL_CLR);
-- 
1.7.8


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


[PATCH v4 17/17] usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

2013-12-03 Thread Peter Chen
At very rare cases, the SoF will not send out after resume with
low speed connection. The workaround is do not power down
PWD.RXPWD1PT1 bit during the suspend.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   47 -
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 542b6ec..5ae4a57 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -69,6 +69,9 @@
 #define ANADIG_USB2_LOOPBACK_SET   0x244
 #define ANADIG_USB2_LOOPBACK_CLR   0x248
 
+#define ANADIG_USB1_MISC   0x1f0
+#define ANADIG_USB2_MISC   0x250
+
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG   BIT(12)
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
 
@@ -80,6 +83,11 @@
 #define BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1  BIT(2)
 #define BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN BIT(5)
 
+#define BM_ANADIG_USB1_MISC_RX_VPIN_FS BIT(29)
+#define BM_ANADIG_USB1_MISC_RX_VMIN_FS BIT(28)
+#define BM_ANADIG_USB2_MISC_RX_VPIN_FS BIT(29)
+#define BM_ANADIG_USB2_MISC_RX_VMIN_FS BIT(28)
+
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
 /* Do disconnection between PHY and controller without vbus */
@@ -296,12 +304,49 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
clk_disable_unprepare(mxs_phy-clk);
 }
 
+static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy)
+{
+   unsigned int line_state;
+   /* bit definition is the same for all controllers */
+   unsigned int dp_bit = BM_ANADIG_USB1_MISC_RX_VPIN_FS,
+dm_bit = BM_ANADIG_USB1_MISC_RX_VMIN_FS;
+   unsigned int reg = ANADIG_USB1_MISC;
+
+   /* If the SoCs don't have anatop, quit */
+   if (!mxs_phy-regmap_anatop)
+   return false;
+
+   if (mxs_phy-port_id == 0)
+   reg = ANADIG_USB1_MISC;
+   else if (mxs_phy-port_id == 1)
+   reg = ANADIG_USB2_MISC;
+
+   regmap_read(mxs_phy-regmap_anatop, reg, line_state);
+
+   if ((line_state  (dp_bit | dm_bit)) ==  dm_bit)
+   return true;
+   else
+   return false;
+}
+
 static int mxs_phy_suspend(struct usb_phy *x, int suspend)
 {
struct mxs_phy *mxs_phy = to_mxs_phy(x);
+   bool low_speed_connection, vbus_is_on;
+
+   low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy);
+   vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
 
if (suspend) {
-   writel(0x, x-io_priv + HW_USBPHY_PWD);
+   /*
+* FIXME: Do not power down RXPWD1PT1 bit for low speed
+* connect. The low speed connection will have problem at
+* very rare cases during usb suspend and resume process.
+*/
+   if (low_speed_connection  vbus_is_on)
+   writel(0xfffb, x-io_priv + HW_USBPHY_PWD);
+   else
+   writel(0x, x-io_priv + HW_USBPHY_PWD);
writel(BM_USBPHY_CTRL_CLKGATE,
   x-io_priv + HW_USBPHY_CTRL_SET);
clk_disable_unprepare(mxs_phy-clk);
-- 
1.7.8


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


[PATCH v4 09/17] usb: phy-mxs: Enable IC fixes for related SoCs

2013-12-03 Thread Peter Chen
Some PHY bugs are fixed by IC logic, but these bits are not
enabled by default, so we enable them at driver.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 8738890..0908d74 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,10 @@
 #define HW_USBPHY_CTRL_SET 0x34
 #define HW_USBPHY_CTRL_CLR 0x38
 
+#define HW_USBPHY_IP   0x90
+#define HW_USBPHY_IP_SET   0x94
+#define HW_USBPHY_IP_CLR   0x98
+
 #define BM_USBPHY_CTRL_SFTRST  BIT(31)
 #define BM_USBPHY_CTRL_CLKGATE BIT(30)
 #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS   BIT(26)
@@ -42,6 +46,8 @@
 #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
 
+#define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
+
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
 /* Do disconnection between PHY and controller without vbus */
@@ -97,6 +103,16 @@ struct mxs_phy {
struct regmap *regmap_anatop;
 };
 
+static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
+{
+   return mxs_phy-data == imx6q_phy_data;
+}
+
+static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
+{
+   return mxs_phy-data == imx6sl_phy_data;
+}
+
 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 {
int ret;
@@ -123,6 +139,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
BM_USBPHY_CTRL_ENUTMILEVEL3,
   base + HW_USBPHY_CTRL_SET);
 
+   /* Enable IC solution */
+   if (is_imx6q_phy(mxs_phy) || is_imx6sl_phy(mxs_phy))
+   writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
+
return 0;
 }
 
-- 
1.7.8


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


[PATCH v4 11/17] usb: phy-mxs: Add implementation of set_wakeup

2013-12-03 Thread Peter Chen
When we need the PHY can be waken up by external signals,
we can call this API. Besides, we call mxs_phy_disconnect_line
at this API to close the connection between USB PHY and
controller, after that, the line state from controller is SE0.
Once the PHY is out of power, without calling mxs_phy_disconnect_line,
there are unknown wakeups due to dp/dm floating at device mode.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   79 +
 1 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 0908d74..84680e3 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,9 @@
 #define HW_USBPHY_CTRL_SET 0x34
 #define HW_USBPHY_CTRL_CLR 0x38
 
+#define HW_USBPHY_DEBUG_SET0x54
+#define HW_USBPHY_DEBUG_CLR0x58
+
 #define HW_USBPHY_IP   0x90
 #define HW_USBPHY_IP_SET   0x94
 #define HW_USBPHY_IP_CLR   0x98
@@ -39,6 +42,9 @@
 #define BM_USBPHY_CTRL_CLKGATE BIT(30)
 #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS   BIT(26)
 #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATEBIT(25)
+#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP  BIT(23)
+#define BM_USBPHY_CTRL_ENIDCHG_WKUPBIT(22)
+#define BM_USBPHY_CTRL_ENDPDMCHG_WKUP  BIT(21)
 #define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD   BIT(20)
 #define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE   BIT(19)
 #define BM_USBPHY_CTRL_ENAUTO_PWRON_PLLBIT(18)
@@ -48,6 +54,19 @@
 
 #define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
 
+#define BM_USBPHY_DEBUG_CLKGATEBIT(30)
+
+/* Anatop Registers */
+#define ANADIG_USB1_VBUS_DET_STAT  0x1c0
+
+#define ANADIG_USB1_LOOPBACK_SET   0x1e4
+#define ANADIG_USB1_LOOPBACK_CLR   0x1e8
+
+#define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3)
+
+#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1  BIT(2)
+#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN BIT(5)
+
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
 /* Do disconnection between PHY and controller without vbus */
@@ -146,6 +165,48 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
return 0;
 }
 
+static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
+{
+   void __iomem *base = mxs_phy-phy.io_priv;
+   bool vbus_is_on = false;
+   static bool line_is_disconnected;
+   unsigned int vbus_value = 0;
+
+   /* If the SoCs don't need to disconnect line without vbus, quit */
+   if (!(mxs_phy-data-flags  MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS))
+   return;
+
+   /* If the SoCs don't have anatop, quit */
+   if (!mxs_phy-regmap_anatop)
+   return;
+
+   regmap_read(mxs_phy-regmap_anatop, ANADIG_USB1_VBUS_DET_STAT,
+   vbus_value);
+   if (vbus_value  BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)
+   vbus_is_on = true;
+
+   if (on  !vbus_is_on) {
+   writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+   base + HW_USBPHY_DEBUG_CLR);
+   regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_SET,
+   BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+   BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+   /* Delay some time, and let Linestate be SE0 for controller */
+   usleep_range(500, 1000);
+   line_is_disconnected = true;
+   } else if (line_is_disconnected) {
+   regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_CLR,
+   BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+   BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+   writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+   base + HW_USBPHY_DEBUG_SET);
+   line_is_disconnected = false;
+   }
+
+   dev_dbg(mxs_phy-phy.dev, line is %s\n, line_is_disconnected
+   ? disconnected : connected);
+}
+
 static int mxs_phy_init(struct usb_phy *phy)
 {
struct mxs_phy *mxs_phy = to_mxs_phy(phy);
@@ -183,6 +244,23 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
return 0;
 }
 
+static int mxs_phy_set_wakeup(struct usb_phy *x, bool enabled)
+{
+   struct mxs_phy *mxs_phy = to_mxs_phy(x);
+   u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP |
+   BM_USBPHY_CTRL_ENDPDMCHG_WKUP |
+   BM_USBPHY_CTRL_ENIDCHG_WKUP;
+   if (enabled) {
+   mxs_phy_disconnect_line(mxs_phy, true);
+   writel_relaxed(value, x-io_priv + HW_USBPHY_CTRL_SET);
+   } else {
+   writel_relaxed(value, x-io_priv + HW_USBPHY_CTRL_CLR);
+   

[PATCH v4 05/17] ARM: dts: imx6: add anatop phandle for usbphy

2013-12-03 Thread Peter Chen
Add anatop phandle for usbphy

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 arch/arm/boot/dts/imx6qdl.dtsi |2 ++
 arch/arm/boot/dts/imx6sl.dtsi  |2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 59154dc..4e74962 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -557,6 +557,7 @@
reg = 0x020c9000 0x1000;
interrupts = 0 44 0x04;
clocks = clks 182;
+   fsl,anatop = anatop;
};
 
usbphy2: usbphy@020ca000 {
@@ -564,6 +565,7 @@
reg = 0x020ca000 0x1000;
interrupts = 0 45 0x04;
clocks = clks 183;
+   fsl,anatop = anatop;
};
 
snvs@020cc000 {
diff --git a/arch/arm/boot/dts/imx6sl.dtsi b/arch/arm/boot/dts/imx6sl.dtsi
index 28558f1..30322b5 100644
--- a/arch/arm/boot/dts/imx6sl.dtsi
+++ b/arch/arm/boot/dts/imx6sl.dtsi
@@ -489,6 +489,7 @@
reg = 0x020c9000 0x1000;
interrupts = 0 44 0x04;
clocks = clks IMX6SL_CLK_USBPHY1;
+   fsl,anatop = anatop;
};
 
usbphy2: usbphy@020ca000 {
@@ -496,6 +497,7 @@
reg = 0x020ca000 0x1000;
interrupts = 0 45 0x04;
clocks = clks IMX6SL_CLK_USBPHY2;
+   fsl,anatop = anatop;
};
 
snvs@020cc000 {
-- 
1.7.8


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


[PATCH v4 07/17] usb: phy: add notify suspend and resume callback

2013-12-03 Thread Peter Chen
They are used to notify PHY that the controller enters suspend
or finishes resume.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 include/linux/usb/phy.h |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 6c0b1c5..a747960 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -116,6 +116,11 @@ struct usb_phy {
enum usb_device_speed speed);
int (*notify_disconnect)(struct usb_phy *x,
enum usb_device_speed speed);
+   int (*notify_suspend)(struct usb_phy *x,
+   enum usb_device_speed speed);
+   int (*notify_resume)(struct usb_phy *x,
+   enum usb_device_speed speed);
+
 };
 
 /**
@@ -282,6 +287,24 @@ usb_phy_notify_disconnect(struct usb_phy *x, enum 
usb_device_speed speed)
return 0;
 }
 
+static inline int usb_phy_notify_suspend
+   (struct usb_phy *x, enum usb_device_speed speed)
+{
+   if (x  x-notify_suspend)
+   return x-notify_suspend(x, speed);
+   else
+   return 0;
+}
+
+static inline int usb_phy_notify_resume
+   (struct usb_phy *x, enum usb_device_speed speed)
+{
+   if (x  x-notify_resume)
+   return x-notify_resume(x, speed);
+   else
+   return 0;
+}
+
 /* notifiers */
 static inline int
 usb_register_notifier(struct usb_phy *x, struct notifier_block *nb)
-- 
1.7.8


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


[PATCH v4 15/17] usb: phy-mxs: add controller id

2013-12-03 Thread Peter Chen
It is used to access un-regulator registers according to
different controllers.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 52e80d9..4c2dfcd 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -127,6 +127,7 @@ struct mxs_phy {
struct clk *clk;
const struct mxs_phy_data *data;
struct regmap *regmap_anatop;
+   int port_id;
 };
 
 static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
@@ -392,6 +393,13 @@ static int mxs_phy_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
+   ret = of_alias_get_id(np, usbphy);
+   if (ret  0) {
+   dev_err(pdev-dev, failed to get alias id, errno %d\n, ret);
+   return ret;
+   }
+   mxs_phy-port_id = ret;
+
mxs_phy-phy.io_priv= base;
mxs_phy-phy.dev= pdev-dev;
mxs_phy-phy.label  = DRIVER_NAME;
-- 
1.7.8


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


[PATCH v4 16/17] usb: phy-mxs: fix the problem by only using 1st controller's register

2013-12-03 Thread Peter Chen
We fix the problem that we only use the 1st controller's related
registers at mxs_phy_disconnect_line, but in fact, it needs to
access registers according to different PHYs.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   89 +
 1 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 4c2dfcd..542b6ec 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -62,17 +62,23 @@
 #define ANADIG_ANA_MISC0_CLR   0x158
 
 #define ANADIG_USB1_VBUS_DET_STAT  0x1c0
+#define ANADIG_USB2_VBUS_DET_STAT  0x220
 
 #define ANADIG_USB1_LOOPBACK_SET   0x1e4
 #define ANADIG_USB1_LOOPBACK_CLR   0x1e8
+#define ANADIG_USB2_LOOPBACK_SET   0x244
+#define ANADIG_USB2_LOOPBACK_CLR   0x248
 
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG   BIT(12)
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
 
 #define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3)
+#define BM_ANADIG_USB2_VBUS_DET_STAT_VBUS_VALIDBIT(3)
 
 #define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1  BIT(2)
 #define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN BIT(5)
+#define BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1  BIT(2)
+#define BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN BIT(5)
 
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
@@ -182,12 +188,61 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
return 0;
 }
 
-static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
+/* Return true if the vbus is there */
+static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy)
+{
+   unsigned int vbus_value;
+
+   if (mxs_phy-port_id == 0)
+   regmap_read(mxs_phy-regmap_anatop,
+   ANADIG_USB1_VBUS_DET_STAT,
+   vbus_value);
+   else if (mxs_phy-port_id == 1)
+   regmap_read(mxs_phy-regmap_anatop,
+   ANADIG_USB2_VBUS_DET_STAT,
+   vbus_value);
+
+   if (vbus_value  BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)
+   return true;
+   else
+   return false;
+}
+
+static void __mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool disconnect)
 {
void __iomem *base = mxs_phy-phy.io_priv;
+   u32 reg;
+
+   if (disconnect)
+   writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+   base + HW_USBPHY_DEBUG_CLR);
+
+   if (mxs_phy-port_id == 0) {
+   reg = disconnect ? ANADIG_USB1_LOOPBACK_SET
+   : ANADIG_USB1_LOOPBACK_CLR;
+   regmap_write(mxs_phy-regmap_anatop, reg,
+   BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+   BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+   } else if (mxs_phy-port_id == 1) {
+   reg = disconnect ? ANADIG_USB2_LOOPBACK_SET
+   : ANADIG_USB2_LOOPBACK_CLR;
+   regmap_write(mxs_phy-regmap_anatop, reg,
+   BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1 |
+   BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN);
+   }
+
+   if (!disconnect)
+   writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+   base + HW_USBPHY_DEBUG_SET);
+
+   /* Delay some time, and let Linestate be SE0 for controller */
+   if (disconnect)
+   usleep_range(500, 1000);
+}
+
+static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
+{
bool vbus_is_on = false;
-   static bool line_is_disconnected;
-   unsigned int vbus_value = 0;
 
/* If the SoCs don't need to disconnect line without vbus, quit */
if (!(mxs_phy-data-flags  MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS))
@@ -197,31 +252,13 @@ static void mxs_phy_disconnect_line(struct mxs_phy 
*mxs_phy, bool on)
if (!mxs_phy-regmap_anatop)
return;
 
-   regmap_read(mxs_phy-regmap_anatop, ANADIG_USB1_VBUS_DET_STAT,
-   vbus_value);
-   if (vbus_value  BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)
-   vbus_is_on = true;
+   vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
 
-   if (on  !vbus_is_on) {
-   writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
-   base + HW_USBPHY_DEBUG_CLR);
-   regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_SET,
-   BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
-   BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
-   /* Delay some time, and let Linestate be SE0 for controller */
-   usleep_range(500, 1000);
-   line_is_disconnected = true;
-   } else if (line_is_disconnected) {
-   regmap_write(mxs_phy-regmap_anatop, ANADIG_USB1_LOOPBACK_CLR,
-   BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
-  

[PATCH v4 12/17] usb: phy-mxs: Add system suspend/resume API

2013-12-03 Thread Peter Chen
We need this to keep PHY's power on or off during the system
suspend mode. If we need to enable USB wakeup, then we
must keep PHY's power being on during the system suspend mode.
Otherwise, we need to keep PHY's power being off to save power.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   48 +
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 84680e3..3e25c3d 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -57,11 +57,18 @@
 #define BM_USBPHY_DEBUG_CLKGATEBIT(30)
 
 /* Anatop Registers */
+#define ANADIG_ANA_MISC0   0x150
+#define ANADIG_ANA_MISC0_SET   0x154
+#define ANADIG_ANA_MISC0_CLR   0x158
+
 #define ANADIG_USB1_VBUS_DET_STAT  0x1c0
 
 #define ANADIG_USB1_LOOPBACK_SET   0x1e4
 #define ANADIG_USB1_LOOPBACK_CLR   0x1e8
 
+#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG   BIT(12)
+#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
+
 #define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALIDBIT(3)
 
 #define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1  BIT(2)
@@ -207,6 +214,22 @@ static void mxs_phy_disconnect_line(struct mxs_phy 
*mxs_phy, bool on)
? disconnected : connected);
 }
 
+static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
+{
+   unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR;
+
+   /* If the SoCs don't have anatop, quit */
+   if (!mxs_phy-regmap_anatop)
+   return;
+
+   if (is_imx6q_phy(mxs_phy))
+   regmap_write(mxs_phy-regmap_anatop, reg,
+   BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+   else if (is_imx6sl_phy(mxs_phy))
+   regmap_write(mxs_phy-regmap_anatop,
+   reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL);
+}
+
 static int mxs_phy_init(struct usb_phy *phy)
 {
struct mxs_phy *mxs_phy = to_mxs_phy(phy);
@@ -391,6 +414,8 @@ static int mxs_phy_probe(struct platform_device *pdev)
}
}
 
+   device_set_wakeup_capable(pdev-dev, true);
+
ret = usb_add_phy_dev(mxs_phy-phy);
if (ret)
return ret;
@@ -407,6 +432,28 @@ static int mxs_phy_remove(struct platform_device *pdev)
return 0;
 }
 
+static int mxs_phy_system_suspend(struct device *dev)
+{
+   struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
+
+   if (device_may_wakeup(dev))
+   mxs_phy_enable_ldo_in_suspend(mxs_phy, true);
+
+   return 0;
+}
+
+static int mxs_phy_system_resume(struct device *dev)
+{
+   struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
+
+   if (device_may_wakeup(dev))
+   mxs_phy_enable_ldo_in_suspend(mxs_phy, false);
+
+   return 0;
+}
+
+SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend, mxs_phy_system_resume);
+
 static struct platform_driver mxs_phy_driver = {
.probe = mxs_phy_probe,
.remove = mxs_phy_remove,
@@ -414,6 +461,7 @@ static struct platform_driver mxs_phy_driver = {
.name = DRIVER_NAME,
.owner  = THIS_MODULE,
.of_match_table = mxs_phy_dt_ids,
+   .pm = mxs_phy_pm,
 },
 };
 
-- 
1.7.8


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


[PATCH v4 08/17] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume

2013-12-03 Thread Peter Chen
Implementation of notify_suspend and notify_resume will be different
according to mxs_phy_data-flags.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   55 ++---
 1 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index d34df4c..8738890 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -166,8 +166,8 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
 static int mxs_phy_on_connect(struct usb_phy *phy,
enum usb_device_speed speed)
 {
-   dev_dbg(phy-dev, %s speed device has connected\n,
-   (speed == USB_SPEED_HIGH) ? high : non-high);
+   dev_dbg(phy-dev, %s device has connected\n,
+   (speed == USB_SPEED_HIGH) ? HS : FS/LS);
 
if (speed == USB_SPEED_HIGH)
writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
@@ -179,8 +179,8 @@ static int mxs_phy_on_connect(struct usb_phy *phy,
 static int mxs_phy_on_disconnect(struct usb_phy *phy,
enum usb_device_speed speed)
 {
-   dev_dbg(phy-dev, %s speed device has disconnected\n,
-   (speed == USB_SPEED_HIGH) ? high : non-high);
+   dev_dbg(phy-dev, %s device has disconnected\n,
+   (speed == USB_SPEED_HIGH) ? HS : FS/LS);
 
if (speed == USB_SPEED_HIGH)
writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
@@ -189,6 +189,48 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
return 0;
 }
 
+static int mxs_phy_on_suspend(struct usb_phy *phy,
+   enum usb_device_speed speed)
+{
+   struct mxs_phy *mxs_phy = to_mxs_phy(phy);
+
+   dev_dbg(phy-dev, %s device has suspended\n,
+   (speed == USB_SPEED_HIGH) ? HS : FS/LS);
+
+   /* delay 4ms to wait bus entering idle */
+   usleep_range(4000, 5000);
+
+   if (mxs_phy-data-flags  MXS_PHY_ABNORAML_IN_SUSPEND) {
+   writel_relaxed(0x, phy-io_priv + HW_USBPHY_PWD);
+   writel_relaxed(0, phy-io_priv + HW_USBPHY_PWD);
+   }
+
+   if (speed == USB_SPEED_HIGH)
+   writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+   phy-io_priv + HW_USBPHY_CTRL_CLR);
+
+   return 0;
+}
+
+/*
+ * The resume signal must be finished here.
+ */
+static int mxs_phy_on_resume(struct usb_phy *phy,
+   enum usb_device_speed speed)
+{
+   dev_dbg(phy-dev, %s device has resumed\n,
+   (speed == USB_SPEED_HIGH) ? HS : FS/LS);
+
+   if (speed == USB_SPEED_HIGH) {
+   /* Make sure the device has switched to High-Speed mode */
+   udelay(500);
+   writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+   phy-io_priv + HW_USBPHY_CTRL_SET);
+   }
+
+   return 0;
+}
+
 static int mxs_phy_probe(struct platform_device *pdev)
 {
struct resource *res;
@@ -235,6 +277,11 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mxs_phy);
 
+   if (mxs_phy-data-flags  MXS_PHY_SENDING_SOF_TOO_FAST) {
+   mxs_phy-phy.notify_suspend = mxs_phy_on_suspend;
+   mxs_phy-phy.notify_resume = mxs_phy_on_resume;
+   }
+
if (mxs_phy-data-flags  MXS_PHY_HAS_ANATOP) {
mxs_phy-regmap_anatop = syscon_regmap_lookup_by_phandle
(np, fsl,anatop);
-- 
1.7.8


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


[PATCH v4 06/17] usb: phy-mxs: Add anatop regmap

2013-12-03 Thread Peter Chen
It is needed by imx6 SoC series, but not for imx23 and imx28.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/phy/phy-mxs-usb.c |   23 +--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 70b084d..d34df4c 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -21,6 +21,8 @@
 #include linux/err.h
 #include linux/io.h
 #include linux/of_device.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
 
 #define DRIVER_NAME mxs_phy
 
@@ -58,6 +60,9 @@
  */
 #define MXS_PHY_SENDING_SOF_TOO_FAST   BIT(2)
 
+/* The SoCs who have anatop module */
+#define MXS_PHY_HAS_ANATOP BIT(3)
+
 struct mxs_phy_data {
unsigned int flags;
 };
@@ -68,11 +73,13 @@ static const struct mxs_phy_data imx23_phy_data = {
 
 static const struct mxs_phy_data imx6q_phy_data = {
.flags = MXS_PHY_SENDING_SOF_TOO_FAST |
-   MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+   MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
+   MXS_PHY_HAS_ANATOP,
 };
 
 static const struct mxs_phy_data imx6sl_phy_data = {
-   .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+   .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
+   MXS_PHY_HAS_ANATOP,
 };
 
 static const struct of_device_id mxs_phy_dt_ids[] = {
@@ -87,6 +94,7 @@ struct mxs_phy {
struct usb_phy phy;
struct clk *clk;
const struct mxs_phy_data *data;
+   struct regmap *regmap_anatop;
 };
 
 static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
@@ -190,6 +198,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
int ret;
const struct of_device_id *of_id =
of_match_device(mxs_phy_dt_ids, pdev-dev);
+   struct device_node *np = pdev-dev.of_node;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(pdev-dev, res);
@@ -226,6 +235,16 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, mxs_phy);
 
+   if (mxs_phy-data-flags  MXS_PHY_HAS_ANATOP) {
+   mxs_phy-regmap_anatop = syscon_regmap_lookup_by_phandle
+   (np, fsl,anatop);
+   if (IS_ERR(mxs_phy-regmap_anatop)) {
+   dev_dbg(pdev-dev,
+   failed to find regmap for anatop\n);
+   return PTR_ERR(mxs_phy-regmap_anatop);
+   }
+   }
+
ret = usb_add_phy_dev(mxs_phy-phy);
if (ret)
return ret;
-- 
1.7.8


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


[PATCH v4 04/17] usb: doc: phy-mxs: update binding for adding anatop phandle

2013-12-03 Thread Peter Chen
Add anatop phandle which is used to access anatop registers to
control PHY's power and other USB operations.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt 
b/Documentation/devicetree/bindings/usb/mxs-phy.txt
index d850e55..059536c 100644
--- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
+++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
@@ -5,10 +5,12 @@ Required properties:
 for imx6dq and imx6dl, fsl,imx6sl-usbphy for imx6sl
 - reg: Should contain registers location and length
 - interrupts: Should contain phy interrupt
+- fsl,anatop: phandle for anatop register, it is only for imx6 SoC series
 
 Example:
 usbphy1: usbphy@020c9000 {
compatible = fsl,imx6q-usbphy, fsl,imx23-usbphy;
reg = 0x020c9000 0x1000;
interrupts = 0 44 0x04;
+   fsl,anatop = anatop;
 };
-- 
1.7.8


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


[PATCH v4 10/17] usb: phy: Add set_wakeup API

2013-12-03 Thread Peter Chen
This API is used to set wakeup enable at PHY registers, in that
case, the PHY can be waken up from suspend due to external events,
like vbus change, dp/dm change and id change.

Signed-off-by: Peter Chen peter.c...@freescale.com
---
 include/linux/usb/phy.h |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a747960..c6ebe1d 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -111,6 +111,13 @@ struct usb_phy {
int (*set_suspend)(struct usb_phy *x,
int suspend);
 
+   /*
+* Set wakeup enable for PHY, in that case, the PHY can be
+* waken up from suspend status due to external events,
+* like vbus change, dp/dm change and id.
+*/
+   int (*set_wakeup)(struct usb_phy *x, bool enabled);
+
/* notify phy connect status change */
int (*notify_connect)(struct usb_phy *x,
enum usb_device_speed speed);
@@ -270,6 +277,15 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend)
 }
 
 static inline int
+usb_phy_set_wakeup(struct usb_phy *x, bool enabled)
+{
+   if (x  x-set_wakeup)
+   return x-set_wakeup(x, enabled);
+   else
+   return 0;
+}
+
+static inline int
 usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed)
 {
if (x  x-notify_connect)
-- 
1.7.8


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


Re: [PATCH 3/3] usb: phy-generic: Add ULPI VBUS support

2013-12-03 Thread Heikki Krogerus
On Mon, Dec 02, 2013 at 03:05:19PM +0800, Chris Ruehl wrote:
 @@ -154,6 +164,27 @@ int usb_phy_gen_create_phy(struct device *dev, struct 
 usb_phy_gen_xceiv *nop,
  {
   int err;
  
 + if (nop-ulpi_vbus  0) {
 + unsigned int flags = 0;
 +
 + if (nop-ulpi_vbus  0x1)
 + flags |= ULPI_OTG_DRVVBUS;
 + if (nop-ulpi_vbus  0x2)
 + flags |= ULPI_OTG_DRVVBUS_EXT;
 + if (nop-ulpi_vbus  0x4)
 + flags |= ULPI_OTG_EXTVBUSIND;
 + if (nop-ulpi_vbus  0x8)
 + flags |= ULPI_OTG_CHRGVBUS;
 +
 + nop-ulpi = otg_ulpi_create(ulpi_viewport_access_ops, flags);
 + if (!nop-ulpi) {
 + dev_err(dev, Failed create ULPI Phy\n);
 + return -ENOMEM;
 + }
 + dev_dbg(dev, Create ULPI Phy\n);
 + nop-ulpi-io_priv =  nop-viewport;
 + }

This is so wrong. You are registering one kind of usb phy driver from
an other. Change drivers/usb/phy/ulpi.c to be a platform device. The
whole flag system in it is pretty horrid. While you are at it, change
that so it sets the values based on boolean flags from OF properties
or platform data.

NAK for the whole set.


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


Re: [PATCH v4 09/17] usb: phy-mxs: Enable IC fixes for related SoCs

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 08:37 AM, Peter Chen wrote:
 Some PHY bugs are fixed by IC logic, but these bits are not
 enabled by default, so we enable them at driver.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/phy/phy-mxs-usb.c |   20 
  1 files changed, 20 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
 index 8738890..0908d74 100644
 --- a/drivers/usb/phy/phy-mxs-usb.c
 +++ b/drivers/usb/phy/phy-mxs-usb.c
 @@ -31,6 +31,10 @@
  #define HW_USBPHY_CTRL_SET   0x34
  #define HW_USBPHY_CTRL_CLR   0x38
  
 +#define HW_USBPHY_IP 0x90
 +#define HW_USBPHY_IP_SET 0x94
 +#define HW_USBPHY_IP_CLR 0x98
 +
  #define BM_USBPHY_CTRL_SFTRSTBIT(31)
  #define BM_USBPHY_CTRL_CLKGATE   BIT(30)
  #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26)
 @@ -42,6 +46,8 @@
  #define BM_USBPHY_CTRL_ENUTMILEVEL2  BIT(14)
  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECTBIT(1)
  
 +#define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
 +
  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
  
  /* Do disconnection between PHY and controller without vbus */
 @@ -97,6 +103,16 @@ struct mxs_phy {
   struct regmap *regmap_anatop;
  };
  
 +static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
 +{
 + return mxs_phy-data == imx6q_phy_data;
 +}
 +
 +static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
 +{
 + return mxs_phy-data == imx6sl_phy_data;
 +}

Why don't you use a a BIT() here as in Patch 2/17, too?

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4 16/17] usb: phy-mxs: fix the problem by only using 1st controller's register

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 08:37 AM, Peter Chen wrote:
 We fix the problem that we only use the 1st controller's related
 registers at mxs_phy_disconnect_line, but in fact, it needs to
 access registers according to different PHYs.

Are you fixing the code that has been added in this series before? If
so, please squash into the patch. Don't add the broken code in the first
place.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v4 02/17] usb: phy-mxs: Add platform judgement code

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 08:36 AM, Peter Chen wrote:
 The mxs-phy has several bugs and features at different
 versions, the driver code can get it through of_device_id.data.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/phy/phy-mxs-usb.c |   58 ++--
  1 files changed, 49 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
 index 545844b..f6cbc78 100644
 --- a/drivers/usb/phy/phy-mxs-usb.c
 +++ b/drivers/usb/phy/phy-mxs-usb.c
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2012 Freescale Semiconductor, Inc.
 + * Copyright 2012-2013 Freescale Semiconductor, Inc.
   * Copyright (C) 2012 Marek Vasut ma...@denx.de
   * on behalf of DENX Software Engineering GmbH
   *
 @@ -20,6 +20,7 @@
  #include linux/delay.h
  #include linux/err.h
  #include linux/io.h
 +#include linux/of_device.h
  
  #define DRIVER_NAME mxs_phy
  
 @@ -34,13 +35,55 @@
  #define BM_USBPHY_CTRL_ENUTMILEVEL2  BIT(14)
  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECTBIT(1)
  
 +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 +
 +/* Do disconnection between PHY and controller without vbus */
 +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0)
 +
 +/*
 + * The PHY will be in messy if there is an wakeup after putting
   ^^
   a
Do you mean messy state?

 + * bus to suspend (set portsc.suspendM) but before setting PHY to low
 + * power mode (set portsc.phcd).
 + */

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


RE: [PATCH v4 09/17] usb: phy-mxs: Enable IC fixes for related SoCs

2013-12-03 Thread Peter Chen
 
 
 On 12/03/2013 08:37 AM, Peter Chen wrote:
  Some PHY bugs are fixed by IC logic, but these bits are not
  enabled by default, so we enable them at driver.
 
  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
   drivers/usb/phy/phy-mxs-usb.c |   20 
   1 files changed, 20 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-
 usb.c
  index 8738890..0908d74 100644
  --- a/drivers/usb/phy/phy-mxs-usb.c
  +++ b/drivers/usb/phy/phy-mxs-usb.c
  @@ -31,6 +31,10 @@
   #define HW_USBPHY_CTRL_SET 0x34
   #define HW_USBPHY_CTRL_CLR 0x38
 
  +#define HW_USBPHY_IP   0x90
  +#define HW_USBPHY_IP_SET   0x94
  +#define HW_USBPHY_IP_CLR   0x98
  +
   #define BM_USBPHY_CTRL_SFTRST  BIT(31)
   #define BM_USBPHY_CTRL_CLKGATE BIT(30)
   #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS   BIT(26)
  @@ -42,6 +46,8 @@
   #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
   #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
 
  +#define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
  +
   #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
   /* Do disconnection between PHY and controller without vbus */
  @@ -97,6 +103,16 @@ struct mxs_phy {
  struct regmap *regmap_anatop;
   };
 
  +static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
  +{
  +   return mxs_phy-data == imx6q_phy_data;
  +}
  +
  +static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
  +{
  +   return mxs_phy-data == imx6sl_phy_data;
  +}
 
 Why don't you use a a BIT() here as in Patch 2/17, too?
 
 
Thanks, I will define the two PHY problems as the register bit
position at 2/17, and use those two MACROs at this patch.
Is it your point?

Peter





Re: [PATCH v4 02/17] usb: phy-mxs: Add platform judgement code

2013-12-03 Thread Peter Chen
On Tue, Dec 03, 2013 at 09:38:20AM +0100, Marc Kleine-Budde wrote:
 On 12/03/2013 08:36 AM, Peter Chen wrote:
  The mxs-phy has several bugs and features at different
  versions, the driver code can get it through of_device_id.data.
  
  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
   drivers/usb/phy/phy-mxs-usb.c |   58 
  ++--
   1 files changed, 49 insertions(+), 9 deletions(-)
  
  diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
  index 545844b..f6cbc78 100644
  --- a/drivers/usb/phy/phy-mxs-usb.c
  +++ b/drivers/usb/phy/phy-mxs-usb.c
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 2012 Freescale Semiconductor, Inc.
  + * Copyright 2012-2013 Freescale Semiconductor, Inc.
* Copyright (C) 2012 Marek Vasut ma...@denx.de
* on behalf of DENX Software Engineering GmbH
*
  @@ -20,6 +20,7 @@
   #include linux/delay.h
   #include linux/err.h
   #include linux/io.h
  +#include linux/of_device.h
   
   #define DRIVER_NAME mxs_phy
   
  @@ -34,13 +35,55 @@
   #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
   #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)
   
  +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
  +
  +/* Do disconnection between PHY and controller without vbus */
  +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS   BIT(0)
  +
  +/*
  + * The PHY will be in messy if there is an wakeup after putting
^^
a
 Do you mean messy state?

Yes, will change the typo.


-- 

Best Regards,
Peter Chen

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


Re: [PATCH v4 16/17] usb: phy-mxs: fix the problem by only using 1st controller's register

2013-12-03 Thread Peter Chen
On Tue, Dec 03, 2013 at 09:34:09AM +0100, Marc Kleine-Budde wrote:
 On 12/03/2013 08:37 AM, Peter Chen wrote:
  We fix the problem that we only use the 1st controller's related
  registers at mxs_phy_disconnect_line, but in fact, it needs to
  access registers according to different PHYs.
 
 Are you fixing the code that has been added in this series before? If
 so, please squash into the patch. Don't add the broken code in the first
 place.
 

Thanks, will do squash

-- 

Best Regards,
Peter Chen

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


Re: [PATCH v4 09/17] usb: phy-mxs: Enable IC fixes for related SoCs

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 09:38 AM, Peter Chen wrote:
  

 On 12/03/2013 08:37 AM, Peter Chen wrote:
 Some PHY bugs are fixed by IC logic, but these bits are not
 enabled by default, so we enable them at driver.

 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/phy/phy-mxs-usb.c |   20 
  1 files changed, 20 insertions(+), 0 deletions(-)

 diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-
 usb.c
 index 8738890..0908d74 100644
 --- a/drivers/usb/phy/phy-mxs-usb.c
 +++ b/drivers/usb/phy/phy-mxs-usb.c
 @@ -31,6 +31,10 @@
  #define HW_USBPHY_CTRL_SET 0x34
  #define HW_USBPHY_CTRL_CLR 0x38

 +#define HW_USBPHY_IP   0x90
 +#define HW_USBPHY_IP_SET   0x94
 +#define HW_USBPHY_IP_CLR   0x98
 +
  #define BM_USBPHY_CTRL_SFTRST  BIT(31)
  #define BM_USBPHY_CTRL_CLKGATE BIT(30)
  #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS   BIT(26)
 @@ -42,6 +46,8 @@
  #define BM_USBPHY_CTRL_ENUTMILEVEL2BIT(14)
  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT  BIT(1)

 +#define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
 +
  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)

  /* Do disconnection between PHY and controller without vbus */
 @@ -97,6 +103,16 @@ struct mxs_phy {
 struct regmap *regmap_anatop;
  };

 +static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
 +{
 +   return mxs_phy-data == imx6q_phy_data;
 +}
 +
 +static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
 +{
 +   return mxs_phy-data == imx6sl_phy_data;
 +}

 Why don't you use a a BIT() here as in Patch 2/17, too?

  
 Thanks, I will define the two PHY problems as the register bit
 position at 2/17, and use those two MACROs at this patch.
 Is it your point?

I was wondering if the driver looks more uniform if you use something
like this:

#define MXS_PHY_NEED_IP_FIX BIT(3)

  static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
  {
   int ret;
 @@ -123,6 +139,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
   BM_USBPHY_CTRL_ENUTMILEVEL3,
  base + HW_USBPHY_CTRL_SET);
  
 + /* Enable IC solution */
 + if (is_imx6q_phy(mxs_phy) || is_imx6sl_phy(mxs_phy))

if (mxs_phy-data-flags  MXS_PHY_NEED_IP_FIX)

 + writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
 +
   return 0;
  }

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 2/2] Indent with tab instead of spaces.

2013-12-03 Thread Oliver Neukum
On Mon, 2013-12-02 at 13:19 +0100, David Cluytens wrote:
 From: David Cluytens david.cluytens_...@softathome.com

Please see the FAQ on submitting kernel patches in the Documentation
directory of the kernel. Your patches need a Signed-off-by line.

Regards
Oliver


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


RE: [PATCH v4 09/17] usb: phy-mxs: Enable IC fixes for related SoCs

2013-12-03 Thread Peter Chen


 
 On 12/03/2013 09:38 AM, Peter Chen wrote:
 
 
  On 12/03/2013 08:37 AM, Peter Chen wrote:
  Some PHY bugs are fixed by IC logic, but these bits are not
  enabled by default, so we enable them at driver.
 
  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
   drivers/usb/phy/phy-mxs-usb.c |   20 
   1 files changed, 20 insertions(+), 0 deletions(-)
 
  diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-
  usb.c
  index 8738890..0908d74 100644
  --- a/drivers/usb/phy/phy-mxs-usb.c
  +++ b/drivers/usb/phy/phy-mxs-usb.c
  @@ -31,6 +31,10 @@
   #define HW_USBPHY_CTRL_SET   0x34
   #define HW_USBPHY_CTRL_CLR   0x38
 
  +#define HW_USBPHY_IP 0x90
  +#define HW_USBPHY_IP_SET 0x94
  +#define HW_USBPHY_IP_CLR 0x98
  +
   #define BM_USBPHY_CTRL_SFTRSTBIT(31)
   #define BM_USBPHY_CTRL_CLKGATE   BIT(30)
   #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS BIT(26)
  @@ -42,6 +46,8 @@
   #define BM_USBPHY_CTRL_ENUTMILEVEL2  BIT(14)
   #define BM_USBPHY_CTRL_ENHOSTDISCONDETECTBIT(1)
 
  +#define BM_USBPHY_IP_FIX   (BIT(17) | BIT(18))
  +
   #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
   /* Do disconnection between PHY and controller without vbus */
  @@ -97,6 +103,16 @@ struct mxs_phy {
struct regmap *regmap_anatop;
   };
 
  +static inline bool is_imx6q_phy(struct mxs_phy *mxs_phy)
  +{
  + return mxs_phy-data == imx6q_phy_data;
  +}
  +
  +static inline bool is_imx6sl_phy(struct mxs_phy *mxs_phy)
  +{
  + return mxs_phy-data == imx6sl_phy_data;
  +}
 
  Why don't you use a a BIT() here as in Patch 2/17, too?
 
 
  Thanks, I will define the two PHY problems as the register bit
  position at 2/17, and use those two MACROs at this patch.
  Is it your point?
 
 I was wondering if the driver looks more uniform if you use something
 like this:
 
 #define MXS_PHY_NEED_IP_FIX   BIT(3)
 

OK, will change like below:

if (mxs_phy-data-flags  MXS_PHY_NEED_IP_FIX)
writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);

Peter



Re: [PATCH v4 17/17] usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 08:37 AM, Peter Chen wrote:
 At very rare cases, the SoF will not send out after resume with
 low speed connection. The workaround is do not power down
 PWD.RXPWD1PT1 bit during the suspend.

Is this also a fix for newly added code? If so please also squash.

 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/phy/phy-mxs-usb.c |   47 
 -
  1 files changed, 46 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
 index 542b6ec..5ae4a57 100644
 --- a/drivers/usb/phy/phy-mxs-usb.c
 +++ b/drivers/usb/phy/phy-mxs-usb.c
 @@ -69,6 +69,9 @@
  #define ANADIG_USB2_LOOPBACK_SET 0x244
  #define ANADIG_USB2_LOOPBACK_CLR 0x248
  
 +#define ANADIG_USB1_MISC 0x1f0
 +#define ANADIG_USB2_MISC 0x250
 +
  #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG BIT(12)
  #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
  
 @@ -80,6 +83,11 @@
  #define BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1BIT(2)
  #define BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN   BIT(5)
  
 +#define BM_ANADIG_USB1_MISC_RX_VPIN_FS   BIT(29)
 +#define BM_ANADIG_USB1_MISC_RX_VMIN_FS   BIT(28)
 +#define BM_ANADIG_USB2_MISC_RX_VPIN_FS   BIT(29)
 +#define BM_ANADIG_USB2_MISC_RX_VMIN_FS   BIT(28)
 +
  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
  
  /* Do disconnection between PHY and controller without vbus */
 @@ -296,12 +304,49 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
   clk_disable_unprepare(mxs_phy-clk);
  }
  
 +static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy)
 +{
 + unsigned int line_state;
 + /* bit definition is the same for all controllers */
 + unsigned int dp_bit = BM_ANADIG_USB1_MISC_RX_VPIN_FS,
 +  dm_bit = BM_ANADIG_USB1_MISC_RX_VMIN_FS;
 + unsigned int reg = ANADIG_USB1_MISC;
 +
 + /* If the SoCs don't have anatop, quit */
 + if (!mxs_phy-regmap_anatop)
 + return false;
 +
 + if (mxs_phy-port_id == 0)
 + reg = ANADIG_USB1_MISC;
 + else if (mxs_phy-port_id == 1)
 + reg = ANADIG_USB2_MISC;
 +
 + regmap_read(mxs_phy-regmap_anatop, reg, line_state);
 +
 + if ((line_state  (dp_bit | dm_bit)) ==  dm_bit)
 + return true;
 + else
 + return false;
 +}
 +
  static int mxs_phy_suspend(struct usb_phy *x, int suspend)
  {
   struct mxs_phy *mxs_phy = to_mxs_phy(x);
 + bool low_speed_connection, vbus_is_on;
 +
 + low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy);
 + vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
  
   if (suspend) {
 - writel(0x, x-io_priv + HW_USBPHY_PWD);
 + /*
 +  * FIXME: Do not power down RXPWD1PT1 bit for low speed

Is this FIXME still true?

 +  * connect. The low speed connection will have problem at
 +  * very rare cases during usb suspend and resume process.
 +  */
 + if (low_speed_connection  vbus_is_on)
 + writel(0xfffb, x-io_priv + HW_USBPHY_PWD);
 + else
 + writel(0x, x-io_priv + HW_USBPHY_PWD);
   writel(BM_USBPHY_CTRL_CLKGATE,
  x-io_priv + HW_USBPHY_CTRL_SET);
   clk_disable_unprepare(mxs_phy-clk);
 

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


RE: [PATCH v4 17/17] usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

2013-12-03 Thread Peter Chen

 
 
 On 12/03/2013 08:37 AM, Peter Chen wrote:
  At very rare cases, the SoF will not send out after resume with
  low speed connection. The workaround is do not power down
  PWD.RXPWD1PT1 bit during the suspend.
 
 Is this also a fix for newly added code? If so please also squash.
 

No, it is a workaround for new problem.

  Signed-off-by: Peter Chen peter.c...@freescale.com
  ---
   drivers/usb/phy/phy-mxs-usb.c |   47
 -
   1 files changed, 46 insertions(+), 1 deletions(-)
 
  diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-
 usb.c
  index 542b6ec..5ae4a57 100644
  --- a/drivers/usb/phy/phy-mxs-usb.c
  +++ b/drivers/usb/phy/phy-mxs-usb.c
  @@ -69,6 +69,9 @@
   #define ANADIG_USB2_LOOPBACK_SET   0x244
   #define ANADIG_USB2_LOOPBACK_CLR   0x248
 
  +#define ANADIG_USB1_MISC   0x1f0
  +#define ANADIG_USB2_MISC   0x250
  +
   #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG   BIT(12)
   #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
 
  @@ -80,6 +83,11 @@
   #define BM_ANADIG_USB2_LOOPBACK_UTMI_DIG_TST1  BIT(2)
   #define BM_ANADIG_USB2_LOOPBACK_TSTI_TX_EN BIT(5)
 
  +#define BM_ANADIG_USB1_MISC_RX_VPIN_FS BIT(29)
  +#define BM_ANADIG_USB1_MISC_RX_VMIN_FS BIT(28)
  +#define BM_ANADIG_USB2_MISC_RX_VPIN_FS BIT(29)
  +#define BM_ANADIG_USB2_MISC_RX_VMIN_FS BIT(28)
  +
   #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
   /* Do disconnection between PHY and controller without vbus */
  @@ -296,12 +304,49 @@ static void mxs_phy_shutdown(struct usb_phy *phy)
  clk_disable_unprepare(mxs_phy-clk);
   }
 
  +static bool mxs_phy_is_low_speed_connection(struct mxs_phy *mxs_phy)
  +{
  +   unsigned int line_state;
  +   /* bit definition is the same for all controllers */
  +   unsigned int dp_bit = BM_ANADIG_USB1_MISC_RX_VPIN_FS,
  +dm_bit = BM_ANADIG_USB1_MISC_RX_VMIN_FS;
  +   unsigned int reg = ANADIG_USB1_MISC;
  +
  +   /* If the SoCs don't have anatop, quit */
  +   if (!mxs_phy-regmap_anatop)
  +   return false;
  +
  +   if (mxs_phy-port_id == 0)
  +   reg = ANADIG_USB1_MISC;
  +   else if (mxs_phy-port_id == 1)
  +   reg = ANADIG_USB2_MISC;
  +
  +   regmap_read(mxs_phy-regmap_anatop, reg, line_state);
  +
  +   if ((line_state  (dp_bit | dm_bit)) ==  dm_bit)
  +   return true;
  +   else
  +   return false;
  +}
  +
   static int mxs_phy_suspend(struct usb_phy *x, int suspend)
   {
  struct mxs_phy *mxs_phy = to_mxs_phy(x);
  +   bool low_speed_connection, vbus_is_on;
  +
  +   low_speed_connection = mxs_phy_is_low_speed_connection(mxs_phy);
  +   vbus_is_on = mxs_phy_get_vbus_status(mxs_phy);
 
  if (suspend) {
  -   writel(0x, x-io_priv + HW_USBPHY_PWD);
  +   /*
  +* FIXME: Do not power down RXPWD1PT1 bit for low speed
 
 Is this FIXME still true?

Yes, still not find the root cause.

Peter

 
  +* connect. The low speed connection will have problem at
  +* very rare cases during usb suspend and resume process.
  +*/
  +   if (low_speed_connection  vbus_is_on)
  +   writel(0xfffb, x-io_priv + HW_USBPHY_PWD);
  +   else
  +   writel(0x, x-io_priv + HW_USBPHY_PWD);
  writel(BM_USBPHY_CTRL_CLKGATE,
 x-io_priv + HW_USBPHY_CTRL_SET);
  clk_disable_unprepare(mxs_phy-clk);
 
 
 Marc
 
 --
 Pengutronix e.K.  | Marc Kleine-Budde   |
 Industrial Linux Solutions| Phone: +49-231-2826-924 |
 Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
 Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h����G���h�(�階�ݢj���m��z�ޖ���f���h���~�m�

Re: [PATCH v4 17/17] usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 10:19 AM, Peter Chen wrote:
 On 12/03/2013 08:37 AM, Peter Chen wrote:
 At very rare cases, the SoF will not send out after resume with
 low speed connection. The workaround is do not power down
 PWD.RXPWD1PT1 bit during the suspend.

 Is this also a fix for newly added code? If so please also squash.

 No, it is a workaround for new problem.

If this would be a fix, it's better to put this as first patch into a
series, so that it can be applied to the stable trees easier.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] ARM: dts: omap3-beagle: Fix USB host on beagle boards (for 3.13)

2013-12-03 Thread Roger Quadros
Hi Laurent,

On 12/03/2013 05:54 AM, Laurent Pinchart wrote:
 Hi Roger,
 
 On Monday 25 November 2013 15:55:45 Roger Quadros wrote:
 Beagle (rev. C4) and Beagle-XM (all revs) need VAUX2 1.8V supply
 for the USB PHY.

 As the generic PHY driver can't handle more than one supply
 at the moment, we configure this supply to be always on.
 This will cause a very small power impact if the USB host subsystem
 is not in use, about 76.86 micro-W + LDO power.

 Older Beagle boards (prior to C4) don't have VAUX2 connected anywhere,
 so there won't be any functional impact on those boards other than
 some additional LDO power consumption.
 
 Do I need any patch other than this one (on top of v3.13-rc1) to enable the
 ethernet port on a Beagleboard-xM rev B ? Here's what the kernel reports at
 boot (with ignore_loglevel set on the command line).
 

It seems on Rev A/B, the power enable line for the USB hub has reversed polarity
than Rev C.

Does the below patch work for you?

If yes, how do we account for it? Do we add a new file omap3-beagle-xm-ab.dts 
for
rev A/B boards?

cheers,
-roger

diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts 
b/arch/arm/boot/dts/omap3-beagle-xm.dts
index b39918e..434d903 100644
--- a/arch/arm/boot/dts/omap3-beagle-xm.dts
+++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
@@ -78,6 +78,7 @@
regulator-max-microvolt = 330;
gpio = twl_gpio 18 0;/* GPIO LEDA */
startup-delay-us = 7;
+   enable-active-high;
};
 
/* HS USB Host PHY on PORT 2 */

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


Re: [PATCH 1/1] mfd: omap-usb-host: Fix USB device detection problems on OMAP4 Panda

2013-12-03 Thread Roger Quadros
On 12/02/2013 06:28 PM, David Laight wrote:
 From: Roger Quadros [mailto:rog...@ti.com]
 On 11/29/2013 03:17 PM, David Laight wrote:
 ...
 +  timeout = jiffies + msecs_to_jiffies(100);
 +  while (!(usbhs_read(omap-uhh_base, OMAP_UHH_SYSSTATUS)
 +   OMAP_UHH_SYSSTATUS_RESETDONE)) {
 +  cpu_relax();

 You mean use msleep(1) here instead of cpu_relax()?
 Shouldn't be a problem IMO, but can you please tell me why that is better
 as the reset seems to complete usually in the first iteration.
 
 If it doesn't finish in the first iteration you don't want to
 spin the cpu for 100ms.
 
 If it hasn't finished in the first millisecond, you probably expect
 it to actually time out - so you might as well look (say) every 10ms.
 

Understood now. Thanks.

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


RE: [PATCH v4 17/17] usb: phy-mxs: do not set PWD.RXPWD1PT1 for low speed connection

2013-12-03 Thread Peter Chen
 
 
 On 12/03/2013 10:19 AM, Peter Chen wrote:
  On 12/03/2013 08:37 AM, Peter Chen wrote:
  At very rare cases, the SoF will not send out after resume with
  low speed connection. The workaround is do not power down
  PWD.RXPWD1PT1 bit during the suspend.
 
  Is this also a fix for newly added code? If so please also squash.
 
  No, it is a workaround for new problem.
 
 If this would be a fix, it's better to put this as first patch into a
 series, so that it can be applied to the stable trees easier.
 

It is introduced by [3/17], without [3/17] it needs another fix which
we have not intended to use. I will squash them, thanks.

Peter

 




Re: [PATCH v2 1/7] usb: dwc3: get usb_phy only if the platform indicates the presence of PHY's

2013-12-03 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 26 November 2013 03:02 AM, Felipe Balbi wrote:
 Hi,
 
 On Mon, Nov 11, 2013 at 08:06:12PM +0530, Kishon Vijay Abraham I wrote:
 diff --git a/drivers/usb/dwc3/platform_data.h 
 b/drivers/usb/dwc3/platform_data.h
 index 7db34f0..49ffa6d 100644
 --- a/drivers/usb/dwc3/platform_data.h
 +++ b/drivers/usb/dwc3/platform_data.h
 @@ -24,4 +24,6 @@ struct dwc3_platform_data {
enum usb_device_speed maximum_speed;
enum usb_dr_mode dr_mode;
bool tx_fifo_resize;
 +  bool usb2_phy;
 +  bool usb3_phy;

 This would look better as a quirks flag, then we could:

 unsigned long quirks;
 #define DWC3_QUIRK_NO_USB3_PHY  BIT(0)
 #define DWC3_QUIRK_NO_USB2_PHY  BIT(1)

 Should this quirk be used for dt also? Currently we find if it has usb3 phy 
 or
 usb2 phy from the dt data only. But if we add a quirk, we'll have to add a
 property to populate the quirk no?
 
 either we use the quirk, or use the fact that no usb2_phy phandle is
 defined, would work both ways, no ?

In my v3, I've made both to use quirks since we don't want to have separate
mechanism for dt and non-dt stuff to know the presence of a particular PHY.

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


Re: [PATCH v4 02/17] usb: phy-mxs: Add platform judgement code

2013-12-03 Thread Michael Grzeschik
On Tue, Dec 03, 2013 at 03:36:56PM +0800, Peter Chen wrote:
 The mxs-phy has several bugs and features at different
 versions, the driver code can get it through of_device_id.data.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/phy/phy-mxs-usb.c |   58 ++--
  1 files changed, 49 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
 index 545844b..f6cbc78 100644
 --- a/drivers/usb/phy/phy-mxs-usb.c
 +++ b/drivers/usb/phy/phy-mxs-usb.c
 @@ -1,5 +1,5 @@
  /*
 - * Copyright 2012 Freescale Semiconductor, Inc.
 + * Copyright 2012-2013 Freescale Semiconductor, Inc.
   * Copyright (C) 2012 Marek Vasut ma...@denx.de
   * on behalf of DENX Software Engineering GmbH
   *
 @@ -20,6 +20,7 @@
  #include linux/delay.h
  #include linux/err.h
  #include linux/io.h
 +#include linux/of_device.h
  
  #define DRIVER_NAME mxs_phy
  
 @@ -34,13 +35,55 @@
  #define BM_USBPHY_CTRL_ENUTMILEVEL2  BIT(14)
  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECTBIT(1)
  
 +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 +
 +/* Do disconnection between PHY and controller without vbus */
 +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0)
 +
 +/*
 + * The PHY will be in messy if there is an wakeup after putting
 + * bus to suspend (set portsc.suspendM) but before setting PHY to low
 + * power mode (set portsc.phcd).
 + */
 +#define MXS_PHY_ABNORAML_IN_SUSPEND  BIT(1)

ABNORAML? - ABNORMAL

 +
 +/*
 + * The SOF sends too fast after resuming, it will cause disconnection
 + * between host and high speed device.
 + */
 +#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
 +
 +struct mxs_phy_data {
 + unsigned int flags;
 +};
 +
 +static const struct mxs_phy_data imx23_phy_data = {
 + .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
 +};

ABNORAML? - ABNORMAL

 +
 +static const struct mxs_phy_data imx6q_phy_data = {
 + .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
 + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
 +};
 +
 +static const struct mxs_phy_data imx6sl_phy_data = {
 + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
 +};
 +
 +static const struct of_device_id mxs_phy_dt_ids[] = {
 + { .compatible = fsl,imx6sl-usbphy, .data = imx6sl_phy_data, },
 + { .compatible = fsl,imx6q-usbphy, .data = imx6q_phy_data, },
 + { .compatible = fsl,imx23-usbphy, .data = imx23_phy_data, },
 + { /* sentinel */ }
 +};
 +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
 +
  struct mxs_phy {
   struct usb_phy phy;
   struct clk *clk;
 + const struct mxs_phy_data *data;
  };
  
 -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 -
  static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
  {
   int ret;
 @@ -131,6 +174,8 @@ static int mxs_phy_probe(struct platform_device *pdev)
   struct clk *clk;
   struct mxs_phy *mxs_phy;
   int ret;
 + const struct of_device_id *of_id =
 + of_match_device(mxs_phy_dt_ids, pdev-dev);
  
   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   base = devm_ioremap_resource(pdev-dev, res);
 @@ -163,6 +208,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
   ATOMIC_INIT_NOTIFIER_HEAD(mxs_phy-phy.notifier);
  
   mxs_phy-clk = clk;
 + mxs_phy-data = of_id-data;
  
   platform_set_drvdata(pdev, mxs_phy);
  
 @@ -182,12 +228,6 @@ static int mxs_phy_remove(struct platform_device *pdev)
   return 0;
  }
  
 -static const struct of_device_id mxs_phy_dt_ids[] = {
 - { .compatible = fsl,imx23-usbphy, },
 - { /* sentinel */ }
 -};
 -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
 -
  static struct platform_driver mxs_phy_driver = {
   .probe = mxs_phy_probe,
   .remove = mxs_phy_remove,
 -- 
 1.7.8
 
 
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/7] usb: dwc3: get usb_phy only if the platform indicates the presence of PHY's

2013-12-03 Thread Heikki Krogerus
Hi,

On Thu, Oct 17, 2013 at 09:54:26AM -0500, Felipe Balbi wrote:
 On Wed, Oct 16, 2013 at 04:27:26PM +0300, Roger Quadros wrote:
  On 10/16/2013 04:10 PM, Kishon Vijay Abraham I wrote:
  Do you know if there are users of dwc3 other than exynos5250 and omap5?
  If not, we should get rid of the old USB PHY altogether.
 
 Intel's Baytrail, at least. But they don't use DT.

I don't see any use for the generic-phy when the device is enumerated
from PCI. If dwc3 can live without phys, there should not be any
problem dropping the old USB PHY support.

Br,

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


Re: [PATCH] ARM: dts: omap3-beagle: Fix USB host on beagle boards (for 3.13)

2013-12-03 Thread Laurent Pinchart
Hi Roger,

On Tuesday 03 December 2013 11:36:57 Roger Quadros wrote:
 On 12/03/2013 05:54 AM, Laurent Pinchart wrote:
  Hi Roger,
  
  On Monday 25 November 2013 15:55:45 Roger Quadros wrote:
  Beagle (rev. C4) and Beagle-XM (all revs) need VAUX2 1.8V supply
  for the USB PHY.
  
  As the generic PHY driver can't handle more than one supply
  at the moment, we configure this supply to be always on.
  This will cause a very small power impact if the USB host subsystem
  is not in use, about 76.86 micro-W + LDO power.
  
  Older Beagle boards (prior to C4) don't have VAUX2 connected anywhere,
  so there won't be any functional impact on those boards other than
  some additional LDO power consumption.
  
  Do I need any patch other than this one (on top of v3.13-rc1) to enable
  the ethernet port on a Beagleboard-xM rev B ? Here's what the kernel
  reports at boot (with ignore_loglevel set on the command line).
 
 It seems on Rev A/B, the power enable line for the USB hub has reversed
 polarity than Rev C.
 
 Does the below patch work for you?

It does, thank you.

 If yes, how do we account for it? Do we add a new file
 omap3-beagle-xm-ab.dts for rev A/B boards?

Unless we want to add board code back with a runtime check, which I doubt 
would be regarded as a good idea, I don't see any other easy solution.

 diff --git a/arch/arm/boot/dts/omap3-beagle-xm.dts
 b/arch/arm/boot/dts/omap3-beagle-xm.dts index b39918e..434d903 100644
 --- a/arch/arm/boot/dts/omap3-beagle-xm.dts
 +++ b/arch/arm/boot/dts/omap3-beagle-xm.dts
 @@ -78,6 +78,7 @@
   regulator-max-microvolt = 330;
   gpio = twl_gpio 18 0;/* GPIO LEDA */
   startup-delay-us = 7;
 + enable-active-high;
   };
 
   /* HS USB Host PHY on PORT 2 */

-- 
Regards,

Laurent Pinchart

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


Re: [PATCH 1/3 v4] usb: chipidea: Reallocate regmap only if lpm is detected

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 09:01 AM, Chris Ruehl wrote:
 usb: chipidea: Reallocate regmap only if lpm is detected
 
 The regmap only needs to reallocate if the hw_read on the CAP register shows
 lpm is used. Therefore the if() statement check the change.
 
 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 Acked-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/chipidea/core.c |7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 5d8981c..9a5ef20 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void 
 __iomem *base)
   reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
   __ffs(HCCPARAMS_LEN);
   ci-hw_bank.lpm  = reg;
 - hw_alloc_regmap(ci, !!reg);
 + if (reg)
 + hw_alloc_regmap(ci, !!reg);
   ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
   ci-hw_bank.size += OP_LAST;
   ci-hw_bank.size /= sizeof(u32);
 @@ -642,6 +643,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
   : CI_ROLE_GADGET;
   }
  
 + /* only update vbus status for peripheral */
 + if (ci-role == CI_ROLE_GADGET)
 + ci_handle_vbus_change(ci);
 +

This change seems unrelated to me.

Marc

   ret = ci_role_start(ci, ci-role);
   if (ret) {
   dev_err(dev, can't start %s role\n, ci_role(ci)-name);
 


-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Alexander Shishkin
Greg KH gre...@linuxfoundation.org writes:

 From: Greg Kroah-Hartman gre...@linuxfoundation.org

 Alexander isn't able to maintain the Chipidea code anymore, and as Peter
 has been acting as the de-facto maintainer anyway, make it official.

 Cc: Alexander Shishkin alexander.shish...@linux.intel.com
 Cc: Peter Chen peter.c...@freescale.com
 Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

Acked-by: Alexander Shishkin alexander.shish...@linux.intel.com

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


Re: [PATCH v2 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-12-03 Thread Heikki Krogerus
Hi Kishon,

On Wed, Oct 16, 2013 at 01:24:12AM +0530, Kishon Vijay Abraham I wrote:
 + count = of_property_match_string(node, phy-names, usb2-phy);
 + if (count = 0 || (pdata  pdata-usb2_generic_phy)) {
 + dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 + if (IS_ERR(dwc-usb2_generic_phy)) {
 + dev_err(dev, no usb2 phy configured yet);
 + return PTR_ERR(dwc-usb2_generic_phy);
 + }
 + dwc-usb2_phy = NULL;
 + }
 +
 + count = of_property_match_string(node, phy-names, usb3-phy);
 + if (count = 0 || (pdata  pdata-usb3_generic_phy)) {
 + dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 + if (IS_ERR(dwc-usb3_generic_phy)) {
 + dev_err(dev, no usb3 phy configured yet);
 + return PTR_ERR(dwc-usb3_generic_phy);
 + }
 + dwc-usb3_phy = NULL;
 + }

Is there some specific reason for these checks? The driver should not
need to care about the platform (DT, ACPI, platform based).

Just get the phys and check the return value. In case ERR_PTR(-ENODEV)
leave the phy as NULL and let the driver continue normally. With other
errors you make the dwc3 probe fail.

Thanks,

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


Strange behavior with ZTE MF821D (and possible other MDM9200 devices)

2013-12-03 Thread Kristian Evensen
Hello,

I am currently working on a project where we are building devices that
will be placed on moving objects (buses, trains, etc.). The devices
are routers (TP-Link WDR4300) based on the Atheros AR9344 SoC and
running OpenWrt with kernel 3.10.18. The purpose of these devices is
to measure the mobile broadband performance, of both HSDPA and LTE,
and the modem we are currently working with is the ZTE MF821D (QMI).
The reason is that this is the modem used the two biggest operators
and it exports the information we need.

We are currently facing a USB problem that we have not been able to
solve. A USB ACK is not sent and the following messages appear in the
kernel logs:
Thu Nov 21 09:44:53 2013 kern.err kernel: [  490.60] qmi_wwan
1-1.1.2:1.4: nonzero urb status received: -71
Thu Nov 21 09:44:53 2013 kern.err kernel: [  490.60] qmi_wwan
1-1.1.2:1.4: wdm_int_callback - 0 bytes

This can go on for several minutes, during which USB is
non-responding. After this time period has passed, USB starts
responding again, the modems disconnect/connect and work again.
Initially we suspected a bug in the USB hub on the SoC, but after some
great help from Alan Stern that seems not to be the case. A summary of
our initial observations can be found here:
http://thread.gmane.org/gmane.linux.usb.general/99142

Instead, it seems like the issue is caused by the modem. The common
behavior is that the modem is moved into areas where there is no data
coverage (LED turns red), but it does not loose packet service. When
it gets service again (LED turns blue/green), the error occurs. The
following then appears in the log file (along with the
XactErr-messages described in my other email):

[ 2185.29] qmi_wwan 1-1.1.3:1.4: nonzero urb status received: -71
[ 2185.29] qmi_wwan 1-1.1.3:1.4: wdm_int_callback - 0 bytes
[ 2185.47] qmi_wwan 1-1.1.2:1.4: nonzero urb status received: -71
[ 2185.47] qmi_wwan 1-1.1.2:1.4: wdm_int_callback - 0 bytes
[ 2185.50] qmi_wwan 1-1.1.3:1.4: nonzero urb status received: -71
[ 2185.50] qmi_wwan 1-1.1.3:1.4: wdm_int_callback - 0 bytes
[ 2185.59] qmi_wwan 1-1.1.2:1.4: Error in flush path: -71
[ 2185.60] qmi_wwan 1-1.1.3:1.4: Error in flush path: -71

In order to get the Error in flush path, we first had to remove the
option module. Otherwise, we would only see (in addition to
wdm_int_callback + nonzero urb):
[62979.28] option1 ttyUSB7: option_instat_callback: error -71

We are currently a bit stomped and unsure how to progress. Our
qmi-dialer is exited and lsof shows that no applications have the
wdm-device open. We have tested with modems with different chipsets
(older Huawei 3G modems), and they do not display this issue, so it
seems to be a modem or chipset issue. We ran some tests with a ZTE
MF823D WebUI (also based on MDM9200) modem and saw some strange
behavior with it as well.

My question is, has anyone seen this behavior or have any hints as to
how we can progress? I implemented a quick hack in which I reduced the
number of retransmissions of a USB packet to a driver, in order to
shorten the time until USB becomes responsive again. It works, but it
is not very nice and seems to cause problems elsewhere.

Thanks in advance for any help,
Kristian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Added support for the Lenovo RD02-D400 USB Modem

2013-12-03 Thread David Cluytens
From: David Cluytens david.cluytens_...@softathome.com

Signed-off-by: David Cluytens david.cluyt...@gmail.com
---
 drivers/usb/class/cdc-acm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ad4e94..e840431 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,8 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)
 
 static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
-{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
-.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
+   { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
+   .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
{ USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
.driver_info = NO_UNION_NORMAL, /* has no union descriptor */
},
-- 
1.8.4.4

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


Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 06:21 AM, Peter Chen wrote:
 On Mon, Dec 02, 2013 at 07:38:46PM -0800, Greg KH wrote:
 On Tue, Dec 03, 2013 at 11:00:30AM +0800, Peter Chen wrote:
 On Mon, Dec 02, 2013 at 03:43:48PM -0800, Greg KH wrote:
 From: Greg Kroah-Hartman gre...@linuxfoundation.org

 Alexander isn't able to maintain the Chipidea code anymore, and as Peter
 has been acting as the de-facto maintainer anyway, make it official.

 Cc: Alexander Shishkin alexander.shish...@linux.intel.com
 Cc: Peter Chen peter.c...@freescale.com
 Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

 ---

 Alex and Peter, can I get your signed-off-by: or ack for this patch?

 diff --git a/MAINTAINERS b/MAINTAINERS
 index 4afcfb4c..e3e79afd 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -2137,7 +2137,7 @@ S:   Maintained
  F:Documentation/zh_CN/
  
  CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
 -M:Alexander Shishkin alexander.shish...@linux.intel.com
 +M:Peter Chen peter.c...@freescale.com
  L:linux-usb@vger.kernel.org
  S:Maintained
  F:drivers/usb/chipidea/
 --

 Acked-by: Peter Chen peter.c...@freescale.com

FWIW:
Acked-by: Marc Kleine-Budde m...@pengutronix.de


 Greg, below is my git tree, please help add it, thanks.
 T:  git://github.com/hzpeterchen/linux-usb.git

 Ugh, github, really?  I'm not going to pull from a github tree, sorry.
 Can you apply for a kernel.org one?

 Or you can just send patches, which is probably good for a while anyway.

 
 Thanks, I will use the way which send patches to you directly.
 The github can be used for someone who wants to work based on
 the newest chipidea code.
 
 I will collect chipidea dev patches for 3.14, and bug-fixes for 3.13-rcX.

Great! Do you have the names for those branches, yet? I'm especially
interested in branches for usb and usb-next, which will have only
final patches applied. So that these trees don't need to be rebased.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 04:38 AM, Greg KH wrote:
 On Tue, Dec 03, 2013 at 11:00:30AM +0800, Peter Chen wrote:
 On Mon, Dec 02, 2013 at 03:43:48PM -0800, Greg KH wrote:
 From: Greg Kroah-Hartman gre...@linuxfoundation.org

 Alexander isn't able to maintain the Chipidea code anymore, and as Peter
 has been acting as the de-facto maintainer anyway, make it official.

 Cc: Alexander Shishkin alexander.shish...@linux.intel.com
 Cc: Peter Chen peter.c...@freescale.com
 Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org

 ---

 Alex and Peter, can I get your signed-off-by: or ack for this patch?

 diff --git a/MAINTAINERS b/MAINTAINERS
 index 4afcfb4c..e3e79afd 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -2137,7 +2137,7 @@ S:Maintained
  F: Documentation/zh_CN/
  
  CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
 -M: Alexander Shishkin alexander.shish...@linux.intel.com
 +M: Peter Chen peter.c...@freescale.com
  L: linux-usb@vger.kernel.org
  S: Maintained
  F: drivers/usb/chipidea/
 --

 Acked-by: Peter Chen peter.c...@freescale.com

 Greg, below is my git tree, please help add it, thanks.
 T:   git://github.com/hzpeterchen/linux-usb.git
 
 Ugh, github, really?  I'm not going to pull from a github tree, sorry.
 Can you apply for a kernel.org one?

github can be used without all that fancy web-2.0 interface. If Peter
sends you a standard plain $(git request-pull) it's not much different
from a non github git account.

just my 2¢,
Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] Added support for the Lenovo RD02-D400 USB Modem

2013-12-03 Thread Sergei Shtylyov

Hello.

On 03-12-2013 16:34, David Cluytens wrote:


From: David Cluytens david.cluytens_...@softathome.com



Signed-off-by: David Cluytens david.cluyt...@gmail.com
---
  drivers/usb/class/cdc-acm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)



diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 8ad4e94..e840431 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,8 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)

  static const struct usb_device_id acm_ids[] = {
/* quirky and broken devices */
-{ USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
-.driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
+   { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
+   .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */


   As far as I can see, this patch is not adding any support.

WBR, Sergei

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


RE: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Peter Chen
 
 On 12/03/2013 06:21 AM, Peter Chen wrote:
  On Mon, Dec 02, 2013 at 07:38:46PM -0800, Greg KH wrote:
  On Tue, Dec 03, 2013 at 11:00:30AM +0800, Peter Chen wrote:
  On Mon, Dec 02, 2013 at 03:43:48PM -0800, Greg KH wrote:
  From: Greg Kroah-Hartman gre...@linuxfoundation.org
 
  Alexander isn't able to maintain the Chipidea code anymore, and as
 Peter
  has been acting as the de-facto maintainer anyway, make it official.
 
  Cc: Alexander Shishkin alexander.shish...@linux.intel.com
  Cc: Peter Chen peter.c...@freescale.com
  Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
 
  ---
 
  Alex and Peter, can I get your signed-off-by: or ack for this patch?
 
  diff --git a/MAINTAINERS b/MAINTAINERS
  index 4afcfb4c..e3e79afd 100644
  --- a/MAINTAINERS
  +++ b/MAINTAINERS
  @@ -2137,7 +2137,7 @@ S: Maintained
   F:  Documentation/zh_CN/
 
   CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
  -M:  Alexander Shishkin alexander.shish...@linux.intel.com
  +M:  Peter Chen peter.c...@freescale.com
   L:  linux-usb@vger.kernel.org
   S:  Maintained
   F:  drivers/usb/chipidea/
  --
 
  Acked-by: Peter Chen peter.c...@freescale.com
 
 FWIW:
 Acked-by: Marc Kleine-Budde m...@pengutronix.de
 
 
  Greg, below is my git tree, please help add it, thanks.
  T:git://github.com/hzpeterchen/linux-usb.git
 
  Ugh, github, really?  I'm not going to pull from a github tree, sorry.
  Can you apply for a kernel.org one?
 
  Or you can just send patches, which is probably good for a while
 anyway.
 
 
  Thanks, I will use the way which send patches to you directly.
  The github can be used for someone who wants to work based on
  the newest chipidea code.
 
  I will collect chipidea dev patches for 3.14, and bug-fixes for 3.13-
 rcX.
 
 Great! Do you have the names for those branches, yet? I'm especially
 interested in branches for usb and usb-next, which will have only
 final patches applied. So that these trees don't need to be rebased.
 

I plan to create branch ci-for-usb-next which is rebased on Greg's usb-next 
tree,
branch ci-for-usb-stable which is rebased on Greg's usb-linus, branch 
ci-for-usb-dev
for chipidea development patch. I hope all related patches will
be there within one week.

Peter





RE: [PATCH 1/3 v4] usb: chipidea: Reallocate regmap only if lpm is detected

2013-12-03 Thread Peter Chen

 
 
  Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
  Acked-by: Peter Chen peter.c...@freescale.com
  ---
   drivers/usb/chipidea/core.c |7 ++-
   1 file changed, 6 insertions(+), 1 deletion(-)
 
  diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
  index 5d8981c..9a5ef20 100644
  --- a/drivers/usb/chipidea/core.c
  +++ b/drivers/usb/chipidea/core.c
  @@ -208,7 +208,8 @@ static int hw_device_init(struct ci_hdrc *ci, void
 __iomem *base)
  reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) 
  __ffs(HCCPARAMS_LEN);
  ci-hw_bank.lpm  = reg;
  -   hw_alloc_regmap(ci, !!reg);
  +   if (reg)
  +   hw_alloc_regmap(ci, !!reg);
  ci-hw_bank.size = ci-hw_bank.op - ci-hw_bank.abs;
  ci-hw_bank.size += OP_LAST;
  ci-hw_bank.size /= sizeof(u32);
  @@ -642,6 +643,10 @@ static int ci_hdrc_probe(struct platform_device
 *pdev)
  : CI_ROLE_GADGET;
  }
 
  +   /* only update vbus status for peripheral */
  +   if (ci-role == CI_ROLE_GADGET)
  +   ci_handle_vbus_change(ci);
  +
 
 This change seems unrelated to me.
 
 Marc

Hi Chris. Why above change is there, it is not existed at your v3 patch.

Peter

 
  ret = ci_role_start(ci, ci-role);
  if (ret) {
  dev_err(dev, can't start %s role\n, ci_role(ci)-name);
 
 
 
 --
 Pengutronix e.K.  | Marc Kleine-Budde   |
 Industrial Linux Solutions| Phone: +49-231-2826-924 |
 Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
 Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h����G���h�(�階�ݢj���m��z�ޖ���f���h���~�m�

Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 02:54 PM, Peter Chen wrote:
 Great! Do you have the names for those branches, yet? I'm especially
 interested in branches for usb and usb-next, which will have only
 final patches applied. So that these trees don't need to be rebased.

 I plan to create branch ci-for-usb-next which is rebased on Greg's usb-next 
 tree,
 branch ci-for-usb-stable which is rebased on Greg's usb-linus, branch 
 ci-for-usb-dev
 for chipidea development patch. I hope all related patches will
 be there within one week.

The less rebasing the better for any downstream developer.

From my point of view you can already queue the series reescale imx28
special write register method and the patch imx: set
CI_HDRC_IMX28_WRITE_FIX for imx28 for v3.13-rcX.

Marc
-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread Boris BREZILLON
Replace clk_get calls by devm_clk_get calls.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 drivers/usb/host/ohci-at91.c |   32 
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c406f1e..3652962 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -164,30 +164,30 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
goto err;
}
 
-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = devm_clk_get(dev, ohci_clk);
if (IS_ERR(iclk)) {
-   dev_err(pdev-dev, failed to get ohci_clk\n);
+   dev_err(dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
goto err;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = devm_clk_get(dev, uhpck);
if (IS_ERR(fclk)) {
dev_err(pdev-dev, failed to get uhpck\n);
retval = PTR_ERR(fclk);
-   goto err4;
+   goto err;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = devm_clk_get(dev, hclk);
if (IS_ERR(hclk)) {
dev_err(pdev-dev, failed to get hclk\n);
retval = PTR_ERR(hclk);
-   goto err5;
+   goto err;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = devm_clk_get(pdev-dev, usb_clk);
if (IS_ERR(uclk)) {
dev_err(pdev-dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
-   goto err6;
+   goto err;
}
}
 
@@ -203,15 +203,6 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
/* Error handling */
at91_stop_hc(pdev);
 
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
- err6:
-   clk_put(hclk);
- err5:
-   clk_put(fclk);
- err4:
-   clk_put(iclk);
-
  err:
usb_put_hcd(hcd);
return retval;
@@ -236,13 +227,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
usb_put_hcd(hcd);
-
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
-   clk_put(hclk);
-   clk_put(fclk);
-   clk_put(iclk);
-   fclk = iclk = hclk = NULL;
 }
 
 /*-*/
-- 
1.7.9.5

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


RE: [PATCH v4 02/17] usb: phy-mxs: Add platform judgement code

2013-12-03 Thread Peter Chen
 
  +
  +static const struct mxs_phy_data imx23_phy_data = {
  +   .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
  +};
 
 ABNORAML? - ABNORMAL
 

My careless, will change. Thanks.

Peter 

  +
  +static const struct mxs_phy_data imx6q_phy_data = {
  +   .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
  +   MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
  +};
  +
  +static const struct mxs_phy_data imx6sl_phy_data = {
  +   .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
  +};
  +
  +static const struct of_device_id mxs_phy_dt_ids[] = {
  +   { .compatible = fsl,imx6sl-usbphy, .data = imx6sl_phy_data, },
  +   { .compatible = fsl,imx6q-usbphy, .data = imx6q_phy_data, },
  +   { .compatible = fsl,imx23-usbphy, .data = imx23_phy_data, },
  +   { /* sentinel */ }
  +};
  +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
  +
   struct mxs_phy {
  struct usb_phy phy;
  struct clk *clk;
  +   const struct mxs_phy_data *data;
   };
 
  -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
  -
   static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
   {
  int ret;
  @@ -131,6 +174,8 @@ static int mxs_phy_probe(struct platform_device
 *pdev)
  struct clk *clk;
  struct mxs_phy *mxs_phy;
  int ret;
  +   const struct of_device_id *of_id =
  +   of_match_device(mxs_phy_dt_ids, pdev-dev);
 
  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  base = devm_ioremap_resource(pdev-dev, res);
  @@ -163,6 +208,7 @@ static int mxs_phy_probe(struct platform_device
 *pdev)
  ATOMIC_INIT_NOTIFIER_HEAD(mxs_phy-phy.notifier);
 
  mxs_phy-clk = clk;
  +   mxs_phy-data = of_id-data;
 
  platform_set_drvdata(pdev, mxs_phy);
 
  @@ -182,12 +228,6 @@ static int mxs_phy_remove(struct platform_device
 *pdev)
  return 0;
   }
 
  -static const struct of_device_id mxs_phy_dt_ids[] = {
  -   { .compatible = fsl,imx23-usbphy, },
  -   { /* sentinel */ }
  -};
  -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
  -
   static struct platform_driver mxs_phy_driver = {
  .probe = mxs_phy_probe,
  .remove = mxs_phy_remove,
  --
  1.7.8
 
 
 
 
 --
 Pengutronix e.K.   |
 |
 Industrial Linux Solutions | http://www.pengutronix.de/
 |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
 |
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917-
 |


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


Re: [PATCH 2/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_request_and_ioremap

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

Replace the request_mem_region + ioremap calls by the
devm_request_and_ioremap call which does the same things but with device
managed resources.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  drivers/usb/host/ohci-at91.c |   24 +---
  1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 7aec6ca..c406f1e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -157,24 +157,18 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd-rsrc_start = mem_r-start;
hcd-rsrc_len = resource_size(mem_r);

-   if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
-   pr_debug(request_mem_region failed\n);
-   retval = -EBUSY;
-   goto err1;
-   }
-
-   hcd-regs = ioremap(hcd-rsrc_start, hcd-rsrc_len);
+   hcd-regs = devm_request_and_ioremap(pdev-dev, mem_r);
if (!hcd-regs) {
-   pr_debug(ioremap failed\n);
+   dev_dbg(dev, devm_request_and_ioremap failed\n);
retval = -EIO;
-   goto err2;
+   goto err;
}

iclk = clk_get(pdev-dev, ohci_clk);
if (IS_ERR(iclk)) {
dev_err(pdev-dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
-   goto err3;
+   goto err;
}
fclk = clk_get(pdev-dev, uhpck);
if (IS_ERR(fclk)) {
@@ -218,13 +212,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
   err4:
clk_put(iclk);

- err3:
-   iounmap(hcd-regs);
-
- err2:
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
-
- err1:
+ err:
usb_put_hcd(hcd);
return retval;
  }
@@ -247,8 +235,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
  {
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
-   iounmap(hcd-regs);
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);

if (IS_ENABLED(CONFIG_COMMON_CLK))




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


Re: [PATCH 1/3] usb: ohci-at91: fix irq and iomem resource retrieval

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resource
table.

Retrieve resources using the platform_get_resource function instead of
direct resource table entries to avoid resource type mismatch.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com


---
  drivers/usb/host/ohci-at91.c |   19 +++
  1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 418444e..7aec6ca 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -136,23 +136,26 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct device *dev = pdev-dev;
+   struct resource *mem_r, *irq_r;

-   if (pdev-num_resources != 2) {
-   pr_debug(hcd probe: invalid num_resources);
+   mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!mem_r) {
+   dev_dbg(dev, hcd probe: missing memory resource\n);
return -ENODEV;
}

-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   pr_debug(hcd probe: invalid resource type\n);
+   irq_r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!irq_r) {
+   dev_dbg(dev, hcd probe: missing irq resource\n);
return -ENODEV;
}

hcd = usb_create_hcd(driver, pdev-dev, at91);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = pdev-resource[0].start;
-   hcd-rsrc_len = resource_size(pdev-resource[0]);
+   hcd-rsrc_start = mem_r-start;
+   hcd-rsrc_len = resource_size(mem_r);

if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed\n);
@@ -199,7 +202,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
ohci-num_ports = board-ports;
at91_start_hc(pdev);

-   retval = usb_add_hcd(hcd, pdev-resource[1].start, IRQF_SHARED);
+   retval = usb_add_hcd(hcd, irq_r-start, IRQF_SHARED);
if (retval == 0)
return retval;





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


Re: [PATCH v2 2/7] usb: dwc3: adapt dwc3 core to use Generic PHY Framework

2013-12-03 Thread Kishon Vijay Abraham I
Hi,

On Tuesday 03 December 2013 05:29 PM, Heikki Krogerus wrote:
 Hi Kishon,
 
 On Wed, Oct 16, 2013 at 01:24:12AM +0530, Kishon Vijay Abraham I wrote:
 +count = of_property_match_string(node, phy-names, usb2-phy);
 +if (count = 0 || (pdata  pdata-usb2_generic_phy)) {
 +dwc-usb2_generic_phy = devm_phy_get(dev, usb2-phy);
 +if (IS_ERR(dwc-usb2_generic_phy)) {
 +dev_err(dev, no usb2 phy configured yet);
 +return PTR_ERR(dwc-usb2_generic_phy);
 +}
 +dwc-usb2_phy = NULL;
 +}
 +
 +count = of_property_match_string(node, phy-names, usb3-phy);
 +if (count = 0 || (pdata  pdata-usb3_generic_phy)) {
 +dwc-usb3_generic_phy = devm_phy_get(dev, usb3-phy);
 +if (IS_ERR(dwc-usb3_generic_phy)) {
 +dev_err(dev, no usb3 phy configured yet);
 +return PTR_ERR(dwc-usb3_generic_phy);
 +}
 +dwc-usb3_phy = NULL;
 +}
 
 Is there some specific reason for these checks? The driver should not
 need to care about the platform (DT, ACPI, platform based).

yeah just wanted to throw an error if a platform needs PHY but wasn't able to
get it. Btw this has changed after my v3 of this patch series which I sent
sometime back [1] where we use quirks to know if a PHY is needed for that
platform or not.

http://www.spinics.net/lists/linux-usb/msg98077.html

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


Re: [PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread Nicolas Ferre

On 03/12/2013 15:07, Boris BREZILLON :

Replace clk_get calls by devm_clk_get calls.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com


Acked-by: Nicolas Ferre nicolas.fe...@atmel.com

Thanks Boris for these fixes.

Alan, Greg, can you take the whole series as fixes for 3.13?

Thanks, best regards,


---
  drivers/usb/host/ohci-at91.c |   32 
  1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c406f1e..3652962 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -164,30 +164,30 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
goto err;
}

-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = devm_clk_get(dev, ohci_clk);
if (IS_ERR(iclk)) {
-   dev_err(pdev-dev, failed to get ohci_clk\n);
+   dev_err(dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
goto err;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = devm_clk_get(dev, uhpck);
if (IS_ERR(fclk)) {
dev_err(pdev-dev, failed to get uhpck\n);
retval = PTR_ERR(fclk);
-   goto err4;
+   goto err;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = devm_clk_get(dev, hclk);
if (IS_ERR(hclk)) {
dev_err(pdev-dev, failed to get hclk\n);
retval = PTR_ERR(hclk);
-   goto err5;
+   goto err;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = devm_clk_get(pdev-dev, usb_clk);
if (IS_ERR(uclk)) {
dev_err(pdev-dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
-   goto err6;
+   goto err;
}
}

@@ -203,15 +203,6 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
/* Error handling */
at91_stop_hc(pdev);

-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
- err6:
-   clk_put(hclk);
- err5:
-   clk_put(fclk);
- err4:
-   clk_put(iclk);
-
   err:
usb_put_hcd(hcd);
return retval;
@@ -236,13 +227,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
usb_put_hcd(hcd);
-
-   if (IS_ENABLED(CONFIG_COMMON_CLK))
-   clk_put(uclk);
-   clk_put(hclk);
-   clk_put(fclk);
-   clk_put(iclk);
-   fclk = iclk = hclk = NULL;
  }

  /*-*/




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


[PATCH v5 06/16] usb/gadget: f_subset: remove compatibility layer

2013-12-03 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_subset.c |   60 +
 drivers/usb/gadget/u_ether.h  |3 --
 2 files changed, 1 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
index 7c8674f..f1a5919 100644
--- a/drivers/usb/gadget/f_subset.c
+++ b/drivers/usb/gadget/f_subset.c
@@ -301,7 +301,6 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USB_FSUBSET_INCLUDED
struct f_gether_opts*gether_opts;
 
gether_opts = container_of(f-fi, struct f_gether_opts, func_inst);
@@ -322,7 +321,7 @@ geth_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
gether_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, geth_strings,
 ARRAY_SIZE(geth_string_defs));
if (IS_ERR(us))
@@ -393,61 +392,6 @@ fail:
return status;
 }
 
-#ifdef USB_FSUBSET_INCLUDED
-
-static void
-geth_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   geth_string_defs[0].id = 0;
-   usb_free_all_descriptors(f);
-   kfree(func_to_geth(f));
-}
-
-/**
- * geth_bind_config - add CDC Subset network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * @dev: eth_dev structure
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_gether *geth;
-   int status;
-
-   /* allocate and initialize one new instance */
-   geth = kzalloc(sizeof *geth, GFP_KERNEL);
-   if (!geth)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(geth-ethaddr, sizeof geth-ethaddr, %pm, ethaddr);
-   geth_string_defs[1].s = geth-ethaddr;
-
-   geth-port.ioport = dev;
-   geth-port.cdc_filter = DEFAULT_FILTER;
-
-   geth-port.func.name = cdc_subset;
-   geth-port.func.bind = geth_bind;
-   geth-port.func.unbind = geth_old_unbind;
-   geth-port.func.set_alt = geth_set_alt;
-   geth-port.func.disable = geth_disable;
-
-   status = usb_add_function(c, geth-port.func);
-   if (status)
-   kfree(geth);
-   return status;
-}
-
-#else
-
 static inline struct f_gether_opts *to_f_gether_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_gether_opts,
@@ -573,5 +517,3 @@ static struct usb_function *geth_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(geth, geth_alloc_inst, geth_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 64125a5..f310e6f 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -268,9 +268,6 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
 }
 
 /* each configuration may bind one instance of an ethernet link */
-int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
-
 #ifdef USB_ETH_RNDIS
 
 int rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-- 
1.7.0.4

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


[PATCH v5 01/16] usb/gadget: configfs: allow setting function instance's name

2013-12-03 Thread Andrzej Pietrasiewicz
USB function's configfs config group is created in a generic way in
usb/gadget/configfs.c:function_make(), which in turn delegates actual
allocation and setup of the USB function instance to a particular
implementation, e.g. in f_acm.c. The said implementation does its job
in a parameter-less function e.g. acm_alloc_instance(), which results
in creating an unnamed config group, whose name is set later in
function_make(). function_make() creates the name by parsing a string
of the form:

function name.instance name

which comes from userspace as a parameter to mkdir invocation.

Up to now only function name has been used, while instance name
has been ignored. This patch adds a set_inst_name() operation to
struct usb_function_instance which allows passing the instance name
from function_make() so that it is not ignored. It is entirely up to the
implementor of set_inst_name() what to do with the instance name.

In a typical case, the struct usb_function_instance is embedded in a
larger struct which is retrieved in set_inst_name() with container_of(),
and the larger struct contains a field to store the instance name.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/configfs.c |7 +++
 include/linux/usb/composite.h |2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 2588511..d6c8ab4 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -564,6 +564,13 @@ static struct config_group *function_make(
usb_put_function_instance(fi);
return ERR_PTR(ret);
}
+   if (fi-set_inst_name) {
+   ret = fi-set_inst_name(fi, instance_name);
+   if (ret) {
+   usb_put_function_instance(fi);
+   return ERR_PTR(ret);
+   }
+   }
 
gi = container_of(group, struct gadget_info, functions_group);
 
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 5e61589..dba63f5 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -468,6 +468,8 @@ struct usb_function_instance {
struct config_group group;
struct list_head cfs_list;
struct usb_function_driver *fd;
+   int (*set_inst_name)(struct usb_function_instance *inst,
+ const char *name);
void (*free_func_inst)(struct usb_function_instance *inst);
 };
 
-- 
1.7.0.4

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


[PATCH v5 07/16] usb/gadget: g_ffs: convert to new interface of f_rndis

2013-12-03 Thread Andrzej Pietrasiewicz
There is a new interface of f_rndis and g_ffs is the last to use the old one.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |  105 +++-
 2 files changed, 66 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 77411d7..54b9856 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -894,6 +894,7 @@ config USB_FUNCTIONFS_RNDIS
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
select USB_U_RNDIS
+   select USB_F_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 99ae8ec..7099a11 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -33,29 +33,25 @@
 #  include u_ecm.h
 #  include u_gether.h
 #  ifdef USB_ETH_RNDIS
-#define USB_FRNDIS_INCLUDED
-#include f_rndis.c
+#include u_rndis.h
 #include rndis.h
 #  endif
 #  include u_ether.h
 
 USB_ETHERNET_MODULE_PARAMETERS();
 
-static u8 gfs_host_mac[ETH_ALEN];
-static struct eth_dev *the_dev;
 #  ifdef CONFIG_USB_FUNCTIONFS_ETH
-static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
+static int eth_bind_config(struct usb_configuration *c);
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
 static struct usb_function_instance *fi_geth;
 static struct usb_function *f_geth;
 #  endif
-#else
-#  define the_dev  NULL
-#  define gether_cleanup(dev) do { } while (0)
-#  define gfs_host_mac NULL
-struct eth_dev;
+#  ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+static int bind_rndis_config(struct usb_configuration *c);
+static struct usb_function_instance *fi_rndis;
+static struct usb_function *f_rndis;
+#  endif
 #endif
 
 #include f_fs.c
@@ -148,12 +144,11 @@ static struct usb_gadget_strings *gfs_dev_strings[] = {
 
 struct gfs_configuration {
struct usb_configuration c;
-   int (*eth)(struct usb_configuration *c, u8 *ethaddr,
-   struct eth_dev *dev);
+   int (*eth)(struct usb_configuration *c);
 } gfs_configurations[] = {
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{
-   .eth= rndis_bind_config,
+   .eth= bind_rndis_config,
},
 #endif
 
@@ -351,7 +346,7 @@ static void functionfs_release_dev_callback(struct ffs_data 
*ffs_data)
  */
 static int gfs_bind(struct usb_composite_dev *cdev)
 {
-#if defined CONFIG_USB_FUNCTIONFS_ETH
+#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
struct net_device *net;
 #endif
int ret, i;
@@ -379,28 +374,38 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 func_inst);
net = geth_opts-net;
}
-   gether_set_qmult(net, qmult);
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+   {
+   struct f_rndis_opts *rndis_opts;
+
+   fi_rndis = usb_get_function_instance(rndis);
+   if (IS_ERR(fi_rndis)) {
+   ret = PTR_ERR(fi_rndis);
+   goto error;
+   }
+   rndis_opts = container_of(fi_rndis, struct f_rndis_opts,
+ func_inst);
+#ifndef CONFIG_USB_FUNCTIONFS_ETH
+   net = rndis_opts-net;
+#endif
+   }
+#endif
 
+#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
+   gether_set_qmult(net, qmult);
if (!gether_set_host_addr(net, host_addr))
pr_info(using host ethernet address: %s, host_addr);
if (!gether_set_dev_addr(net, dev_addr))
pr_info(using self ethernet address: %s, dev_addr);
-
-   the_dev = netdev_priv(net);
-
-#elif defined CONFIG_USB_FUNCTIONFS_RNDIS
-
-   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, gfs_host_mac,
-  qmult);
 #endif
-   if (IS_ERR(the_dev))
-   return PTR_ERR(the_dev);
 
 #if defined CONFIG_USB_FUNCTIONFS_RNDIS  defined CONFIG_USB_FUNCTIONFS_ETH
gether_set_gadget(net, cdev-gadget);
ret = gether_register_netdev(net);
if (ret)
-   goto error;
+   goto error_rndis;
 
if (can_support_ecm(cdev-gadget)) {
struct f_ecm_opts *ecm_opts;
@@ -414,12 +419,13 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 func_inst);
geth_opts-bound = true;
}
-   gether_get_host_addr_u8(net, gfs_host_mac);
+
+   rndis_borrow_net(fi_rndis, net);
 #endif
 
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret  0))
-  

[PATCH v5 11/16] usb/gadget: FunctionFS: create utility file

2013-12-03 Thread Andrzej Pietrasiewicz
A header file to be used by f_fs.c and g_ffs.c will be required when
f_fs.c is converted into a module.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c  |1 +
 drivers/usb/gadget/g_ffs.c |   19 ++-
 drivers/usb/gadget/u_fs.h  |   28 
 3 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 drivers/usb/gadget/u_fs.h

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 60cc1a5..9c946cd 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -27,6 +27,7 @@
 #include linux/usb/composite.h
 #include linux/usb/functionfs.h
 
+#include u_fs.h
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 7099a11..1aaa103 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -69,13 +69,6 @@ MODULE_LICENSE(GPL);
 
 #define GFS_MAX_DEVS   10
 
-struct gfs_ffs_obj {
-   const char *name;
-   bool mounted;
-   bool desc_ready;
-   struct ffs_data *ffs_data;
-};
-
 USB_GADGET_COMPOSITE_OPTIONS();
 
 static struct usb_device_descriptor gfs_dev_desc = {
@@ -181,7 +174,7 @@ static DEFINE_MUTEX(gfs_lock);
 static unsigned int missing_funcs;
 static bool gfs_registered;
 static bool gfs_single_func;
-static struct gfs_ffs_obj *ffs_tab;
+static struct ffs_dev *ffs_tab;
 
 static int __init gfs_init(void)
 {
@@ -224,7 +217,7 @@ static void __exit gfs_exit(void)
 }
 module_exit(gfs_exit);
 
-static struct gfs_ffs_obj *gfs_find_dev(const char *dev_name)
+static struct ffs_dev *gfs_find_dev(const char *dev_name)
 {
int i;
 
@@ -242,7 +235,7 @@ static struct gfs_ffs_obj *gfs_find_dev(const char 
*dev_name)
 
 static int functionfs_ready_callback(struct ffs_data *ffs)
 {
-   struct gfs_ffs_obj *ffs_obj;
+   struct ffs_dev *ffs_obj;
int ret;
 
ENTER();
@@ -283,7 +276,7 @@ done:
 
 static void functionfs_closed_callback(struct ffs_data *ffs)
 {
-   struct gfs_ffs_obj *ffs_obj;
+   struct ffs_dev *ffs_obj;
 
ENTER();
mutex_lock(gfs_lock);
@@ -305,7 +298,7 @@ done:
 
 static void *functionfs_acquire_dev_callback(const char *dev_name)
 {
-   struct gfs_ffs_obj *ffs_dev;
+   struct ffs_dev *ffs_dev;
 
ENTER();
mutex_lock(gfs_lock);
@@ -329,7 +322,7 @@ done:
 
 static void functionfs_release_dev_callback(struct ffs_data *ffs_data)
 {
-   struct gfs_ffs_obj *ffs_dev;
+   struct ffs_dev *ffs_dev;
 
ENTER();
mutex_lock(gfs_lock);
diff --git a/drivers/usb/gadget/u_fs.h b/drivers/usb/gadget/u_fs.h
new file mode 100644
index 000..5d9229a
--- /dev/null
+++ b/drivers/usb/gadget/u_fs.h
@@ -0,0 +1,28 @@
+/*
+ * u_fs.h
+ *
+ * Utility definitions for the FunctionFS
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Andrzej Pietrasiewicz andrze...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef U_FFS_H
+#define U_FFS_H
+
+#include linux/usb/composite.h
+
+struct ffs_dev {
+   const char *name;
+   bool mounted;
+   bool desc_ready;
+   struct ffs_data *ffs_data;
+};
+
+#endif /* U_FFS_H */
-- 
1.7.0.4

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


[PATCH v5 16/16] usb/gadget: FunctionFS: add configfs support

2013-12-03 Thread Andrzej Pietrasiewicz
Add support for using FunctionFS in configfs-based USB gadgets.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 Documentation/ABI/testing/configfs-usb-gadget-ffs |9 +++
 drivers/usb/gadget/Kconfig|   12 +++
 drivers/usb/gadget/f_fs.c |   78 +
 drivers/usb/gadget/u_fs.h |5 ++
 4 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-ffs

diff --git a/Documentation/ABI/testing/configfs-usb-gadget-ffs 
b/Documentation/ABI/testing/configfs-usb-gadget-ffs
new file mode 100644
index 000..14343e2
--- /dev/null
+++ b/Documentation/ABI/testing/configfs-usb-gadget-ffs
@@ -0,0 +1,9 @@
+What:  /config/usb-gadget/gadget/functions/ffs.name
+Date:  Nov 2013
+KenelVersion:  3.13
+Description:   The purpose of this directory is to create and remove it.
+
+   A corresponding USB function instance is created/removed.
+   There are no attributes here.
+
+   All parameters are set through FunctionFS.
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 2479644..8da2b1d 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -689,6 +689,18 @@ config USB_CONFIGFS_MASS_STORAGE
  device (in much the same way as the loop device driver),
  specified as a module parameter or sysfs option.
 
+config USB_CONFIGFS_F_FS
+   boolean Function filesystem (FunctionFS)
+   depends on USB_CONFIGFS
+   select USB_F_FS
+   help
+ The Function Filesystem (FunctionFS) lets one create USB
+ composite functions in user space in the same way GadgetFS
+ lets one create USB gadgets in user space.  This allows creation
+ of composite gadgets such that some of the functions are
+ implemented in kernel space (for instance Ethernet, serial or
+ mass storage) and other are implemented in user space.
+
 config USB_ZERO
tristate Gadget Zero (DEVELOPMENT)
select USB_LIBCOMPOSITE
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index f05d3bd..34b9f90 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -29,6 +29,7 @@
 #include linux/usb/functionfs.h
 
 #include u_fs.h
+#include configfs.h
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
@@ -161,6 +162,7 @@ DEFINE_MUTEX(ffs_lock);
 EXPORT_SYMBOL(ffs_lock);
 
 static struct ffs_dev *ffs_find_dev(const char *name);
+static int _ffs_name_dev(struct ffs_dev *dev, const char *name);
 static void *ffs_acquire_dev(const char *dev_name);
 static void ffs_release_dev(struct ffs_data *ffs_data);
 static int ffs_ready(struct ffs_data *ffs);
@@ -2294,6 +2296,31 @@ static struct ffs_dev *ffs_find_dev(const char *name)
return _ffs_find_dev(name);
 }
 
+/* Configfs support */
+
+static inline struct f_fs_opts *to_ffs_opts(struct config_item *item)
+{
+   return container_of(to_config_group(item), struct f_fs_opts,
+   func_inst.group);
+}
+
+static void ffs_attr_release(struct config_item *item)
+{
+   struct f_fs_opts *opts = to_ffs_opts(item);
+
+   usb_put_function_instance(opts-func_inst);
+}
+
+static struct configfs_item_operations ffs_item_ops = {
+   .release= ffs_attr_release,
+};
+
+static struct config_item_type ffs_func_type = {
+   .ct_item_ops= ffs_item_ops,
+   .ct_owner   = THIS_MODULE,
+};
+
+
 /* Function registration interface **/
 
 static void ffs_free_inst(struct usb_function_instance *f)
@@ -2307,6 +2334,44 @@ static void ffs_free_inst(struct usb_function_instance 
*f)
kfree(opts);
 }
 
+#define MAX_INST_NAME_LEN  40
+
+static int ffs_set_inst_name(struct usb_function_instance *fi, const char 
*name)
+{
+   struct f_fs_opts *opts;
+   char *ptr;
+   const char *tmp;
+   int name_len, ret;
+
+   name_len = strlen(name) + 1;
+   if (name_len  MAX_INST_NAME_LEN)
+   return -ENAMETOOLONG;
+
+   ptr = kstrndup(name, name_len, GFP_KERNEL);
+   if (!ptr)
+   return -ENOMEM;
+
+   opts = to_f_fs_opts(fi);
+   tmp = NULL;
+
+   ffs_dev_lock();
+
+   tmp = opts-dev-name_allocated ? opts-dev-name : NULL;
+   ret = _ffs_name_dev(opts-dev, ptr);
+   if (ret) {
+   kfree(ptr);
+   ffs_dev_unlock();
+   return ret;
+   }
+   opts-dev-name_allocated = true;
+   
+   ffs_dev_unlock();
+
+   kfree(tmp);
+
+   return 0;
+}
+
 static struct usb_function_instance *ffs_alloc_inst(void)
 {
struct f_fs_opts *opts;
@@ -2316,6 +2381,7 @@ static struct 

[PATCH v5 00/16] Equivalent of g_ffs with configfs

2013-12-03 Thread Andrzej Pietrasiewicz
This series aims at integrating configfs into FunctionFS, the way
it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet
and mass_storage. It contains everything that is required to provide the
equivalent of g_ffs.ko with configfs.

Configfs support in FunctionFS has been awaited by the Android folks as
discussed during the LPC 2013.

Apart from that a VLAIS (variable length array in a struct) patch is added.
It is not strictly necessary, but it won't hurt and it will make the Clang
people happy.

FunctionFS is more complicated than most other USB functions, so the resulting
patch series is a bit long. Howerver, it is supposed to do things in steps.

1) preliminary work: extend generic configfs support in USB gadget, convert
g_ffs to new function interfaces of f_ecm, f_subset, f_rndis; g_ffs is the
last user of the old interfaces so remove compatibility layers
2) factoring out a u_fs.h header and finally making f_fs a separate module
with both old and new function interface
3) converting all users of f_fs (in fact only g_ffs) to the new interface
and remove compatiblilty layer
4) add configfs support

v4..v5:

- don't take ffs_lock explicitly in g_ffs
- simplify gfs_init, bugfix not decrementing the i in error recovery

v3..v4:

- small fixes after Michal's review, thank you, Michal!
- export ffs_lock instead of ffs_dev_lock and ffs_dev_unlock, which are now
static inline
- improved ffs_find_dev, ffs_alloc_dev by introducing ffs_get_single_dev()
- rearranged kfree invocations in ffs_free_dev
- eliminated goto in ffs_acquire_dev
- used explicit decrementation in gfs_init
- removed some add/remove empty line hunks

v2..v3:

- a number of fixes regarding systems with multiple udcs, e.g. systems,
where more than one gadget can be loaded at a time
- cleanup of ffs devices handling: since they need to be registered by
both g_ffs and configfs-based gadget, they need to be managed in one
place; instead of static callbacks in f_fs.c now each device can have its
own set of callbacks
- callbacks are used by the g_ffs, while configfs-based gadget is happy
with generic ffs_acquire/release_dev(), ffs_ready/closed()
- functionfs_init() and functionfs_cleanup() now called when the first
device is created and when the last is removed, respectively
- removed gfs_lock from g_ffs in favor of a lock in f_fs.c protecting
the devices list
- thanks to all the above the ffs_alloc_inst() is greatly simplified
compared to v2
- simplified the way how usb_f_fs user's (g_ffs's) refcount is maintained
(no ffs_owner static in f_fs.c)
- some of patches 12..16 used to contain Michal's Acked-by, but since there
have been (relatively) many changes to those patches,
I removed the Acked-by lines


v1..v2:

- fixes after Michal's review, thank you, Michal!
- removal of unnecessary hunks, simplified VLAIS replacement code,
used proper pointer dereferencing, simplified ffs_do_functionfs_bind(),
ffs_alloc_inst() and ffs_free(), style corrections, allocated
usb_function structures in one chunk for all configs in g_ffs

Rebased onto Felipe's master.


BACKWARD COMPATIBILITY
==

Please note that the old g_ffs.ko is still available and works.


USING THE NEW GADGET
==

Please refer to this post:

http://www.spinics.net/lists/linux-usb/msg76388.html

for general information from Sebastian on how to use configfs-based
gadgets (*).

With configfs the procedure is as follows, compared to the information
mentioned above (*):

instead of mkdir functions/acm.ttyS1 do

mkdir functions/ffs.instance name

e.g. mkdir functions/ffs.ptp

In functions/function.instance name there will be no attribute files
at all, because all parameters are passed with FunctionFS.

An example gadget with adb and ptp functions:

(I assume there are ptpd and adbd daemons using FunctionFS available,
a proof-of-concept adbd can be found here:
https://android-review.googlesource.com/#/c/31640/,
an early version of ptp which I used is here:
http://www.spinics.net/lists/linux-usb/msg41963.html)

$ modprobe libcomposite

$ mount none cfg -t configfs

$ mkdir cfg/usb_gadget/g1
$ cd cfg/usb_gadget/g1
 
$ mkdir configs/c.1
$ mkdir functions/ffs.adb
$ mkdir functions/ffs.ptp

$ mkdir strings/0x409
$ mkdir configs/c.1/strings/0x409

$ echo 0x2d01  idProduct
$ echo 0x04e8  idVendor

$ echo my-serial-num  strings/0x409/serialnumber
$ echo my-manufacturer  strings/0x409/manufacturer
$ echo FunctionFS gadget (ptp, adb)  strings/0x409/product

$ echo Conf 1  configs/c.1/strings/0x409/configuration
$ echo 120  configs/c.1/MaxPower
$ ln -s functions/ffs.ptp configs/c.1
$ ln -s functions/ffs.adb configs/c.1

$ mkdir /dev/usbffs
$ mount ptp /dev/usbffs -t functionfs
$ ptpd

$ mkdir -p /dev/usbgadget/adb
$ mount -t functionfs adb /dev/usbgadget/adb -o uid=2000,gid=2000
$ adbd

$ echo s3c-hsotg  cfg/usb_gadget/g1/UDC


After unbinding the gadget with echo   UDC
the symbolic links in the configuration directory can be removed,
the strings/* 

[PATCH v5 05/16] usb/gadget: g_ffs: convert to new interface of f_subset

2013-12-03 Thread Andrzej Pietrasiewicz
There is a new function interface of f_subset and g_ffs is the last to use
the old one.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |   69 ++--
 2 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 960f8a6..77411d7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -884,6 +884,7 @@ config USB_FUNCTIONFS_ETH
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
select USB_F_ECM
+   select USB_F_SUBSET
help
  Include a configuration with CDC ECM function (Ethernet) and the
  Function Filesystem.
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index cda4c5d..99ae8ec 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -21,6 +21,8 @@
  * a gcc --combine ... part1.c part2.c part3.c ...  build would.
  */
 #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
+#include linux/netdevice.h
+
 #  if defined USB_ETH_RNDIS
 #undef USB_ETH_RNDIS
 #  endif
@@ -29,8 +31,7 @@
 #  endif
 
 #  include u_ecm.h
-#define USB_FSUBSET_INCLUDED
-#  include f_subset.c
+#  include u_gether.h
 #  ifdef USB_ETH_RNDIS
 #define USB_FRNDIS_INCLUDED
 #include f_rndis.c
@@ -47,6 +48,8 @@ static int eth_bind_config(struct usb_configuration *c, u8 
ethaddr[ETH_ALEN],
struct eth_dev *dev);
 static struct usb_function_instance *fi_ecm;
 static struct usb_function *f_ecm;
+static struct usb_function_instance *fi_geth;
+static struct usb_function *f_geth;
 #  endif
 #else
 #  define the_dev  NULL
@@ -348,6 +351,9 @@ static void functionfs_release_dev_callback(struct ffs_data 
*ffs_data)
  */
 static int gfs_bind(struct usb_composite_dev *cdev)
 {
+#if defined CONFIG_USB_FUNCTIONFS_ETH
+   struct net_device *net;
+#endif
int ret, i;
 
ENTER();
@@ -362,19 +368,25 @@ static int gfs_bind(struct usb_composite_dev *cdev)
if (IS_ERR(fi_ecm))
return PTR_ERR(fi_ecm);
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
-
-   gether_set_qmult(ecm_opts-net, qmult);
-
-   if (!gether_set_host_addr(ecm_opts-net, host_addr))
-   pr_info(using host ethernet address: %s, host_addr);
-   if (!gether_set_dev_addr(ecm_opts-net, dev_addr))
-   pr_info(using self ethernet address: %s, dev_addr);
-
-   the_dev = netdev_priv(ecm_opts-net);
+   net = ecm_opts-net;
} else {
-   the_dev = gether_setup(cdev-gadget, dev_addr, host_addr,
-  gfs_host_mac, qmult);
+   struct f_gether_opts *geth_opts;
+
+   fi_geth = usb_get_function_instance(geth);
+   if (IS_ERR(fi_geth))
+   return PTR_ERR(fi_geth);
+   geth_opts = container_of(fi_geth, struct f_gether_opts,
+func_inst);
+   net = geth_opts-net;
}
+   gether_set_qmult(net, qmult);
+
+   if (!gether_set_host_addr(net, host_addr))
+   pr_info(using host ethernet address: %s, host_addr);
+   if (!gether_set_dev_addr(net, dev_addr))
+   pr_info(using self ethernet address: %s, dev_addr);
+
+   the_dev = netdev_priv(net);
 
 #elif defined CONFIG_USB_FUNCTIONFS_RNDIS
 
@@ -385,18 +397,24 @@ static int gfs_bind(struct usb_composite_dev *cdev)
return PTR_ERR(the_dev);
 
 #if defined CONFIG_USB_FUNCTIONFS_RNDIS  defined CONFIG_USB_FUNCTIONFS_ETH
+   gether_set_gadget(net, cdev-gadget);
+   ret = gether_register_netdev(net);
+   if (ret)
+   goto error;
+
if (can_support_ecm(cdev-gadget)) {
struct f_ecm_opts *ecm_opts;
 
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
-
-   gether_set_gadget(ecm_opts-net, cdev-gadget);
-   ret = gether_register_netdev(ecm_opts-net);
-   if (ret)
-   goto error;
ecm_opts-bound = true;
-   gether_get_host_addr_u8(ecm_opts-net, gfs_host_mac);
+   } else {
+   struct f_gether_opts *geth_opts;
+
+   geth_opts = container_of(fi_geth, struct f_gether_opts,
+func_inst);
+   geth_opts-bound = true;
}
+   gether_get_host_addr_u8(net, gfs_host_mac);
 #endif
 
ret = usb_string_ids_tab(cdev, gfs_strings);
@@ -437,7 +455,7 @@ error:
if (can_support_ecm(cdev-gadget))
usb_put_function_instance(fi_ecm);
else
-   

[PATCH v5 14/16] usb/gadget: g_ffs: convert to new interface of f_fs

2013-12-03 Thread Andrzej Pietrasiewicz
Prepare for configfs integration. Use the new interface so that f_fs can be
made a module.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig |1 +
 drivers/usb/gadget/g_ffs.c |  151 +++
 2 files changed, 96 insertions(+), 56 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 66444d0..2479644 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -862,6 +862,7 @@ config USB_GADGETFS
 config USB_FUNCTIONFS
tristate Function Filesystem
select USB_LIBCOMPOSITE
+   select USB_F_FS
select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || 
USB_FUNCTIONFS_RNDIS)
help
  The Function Filesystem (FunctionFS) lets one create USB
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index ffde36f..fe12e6a 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -13,13 +13,7 @@
 #define pr_fmt(fmt) g_ffs:  fmt
 
 #include linux/module.h
-/*
- * kbuild is not very cooperative with respect to linking separately
- * compiled library objects into one module.  So for now we won't use
- * separate compilation ... ensuring init/exit sections work to shrink
- * the runtime footprint, and giving us at least some parts of what
- * a gcc --combine ... part1.c part2.c part3.c ...  build would.
- */
+
 #if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
 #include linux/netdevice.h
 
@@ -54,8 +48,7 @@ static struct usb_function *f_rndis;
 #  endif
 #endif
 
-#define USB_FFS_INCLUDED
-#include f_fs.c
+#include u_fs.h
 
 #define DRIVER_NAMEg_ffs
 #define DRIVER_DESCUSB Function Filesystem
@@ -139,6 +132,7 @@ static struct usb_gadget_strings *gfs_dev_strings[] = {
 struct gfs_configuration {
struct usb_configuration c;
int (*eth)(struct usb_configuration *c);
+   int num;
 } gfs_configurations[] = {
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{
@@ -158,12 +152,15 @@ struct gfs_configuration {
 #endif
 };
 
+static void *functionfs_acquire_dev(struct ffs_dev *dev);
+static void functionfs_release_dev(struct ffs_dev *dev);
 static int functionfs_ready_callback(struct ffs_data *ffs);
 static void functionfs_closed_callback(struct ffs_data *ffs);
 static int gfs_bind(struct usb_composite_dev *cdev);
 static int gfs_unbind(struct usb_composite_dev *cdev);
 static int gfs_do_config(struct usb_configuration *c);
 
+
 static __refdata struct usb_composite_driver gfs_driver = {
.name   = DRIVER_NAME,
.dev= gfs_dev_desc,
@@ -176,10 +173,26 @@ static __refdata struct usb_composite_driver gfs_driver = 
{
 static unsigned int missing_funcs;
 static bool gfs_registered;
 static bool gfs_single_func;
-static struct ffs_dev **ffs_tab;
+static struct usb_function_instance **fi_ffs;
+static struct usb_function **f_ffs[] = {
+#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
+   NULL,
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_ETH
+   NULL,
+#endif
+
+#ifdef CONFIG_USB_FUNCTIONFS_GENERIC
+   NULL,
+#endif
+};
+
+#define N_CONF ARRAY_SIZE(f_ffs)
 
 static int __init gfs_init(void)
 {
+   struct f_fs_opts *opts;
int i;
int ret = 0;
 
@@ -190,38 +203,53 @@ static int __init gfs_init(void)
func_num = 1;
}
 
-   ffs_tab = kcalloc(func_num, sizeof(*ffs_tab), GFP_KERNEL);
-   if (!ffs_tab)
-   return -ENOMEM;
+   /*
+* Allocate in one chunk for easier maintenance
+*/
+   f_ffs[0] = kcalloc(func_num * N_CONF, sizeof(*f_ffs), GFP_KERNEL);
+   if (!f_ffs[0]) {
+   ret = -ENOMEM;
+   goto no_func;
+   }
+   for (i = 1; i  N_CONF; ++i)
+   f_ffs[i] = f_ffs[0] + i * func_num;
+
+   fi_ffs = kcalloc(func_num, sizeof(*fi_ffs), GFP_KERNEL);
+   if (!fi_ffs) {
+   ret = -ENOMEM;
+   goto no_func;
+   }
 
for (i = 0; i  func_num; i++) {
-   ffs_dev_lock();
-   ffs_tab[i] = ffs_alloc_dev();
-   ffs_dev_unlock();
-   if (IS_ERR(ffs_tab[i])) {
-   ret = PTR_ERR(ffs_tab[i]);
+   fi_ffs[i] = usb_get_function_instance(ffs);
+   if (IS_ERR(fi_ffs[i])) {
+   ret = PTR_ERR(fi_ffs[i]);
--i;
goto no_dev;
}
+   opts = to_f_fs_opts(fi_ffs[i]);
if (gfs_single_func)
-   ret = ffs_single_dev(ffs_tab[i]);
+   ret = ffs_single_dev(opts-dev);
else
-   ret = ffs_name_dev(ffs_tab[i], func_names[i]);
+   ret = ffs_name_dev(opts-dev, func_names[i]);
if (ret)
goto no_dev;
-   ffs_tab[i]-ffs_ready_callback = 

[PATCH v5 10/16] usb/gadget: FunctionFS: Remove VLAIS usage from gadget code

2013-12-03 Thread Andrzej Pietrasiewicz
The use of variable length arrays in structs (VLAIS) in the Linux Kernel code
precludes the use of compilers which don't implement VLAIS (for instance the
Clang compiler). This alternate patch calculates offsets into the kmalloc-ed
memory buffer using macros. The previous patch required multiple kmalloc and
kfree calls. This version uses group vs struct since it really is not a
struct and is essentially a group of VLA in a common allocated block. This
version also fixes the issues pointed out by Andrzej Pietrasiewicz and
Michal Nazarewicz.

Signed-off-by: Mark Charlebois charl...@gmail.com
Signed-off-by: Behan Webster beh...@converseincode.com

[elimination of miexed declaration and code, checkpatch cleanup]
[fixes after Michal's review]
Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c |  116 +---
 1 files changed, 76 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 241fc87..60cc1a5 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -30,6 +30,31 @@
 
 #define FUNCTIONFS_MAGIC   0xa647361 /* Chosen by a honest dice roll ;) */
 
+/* Variable Length Array Macros **/
+#define vla_group(groupname) size_t groupname##__next = 0
+#define vla_group_size(groupname) groupname##__next
+
+#define vla_item(groupname, type, name, n) \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = (n) * sizeof(type);  \
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_item_with_sz(groupname, type, name, n) \
+   size_t groupname##_##name##__sz = (n) * sizeof(type);  \
+   size_t groupname##_##name##__offset = ({   \
+   size_t align_mask = __alignof__(type) - 1; \
+   size_t offset = (groupname##__next + align_mask)  ~align_mask;\
+   size_t size = groupname##_##name##__sz;\
+   groupname##__next = offset + size; \
+   offset;\
+   })
+
+#define vla_ptr(ptr, groupname, name) \
+   ((void *) ((char *)ptr + groupname##_##name##__offset))
 
 /* Debugging /
 
@@ -1901,30 +1926,34 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
 
/* Allocate everything in one chunk so there's less maintenance. */
{
-   struct {
-   struct usb_gadget_strings *stringtabs[lang_count + 1];
-   struct usb_gadget_strings stringtab[lang_count];
-   struct usb_string strings[lang_count*(needed_count+1)];
-   } *d;
unsigned i = 0;
+   vla_group(d);
+   vla_item(d, struct usb_gadget_strings *, stringtabs,
+   lang_count + 1);
+   vla_item(d, struct usb_gadget_strings, stringtab, lang_count);
+   vla_item(d, struct usb_string, strings,
+   lang_count*(needed_count+1));
 
-   d = kmalloc(sizeof *d, GFP_KERNEL);
-   if (unlikely(!d)) {
+   char *vlabuf = kmalloc(vla_group_size(d), GFP_KERNEL);
+
+   if (unlikely(!vlabuf)) {
kfree(_data);
return -ENOMEM;
}
 
-   stringtabs = d-stringtabs;
-   t = d-stringtab;
+   /* Initialize the VLA pointers */
+   stringtabs = vla_ptr(vlabuf, d, stringtabs);
+   t = vla_ptr(vlabuf, d, stringtab);
i = lang_count;
do {
*stringtabs++ = t++;
} while (--i);
*stringtabs = NULL;
 
-   stringtabs = d-stringtabs;
-   t = d-stringtab;
-   s = d-strings;
+   /* stringtabs = vlabuf = d_stringtabs for later kfree */
+   stringtabs = vla_ptr(vlabuf, d, stringtabs);
+   t = vla_ptr(vlabuf, d, stringtab);
+   s = vla_ptr(vlabuf, d, strings);
strings = s;
}
 
@@ -2200,16 +2229,16 @@ static int ffs_func_bind(struct usb_configuration *c,
int ret;
 
/* Make it a single chunk, less management later on */
-   struct {
-   struct ffs_ep eps[ffs-eps_count];
- 

[PATCH v5 04/16] usb/gadget: f_ecm: remove compatibility layer

2013-12-03 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmim Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_ecm.c   |   73 +-
 drivers/usb/gadget/u_ether.h |2 -
 2 files changed, 1 insertions(+), 74 deletions(-)

diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
index 8d9e6f7..798760f 100644
--- a/drivers/usb/gadget/f_ecm.c
+++ b/drivers/usb/gadget/f_ecm.c
@@ -691,7 +691,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USBF_ECM_INCLUDED
struct f_ecm_opts   *ecm_opts;
 
if (!can_support_ecm(cdev-gadget))
@@ -715,7 +714,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
ecm_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, ecm_strings,
 ARRAY_SIZE(ecm_string_defs));
if (IS_ERR(us))
@@ -834,74 +833,6 @@ fail:
return status;
 }
 
-#ifdef USBF_ECM_INCLUDED
-
-static void
-ecm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_ecm*ecm = func_to_ecm(f);
-
-   DBG(c-cdev, ecm unbind\n);
-
-   usb_free_all_descriptors(f);
-
-   kfree(ecm-notify_req-buf);
-   usb_ep_free_request(ecm-notify, ecm-notify_req);
-   kfree(ecm);
-}
-
-/**
- * ecm_bind_config - add CDC Ethernet network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * @dev: eth_dev structure
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also responsible
- * for calling @gether_cleanup() before module unload.
- */
-int
-ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev)
-{
-   struct f_ecm*ecm;
-   int status;
-
-   if (!can_support_ecm(c-cdev-gadget) || !ethaddr)
-   return -EINVAL;
-
-   /* allocate and initialize one new instance */
-   ecm = kzalloc(sizeof *ecm, GFP_KERNEL);
-   if (!ecm)
-   return -ENOMEM;
-
-   /* export host's Ethernet address in CDC format */
-   snprintf(ecm-ethaddr, sizeof ecm-ethaddr, %pm, ethaddr);
-   ecm_string_defs[1].s = ecm-ethaddr;
-
-   ecm-port.ioport = dev;
-   ecm-port.cdc_filter = DEFAULT_FILTER;
-
-   ecm-port.func.name = cdc_ethernet;
-   /* descriptors are per-instance copies */
-   ecm-port.func.bind = ecm_bind;
-   ecm-port.func.unbind = ecm_old_unbind;
-   ecm-port.func.set_alt = ecm_set_alt;
-   ecm-port.func.get_alt = ecm_get_alt;
-   ecm-port.func.setup = ecm_setup;
-   ecm-port.func.disable = ecm_disable;
-
-   status = usb_add_function(c, ecm-port.func);
-   if (status)
-   kfree(ecm);
-   return status;
-}
-
-#else
-
 static inline struct f_ecm_opts *to_f_ecm_opts(struct config_item *item)
 {
return container_of(to_config_group(item), struct f_ecm_opts,
@@ -1040,5 +971,3 @@ static struct usb_function *ecm_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(ecm, ecm_alloc_inst, ecm_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index fb23d1f..64125a5 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -270,8 +270,6 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
 /* each configuration may bind one instance of an ethernet link */
 int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
struct eth_dev *dev);
-int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   struct eth_dev *dev);
 
 #ifdef USB_ETH_RNDIS
 
-- 
1.7.0.4

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


[PATCH v5 02/16] usb/gadget: g_ffs: remove a reduntant gfs_ether_setup variable

2013-12-03 Thread Andrzej Pietrasiewicz
Since d6a0143985489e470a118605352f4b18df0ce142
usb: gadget: move the global the_dev variable to their users
the_dev variable can be used as a setup done flag; non-NULL
meaning setup done, NULL meaning setup not done. Moreover,
gether_cleanup() can be safely called with a NULL argument.

Corrected a comment to be consistent with the code.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/g_ffs.c |   13 +
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 2344efe..e954082 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -182,7 +182,6 @@ static __refdata struct usb_composite_driver gfs_driver = {
 
 static DEFINE_MUTEX(gfs_lock);
 static unsigned int missing_funcs;
-static bool gfs_ether_setup;
 static bool gfs_registered;
 static bool gfs_single_func;
 static struct gfs_ffs_obj *ffs_tab;
@@ -364,7 +363,6 @@ static int gfs_bind(struct usb_composite_dev *cdev)
ret = PTR_ERR(the_dev);
goto error_quick;
}
-   gfs_ether_setup = true;
 
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret  0))
@@ -401,8 +399,8 @@ error_unbind:
functionfs_unbind(ffs_tab[i].ffs_data);
 error:
gether_cleanup(the_dev);
+   the_dev = NULL;
 error_quick:
-   gfs_ether_setup = false;
return ret;
 }
 
@@ -415,18 +413,17 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
 
ENTER();
 
+   gether_cleanup(the_dev);
+   the_dev = NULL;
+
/*
 * We may have been called in an error recovery from
 * composite_bind() after gfs_unbind() failure so we need to
-* check if gfs_ffs_data is not NULL since gfs_bind() handles
+* check if instance's ffs_data is not NULL since gfs_bind() handles
 * all error recovery itself.  I'd rather we werent called
 * from composite on orror recovery, but what you're gonna
 * do...?
 */
-   if (gfs_ether_setup)
-   gether_cleanup(the_dev);
-   gfs_ether_setup = false;
-
for (i = func_num; i--; )
if (ffs_tab[i].ffs_data)
functionfs_unbind(ffs_tab[i].ffs_data);
-- 
1.7.0.4

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


[PATCH v5 13/16] usb/gadget: FunctionFS: convert to new function interface with backward compatibility

2013-12-03 Thread Andrzej Pietrasiewicz
This is required in order to integrate configfs support.
f_fs needs to be a separately compiled module and so it needs to use the new
interface.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/gadget/Kconfig |3 +
 drivers/usb/gadget/Makefile|2 +
 drivers/usb/gadget/f_fs.c  |  422 
 drivers/usb/gadget/g_ffs.c |1 +
 drivers/usb/gadget/u_fs.h  |  214 
 include/linux/usb/functionfs.h |2 +
 6 files changed, 435 insertions(+), 209 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 0d117e2..66444d0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -539,6 +539,9 @@ config USB_F_RNDIS
 config USB_F_MASS_STORAGE
tristate
 
+config USB_F_FS
+   tristate
+
 choice
tristate USB Gadget Drivers
default USB_ETH
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index fd9fe1f..6bb1155 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -61,6 +61,8 @@ usb_f_rndis-y := f_rndis.o rndis.o
 obj-$(CONFIG_USB_F_RNDIS)  += usb_f_rndis.o
 usb_f_mass_storage-y   := f_mass_storage.o storage_common.o
 obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
+usb_f_fs-y := f_fs.o
+obj-$(CONFIG_USB_F_FS) += usb_f_fs.o
 
 #
 # USB gadget drivers
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 8c45dc3..fdb0625 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -22,6 +22,7 @@
 #include linux/pagemap.h
 #include linux/export.h
 #include linux/hid.h
+#include linux/module.h
 #include asm/unaligned.h
 
 #include linux/usb/composite.h
@@ -57,210 +58,6 @@
 #define vla_ptr(ptr, groupname, name) \
((void *) ((char *)ptr + groupname##_##name##__offset))
 
-/* Debugging /
-
-#ifdef VERBOSE_DEBUG
-#ifndef pr_vdebug
-#  define pr_vdebug pr_debug
-#endif /* pr_vdebug */
-#  define ffs_dump_mem(prefix, ptr, len) \
-   print_hex_dump_bytes(pr_fmt(prefix : ), DUMP_PREFIX_NONE, ptr, len)
-#else
-#ifndef pr_vdebug
-#  define pr_vdebug(...) do { } while (0)
-#endif /* pr_vdebug */
-#  define ffs_dump_mem(prefix, ptr, len) do { } while (0)
-#endif /* VERBOSE_DEBUG */
-
-#define ENTER()pr_vdebug(%s()\n, __func__)
-
-
-/* The data structure and setup file /
-
-enum ffs_state {
-   /*
-* Waiting for descriptors and strings.
-*
-* In this state no open(2), read(2) or write(2) on epfiles
-* may succeed (which should not be the problem as there
-* should be no such files opened in the first place).
-*/
-   FFS_READ_DESCRIPTORS,
-   FFS_READ_STRINGS,
-
-   /*
-* We've got descriptors and strings.  We are or have called
-* ffs_ready().  functionfs_bind() may have
-* been called but we don't know.
-*
-* This is the only state in which operations on epfiles may
-* succeed.
-*/
-   FFS_ACTIVE,
-
-   /*
-* All endpoints have been closed.  This state is also set if
-* we encounter an unrecoverable error.  The only
-* unrecoverable error is situation when after reading strings
-* from user space we fail to initialise epfiles or
-* ffs_ready() returns with error (0).
-*
-* In this state no open(2), read(2) or write(2) (both on ep0
-* as well as epfile) may succeed (at this point epfiles are
-* unlinked and all closed so this is not a problem; ep0 is
-* also closed but ep0 file exists and so open(2) on ep0 must
-* fail).
-*/
-   FFS_CLOSING
-};
-
-
-enum ffs_setup_state {
-   /* There is no setup request pending. */
-   FFS_NO_SETUP,
-   /*
-* User has read events and there was a setup request event
-* there.  The next read/write on ep0 will handle the
-* request.
-*/
-   FFS_SETUP_PENDING,
-   /*
-* There was event pending but before user space handled it
-* some other event was introduced which canceled existing
-* setup.  If this state is set read/write on ep0 return
-* -EIDRM.  This state is only set when adding event.
-*/
-   FFS_SETUP_CANCELED
-};
-
-
-
-struct ffs_epfile;
-struct ffs_function;
-
-struct ffs_data {
-   struct usb_gadget   *gadget;
-
-   /*
-* Protect access read/write operations, only one read/write
-* at a time.  As a consequence protects ep0req and company.
-* While setup request is being processed (queued) this is
-* held.
-*/
-   struct mutexmutex;
-
-   /*
-* Protect access to endpoint 

[PATCH v5 15/16] usb/gadget: FunctionFS: Remove compatibility layer

2013-12-03 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface can
be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_fs.c  |  114 
 drivers/usb/gadget/u_fs.h  |2 -
 include/linux/usb/functionfs.h |   18 --
 3 files changed, 0 insertions(+), 134 deletions(-)

diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index fdb0625..f05d3bd 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -97,19 +97,12 @@ static struct ffs_function *ffs_func_from_usb(struct 
usb_function *f)
return container_of(f, struct ffs_function, function);
 }
 
-#ifdef USB_FFS_INCLUDED
-static void ffs_func_free(struct ffs_function *func);
-#endif
 
 static void ffs_func_eps_disable(struct ffs_function *func);
 static int __must_check ffs_func_eps_enable(struct ffs_function *func);
 
 static int ffs_func_bind(struct usb_configuration *,
 struct usb_function *);
-#ifdef USB_FFS_INCLUDED
-static void old_ffs_func_unbind(struct usb_configuration *,
-   struct usb_function *);
-#endif
 static int ffs_func_set_alt(struct usb_function *, unsigned, unsigned);
 static void ffs_func_disable(struct usb_function *);
 static int ffs_func_setup(struct usb_function *,
@@ -165,9 +158,7 @@ ffs_sb_create_file(struct super_block *sb, const char 
*name, void *data,
 /* Devices management ***/
 
 DEFINE_MUTEX(ffs_lock);
-#ifndef USB_FFS_INCLUDED
 EXPORT_SYMBOL(ffs_lock);
-#endif
 
 static struct ffs_dev *ffs_find_dev(const char *name);
 static void *ffs_acquire_dev(const char *dev_name);
@@ -1302,75 +1293,6 @@ static void ffs_epfiles_destroy(struct ffs_epfile 
*epfiles, unsigned count)
kfree(epfiles);
 }
 
-#ifdef USB_FFS_INCLUDED
-
-static int functionfs_bind_config(struct usb_composite_dev *cdev,
- struct usb_configuration *c,
- struct ffs_data *ffs)
-{
-   struct ffs_function *func;
-   int ret;
-
-   ENTER();
-
-   func = kzalloc(sizeof *func, GFP_KERNEL);
-   if (unlikely(!func))
-   return -ENOMEM;
-
-   func-function.name= Function FS Gadget;
-   func-function.strings = ffs-stringtabs;
-
-   func-function.bind= ffs_func_bind;
-   func-function.unbind  = old_ffs_func_unbind;
-   func-function.set_alt = ffs_func_set_alt;
-   func-function.disable = ffs_func_disable;
-   func-function.setup   = ffs_func_setup;
-   func-function.suspend = ffs_func_suspend;
-   func-function.resume  = ffs_func_resume;
-
-   func-conf   = c;
-   func-gadget = cdev-gadget;
-   func-ffs = ffs;
-   ffs_data_get(ffs);
-
-   ret = usb_add_function(c, func-function);
-   if (unlikely(ret))
-   ffs_func_free(func);
-
-   return ret;
-}
-
-static void ffs_func_free(struct ffs_function *func)
-{
-   struct ffs_ep *ep = func-eps;
-   unsigned count= func-ffs-eps_count;
-   unsigned long flags;
-
-   ENTER();
-
-   /* cleanup after autoconfig */
-   spin_lock_irqsave(func-ffs-eps_lock, flags);
-   do {
-   if (ep-ep  ep-req)
-   usb_ep_free_request(ep-ep, ep-req);
-   ep-req = NULL;
-   ++ep;
-   } while (--count);
-   spin_unlock_irqrestore(func-ffs-eps_lock, flags);
-
-   ffs_data_put(func-ffs);
-
-   kfree(func-eps);
-   /*
-* eps and interfaces_nums are allocated in the same chunk so
-* only one free is required.  Descriptors are also allocated
-* in the same chunk.
-*/
-
-   kfree(func);
-}
-
-#endif
 
 static void ffs_func_eps_disable(struct ffs_function *func)
 {
@@ -2034,7 +1956,6 @@ static int __ffs_func_bind_do_nums(enum ffs_entity_type 
type, u8 *valuep,
return 0;
 }
 
-#ifndef USB_FFS_INCLUDED
 static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
struct usb_configuration *c)
 {
@@ -2083,7 +2004,6 @@ static inline struct f_fs_opts 
*ffs_do_functionfs_bind(struct usb_function *f,
 
return ffs_opts;
 }
-#endif
 
 static int _ffs_func_bind(struct usb_configuration *c,
  struct usb_function *f)
@@ -2189,12 +2109,10 @@ error:
 static int ffs_func_bind(struct usb_configuration *c,
 struct usb_function *f)
 {
-#ifndef USB_FFS_INCLUDED
struct f_fs_opts *ffs_opts = ffs_do_functionfs_bind(f, c);
 
if (IS_ERR(ffs_opts))
return PTR_ERR(ffs_opts);
-#endif
 
return _ffs_func_bind(c, f);
 }
@@ -2202,28 +2120,6 @@ static int ffs_func_bind(struct usb_configuration *c,
 
 /* Other USB function hooks 

[PATCH v5 09/16] usb/gadget: rndis: merge u_rndis.ko with usb_f_rndis.ko

2013-12-03 Thread Andrzej Pietrasiewicz
The rndis function's users use only the new interface, so the two modules
can be merged.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/Kconfig   |7 ---
 drivers/usb/gadget/Makefile  |4 +---
 drivers/usb/gadget/f_rndis.c |   22 +-
 drivers/usb/gadget/rndis.c   |7 ++-
 drivers/usb/gadget/u_rndis.h |2 ++
 5 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 54b9856..0d117e2 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -512,9 +512,6 @@ config USB_U_SERIAL
 config USB_U_ETHER
tristate
 
-config USB_U_RNDIS
-   tristate
-
 config USB_F_SERIAL
tristate
 
@@ -642,7 +639,6 @@ config USB_CONFIGFS_RNDIS
depends on USB_CONFIGFS
depends on NET
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_RNDIS
help
   Microsoft Windows XP bundles the Remote NDIS (RNDIS) protocol,
@@ -760,7 +756,6 @@ config USB_ETH
depends on NET
select USB_LIBCOMPOSITE
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_ECM
select USB_F_SUBSET
select CRC32
@@ -893,7 +888,6 @@ config USB_FUNCTIONFS_RNDIS
bool Include configuration with RNDIS (Ethernet)
depends on USB_FUNCTIONFS  NET
select USB_U_ETHER
-   select USB_U_RNDIS
select USB_F_RNDIS
help
  Include a configuration with RNDIS function (Ethernet) and the 
Filesystem.
@@ -1068,7 +1062,6 @@ config USB_G_MULTI
 config USB_G_MULTI_RNDIS
bool RNDIS + CDC Serial + Storage configuration
depends on USB_G_MULTI
-   select USB_U_RNDIS
select USB_F_RNDIS
default y
help
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index f1af396..fd9fe1f 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -47,8 +47,6 @@ obj-$(CONFIG_USB_F_SERIAL)+= usb_f_serial.o
 usb_f_obex-y   := f_obex.o
 obj-$(CONFIG_USB_F_OBEX)   += usb_f_obex.o
 obj-$(CONFIG_USB_U_ETHER)  += u_ether.o
-u_rndis-y  := rndis.o
-obj-$(CONFIG_USB_U_RNDIS)  += u_rndis.o
 usb_f_ncm-y:= f_ncm.o
 obj-$(CONFIG_USB_F_NCM)+= usb_f_ncm.o
 usb_f_ecm-y:= f_ecm.o
@@ -59,7 +57,7 @@ usb_f_eem-y   := f_eem.o
 obj-$(CONFIG_USB_F_EEM)+= usb_f_eem.o
 usb_f_ecm_subset-y := f_subset.o
 obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o
-usb_f_rndis-y  := f_rndis.o
+usb_f_rndis-y  := f_rndis.o rndis.o
 obj-$(CONFIG_USB_F_RNDIS)  += usb_f_rndis.o
 usb_f_mass_storage-y   := f_mass_storage.o storage_common.o
 obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 9d7c995..c11761c 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -979,6 +979,26 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
return rndis-port.func;
 }
 
-DECLARE_USB_FUNCTION_INIT(rndis, rndis_alloc_inst, rndis_alloc);
+DECLARE_USB_FUNCTION(rndis, rndis_alloc_inst, rndis_alloc);
+
+static int __init rndis_mod_init(void)
+{
+   int ret;
+
+   ret = rndis_init();
+   if (ret)
+   return ret;
+
+   return usb_function_register(rndisusb_func);
+}
+module_init(rndis_mod_init);
+
+static void __exit rndis_mod_exit(void)
+{
+   usb_function_unregister(rndisusb_func);
+   rndis_exit();
+}
+module_exit(rndis_mod_exit);
+
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
diff --git a/drivers/usb/gadget/rndis.c b/drivers/usb/gadget/rndis.c
index a3ad732..1ffbdb4 100644
--- a/drivers/usb/gadget/rndis.c
+++ b/drivers/usb/gadget/rndis.c
@@ -1142,7 +1142,7 @@ static struct proc_dir_entry *rndis_connect_state 
[RNDIS_MAX_CONFIGS];
 #endif /* CONFIG_USB_GADGET_DEBUG_FILES */
 
 
-static int rndis_init(void)
+int rndis_init(void)
 {
u8 i;
 
@@ -1174,9 +1174,8 @@ static int rndis_init(void)
 
return 0;
 }
-module_init(rndis_init);
 
-static void rndis_exit(void)
+void rndis_exit(void)
 {
 #ifdef CONFIG_USB_GADGET_DEBUG_FILES
u8 i;
@@ -1188,6 +1187,4 @@ static void rndis_exit(void)
}
 #endif
 }
-module_exit(rndis_exit);
 
-MODULE_LICENSE(GPL);
diff --git a/drivers/usb/gadget/u_rndis.h b/drivers/usb/gadget/u_rndis.h
index c62ba82..7291b15 100644
--- a/drivers/usb/gadget/u_rndis.h
+++ b/drivers/usb/gadget/u_rndis.h
@@ -36,6 +36,8 @@ struct f_rndis_opts {
int refcnt;
 };
 
+int rndis_init(void);
+void rndis_exit(void);
 void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net);
 
 #endif /* U_RNDIS_H */
-- 

Re: 答复: Re: 答复: Re: 答复: Re: 答复: Re: 【PATCH】USB:add new zte 3g-modem's pid to option.c

2013-12-03 Thread Greg KH
On Tue, Dec 03, 2013 at 04:50:17PM +0800, zhang.ju...@zte.com.cn wrote:
 
 This was in html format, and line-wrapped, with no signed-off-by: line
 :(

And your responses are still in html, making the mailing list reject
them.

 Re:with no signed-off-by: line:(, it means there are no signed-off-by in
 my option-patch.diff?

I don't know, I just looked at the in-line patch.

Please read Documenation/email_clients.txt and
Documentation/SubmittingPatches for how to fix up your patch and email
tool properly.

thanks,

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


[PATCH v5 08/16] usb/gadget: f_rndis: remove compatibility layer

2013-12-03 Thread Andrzej Pietrasiewicz
There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Michal Nazarewicz min...@mina86.com
---
 drivers/usb/gadget/f_rndis.c |   72 +-
 drivers/usb/gadget/u_ether.h |   36 -
 2 files changed, 1 insertions(+), 107 deletions(-)

diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 717ed7f..9d7c995 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -675,7 +675,6 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
int status;
struct usb_ep   *ep;
 
-#ifndef USB_FRNDIS_INCLUDED
struct f_rndis_opts *rndis_opts;
 
if (!can_support_rndis(c))
@@ -697,7 +696,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function 
*f)
return status;
rndis_opts-bound = true;
}
-#endif
+
us = usb_gstrings_attach(cdev, rndis_strings,
 ARRAY_SIZE(rndis_string_defs));
if (IS_ERR(us))
@@ -782,13 +781,6 @@ rndis_bind(struct usb_configuration *c, struct 
usb_function *f)
rndis-port.open = rndis_open;
rndis-port.close = rndis_close;
 
-#ifdef USB_FRNDIS_INCLUDED
-   status = rndis_register(rndis_response_available, rndis);
-   if (status  0)
-   goto fail;
-   rndis-config = status;
-#endif
-
rndis_set_param_medium(rndis-config, RNDIS_MEDIUM_802_3, 0);
rndis_set_host_mac(rndis-config, rndis-ethaddr);
 
@@ -830,66 +822,6 @@ fail:
return status;
 }
 
-#ifdef USB_FRNDIS_INCLUDED
-
-static void
-rndis_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
-   struct f_rndis  *rndis = func_to_rndis(f);
-
-   rndis_deregister(rndis-config);
-
-   usb_free_all_descriptors(f);
-
-   kfree(rndis-notify_req-buf);
-   usb_ep_free_request(rndis-notify, rndis-notify_req);
-
-   kfree(rndis);
-}
-
-int
-rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev)
-{
-   struct f_rndis  *rndis;
-   int status;
-
-   /* allocate and initialize one new instance */
-   status = -ENOMEM;
-   rndis = kzalloc(sizeof *rndis, GFP_KERNEL);
-   if (!rndis)
-   goto fail;
-
-   memcpy(rndis-ethaddr, ethaddr, ETH_ALEN);
-   rndis-vendorID = vendorID;
-   rndis-manufacturer = manufacturer;
-
-   rndis-port.ioport = dev;
-   /* RNDIS activates when the host changes this filter */
-   rndis-port.cdc_filter = 0;
-
-   /* RNDIS has special (and complex) framing */
-   rndis-port.header_len = sizeof(struct rndis_packet_msg_type);
-   rndis-port.wrap = rndis_add_header;
-   rndis-port.unwrap = rndis_rm_hdr;
-
-   rndis-port.func.name = rndis;
-   /* descriptors are per-instance copies */
-   rndis-port.func.bind = rndis_bind;
-   rndis-port.func.unbind = rndis_old_unbind;
-   rndis-port.func.set_alt = rndis_set_alt;
-   rndis-port.func.setup = rndis_setup;
-   rndis-port.func.disable = rndis_disable;
-
-   status = usb_add_function(c, rndis-port.func);
-   if (status)
-   kfree(rndis);
-fail:
-   return status;
-}
-
-#else
-
 void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net)
 {
struct f_rndis_opts *opts;
@@ -1050,5 +982,3 @@ static struct usb_function *rndis_alloc(struct 
usb_function_instance *fi)
 DECLARE_USB_FUNCTION_INIT(rndis, rndis_alloc_inst, rndis_alloc);
 MODULE_LICENSE(GPL);
 MODULE_AUTHOR(David Brownell);
-
-#endif
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index f310e6f..f1e0cbe 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -267,40 +267,4 @@ static inline bool can_support_ecm(struct usb_gadget 
*gadget)
return true;
 }
 
-/* each configuration may bind one instance of an ethernet link */
-#ifdef USB_ETH_RNDIS
-
-int rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev);
-
-#else
-
-static inline int
-rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
-   u32 vendorID, const char *manufacturer, struct eth_dev *dev)
-{
-   return 0;
-}
-
-#endif
-
-/**
- * rndis_bind_config - add RNDIS network link to a configuration
- * @c: the configuration to support the network link
- * @ethaddr: a buffer in which the ethernet address of the host side
- * side of the link was recorded
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- * Caller must have called @gether_setup().  Caller is also 

Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Greg KH
On Tue, Dec 03, 2013 at 01:38:10PM +0100, Marc Kleine-Budde wrote:
 On 12/03/2013 04:38 AM, Greg KH wrote:
  On Tue, Dec 03, 2013 at 11:00:30AM +0800, Peter Chen wrote:
  On Mon, Dec 02, 2013 at 03:43:48PM -0800, Greg KH wrote:
  From: Greg Kroah-Hartman gre...@linuxfoundation.org
 
  Alexander isn't able to maintain the Chipidea code anymore, and as Peter
  has been acting as the de-facto maintainer anyway, make it official.
 
  Cc: Alexander Shishkin alexander.shish...@linux.intel.com
  Cc: Peter Chen peter.c...@freescale.com
  Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
 
  ---
 
  Alex and Peter, can I get your signed-off-by: or ack for this patch?
 
  diff --git a/MAINTAINERS b/MAINTAINERS
  index 4afcfb4c..e3e79afd 100644
  --- a/MAINTAINERS
  +++ b/MAINTAINERS
  @@ -2137,7 +2137,7 @@ S:  Maintained
   F:   Documentation/zh_CN/
   
   CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
  -M:   Alexander Shishkin alexander.shish...@linux.intel.com
  +M:   Peter Chen peter.c...@freescale.com
   L:   linux-usb@vger.kernel.org
   S:   Maintained
   F:   drivers/usb/chipidea/
  --
 
  Acked-by: Peter Chen peter.c...@freescale.com
 
  Greg, below is my git tree, please help add it, thanks.
  T: git://github.com/hzpeterchen/linux-usb.git
  
  Ugh, github, really?  I'm not going to pull from a github tree, sorry.
  Can you apply for a kernel.org one?
 
 github can be used without all that fancy web-2.0 interface.

I know, I use it all the time, even with that interface, that's not what
I'm objecting to.

 If Peter sends you a standard plain $(git request-pull) it's not much
 different from a non github git account.

We don't take kernel pulls from github accounts, that is why we have
git.kernel.org for, which is authenticated a bit more than random
github accounts.

thanks,

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


[PATCH 2/3] usb: ohci-at91: replace request_mem_region + ioremap by devm_request_and_ioremap

2013-12-03 Thread Boris BREZILLON
Replace the request_mem_region + ioremap calls by the
devm_request_and_ioremap call which does the same things but with device
managed resources.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 drivers/usb/host/ohci-at91.c |   24 +---
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 7aec6ca..c406f1e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -157,24 +157,18 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd-rsrc_start = mem_r-start;
hcd-rsrc_len = resource_size(mem_r);
 
-   if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
-   pr_debug(request_mem_region failed\n);
-   retval = -EBUSY;
-   goto err1;
-   }
-
-   hcd-regs = ioremap(hcd-rsrc_start, hcd-rsrc_len);
+   hcd-regs = devm_request_and_ioremap(pdev-dev, mem_r);
if (!hcd-regs) {
-   pr_debug(ioremap failed\n);
+   dev_dbg(dev, devm_request_and_ioremap failed\n);
retval = -EIO;
-   goto err2;
+   goto err;
}
 
iclk = clk_get(pdev-dev, ohci_clk);
if (IS_ERR(iclk)) {
dev_err(pdev-dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
-   goto err3;
+   goto err;
}
fclk = clk_get(pdev-dev, uhpck);
if (IS_ERR(fclk)) {
@@ -218,13 +212,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
  err4:
clk_put(iclk);
 
- err3:
-   iounmap(hcd-regs);
-
- err2:
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
-
- err1:
+ err:
usb_put_hcd(hcd);
return retval;
 }
@@ -247,8 +235,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
 {
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
-   iounmap(hcd-regs);
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);
 
if (IS_ENABLED(CONFIG_COMMON_CLK))
-- 
1.7.9.5

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


[PATCH 2/3] ARM: OMAP2+: hwmod: Fix RESET logic

2013-12-03 Thread Roger Quadros
In _ocp_softreset(), after _set_softreset() + write_sysconfig(),
the hwmod's sysc_cache will always contain SOFTRESET bit set
so all further writes to sysconfig using this cache will initiate
a repeated SOFTRESET e.g. enable_sysc(). This is true for OMAP3 like
platforms that have RESET_DONE status in the SYSSTATUS register and
so the the SOFTRESET bit in SYSCONFIG is not automatically cleared.
It is not a problem for OMAP4 like platforms that indicate RESET
completion by clearing the SOFTRESET bit in the SYSCONFIG register.

This repeated SOFTRESET is undesired and was the root cause of
USB host issues on OMAP3 platforms when hwmod was allowed to do the
SOFTRESET for the USB Host module.

To fix this we clear the SOFTRESET bit and update the sysconfig
register + sysc_cache using write_sysconfig().

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod.c | 43 +++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e3f0eca..615acec 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -399,7 +399,7 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 
clockact, u32 *v)
 }
 
 /**
- * _set_softreset: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v
+ * _set_softreset: set OCP_SYSCONFIG.SOFTRESET bit in @v
  * @oh: struct omap_hwmod *
  * @v: pointer to register contents to modify
  *
@@ -427,6 +427,36 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
 }
 
 /**
+ * _clr_softreset: clear OCP_SYSCONFIG.SOFTRESET bit in @v
+ * @oh: struct omap_hwmod *
+ * @v: pointer to register contents to modify
+ *
+ * Clear the SOFTRESET bit in @v for hwmod @oh.  Returns -EINVAL upon
+ * error or 0 upon success.
+ */
+static int _clr_softreset(struct omap_hwmod *oh, u32 *v)
+{
+   u32 softrst_mask;
+
+   if (!oh-class-sysc ||
+   !(oh-class-sysc-sysc_flags  SYSC_HAS_SOFTRESET))
+   return -EINVAL;
+
+   if (!oh-class-sysc-sysc_fields) {
+   WARN(1,
+omap_hwmod: %s: sysc_fields absent for sysconfig class\n,
+oh-name);
+   return -EINVAL;
+   }
+
+   softrst_mask = (0x1  oh-class-sysc-sysc_fields-srst_shift);
+
+   *v = ~softrst_mask;
+
+   return 0;
+}
+
+/**
  * _wait_softreset_complete - wait for an OCP softreset to complete
  * @oh: struct omap_hwmod * to wait on
  *
@@ -1911,6 +1941,12 @@ static int _ocp_softreset(struct omap_hwmod *oh)
ret = _set_softreset(oh, v);
if (ret)
goto dis_opt_clks;
+
+   _write_sysconfig(v, oh);
+   ret = _clr_softreset(oh, v);
+   if (ret)
+   goto dis_opt_clks;
+
_write_sysconfig(v, oh);
 
if (oh-class-sysc-srst_udelay)
@@ -3169,6 +3205,11 @@ int omap_hwmod_softreset(struct omap_hwmod *oh)
goto error;
_write_sysconfig(v, oh);
 
+   ret = _clr_softreset(oh, v);
+   if (ret)
+   goto error;
+   _write_sysconfig(v, oh);
+
 error:
return ret;
 }
-- 
1.8.3.2

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


[PATCH 1/3] ARM: OMAP4+: hwmod data: Don't prevent RESET of USB Host module

2013-12-03 Thread Roger Quadros
Without this, the USB devices are sometimes not detected on OMAP4 Panda
with u-boot v2013.10.

Unlike what the comment states, errata i660 does not state that we
can't RESET the USB host module. Instead it states that RESET is the
only way to recover from a deadlock situation.

RESET ensures that the module is in a known good state irrespective
of what bootloader does with the module, so it must be done at boot.

Reported-by: Tomi Valkeinen tomi.valkei...@ti.com
Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 12 ++--
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c | 13 +++--
 2 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 1e5b12c..3318cae9 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2937,7 +2937,7 @@ static struct omap_hwmod_class_sysconfig 
omap44xx_usb_host_hs_sysc = {
.sysc_offs  = 0x0010,
.syss_offs  = 0x0014,
.sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE |
-  SYSC_HAS_SOFTRESET),
+  SYSC_HAS_SOFTRESET | SYSC_HAS_RESET_STATUS),
.idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
@@ -3001,15 +3001,7 @@ static struct omap_hwmod omap44xx_usb_host_hs_hwmod = {
 * hence HWMOD_SWSUP_MSTANDBY
 */
 
-   /*
-* During system boot; If the hwmod framework resets the module
-* the module will have smart idle settings; which can lead to deadlock
-* (above Errata Id:i660); so, dont reset the module during boot;
-* Use HWMOD_INIT_NO_RESET.
-*/
-
-   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
- HWMOD_INIT_NO_RESET,
+   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
 };
 
 /*
diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index 9e08d69..e297d62 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -1544,7 +1544,8 @@ static struct omap_hwmod_class_sysconfig 
omap54xx_usb_host_hs_sysc = {
.rev_offs   = 0x,
.sysc_offs  = 0x0010,
.sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_RESET_STATUS |
-  SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET),
+  SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET |
+  SYSC_HAS_RESET_STATUS),
.idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
@@ -1598,15 +1599,7 @@ static struct omap_hwmod omap54xx_usb_host_hs_hwmod = {
 * hence HWMOD_SWSUP_MSTANDBY
 */
 
-   /*
-* During system boot; If the hwmod framework resets the module
-* the module will have smart idle settings; which can lead to deadlock
-* (above Errata Id:i660); so, dont reset the module during boot;
-* Use HWMOD_INIT_NO_RESET.
-*/
-
-   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
- HWMOD_INIT_NO_RESET,
+   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
.main_clk   = l3init_60m_fclk,
.prcm = {
.omap4 = {
-- 
1.8.3.2

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


RE: [PATCH 3/3 v4] usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

2013-12-03 Thread Peter Chen
 
 
 usb: chipidea: hw_phymode_configure moved before ci_usb_phy_init

usb: chipidea: put hw_phymode_configure before ci_usb_phy_init
Besides, a blank line is needed between your subject and commit log.

 hw_phymode_configure configures the PORTSC registers and allow the
 following phy_inits to operate on the right parameters. This fix a
 problem
 where the UPLI (ISP1504) could not detected,
^^be

 because the Viewport was not
 available and read the viewport return 0's only.
 
 Signed-off-by: Chris Ruehl chris.ru...@gtsys.com.hk
 Acked-by: Peter Chen peter.c...@freescale.com
 ---
  drivers/usb/chipidea/core.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
 index 2834801..43897dd 100644
 --- a/drivers/usb/chipidea/core.c
 +++ b/drivers/usb/chipidea/core.c
 @@ -564,6 +564,8 @@ static int ci_hdrc_probe(struct platform_device *pdev)
   return -ENODEV;
   }
 
 + hw_phymode_configure(ci);
 +
   ret = ci_usb_phy_init(ci);
   if (ret) {
   dev_err(dev, unable to init phy: %d\n, ret);
 @@ -581,8 +583,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 
   ci_get_otg_capable(ci);
 
 - hw_phymode_configure(ci);
 -
   dr_mode = ci-platdata-dr_mode;
   /* initialize role(s) before the interrupt is requested */
   if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
 --
 1.7.10.4
 


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


[PATCH v2 0/3] ARM: OMAP2+: USB Host bug fixes for 3.13 rc

2013-12-03 Thread Roger Quadros
Hi,

This is a follow up solution to the original series in [1]

The first patch fixes the OMAP4 Panda USB detection problems on 3.13-rc1
with u-boot v2013.10.

The remaining 2 patches are required if SOFTRESET needs to be done for the
USB Host module on OMAP3 platforms.

Patch 2 fixes the hwmod RESET logic to prevent multiple SOFTRESETs
being issued to the modules. This multiple SOFTRESET was causing problems
with OMAP3 USB Host module. On Beagleboard C4 this is seen as failure to
mount NFS root over external USB to Ethernet device.

This might be the reason why HWMOD_INIT_NO_RESET was used for the OMAP
USB host module in OMAP3 hwmod data and just carried forward in OMAP4
and OMAP5 hwmod data as well.

cheers,
-roger

[1] - http://thread.gmane.org/gmane.linux.kernel/1603931

Roger Quadros (3):
  ARM: OMAP4+: hwmod data: Don't prevent RESET of USB Host module
  ARM: OMAP2+: hwmod: Fix RESET logic
  ARM: OMAP3: hwmod data: Don't prevent RESET of USB Host module

 arch/arm/mach-omap2/omap_hwmod.c   | 43 +-
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 13 +++--
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 12 ++---
 arch/arm/mach-omap2/omap_hwmod_54xx_data.c | 13 +++--
 4 files changed, 50 insertions(+), 31 deletions(-)

-- 
1.8.3.2

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


[PATCH 3/3] ARM: OMAP3: hwmod data: Don't prevent RESET of USB Host module

2013-12-03 Thread Roger Quadros
Unlike what the comment states, errata i660 does not state that we
can't RESET the USB host module. Instead it states that RESET is the
only way to recover from a deadlock situation.

RESET ensures that the module is in a known good state irrespective
of what bootloader does with the module, so it must be done at boot.

Signed-off-by: Roger Quadros rog...@ti.com
---
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 9e56fab..d337429 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1943,7 +1943,8 @@ static struct omap_hwmod_class_sysconfig 
omap3xxx_usb_host_hs_sysc = {
.syss_offs  = 0x0014,
.sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
   SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP |
-  SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE),
+  SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
+  SYSS_HAS_RESET_STATUS),
.idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
   MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
.sysc_fields= omap_hwmod_sysc_type1,
@@ -2021,15 +2022,7 @@ static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = {
 * hence HWMOD_SWSUP_MSTANDBY
 */
 
-   /*
-* During system boot; If the hwmod framework resets the module
-* the module will have smart idle settings; which can lead to deadlock
-* (above Errata Id:i660); so, dont reset the module during boot;
-* Use HWMOD_INIT_NO_RESET.
-*/
-
-   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
- HWMOD_INIT_NO_RESET,
+   .flags  = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
 };
 
 /*
-- 
1.8.3.2

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


Re: [3.8-rc3 - 3.8-rc4 regression] Re: [PATCH] module, async: async_synchronize_full() on module init iff async is used

2013-12-03 Thread Josh Hunt
On Tue, Nov 26, 2013 at 4:29 PM, Tejun Heo t...@kernel.org wrote:
 Hello,

 On Tue, Nov 26, 2013 at 04:12:41PM -0600, Josh Hunt wrote:
 I should have clarified that I'm not using dm/md in my setup. I know
 the modules are getting loaded in the log I attached, but root is not
 a md/dm device.

 Can you please still try it?  The init script is broken and we're now
 just trying to restore just enough of the old behavior so that the
 issue is not exposed.  The boot script in use seems to load md/dm
 modules after storage drivers and use their termination as the signal
 for storage ready, so it could be a good enough bandaid even if
 you're not using dm/md.

 Thanks.

 --
 tejun

Tejun

You're right. Thanks for pointing this out. I did not realize there
was a bug in the init script. The version of initramfs-tools I was
using had the following bug:
https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1215911

Updating to 0.99ubuntu13.4 of initramfs-tools resolved my boot hangs.

I did try using the workaround as suggested by Linus. In my setup the
dm_init() code was hit, however it still appeared to be too late at
times. I also tried moving the call to async_synchronize_full() above
the for loop and it still had the same issue (patch attached.) Out of
around 10 reboot tests it failed to find root 1 or 2 times.

The ubuntu scripts don't ever actually call do_mount() if it can't
find the device. It seems to rely on some udev functionality to tell
it when the device is present, and if that fails it just bails out.

This change has introduced a regression. However, I only noticed it
b/c my init script had a bug which caused it not to wait around for
the device to appear.

-- 
Josh
Index: linux-3.10/drivers/md/dm.c
===
--- linux-3.10.orig/drivers/md/dm.c
+++ linux-3.10/drivers/md/dm.c
@@ -16,12 +16,13 @@
 #include linux/bio.h
 #include linux/mempool.h
 #include linux/slab.h
 #include linux/idr.h
 #include linux/hdreg.h
 #include linux/delay.h
+#include linux/async.h
 
 #include trace/events/block.h
 
 #define DM_MSG_PREFIX core
 
 #ifdef CONFIG_PRINTK
@@ -275,12 +276,15 @@ static void (*_exits[])(void) = {
 static int __init dm_init(void)
 {
 	const int count = ARRAY_SIZE(_inits);
 
 	int r, i;
 
+	printk(KERN_CRIT DBG: %s: Calling async_synchronize_full();\n, __func__);
+	async_synchronize_full();
+
 	for (i = 0; i  count; i++) {
 		r = _inits[i]();
 		if (r)
 			goto bad;
 	}
 
Index: linux-3.10/drivers/md/md.c
===
--- linux-3.10.orig/drivers/md/md.c
+++ linux-3.10/drivers/md/md.c
@@ -48,12 +48,13 @@
 #include linux/file.h
 #include linux/compat.h
 #include linux/delay.h
 #include linux/raid/md_p.h
 #include linux/raid/md_u.h
 #include linux/slab.h
+#include linux/async.h
 #include md.h
 #include bitmap.h
 
 #ifndef MODULE
 static void autostart_arrays(int part);
 #endif
@@ -8573,12 +8574,14 @@ static void autostart_arrays(int part)
 	dev_t dev;
 	int i_scanned, i_passed;
 
 	i_scanned = 0;
 	i_passed = 0;
 
+	printk(KERN_CRIT DBG: %s: Calling async_synchronize_full()\n, __func__);
+	async_synchronize_full();
 	printk(KERN_INFO md: Autodetecting RAID arrays.\n);
 
 	while (!list_empty(all_detected_devices)  i_scanned  INT_MAX) {
 		i_scanned++;
 		node_detected_dev = list_entry(all_detected_devices.next,
 	struct detected_devices_node, list);


Re: Strange behavior with ZTE MF821D (and possible other MDM9200 devices)

2013-12-03 Thread Bjørn Mork
Kristian Evensen kristian.even...@gmail.com writes:

 We are currently facing a USB problem that we have not been able to
 solve. A USB ACK is not sent and the following messages appear in the
 kernel logs:
 Thu Nov 21 09:44:53 2013 kern.err kernel: [  490.60] qmi_wwan
 1-1.1.2:1.4: nonzero urb status received: -71
 Thu Nov 21 09:44:53 2013 kern.err kernel: [  490.60] qmi_wwan
 1-1.1.2:1.4: wdm_int_callback - 0 bytes

The most likely cause of this is a modem firmware crash.  I don't think
there is much you can do about that, except trying to avoid the
situations which causes the crash or getting another modem.


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


Re: [PATCH] USB: switch maintainership of chipidea to Peter

2013-12-03 Thread Marc Kleine-Budde
On 12/03/2013 03:21 PM, Greg KH wrote:
 Ugh, github, really?  I'm not going to pull from a github tree, sorry.
 Can you apply for a kernel.org one?

 github can be used without all that fancy web-2.0 interface.
 
 I know, I use it all the time, even with that interface, that's not what
 I'm objecting to.
 
 If Peter sends you a standard plain $(git request-pull) it's not much
 different from a non github git account.
 
 We don't take kernel pulls from github accounts, that is why we have
 git.kernel.org for, which is authenticated a bit more than random
 github accounts.

Thanks for the clarification.

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature


[PATCH 1/3] usb: ohci-at91: fix irq and iomem resource retrieval

2013-12-03 Thread Boris BREZILLON
When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resource
table.

Retrieve resources using the platform_get_resource function instead of
direct resource table entries to avoid resource type mismatch.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
 drivers/usb/host/ohci-at91.c |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 418444e..7aec6ca 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -136,23 +136,26 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct device *dev = pdev-dev;
+   struct resource *mem_r, *irq_r;
 
-   if (pdev-num_resources != 2) {
-   pr_debug(hcd probe: invalid num_resources);
+   mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!mem_r) {
+   dev_dbg(dev, hcd probe: missing memory resource\n);
return -ENODEV;
}
 
-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   pr_debug(hcd probe: invalid resource type\n);
+   irq_r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!irq_r) {
+   dev_dbg(dev, hcd probe: missing irq resource\n);
return -ENODEV;
}
 
hcd = usb_create_hcd(driver, pdev-dev, at91);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = pdev-resource[0].start;
-   hcd-rsrc_len = resource_size(pdev-resource[0]);
+   hcd-rsrc_start = mem_r-start;
+   hcd-rsrc_len = resource_size(mem_r);
 
if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed\n);
@@ -199,7 +202,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
ohci-num_ports = board-ports;
at91_start_hc(pdev);
 
-   retval = usb_add_hcd(hcd, pdev-resource[1].start, IRQF_SHARED);
+   retval = usb_add_hcd(hcd, irq_r-start, IRQF_SHARED);
if (retval == 0)
return retval;
 
-- 
1.7.9.5

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


[PATCH 0/3] usb: ohci-at91: various fixes and improvements

2013-12-03 Thread Boris BREZILLON
Hello,

This patch series fixes a bug detected in 3.13-rc1 caused by a wrong
assumption on platform device resources order in the platform device
resource table.

It also move the different driver resources (clks and iomem) retrieval
to the device managed versions (devm_ functions).

Best Regards,

Boris

Boris BREZILLON (3):
  usb: ohci-at91: fix irq and iomem resource retrieval
  usb: ohci-at91: replace request_mem_region + ioremap by
devm_request_and_ioremap
  usb: ohci-at91: use device managed clk retrieval

 drivers/usb/host/ohci-at91.c |   75 ++
 1 file changed, 24 insertions(+), 51 deletions(-)

-- 
1.7.9.5

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


Re: Strange behavior with ZTE MF821D (and possible other MDM9200 devices)

2013-12-03 Thread Kristian Evensen
Hei Bjørn,

On Tue, Dec 3, 2013 at 3:37 PM, Bjørn Mork bj...@mork.no wrote:
 The most likely cause of this is a modem firmware crash.  I don't think
 there is much you can do about that, except trying to avoid the
 situations which causes the crash or getting another modem.

Ok, that is what I suspected, thank you very much for letting me know.
Then I guess we have to live with some work-arounds. One interesting
observation is that the modem seems to reboot by itself and works just
fine once the USB queue (probably not the correct name) has been
flushed, so we will try to speed up the flush when packets with status
-71 arrives. I guess this will be a special case solution and not
something that should be submitted as a patch to the kernel.

Thanks again for the help,
Kristian
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [3.8-rc3 - 3.8-rc4 regression] Re: [PATCH] module, async: async_synchronize_full() on module init iff async is used

2013-12-03 Thread Tejun Heo
Hello,

On Tue, Dec 03, 2013 at 08:28:43AM -0600, Josh Hunt wrote:
 You're right. Thanks for pointing this out. I did not realize there
 was a bug in the init script. The version of initramfs-tools I was
 using had the following bug:
 https://bugs.launchpad.net/ubuntu/+source/initramfs-tools/+bug/1215911
 
 Updating to 0.99ubuntu13.4 of initramfs-tools resolved my boot hangs.
 
 I did try using the workaround as suggested by Linus. In my setup the
 dm_init() code was hit, however it still appeared to be too late at
 times. I also tried moving the call to async_synchronize_full() above
 the for loop and it still had the same issue (patch attached.) Out of
 around 10 reboot tests it failed to find root 1 or 2 times.
 
 The ubuntu scripts don't ever actually call do_mount() if it can't
 find the device. It seems to rely on some udev functionality to tell
 it when the device is present, and if that fails it just bails out.
 
 This change has introduced a regression. However, I only noticed it
 b/c my init script had a bug which caused it not to wait around for
 the device to appear.

Hmmm so, read the bug report, digged and asked around a bit.
Here's the root problem - ubuntu's initramfs uses a tool to wait for
the root device which uses libudev to listen for the device event;
unfortunately, its rx buffer is not set large enough and the receiver
isn't fast enough, which means that netlink broadcast messages from
the kernel can overrun the buffer.  When that happens, it sets an
error on the socket, so the next recv fails with -ENOBUFS.  If that
happens, the wait for root aborts immediately and initramfs proceeds
to mount non-existent root device.

The only thing which changes by these patches is the timing of events.
The problem likely wasn't as exposed before because things were slow
enough so that either the messages could be consumed fast enough or
there's enough delay between libata module load and the root device
wait hiding the bug in the wait logic.

So, yeah, it's a full blown timing bug.  I'm not sure what we can do
to work around from kernel side except for randomly slowing things
down or forcefully enlarging rx buffer size.  There really is no
interlocking to take advantage of. :(

Thanks.

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


Re: xhci regression: usb 3.0 hdd disconnects immediately

2013-12-03 Thread Alan Stern
On Mon, 2 Dec 2013, Sarah Sharp wrote:

  Pleas check this, thi seems to be the exact same problem, but on ubuntu
  
  https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1254261
 
 There's many reasons why a USB device would not respond to device
 descriptor requests, and disconnect.  That report is not necessarily
 related.

It's worth noting that the Ubuntu problem was solved by updating the 
BIOS.  No changes to the kernel were needed.

Alan Stern

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


Re: some question about EXDEV status in period schedule

2013-12-03 Thread Alan Stern
On Tue, 3 Dec 2013, yoma sophian wrote:

  This isn't a race condition, because the driver does not terminate
  isochronous URBs before they are scheduled to end.
 
  For example, suppose there was an isochronous URB that was scheduled to
  transmit packets during microframes 100, 180, 260, and 340.  If an
  interrupt for a bulk URB happens during microframe 212, the driver will
  not terminate the isochronous URB, because it is not scheduled to end
  yet.  But if an interrupt for a bulk URB happens during microframe 347,
  then the driver will terminate the isochronous URB, because that is
  after the scheduled end (which is microframe 340).
 how about situation like below:
 HW Frame index is located at microframe 90. And there was an
 isochronous URB that was scheduled to transmit packets during
 microframes 100, 180, 260, and 340.
 
 Interrupt happen for Bulk when HW increase Frame index to 98.
 
 After driver scan asynchronous schedule,  driver finds
 ehci-isoc_count != 0 and start scan_isoc.
 Isn't it possible that Driver may drop those previous scheduled
 isochronous packets?

No, it's not possible.  The packets won't be removed from the schedule 
until after microframe 340.

Alan Stern

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


Re: [PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread Alan Stern
On Tue, 3 Dec 2013, Nicolas Ferre wrote:

 On 03/12/2013 15:07, Boris BREZILLON :
  Replace clk_get calls by devm_clk_get calls.
 
  Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
  Tested-by: Robert Nelson robertcnel...@gmail.com
 
 Acked-by: Nicolas Ferre nicolas.fe...@atmel.com
 
 Thanks Boris for these fixes.
 
 Alan, Greg, can you take the whole series as fixes for 3.13?

Signed-off-by: Alan Stern st...@rowland.harvard.edu

The patches look fine to me.  But only the 1/3 patch fixes a bug; the 
others merely change the resource management.

Alan Stern

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


Re: [PATCH v5 12/16] usb/gadget: FunctionFS: add devices management code

2013-12-03 Thread Michal Nazarewicz
On Tue, Dec 03 2013, Andrzej Pietrasiewicz wrote:
 This will be required in order to use the new function interface
 (usb_get_function_instance/usb_put_function_instance)

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyunmgin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

 ---
  drivers/usb/gadget/f_fs.c  |  238 ++-
  drivers/usb/gadget/g_ffs.c |  175 ++---
  drivers/usb/gadget/u_fs.h  |   24 
  include/linux/usb/functionfs.h |   14 ---
  4 files changed, 314 insertions(+), 137 deletions(-)

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: [PATCH v5 14/16] usb/gadget: g_ffs: convert to new interface of f_fs

2013-12-03 Thread Michal Nazarewicz
On Tue, Dec 03 2013, Andrzej Pietrasiewicz wrote:
 Prepare for configfs integration. Use the new interface so that f_fs can be
 made a module.

 Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com

Acked-by: Michal Nazarewicz min...@mina86.com

OK, now there should by my acked-by for all the patches in this series. ^_^

 ---
  drivers/usb/gadget/Kconfig |1 +
  drivers/usb/gadget/g_ffs.c |  151 +++
  2 files changed, 96 insertions(+), 56 deletions(-)

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo--


signature.asc
Description: PGP signature


Re: zte_ev not properly handling ZTE AC2726 CDMA modems

2013-12-03 Thread Dan Williams
On Mon, 2013-12-02 at 21:46 -0800, 'Greg KH' wrote:
 On Mon, Nov 25, 2013 at 07:46:40PM -0800, Dmitry Kunilov wrote:
  Hi Greg,
  
  All of them are the same model (AC2726), device ID is 19d2:fff1. Moving just
  that one line fixes my problem.
 
 Given that fixing this would be good to have, can you send a patch that
 moves the id between drivers?

IIRC the AC2726 had some kind of quirk too (sendsetup?) so we have to
make sure that's resurrected when moved back.

Dan

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


Re: [PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread Sergei Shtylyov

Hello.

On 12/03/2013 05:07 PM, Boris BREZILLON wrote:


Replace clk_get calls by devm_clk_get calls.



Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
  drivers/usb/host/ohci-at91.c |   32 
  1 file changed, 8 insertions(+), 24 deletions(-)



diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c406f1e..3652962 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -164,30 +164,30 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
goto err;
}

-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = devm_clk_get(dev, ohci_clk);
if (IS_ERR(iclk)) {
-   dev_err(pdev-dev, failed to get ohci_clk\n);
+   dev_err(dev, failed to get ohci_clk\n);


   You changed this call...


retval = PTR_ERR(iclk);
goto err;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = devm_clk_get(dev, uhpck);
if (IS_ERR(fclk)) {
dev_err(pdev-dev, failed to get uhpck\n);


   ... but not this one.


retval = PTR_ERR(fclk);
-   goto err4;
+   goto err;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = devm_clk_get(dev, hclk);
if (IS_ERR(hclk)) {
dev_err(pdev-dev, failed to get hclk\n);


   ... or this one. Actually, I think cganging these calls would be out of 
scope for this patch.



retval = PTR_ERR(hclk);
-   goto err5;
+   goto err;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = devm_clk_get(pdev-dev, usb_clk);


   Hm, why not 'dev' like in all of the above?


if (IS_ERR(uclk)) {
dev_err(pdev-dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
-   goto err6;
+   goto err;
}
}



WBR, Sergei


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


Re: [PATCH 3/3] usb: ohci-at91: use device managed clk retrieval

2013-12-03 Thread boris brezillon

Hello Sergei,

On 03/12/2013 19:01, Sergei Shtylyov wrote:

Hello.

On 12/03/2013 05:07 PM, Boris BREZILLON wrote:


Replace clk_get calls by devm_clk_get calls.



Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Tested-by: Robert Nelson robertcnel...@gmail.com
---
  drivers/usb/host/ohci-at91.c |   32 
  1 file changed, 8 insertions(+), 24 deletions(-)



diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index c406f1e..3652962 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -164,30 +164,30 @@ static int usb_hcd_at91_probe(const struct 
hc_driver *driver,

  goto err;
  }

-iclk = clk_get(pdev-dev, ohci_clk);
+iclk = devm_clk_get(dev, ohci_clk);
  if (IS_ERR(iclk)) {
-dev_err(pdev-dev, failed to get ohci_clk\n);
+dev_err(dev, failed to get ohci_clk\n);


   You changed this call...


  retval = PTR_ERR(iclk);
  goto err;
  }
-fclk = clk_get(pdev-dev, uhpck);
+fclk = devm_clk_get(dev, uhpck);
  if (IS_ERR(fclk)) {
  dev_err(pdev-dev, failed to get uhpck\n);


   ... but not this one.


This is an oversight.




  retval = PTR_ERR(fclk);
-goto err4;
+goto err;
  }
-hclk = clk_get(pdev-dev, hclk);
+hclk = devm_clk_get(dev, hclk);
  if (IS_ERR(hclk)) {
  dev_err(pdev-dev, failed to get hclk\n);


   ... or this one. Actually, I think cganging these calls would be 
out of scope for this patch.


Ditto.

I'll split the patch to in 2 patches:
 1) replace pdev-dev by dev
 2) use devm_clk_get instead of clk_get.




  retval = PTR_ERR(hclk);
-goto err5;
+goto err;
  }
  if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-uclk = clk_get(pdev-dev, usb_clk);
+uclk = devm_clk_get(pdev-dev, usb_clk);


   Hm, why not 'dev' like in all of the above?

Ditto.

Thanks for your review.

Best Regards,

Boris



  if (IS_ERR(uclk)) {
  dev_err(pdev-dev, failed to get uclk\n);
  retval = PTR_ERR(uclk);
-goto err6;
+goto err;
  }
  }



WBR, Sergei




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


[PATCH v2 1/4] usb: ohci-at91: fix irq and iomem resource retrieval

2013-12-03 Thread Boris BREZILLON
When using dt resources retrieval (interrupts and reg properties) there is
no predefined order for these resources in the platform dev resources
table.

Retrieve resources using the platform_get_resource function instead of
direct resource table entries to avoid resource type mismatch.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com 
---
 drivers/usb/host/ohci-at91.c |   19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 418444e..7aec6ca 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -136,23 +136,26 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
struct ohci_hcd *ohci;
int retval;
struct usb_hcd *hcd = NULL;
+   struct device *dev = pdev-dev;
+   struct resource *mem_r, *irq_r;
 
-   if (pdev-num_resources != 2) {
-   pr_debug(hcd probe: invalid num_resources);
+   mem_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!mem_r) {
+   dev_dbg(dev, hcd probe: missing memory resource\n);
return -ENODEV;
}
 
-   if ((pdev-resource[0].flags != IORESOURCE_MEM)
-   || (pdev-resource[1].flags != IORESOURCE_IRQ)) {
-   pr_debug(hcd probe: invalid resource type\n);
+   irq_r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+   if (!irq_r) {
+   dev_dbg(dev, hcd probe: missing irq resource\n);
return -ENODEV;
}
 
hcd = usb_create_hcd(driver, pdev-dev, at91);
if (!hcd)
return -ENOMEM;
-   hcd-rsrc_start = pdev-resource[0].start;
-   hcd-rsrc_len = resource_size(pdev-resource[0]);
+   hcd-rsrc_start = mem_r-start;
+   hcd-rsrc_len = resource_size(mem_r);
 
if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
pr_debug(request_mem_region failed\n);
@@ -199,7 +202,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
ohci-num_ports = board-ports;
at91_start_hc(pdev);
 
-   retval = usb_add_hcd(hcd, pdev-resource[1].start, IRQF_SHARED);
+   retval = usb_add_hcd(hcd, irq_r-start, IRQF_SHARED);
if (retval == 0)
return retval;
 
-- 
1.7.9.5

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


[PATCH v2 3/4] usb: ohci-at91: use dev variable instead of pdev-dev

2013-12-03 Thread Boris BREZILLON
Make use of the dev variable instead of referencing the dev field of the
pdev struct.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com 
---
 drivers/usb/host/ohci-at91.c |   18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 8528895..2a86e32 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -151,7 +151,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
return -ENODEV;
}
 
-   hcd = usb_create_hcd(driver, pdev-dev, at91);
+   hcd = usb_create_hcd(driver, dev, at91);
if (!hcd)
return -ENOMEM;
hcd-rsrc_start = mem_r-start;
@@ -164,28 +164,28 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
goto err;
}
 
-   iclk = clk_get(pdev-dev, ohci_clk);
+   iclk = clk_get(dev, ohci_clk);
if (IS_ERR(iclk)) {
-   dev_err(pdev-dev, failed to get ohci_clk\n);
+   dev_err(dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
goto err;
}
-   fclk = clk_get(pdev-dev, uhpck);
+   fclk = clk_get(dev, uhpck);
if (IS_ERR(fclk)) {
-   dev_err(pdev-dev, failed to get uhpck\n);
+   dev_err(dev, failed to get uhpck\n);
retval = PTR_ERR(fclk);
goto err4;
}
-   hclk = clk_get(pdev-dev, hclk);
+   hclk = clk_get(dev, hclk);
if (IS_ERR(hclk)) {
-   dev_err(pdev-dev, failed to get hclk\n);
+   dev_err(dev, failed to get hclk\n);
retval = PTR_ERR(hclk);
goto err5;
}
if (IS_ENABLED(CONFIG_COMMON_CLK)) {
-   uclk = clk_get(pdev-dev, usb_clk);
+   uclk = clk_get(dev, usb_clk);
if (IS_ERR(uclk)) {
-   dev_err(pdev-dev, failed to get uclk\n);
+   dev_err(dev, failed to get uclk\n);
retval = PTR_ERR(uclk);
goto err6;
}
-- 
1.7.9.5

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


Re: Xhci Host not allowed to send get device desc at addr zero

2013-12-03 Thread Sarah Sharp
On Wed, Nov 27, 2013 at 05:07:04PM +0100, Aymen BOUATTAY wrote:
 Hi Pratyush,
 
 Douglas Turner  pointed me to this thread discussion
 http://www.spinics.net/lists/linux-usb/msg95103.html
 
 seems there is some issue to use new scheme enumeration with super speed 
 devices
 
 Hi Sarah,
 Any comments will be appreciated

Dan, I'm trying to remember if we actually ran into issues with USB 3.0
devices not enumerating correctly with the new scheme, or if I was just
being cautious, since we have always enumerated USB 3.0 devices with the
old scheme.  Do you remember if you actually ran into issues with the
new scheme enumeration?

Sarah Sharp

 -Original Message-
 From: Pratyush Anand [mailto:pratyush.an...@gmail.com] 
 Sent: mardi 26 novembre 2013 14:06
 To: Aymen BOUATTAY; sarah.a.sh...@linux.intel.com
 Cc: linux-usb@vger.kernel.org
 Subject: Re: Xhci Host not allowed to send get device desc at addr zero
 
  Hi Aymen
 
 
 On Tue, Nov 26, 2013 at 4:31 PM, Aymen BOUATTAY aymen.bouat...@st.com wrote:
  Hi,
 
  I'm using Kernel release 3.4 with an embedded xhci host controller 
  Seems USB core driver does not allow xhci controller to send a get 
  device descriptor at address zero As when a device is attached to the 
  root hub, usb core driver reset the device and if the link is 
  superspeed than do a set_address
 
  LeCroy Compliance test TD7.06 Data Payload Packet Framing Robustness 
  test script expects for get device descriptor at  @ zero from host
 
  How to let xhci controller sending a get device descriptor command before 
  setting an address to  USB3 device ?
 
 It does not work because USE_NEW_SCHEME has not been enabled for super speed 
 devices.
 
 I see following comment
 
  An xHCI controller cannot send any packets to a device until a set address 
 command successfully completes.
 
 in
 
 commit c6515272b858742962c1de0f3bf497a048b9abd7
 Author: Sarah Sharp sarah.a.sh...@linux.intel.com
 Date:   Mon Apr 27 19:57:26 2009 -0700
 USB: Support for addressing a USB device under xHCI
 
 Hi Sarah,
 
 But as per usb3.0 specs section 9.4.3 get descriptor should be allowed in 
 default state.
 
 xhci specs is not very clear about it.
 
 xhci specs says
 once a successful address device command has completed, system software can 
 issue USB GET_DESCRIPTOR request through Default Control Endpoint to retrieve 
 the USB Device, configuration, etc. descriptors from USB device.
 
 So, what if XHCI Software issues, SET ADDRESS(0) followed by GET DESC(Device).
 
 Regards
 Pratyush
 
 
  Thanks,
  Aymen
  --
  To unsubscribe from this list: send the line unsubscribe linux-usb 
  in the body of a message to majord...@vger.kernel.org More majordomo 
  info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/4] usb: ohci-at91: replace request_mem_region + ioremap by devm_request_and_ioremap

2013-12-03 Thread Boris BREZILLON
Replace the request_mem_region + ioremap calls by the
devm_request_and_ioremap call which does the same things but with device
managed resources.

Signed-off-by: Boris BREZILLON b.brezil...@overkiz.com
Acked-by: Nicolas Ferre nicolas.fe...@atmel.com 
---
 drivers/usb/host/ohci-at91.c |   24 +---
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 7aec6ca..8528895 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -157,24 +157,18 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
hcd-rsrc_start = mem_r-start;
hcd-rsrc_len = resource_size(mem_r);
 
-   if (!request_mem_region(hcd-rsrc_start, hcd-rsrc_len, hcd_name)) {
-   pr_debug(request_mem_region failed\n);
-   retval = -EBUSY;
-   goto err1;
-   }
-
-   hcd-regs = ioremap(hcd-rsrc_start, hcd-rsrc_len);
+   hcd-regs = devm_request_and_ioremap(dev, mem_r);
if (!hcd-regs) {
-   pr_debug(ioremap failed\n);
+   dev_dbg(dev, devm_request_and_ioremap failed\n);
retval = -EIO;
-   goto err2;
+   goto err;
}
 
iclk = clk_get(pdev-dev, ohci_clk);
if (IS_ERR(iclk)) {
dev_err(pdev-dev, failed to get ohci_clk\n);
retval = PTR_ERR(iclk);
-   goto err3;
+   goto err;
}
fclk = clk_get(pdev-dev, uhpck);
if (IS_ERR(fclk)) {
@@ -218,13 +212,7 @@ static int usb_hcd_at91_probe(const struct hc_driver 
*driver,
  err4:
clk_put(iclk);
 
- err3:
-   iounmap(hcd-regs);
-
- err2:
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
-
- err1:
+ err:
usb_put_hcd(hcd);
return retval;
 }
@@ -247,8 +235,6 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
 {
usb_remove_hcd(hcd);
at91_stop_hc(pdev);
-   iounmap(hcd-regs);
-   release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);
 
if (IS_ENABLED(CONFIG_COMMON_CLK))
-- 
1.7.9.5

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


[PATCH v2 0/4] usb: ohci-at91: various fixes and improvements

2013-12-03 Thread Boris BREZILLON
Hello,

This patch series fixes a bug detected in 3.13-rc1 caused by a wrong
assumption on platform device resources order in the platform device
resource table.

It also move the different driver resources (clks and iomem) retrieval
to the device managed versions (devm_ functions).

Best Regards,

Boris

Changes since v1:
 - split PATCH 3 in 2 different patches: one to remove references to
   pdev-dev, the other to make use of devm_clk_get
 - replace forgotten pdev-dev references in usb_hcd_at91_probe

Boris BREZILLON (4):
  usb: ohci-at91: fix irq and iomem resource retrieval
  usb: ohci-at91: replace request_mem_region + ioremap by
devm_request_and_ioremap
  usb: ohci-at91: use dev variable instead of pdev-dev
  usb: ohci-at91: use device managed clk retrieval

 drivers/usb/host/ohci-at91.c |   83 ++
 1 file changed, 28 insertions(+), 55 deletions(-)

-- 
1.7.9.5

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


  1   2   >