Re: [PATCH v4 3/3] gpio: add support for the Diolan DLN-2 USB GPIO driver
On Thu, Sep 18, 2014 at 06:54:34PM +0300, Octavian Purdila wrote: On Thu, Sep 18, 2014 at 3:46 PM, Johan Hovold jo...@kernel.org wrote: On Thu, Sep 18, 2014 at 03:43:07PM +0300, Octavian Purdila wrote: On Thu, Sep 18, 2014 at 1:54 PM, Johan Hovold jo...@kernel.org wrote: On Tue, Sep 09, 2014 at 10:24:46PM +0300, Octavian Purdila wrote: Either way, it looks like this could race with get_direction() if you get a set_direction() while get_direction() is retrieving the direction from the device. This would break gpio_get(). I don't think gpio_set_direction() and gpio_get() are allowed to race. I wrote that set_direction() and get_direction() could race, which in turn would break gpio_get() as you would be caching the wrong direction setting. OK, I now see the problem. I think doing this in get_direction() will fix the issue: if (!test_and_set_bit(offset, dln2-pin_dir_set)) set/clear_bit(offset, dln2-pin_dir); because gpiolib calls get_direction() while requesting a pin and request cannot race with itself. Which means that get_direction() can not race with itself the first time it is called, when the set/clear operation will be run. And because we know that get_direction() is called first, we can even remove the set/clear operation from set_direction(). Why not simply fetch the direction in request() and get rid of the pin_dir_set bitmask? Johan -- 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 net] r8152: disable ALDPS
If the hw is in ALDPS mode, the hw may have no response for accessing the most registers. Therefore, the ALDPS should be disabled before accessing the hw in rtl_ops.init(), rtl_ops.disable(), rtl_ops.up(), and rtl_ops.down(). Regardless of rtl_ops.enable(), because the hw wouldn't enter ALDPS mode when linking on. The hw would enter the ALDPS mode after several seconds when link down occurs and the ALDPS is enabled. Signed-off-by: Hayes Wang hayesw...@realtek.com --- drivers/net/usb/r8152.c | 62 +++-- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 87f7104..74760e8 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c @@ -2019,7 +2019,7 @@ static int rtl8153_enable(struct r8152 *tp) return rtl_enable(tp); } -static void rtl8152_disable(struct r8152 *tp) +static void rtl_disable(struct r8152 *tp) { u32 ocp_data; int i; @@ -2232,6 +2232,13 @@ static inline void r8152b_enable_aldps(struct r8152 *tp) LINKENA | DIS_SDSAVE); } +static void rtl8152_disable(struct r8152 *tp) +{ + r8152b_disable_aldps(tp); + rtl_disable(tp); + r8152b_enable_aldps(tp); +} + static void r8152b_hw_phy_cfg(struct r8152 *tp) { u16 data; @@ -2242,11 +2249,8 @@ static void r8152b_hw_phy_cfg(struct r8152 *tp) r8152_mdio_write(tp, MII_BMCR, data); } - r8152b_disable_aldps(tp); - rtl_clear_bp(tp); - r8152b_enable_aldps(tp); set_bit(PHY_RESET, tp-flags); } @@ -2255,9 +2259,6 @@ static void r8152b_exit_oob(struct r8152 *tp) u32 ocp_data; int i; - if (test_bit(RTL8152_UNPLUG, tp-flags)) - return; - ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ocp_data = ~RCR_ACPT_ALL; ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); @@ -2347,7 +2348,7 @@ static void r8152b_enter_oob(struct r8152 *tp) ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB); ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB); - rtl8152_disable(tp); + rtl_disable(tp); for (i = 0; i 1000; i++) { ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); @@ -2485,9 +2486,6 @@ static void r8153_first_init(struct r8152 *tp) u32 ocp_data; int i; - if (test_bit(RTL8152_UNPLUG, tp-flags)) - return; - rxdy_gated_en(tp, true); r8153_teredo_off(tp); @@ -2560,7 +2558,7 @@ static void r8153_enter_oob(struct r8152 *tp) ocp_data = ~NOW_IS_OOB; ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); - rtl8152_disable(tp); + rtl_disable(tp); for (i = 0; i 1000; i++) { ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); @@ -2624,6 +2622,13 @@ static void r8153_enable_aldps(struct r8152 *tp) ocp_reg_write(tp, OCP_POWER_CFG, data); } +static void rtl8153_disable(struct r8152 *tp) +{ + r8153_disable_aldps(tp); + rtl_disable(tp); + r8153_enable_aldps(tp); +} + static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) { u16 bmcr, anar, gbcr; @@ -2714,6 +2719,16 @@ out: return ret; } +static void rtl8152_up(struct r8152 *tp) +{ + if (test_bit(RTL8152_UNPLUG, tp-flags)) + return; + + r8152b_disable_aldps(tp); + r8152b_exit_oob(tp); + r8152b_enable_aldps(tp); +} + static void rtl8152_down(struct r8152 *tp) { if (test_bit(RTL8152_UNPLUG, tp-flags)) { @@ -2727,6 +2742,16 @@ static void rtl8152_down(struct r8152 *tp) r8152b_enable_aldps(tp); } +static void rtl8153_up(struct r8152 *tp) +{ + if (test_bit(RTL8152_UNPLUG, tp-flags)) + return; + + r8153_disable_aldps(tp); + r8153_first_init(tp); + r8153_enable_aldps(tp); +} + static void rtl8153_down(struct r8152 *tp) { if (test_bit(RTL8152_UNPLUG, tp-flags)) { @@ -2946,6 +2971,8 @@ static void r8152b_init(struct r8152 *tp) if (test_bit(RTL8152_UNPLUG, tp-flags)) return; + r8152b_disable_aldps(tp); + if (tp-version == RTL_VER_01) { ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); ocp_data = ~LED_MODE_MASK; @@ -2984,6 +3011,7 @@ static void r8153_init(struct r8152 *tp) if (test_bit(RTL8152_UNPLUG, tp-flags)) return; + r8153_disable_aldps(tp); r8153_u1u2en(tp, false); for (i = 0; i 500; i++) { @@ -3392,7 +3420,7 @@ static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id) ops-init = r8152b_init; ops-enable = rtl8152_enable; ops-disable= rtl8152_disable; -
[PATCH] phy: exynos5-drd: Fix PCS_TXDEEMPH mask
According to user manual, pcs_tx_deemph_3p5db field in PHYPARAM1 register is 6bits wide, so mask value should be 0x3f instead of 0x1f. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com --- drivers/phy/phy-exynos5-usbdrd.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5- usbdrd.c index 392101c..f421d16 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -99,7 +99,7 @@ #define EXYNOS5_DRD_PHYPARAM1 0x20 -#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x1f 0) +#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x3f 0) #define PHYPARAM1_PCS_TXDEEMPH (0x1c) #define EXYNOS5_DRD_PHYTERM0x24 -- 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] phy: exynos5-drd: Fix PCS_TXDEEMPH mask
On Friday, September 19, 2014 4:36 PM, Anton Tikhomirov wrote: According to user manual, pcs_tx_deemph_3p5db field in PHYPARAM1 register is 6bits wide, so mask value should be 0x3f instead of 0x1f. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com Reviewed-by: Jingoo Han jg1@samsung.com Best regards, Jingoo Han --- drivers/phy/phy-exynos5-usbdrd.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5- usbdrd.c index 392101c..f421d16 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -99,7 +99,7 @@ #define EXYNOS5_DRD_PHYPARAM10x20 -#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x1f 0) +#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x3f 0) #define PHYPARAM1_PCS_TXDEEMPH (0x1c) #define EXYNOS5_DRD_PHYTERM 0x24 -- 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] phy: exynos5-drd: Fix PCS_TXDEEMPH mask
Hi Anton, On Fri, Sep 19, 2014 at 1:05 PM, Anton Tikhomirov av.tikhomi...@samsung.com wrote: According to user manual, pcs_tx_deemph_3p5db field in PHYPARAM1 register is 6bits wide, so mask value should be 0x3f instead of 0x1f. Signed-off-by: Anton Tikhomirov av.tikhomi...@samsung.com --- drivers/phy/phy-exynos5-usbdrd.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos5-usbdrd.c b/drivers/phy/phy-exynos5- usbdrd.c index 392101c..f421d16 100644 --- a/drivers/phy/phy-exynos5-usbdrd.c +++ b/drivers/phy/phy-exynos5-usbdrd.c @@ -99,7 +99,7 @@ #define EXYNOS5_DRD_PHYPARAM1 0x20 -#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x1f 0) +#define PHYPARAM1_PCS_TXDEEMPH_MASK(0x3f 0) use a _3P5DB suffix for the macro name ? may sound similar to how UM says. anyways verified from Exynos5420 user manual. with that change, Reviewed-by: Vivek Gautam gautam.vi...@samsung.com [snip] -- Best Regards Vivek Gautam Samsung RD Institute, Bangalore India -- 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: OMAP3/AM3517 EHCI USB Issue
Hi Michael, On 08/04/2014 06:27 PM, Michael Welling wrote: On Mon, Aug 04, 2014 at 12:34:16PM +0300, Roger Quadros wrote: On 08/02/2014 02:51 AM, Michael Welling wrote: On Fri, Aug 1, 2014 at 6:04 PM, Michael Welling mwell...@emacinc.com wrote: On Wed, Jul 30, 2014 at 12:03:22PM +0300, Roger Quadros wrote: On 07/29/2014 06:20 PM, Michael Welling wrote: On Tue, Jul 29, 2014 at 11:59:07AM +0300, Roger Quadros wrote: Hi Michael, On 07/28/2014 09:10 PM, Felipe Balbi wrote: On Mon, Jul 28, 2014 at 12:57:39PM -0500, Michael Welling wrote: On Mon, Jul 28, 2014 at 10:57:18AM -0500, Felipe Balbi wrote: Hi, On Mon, Jul 28, 2014 at 10:29:49AM -0500, Michael Welling wrote: On Mon, Jul 28, 2014 at 11:02:47AM -0400, Alan Stern wrote: On Fri, 25 Jul 2014, Michael Welling wrote: The plot thickens So if I run the above command before anything is plugged into the ports the HUB disconnects. root@som3517:~# echo on /sys/bus/usb/devices/1-1/power/control [ 63.068839] usb 1-1: USB disconnect, device number 2 Here is the output of the usbmon output when running the above command: root@som3517:/sys/kernel/debug/usb/usbmon# cat 1t de382e40 376573 S Ci:001:00 s a3 00 0001 0004 4 de382e40 3788890604 C Ci:001:00 0 4 = 0705 de382e40 3788892965 S Ci:001:00 s a3 00 0002 0004 4 de382e40 3788893093 C Ci:001:00 0 4 = 0001 de382e40 3788894834 S Ci:001:00 s a3 00 0003 0004 4 de382e40 3788894958 C Ci:001:00 0 4 = 0001 de7d92c0 3788896519 S Ii:001:01 -115 4 de382e40 3788898778 S Ci:001:00 s a3 00 0001 0004 4 de382e40 3788900188 C Ci:001:00 0 4 = 0705 de382e40 3788902705 S Co:001:00 s 23 01 0002 0001 0 de382e40 3788905793 C Co:001:00 0 0 de382e40 3788940998 S Ci:001:00 s a3 00 0001 0004 4 de7d92c0 3788942065 C Ii:001:01 0 1 = 02 de7d92c0 3788943013 S Ii:001:01 -115 4 de382e40 3788943145 C Ci:001:00 0 4 = 03050400 de382e40 3788961031 S Co:001:00 s 23 01 0012 0001 0 de382e40 3788961175 C Co:001:00 0 0 de382e40 3788961304 S Ci:002:00 s 80 00 0002 2 de382e40 3788965395 C Ci:002:00 -71 0 de249040 3788966954 S Co:001:00 s 23 03 0004 0001 0 de249040 3788968362 C Co:001:00 0 0 de249040 3789021103 S Ci:001:00 s a3 00 0001 0004 4 de7d92c0 3789022194 C Ii:001:01 0 1 = 02 de7d92c0 378906 S Ii:001:01 -115 4 de249040 3789023423 C Ci:001:00 0 4 = 01051200 de249040 3789025010 S Co:001:00 s 23 03 0004 0001 0 de249040 3789026815 C Co:001:00 0 0 de249040 3789230980 S Ci:001:00 s a3 00 0001 0004 4 de249040 378923 C Ci:001:00 0 4 = 00010300 de249040 3789232280 S Co:001:00 s 23 01 0014 0001 0 de249040 3789232404 C Co:001:00 0 0 de249040 3789233056 S Co:001:00 s 23 01 0001 0001 0 de249040 3789235345 C Co:001:00 0 0 de249040 3789236820 S Co:001:00 s 23 01 0001 0001 0 de249040 3789237201 C Co:001:00 0 0 de249040 3789238180 S Co:001:00 s 23 01 0001 0001 0 de249040 3789238510 C Co:001:00 0 0 de249040 3789240602 S Ci:001:00 s a3 00 0001 0004 4 de249040 3789241661 C Ci:001:00 0 4 = 00010300 de249040 3789242264 S Co:001:00 s 23 01 0010 0001 0 de249040 3789243921 C Co:001:00 0 0 de249040 3789246540 S Co:001:00 s 23 01 0011 0001 0 de249040 3789246930 C Co:001:00 0 0 de2490c0 3789283096 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789286255 C Ci:001:00 0 4 = 0001 de2490c0 3789330975 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789332606 C Ci:001:00 0 4 = 0001 de2490c0 3789371015 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789371146 C Ci:001:00 0 4 = 0001 de2490c0 3789410975 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789411097 C Ci:001:00 0 4 = 0001 de2490c0 3789450972 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789451081 C Ci:001:00 0 4 = 0001 de7d92c0 3789452462 C Ii:001:01 -2 0 Not sure what any of it means. Basically it means what you said above: the hub disconnected. I can't tell why. You'll have to ask someone who's familiar with the hardware on that board. Sadly, there is no one more familar with this specific hardware than myself. I can however ellaborate the hardware setup of the USB subsystem in case there is someone out there that has used a similar setup. The board uses the AM3517 SoC from TI. The SoC's USB host port (HSUSB1) is connected to a USB3320 PHY. The PHY is connected to a USB2512 switch to provide two downstream USB ports. The very same hardware worked with the 2.6.37 kernel that I am trying to move away from. It should be noted that the USB hardware work on the 3.2 kernel as well. Today I am going to try using 3.10 and 3.14 kernels see if they exhibit the same behavior. It should be noted that the 3.10 kernel did not even detect the external HUB and the 3.14 kernel exhibits the same failure as 3.16. Do you have off-while-idle enabled ? This could be, as Alan suggested, a problem with remote wakeup. EHCI on TI parts is kinda awkward, if
Re: OMAP3/AM3517 EHCI USB Issue
Hi Roger On Fri, Sep 19, 2014 at 11:22 AM, Roger Quadros rog...@ti.com wrote: Hi Michael, On 08/04/2014 06:27 PM, Michael Welling wrote: On Mon, Aug 04, 2014 at 12:34:16PM +0300, Roger Quadros wrote: On 08/02/2014 02:51 AM, Michael Welling wrote: On Fri, Aug 1, 2014 at 6:04 PM, Michael Welling mwell...@emacinc.com wrote: On Wed, Jul 30, 2014 at 12:03:22PM +0300, Roger Quadros wrote: On 07/29/2014 06:20 PM, Michael Welling wrote: On Tue, Jul 29, 2014 at 11:59:07AM +0300, Roger Quadros wrote: Hi Michael, On 07/28/2014 09:10 PM, Felipe Balbi wrote: On Mon, Jul 28, 2014 at 12:57:39PM -0500, Michael Welling wrote: On Mon, Jul 28, 2014 at 10:57:18AM -0500, Felipe Balbi wrote: Hi, On Mon, Jul 28, 2014 at 10:29:49AM -0500, Michael Welling wrote: On Mon, Jul 28, 2014 at 11:02:47AM -0400, Alan Stern wrote: On Fri, 25 Jul 2014, Michael Welling wrote: The plot thickens So if I run the above command before anything is plugged into the ports the HUB disconnects. root@som3517:~# echo on /sys/bus/usb/devices/1-1/power/control [ 63.068839] usb 1-1: USB disconnect, device number 2 Here is the output of the usbmon output when running the above command: root@som3517:/sys/kernel/debug/usb/usbmon# cat 1t de382e40 376573 S Ci:001:00 s a3 00 0001 0004 4 de382e40 3788890604 C Ci:001:00 0 4 = 0705 de382e40 3788892965 S Ci:001:00 s a3 00 0002 0004 4 de382e40 3788893093 C Ci:001:00 0 4 = 0001 de382e40 3788894834 S Ci:001:00 s a3 00 0003 0004 4 de382e40 3788894958 C Ci:001:00 0 4 = 0001 de7d92c0 3788896519 S Ii:001:01 -115 4 de382e40 3788898778 S Ci:001:00 s a3 00 0001 0004 4 de382e40 3788900188 C Ci:001:00 0 4 = 0705 de382e40 3788902705 S Co:001:00 s 23 01 0002 0001 0 de382e40 3788905793 C Co:001:00 0 0 de382e40 3788940998 S Ci:001:00 s a3 00 0001 0004 4 de7d92c0 3788942065 C Ii:001:01 0 1 = 02 de7d92c0 3788943013 S Ii:001:01 -115 4 de382e40 3788943145 C Ci:001:00 0 4 = 03050400 de382e40 3788961031 S Co:001:00 s 23 01 0012 0001 0 de382e40 3788961175 C Co:001:00 0 0 de382e40 3788961304 S Ci:002:00 s 80 00 0002 2 de382e40 3788965395 C Ci:002:00 -71 0 de249040 3788966954 S Co:001:00 s 23 03 0004 0001 0 de249040 3788968362 C Co:001:00 0 0 de249040 3789021103 S Ci:001:00 s a3 00 0001 0004 4 de7d92c0 3789022194 C Ii:001:01 0 1 = 02 de7d92c0 378906 S Ii:001:01 -115 4 de249040 3789023423 C Ci:001:00 0 4 = 01051200 de249040 3789025010 S Co:001:00 s 23 03 0004 0001 0 de249040 3789026815 C Co:001:00 0 0 de249040 3789230980 S Ci:001:00 s a3 00 0001 0004 4 de249040 378923 C Ci:001:00 0 4 = 00010300 de249040 3789232280 S Co:001:00 s 23 01 0014 0001 0 de249040 3789232404 C Co:001:00 0 0 de249040 3789233056 S Co:001:00 s 23 01 0001 0001 0 de249040 3789235345 C Co:001:00 0 0 de249040 3789236820 S Co:001:00 s 23 01 0001 0001 0 de249040 3789237201 C Co:001:00 0 0 de249040 3789238180 S Co:001:00 s 23 01 0001 0001 0 de249040 3789238510 C Co:001:00 0 0 de249040 3789240602 S Ci:001:00 s a3 00 0001 0004 4 de249040 3789241661 C Ci:001:00 0 4 = 00010300 de249040 3789242264 S Co:001:00 s 23 01 0010 0001 0 de249040 3789243921 C Co:001:00 0 0 de249040 3789246540 S Co:001:00 s 23 01 0011 0001 0 de249040 3789246930 C Co:001:00 0 0 de2490c0 3789283096 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789286255 C Ci:001:00 0 4 = 0001 de2490c0 3789330975 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789332606 C Ci:001:00 0 4 = 0001 de2490c0 3789371015 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789371146 C Ci:001:00 0 4 = 0001 de2490c0 3789410975 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789411097 C Ci:001:00 0 4 = 0001 de2490c0 3789450972 S Ci:001:00 s a3 00 0001 0004 4 de2490c0 3789451081 C Ci:001:00 0 4 = 0001 de7d92c0 3789452462 C Ii:001:01 -2 0 Not sure what any of it means. Basically it means what you said above: the hub disconnected. I can't tell why. You'll have to ask someone who's familiar with the hardware on that board. Sadly, there is no one more familar with this specific hardware than myself. I can however ellaborate the hardware setup of the USB subsystem in case there is someone out there that has used a similar setup. The board uses the AM3517 SoC from TI. The SoC's USB host port (HSUSB1) is connected to a USB3320 PHY. The PHY is connected to a USB2512 switch to provide two downstream USB ports. The very same hardware worked with the 2.6.37 kernel that I am trying to move away from. It should be noted that the USB hardware work on the 3.2 kernel as well. Today I am going to try using 3.10 and 3.14 kernels see if they exhibit the same behavior. It should be noted that the 3.10 kernel did not even detect the external HUB and the 3.14 kernel exhibits the same failure as 3.16. Do you have off-while-idle enabled ? This could be, as Alan
Your E-MAIL ADDRESS WON £1,000,000.00GBP IN 2014 CNN AWARD PROMOTION. For claims process, send (Full Name,Mobile Number) to Email: cnn.depp...@outlook.com
-- 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: OMAP3/AM3517 EHCI USB Issue
On 09/19/2014 12:37 PM, Michael Trimarchi wrote: Hi Roger On Fri, Sep 19, 2014 at 11:22 AM, Roger Quadros rog...@ti.com wrote: Hi Michael, snip It should be noted that the external HUB must be prevented from autosuspend otherwise the resume fails. OK. I was able to reproduce the issue on my beagleboard as well. The key to reproduce the issue is to use a device which has autosuspend working. Earlier I was using a mass storage device so couldn't reproduce the issue. On using a HUB I could see the issue. Debugging this issue is on my action list. I will keep an eye out for the fix if it is possible. The implementation of the remote resume workaround as listed in the sprz306d.pdf seems to hack into the core EHCI drivers and limits you to a single USB host. Please see Advisory 1.1.33 HSUSB Interoperability Issue with SMSC USB3320 PHY (sprz306d errata doc). It seems ULPI suspend/resume is broken and there is no workaround. So you have to prevent the USB device connected at root port from suspending. It's very important to understand if this affect even OMAP4 and tusb1210 that is suggested by TI. This particular issue was fixed in omap3630 ES1.1 onwards. But that doesn't mean OMAP4 is free of issues around USB EHCI. 4430 brought it's own set of issues which were fixed in 4460. But there were still some issues requiring software workaround especially around USB suspend/resume. e.g. There is still an issue with both 4430 and 4460 called i701 (USB Host - Possible Interoperability With External PHY At Resume Time) which is observed on certain PHYs (at least not on usb3320). There is a software workaround for that. 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
[PATCH 1/1] cp210x: Add support for Seluxit USB Dongle
We have a USB dongle with the cp210x chip on. And we have put our own USB id into it. Signed-off-by: Andreas Bomholtz andr...@seluxit.com --- diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index e4bb622..abd7577 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ + { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */ { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */ { USB_DEVICE(0x1FB9, 0x0100) }, /* Lake Shore Model 121 Current Source */ --- git stable tag v3.9.9 -- 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] cp210x: Add support for Seluxit USB Dongle
On Fri, Sep 19, 2014 at 01:23:03PM +0200, Andreas Bomholtz wrote: We have a USB dongle with the cp210x chip on. And we have put our own USB id into it. Signed-off-by: Andreas Bomholtz andr...@seluxit.com Thanks for the patch. There are just two minor issues. Your patch appear to have been line wrapped by your mailer (check out git send-email), and also you should use tabs for indentation. --- diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index e4bb622..abd7577 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = { { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ + { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */ { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */ { USB_DEVICE(0x1FB9, 0x0100) }, /* Lake Shore Model 121 Current Source */ You can run your patch through scripts/checkpatch.pl before submitting to catch some issues. Here it now says: ERROR: patch seems to be corrupt (line wrapped?) #18: FILE: drivers/usb/serial/cp210x.c:155: */ WARNING: please, no spaces at the start of a line #21: FILE: drivers/usb/serial/cp210x.c:158: + { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */$ total: 1 errors, 1 warnings, 8 lines checked --- git stable tag v3.9.9 Also try to base your patch on a more recent kernel (e.g. 3.16.3). Care to fix this up and resubmit? Johan -- 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: [PATCHv4 08/12] usb: dwc2: gadget: Do not fail probe if there isn't a clock node
On 9/12/14, 11:28 AM, Bartlomiej Zolnierkiewicz wrote: [ added linux-kernel ML to cc: ] Hi, On Tuesday, August 26, 2014 11:19:59 AM dingu...@opensource.altera.com wrote: From: Dinh Nguyen dingu...@opensource.altera.com Since the dwc2 hcd driver is currently not looking for a clock node during init, we should not completely fail if there isn't a clock provided. Add a check for a valid clock before calling clock functions. This doesn't look correct at least for the case when we are really missing the clock and USB_DWC2_PERIPHERAL=y (moreover it just looks wrong to access gadget functionalities when clock is disabled). It seems that it would be better to just disable gadget functionality on dwc2_gadget_init() failure in hcd and not call gadget functions later from hcd if gadget functionality is disabled. Yes...this is correct. Will fix up in v5. Thanks, Dinh -- 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: [PATCHv4 01/12] usb: dwc2: Update Kconfig to support dual-role
Hi, On Thursday, September 18, 2014 10:54:24 AM Dinh Nguyen wrote: Hi Bartlomiej, On 09/12/2014 10:49 AM, Bartlomiej Zolnierkiewicz wrote: [ added linux-kernel ML to cc: ] Hi, On Tuesday, August 26, 2014 11:19:52 AM dingu...@opensource.altera.com wrote: From: Dinh Nguyen dingu...@opensource.altera.com Update DWC2 kconfig and makefile to support dual-role mode. The platform file will always get compiled for the case where the controller is directly connected to the CPU. So for loadable modules, only dwc2.ko is needed. Kconfig and Makefile changes should be done after (or at the same time as) driver code itself is modified to support dual-role mode. Each individual patch of the patchset should be correct itself (not cause any breakages) in order to keep the whole patchset bisectable. Paulz mentioned this in v1 of this patch series and ever since then, I have been careful to test each patch on it's own, and each version since then has passed 0-Day kbuild testing. But I may have missed something in v4. Will try to move the edits to Kconfig/Makefile to end for v5. Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com Acked-by: Paul Zimmerman pa...@synopsys.com --- v3: Add USB_GADGET=y and USB_GADGET=USB_DWC2 for peripheral and dual-role config options. v2: Remove reference to dwc2_gadget --- drivers/usb/dwc2/Kconfig | 63 +++ drivers/usb/dwc2/Makefile | 21 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/drivers/usb/dwc2/Kconfig b/drivers/usb/dwc2/Kconfig index f93807b..4396a1f 100644 --- a/drivers/usb/dwc2/Kconfig +++ b/drivers/usb/dwc2/Kconfig @@ -1,40 +1,29 @@ config USB_DWC2 - bool DesignWare USB2 DRD Core Support + tristate DesignWare USB2 DRD Core Support depends on USB help Say Y here if your system has a Dual Role Hi-Speed USB controller based on the DesignWare HSOTG IP Core. -For host mode, if you choose to build the driver as dynamically -linked modules, the core module will be called dwc2.ko, the PCI -bus interface module (if you have a PCI bus system) will be -called dwc2_pci.ko, and the platform interface module (for -controllers directly connected to the CPU) will be called -dwc2_platform.ko. For gadget mode, there will be a single -module called dwc2_gadget.ko. - -NOTE: The s3c-hsotg driver is now renamed to dwc2_gadget. The -host and gadget drivers are still currently separate drivers. -There are plans to merge the dwc2_gadget driver with the dwc2 -host driver in the near future to create a dual-role driver. +If you choose to build the driver as dynamically +linked modules, a single dwc2.ko(regardless of mode of operation) minort nitpick: is missing after dwc2.ko +will get built for both platform IPs and PCI. Why do you want ot merge both platform and PCI drivers into one? To do it properly you need to modify module_init/exit() of the final module to properly handle both PCI and platform devices. It should be easier to leave separate dwc2_pci/platform drivers and just put the common code into dwc2.ko. I need to rework to the comment. I think it should say, will get built for either platform IPs or PCI. I am not merging both platform and PCI drivers into one. OK, it is good to hear that. Unfortunately after second look there are even more problems with Kconfig changes, please see below. if USB_DWC2 +choice + bool DWC2 Mode Selection + default USB_DWC2_DUAL_ROLE if (USB USB_GADGET) + default USB_DWC2_HOST if (USB !USB_GADGET) + default USB_DWC2_PERIPHERAL if (!USB USB_GADGET) Previously it was possible to have following functionalities in one kernel (for multiplatform kernels): - host PCI support - host platform support - gadget platform support Now mode selection will determine the used mode for combined host+gadget platform driver. It is no longer possible to have host platform and gadget platform support in one kernel. Also there is only one mode selection for both PCI and platform drivers so it is no longer possible to have both gadget platform support and host PCI support in one kernel. I think it would be the best to replace global mode selection choice option with just two independent suboptions for combined host+gadget platform driver which will enable host and gadget support to be compiled into the driver (you would need to enable both for dual role support). The actual selection of the mode used should be done at runtime using device tree. [ Host PCI support can be left as independent host only driver for now until it also gets proper gadget support (according to comments from Paul). ] + config USB_DWC2_HOST - tristate Host only mode + bool Host only mode depends on USB help The Designware
Re: [PATCH] Revert usb: gadget: composite: dequeue cdev-req before free it in composite_dev_cleanup
On Thu, Sep 18, 2014 at 09:31:32AM -0500, Felipe Balbi wrote: This reverts commit f2267089ea17fa97b796b1b4247e3f8957655df3. That commit causes more problem than fixes. Firstly, kfree() should be called after usb_ep_dequeue() and secondly, the way things are, we will try to dequeue a request that has already completed much more frequently than one which is pending. Cc: Li Jun b47...@freescale.com Signed-off-by: Felipe Balbi ba...@ti.com --- Greg, can you still apply this for v3.17 final ? Please take it as a patch directly so we avoid a pull request for a single patch. If you prefer a pull, let me know. Li Jun, a proper change to guarantee there will be no pending requests when we unload a composite gadget driver needs to be more involved. I'll send patches (which I plan on adding to v3.19 only) shortly. Please give me your Tested-by once I send such patches. okay, wait your patches. Li Jun drivers/usb/gadget/composite.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 6935a82..f801519 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1956,7 +1956,6 @@ void composite_dev_cleanup(struct usb_composite_dev *cdev) } if (cdev-req) { kfree(cdev-req-buf); - usb_ep_dequeue(cdev-gadget-ep0, cdev-req); usb_ep_free_request(cdev-gadget-ep0, cdev-req); } cdev-next_string_id = 0; -- 2.1.0.243.g30d45f7 -- 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 v3 2/6] usb: hub: rename hub_events() to hub_event() and handle only one event there
We would like to convert khubd kthread to a workqueue. As a result hub_events() will handle only one event per call. In fact, we could do this already now because there is another cycle in hub_thread(). It calls hub_events() until hub_event_list is empty. This patch renames the function to hub_event(), removes the while cycle, and renames the goto targets from loop* to out*. When touching the code, it fixes also formatting of dev_err() and dev_dbg() calls to make checkpatch.pl happy :-) Signed-off-by: Petr Mladek pmla...@suse.cz --- drivers/usb/core/hub.c | 236 +++-- 1 file changed, 111 insertions(+), 125 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8f35e5158daf..f1efd5a493ba 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -4994,8 +4994,7 @@ static void port_event(struct usb_hub *hub, int port1) hub_port_connect_change(hub, port1, portstatus, portchange); } - -static void hub_events(void) +static void hub_event(void) { struct list_head *tmp; struct usb_device *hdev; @@ -5006,144 +5005,131 @@ static void hub_events(void) u16 hubchange; int i, ret; - /* -* We restart the list every time to avoid a deadlock with -* deleting hubs downstream from this one. This should be -* safe since we delete the hub from the event list. -* Not the most efficient, but avoids deadlocks. -*/ - while (1) { + /* Grab the first entry at the beginning of the list */ + spin_lock_irq(hub_event_lock); + if (list_empty(hub_event_list)) { + spin_unlock_irq(hub_event_lock); + return; + } - /* Grab the first entry at the beginning of the list */ - spin_lock_irq(hub_event_lock); - if (list_empty(hub_event_list)) { - spin_unlock_irq(hub_event_lock); - break; - } + tmp = hub_event_list.next; + list_del_init(tmp); - tmp = hub_event_list.next; - list_del_init(tmp); + hub = list_entry(tmp, struct usb_hub, event_list); + kref_get(hub-kref); + spin_unlock_irq(hub_event_lock); - hub = list_entry(tmp, struct usb_hub, event_list); - kref_get(hub-kref); - spin_unlock_irq(hub_event_lock); + hdev = hub-hdev; + hub_dev = hub-intfdev; + intf = to_usb_interface(hub_dev); + dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n, + hdev-state, hdev-maxchild, + /* NOTE: expects max 15 ports... */ + (u16) hub-change_bits[0], + (u16) hub-event_bits[0]); + + /* Lock the device, then check to see if we were +* disconnected while waiting for the lock to succeed. */ + usb_lock_device(hdev); + if (unlikely(hub-disconnected)) + goto out_disconnected; + + /* If the hub has died, clean up after it */ + if (hdev-state == USB_STATE_NOTATTACHED) { + hub-error = -ENODEV; + hub_quiesce(hub, HUB_DISCONNECT); + goto out; + } + + /* Autoresume */ + ret = usb_autopm_get_interface(intf); + if (ret) { + dev_dbg(hub_dev, Can't autoresume: %d\n, ret); + goto out; + } - hdev = hub-hdev; - hub_dev = hub-intfdev; - intf = to_usb_interface(hub_dev); - dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n, - hdev-state, hdev-maxchild, - /* NOTE: expects max 15 ports... */ - (u16) hub-change_bits[0], - (u16) hub-event_bits[0]); - - /* Lock the device, then check to see if we were -* disconnected while waiting for the lock to succeed. */ - usb_lock_device(hdev); - if (unlikely(hub-disconnected)) - goto loop_disconnected; - - /* If the hub has died, clean up after it */ - if (hdev-state == USB_STATE_NOTATTACHED) { - hub-error = -ENODEV; - hub_quiesce(hub, HUB_DISCONNECT); - goto loop; - } + /* If this is an inactive hub, do nothing */ + if (hub-quiescing) + goto out_autopm; + + if (hub-error) { + dev_dbg(hub_dev, resetting for error %d\n, hub-error); - /* Autoresume */ - ret = usb_autopm_get_interface(intf); + ret = usb_reset_device(hdev); if (ret) { - dev_dbg(hub_dev, Can't autoresume: %d\n, ret); - goto loop; + dev_dbg(hub_dev, error
[PATCH v3 1/6] usb: hub: keep hub-dev reference all the time when struct usb_hub lives
This is just a small optimization of the fix from the commit c605f3cdff53a743f6 (usb: hub: take hub-hdev reference when processing from eventlist). We do not need to take the reference for each event. Instead we could get it when struct usb_hub is allocated and put it when it is released. By other words, we could handle it the same way as the reference for hub-intfdev. The motivation is that it will make the life easier when switching from khubd kthread to a workqueue. Suggested-by: Alan Stern st...@rowland.harvard.edu Signed-off-by: Petr Mladek pmla...@suse.cz --- drivers/usb/core/hub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index d481c99a20d7..8f35e5158daf 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1634,6 +1634,7 @@ static void hub_release(struct kref *kref) { struct usb_hub *hub = container_of(kref, struct usb_hub, kref); + usb_put_dev(hub-hdev); usb_put_intf(to_usb_interface(hub-intfdev)); kfree(hub); } @@ -1799,6 +1800,7 @@ descriptor_error: INIT_DELAYED_WORK(hub-leds, led_work); INIT_DELAYED_WORK(hub-init_work, NULL); usb_get_intf(intf); + usb_get_dev(hdev); usb_set_intfdata (intf, hub); intf-needs_remote_wakeup = 1; @@ -5024,10 +5026,9 @@ static void hub_events(void) hub = list_entry(tmp, struct usb_hub, event_list); kref_get(hub-kref); - hdev = hub-hdev; - usb_get_dev(hdev); spin_unlock_irq(hub_event_lock); + hdev = hub-hdev; hub_dev = hub-intfdev; intf = to_usb_interface(hub_dev); dev_dbg(hub_dev, state %d ports %d chg %04x evt %04x\n, @@ -5140,7 +5141,6 @@ static void hub_events(void) usb_autopm_put_interface(intf); loop_disconnected: usb_unlock_device(hdev); - usb_put_dev(hdev); kref_put(hub-kref, hub_release); } /* end while (1) */ -- 1.8.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 v3 6/6] usb: hub: allow to process more usb hub events in parallel
It seems that only choose_devnum() was not ready to process more hub events at the same time. All should be fine if we take bus-usb_address0_mutex there. It will make sure that more devnums will not be chosen for the given bus and the related devices at the same time. Signed-off-by: Petr Mladek pmla...@suse.cz --- drivers/usb/core/hub.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 6c1a79a50576..69f9f1c1d9c1 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2042,7 +2042,8 @@ static void choose_devnum(struct usb_device *udev) int devnum; struct usb_bus *bus = udev-bus; - /* If hub_wq ever becomes multithreaded, this will need a lock */ + /* be safe when more hub events are proceed in parallel */ + mutex_lock(bus-usb_address0_mutex); if (udev-wusb) { devnum = udev-portnum + 1; BUG_ON(test_bit(devnum, bus-devmap.devicemap)); @@ -2060,6 +2061,7 @@ static void choose_devnum(struct usb_device *udev) set_bit(devnum, bus-devmap.devicemap); udev-devnum = devnum; } + mutex_unlock(bus-usb_address0_mutex); } static void release_devnum(struct usb_device *udev) @@ -5162,11 +5164,8 @@ int usb_hub_init(void) * USB-PERSIST port handover. Otherwise it might see that a full-speed * device was gone before the EHCI controller had handed its port * over to the companion full-speed controller. -* -* Also we use ordered workqueue because the code is not ready -* for parallel execution of hub events, see choose_devnum(). */ - hub_wq = alloc_ordered_workqueue(usb_hub_wq, WQ_FREEZABLE); + hub_wq = alloc_workqueue(usb_hub_wq, WQ_FREEZABLE, 0); if (hub_wq) return 0; -- 1.8.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 v3 5/6] usb: hub: rename khubd to hub_wq in documentation and comments
USB hub has started to use a workqueue instead of kthread. Let's update the documentation and comments here and there. This patch mostly just replaces khubd with hub_wq. There are only few exceptions where the whole sentence was updated. These more complicated changes can be found in the following files: Documentation/usb/hotplug.txt drivers/net/usb/usbnet.c drivers/usb/core/hcd.c drivers/usb/host/ohci-hcd.c drivers/usb/host/xhci.c Signed-off-by: Petr Mladek pmla...@suse.cz --- Documentation/DocBook/usb.tmpl | 2 +- Documentation/usb/WUSB-Design-overview.txt | 6 ++-- Documentation/usb/hotplug.txt | 2 +- drivers/net/usb/usbnet.c | 14 ++ drivers/usb/README | 2 +- drivers/usb/core/hcd.c | 10 +++ drivers/usb/core/hub.c | 44 +++--- drivers/usb/host/ehci-fsl.c| 2 +- drivers/usb/host/ehci-hcd.c| 2 +- drivers/usb/host/ehci-hub.c| 8 +++--- drivers/usb/host/fhci-hcd.c| 6 ++-- drivers/usb/host/fotg210-hcd.c | 8 +++--- drivers/usb/host/fusbh200-hcd.c| 8 +++--- drivers/usb/host/isp1760-hcd.c | 6 ++-- drivers/usb/host/ohci-hcd.c| 6 ++-- drivers/usb/host/ohci-hub.c| 4 +-- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/host/oxu210hp-hcd.c| 10 +++ drivers/usb/host/sl811-hcd.c | 8 +++--- drivers/usb/host/xhci-hub.c| 2 +- drivers/usb/host/xhci.c| 4 +-- drivers/usb/misc/usbtest.c | 2 +- drivers/usb/musb/am35x.c | 1 + drivers/usb/musb/tusb6010.c| 2 +- drivers/usb/phy/phy-fsl-usb.c | 2 +- drivers/usb/phy/phy-isp1301-omap.c | 2 +- drivers/usb/wusbcore/devconnect.c | 6 ++-- drivers/usb/wusbcore/wa-hc.h | 2 +- sound/usb/midi.c | 2 +- 29 files changed, 89 insertions(+), 86 deletions(-) diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl index 85fc0e28576f..4cd5b2cd0f3d 100644 --- a/Documentation/DocBook/usb.tmpl +++ b/Documentation/DocBook/usb.tmpl @@ -593,7 +593,7 @@ for (;;) { Each device has one control endpoint (endpoint zero) which supports a limited RPC style RPC access. Devices are configured - by khubd (in the kernel) setting a device-wide + by hub_wq (in the kernel) setting a device-wide emphasisconfiguration/emphasis that affects things like power consumption and basic functionality. The endpoints are part of USB emphasisinterfaces/emphasis, diff --git a/Documentation/usb/WUSB-Design-overview.txt b/Documentation/usb/WUSB-Design-overview.txt index 1cd07c017cf6..9d08f179a7ca 100644 --- a/Documentation/usb/WUSB-Design-overview.txt +++ b/Documentation/usb/WUSB-Design-overview.txt @@ -317,7 +317,7 @@ HC picks the /DN_Connect/ out (nep module sends to notif.c for delivery into /devconnect/). This process starts the authentication process for the device. First we allocate a /fake port/ and assign an unauthenticated address (128 to 255--what we really do is -0x80 | fake_port_idx). We fiddle with the fake port status and /khubd/ +0x80 | fake_port_idx). We fiddle with the fake port status and /hub_wq/ sees a new connection, so he moves on to enable the fake port with a reset. So now we are in the reset path -- we know we have a non-yet enumerated @@ -326,7 +326,7 @@ device with an unauthorized address; we ask user space to authenticate exchange (FIXME: not yet done) and issue a /set address 0/ to bring the device to the default state. Device is authenticated. -From here, the USB stack takes control through the usb_hcd ops. khubd +From here, the USB stack takes control through the usb_hcd ops. hub_wq has seen the port status changes, as we have been toggling them. It will start enumerating and doing transfers through usb_hcd-urb_enqueue() to read descriptors and move our data. @@ -340,7 +340,7 @@ Keep Alive IE; it responds with a /DN_Alive/ pong during the DNTS (this arrives to us as a notification through devconnect.c:wusb_handle_dn_alive(). If a device times out, we disconnect it from the system (cleaning up internal information and -toggling the bits in the fake hub port, which kicks khubd into removing +toggling the bits in the fake hub port, which kicks hub_wq into removing the rest of the stuff). This is done through devconnect:__wusb_check_devs(), which will scan the diff --git a/Documentation/usb/hotplug.txt b/Documentation/usb/hotplug.txt index a80b0e9a7a0b..5b243f315b2c 100644 --- a/Documentation/usb/hotplug.txt +++ b/Documentation/usb/hotplug.txt @@ -58,7 +58,7 @@ USB POLICY AGENT The USB subsystem
[PATCH v3 3/6] usb: hub: convert khubd into workqueue
There is no need to have separate kthread for handling USB hub events. It is more elegant to use the workqueue framework. The workqueue is allocated as freezable because the original thread was freezable as well. Also it is allocated as ordered because the code is not ready for parallel processing of hub events, see choose_devnum(). struct usb_hub is passed via the work item. Therefore we do not need hub_event_list. Also hub_thread() is not longer needed. It would call only hub_event(). The rest of the code did manipulate the kthread and it is handled by the workqueue framework now. kick_khubd is renamed to kick_hub_wq() to make the function clear. And the protection against races is done another way, see below. hub_event_lock has been removed. It cannot longer be used to protect struct usb_hub between hub_event() and hub_disconnect(). Instead we need to get hub-kref already in kick_hub_wq(). The lock is not really needed for the other scenarios as well. queue_work() returns whether it succeeded. We could revert the needed operations accordingly. This is enough to avoid duplicity and inconsistencies. Yes, the removed lock causes that there is not longer such a strong synchronization between scheduling the work and manipulating hub-disconnected. But kick_hub_wq() must never be called together with hub_disconnect() otherwise even the original code would have failed. Any callers are responsible for this. Therefore the only problem is that hub_disconnect() could be called in parallel with hub_event(). But this was possible even in the past. struct usb_hub is still guarded by hub-kref and released in hub_events() when needed. Note that the source file is still full of the obsolete khubd strings. Let's remove them in a follow up patch. This patch already is complex enough. Thanks a lot Alan Stern st...@rowland.harvard.edu for code review, many useful tips and guidance. Also thanks to Tejun Heo t...@kernel.org for hints how to allocate the workqueue. Signed-off-by: Petr Mladek pmla...@suse.cz --- drivers/usb/core/hub.c | 143 + drivers/usb/core/hub.h | 2 +- 2 files changed, 61 insertions(+), 84 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index f1efd5a493ba..193f58988535 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -22,9 +22,8 @@ #include linux/usb/hcd.h #include linux/usb/otg.h #include linux/usb/quirks.h -#include linux/kthread.h +#include linux/workqueue.h #include linux/mutex.h -#include linux/freezer.h #include linux/random.h #include linux/pm_qos.h @@ -41,14 +40,9 @@ * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ static DEFINE_SPINLOCK(device_state_lock); -/* khubd's worklist and its lock */ -static DEFINE_SPINLOCK(hub_event_lock); -static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */ - -/* Wakes up khubd */ -static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); - -static struct task_struct *khubd_task; +/* workqueue to process hub events */ +static struct workqueue_struct *hub_wq; +static void hub_event(struct work_struct *work); /* synchronize hub-port add/remove and peering operations */ DEFINE_MUTEX(usb_port_peer_mutex); @@ -104,6 +98,7 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rwsem); #define HUB_DEBOUNCE_STEP25 #define HUB_DEBOUNCE_STABLE 100 +static void hub_release(struct kref *kref); static int usb_reset_and_verify_device(struct usb_device *udev); static inline char *portspeed(struct usb_hub *hub, int portstatus) @@ -575,20 +570,31 @@ static int hub_port_status(struct usb_hub *hub, int port1, return ret; } -static void kick_khubd(struct usb_hub *hub) +static void kick_hub_wq(struct usb_hub *hub) { - unsigned long flags; + struct usb_interface *intf; - spin_lock_irqsave(hub_event_lock, flags); - if (!hub-disconnected list_empty(hub-event_list)) { - list_add_tail(hub-event_list, hub_event_list); + if (hub-disconnected || work_pending(hub-events)) + return; - /* Suppress autosuspend until khubd runs */ - usb_autopm_get_interface_no_resume( - to_usb_interface(hub-intfdev)); - wake_up(khubd_wait); - } - spin_unlock_irqrestore(hub_event_lock, flags); + /* +* Suppress autosuspend until the event is proceed. +* +* Be careful and make sure that the symmetric operation is +* always called. We are here only when there is no pending +* work for this hub. Therefore put the interface either when +* the new work is called or when it is canceled. +*/ + intf = to_usb_interface(hub-intfdev); + usb_autopm_get_interface_no_resume(intf); + kref_get(hub-kref); + + if (queue_work(hub_wq, hub-events)) + return; + + /* the work has already been scheduled */ +
[PATCH v3 4/6] usb: hub: rename usb_kick_khubd() to usb_kick_hub_wq()
USB hub started to use a workqueue instead of kthread. Let's make it clear from the function names. Signed-off-by: Petr Mladek pmla...@suse.cz --- drivers/usb/core/hcd.c | 4 ++-- drivers/usb/core/hub.c | 2 +- drivers/usb/core/usb.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 487abcfcccd8..4bec044a786c 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2386,7 +2386,7 @@ void usb_hc_died (struct usb_hcd *hcd) /* make khubd clean up old urbs and devices */ usb_set_device_state (hcd-self.root_hub, USB_STATE_NOTATTACHED); - usb_kick_khubd (hcd-self.root_hub); + usb_kick_hub_wq(hcd-self.root_hub); } if (usb_hcd_is_primary_hcd(hcd) hcd-shared_hcd) { hcd = hcd-shared_hcd; @@ -2396,7 +2396,7 @@ void usb_hc_died (struct usb_hcd *hcd) /* make khubd clean up old urbs and devices */ usb_set_device_state(hcd-self.root_hub, USB_STATE_NOTATTACHED); - usb_kick_khubd(hcd-self.root_hub); + usb_kick_hub_wq(hcd-self.root_hub); } } spin_unlock_irqrestore (hcd_root_hub_lock, flags); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 193f58988535..33ad49ca6cb6 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -597,7 +597,7 @@ static void kick_hub_wq(struct usb_hub *hub) kref_put(hub-kref, hub_release); } -void usb_kick_khubd(struct usb_device *hdev) +void usb_kick_hub_wq(struct usb_device *hdev) { struct usb_hub *hub = usb_hub_to_struct_hub(hdev); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index d9d08720c386..b1b34d0557c9 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -48,7 +48,7 @@ static inline unsigned usb_get_max_power(struct usb_device *udev, return c-desc.bMaxPower * mul; } -extern void usb_kick_khubd(struct usb_device *dev); +extern void usb_kick_hub_wq(struct usb_device *dev); extern int usb_match_one_id_intf(struct usb_device *dev, struct usb_host_interface *intf, const struct usb_device_id *id); -- 1.8.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 v3 0/6] usb: hub: convert khubd into workqueue
The 3rd version of the patchset is slightly reordered and refactored as suggested earlier. See below for more details. IMHO, the result is more clean. But feel free to ask me to revert it. I do not want to make the review more complicated. Well, I double checked the diff of patches files between v2 and v3. It is pretty small and only the expected changes are there. Changes in: + v3: + split the optimization of hub-hdev reference counting into separate patch; usable standalone (1st patch) + switch order of the two patches that convert the kthread and that remove the while cycle in hub_event(); it is cleaner (2nd and 3rd patch) + use ordered workqueue by default; it makes it compatible with the original kthread solution (3rd patch) + added optional patch that allows to process events in parallel (6th patch) + fixed the suggested stylistic problems (2nd and 3rd patch) + v2: + solved potential races: + get hub-kref in kick_hub_wq() + call usb_get_dev(hdev) in hub_probe() and usb_put_dev(hdev) in hub_release() + INIT_WORK only once in hub_probe() + do not call cancel_work_sync() in hub_disconnect() to keep it fast + rename kick_khubd() to kick_hub_wq() already in the first patch; IMHO, it is cleaner while adding only very few changes The workqueue API is well defined and tested. It has many options that could be used to tune the scheduling. The code is usually easier and thus more safe. It allows to avoid the extra thread in most cases. It has has clearly defined behavior vrt. system suspend. This patchset converts khubd into the workqueue. It saves one thread, lock, and list. It looks huge but the main change is in the first patch. The rest is simple renaming of functions, comments and documentation. Thanks a lot Alan Stern and Tejun Heo for hints and guidance. The patches can be applied either against Linus' tree or linux-next. Petr Mladek (6): usb: hub: keep hub-dev reference all the time when struct usb_hub lives usb: hub: rename hub_events() to hub_event() and handle only one event there usb: hub: convert khubd into workqueue usb: hub: rename usb_kick_khubd() to usb_kick_hub_wq() usb: hub: rename khubd to hub_wq in documentation and comments usb: hub: allow to process more usb hub events in parallel Documentation/DocBook/usb.tmpl | 2 +- Documentation/usb/WUSB-Design-overview.txt | 6 +- Documentation/usb/hotplug.txt | 2 +- drivers/net/usb/usbnet.c | 14 +- drivers/usb/README | 2 +- drivers/usb/core/hcd.c | 14 +- drivers/usb/core/hub.c | 380 + drivers/usb/core/hub.h | 2 +- drivers/usb/core/usb.h | 2 +- drivers/usb/host/ehci-fsl.c| 2 +- drivers/usb/host/ehci-hcd.c| 2 +- drivers/usb/host/ehci-hub.c| 8 +- drivers/usb/host/fhci-hcd.c| 6 +- drivers/usb/host/fotg210-hcd.c | 8 +- drivers/usb/host/fusbh200-hcd.c| 8 +- drivers/usb/host/isp1760-hcd.c | 6 +- drivers/usb/host/ohci-hcd.c| 6 +- drivers/usb/host/ohci-hub.c| 4 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/host/oxu210hp-hcd.c| 10 +- drivers/usb/host/sl811-hcd.c | 8 +- drivers/usb/host/xhci-hub.c| 2 +- drivers/usb/host/xhci.c| 4 +- drivers/usb/misc/usbtest.c | 2 +- drivers/usb/musb/am35x.c | 1 + drivers/usb/musb/tusb6010.c| 2 +- drivers/usb/phy/phy-fsl-usb.c | 2 +- drivers/usb/phy/phy-isp1301-omap.c | 2 +- drivers/usb/wusbcore/devconnect.c | 6 +- drivers/usb/wusbcore/wa-hc.h | 2 +- sound/usb/midi.c | 2 +- 31 files changed, 242 insertions(+), 277 deletions(-) -- 1.8.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 v3 0/6] usb: hub: convert khubd into workqueue
On Fri, 19 Sep 2014, Petr Mladek wrote: The 3rd version of the patchset is slightly reordered and refactored as suggested earlier. See below for more details. IMHO, the result is more clean. But feel free to ask me to revert it. I do not want to make the review more complicated. Well, I double checked the diff of patches files between v2 and v3. It is pretty small and only the expected changes are there. Changes in: + v3: + split the optimization of hub-hdev reference counting into separate patch; usable standalone (1st patch) + switch order of the two patches that convert the kthread and that remove the while cycle in hub_event(); it is cleaner (2nd and 3rd patch) + use ordered workqueue by default; it makes it compatible with the original kthread solution (3rd patch) + added optional patch that allows to process events in parallel (6th patch) + fixed the suggested stylistic problems (2nd and 3rd patch) + v2: + solved potential races: + get hub-kref in kick_hub_wq() + call usb_get_dev(hdev) in hub_probe() and usb_put_dev(hdev) in hub_release() + INIT_WORK only once in hub_probe() + do not call cancel_work_sync() in hub_disconnect() to keep it fast + rename kick_khubd() to kick_hub_wq() already in the first patch; IMHO, it is cleaner while adding only very few changes The workqueue API is well defined and tested. It has many options that could be used to tune the scheduling. The code is usually easier and thus more safe. It allows to avoid the extra thread in most cases. It has has clearly defined behavior vrt. system suspend. This patchset converts khubd into the workqueue. It saves one thread, lock, and list. It looks huge but the main change is in the first patch. The rest is simple renaming of functions, comments and documentation. Thanks a lot Alan Stern and Tejun Heo for hints and guidance. The patches can be applied either against Linus' tree or linux-next. Very nice work. I haven't tried it out, but it all looks good. No doubt we will be able to sort out unforeseen troubles if any arise, without much difficulty. For all six patches, Acked-by: Alan Stern st...@rowland.harvard.edu Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 5/5] usb: gadget: pxa27x_udc: fix clock prepare and enable
As the udc clock controls both the output signals and the internal IP, it must be enabled before any UDC register is touched. The bug is revealed when the clock framework disables the clock for a couple of milliseconds during the boot sequence, and the endpoint configuration is lost. The bug is hidden when clock framework is not used, because no unused clocks disable occurs. This patch fixes the wrong behaviour by ensuring that : - whenever a UDC register is read or written, the clock is enabled - reworks the endpoints programming to have it done under running clock - reworks suspend/resume to ensure the same thing Signed-off-by: Robert Jarzmik robert.jarz...@free.fr --- drivers/usb/gadget/udc/pxa27x_udc.c | 26 +- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index 3c1ba78..9506da8 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -1704,10 +1704,10 @@ static void udc_disable(struct pxa_udc *udc) udc_writel(udc, UDCICR1, 0); udc_clear_mask_UDCCR(udc, UDCCR_UDE); - clk_disable(udc-clk); ep0_idle(udc); udc-gadget.speed = USB_SPEED_UNKNOWN; + clk_disable(udc-clk); udc-enabled = 0; } @@ -1760,16 +1760,16 @@ static void udc_enable(struct pxa_udc *udc) if (udc-enabled) return; + clk_enable(udc-clk); udc_writel(udc, UDCICR0, 0); udc_writel(udc, UDCICR1, 0); udc_clear_mask_UDCCR(udc, UDCCR_UDE); - clk_enable(udc-clk); - ep0_idle(udc); udc-gadget.speed = USB_SPEED_FULL; memset(udc-stats, 0, sizeof(udc-stats)); + pxa_eps_setup(udc); udc_set_mask_UDCCR(udc, UDCCR_UDE); ep_write_UDCCSR(udc-pxa_ep[0], UDCCSR0_ACM); udelay(2); @@ -2513,7 +2513,6 @@ static int pxa_udc_probe(struct platform_device *pdev) the_controller = udc; platform_set_drvdata(pdev, udc); udc_init_data(udc); - pxa_eps_setup(udc); /* irq setup after old hardware state is cleaned up */ retval = devm_request_irq(pdev-dev, udc-irq, pxa_udc_irq, @@ -2529,7 +2528,8 @@ static int pxa_udc_probe(struct platform_device *pdev) goto err; pxa_init_debugfs(udc); - + if (should_enable_udc(udc)) + udc_enable(udc); return 0; err: clk_unprepare(udc-clk); @@ -2582,19 +2582,11 @@ extern void pxa27x_clear_otgph(void); */ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) { - int i; struct pxa_udc *udc = platform_get_drvdata(_dev); struct pxa_ep *ep; ep = udc-pxa_ep[0]; udc-udccsr0 = udc_ep_readl(ep, UDCCSR); - for (i = 1; i NR_PXA_ENDPOINTS; i++) { - ep = udc-pxa_ep[i]; - ep-udccsr_value = udc_ep_readl(ep, UDCCSR); - ep-udccr_value = udc_ep_readl(ep, UDCCR); - ep_dbg(ep, udccsr:0x%03x, udccr:0x%x\n, - ep-udccsr_value, ep-udccr_value); - } udc_disable(udc); udc-pullup_resume = udc-pullup_on; @@ -2612,19 +2604,11 @@ static int pxa_udc_suspend(struct platform_device *_dev, pm_message_t state) */ static int pxa_udc_resume(struct platform_device *_dev) { - int i; struct pxa_udc *udc = platform_get_drvdata(_dev); struct pxa_ep *ep; ep = udc-pxa_ep[0]; udc_ep_writel(ep, UDCCSR, udc-udccsr0 (UDCCSR0_FST | UDCCSR0_DME)); - for (i = 1; i NR_PXA_ENDPOINTS; i++) { - ep = udc-pxa_ep[i]; - udc_ep_writel(ep, UDCCSR, ep-udccsr_value); - udc_ep_writel(ep, UDCCR, ep-udccr_value); - ep_dbg(ep, udccsr:0x%03x, udccr:0x%x\n, - ep-udccsr_value, ep-udccr_value); - } dplus_pullup(udc, udc-pullup_resume); if (should_enable_udc(udc)) -- 2.0.0.rc2 -- 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 v6 4/5] usb: gadget: pxa27x_udc: use devm_* helpers
Use devm_* helpers in the probe function to simplify the error path and the remove path. Signed-off-by: Robert Jarzmik robert.jarz...@free.fr Cc: Sergei Shtylyov sergei.shtyl...@cogentembedded.com --- Since V1: Addressed Sergei's comments Since V2: Addressed Sergei's comments on includes Since V4: Addressed Sergei's comment on clk_uprepare in probe() function --- drivers/usb/gadget/udc/pxa27x_udc.c | 53 +++-- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index 42f4929..3c1ba78 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -2477,8 +2477,9 @@ static int pxa_udc_probe(struct platform_device *pdev) pxa_udc_probe_pdata(pdev, udc); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!regs) - return -ENXIO; + udc-regs = devm_ioremap_resource(pdev-dev, regs); + if (IS_ERR(udc-regs)) + return PTR_ERR(udc-regs); udc-irq = platform_get_irq(pdev, 0); if (udc-irq 0) return udc-irq; @@ -2487,7 +2488,8 @@ static int pxa_udc_probe(struct platform_device *pdev) udc-transceiver = usb_get_phy(USB_PHY_TYPE_USB2); if (gpio_is_valid(udc-gpio_pullup)) { - retval = gpio_request(udc-gpio_pullup, USB D+ pullup); + retval = devm_gpio_request(pdev-dev, + udc-gpio_pullup, USB D+ pullup); if (retval == 0) gpio_direction_output(udc-gpio_pullup, udc-gpio_pullup_inverted); @@ -2498,21 +2500,13 @@ static int pxa_udc_probe(struct platform_device *pdev) return retval; } - udc-clk = clk_get(pdev-dev, NULL); - if (IS_ERR(udc-clk)) { - retval = PTR_ERR(udc-clk); - goto err_clk; - } + udc-clk = devm_clk_get(pdev-dev, NULL); + if (IS_ERR(udc-clk)) + return PTR_ERR(udc-clk); + retval = clk_prepare(udc-clk); if (retval) - goto err_clk_prepare; - - retval = -ENOMEM; - udc-regs = ioremap(regs-start, resource_size(regs)); - if (!udc-regs) { - dev_err(pdev-dev, Unable to map UDC I/O memory\n); - goto err_map; - } + return retval; udc-vbus_sensed = 0; @@ -2522,34 +2516,23 @@ static int pxa_udc_probe(struct platform_device *pdev) pxa_eps_setup(udc); /* irq setup after old hardware state is cleaned up */ - retval = request_irq(udc-irq, pxa_udc_irq, - IRQF_SHARED, driver_name, udc); + retval = devm_request_irq(pdev-dev, udc-irq, pxa_udc_irq, + IRQF_SHARED, driver_name, udc); if (retval != 0) { dev_err(udc-dev, %s: can't get irq %i, err %d\n, driver_name, udc-irq, retval); - goto err_irq; + goto err; } retval = usb_add_gadget_udc(pdev-dev, udc-gadget); if (retval) - goto err_add_udc; + goto err; pxa_init_debugfs(udc); return 0; - -err_add_udc: - free_irq(udc-irq, udc); -err_irq: - iounmap(udc-regs); -err_map: +err: clk_unprepare(udc-clk); -err_clk_prepare: - clk_put(udc-clk); - udc-clk = NULL; -err_clk: - if (gpio_is_valid(udc-gpio_pullup)) - gpio_free(udc-gpio_pullup); return retval; } @@ -2560,22 +2543,16 @@ err_clk: static int pxa_udc_remove(struct platform_device *_dev) { struct pxa_udc *udc = platform_get_drvdata(_dev); - int gpio = udc-mach-gpio_pullup; usb_del_gadget_udc(udc-gadget); usb_gadget_unregister_driver(udc-driver); - free_irq(udc-irq, udc); pxa_cleanup_debugfs(udc); - if (gpio_is_valid(gpio)) - gpio_free(gpio); usb_put_phy(udc-transceiver); udc-transceiver = NULL; the_controller = NULL; clk_unprepare(udc-clk); - clk_put(udc-clk); - iounmap(udc-regs); return 0; } -- 2.0.0.rc2 -- 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 v6 2/5] usb: gadget: pxa27x_udc: add devicetree support
Add support for device-tree device discovery. If devicetree is not provided, fallback to legacy platform data discovery. Signed-off-by: Robert Jarzmik robert.jarz...@free.fr Cc: devicet...@vger.kernel.org --- Since V1: change OF id mrvl,pxa27x_udc - marvell,pxa27x-udc This is a consequence of other DT reviews on the marvell namings. Since V2: address Mark's comments: - wildcard pxa27x becomes pxa270 - pullup gpio is described as standard dt gpio - bool XXX_probe_dt becomes int XXX_probe_dt Since v5: split out into 2 patches, this one being the second --- drivers/usb/gadget/udc/pxa27x_udc.c | 44 - 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index 0e356c0..42f4929 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -26,6 +26,8 @@ #include linux/prefetch.h #include linux/byteorder/generic.h #include linux/platform_data/pxa2xx_udc.h +#include linux/of_device.h +#include linux/of_gpio.h #include linux/usb.h #include linux/usb/ch9.h @@ -2405,6 +2407,41 @@ static struct pxa_udc memory = { } }; +static struct of_device_id udc_pxa_dt_ids[] = { + { .compatible = marvell,pxa270-udc }, + {} +}; +MODULE_DEVICE_TABLE(of, udc_pxa_dt_ids); + +/** + * pxa_udc_probe_dt - device tree specific probe + * @pdev: platform data + * @udc: pxa_udc structure to fill + * + * Fills udc from platform data out of device tree. + * + * Returns 0 if DT found, 1 if DT not found, and 0 on error + */ +static int pxa_udc_probe_dt(struct platform_device *pdev, struct pxa_udc *udc) +{ + struct device_node *np = pdev-dev.of_node; + const struct of_device_id *of_id = + of_match_device(udc_pxa_dt_ids, pdev-dev); + u32 gpio_pullup; + enum of_gpio_flags flags; + + if (!np || !of_id) + return 1; + pdev-id = -1; + + gpio_pullup = of_get_gpio_flags(np, 0, flags); + if (gpio_pullup = 0) { + udc-gpio_pullup = gpio_pullup; + udc-gpio_pullup_inverted = (flags OF_GPIO_ACTIVE_LOW); + } + return 0; +} + /** * pxa_udc_probe_pdata - legacy platform data probe * @pdev: platform device @@ -2433,7 +2470,11 @@ static int pxa_udc_probe(struct platform_device *pdev) struct pxa_udc *udc = memory; int retval = 0; - pxa_udc_probe_pdata(pdev, udc); + retval = pxa_udc_probe_dt(pdev, udc); + if (retval 0) + return retval; + if (retval 0) + pxa_udc_probe_pdata(pdev, udc); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) @@ -2633,6 +2674,7 @@ static struct platform_driver udc_driver = { .driver = { .name = pxa27x-udc, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(udc_pxa_dt_ids), }, .probe = pxa_udc_probe, .remove = pxa_udc_remove, -- 2.0.0.rc2 -- 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 v6 3/5] usb: gadget: pxa27x_udc device-tree documentation
Add documentation for device-tree binding of arm PXA 27x udc (usb device) driver. Signed-off-by: Robert Jarzmik robert.jarz...@free.fr Cc: devicet...@vger.kernel.org --- Since V1: change OF id mrvl,pxa27x_udc - marvell,pxa27x-udc This is a consequence of other DT reviews on the marvell namings. Since V2: Mark's review - described standard properties - use standard gpio bindings for pullup gpio Since V3: Arnd's review - removed clock-names --- Documentation/devicetree/bindings/usb/pxa-usb.txt | 22 ++ 1 file changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/pxa-usb.txt b/Documentation/devicetree/bindings/usb/pxa-usb.txt index 79729a9..9c33179 100644 --- a/Documentation/devicetree/bindings/usb/pxa-usb.txt +++ b/Documentation/devicetree/bindings/usb/pxa-usb.txt @@ -29,3 +29,25 @@ Example: marvell,port-mode = 2; /* PMM_GLOBAL_MODE */ }; +UDC + +Required properties: + - compatible: Should be marvell,pxa270-udc for USB controllers + used in device mode. + - reg: usb device MMIO address space + - interrupts: single interrupt generated by the UDC IP + - clocks: input clock of the UDC IP (see clock-bindings.txt) + +Optional properties: + - gpios: + - gpio activated to control the USB D+ pullup (see gpio.txt) + +Example: + + pxa27x_udc: udc@4060 { + compatible = marvell,pxa270-udc; + reg = 0x4060 0x1; + interrupts = 11; + clocks = pxa2xx_clks 11; + gpios = gpio 22 GPIO_ACTIVE_LOW; + }; -- 2.0.0.rc2 -- 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 v6 1/5] usb: gadget: pxa27x_udc: prepare device-tree support
The pxa27x_udc should support 2 modes of initialization : - one through legacy platform data - one new through device-tree Prepare the double support by moving the initialization data, ie. the gpios, into the udc control structure. Signed-off-by: Robert Jarzmik robert.jarz...@free.fr --- Since v5: This new patch, split out of the first DT patch --- drivers/usb/gadget/udc/pxa27x_udc.c | 52 + drivers/usb/gadget/udc/pxa27x_udc.h | 4 +++ 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c index 597d39f..0e356c0 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.c +++ b/drivers/usb/gadget/udc/pxa27x_udc.c @@ -1508,16 +1508,16 @@ static struct usb_ep_ops pxa_ep_ops = { static void dplus_pullup(struct pxa_udc *udc, int on) { if (on) { - if (gpio_is_valid(udc-mach-gpio_pullup)) - gpio_set_value(udc-mach-gpio_pullup, - !udc-mach-gpio_pullup_inverted); - if (udc-mach-udc_command) + if (gpio_is_valid(udc-gpio_pullup)) + gpio_set_value(udc-gpio_pullup, + !udc-gpio_pullup_inverted); + if (udc-mach udc-mach-udc_command) udc-mach-udc_command(PXA2XX_UDC_CMD_CONNECT); } else { - if (gpio_is_valid(udc-mach-gpio_pullup)) - gpio_set_value(udc-mach-gpio_pullup, - udc-mach-gpio_pullup_inverted); - if (udc-mach-udc_command) + if (gpio_is_valid(udc-gpio_pullup)) + gpio_set_value(udc-gpio_pullup, + udc-gpio_pullup_inverted); + if (udc-mach udc-mach-udc_command) udc-mach-udc_command(PXA2XX_UDC_CMD_DISCONNECT); } udc-pullup_on = on; @@ -1609,7 +1609,8 @@ static int pxa_udc_pullup(struct usb_gadget *_gadget, int is_active) { struct pxa_udc *udc = to_gadget_udc(_gadget); - if (!gpio_is_valid(udc-mach-gpio_pullup) !udc-mach-udc_command) + if (!gpio_is_valid(udc-gpio_pullup) +!(udc-mach udc-mach-udc_command)) return -EOPNOTSUPP; dplus_pullup(udc, is_active); @@ -2405,6 +2406,21 @@ static struct pxa_udc memory = { }; /** + * pxa_udc_probe_pdata - legacy platform data probe + * @pdev: platform device + * @udc: pxa_udc structure to fill + * + * Simple copy of data from platform_data to udc control structure + */ +static void pxa_udc_probe_pdata(struct platform_device *pdev, + struct pxa_udc *udc) +{ + udc-mach = dev_get_platdata(pdev-dev); + udc-gpio_pullup = udc-mach-gpio_pullup; + udc-gpio_pullup_inverted = udc-mach-gpio_pullup_inverted; +} + +/** * pxa_udc_probe - probes the udc device * @_dev: platform device * @@ -2415,7 +2431,9 @@ static int pxa_udc_probe(struct platform_device *pdev) { struct resource *regs; struct pxa_udc *udc = memory; - int retval = 0, gpio; + int retval = 0; + + pxa_udc_probe_pdata(pdev, udc); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!regs) @@ -2425,19 +2443,17 @@ static int pxa_udc_probe(struct platform_device *pdev) return udc-irq; udc-dev = pdev-dev; - udc-mach = dev_get_platdata(pdev-dev); udc-transceiver = usb_get_phy(USB_PHY_TYPE_USB2); - gpio = udc-mach-gpio_pullup; - if (gpio_is_valid(gpio)) { - retval = gpio_request(gpio, USB D+ pullup); + if (gpio_is_valid(udc-gpio_pullup)) { + retval = gpio_request(udc-gpio_pullup, USB D+ pullup); if (retval == 0) - gpio_direction_output(gpio, - udc-mach-gpio_pullup_inverted); + gpio_direction_output(udc-gpio_pullup, + udc-gpio_pullup_inverted); } if (retval) { dev_err(pdev-dev, Couldn't request gpio %d : %d\n, - gpio, retval); + udc-gpio_pullup, retval); return retval; } @@ -2491,6 +2507,8 @@ err_clk_prepare: clk_put(udc-clk); udc-clk = NULL; err_clk: + if (gpio_is_valid(udc-gpio_pullup)) + gpio_free(udc-gpio_pullup); return retval; } diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h index 28f2b53..8995b34 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.h +++ b/drivers/usb/gadget/udc/pxa27x_udc.h @@ -421,6 +421,8 @@ struct udc_stats { * @driver: bound gadget (zero, g_ether, g_mass_storage, ...) * @dev: device * @mach: machine info, used to activate specific GPIO + * @gpio_pullup: if valid, D+ pullup GPIO + *
[PATCH v5 0/4] mfd: add support for Diolan DLN-2
This patch series adds support for Diolan USB-I2C/GPIO Master Adapter DLN-2. Details about device can be found here: https://www.diolan.com/i2c/i2c_interface.html. Changes since v4: * Add a new gpiolib chip flag to allow blocking chips with non threaded IRQ handlers * MFD: set GPLv2 as license, fix a couple of coding style issues, add code to stop I/O after USB disconnect and prevent further I/O, simplify the DNL2 platform data * GPIO: add modalias, set GPLv2 as license, rework pin direction caching, use irq_find_mapping in dln2_irq_unmask, allocate irq work based on the number of pins read from the device, flush irq work at remove time, use RCU to iterate and run the callback list * I2C: add modalias, set GPLv2 as license, allocate the RX/TX buf separately to avoid cache line sharing issue, don't truncate i2c reads, use u32 instead of uint32_t, attach the sysfs freq attribute to the i2c adapter device instead of the platform device (and also use device attribute groups), simplify dln2_i2c_read a bit Daniel Baluta (1): gpio: add support for the Diolan DLN-2 USB GPIO driver Laurentiu Palcu (1): i2c: add support for Diolan DLN-2 USB-I2C adapter Octavian Purdila (2): mfd: add support for Diolan DLN-2 devices gpiolib: add irq_not_threaded flag to gpio_chip drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-dln2.c | 554 ++ drivers/gpio/gpiolib.c| 2 +- drivers/i2c/busses/Kconfig| 10 + drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-dln2.c | 383 + drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 1 + drivers/mfd/dln2.c| 758 ++ include/linux/gpio/driver.h | 3 + include/linux/mfd/dln2.h | 67 12 files changed, 1800 insertions(+), 1 deletion(-) create mode 100644 drivers/gpio/gpio-dln2.c create mode 100644 drivers/i2c/busses/i2c-dln2.c create mode 100644 drivers/mfd/dln2.c create mode 100644 include/linux/mfd/dln2.h -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 1/4] mfd: add support for Diolan DLN-2 devices
This patch implements the USB part of the Diolan USB-I2C/SPI/GPIO Master Adapter DLN-2. Details about the device can be found here: https://www.diolan.com/i2c/i2c_interface.html. Information about the USB protocol can be found in the Programmer's Reference Manual [1], see section 1.7. Because the hardware has a single transmit endpoint and a single receive endpoint the communication between the various DLN2 drivers and the hardware will be muxed/demuxed by this driver. Each DLN2 module will be identified by the handle field within the DLN2 message header. If a DLN2 module issues multiple commands in parallel they will be identified by the echo counter field in the message header. The DLN2 modules can use the dln2_transfer() function to issue a command and wait for its response. They can also register a callback that is going to be called when a specific event id is generated by the device (e.g. GPIO interrupts). The device uses handle 0 for sending events. [1] https://www.diolan.com/downloads/dln-api-manual.pdf Signed-off-by: Octavian Purdila octavian.purd...@intel.com --- drivers/mfd/Kconfig | 9 + drivers/mfd/Makefile | 1 + drivers/mfd/dln2.c | 758 +++ include/linux/mfd/dln2.h | 67 + 4 files changed, 835 insertions(+) create mode 100644 drivers/mfd/dln2.c create mode 100644 include/linux/mfd/dln2.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index de5abf2..7bcf895 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -183,6 +183,15 @@ config MFD_DA9063 Additional drivers must be enabled in order to use the functionality of the device. +config MFD_DLN2 + tristate Diolan DLN2 support + select MFD_CORE + depends on USB + help + This adds support for Diolan USB-I2C/SPI/GPIO Master Adapter DLN-2. + Additional drivers must be enabled in order to use the functionality + of the device. + config MFD_MC13XXX tristate depends on (SPI_MASTER || I2C) diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f001487..591988d 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -169,6 +169,7 @@ obj-$(CONFIG_MFD_AS3711)+= as3711.o obj-$(CONFIG_MFD_AS3722) += as3722.o obj-$(CONFIG_MFD_STW481X) += stw481x.o obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o +obj-$(CONFIG_MFD_DLN2) += dln2.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c new file mode 100644 index 000..36c53cd --- /dev/null +++ b/drivers/mfd/dln2.c @@ -0,0 +1,758 @@ +/* + * Driver for the Diolan DLN-2 USB adapter + * + * Copyright (c) 2014 Intel Corporation + * + * Derived from: + * i2c-diolan-u2c.c + * Copyright (c) 2010-2011 Ericsson AB + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/types.h +#include linux/slab.h +#include linux/usb.h +#include linux/i2c.h +#include linux/mutex.h +#include linux/platform_device.h +#include linux/mfd/core.h +#include linux/mfd/dln2.h +#include linux/rculist.h + +struct dln2_header { + __le16 size; + __le16 id; + __le16 echo; + __le16 handle; +} __packed; + +struct dln2_response { + struct dln2_header hdr; + __le16 result; +} __packed; + +#define DLN2_GENERIC_MODULE_ID 0x00 +#define DLN2_GENERIC_CMD(cmd) DLN2_CMD(cmd, DLN2_GENERIC_MODULE_ID) +#define CMD_GET_DEVICE_VER DLN2_GENERIC_CMD(0x30) +#define CMD_GET_DEVICE_SN DLN2_GENERIC_CMD(0x31) + +#define DLN2_HW_ID 0x200 +#define DLN2_USB_TIMEOUT 200 /* in ms */ +#define DLN2_MAX_RX_SLOTS 16 +#define DLN2_MAX_URBS 16 +#define DLN2_RX_BUF_SIZE 512 + +#define DLN2_HANDLE_EVENT 0 +#define DLN2_HANDLE_CTRL 1 +#define DLN2_HANDLE_GPIO 2 +#define DLN2_HANDLE_I2C3 +#define DLN2_HANDLES 4 + + +/* + * Receive context used between the receive demultiplexer and the + * transfer routine. While sending a request the transfer routine + * will look for a free receive context and use it to wait for a + * response and to receive the URB and thus the response data. + */ +struct dln2_rx_context { + /* completion used to wait a response */ + struct completion done; + + /* if non-NULL the URB contains the response */ + struct urb *urb; + + /* if true then this context is used to wait for a response */ + bool connected; + + /* cancel waiting for a response, e.g. on USB disconnect */ + bool cancel; +}; + +/* + * Receive contexts for
[PATCH v5 3/4] gpiolib: add irq_not_threaded flag to gpio_chip
Some GPIO chips (e.g. the DLN2 USB adapter) have blocking get/set operation but do not need a threaded irq handler. Signed-off-by: Octavian Purdila octavian.purd...@intel.com --- drivers/gpio/gpiolib.c | 2 +- include/linux/gpio/driver.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 15cc0bb..3fa7e73 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -447,7 +447,7 @@ static int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, irq_set_lockdep_class(irq, gpiochip_irq_lock_class); irq_set_chip_and_handler(irq, chip-irqchip, chip-irq_handler); /* Chips that can sleep need nested thread handlers */ - if (chip-can_sleep) + if (chip-can_sleep !chip-irq_not_threaded) irq_set_nested_thread(irq, 1); #ifdef CONFIG_ARM set_irq_flags(irq, IRQF_VALID); diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index e78a237..44161ac 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -56,6 +56,8 @@ struct seq_file; * as the chip access may sleep when e.g. reading out the IRQ status * registers. * @exported: flags if the gpiochip is exported for use from sysfs. Private. + * @irq_not_threaded: flag must be set if @can_sleep is set but the + * IRQs don't need to be threaded * * A gpio_chip can help platforms abstract various sources of GPIOs so * they can all be accessed through a common programing interface. @@ -101,6 +103,7 @@ struct gpio_chip { struct gpio_desc*desc; const char *const *names; boolcan_sleep; + boolirq_not_threaded; boolexported; #ifdef CONFIG_GPIOLIB_IRQCHIP -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 2/4] i2c: add support for Diolan DLN-2 USB-I2C adapter
From: Laurentiu Palcu laurentiu.pa...@intel.com This patch adds support for the Diolan DLN-2 I2C master module. Due to hardware limitations it does not support SMBUS quick commands. Information about the USB protocol interface can be found in the Programmer's Reference Manual [1], see section 6.2.2 for the I2C master module commands and responses. [1] https://www.diolan.com/downloads/dln-api-manual.pdf Signed-off-by: Laurentiu Palcu laurentiu.pa...@intel.com Signed-off-by: Octavian Purdila octavian.purd...@intel.com --- drivers/i2c/busses/Kconfig| 10 ++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-dln2.c | 383 ++ 3 files changed, 394 insertions(+) create mode 100644 drivers/i2c/busses/i2c-dln2.c diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 2ac87fa..6afc17e 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -1021,4 +1021,14 @@ config SCx200_ACB This support is also available as a module. If so, the module will be called scx200_acb. +config I2C_DLN2 + tristate Diolan DLN-2 USB I2C adapter + depends on MFD_DLN2 + help + If you say yes to this option, support will be included for Diolan + DLN2, a USB to I2C interface. + + This driver can also be built as a module. If so, the module + will be called i2c-dln2. + endmenu diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index 49bf07e..3118fea 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -100,5 +100,6 @@ obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o obj-$(CONFIG_SCx200_ACB) += scx200_acb.o +obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o ccflags-$(CONFIG_I2C_DEBUG_BUS) := -DDEBUG diff --git a/drivers/i2c/busses/i2c-dln2.c b/drivers/i2c/busses/i2c-dln2.c new file mode 100644 index 000..21ad6dc --- /dev/null +++ b/drivers/i2c/busses/i2c-dln2.c @@ -0,0 +1,383 @@ +/* + * Driver for the Diolan DLN-2 USB-I2C adapter + * + * Copyright (c) 2014 Intel Corporation + * + * Derived from: + * i2c-diolan-u2c.c + * Copyright (c) 2010-2011 Ericsson AB + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/types.h +#include linux/slab.h +#include linux/i2c.h +#include linux/platform_device.h +#include linux/mfd/dln2.h + +#define DLN2_I2C_MODULE_ID 0x03 +#define DLN2_I2C_CMD(cmd) DLN2_CMD(cmd, DLN2_I2C_MODULE_ID) + +/* I2C commands */ +#define DLN2_I2C_GET_PORT_COUNTDLN2_I2C_CMD(0x00) +#define DLN2_I2C_ENABLEDLN2_I2C_CMD(0x01) +#define DLN2_I2C_DISABLE DLN2_I2C_CMD(0x02) +#define DLN2_I2C_IS_ENABLEDDLN2_I2C_CMD(0x03) +#define DLN2_I2C_SET_FREQUENCY DLN2_I2C_CMD(0x04) +#define DLN2_I2C_GET_FREQUENCY DLN2_I2C_CMD(0x05) +#define DLN2_I2C_WRITE DLN2_I2C_CMD(0x06) +#define DLN2_I2C_READ DLN2_I2C_CMD(0x07) +#define DLN2_I2C_SCAN_DEVICES DLN2_I2C_CMD(0x08) +#define DLN2_I2C_PULLUP_ENABLE DLN2_I2C_CMD(0x09) +#define DLN2_I2C_PULLUP_DISABLEDLN2_I2C_CMD(0x0A) +#define DLN2_I2C_PULLUP_IS_ENABLED DLN2_I2C_CMD(0x0B) +#define DLN2_I2C_TRANSFER DLN2_I2C_CMD(0x0C) +#define DLN2_I2C_SET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0D) +#define DLN2_I2C_GET_MAX_REPLY_COUNT DLN2_I2C_CMD(0x0E) +#define DLN2_I2C_GET_MIN_FREQUENCY DLN2_I2C_CMD(0x40) +#define DLN2_I2C_GET_MAX_FREQUENCY DLN2_I2C_CMD(0x41) + +#define DLN2_I2C_FREQ_STD 10 + +#define DLN2_I2C_MAX_XFER_SIZE 256 + +struct dln2_i2c { + struct platform_device *pdev; + struct i2c_adapter adapter; + u32 freq; + u32 min_freq; + u32 max_freq; + /* +* Buffer to hold the packet for read or write transfers. One +* is enough since we can't have multiple transfers in +* parallel on the i2c adapter. +*/ + union { + struct { + u8 port; + u8 addr; + u8 mem_addr_len; + __le32 mem_addr; + __le16 buf_len; + u8 buf[DLN2_I2C_MAX_XFER_SIZE]; + } __packed tx; + struct { + __le16 buf_len; + u8 buf[DLN2_I2C_MAX_XFER_SIZE]; + } __packed rx; + } *buf; +}; + +static int dln2_i2c_enable(struct dln2_i2c *dln2, bool enable) +{ + struct dln2_platform_data *pdata = dev_get_platdata(dln2-pdev-dev); + int ret; + u8 port; + u16 cmd; + + port = pdata-port; + +
[PATCH v5 4/4] gpio: add support for the Diolan DLN-2 USB GPIO driver
From: Daniel Baluta daniel.bal...@intel.com This patch adds GPIO and IRQ support for the Diolan DLN-2 GPIO module. Information about the USB protocol interface can be found in the Programmer's Reference Manual [1], see section 2.9 for the GPIO module commands and responses. [1] https://www.diolan.com/downloads/dln-api-manual.pdf Signed-off-by: Daniel Baluta daniel.bal...@intel.com Signed-off-by: Octavian Purdila octavian.purd...@intel.com --- drivers/gpio/Kconfig | 12 + drivers/gpio/Makefile| 1 + drivers/gpio/gpio-dln2.c | 554 +++ 3 files changed, 567 insertions(+) create mode 100644 drivers/gpio/gpio-dln2.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 9de1515..44ec206 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -897,4 +897,16 @@ config GPIO_VIPERBOARD River Tech's viperboard.h for detailed meaning of the module parameters. +config GPIO_DLN2 + tristate Diolan DLN2 GPIO support + depends on MFD_DLN2 + select GPIOLIB_IRQCHIP + + help + Select this option to enable GPIO driver for the Diolan DLN2 + board. + + This driver can also be built as a module. If so, the module + will be called gpio-dln2. + endif diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 5d024e3..eaa97a0 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o +obj-$(CONFIG_GPIO_DLN2)+= gpio-dln2.o obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o obj-$(CONFIG_GPIO_EM) += gpio-em.o obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o diff --git a/drivers/gpio/gpio-dln2.c b/drivers/gpio/gpio-dln2.c new file mode 100644 index 000..95d8ca3 --- /dev/null +++ b/drivers/gpio/gpio-dln2.c @@ -0,0 +1,554 @@ +/* + * Driver for the Diolan DLN-2 USB-GPIO adapter + * + * Copyright (c) 2014 Intel Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2. + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/slab.h +#include linux/types.h +#include linux/irqdomain.h +#include linux/irq.h +#include linux/irqchip/chained_irq.h +#include linux/gpio.h +#include linux/gpio/driver.h +#include linux/platform_device.h +#include linux/mfd/dln2.h + +#define DLN2_GPIO_ID 0x01 + +#define DLN2_GPIO_GET_PORT_COUNT DLN2_CMD(0x00, DLN2_GPIO_ID) +#define DLN2_GPIO_GET_PIN_COUNTDLN2_CMD(0x01, DLN2_GPIO_ID) +#define DLN2_GPIO_SET_DEBOUNCE DLN2_CMD(0x04, DLN2_GPIO_ID) +#define DLN2_GPIO_GET_DEBOUNCE DLN2_CMD(0x05, DLN2_GPIO_ID) +#define DLN2_GPIO_PORT_GET_VAL DLN2_CMD(0x06, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_GET_VAL DLN2_CMD(0x0B, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_SET_OUT_VAL DLN2_CMD(0x0C, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_GET_OUT_VAL DLN2_CMD(0x0D, DLN2_GPIO_ID) +#define DLN2_GPIO_CONDITION_MET_EV DLN2_CMD(0x0F, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_ENABLE DLN2_CMD(0x10, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_DISABLE DLN2_CMD(0x11, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_SET_DIRECTIONDLN2_CMD(0x13, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_GET_DIRECTIONDLN2_CMD(0x14, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_SET_EVENT_CFGDLN2_CMD(0x1E, DLN2_GPIO_ID) +#define DLN2_GPIO_PIN_GET_EVENT_CFGDLN2_CMD(0x1F, DLN2_GPIO_ID) + +#define DLN2_GPIO_EVENT_NONE 0 +#define DLN2_GPIO_EVENT_CHANGE 1 +#define DLN2_GPIO_EVENT_LVL_HIGH 2 +#define DLN2_GPIO_EVENT_LVL_LOW3 +#define DLN2_GPIO_EVENT_CHANGE_RISING 0x11 +#define DLN2_GPIO_EVENT_CHANGE_FALLING 0x21 +#define DLN2_GPIO_EVENT_MASK 0x0F + +#define DLN2_GPIO_MAX_PINS 32 + +struct dln2_irq_work { + struct work_struct work; + struct dln2_gpio *dln2; + int pin; + int type; +}; + +struct dln2_gpio { + struct platform_device *pdev; + struct gpio_chip gpio; + + /* +* Cache pin direction to save us one transfer, since the +* hardware has separate commands to read the in and out +* values. Bit set for out, bit clear for in. +*/ + DECLARE_BITMAP(pin_dir, DLN2_GPIO_MAX_PINS); + + DECLARE_BITMAP(irqs_masked, DLN2_GPIO_MAX_PINS); + DECLARE_BITMAP(irqs_enabled, DLN2_GPIO_MAX_PINS); + DECLARE_BITMAP(irqs_pending, DLN2_GPIO_MAX_PINS); + struct dln2_irq_work *irq_work; +}; + +struct dln2_gpio_pin { + __le16 pin; +} __packed; + +struct dln2_gpio_pin_val { + __le16 pin; + u8 value; +} __packed; + +static int dln2_gpio_get_pin_count(struct platform_device *pdev) +{ +
Re: [PATCH v6 1/5] usb: gadget: pxa27x_udc: prepare device-tree support
Hi, On Fri, Sep 19, 2014 at 09:46:22PM +0200, Robert Jarzmik wrote: The pxa27x_udc should support 2 modes of initialization : - one through legacy platform data - one new through device-tree Prepare the double support by moving the initialization data, ie. the gpios, into the udc control structure. Signed-off-by: Robert Jarzmik robert.jarz...@free.fr --- Since v5: This new patch, split out of the first DT patch please resend once v3.18-rc1 is out. But... - if (gpio_is_valid(udc-mach-gpio_pullup)) - gpio_set_value(udc-mach-gpio_pullup, -!udc-mach-gpio_pullup_inverted); - if (udc-mach-udc_command) + if (gpio_is_valid(udc-gpio_pullup)) you might want to add a patch converting to gpio_desc -- balbi signature.asc Description: Digital signature
Re: [PATCH v6 1/5] usb: gadget: pxa27x_udc: prepare device-tree support
Felipe Balbi ba...@ti.com writes: On Fri, Sep 19, 2014 at 09:46:22PM +0200, Robert Jarzmik wrote: Since v5: This new patch, split out of the first DT patch please resend once v3.18-rc1 is out. But... There are 2 -rc left for v3.17, can't this serie make it for 3.18 merge window ? +if (gpio_is_valid(udc-gpio_pullup)) you might want to add a patch converting to gpio_desc Not in this serie, that's another topic. Cheers. -- Robert -- 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
Take dwc2 driver through Felipe's tree?
Hi Greg, How would you feel about Felipe taking the dwc2 driver into his tree? There has been quite a bit of increased activity with dwc2 lately, and I know you already have more than enough stuff on your plate already. So this would mean one less thing for you to worry about. Plus it would mean an extra layer of review before getting to you. I've already talked to Felipe about it, and he's fine with it. If you're OK with it, I think I just need to send a patch adding a T: line to the MAINTAINERS entry, showing Felipe's tree? I guess we would want to do this just before you close your USB tree, and you could announce it then? -- Paul -- 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: Take dwc2 driver through Felipe's tree?
On Fri, Sep 19, 2014 at 08:52:07PM +, Paul Zimmerman wrote: Hi Greg, How would you feel about Felipe taking the dwc2 driver into his tree? There has been quite a bit of increased activity with dwc2 lately, and I know you already have more than enough stuff on your plate already. So this would mean one less thing for you to worry about. Plus it would mean an extra layer of review before getting to you. I've already talked to Felipe about it, and he's fine with it. If you're OK with it, I think I just need to send a patch adding a T: line to the MAINTAINERS entry, showing Felipe's tree? I guess we would want to do this just before you close your USB tree, and you could announce it then? No objection from me. I'm working in my patch backlog right now, should get through them by the end of the day, so feel free to send me a MAINTAINERS patch I can use. thanks, greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 1/5] usb: gadget: pxa27x_udc: prepare device-tree support
Hi, On Fri, Sep 19, 2014 at 10:48:25PM +0200, Robert Jarzmik wrote: Felipe Balbi ba...@ti.com writes: On Fri, Sep 19, 2014 at 09:46:22PM +0200, Robert Jarzmik wrote: Since v5: This new patch, split out of the first DT patch please resend once v3.18-rc1 is out. But... There are 2 -rc left for v3.17, can't this serie make it for 3.18 merge window ? not anymore. My tree is already closed for v3.18. A bit early, yeah, but I'm busy with other stuff. + if (gpio_is_valid(udc-gpio_pullup)) you might want to add a patch converting to gpio_desc Not in this serie, that's another topic. oh, it can definitely be on this series. Just make it patch one. -- balbi signature.asc Description: Digital signature
Re: Take dwc2 driver through Felipe's tree?
On Fri, Sep 19, 2014 at 02:01:50PM -0700, gre...@linuxfoundation.org wrote: On Fri, Sep 19, 2014 at 08:52:07PM +, Paul Zimmerman wrote: Hi Greg, How would you feel about Felipe taking the dwc2 driver into his tree? There has been quite a bit of increased activity with dwc2 lately, and I know you already have more than enough stuff on your plate already. So this would mean one less thing for you to worry about. Plus it would mean an extra layer of review before getting to you. I've already talked to Felipe about it, and he's fine with it. If you're OK with it, I think I just need to send a patch adding a T: line to the MAINTAINERS entry, showing Felipe's tree? I guess we would want to do this just before you close your USB tree, and you could announce it then? No objection from me. I'm working in my patch backlog right now, should get through them by the end of the day, so feel free to send me a MAINTAINERS patch I can use. alright, it's all set now. Starting on v3.18-rc, I'll start taking dwc2 on my tree. -- balbi signature.asc Description: Digital signature
[PATCH] usb: dwc2: add T: line to MAINTAINERS showing Felipe's tree
Starting with v3.18-rc, patches for dwc2 will go through Felipe's tree. Add a T: line to MAINTAINERS to document this. Signed-off-by: Paul Zimmerman pa...@synopsys.com --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 809ecd6..bffd59c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2848,6 +2848,7 @@ F:drivers/platform/x86/dell-wmi.c DESIGNWARE USB2 DRD IP DRIVER M: Paul Zimmerman pa...@synopsys.com L: linux-usb@vger.kernel.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git S: Maintained F: drivers/usb/dwc2/ -- 2.1.0.24.g4109c28 -- 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: [GIT PULL v2] USB changes for v3.18 merge window
On Thu, Sep 18, 2014 at 09:46:11AM -0500, Felipe Balbi wrote: Hi Greg, Here you go. This one should be good to go. Sorry for the last minute change but it was better to revert those patches than having a broken v3.17 final. Let me know if you want any changes. cheers The following changes since commit 9e82bf014195d6f0054982c463575cdce24292be: Linux 3.17-rc5 (2014-09-14 17:50:12 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git tags/usb-for-v3.18 Pulled and pushed out, thanks. greg k-h -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: add T: line to MAINTAINERS showing Felipe's tree
On Fri, Sep 19, 2014 at 02:49:36PM -0700, Paul Zimmerman wrote: Starting with v3.18-rc, patches for dwc2 will go through Felipe's tree. Add a T: line to MAINTAINERS to document this. Signed-off-by: Paul Zimmerman pa...@synopsys.com Now applied. I've caught up with all pending dwc2 patches that I know of. If I've missed any, please resend. 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