[PATCH v4 4/5] xhci: mediatek: support MTK xHCI host controller
MTK xhci host controller defines some extra SW scheduling parameters for HW to minimize the scheduling effort for synchronous and interrupt endpoints. The parameters are put into reseved DWs of slot context and endpoint context Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- drivers/usb/host/Kconfig| 9 + drivers/usb/host/Makefile | 4 + drivers/usb/host/xhci-mtk-sch.c | 436 + drivers/usb/host/xhci-mtk.c | 836 drivers/usb/host/xhci-mtk.h | 135 +++ drivers/usb/host/xhci-ring.c| 35 +- drivers/usb/host/xhci.c | 19 +- drivers/usb/host/xhci.h | 1 + 8 files changed, 1468 insertions(+), 7 deletions(-) create mode 100644 drivers/usb/host/xhci-mtk-sch.c create mode 100644 drivers/usb/host/xhci-mtk.c create mode 100644 drivers/usb/host/xhci-mtk.h diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 8afc3c1..358ab6d 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -34,6 +34,15 @@ config USB_XHCI_PCI config USB_XHCI_PLATFORM tristate +config USB_XHCI_MTK + tristate xHCI support for Mediatek MT65xx + select MFD_SYSCON + depends on ARCH_MEDIATEK || COMPILE_TEST + ---help--- + Say 'Y' to enable the support for the xHCI host controller + found in Mediatek MT65xx SoCs. + If unsure, say N. + config USB_XHCI_MVEBU tristate xHCI support for Marvell Armada 375/38x select USB_XHCI_PLATFORM diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 754efaa..00401f9 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -13,6 +13,9 @@ fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o xhci-hcd-y := xhci.o xhci-mem.o xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o xhci-hcd-y += xhci-trace.o +ifneq ($(CONFIG_USB_XHCI_MTK), ) + xhci-hcd-y += xhci-mtk-sch.o +endif xhci-plat-hcd-y := xhci-plat.o ifneq ($(CONFIG_USB_XHCI_MVEBU), ) @@ -30,6 +33,7 @@ endif obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o +obj-$(CONFIG_USB_XHCI_MTK) += xhci-mtk.o obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c new file mode 100644 index 000..d4b41a6 --- /dev/null +++ b/drivers/usb/host/xhci-mtk-sch.c @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: + * Zhigang.Wei zhigang@mediatek.com + * Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/slab.h + +#include xhci.h +#include xhci-mtk.h + +#define SS_BW_BOUNDARY 51000 +/* table 5-5. High-speed Isoc Transaction Limits in usb_20 spec */ +#define HS_BW_BOUNDARY 6144 +/* usb2 spec section11.18.1: at most 188 FS bytes per microframe */ +#define FS_PAYLOAD_MAX 188 + +/* mtk scheduler bitmasks */ +#define EP_BPKTS(p)((p) 0x3f) +#define EP_BCSCOUNT(p) (((p) 0x7) 8) +#define EP_BBM(p) ((p) 11) +#define EP_BOFFSET(p) ((p) 0x3fff) +#define EP_BREPEAT(p) (((p) 0x7fff) 16) + +static int is_fs_or_ls(enum usb_device_speed speed) +{ + return speed == USB_SPEED_FULL || speed == USB_SPEED_LOW; +} + +static int get_bw_index(struct xhci_hcd *xhci, struct usb_device *udev, + struct usb_host_endpoint *ep) +{ + int bw_index; + int port_id; + struct xhci_virt_device *virt_dev; + + virt_dev = xhci-devs[udev-slot_id]; + port_id = virt_dev-real_port; + + if (udev-speed == USB_SPEED_SUPER) { + if (usb_endpoint_dir_out(ep-desc)) + bw_index = (port_id - 1) * 2; + else + bw_index = (port_id - 1) * 2 + 1; + } else { + bw_index = port_id + xhci-num_usb3_ports - 1; + } + + return bw_index; +} + +static void setup_sch_info(struct usb_device *udev, + struct xhci_ep_ctx *ep_ctx, struct mu3h_sch_ep_info *sch_ep) +{ + u32 ep_type; + u32 ep_interval; + u32 max_packet_size; + u32 max_burst; + u32 mult; + u32 esit_pkts; + + ep_type = CTX_TO_EP_TYPE(le32_to_cpu(ep_ctx-ep_info2)); + ep_interval = CTX_TO_EP_INTERVAL(le32_to_cpu(ep_ctx-ep_info)); + max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx-ep_info2)); + max_burst = CTX_TO_MAX_BURST(le32_to_cpu(ep_ctx-ep_info2)); + mult =
[PATCH v4 5/5] arm64: dts: mediatek: add xHCI usb phy for mt8173
add xHCI and phy drivers for MT8173-EVB Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 17 + arch/arm64/boot/dts/mediatek/mt8173.dtsi| 29 + 2 files changed, 46 insertions(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts index f433c21..f9bbabd 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts +++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts @@ -13,6 +13,7 @@ */ /dts-v1/; +#include dt-bindings/gpio/gpio.h #include mt8173.dtsi / { @@ -32,6 +33,15 @@ }; chosen { }; + + usb_p1_vbus: regulator@0 { + compatible = regulator-fixed; + regulator-name = usb_vbus; + regulator-min-microvolt = 500; + regulator-max-microvolt = 500; + gpio = pio 130 GPIO_ACTIVE_HIGH; + enable-active-high; + }; }; pwrap { @@ -211,3 +221,10 @@ uart0 { status = okay; }; + +usb { + vusb33-supply = mt6397_vusb_reg; + vbus-supply = usb_p1_vbus; + mediatek,wakeup-src = 1; + mediatek,u2port-num = 2; +}; diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 0696f8f..8fa9ae8 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -14,6 +14,7 @@ #include dt-bindings/clock/mt8173-clk.h #include dt-bindings/interrupt-controller/irq.h #include dt-bindings/interrupt-controller/arm-gic.h +#include dt-bindings/power/mt8173-power.h #include dt-bindings/reset-controller/mt8173-resets.h #include mt8173-pinfunc.h @@ -393,6 +394,34 @@ #size-cells = 0; status = disabled; }; + + usb: usb@1127 { + compatible = mediatek,mt8173-xhci; + reg = 0 0x1127 0 0x4000, + 0 0x1128 0 0x0800; + interrupts = GIC_SPI 115 IRQ_TYPE_LEVEL_LOW; + power-domains = scpsys MT8173_POWER_DOMAIN_USB; + clocks = topckgen CLK_TOP_USB30_SEL, +pericfg CLK_PERI_USB0, +pericfg CLK_PERI_USB1; + clock-names = sys_mac, + wakeup_deb_p0, + wakeup_deb_p1; + phys = u3phy 0, u3phy 1; + phy-names = usb-phy0, usb-phy1; + usb3-lpm-capable; + mediatek,usb-wakeup = pericfg; + status = okay; + }; + + u3phy: usb-phy@1129 { + compatible = mediatek,mt8173-u3phy; + reg = 0 0x1129 0 0x3000; + clocks = apmixedsys CLK_APMIXED_REF2USB_TX; + clock-names = u3phya_ref; + #phy-cells = 1; + status = okay; + }; }; }; -- 1.8.1.1.dirty -- 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 05/46] usb: chipidea: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/chipidea/udc.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index b7cca3e..4aaa476 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1624,6 +1624,20 @@ static int init_eps(struct ci_hdrc *ci) hwep-ep.name = hwep-name; hwep-ep.ops = usb_ep_ops; + + if (i == 0) { + hwep-ep.caps.type_control = true; + } else { + hwep-ep.caps.type_iso = true; + hwep-ep.caps.type_bulk = true; + hwep-ep.caps.type_int = true; + } + + if (j == TX) + hwep-ep.caps.dir_in = true; + else + hwep-ep.caps.dir_out = true; + /* * for ep0: maxP defined in desc, for other * eps, maxP is set by epautoconfig() called -- 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 36/46] usb: gadget: atmel_usba_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 37d414e..267d84f 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2067,6 +2067,17 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, ep-can_dma = pdata-ep[i].can_dma; ep-can_isoc = pdata-ep[i].can_isoc; + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = ep-can_isoc; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + if (i) list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } -- 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 34/46] usb: musb: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/musb/musb_gadget.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 9e18178..4150baf 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1729,6 +1729,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) INIT_LIST_HEAD(ep-end_point.ep_list); if (!epnum) { usb_ep_set_maxpacket_limit(ep-end_point, 64); + ep-end_point.caps.type_control = true; ep-end_point.ops = musb_g_ep0_ops; musb-g.ep0 = ep-end_point; } else { @@ -1736,9 +1737,20 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_tx); else usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_rx); + ep-end_point.caps.type_iso = true; + ep-end_point.caps.type_bulk = true; + ep-end_point.caps.type_int = true; ep-end_point.ops = musb_ep_ops; list_add_tail(ep-end_point.ep_list, musb-g.ep_list); } + + if (!epnum || hw_ep-is_shared_fifo) { + ep-end_point.caps.dir_in = true; + ep-end_point.caps.dir_out = true; + } else if (is_in) + ep-end_point.caps.dir_in = true; + else + ep-end_point.caps.dir_out = true; } /* -- 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 37/46] usb: gadget: epautoconf: add endpoint capabilities flags verification
Introduce endpoint matching mechanism basing on endpoint capabilities flags. We check if endpoint supports transfer type and direction requested in ep descriptor. Since we have this new endpoint matching mechanism there is no need to have old code guessing endpoint capabilities basing on its name, so we are getting rid of it. Remove also the obsolete comment. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 96 + 1 file changed, 30 insertions(+), 66 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 8e00ca7..af4b10a 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,22 +22,6 @@ #include gadget_chips.h -/* - * This should work with endpoints from controller drivers sharing the - * same endpoint naming convention. By example: - * - * - ep1, ep2, ... address is fixed, not direction or type - * - ep1in, ep2out, ... address and direction are fixed, not type - * - ep1-bulk, ep2-bulk, ... address and type are fixed, not direction - * - ep1in-bulk, ep2out-iso, ... all three are fixed - * - ep-* ... no functionality restrictions - * - * Type suffixes are -bulk, -iso, or -int. Numbers are decimal. - * Less common restrictions are implied by gadget_is_*(). - * - * NOTE: each endpoint is unidirectional, as specified by its USB - * descriptor; and isn't specific to a configuration or altsetting. - */ static int ep_matches ( struct usb_gadget *gadget, @@ -47,7 +31,6 @@ ep_matches ( ) { u8 type; - const char *tmp; u16 max; int num_req_streams = 0; @@ -56,58 +39,39 @@ ep_matches ( if (ep-claimed) return 0; - /* only support ep0 for portable CONTROL traffic */ type = usb_endpoint_type(desc); - if (USB_ENDPOINT_XFER_CONTROL == type) - return 0; - - /* some other naming convention */ - if ('e' != ep-name[0]) + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + /* only support ep0 for portable CONTROL traffic */ return 0; + case USB_ENDPOINT_XFER_ISOC: + if (!ep-caps.type_iso) + return 0; + break; + case USB_ENDPOINT_XFER_BULK: + if (!ep-caps.type_bulk) + return 0; + break; + case USB_ENDPOINT_XFER_INT: + /* bulk endpoints handle interrupt transfers, +* except the toggle-quirky iso-synch kind +*/ + if (!ep-caps.type_int !ep-caps.type_bulk) + return 0; + /* for now, avoid PXA interrupt-in; +* it's documented as never using DATA1. +*/ + if (gadget_is_pxa(gadget) ep-caps.type_int) + return 0; + break; + } - /* type-restriction: -iso, -bulk, or -int. -* direction-restriction: in, out. -*/ - if ('-' != ep-name[2]) { - tmp = strrchr (ep-name, '-'); - if (tmp) { - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, -* except the toggle-quirky iso-synch kind -*/ - if ('s' == tmp[2]) // == -iso - return 0; - /* for now, avoid PXA interrupt-in; -* it's documented as never using DATA1. -*/ - if (gadget_is_pxa (gadget) -'i' == tmp [1]) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if ('b' != tmp[1]) // != -bulk - return 0; - break; - case USB_ENDPOINT_XFER_ISOC: - if ('s' != tmp[2]) // != -iso - return 0; - } - } else { - tmp = ep-name + strlen (ep-name); - } - - /* direction-restriction: ..in-.., out-.. */ - tmp--; - if (!isdigit (*tmp)) { - if (desc-bEndpointAddress USB_DIR_IN) { - if ('n' != *tmp) - return 0; - } else { - if ('t' != *tmp) - return 0; -
[PATCH v5 29/46] usb: gadget: r8a66597-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/r8a66597-udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 0293f71..baa0609 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1935,6 +1935,16 @@ static int r8a66597_probe(struct platform_device *pdev) ep-ep.name = r8a66597_ep_name[i]; ep-ep.ops = r8a66597_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(r8a66597-ep[0].ep, 64); r8a66597-ep[0].pipenum = 0; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 28/46] usb: gadget: pxa27x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa27x_udc.h | 40 +++-- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h index 11e1423..cea2cb7 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.h +++ b/drivers/usb/gadget/udc/pxa27x_udc.h @@ -234,25 +234,35 @@ /* * Endpoint definition helpers */ -#define USB_EP_DEF(addr, bname, dir, type, maxpkt) \ -{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, }, \ +#define USB_EP_DEF(addr, bname, dir, type, maxpkt, ctype, cdir) \ +{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, \ + .caps = USB_EP_CAPS(ctype, cdir), }, \ .desc = {.bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ - .bmAttributes = type, \ + .bmAttributes = USB_ENDPOINT_XFER_ ## type, \ .wMaxPacketSize = maxpkt, }, \ .dev = memory \ } -#define USB_EP_BULK(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE) -#define USB_EP_ISO(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE) -#define USB_EP_INT(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE) -#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1) -#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0) -#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1) -#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0) -#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1) -#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, 0, EP0_FIFO_SIZE) +#define USB_EP_BULK(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, BULK, BULK_FIFO_SIZE, \ + USB_EP_CAPS_TYPE_BULK, cdir) +#define USB_EP_ISO(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, ISOC, ISO_FIFO_SIZE, \ + USB_EP_CAPS_TYPE_ISO, cdir) +#define USB_EP_INT(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, INT, INT_FIFO_SIZE, \ + USB_EP_CAPS_TYPE_INT, cdir) +#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1, \ + USB_EP_CAPS_DIR_IN) +#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0, \ + USB_EP_CAPS_DIR_OUT) +#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1, \ + USB_EP_CAPS_DIR_IN) +#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0, \ + USB_EP_CAPS_DIR_OUT) +#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1, \ + USB_EP_CAPS_DIR_IN) +#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, CONTROL, EP0_FIFO_SIZE, \ + USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL) #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ { \ -- 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 33/46] usb: isp1760: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/isp1760/isp1760-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 3699962..1c3d0fd 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c @@ -1383,13 +1383,24 @@ static void isp1760_udc_init_eps(struct isp1760_udc *udc) */ if (ep_num == 0) { usb_ep_set_maxpacket_limit(ep-ep, 64); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-maxpacket = 64; udc-gadget.ep0 = ep-ep; } else { usb_ep_set_maxpacket_limit(ep-ep, 512); + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; ep-maxpacket = 0; list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } + + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; } } -- 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 30/46] usb: gadget: s3c-hsudc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c-hsudc.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c index 85a712a..e9def42 100644 --- a/drivers/usb/gadget/udc/s3c-hsudc.c +++ b/drivers/usb/gadget/udc/s3c-hsudc.c @@ -1005,6 +1005,21 @@ static void s3c_hsudc_initep(struct s3c_hsudc *hsudc, hsep-stopped = 0; hsep-wedge = 0; + if (epnum == 0) { + hsep-ep.caps.type_control = true; + hsep-ep.caps.dir_in = true; + hsep-ep.caps.dir_out = true; + } else { + hsep-ep.caps.type_iso = true; + hsep-ep.caps.type_bulk = true; + hsep-ep.caps.type_int = true; + } + + if (epnum 1) + hsep-ep.caps.dir_in = true; + else + hsep-ep.caps.dir_out = true; + set_index(hsudc, epnum); writel(hsep-ep.maxpacket, hsudc-regs + S3C_MPR); } -- 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 32/46] usb: gadget: udc-xilinx: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/udc-xilinx.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 1f24274..1cbb0ac 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -1317,12 +1317,21 @@ static void xudc_eps_init(struct xusb_udc *udc) snprintf(ep-name, EPNAME_SIZE, ep%d, ep_number); ep-ep_usb.name = ep-name; ep-ep_usb.ops = xusb_ep_ops; + + ep-ep_usb.caps.type_iso = true; + ep-ep_usb.caps.type_bulk = true; + ep-ep_usb.caps.type_int = true; } else { ep-ep_usb.name = ep0name; usb_ep_set_maxpacket_limit(ep-ep_usb, EP0_MAX_PACKET); ep-ep_usb.ops = xusb_ep0_ops; + + ep-ep_usb.caps.type_control = true; } + ep-ep_usb.caps.dir_in = true; + ep-ep_usb.caps.dir_out = true; + ep-udc = udc; ep-epnumber = ep_number; ep-desc = NULL; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs
hi Ricky, On Mon, 2015-07-27 at 21:58 +0800, Ricky Liang wrote: Hi Chungfeng, Comments inline. On Wed, Jul 22, 2015 at 10:05 PM, Chunfeng Yun chunfeng@mediatek.com wrote: support usb3.0 phy of mt65xx SoCs Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 426 ++ 3 files changed, 436 insertions(+) create mode 100644 drivers/phy/phy-mt65xx-usb3.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c0e6ede..019cf8b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -193,6 +193,15 @@ config PHY_HIX5HD2_SATA help Support for SATA PHY on Hisilicon hix5hd2 Soc. +config PHY_MT65XX_USB3 + tristate Mediatek USB3.0 PHY Driver + depends on ARCH_MEDIATEK OF + select GENERIC_PHY + help + Say 'Y' here to add support for Mediatek USB3.0 PHY driver + for mt65xx SoCs. it supports two usb2.0 ports and + one usb3.0 port. + config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f344e1b..3ceff2a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_TI_PIPE3)+= phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o +obj-$(CONFIG_PHY_MT65XX_USB3) += phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB)+= phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB)+= phy-sun9i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c new file mode 100644 index 000..5da4534 --- /dev/null +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/module.h +#include linux/of_address.h +#include linux/of_device.h +#include linux/of_gpio.h +#include linux/of.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/regulator/consumer.h +#include linux/resource.h + +/* + * for sifslv2 register + * relative to USB3_SIF2_BASE base address + */ +#define SSUSB_SIFSLV_SPLLC (0x) +#define SSUSB_SIFSLV_U2PHY_COM_BASE(0x0800) +#define SSUSB_SIFSLV_U3PHYD_BASE (0x0900) +#define SSUSB_USB30_PHYA_SIV_B_BASE(0x0b00) +#define SSUSB_SIFSLV_U3PHYA_DA_BASE(0x0c00) You don't need () here. Same for all following numeric constants. Ok, I will delete them. + +/*port1 refs. +0x800(refer to port0)*/ +#define U3P_PORT_INTERVAL (0x800) /*based on port0 */ +#define U3P_PHY_DELTA(index) ((U3P_PORT_INTERVAL) * (index)) Indent with tab. It might also be a good idea to align the indentations of all the macros. OK + +#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +#define PA0_RG_U2PLL_FORCE_ON (0x1 15) Use BIT() instead? Same for all following (0x1 xx) macros. I'll do it. thanks. + +#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define PA2_RG_SIF_U2PLL_FORCE_EN (0x1 18) + +#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define PA5_RG_U2_HSTX_SRCTRL (0x7 12) +#define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 (x)) 12) +#define PA5_RG_U2_HS_100U_U3_EN(0x1 11) + +#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define PA6_RG_U2_ISO_EN (0x1 31) +#define PA6_RG_U2_BC11_SW_EN (0x1 23) +#define PA6_RG_U2_OTG_VBUSCMP_EN (0x1 20) + +#define U3P_U2PHYACR4 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define P2C_RG_USB20_GPIO_CTL (0x1 9) +#define P2C_USB20_GPIO_MODE(0x1 8) +#define P2C_U2_GPIO_CTR_MSK(P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) + +#define U3D_U2PHYDCR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0060) +#define P2C_RG_SIF_U2PLL_FORCE_ON (0x1 24) + +#define U3P_U2PHYDTM0
[PATCH v5 06/46] usb: dwc2: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc2/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 731b13d..3ee5b4c 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3289,6 +3289,19 @@ static void s3c_hsotg_initep(struct dwc2_hsotg *hsotg, usb_ep_set_maxpacket_limit(hs_ep-ep, epnum ? 1024 : EP0_MPS_LIMIT); hs_ep-ep.ops = s3c_hsotg_ep_ops; + if (epnum == 0) { + hs_ep-ep.caps.type_control = true; + } else { + hs_ep-ep.caps.type_iso = true; + hs_ep-ep.caps.type_bulk = true; + hs_ep-ep.caps.type_int = true; + } + + if (dir_in) + hs_ep-ep.caps.dir_in = true; + else + hs_ep-ep.caps.dir_out = true; + /* * if we're using dma, we need to set the next-endpoint pointer * to be something valid. -- 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 04/46] staging: emxx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Fixed typo in epc-nulk to epc-bulk. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/staging/emxx_udc/emxx_udc.c | 73 + 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 3b7aa36..b6b76ff 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -3153,36 +3153,46 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops = { .ioctl = nbu2ss_gad_ioctl, }; -static const char g_ep0_name[] = ep0; -static const char g_ep1_name[] = ep1-bulk; -static const char g_ep2_name[] = ep2-bulk; -static const char g_ep3_name[] = ep3in-int; -static const char g_ep4_name[] = ep4-iso; -static const char g_ep5_name[] = ep5-iso; -static const char g_ep6_name[] = ep6-bulk; -static const char g_ep7_name[] = ep7-bulk; -static const char g_ep8_name[] = ep8in-int; -static const char g_ep9_name[] = ep9-iso; -static const char g_epa_name[] = epa-iso; -static const char g_epb_name[] = epb-bulk; -static const char g_epc_name[] = epc-nulk; -static const char g_epd_name[] = epdin-int; - -static const char *gp_ep_name[NUM_ENDPOINTS] = { - g_ep0_name, - g_ep1_name, - g_ep2_name, - g_ep3_name, - g_ep4_name, - g_ep5_name, - g_ep6_name, - g_ep7_name, - g_ep8_name, - g_ep9_name, - g_epa_name, - g_epb_name, - g_epc_name, - g_epd_name, +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[NUM_ENDPOINTS] = { +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + + EP_INFO(ep0, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep1-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep2-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep3in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep4-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep5-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep6-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep7-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep8in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep9-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), + EP_INFO(epa-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), + EP_INFO(epb-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(epc-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), + EP_INFO(epdin-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + +#undef EP_INFO }; /*-*/ @@ -3200,7 +3210,8 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) ep-desc = NULL; ep-ep.driver_data = NULL; - ep-ep.name = gp_ep_name[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = nbu2ss_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, -- 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 v4 1/5] dt-bindings: Add usb3.0 phy binding for MT65xx SoCs
add a DT binding documentation of usb3.0 phy for MT65xx SoCs from Mediatek. Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 21 + 1 file changed, 21 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt new file mode 100644 index 000..752abc0 --- /dev/null +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -0,0 +1,21 @@ +MT65xx USB3.0 PHY + +The device node for Mediatek SOC usb3.0 phy + +Required properties: + - compatible : Should be mediatek,mt8173-u3phy + - reg: Offset and length of registers for phy domain + - clocks : must support all clocks that phy need + - clock-names: should be u3phya_ref for u3phya reference clock. + - #phy-cells : must be 1 for the phy + +Example: + +u3phy: usb-phy@1129 { + compatible = mediatek,mt8173-u3phy; + reg = 0 0x1129 0 0x3000; + clocks = apmixedsys CLK_APMIXED_REF2USB_TX; + clock-names = u3phya_ref; + #phy-cells = 1; + status = okay; +}; -- 1.8.1.1.dirty -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs
support usb3.0 phy of mt65xx SoCs Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 419 ++ 3 files changed, 429 insertions(+) create mode 100644 drivers/phy/phy-mt65xx-usb3.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c0e6ede..019cf8b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -193,6 +193,15 @@ config PHY_HIX5HD2_SATA help Support for SATA PHY on Hisilicon hix5hd2 Soc. +config PHY_MT65XX_USB3 + tristate Mediatek USB3.0 PHY Driver + depends on ARCH_MEDIATEK OF + select GENERIC_PHY + help + Say 'Y' here to add support for Mediatek USB3.0 PHY driver + for mt65xx SoCs. it supports two usb2.0 ports and + one usb3.0 port. + config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f344e1b..3ceff2a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_TI_PIPE3)+= phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o +obj-$(CONFIG_PHY_MT65XX_USB3) += phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB)+= phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB)+= phy-sun9i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c new file mode 100644 index 000..1d2f2e0 --- /dev/null +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/module.h +#include linux/phy/phy.h +#include linux/platform_device.h + +/* + * for sifslv2 register + * relative to USB3_SIF2_BASE base address + */ +#define SSUSB_SIFSLV_SPLLC 0x +#define SSUSB_SIFSLV_U2PHY_COM_BASE0x0800 +#define SSUSB_SIFSLV_U3PHYD_BASE 0x0900 +#define SSUSB_USB30_PHYA_SIV_B_BASE0x0b00 +#define SSUSB_SIFSLV_U3PHYA_DA_BASE0x0c00 + +/*port1 refs. +0x800(refer to port0)*/ +#define U3P_PORT_INTERVAL 0x800 /*based on port0 */ +#define U3P_PHY_DELTA(index) ((U3P_PORT_INTERVAL) * (index)) + +#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +#define PA0_RG_U2PLL_FORCE_ON BIT(15) + +#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define PA2_RG_SIF_U2PLL_FORCE_EN BIT(18) + +#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define PA5_RG_U2_HSTX_SRCTRL (0x7 12) +#define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 (x)) 12) +#define PA5_RG_U2_HS_100U_U3_ENBIT(11) + +#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define PA6_RG_U2_ISO_EN BIT(31) +#define PA6_RG_U2_BC11_SW_EN BIT(23) +#define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) + +#define U3P_U2PHYACR4 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define P2C_RG_USB20_GPIO_CTL BIT(9) +#define P2C_USB20_GPIO_MODEBIT(8) +#define P2C_U2_GPIO_CTR_MSK(P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) + +#define U3D_U2PHYDCR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0060) +#define P2C_RG_SIF_U2PLL_FORCE_ON BIT(24) + +#define U3P_U2PHYDTM0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0068) +#define P2C_FORCE_UART_EN BIT(26) +#define P2C_FORCE_DATAIN BIT(23) +#define P2C_FORCE_DM_PULLDOWN BIT(21) +#define P2C_FORCE_DP_PULLDOWN BIT(20) +#define P2C_FORCE_XCVRSEL BIT(19) +#define P2C_FORCE_SUSPENDM BIT(18) +#define P2C_FORCE_TERMSEL BIT(17) +#define P2C_RG_DATAIN (0xf 10) +#define P2C_RG_DATAIN_VAL(x) ((0xf (x)) 10) +#define P2C_RG_DMPULLDOWN BIT(7) +#define P2C_RG_DPPULLDOWN BIT(6) +#define P2C_RG_XCVRSEL (0x3 4) +#define P2C_RG_XCVRSEL_VAL(x) ((0x3 (x)) 4) +#define P2C_RG_SUSPENDMBIT(3) +#define P2C_RG_TERMSEL BIT(2) +#define P2C_DTM0_PART_MASK \ + (P2C_FORCE_DATAIN |
Mediatek xHCI support
From 8babf12102cda26752771c1aebd0aff38514847f Mon Sep 17 00:00:00 2001 From: Chunfeng Yun chunfeng@mediatek.com Date: Fri, 31 Jul 2015 20:44:17 +0800 Subject: [PATCH v4 0/5] Mediatek xHCI support The patch supports MediaTek's xHCI controller. There are some differences from xHCI spec: 1. The interval is specified in 250 * 8ns increments for Interrupt Moderation Interval(IMODI) of the Interrupter Moderation(IMOD) register, it is 8 times as much as that defined in xHCI spec. 2. For the value of TD Size in Normal TRB, MTK's xHCI controller defines a number of packets that remain to be transferred for a TD after processing all Max packets in all previous TRBs,that means don't include the current TRB's, but in xHCI spec it includes the current ones. 3. To minimize the scheduling effort for synchronous endpoints in xHC, the MTK architecture defines some extra SW scheduling parameters for HW. According to these parameters provided by SW, the xHC can easily decide whether a synchronous endpoint should be scheduled in a specific uFrame. The extra SW scheduling parameters are put into reserved DWs in Slot and Endpoint Context. And a bandwidth scheduler algorithm is added to support such feature. A usb3.0 phy driver is also added which used by mt65xx SoCs platform, it supports two usb2.0 ports and one usb3.0 port. Change in v4: 1. descripte more exactly for each specifiers in binding file 2. use BIT() to define a bit mask mcro Chunfeng Yun (5): dt-bindings: Add usb3.0 phy binding for MT65xx SoCs dt-bindings: Add a binding for Mediatek xHCI host controller usb: phy: add usb3.0 phy driver for mt65xx SoCs xhci: mediatek: support MTK xHCI host controller arm64: dts: mediatek: add xHCI usb phy for mt8173 .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 21 + .../devicetree/bindings/usb/mt8173-xhci.txt| 51 ++ arch/arm64/boot/dts/mediatek/mt8173-evb.dts| 17 + arch/arm64/boot/dts/mediatek/mt8173.dtsi | 29 + drivers/phy/Kconfig| 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 419 +++ drivers/usb/host/Kconfig | 9 + drivers/usb/host/Makefile | 4 + drivers/usb/host/xhci-mtk-sch.c| 436 +++ drivers/usb/host/xhci-mtk.c| 836 + drivers/usb/host/xhci-mtk.h| 135 drivers/usb/host/xhci-ring.c | 35 +- drivers/usb/host/xhci.c| 19 +- drivers/usb/host/xhci.h| 1 + 15 files changed, 2015 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt create mode 100644 Documentation/devicetree/bindings/usb/mt8173-xhci.txt create mode 100644 drivers/phy/phy-mt65xx-usb3.c create mode 100644 drivers/usb/host/xhci-mtk-sch.c create mode 100644 drivers/usb/host/xhci-mtk.c create mode 100644 drivers/usb/host/xhci-mtk.h -- 1.8.1.1.dirty -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/5] dt-bindings: Add a binding for Mediatek xHCI host controller
add a DT binding documentation of xHCI host controller for the MT8173 SoC from Mediatek. Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- .../devicetree/bindings/usb/mt8173-xhci.txt| 51 ++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mt8173-xhci.txt diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt new file mode 100644 index 000..364be5a --- /dev/null +++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt @@ -0,0 +1,51 @@ +MT65XX xhci + +The device node for Mediatek SOC usb3.0 host controller + +Required properties: + - compatible : Supports mediatek,mt8173-xhci + - reg : Specifies physical base address and size of the registers, + the first one for MAC, the second for IPPC + - interrupts : Interrupt mode, number and trigger mode + - power-domains : To enable usb's mtcmos + - vusb33-supply : Regulator of usb avdd3.3v + - clocks : Must support all clocks that xhci needs + - clock-names : Should be sys_mac for sys and mac clocks, and + wakeup_deb_p0, wakeup_deb_p1 for wakeup debounce control + clocks + - phys : List of PHY specifiers (used by generic PHY framework). + - phy-names : Must be usb-phy0, usb-phy1,.., usb-phyN, based on + the number of PHYs as specified in @phys property. + - usb3-lpm-capable : Supports USB3 LPM + - mediatek,usb-wakeup : To access usb wakeup control register + - mediatek,wakeup-src : 1: Ip sleep wakeup mode; 2: line state wakeup + mode; others means don't enable wakeup source of usb + - mediatek,u2port-num : The number should not greater than the number + of phys + +Optional properties: + - vbus-supply : Reference to the VBUS regulator; + +Example: +usb: usb@1127 { + compatible = mediatek,mt8173-xhci; + reg = 0 0x1127 0 0x4000, + 0 0x1128 0 0x0800; + interrupts = GIC_SPI 115 IRQ_TYPE_LEVEL_LOW; + power-domains = scpsys MT8173_POWER_DOMAIN_USB; + clocks = topckgen CLK_TOP_USB30_SEL, +pericfg CLK_PERI_USB0, +pericfg CLK_PERI_USB1; + clock-names = sys_mac, + wakeup_deb_p0, + wakeup_deb_p1; + phys = u3phy 0, u3phy 1; + phy-names = usb-phy0, usb-phy1; + vusb33-supply = mt6397_vusb_reg; + vbus-supply = usb_p1_vbus; + usb3-lpm-capable; + mediatek,usb-wakeup = pericfg; + mediatek,wakeup-src = 1; + mediatek,u2port-num = 2; + status = okay; +}; -- 1.8.1.1.dirty -- 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 41/46] usb: gadget: add 'ep_match' callback to usb_gadget_ops
Add callback that is called by epautoconf to allow UDC driver match the best endpoint for specific descriptor. It's intended to supply mechanism which allows to get rid of chip-specific endpoint matching code from epautoconf. If gadget has set 'ep_match' callback we prefer to call it first, and if it fails to find matching endpoint, then we try to use default matching algorithm. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 6 ++ include/linux/usb/gadget.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 4fa6f5d..1b1fee0 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -165,6 +165,12 @@ struct usb_ep *usb_ep_autoconfig_ss( type = desc-bmAttributes USB_ENDPOINT_XFERTYPE_MASK; + if (gadget-ops-match_ep) { + ep = gadget-ops-match_ep(gadget, desc, ep_comp); + if (ep) + goto found_ep; + } + /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 82b5bcb..303214b 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -534,6 +534,9 @@ struct usb_gadget_ops { int (*udc_start)(struct usb_gadget *, struct usb_gadget_driver *); int (*udc_stop)(struct usb_gadget *); + struct usb_ep *(*match_ep)(struct usb_gadget *, + struct usb_endpoint_descriptor *, + struct usb_ss_ep_comp_descriptor *); }; /** -- 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 40/46] usb: gadget: epautoconf: rework ep_matches() function
Rework ep_matches() function to make it shorter and more readable. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 87 + 1 file changed, 35 insertions(+), 52 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 7bb28f1..4fa6f5d 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -30,16 +30,29 @@ ep_matches ( struct usb_ss_ep_comp_descriptor *ep_comp ) { - u8 type; - u16 max; - - int num_req_streams = 0; + u8 type; + u16 max; + int num_req_streams = 0; /* endpoint already claimed? */ if (ep-claimed) return 0; type = usb_endpoint_type(desc); + max = 0x7ff usb_endpoint_maxp(desc); + + if (usb_endpoint_dir_in(desc) !ep-caps.dir_in) + return 0; + else if (!ep-caps.dir_out) + return 0; + + if (max ep-maxpacket_limit) + return 0; + + /* high bandwidth works only at high speed */ + if (!gadget_is_dualspeed(gadget) usb_endpoint_maxp(desc) (311)) + return 0; + switch (type) { case USB_ENDPOINT_XFER_CONTROL: /* only support ep0 for portable CONTROL traffic */ @@ -47,66 +60,36 @@ ep_matches ( case USB_ENDPOINT_XFER_ISOC: if (!ep-caps.type_iso) return 0; + /* ISO: limit 1023 bytes full speed, +* 1024 high/super speed +*/ + if (!gadget_is_dualspeed(gadget) max 1023) + return 0; break; case USB_ENDPOINT_XFER_BULK: if (!ep-caps.type_bulk) return 0; + if (ep_comp gadget_is_superspeed(gadget)) { + /* Get the number of required streams from the +* EP companion descriptor and see if the EP +* matches it +*/ + num_req_streams = ep_comp-bmAttributes 0x1f; + if (num_req_streams ep-max_streams) + return 0; + } break; case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, + /* Bulk endpoints handle interrupt transfers, * except the toggle-quirky iso-synch kind */ if (!ep-caps.type_int !ep-caps.type_bulk) return 0; - break; - } - - if (usb_endpoint_dir_in(desc)) { - if (!ep-caps.dir_in) - return 0; - } else { - if (!ep-caps.dir_out) - return 0; - } - - /* -* Get the number of required streams from the EP companion -* descriptor and see if the EP matches it -*/ - if (usb_endpoint_xfer_bulk(desc)) { - if (ep_comp gadget-max_speed = USB_SPEED_SUPER) { - num_req_streams = ep_comp-bmAttributes 0x1f; - if (num_req_streams ep-max_streams) - return 0; - } - - } - - /* endpoint maxpacket size is an input parameter, except for bulk -* where it's an output parameter representing the full speed limit. -* the usb spec fixes high speed bulk maxpacket at 512 bytes. -*/ - max = 0x7ff usb_endpoint_maxp(desc); - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* INT: limit 64 bytes full speed, 1024 high/super speed */ + /* INT: limit 64 bytes full speed, +* 1024 high/super speed +*/ if (!gadget_is_dualspeed(gadget) max 64) return 0; - /* FALLTHROUGH */ - - case USB_ENDPOINT_XFER_ISOC: - /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ - if (ep-maxpacket_limit max) - return 0; - if (!gadget_is_dualspeed(gadget) max 1023) - return 0; - - /* BOTH: high bandwidth works only at high speed */ - if ((desc-wMaxPacketSize cpu_to_le16(311))) { - if (!gadget_is_dualspeed(gadget)) - return 0; - /* configure your hardware with enough buffering!! */ - } break; } -- 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 46/46] usb: musb: gadget: add musb_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 23 --- drivers/usb/musb/musb_gadget.c | 34 ++ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index da45371..254ece7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss( goto found_ep; } - /* First, apply chip-specific best usage knowledge. -* This might make a good usb_gadget_ops hook ... -*/ -#ifdef CONFIG_BLACKFIN - if (gadget_is_musbhdrc(gadget)) { - if ((USB_ENDPOINT_XFER_BULK == type) || - (USB_ENDPOINT_XFER_ISOC == type)) { - if (USB_DIR_IN desc-bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, ep5in); - else - ep = gadget_find_ep_by_name(gadget, ep6out); - } else if (USB_ENDPOINT_XFER_INT == type) { - if (USB_DIR_IN desc-bEndpointAddress) - ep = gadget_find_ep_by_name(gadget, ep1in); - else - ep = gadget_find_ep_by_name(gadget, ep2out); - } else - ep = NULL; - if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) - goto found_ep; - } -#endif - /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, gadget-ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 4150baf..02c3f8a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) return 0; } +#ifdef CONFIG_BLACKFIN +static struct usb_ep *musb_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct usb_ep *ep = NULL; + u8 type = usb_endpoint_type(desc); + + switch(type) { + case USB_ENDPOINT_XFER_ISOC: + case USB_ENDPOINT_XFER_BULK: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, ep5in); + else + ep = gadget_find_ep_by_name(g, ep6out); + break; + case USB_ENDPOINT_XFER_INT: + if (usb_endpoint_dir_in(desc)) + ep = gadget_find_ep_by_name(g, ep1in); + else + ep = gadget_find_ep_by_name(g, ep2out); + default: + } + + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + + return NULL; +} +#else +#define musb_match_ep NULL +#endif + static int musb_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int musb_gadget_stop(struct usb_gadget *g); @@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations = { .pullup = musb_gadget_pullup, .udc_start = musb_gadget_start, .udc_stop = musb_gadget_stop, + .match_ep = musb_match_ep, }; /* --- */ -- 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 43/46] usb: gadget: move find_ep() from epautoconf to gadget.h
Move find_ep() function to gadget.h, rename it to gadget_find_ep_by_name() and make it static inline. It can be used in UDC drivers, especially in 'match_ep' callback after moving chip-specific endpoint matching logic from epautoconf to UDC drivers. Replace all calls of find_ep() function with gadget_find_ep_by_name(). Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 30 +- include/linux/usb/gadget.h | 18 ++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 3f0a380..cc0b084 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,18 +22,6 @@ #include gadget_chips.h -static struct usb_ep * -find_ep (struct usb_gadget *gadget, const char *name) -{ - struct usb_ep *ep; - - list_for_each_entry (ep, gadget-ep_list, ep_list) { - if (0 == strcmp (ep-name, name)) - return ep; - } - return NULL; -} - /** * usb_ep_autoconfig_ss() - choose an endpoint matching the ep * descriptor and ep companion descriptor @@ -103,11 +91,11 @@ struct usb_ep *usb_ep_autoconfig_ss( if (type == USB_ENDPOINT_XFER_INT) { /* ep-e, ep-f are PIO with only 64 byte fifos */ - ep = find_ep(gadget, ep-e); + ep = gadget_find_ep_by_name(gadget, ep-e); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; - ep = find_ep(gadget, ep-f); + ep = gadget_find_ep_by_name(gadget, ep-f); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; @@ -116,20 +104,20 @@ struct usb_ep *usb_ep_autoconfig_ss( /* USB3380: use same address for usb and hardware endpoints */ snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), usb_endpoint_dir_in(desc) ? in : out); - ep = find_ep(gadget, name); + ep = gadget_find_ep_by_name(gadget, name); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ - ep = find_ep(gadget, ep3-bulk); + ep = gadget_find_ep_by_name(gadget, ep3-bulk); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (USB_ENDPOINT_XFER_BULK == type (USB_DIR_IN desc-bEndpointAddress)) { /* DMA may be available */ - ep = find_ep(gadget, ep2-bulk); + ep = gadget_find_ep_by_name(gadget, ep2-bulk); if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; @@ -140,14 +128,14 @@ struct usb_ep *usb_ep_autoconfig_ss( if ((USB_ENDPOINT_XFER_BULK == type) || (USB_ENDPOINT_XFER_ISOC == type)) { if (USB_DIR_IN desc-bEndpointAddress) - ep = find_ep (gadget, ep5in); + ep = gadget_find_ep_by_name(gadget, ep5in); else - ep = find_ep (gadget, ep6out); + ep = gadget_find_ep_by_name(gadget, ep6out); } else if (USB_ENDPOINT_XFER_INT == type) { if (USB_DIR_IN desc-bEndpointAddress) - ep = find_ep(gadget, ep1in); + ep = gadget_find_ep_by_name(gadget, ep1in); else - ep = find_ep(gadget, ep2out); + ep = gadget_find_ep_by_name(gadget, ep2out); } else ep = NULL; if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index e04fd63..6a413ab 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -639,6 +639,24 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev) #define gadget_for_each_ep(tmp, gadget) \ list_for_each_entry(tmp, (gadget)-ep_list, ep_list) +/** + * gadget_find_ep_by_name - returns ep whose name is the same as sting passed + * in second parameter or NULL if
[PATCH v5 45/46] usb: gadget: goku_udc: add goku_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 20 ++-- drivers/usb/gadget/udc/goku_udc.c | 25 + 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index d41fd82..da45371 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss( /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ - if (gadget_is_goku (gadget)) { - if (USB_ENDPOINT_XFER_INT == type) { - /* single buffering is enough */ - ep = gadget_find_ep_by_name(gadget, ep3-bulk); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } else if (USB_ENDPOINT_XFER_BULK == type -(USB_DIR_IN desc-bEndpointAddress)) { - /* DMA may be available */ - ep = gadget_find_ep_by_name(gadget, ep2-bulk); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } - #ifdef CONFIG_BLACKFIN - } else if (gadget_is_musbhdrc(gadget)) { + if (gadget_is_musbhdrc(gadget)) { if ((USB_ENDPOINT_XFER_BULK == type) || (USB_ENDPOINT_XFER_ISOC == type)) { if (USB_DIR_IN desc-bEndpointAddress) @@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss( ep = NULL; if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; -#endif } +#endif /* Second, look at endpoints until an unclaimed one looks usable */ list_for_each_entry (ep, gadget-ep_list, ep_list) { diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 46b8d14..d5a93ea 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -990,6 +990,30 @@ static int goku_get_frame(struct usb_gadget *_gadget) return -EOPNOTSUPP; } +static struct usb_ep *goku_match_ep(struct usb_gadget *g, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + struct goku_udc *dev = to_goku_udc(g); + struct usb_ep *ep; + u8 type = usb_endpoint_type(desc); + + if (type == USB_ENDPOINT_XFER_INT) { + /* single buffering is enough */ + ep = dev-ep[3].ep; + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } else if (type == USB_ENDPOINT_XFER_BULK +usb_endpoint_dir_in(desc)) { + /* DMA may be available */ + ep = dev-ep[2].ep; + if (ep usb_gadget_ep_match_desc(g, ep, desc, ep_comp)) + return ep; + } + + return NULL; +} + static int goku_udc_start(struct usb_gadget *g, struct usb_gadget_driver *driver); static int goku_udc_stop(struct usb_gadget *g); @@ -998,6 +1022,7 @@ static const struct usb_gadget_ops goku_ops = { .get_frame = goku_get_frame, .udc_start = goku_udc_start, .udc_stop = goku_udc_stop, + .match_ep = goku_match_ep, // no remote wakeup // not selfpowered }; -- 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 18/46] usb: gadget: gr_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/gr_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index c886887..8aa2593 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -2018,12 +2018,23 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) usb_ep_set_maxpacket_limit(ep-ep, MAX_CTRL_PL_SIZE); ep-bytes_per_buffer = MAX_CTRL_PL_SIZE; + + ep-ep.caps.type_control = true; } else { usb_ep_set_maxpacket_limit(ep-ep, (u16)maxplimit); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); + + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; } list_add_tail(ep-ep_list, dev-ep_list); + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-tailbuf = dma_alloc_coherent(dev-dev, ep-ep.maxpacket_limit, ep-tailbuf_paddr, GFP_ATOMIC); if (!ep-tailbuf) -- 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 42/46] usb: gadget: move ep_matches() from epautoconf to udc-core
Move ep_matches() function to udc-core and rename it to usb_gadget_ep_match_desc(). This function can be used by UDC drivers in 'match_ep' callback to avoid writing lots of repetitive code. Replace all calls of ep_matches() with usb_gadget_ep_match_desc(). Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 95 +-- drivers/usb/gadget/udc/udc-core.c | 69 include/linux/usb/gadget.h| 8 3 files changed, 88 insertions(+), 84 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 1b1fee0..3f0a380 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -22,82 +22,6 @@ #include gadget_chips.h -static int -ep_matches ( - struct usb_gadget *gadget, - struct usb_ep *ep, - struct usb_endpoint_descriptor *desc, - struct usb_ss_ep_comp_descriptor *ep_comp -) -{ - u8 type; - u16 max; - int num_req_streams = 0; - - /* endpoint already claimed? */ - if (ep-claimed) - return 0; - - type = usb_endpoint_type(desc); - max = 0x7ff usb_endpoint_maxp(desc); - - if (usb_endpoint_dir_in(desc) !ep-caps.dir_in) - return 0; - else if (!ep-caps.dir_out) - return 0; - - if (max ep-maxpacket_limit) - return 0; - - /* high bandwidth works only at high speed */ - if (!gadget_is_dualspeed(gadget) usb_endpoint_maxp(desc) (311)) - return 0; - - switch (type) { - case USB_ENDPOINT_XFER_CONTROL: - /* only support ep0 for portable CONTROL traffic */ - return 0; - case USB_ENDPOINT_XFER_ISOC: - if (!ep-caps.type_iso) - return 0; - /* ISO: limit 1023 bytes full speed, -* 1024 high/super speed -*/ - if (!gadget_is_dualspeed(gadget) max 1023) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if (!ep-caps.type_bulk) - return 0; - if (ep_comp gadget_is_superspeed(gadget)) { - /* Get the number of required streams from the -* EP companion descriptor and see if the EP -* matches it -*/ - num_req_streams = ep_comp-bmAttributes 0x1f; - if (num_req_streams ep-max_streams) - return 0; - } - break; - case USB_ENDPOINT_XFER_INT: - /* Bulk endpoints handle interrupt transfers, -* except the toggle-quirky iso-synch kind -*/ - if (!ep-caps.type_int !ep-caps.type_bulk) - return 0; - /* INT: limit 64 bytes full speed, -* 1024 high/super speed -*/ - if (!gadget_is_dualspeed(gadget) max 64) - return 0; - break; - } - - /* MATCH!! */ - - return 1; -} - static struct usb_ep * find_ep (struct usb_gadget *gadget, const char *name) { @@ -180,10 +104,12 @@ struct usb_ep *usb_ep_autoconfig_ss( if (type == USB_ENDPOINT_XFER_INT) { /* ep-e, ep-f are PIO with only 64 byte fifos */ ep = find_ep(gadget, ep-e); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, + ep, desc, ep_comp)) goto found_ep; ep = find_ep(gadget, ep-f); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, + ep, desc, ep_comp)) goto found_ep; } @@ -191,20 +117,21 @@ struct usb_ep *usb_ep_autoconfig_ss( snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), usb_endpoint_dir_in(desc) ? in : out); ep = find_ep(gadget, name); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) goto found_ep; } else if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ ep = find_ep(gadget, ep3-bulk); - if (ep ep_matches(gadget, ep, desc, ep_comp)) + if (ep usb_gadget_ep_match_desc(gadget, +
[PATCH v5 08/46] usb: gadget: amd5536udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/amd5536udc.c | 88 - 1 file changed, 78 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index de7e5e2..fdacddb 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -138,15 +138,82 @@ static DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, /* endpoint names used for print */ static const char ep0_string[] = ep0in; -static const char *const ep_string[] = { - ep0_string, - ep1in-int, ep2in-bulk, ep3in-bulk, ep4in-bulk, ep5in-bulk, - ep6in-bulk, ep7in-bulk, ep8in-bulk, ep9in-bulk, ep10in-bulk, - ep11in-bulk, ep12in-bulk, ep13in-bulk, ep14in-bulk, - ep15in-bulk, ep0out, ep1out-bulk, ep2out-bulk, ep3out-bulk, - ep4out-bulk, ep5out-bulk, ep6out-bulk, ep7out-bulk, - ep8out-bulk, ep9out-bulk, ep10out-bulk, ep11out-bulk, - ep12out-bulk, ep13out-bulk, ep14out-bulk, ep15out-bulk +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + + EP_INFO(ep0_string, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep1in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep2in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep3in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep4in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep5in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep6in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep7in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep8in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep9in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep10in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep11in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep12in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep13in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep14in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep15in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep0out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep1out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep2out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep3out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep4out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep5out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep6out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep7out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep8out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep9out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep10out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep11out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep12out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep13out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep14out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep15out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + +#undef EP_INFO }; /* DMA usage flag */ @@ -1517,7 +1584,8 @@ static void udc_setup_endpoints(struct udc *dev) for (tmp = 0; tmp UDC_EP_NUM; tmp++) { ep = dev-ep[tmp]; ep-dev = dev; - ep-ep.name = ep_string[tmp]; + ep-ep.name = ep_info[tmp].name; + ep-ep.caps =
[PATCH v5 11/46] usb: gadget: bdc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bdc/bdc_ep.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index b04980c..f9a8f57 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -1952,12 +1952,18 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) ep-bdc = bdc; ep-dir = dir; + if (dir) + ep-usb_ep.caps.dir_in = true; + else + ep-usb_ep.caps.dir_out = true; + /* ep-ep_num is the index inside bdc_ep */ if (epnum == 1) { ep-ep_num = 1; bdc-bdc_ep_array[ep-ep_num] = ep; snprintf(ep-name, sizeof(ep-name), ep%d, epnum - 1); usb_ep_set_maxpacket_limit(ep-usb_ep, EP0_MAX_PKT_SIZE); + ep-usb_ep.caps.type_control = true; ep-comp_desc = NULL; bdc-gadget.ep0 = ep-usb_ep; } else { @@ -1971,6 +1977,9 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) dir 1 ? in : out); usb_ep_set_maxpacket_limit(ep-usb_ep, 1024); + ep-usb_ep.caps.type_iso = true; + ep-usb_ep.caps.type_bulk = true; + ep-usb_ep.caps.type_int = true; ep-usb_ep.max_streams = 0; list_add_tail(ep-usb_ep.ep_list, bdc-gadget.ep_list); } -- 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 39/46] usb: gadget: epautoconf: remove ep and desc configuration from ep_matches()
As function ep_matches() is used to match endpoint with usb descriptor it's highly unintuitive that it modifies endpoint and descriptor structures fields. This patch moves code configuring ep and desc from ep_matches() to usb_ep_autoconfig_ss(), so now function ep_matches() does nothing more than its name suggests. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 66 + 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 4f66e9d73..7bb28f1 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -82,13 +82,6 @@ ep_matches ( } - /* -* If the protocol driver hasn't yet decided on wMaxPacketSize -* and wants to know the maximum possible, provide the info. -*/ - if (desc-wMaxPacketSize == 0) - desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit); - /* endpoint maxpacket size is an input parameter, except for bulk * where it's an output parameter representing the full speed limit. * the usb spec fixes high speed bulk maxpacket at 512 bytes. @@ -119,31 +112,6 @@ ep_matches ( /* MATCH!! */ - /* report address */ - desc-bEndpointAddress = USB_DIR_IN; - if (isdigit (ep-name [2])) { - u8 num = simple_strtoul (ep-name [2], NULL, 10); - desc-bEndpointAddress |= num; - } else if (desc-bEndpointAddress USB_DIR_IN) { - if (++gadget-in_epnum 15) - return 0; - desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum; - } else { - if (++gadget-out_epnum 15) - return 0; - desc-bEndpointAddress |= gadget-out_epnum; - } - - /* report (variable) full speed bulk maxpacket */ - if ((USB_ENDPOINT_XFER_BULK == type) !ep_comp) { - int size = ep-maxpacket_limit; - - /* min() doesn't work on bitfields with gcc-3.5 */ - if (size 64) - size = 64; - desc-wMaxPacketSize = cpu_to_le16(size); - } - ep-address = desc-bEndpointAddress; return 1; } @@ -280,6 +248,40 @@ struct usb_ep *usb_ep_autoconfig_ss( /* Fail */ return NULL; found_ep: + + /* +* If the protocol driver hasn't yet decided on wMaxPacketSize +* and wants to know the maximum possible, provide the info. +*/ + if (desc-wMaxPacketSize == 0) + desc-wMaxPacketSize = cpu_to_le16(ep-maxpacket_limit); + + /* report address */ + desc-bEndpointAddress = USB_DIR_IN; + if (isdigit(ep-name[2])) { + u8 num = simple_strtoul(ep-name[2], NULL, 10); + desc-bEndpointAddress |= num; + } else if (desc-bEndpointAddress USB_DIR_IN) { + if (++gadget-in_epnum 15) + return 0; + desc-bEndpointAddress = USB_DIR_IN | gadget-in_epnum; + } else { + if (++gadget-out_epnum 15) + return 0; + desc-bEndpointAddress |= gadget-out_epnum; + } + + /* report (variable) full speed bulk maxpacket */ + if ((type == USB_ENDPOINT_XFER_BULK) !ep_comp) { + int size = ep-maxpacket_limit; + + /* min() doesn't work on bitfields with gcc-3.5 */ + if (size 64) + size = 64; + desc-wMaxPacketSize = cpu_to_le16(size); + } + + ep-address = desc-bEndpointAddress; ep-desc = NULL; ep-comp_desc = NULL; ep-claimed = true; -- 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 31/46] usb: gadget: s3c2410_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c2410_udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c index 5d9aa81..eb3571e 100644 --- a/drivers/usb/gadget/udc/s3c2410_udc.c +++ b/drivers/usb/gadget/udc/s3c2410_udc.c @@ -1691,6 +1691,8 @@ static struct s3c2410_udc memory = { .name = ep0name, .ops= s3c2410_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, }, @@ -1702,6 +1704,8 @@ static struct s3c2410_udc memory = { .name = ep1-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1714,6 +1718,8 @@ static struct s3c2410_udc memory = { .name = ep2-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1726,6 +1732,8 @@ static struct s3c2410_udc memory = { .name = ep3-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1738,6 +1746,8 @@ static struct s3c2410_udc memory = { .name = ep4-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, -- 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 35/46] usb: renesas: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/renesas_usbhs/mod_gadget.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 494dfe0..de4f97d 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -1103,12 +1103,18 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) if (usbhsg_is_dcp(uep)) { gpriv-gadget.ep0 = uep-ep; usb_ep_set_maxpacket_limit(uep-ep, 64); + uep-ep.caps.type_control = true; } /* init normal pipe */ else { usb_ep_set_maxpacket_limit(uep-ep, 512); + uep-ep.caps.type_iso = true; + uep-ep.caps.type_bulk = true; + uep-ep.caps.type_int = true; list_add_tail(uep-ep.ep_list, gpriv-gadget.ep_list); } + uep-ep.caps.dir_in = true; + uep-ep.caps.dir_out = true; } ret = usb_add_gadget_udc(dev, gpriv-gadget); -- 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 38/46] usb: gadget: epautoconf: remove pxa quirk from ep_matches()
The same effect can be achieved by using capabilities flags, so now we can get rid of handling of hardware specific limitations in generic code. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 5 - drivers/usb/gadget/udc/pxa25x_udc.c | 9 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index af4b10a..4f66e9d73 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -58,11 +58,6 @@ ep_matches ( */ if (!ep-caps.type_int !ep-caps.type_bulk) return 0; - /* for now, avoid PXA interrupt-in; -* it's documented as never using DATA1. -*/ - if (gadget_is_pxa(gadget) ep-caps.type_int) - return 0; break; } diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index b4d25dc..b82cb14 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1899,8 +1899,7 @@ static struct pxa25x_udc memory = { .name = ep5in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -1978,8 +1977,7 @@ static struct pxa25x_udc memory = { .name = ep10in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -2057,8 +2055,7 @@ static struct pxa25x_udc memory = { .name = ep15in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, - .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, - USB_EP_CAPS_DIR_IN), + .caps = USB_EP_CAPS(0, 0), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, -- 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 27/46] usb: gadget: pxa25x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa25x_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index 27f9442..b4d25dc 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1822,6 +1822,8 @@ static struct pxa25x_udc memory = { .name = ep0name, .ops= pxa25x_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .reg_udccs = UDCCS0, @@ -1834,6 +1836,8 @@ static struct pxa25x_udc memory = { .name = ep1in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1847,6 +1851,8 @@ static struct pxa25x_udc memory = { .name = ep2out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1862,6 +1868,8 @@ static struct pxa25x_udc memory = { .name = ep3in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1875,6 +1883,8 @@ static struct pxa25x_udc memory = { .name = ep4out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1889,6 +1899,8 @@ static struct pxa25x_udc memory = { .name = ep5in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -1904,6 +1916,8 @@ static struct pxa25x_udc memory = { .name = ep6in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1917,6 +1931,8 @@ static struct pxa25x_udc memory = { .name = ep7out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1931,6 +1947,8 @@ static struct pxa25x_udc memory = { .name = ep8in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1944,6 +1962,8 @@ static struct pxa25x_udc memory = { .name = ep9out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, +
[PATCH v5 00/46] usb: gadget: rework ep matching and claiming mechanism
Hello, This patch series reworks endpoint matching and claiming mechanism in epautoconf. From v2 there are couple of new patches adding 'ep_match' to usb_gadget_ops and removing chip-specific quirk handling from generic code of autoconfig. I'm not sure if this patch set isn't too long, as it has 46 patches, but I decided to send it as single series to avoid problems with patch applying order. The aim of whole patchset is to rework epautoconf code to get rid of things like name-based endpoint matching and UDC name-based quirks in generic code. These needed to do some modifications in framework like adding 'endpoint capabilities flags' feature or adding 'match_ep'. Following paragraphs contain brief description of what modifications are done by particular parts of this patch set: Patch (1) introduces new safer endpoint claiming method, basing on new 'claimed' flag. It was discussed here [1]. I proposed this solution over year ago and it was accepted, but I apparently forgot to send the final version of my patch. Patches (2-3) add the 'capabilities flags' structure and helper macros. This solution is inspired by the 'feature flags' originally proposed by Felipe Balbi in 2013 [2], but unfortunately implementation of this feature has never been completed. Patches (4-36) add' capabilites flags' support to all UDC drivers present in the kernel tree. It's needed to be done before replacing old endpoint matching mechanism, otherwise UDC drivers which doesn't set 'capabilities flags' won't work with new matching function. Patch (37) finally replaces old endpoint matching method with the new one basing on capabilities flags. These changes aims to get rid of code, which guesses endpoint capabilities basing on it's name, and introduce new better replacement. In result we have better way to describe types and directions supported by each endpoint. For example the old name-based method didn't allow to have endpoint supporing two types of transfers - there were only ability to support one or all of endpoint types. The 'capabilities flags' feature supply precise, flexible and extensible mechanism of description of endpoint hardware limitations, which is desired for proper endpoint matching. Patch (38) removes chip-specific quirk from ep_matches() function. Patches (39-40) remove code modifying endpoint and descriptor structures from ep_matches() function and cleans it up to make it simpler and more readable. Patch (41) add 'match_ep' callback to usb_gadget_ops and make use of it in epautoconf. This callback allows UDC drivers to supply non-standard endpoint matching algorithms. Patches (42-43) move ep_matches() and find_ep() functions outside epautoconf and rename them to usb_gadget_ep_match_desc() and gadget_find_ep_by_name(). It's because they may be useful in 'match_ep' callbacks in UDC drivers to avoid writing repetitive code. Patches (44-46) move chip-specific enpoint matching algorithms from generic code of usb_ep_autoconfig_ss() function to UDC controller drivers using 'match_ep' callback. In the result we have epautoconf source free of chip-specific code, plus two new mechanisms allowing to handle non-standard hardware limitations. [1] https://lkml.org/lkml/2014/6/16/94 [2] http://www.spinics.net/lists/linux-usb/msg99662.html Best regards, Robert Baldyga Changelog: v5: - made code more grepable according to Felipe's suggestion v4: https://lkml.org/lkml/2015/7/27/181 - addressed comments from Krzysztof Opasiak and Felipe Balbi v3: https://lkml.org/lkml/2015/7/15/68 - addressed comments from Sergei Shtylyov v2: https://lkml.org/lkml/2015/7/14/172 - remove PXA quirk from ep_matches() function without behaviour change using ep capabilities flags - separate ep and desc configuration code from ep_match() function - add 'ep_match' to usb_gadget_ops and move chip-specific endpoint matching algorithms from generic code to UDC controller drivers v1: https://lkml.org/lkml/2015/7/8/436 Robert Baldyga (46): usb: gadget: encapsulate endpoint claiming mechanism usb: gadget: add endpoint capabilities flags usb: gadget: add endpoint capabilities helper macros staging: emxx_udc: add ep capabilities support usb: chipidea: udc: add ep capabilities support usb: dwc2: gadget: add ep capabilities support usb: dwc3: gadget: add ep capabilities support usb: gadget: amd5536udc: add ep capabilities support usb: gadget: at91_udc: add ep capabilities support usb: gadget: bcm63xx_udc: add ep capabilities support usb: gadget: bdc: add ep capabilities support usb: gadget: dummy-hcd: add ep capabilities support usb: gadget: fotg210-udc: add ep capabilities support usb: gadget: fsl_qe_udc: add ep capabilities support usb: gadget: fsl_udc_core: add ep capabilities support usb: gadget: fusb300_udc: add ep capabilities support usb: gadget: goku_udc: add ep capabilities support usb: gadget: gr_udc: add ep capabilities support usb: gadget: lpc32xx_udc: add ep capabilities support usb:
[PATCH v5 07/46] usb: dwc3: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc3/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 2feed9e..bd4c3db 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1715,6 +1715,19 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, return ret; } + if (epnum == 0 || epnum == 1) { + dep-endpoint.caps.type_control = true; + } else { + dep-endpoint.caps.type_iso = true; + dep-endpoint.caps.type_bulk = true; + dep-endpoint.caps.type_int = true; + } + + if (direction) + dep-endpoint.caps.dir_in = true; + else + dep-endpoint.caps.dir_out = true; + INIT_LIST_HEAD(dep-request_list); INIT_LIST_HEAD(dep-req_queued); } -- 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 01/46] usb: gadget: encapsulate endpoint claiming mechanism
So far it was necessary for usb functions to set ep-driver_data in endpoint obtained from autoconfig to non-null value, to indicate that endpoint is claimed by function (in autoconfig it was checked if endpoint has set this field to non-null value, and if it has, it was assumed that it is claimed). It could cause bugs because if some function doesn't set this field autoconfig could return the same endpoint more than one time. To help to avoid such bugs this patch adds claimed flag to struct usb_ep, and encapsulates endpoint claiming mechanism inside usb_ep_autoconfig_ss() and usb_ep_autoconfig_reset(), so now usb functions don't need to perform any additional actions to mark endpoint obtained from autoconfig as claimed. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 11 ++- include/linux/usb/gadget.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 919cdfd..8e00ca7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -53,7 +53,7 @@ ep_matches ( int num_req_streams = 0; /* endpoint already claimed? */ - if (NULL != ep-driver_data) + if (ep-claimed) return 0; /* only support ep0 for portable CONTROL traffic */ @@ -240,7 +240,7 @@ find_ep (struct usb_gadget *gadget, const char *name) * updated with the assigned number of streams if it is * different from the original value. To prevent the endpoint * from being returned by a later autoconfig call, claim it by - * assigning ep-driver_data to some non-null value. + * assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -323,6 +323,7 @@ struct usb_ep *usb_ep_autoconfig_ss( found_ep: ep-desc = NULL; ep-comp_desc = NULL; + ep-claimed = true; return ep; } EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); @@ -354,7 +355,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value * is initialized as if the endpoint were used at full speed. To prevent * the endpoint from being returned by a later autoconfig call, claim it - * by assigning ep-driver_data to some non-null value. + * by assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -373,7 +374,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig); * * Use this for devices where one configuration may need to assign * endpoint resources very differently from the next one. It clears - * state such as ep-driver_data and the record of assigned endpoints + * state such as ep-claimed and the record of assigned endpoints * used by usb_ep_autoconfig(). */ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) @@ -381,7 +382,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) struct usb_ep *ep; list_for_each_entry (ep, gadget-ep_list, ep_list) { - ep-driver_data = NULL; + ep-claimed = false; } gadget-in_epnum = 0; gadget-out_epnum = 0; diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 353a720..68fb5e8 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -173,6 +173,7 @@ struct usb_ep { const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; unsignedmax_streams:16; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-sunxi] [PATCH v5 2/7] phy-sun4i-usb: Add extcon support for the otg phy (phy0)
Hi Hans, On 13/06/2015 10:37 PM, Hans de Goede wrote: The sunxi musb glue needs to know if a host or normal usb cable is plugged in, add extcon support so that the musb glue can monitor the host status. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v5: -Split out of the Add id and vbus detection support commit -Ported to the new extcon API queued for 4.2 --- drivers/phy/Kconfig | 1 + drivers/phy/phy-sun4i-usb.c | 32 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a53bd5b..9841780 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -173,6 +173,7 @@ config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF depends on RESET_CONTROLLER + depends on EXTCON select GENERIC_PHY help Enable this to support the transceiver that is part of Allwinner Should probably add CONFIG_EXTCON=y to arch/arm/configs/sunxi_defconfig so that CONFIG_PHY_SUN4I_USB=y works out of the box. Regards, Jonathan -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-sunxi] [PATCH v5 2/7] phy-sun4i-usb: Add extcon support for the otg phy (phy0)
Hi, On 31-07-15 16:23, Jonathan Liu wrote: Hi Hans, On 13/06/2015 10:37 PM, Hans de Goede wrote: The sunxi musb glue needs to know if a host or normal usb cable is plugged in, add extcon support so that the musb glue can monitor the host status. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v5: -Split out of the Add id and vbus detection support commit -Ported to the new extcon API queued for 4.2 --- drivers/phy/Kconfig | 1 + drivers/phy/phy-sun4i-usb.c | 32 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a53bd5b..9841780 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -173,6 +173,7 @@ config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF depends on RESET_CONTROLLER +depends on EXTCON select GENERIC_PHY help Enable this to support the transceiver that is part of Allwinner Should probably add CONFIG_EXTCON=y to arch/arm/configs/sunxi_defconfig so that CONFIG_PHY_SUN4I_USB=y works out of the box. Right, ChenYu just send out 2 defconfig patches fixing this. Thanks for the heads up. Regards, Hans -- 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 03/46] usb: gadget: add endpoint capabilities helper macros
Add macros useful while initializing array of endpoint capabilities structures. These macros makes structure initialization more compact to decrease number of code lines and increase readability of code. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 20 1 file changed, 20 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index a9a4959..82b5bcb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -158,6 +158,26 @@ struct usb_ep_caps { unsigned dir_out:1; }; +#define USB_EP_CAPS_TYPE_CONTROL 0x01 +#define USB_EP_CAPS_TYPE_ISO 0x02 +#define USB_EP_CAPS_TYPE_BULK0x04 +#define USB_EP_CAPS_TYPE_INT 0x08 +#define USB_EP_CAPS_TYPE_ALL \ + (USB_EP_CAPS_TYPE_ISO | USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT) +#define USB_EP_CAPS_DIR_IN 0x01 +#define USB_EP_CAPS_DIR_OUT 0x02 +#define USB_EP_CAPS_DIR_ALL (USB_EP_CAPS_DIR_IN | USB_EP_CAPS_DIR_OUT) + +#define USB_EP_CAPS(_type, _dir) \ + { \ + .type_control = !!(_type USB_EP_CAPS_TYPE_CONTROL), \ + .type_iso = !!(_type USB_EP_CAPS_TYPE_ISO), \ + .type_bulk = !!(_type USB_EP_CAPS_TYPE_BULK), \ + .type_int = !!(_type USB_EP_CAPS_TYPE_INT), \ + .dir_in = !!(_dir USB_EP_CAPS_DIR_IN), \ + .dir_out = !!(_dir USB_EP_CAPS_DIR_OUT), \ + } + /** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs
hi, On Tue, 2015-07-28 at 11:17 +0530, Kishon Vijay Abraham I wrote: Hi, On Sunday 26 July 2015 08:21 AM, chunfeng yun wrote: hi, On Wed, 2015-07-22 at 09:21 -0500, Felipe Balbi wrote: Hi, On Wed, Jul 22, 2015 at 10:05:43PM +0800, Chunfeng Yun wrote: support usb3.0 phy of mt65xx SoCs Signed-off-by: Chunfeng Yun chunfeng@mediatek.com you missed Kishon here. Thank you. --- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 426 ++ 3 files changed, 436 insertions(+) create mode 100644 drivers/phy/phy-mt65xx-usb3.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c0e6ede..019cf8b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -193,6 +193,15 @@ config PHY_HIX5HD2_SATA help Support for SATA PHY on Hisilicon hix5hd2 Soc. +config PHY_MT65XX_USB3 + tristate Mediatek USB3.0 PHY Driver + depends on ARCH_MEDIATEK OF + select GENERIC_PHY + help + Say 'Y' here to add support for Mediatek USB3.0 PHY driver + for mt65xx SoCs. it supports two usb2.0 ports and + one usb3.0 port. + config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f344e1b..3ceff2a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o +obj-$(CONFIG_PHY_MT65XX_USB3)+= phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB) += phy-sun9i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c new file mode 100644 index 000..5da4534 --- /dev/null +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/module.h +#include linux/of_address.h +#include linux/of_device.h +#include linux/of_gpio.h +#include linux/of.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/regulator/consumer.h Lot of these #include are not required. Add only those what are required by this driver. The dummy header files will be removed later +#include linux/resource.h + +/* + * for sifslv2 register + * relative to USB3_SIF2_BASE base address + */ +#define SSUSB_SIFSLV_SPLLC (0x) +#define SSUSB_SIFSLV_U2PHY_COM_BASE (0x0800) Looks like all this base address can come from dt. The phy supports multi-ports, and these are sub-segment registers for port0, and other ports can be calculated from the bases. So I think it's better to use the same base address in dts +#define SSUSB_SIFSLV_U3PHYD_BASE (0x0900) +#define SSUSB_USB30_PHYA_SIV_B_BASE (0x0b00) +#define SSUSB_SIFSLV_U3PHYA_DA_BASE (0x0c00) + +/*port1 refs. +0x800(refer to port0)*/ +#define U3P_PORT_INTERVAL (0x800)/*based on port0 */ +#define U3P_PHY_DELTA(index) ((U3P_PORT_INTERVAL) * (index)) + +#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +#define PA0_RG_U2PLL_FORCE_ON(0x1 15) + +#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define PA2_RG_SIF_U2PLL_FORCE_EN(0x1 18) + +#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define PA5_RG_U2_HSTX_SRCTRL(0x7 12) +#define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 (x)) 12) +#define PA5_RG_U2_HS_100U_U3_EN (0x1 11) + +#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define PA6_RG_U2_ISO_EN (0x1 31) +#define PA6_RG_U2_BC11_SW_EN (0x1 23) +#define PA6_RG_U2_OTG_VBUSCMP_EN (0x1 20) + +#define U3P_U2PHYACR4(SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define P2C_RG_USB20_GPIO_CTL(0x1 9) +#define P2C_USB20_GPIO_MODE (0x1 8) +#define P2C_U2_GPIO_CTR_MSK (P2C_RG_USB20_GPIO_CTL |
Re: [PATCH v3 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs
Hi, On Friday 31 July 2015 05:55 PM, chunfeng yun wrote: hi, On Tue, 2015-07-28 at 11:17 +0530, Kishon Vijay Abraham I wrote: Hi, On Sunday 26 July 2015 08:21 AM, chunfeng yun wrote: hi, On Wed, 2015-07-22 at 09:21 -0500, Felipe Balbi wrote: Hi, On Wed, Jul 22, 2015 at 10:05:43PM +0800, Chunfeng Yun wrote: support usb3.0 phy of mt65xx SoCs Signed-off-by: Chunfeng Yun chunfeng@mediatek.com you missed Kishon here. Thank you. --- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 426 ++ 3 files changed, 436 insertions(+) create mode 100644 drivers/phy/phy-mt65xx-usb3.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c0e6ede..019cf8b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -193,6 +193,15 @@ config PHY_HIX5HD2_SATA help Support for SATA PHY on Hisilicon hix5hd2 Soc. +config PHY_MT65XX_USB3 + tristate Mediatek USB3.0 PHY Driver + depends on ARCH_MEDIATEK OF + select GENERIC_PHY + help + Say 'Y' here to add support for Mediatek USB3.0 PHY driver + for mt65xx SoCs. it supports two usb2.0 ports and + one usb3.0 port. + config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f344e1b..3ceff2a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB)+= phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA)+= phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o +obj-$(CONFIG_PHY_MT65XX_USB3)+= phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB) += phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB) += phy-sun9i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c new file mode 100644 index 000..5da4534 --- /dev/null +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/module.h +#include linux/of_address.h +#include linux/of_device.h +#include linux/of_gpio.h +#include linux/of.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/regulator/consumer.h Lot of these #include are not required. Add only those what are required by this driver. The dummy header files will be removed later +#include linux/resource.h + +/* + * for sifslv2 register + * relative to USB3_SIF2_BASE base address + */ +#define SSUSB_SIFSLV_SPLLC (0x) +#define SSUSB_SIFSLV_U2PHY_COM_BASE (0x0800) Looks like all this base address can come from dt. The phy supports multi-ports, and these are sub-segment registers for port0, and other ports can be calculated from the bases. So I think it's better to use the same base address in dts Nope. Except for the register offsets everything else can come from dt. +#define SSUSB_SIFSLV_U3PHYD_BASE (0x0900) +#define SSUSB_USB30_PHYA_SIV_B_BASE (0x0b00) +#define SSUSB_SIFSLV_U3PHYA_DA_BASE (0x0c00) + +/*port1 refs. +0x800(refer to port0)*/ +#define U3P_PORT_INTERVAL (0x800)/*based on port0 */ +#define U3P_PHY_DELTA(index) ((U3P_PORT_INTERVAL) * (index)) + +#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +#define PA0_RG_U2PLL_FORCE_ON(0x1 15) + +#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define PA2_RG_SIF_U2PLL_FORCE_EN(0x1 18) + +#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define PA5_RG_U2_HSTX_SRCTRL(0x7 12) +#define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 (x)) 12) +#define PA5_RG_U2_HS_100U_U3_EN (0x1 11) + +#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define PA6_RG_U2_ISO_EN (0x1 31) +#define PA6_RG_U2_BC11_SW_EN (0x1 23) +#define PA6_RG_U2_OTG_VBUSCMP_EN (0x1 20) + +#define U3P_U2PHYACR4(SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define P2C_RG_USB20_GPIO_CTL(0x1 9) +#define P2C_USB20_GPIO_MODE (0x1 8) +#define P2C_U2_GPIO_CTR_MSK (P2C_RG_USB20_GPIO_CTL |
[PATCH v5 15/46] usb: gadget: fsl_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_udc_core.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index c60022b..aab5221 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -2313,6 +2313,19 @@ static int struct_ep_setup(struct fsl_udc *udc, unsigned char index, ep-ep.ops = fsl_ep_ops; ep-stopped = 0; + if (index == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + if (index 1) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + /* for ep0: maxP defined in desc * for other eps, maxP is set by epautoconfig() called by gadget layer */ -- 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 16/46] usb: gadget: fusb300_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fusb300_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index 3970f45..948845c 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -1450,6 +1450,17 @@ static int fusb300_probe(struct platform_device *pdev) ep-ep.name = fusb300_ep_name[i]; ep-ep.ops = fusb300_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, HS_BULK_MAX_PACKET_SIZE); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fusb300-ep[0]-ep, HS_CTL_MAX_PACKET_SIZE); fusb300-ep[0]-epnum = 0; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 14/46] usb: gadget: fsl_qe_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_qe_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index e0822f1..5fb6f8b 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -2417,6 +2417,17 @@ static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) strcpy(ep-name, ep_name[pipe_num]); ep-ep.name = ep_name[pipe_num]; + if (pipe_num == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + ep-ep.ops = qe_ep_ops; ep-stopped = 1; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 13/46] usb: gadget: fotg210-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fotg210-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index a99ed6d..6ba122c 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -1143,6 +1143,17 @@ static int fotg210_udc_probe(struct platform_device *pdev) ep-ep.name = fotg210_ep_name[i]; ep-ep.ops = fotg210_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fotg210-ep[0]-ep, 0x40); fotg210-gadget.ep0 = fotg210-ep[0]-ep; -- 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 02/46] usb: gadget: add endpoint capabilities flags
Introduce struct usb_ep_caps which contains information about capabilities of usb endpoints - supported transfer types and directions. This structure should be filled by UDC driver for each of its endpoints, and will be used in epautoconf in new ep matching mechanism which will replace ugly guessing of endpoint capabilities basing on its name. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 21 + 1 file changed, 21 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 68fb5e8..a9a4959 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -141,10 +141,29 @@ struct usb_ep_ops { }; /** + * struct usb_ep_caps - endpoint capabilities description + * @type_control:Endpoint supports control type (reserved for ep0). + * @type_iso:Endpoint supports isochronous transfers. + * @type_bulk:Endpoint supports bulk transfers. + * @type_int:Endpoint supports interrupt transfers. + * @dir_in:Endpoint supports IN direction. + * @dir_out:Endpoint supports OUT direction. + */ +struct usb_ep_caps { + unsigned type_control:1; + unsigned type_iso:1; + unsigned type_bulk:1; + unsigned type_int:1; + unsigned dir_in:1; + unsigned dir_out:1; +}; + +/** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk * @ops: Function pointers used to access hardware-specific operations. * @ep_list:the gadget's ep_list holds all of its endpoints + * @caps:The structure describing types and directions supported by endoint. * @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. @@ -167,12 +186,14 @@ struct usb_ep_ops { * gadget-ep_list. the control endpoint (gadget-ep0) is not in that list, * and is accessed only in response to a driver setup() callback. */ + struct usb_ep { void*driver_data; const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + struct usb_ep_caps caps; boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] drivers/usb/: Simplify return statements
Hi, (no top-posting) On Fri, Jul 31, 2015 at 05:06:07AM +, Karajgaonkar, Saurabh (S.) wrote: Sure, I'll do that. Just wanted to know whether I should split the patches and send them in this same mail thread (may be something like [PATCH 01/04 V2]) or should I start new threads and send them separately to the respective maintainers. single thread is fine, maintainers will pick single patches. -- balbi signature.asc Description: Digital signature
Re: [PATCH v4 2/5] dt-bindings: Add a binding for Mediatek xHCI host controller
Hi, Sorry for my late reply to a prior version of this series, but I still have concerns with some of the properties. I'll repeat those below. On Fri, Jul 31, 2015 at 02:03:53PM +0100, Chunfeng Yun wrote: add a DT binding documentation of xHCI host controller for the MT8173 SoC from Mediatek. Signed-off-by: Chunfeng Yun chunfeng@mediatek.com --- .../devicetree/bindings/usb/mt8173-xhci.txt| 51 ++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mt8173-xhci.txt diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt new file mode 100644 index 000..364be5a --- /dev/null +++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt @@ -0,0 +1,51 @@ +MT65XX xhci + +The device node for Mediatek SOC usb3.0 host controller + +Required properties: + - compatible : Supports mediatek,mt8173-xhci s/Supports/should contain/ + - reg : Specifies physical base address and size of the registers, + the first one for MAC, the second for IPPC + - interrupts : Interrupt mode, number and trigger mode Just specify what this logically corresponds to; the format of the interrupts proeprty depends on the interrupt controller. + - power-domains : To enable usb's mtcmos Please describe what this contains. I assume you exped a single power domain to be described, covering the whole xHCI controller? + - vusb33-supply : Regulator of usb avdd3.3v + - clocks : Must support all clocks that xhci needs - clocks: a list of phandle + clock-specifier pairs, one for each entry in clock-names. + - clock-names : Should be sys_mac for sys and mac clocks, and + wakeup_deb_p0, wakeup_deb_p1 for wakeup debounce control + clocks This would be better as a list, e.g. - clock-names: should contain: * sys_mac description here if necessary * wakeup_deb_p0 description here if necessary * wakeup_deb_p1 description here if necessary Is sys_mac a single clock input line? Or is it jsut the case that a single line feeds two inputs currently? if the latter they should be separate entries. + - phys : List of PHY specifiers (used by generic PHY framework). The bracketed part should go. The bidnigns should know nothing of Linux internals. + - phy-names : Must be usb-phy0, usb-phy1,.., usb-phyN, based on + the number of PHYs as specified in @phys property. This is useless. You either don't need names, and can acquire the phys by index, or you need names which correspond to those on the data sheet for the xHCI controller. + - mediatek,usb-wakeup : To access usb wakeup control register Please describe what this points to (I guess it's a syscon)/ + - mediatek,wakeup-src : 1: Ip sleep wakeup mode; 2: line state wakeup + mode; others means don't enable wakeup source of usb This sounds like a runtime decision. _why_ do you think this needs to be in the DT? + - mediatek,u2port-num : The number should not greater than the number + of phys This is useless. Either this is implied by the entries in the phys property, or it should be a runtime decision. Thanks, Mark. + +Optional properties: + - vbus-supply : Reference to the VBUS regulator; + +Example: +usb: usb@1127 { + compatible = mediatek,mt8173-xhci; + reg = 0 0x1127 0 0x4000, + 0 0x1128 0 0x0800; + interrupts = GIC_SPI 115 IRQ_TYPE_LEVEL_LOW; + power-domains = scpsys MT8173_POWER_DOMAIN_USB; + clocks = topckgen CLK_TOP_USB30_SEL, + pericfg CLK_PERI_USB0, + pericfg CLK_PERI_USB1; + clock-names = sys_mac, + wakeup_deb_p0, + wakeup_deb_p1; + phys = u3phy 0, u3phy 1; + phy-names = usb-phy0, usb-phy1; + vusb33-supply = mt6397_vusb_reg; + vbus-supply = usb_p1_vbus; + usb3-lpm-capable; + mediatek,usb-wakeup = pericfg; + mediatek,wakeup-src = 1; + mediatek,u2port-num = 2; + status = okay; +}; -- 1.8.1.1.dirty -- 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 20/46] usb: gadget: m66592-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/m66592-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index 9704053..b1cfa96 100644 --- a/drivers/usb/gadget/udc/m66592-udc.c +++ b/drivers/usb/gadget/udc/m66592-udc.c @@ -1644,6 +1644,17 @@ static int m66592_probe(struct platform_device *pdev) ep-ep.name = m66592_ep_name[i]; ep-ep.ops = m66592_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(m66592-ep[0].ep, 64); m66592-ep[0].pipenum = 0; -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 25/46] usb: gadget: omap_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/omap_udc.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index e2fcdb8..9b7d394 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -2579,6 +2579,28 @@ omap_ep_setup(char *name, u8 addr, u8 type, ep-double_buf = dbuf; ep-udc = udc; + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + break; + case USB_ENDPOINT_XFER_ISOC: + ep-ep.caps.type_iso = true; + break; + case USB_ENDPOINT_XFER_BULK: + ep-ep.caps.type_bulk = true; + break; + case USB_ENDPOINT_XFER_INT: + ep-ep.caps.type_int = true; + break; + }; + + if (addr USB_DIR_IN) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-ep.name = ep-name; ep-ep.ops = omap_ep_ops; ep-maxpacket = maxp; -- 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 23/46] usb: gadget: net2272: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2272.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index c2ed5da..18f5ebd 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c @@ -1404,6 +1404,17 @@ net2272_usb_reinit(struct net2272 *dev) else ep-fifo_size = 64; net2272_ep_reset(ep); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(dev-ep[0].ep, 64); -- 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 19/46] usb: gadget: lpc32xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/lpc32xx_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 3b6a785..00b5006 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -2575,6 +2575,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep0, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 0, @@ -2586,6 +2588,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep1-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 2, @@ -2597,6 +2601,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep2-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 4, @@ -2608,6 +2614,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep3-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 6, @@ -2619,6 +2627,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep4-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 8, @@ -2630,6 +2640,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep5-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 10, @@ -2641,6 +2653,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep6-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 12, @@ -2652,6 +2666,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep7-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 14, @@ -2663,6 +2679,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep8-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 16, @@ -2674,6 +2692,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep9-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 18, @@ -2685,6 +2705,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep10-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), },
[PATCH v5 17/46] usb: gadget: goku_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/goku_udc.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 9e8d842..46b8d14 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -1257,6 +1257,14 @@ static void udc_reinit (struct goku_udc *dev) INIT_LIST_HEAD (ep-queue); ep_reset(NULL, ep); + + if (i == 0) + ep-ep.caps.type_control = true; + else + ep-ep.caps.type_bulk = true; + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } dev-ep[0].reg_mode = NULL; -- 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 22/46] usb: gadget: mv_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_udc_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index 5da37c9..339af51 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -1257,6 +1257,9 @@ static int eps_init(struct mv_udc *udc) ep-wedge = 0; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1269,14 +1272,20 @@ static int eps_init(struct mv_udc *udc) if (i % 2) { snprintf(name, sizeof(name), ep%din, i / 2); ep-direction = EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i / 2); ep-direction = EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-udc = udc; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_ep_ops; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 21/46] usb: gadget: mv_u3d_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_u3d_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index ea35a24..4c48969 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -1324,6 +1324,9 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) ep-ep.ops = mv_u3d_ep_ops; ep-wedge = 0; usb_ep_set_maxpacket_limit(ep-ep, MV_U3D_EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_u3d_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1339,14 +1342,20 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) if (i 1) { snprintf(name, sizeof(name), ep%din, i 1); ep-direction = MV_U3D_EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i 1); ep-direction = MV_U3D_EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-u3d = u3d; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_u3d_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); ep-ep_num = i / 2; -- 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 24/46] usb: gadget: net2280: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2280.c | 67 +--- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 2bee912..872ca25 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -74,19 +74,58 @@ static const char driver_desc[] = DRIVER_DESC; static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 }; static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name, - ep-a, ep-b, ep-c, ep-d, - ep-e, ep-f, ep-g, ep-h, -}; -/* Endpoint names for usb3380 advance mode */ -static const char *const ep_name_adv[] = { - ep0name, - ep1in, ep2out, ep3in, ep4out, - ep1out, ep2in, ep3out, ep4in, +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info_dft[] = { /* Default endpoint configuration */ + EP_INFO(ep0name, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-a, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-b, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-c, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-d, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-e, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-f, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-g, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep-h, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), +}, ep_info_adv[] = { /* Endpoints for usb3380 advance mode */ + EP_INFO(ep0name, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep1in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep2out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep3in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep4out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep1out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep2in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep3out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep4in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), }; +#undef EP_INFO + /* mode 0 == ep-{a,b,c,d} 1K fifo each * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable @@ -2055,7 +2094,8 @@ static void usb_reinit_228x(struct net2280 *dev) for (tmp = 0; tmp 7; tmp++) { struct net2280_ep *ep = dev-ep[tmp]; - ep-ep.name = ep_name[tmp]; + ep-ep.name = ep_info_dft[tmp].name; + ep-ep.caps = ep_info_dft[tmp].caps; ep-dev = dev; ep-num = tmp; @@ -2095,7 +2135,10 @@ static void usb_reinit_338x(struct net2280 *dev) for (i = 0; i dev-n_ep; i++) { struct net2280_ep *ep = dev-ep[i]; - ep-ep.name = dev-enhanced_mode ? ep_name_adv[i] : ep_name[i]; + ep-ep.name = dev-enhanced_mode ? ep_info_adv[i].name : + ep_info_dft[i].name; + ep-ep.caps = dev-enhanced_mode ? ep_info_adv[i].caps : + ep_info_dft[i].caps; ep-dev = dev; ep-num = i; -- 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 26/46] usb: gadget: pch_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pch_udc.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index dcf5def..fa9eb3c 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c @@ -2895,11 +2895,21 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev) ep-in = ~i 1; ep-ep.name = ep_string[i]; ep-ep.ops = pch_udc_ep_ops; - if (ep-in) + if (ep-in) { ep-offset_addr = ep-num * UDC_EP_REG_SHIFT; - else + ep-ep.caps.dir_in = true; + } else { ep-offset_addr = (UDC_EPINT_OUT_SHIFT + ep-num) * UDC_EP_REG_SHIFT; + ep-ep.caps.dir_out = true; + } + if (i == UDC_EP0IN_IDX || i == UDC_EP0OUT_IDX) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } /* need to set ep-ep.maxpacket and set Default Configuration?*/ usb_ep_set_maxpacket_limit(ep-ep, UDC_BULK_MAX_PKT_SIZE); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: linux-next: Tree for Jul 31 (usb/phy/phy-qcom-8x16-usb.c)
On 07/30/15 22:47, Stephen Rothwell wrote: Hi all, Changes since 20150730: on i386: when CONFIG_EXTCON=m: drivers/built-in.o: In function `phy_8x16_remove': phy-qcom-8x16-usb.c:(.text+0x24170a): undefined reference to `extcon_unregister_interest' drivers/built-in.o: In function `phy_8x16_init': phy-qcom-8x16-usb.c:(.text+0x241d32): undefined reference to `extcon_get_cable_state' drivers/built-in.o: In function `phy_8x16_probe': phy-qcom-8x16-usb.c:(.text+0x24223c): undefined reference to `extcon_get_edev_by_phandle' phy-qcom-8x16-usb.c:(.text+0x2424bd): undefined reference to `extcon_register_interest' phy-qcom-8x16-usb.c:(.text+0x242582): undefined reference to `extcon_unregister_interest' so config USB_QCOM_8X16_PHY needs to depend on EXTCON. -- ~Randy -- 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
Add commit 3f2cee73b650 (USB: usbfs: allow URBs to be reaped after disconnection) to -stable
Greg: The $SUBJECT commit was added in the 4.0 kernel, but I forgot to mark it for inclusion in the -stable kernels. The problem it fixes is a nasty one, affecting people who use libusb: When a device is disconnected while a libusb transfer is in progress, libusb never receives a completion notification for the transfer. This can result in a hang or a segmentation error, depending on how the userspace program tries to cope. The patch may require some context adjustment before it will apply to the longterm -stable trees, but I think it should be added. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 02/46] usb: gadget: add endpoint capabilities flags
Hi, On Fri, Jul 31, 2015 at 03:51:52PM +, David Laight wrote: From: Robert Baldyga Sent: 31 July 2015 15:00 Introduce struct usb_ep_caps which contains information about capabilities of usb endpoints - supported transfer types and directions. This structure should be filled by UDC driver for each of its endpoints, and will be used in epautoconf in new ep matching mechanism which will replace ugly guessing of endpoint capabilities basing on its name. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 21 + 1 file changed, 21 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 68fb5e8..a9a4959 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -141,10 +141,29 @@ struct usb_ep_ops { }; ... +struct usb_ep_caps { + unsigned type_control:1; + unsigned type_iso:1; + unsigned type_bulk:1; + unsigned type_int:1; + unsigned dir_in:1; + unsigned dir_out:1; +}; With the way this is used (eg below from 13/46) + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; I think it would be more obvious if you used a u8 and explicit bitmasks. The initialisation (as above) would the be explicitly assigning 'not supported' to the other fields. The compiler will also generate much better code... compiler should convert single bit flags into u32 just fine. It's all static data anyway. Besides, single bit flags allow us to have as many as we need without ending up with stuff like: u32 flags; u32 flags1; u32 flags2; etc. Just let the compiler do those conversions for us. -- balbi signature.asc Description: Digital signature
RE: [PATCH v5 02/46] usb: gadget: add endpoint capabilities flags
From: Robert Baldyga Sent: 31 July 2015 15:00 Introduce struct usb_ep_caps which contains information about capabilities of usb endpoints - supported transfer types and directions. This structure should be filled by UDC driver for each of its endpoints, and will be used in epautoconf in new ep matching mechanism which will replace ugly guessing of endpoint capabilities basing on its name. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 21 + 1 file changed, 21 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 68fb5e8..a9a4959 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -141,10 +141,29 @@ struct usb_ep_ops { }; ... +struct usb_ep_caps { + unsigned type_control:1; + unsigned type_iso:1; + unsigned type_bulk:1; + unsigned type_int:1; + unsigned dir_in:1; + unsigned dir_out:1; +}; With the way this is used (eg below from 13/46) + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; I think it would be more obvious if you used a u8 and explicit bitmasks. The initialisation (as above) would the be explicitly assigning 'not supported' to the other fields. The compiler will also generate much better code... David
Re: Fwd: [Bug 102101] USB 3 storage device disconnects after S3 resume,and re-enumerate it.
On Fri, 31 Jul 2015, Aaron Zhou wrote: There is a USB 3 bug . Are you have any suggests? Please try the 4.2-rc4 kernel. The bug may have been fixed already. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Multiple drives on JMS56x-based sata-usb docking station.
On Thu, 30 Jul 2015, Giulio Bernardi wrote: You should check that scsi_report_lun_scan() really does return 1. If it returns 0 instead (because BLIST_NOLUN is set in bflags or for any other reason), that would cause the behavior you see. I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed. It is a bug in scsi_get_device_flags_keyed(): In fact, my device reports these strings for model and vendor: vendor = Inateck 0101 model = 0101 That's not quite right. The vendor string is always exactly 8 bytes, the model string is always exactly 16 bytes, and the revision string is always exactly 4 bytes. Therefore your device actually reports vendor = Inateck , model = , and revision = 0101. and this matches with this entry in the global scsi device list: {, Scanner, 1.80, BLIST_NOLUN} In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so memcmp always passes, and the check on model passes because the code assumes that max length of model is 16: when trimming the string (which is exactly 16 spaces followed by 0101) it ends up with an empty string, which then matches whatever string for the same reason of the previous check. Yes, both of those checks are buggy. I'm surprised they weren't fixed long ago. I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it works, but I don't know if other devices do exist with a longer model string. Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not for USB devices? Those limits always hold for all SCSI devices, including USB. They are part of the SCSI specification. The right way to fix this is to change the tests, not to increase the max string length. Does the patch below fix the problem for you? However, who should I notify about the issue? linux-scsi mailing list? bugzilla? If the patch works, I will submit it to the Linux SCSI maintainer. Thank you again for the support, I wouldn't have been able to discover this alone. You're welcome. Alan Stern Index: usb-4.1/drivers/scsi/scsi_devinfo.c === --- usb-4.1.orig/drivers/scsi/scsi_devinfo.c +++ usb-4.1/drivers/scsi/scsi_devinfo.c @@ -592,16 +592,11 @@ int scsi_get_device_flags_keyed(struct s max--; vendor++; } - /* -* XXX removing the following strlen() would be -* good, using it means that for a an entry not in -* the list, we scan every byte of every vendor -* listed in scsi_static_device_list[], and never match -* a single one (and still have to compare at -* least the first byte of each vendor). -*/ - if (memcmp(devinfo-vendor, vendor, - min(max, strlen(devinfo-vendor + /* Also skip trailing spaces */ + while (max 0 vendor[max - 1] == ' ') + --max; + if (memcmp(devinfo-vendor, vendor, max) || + devinfo-vendor[max]) continue; /* * Skip spaces again. @@ -611,8 +606,10 @@ int scsi_get_device_flags_keyed(struct s max--; model++; } - if (memcmp(devinfo-model, model, - min(max, strlen(devinfo-model + while (max 0 model[max - 1] == ' ') + --max; + if (memcmp(devinfo-model, model, max) || + devinfo-model[max]) continue; return devinfo-flags; } else { -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] drivers: usb: fsl: Workaround for USB erratum-A005275
On Fri, 31 Jul 2015, Nikhil Badola wrote: Incoming packets in high speed are randomly corrupted by h/w resulting in multiple errors. This workaround makes FS as default mode in all affected socs by disabling HS chirp signalling.This errata does not affect FS and LS mode. Forces all HS devices to connect in FS mode for all socs affected by this erratum: P3041 and P2041 rev 1.0 and 1.1 P5020 and P5010 rev 1.0 and 2.0 P5040, P1010 and T4240 rev 1.0 Ooh, that's a really bad bug. People will be pretty annoyed that they can't use high speed connections. --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -1222,6 +1222,13 @@ int ehci_hub_control( ehci-reset_done [wIndex] = jiffies + msecs_to_jiffies (50); } + + /* Force full-speed connect for FSL high-speed erratum; + * disable HS Chirp by setting PFSC bit + */ + if (ehci_has_fsl_hs_errata(ehci)) + temp |= (1 PORTSC_FSL_PFSC); + This hunk was added in the wrong place. It should come before the closing '}' above, not after. That's because you don't want to force a full-speed connection if the device is already using low speed. --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -215,6 +215,7 @@ struct ehci_hcd { /* one per controller */ /* SILICON QUIRKS */ unsignedno_selective_suspend:1; unsignedhas_fsl_port_bug:1; /* FreeScale */ + unsignedhas_fsl_hs_errata:1;/* Freescale HS quirk */ unsignedbig_endian_mmio:1; unsignedbig_endian_desc:1; unsignedbig_endian_capbase:1; @@ -675,6 +676,17 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) #define ehci_port_speed(ehci, portsc) USB_PORT_STAT_HIGH_SPEED #endif +#define PORTSC_FSL_PFSC 24 /* Port Force Full-Speed Connect */ + +#if defined(CONFIG_PPC_85xx) +/* Some Freescale processors have an erratum (USB A-005275) in which + * incoming packets get corrupted in HS mode + */ +#define ehci_has_fsl_hs_errata(e)((e)-has_fsl_hs_errata) +#else +#define ehci_has_fsl_hs_errata(e)(0) +#endif + /*-*/ I would prefer it if you add your new hunk after this /*-...---*/ dividing line (that is, next to the ehci_has_fsl_portno_bug() code) instead of before the dividing line. Otherwise this looks okay. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v9 4/4] USB: io_ti: Add heartbeat to keep idle EP/416 ports from disconnecting
On Fri, 2015-07-31 at 12:21 +0200, Johan Hovold wrote: On Fri, Jul 31, 2015 at 01:55:08AM -0500, Peter E. Berger wrote: From: Peter E. Berger pber...@brimson.com When using Edgeport/416 models with newer firmware (sometime after firmware version 4.80.0), idle ports are automatically bounced (disconnected and then reconnected) approximately every 60 seconds. This breaks programs (e.g: minicom) where idle periods are common, normal and expected. I confirmed with the manufacturer (Digi International) that Edgeport/416 models now ship from the factory with firmware that expects periodic heartbeat queries from the driver to keep idle ports alive. This patch implements heartbeat support using the mechanism Digi suggested (periodically requesting an I2C descriptor address) that appears effective on Edgeports running the newer firmware (that require it) and benign on Edgeport devices running older firmware. Since we know that Edgeport firmware version 4.80 (the version distributed in /lib/firmware/down3.bin and used for Edgeports that are either running still older versions or have no onboard non-volatile firmware image) does not require heartbeat support, this patch schedules heartbeats only on Edgeport/416 devices, and only if they are running firmware versions newer than 4.80. Signed-off-by: Peter E. Berger pber...@brimson.com All now applied for 4.3 (this one with some really minor style changes). Wonderful! Thanks so much to you, Sergei, Oliver and Don for all your thoughtful comments and patience in helping me get these patches into shape. Best regards, --Peter Thanks again for fixing this! 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: [PATCH v3 2/5] dt-bindings: Add a binding for Mediatek xHCI host controller
Hi, + - mediatek,usb-wakeup: to access usb wakeup control register What exactly does this property imply? There are some control registers for usb wakeup which are put in another module, here to get the node of that module, and then use regmap and syscon to operate it. Ok. You need to specify the type of this property (i.e. that it is a phandle to a syscon node). The description makes it sound like a boolean. + - mediatek,wakeup-src: 1: ip sleep wakeup mode; 2: line state wakeup + mode; others means don't enable wakeup source of usb This sounds like configuration rather than a hardware property. Why do you think this needs to be in the DT? Yes, it's better to put it in the DT. That doesn't answer my question. _why_ do you think this needs to be in the DT? What do you think is better for it being there? + - mediatek,u2port-num: the number should not greater than the number + of phys What exactly does this property imply? On some platform, it only makes use of partial usb ports, so disable others to save power. What exactly do you mean by partial USB ports? If a phy isn't wired up, it won't be listed in the phys property, if it is then disabling it sounds like a run-time decision. Thanks, Mark. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: gadget: mass_storage: Use static array for luns
Hi, On Fri, Jul 31, 2015 at 02:08:04PM +0200, Krzysztof Opasiak wrote: Hi, On 07/30/2015 06:43 PM, Felipe Balbi wrote: Hi, On Thu, Jul 23, 2015 at 07:57:49PM +0200, Krzysztof Opasiak wrote: This patch replace dynamicly allocated luns array with static one. This simplifies the code of mass storage function and modules. Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com this actually regresses g_mass_storage: # modprobe g_mass_storage removable=1 [ 40.115294] Mass Storage Function, version: 2009/09/11 [ 40.120680] LUN: removable file: (no medium) [ 40.125374] Unable to handle kernel NULL pointer dereference at virtual address 0054 [ 40.133863] pgd = ed574000 [ 40.136689] [0054] *pgd= [ 40.140429] Internal error: Oops: 5 [#1] SMP ARM [ 40.145238] Modules linked in: g_mass_storage(+) usb_f_mass_storage libcomposite xhci_plat_hcd xhci_hcd usbcore joydev dwc3 udc_core usb_common evdev cpufreq_dt omapfb snd_soc_evm thermal_sys cfbfillrect cfbimgblt cfbcopyarea matrix_keypad hwmon leds_gpio led_class matrix_keymap pwm_bl panel_dpi snd_soc_tlv320aic3x snd_soc_davinci_mcasp snd_soc_edma snd_soc_omap snd_soc_core omapdss snd_compress snd_pcm_dmaengine snd_pcm dwc3_omap snd_timer lis3lv02d_i2c extcon pwm_tiecap snd lis3lv02d input_polldev soundcore rtc_omap spi_ti_qspi omap_wdt tps65218_pwrbutton phy_omap_usb2 ipv6 autofs4 [ 40.199522] CPU: 0 PID: 244 Comm: modprobe Not tainted 4.2.0-rc4-00060-g691ddfcf5846 #755 [ 40.208039] Hardware name: Generic AM43 (Flattened Device Tree) [ 40.214210] task: ed01e240 ti: ee7be000 task.ti: ee7be000 [ 40.219843] PC is at kernfs_find_ns+0xc/0x138 [ 40.224381] LR is at kernfs_find_and_get_ns+0x30/0x4c [ 40.229649] pc : [c01de508]lr : [c01de664]psr: 200f0013 [ 40.229649] sp : ee7bfc68 ip : 0002 fp : bf0aa740 [ 40.241609] r10: bf0aa788 r9 : ed3353c0 r8 : [ 40.247055] r7 : r6 : c06466a4 r5 : r4 : c0917840 [ 40.253851] r3 : c093c5d4 r2 : r1 : c06466a4 r0 : [ 40.260651] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 40.268085] Control: 10c5387d Table: ad574059 DAC: 0015 [ 40.274069] Process modprobe (pid: 244, stack limit = 0xee7be218) [ 40.280415] Stack: (0xee7bfc68 to 0xee7c) [ 40.284959] fc60: c0917840 c06466a4 ed214400 c01de664 [ 40.293478] fc80: c09474d0 ee56f438 ee56f430 c01e13d4 c09474a0 [ 40.301996] fca0: ee56f438 c03f6384 ee56f430 ee56f430 ed214598 c03ec6d0 bf0aa788 c008e820 [ 40.310519] fcc0: c015a7d4 ed01e240 ee56f430 ed2144d0 ed214598 ed21450c ed214400 c03ec8b8 [ 40.319048] fce0: ee56f400 bf10f304 ee533e00 ee533e04 bf0aa980 bf0aa54c 0001 bf10f374 [ 40.327572] fd00: bf115840 bf07ec18 fff0 bf0aa0a0 c05fe878 0001 0100 [ 40.336089] fd20: ed506098 bf2f8528 c0979e80 600f0093 c0091548 [ 40.344612] fd40: 0001 0080 bf2f8528 ed01e768 ed01e240 0004 [ 40.353137] fd60: 0006 12d341e8 bf0aa788 c008e820 c06008b8 ed01e240 0001 bf0aa694 [ 40.361654] fd80: c008e984 a00f0013 ed506088 ed506088 c06008b8 [ 40.370172] fda0: ed335301 0002 ed3353c0 bf0aa6bc [ 40.378690] fdc0: ed506170 12d341e8 bf07ea84 bf2e7d08 ee53b000 bf0aa6bc ee53b000 [ 40.387207] fde0: bf0aa6bc ed2cbd00 ee53b008 12d341e8 bf0aa788 bf0aa740 bf2e7b90 [ 40.395724] fe00: bf2e8308 bf0aa6bc ed2cbd00 bf0b bf2e7d44 c08c9ea0 [ 40.404241] fe20: c08c9ea0 c00097a4 0001 c0150fe4 eeef9000 [ 40.412766] fe40: ef7c8460 4000 001e c008ec68 ee5e1e40 00d0 00d0 c015ba10 [ 40.421283] fe60: ee7bff58 c008ec68 c08c63a8 600f0013 a00f0013 bf0aa740 bf0aa740 c0979fd4 [ 40.429811] fe80: ee5e1e40 ed2cbe40 0001 bf0aa788 bf0aa740 c05f7d28 c0979fd4 0001 [ 40.438334] fea0: ee7bff58 c0979fd4 0001 c00c88c4 bf0aa74c 7fff c00c606c [ 40.446857] fec0: c1153024 0124 bf0aa74c bf0aa95c ee7bff60 f03a29a4 bf0aa74c [ 40.455381] fee0: 02e401dd 000f 000181a4 0001 [ 40.463900] ff00: [ 40.472424] ff20: 7f643410 0005 7f643410 [ 40.480941] ff40: 017b c000f724 ee7be000 7f6431c8 c00c91c0 f0385000 0001d9f4 [ 40.489471] ff60: f03a2314 f039a942 f039b5e0 09a8 0e38 [ 40.497993] ff80: 002a 002b 0012 0016 000b 000b [ 40.506537] ffa0: 000b c000f540 000b 0005 7f643410 7f6431b0 [
[PATCH v5 44/46] usb: gadget: net2280: add net2280_match_ep() function
Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching process. Function does the same that was done by chip-specific code inside of epautoconf. Now this code can be removed from there to separate generic code from platform specific logic. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 23 +-- drivers/usb/gadget/udc/net2280.c | 31 +++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index cc0b084..d41fd82 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -86,28 +86,7 @@ struct usb_ep *usb_ep_autoconfig_ss( /* First, apply chip-specific best usage knowledge. * This might make a good usb_gadget_ops hook ... */ - if (gadget_is_net2280(gadget)) { - char name[8]; - - if (type == USB_ENDPOINT_XFER_INT) { - /* ep-e, ep-f are PIO with only 64 byte fifos */ - ep = gadget_find_ep_by_name(gadget, ep-e); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - ep = gadget_find_ep_by_name(gadget, ep-f); - if (ep usb_gadget_ep_match_desc(gadget, - ep, desc, ep_comp)) - goto found_ep; - } - - /* USB3380: use same address for usb and hardware endpoints */ - snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), - usb_endpoint_dir_in(desc) ? in : out); - ep = gadget_find_ep_by_name(gadget, name); - if (ep usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp)) - goto found_ep; - } else if (gadget_is_goku (gadget)) { + if (gadget_is_goku (gadget)) { if (USB_ENDPOINT_XFER_INT == type) { /* single buffering is enough */ ep = gadget_find_ep_by_name(gadget, ep3-bulk); diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 872ca25..9d7eac1 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -1550,6 +1550,36 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on) return 0; } +static struct usb_ep *net2280_match_ep(struct usb_gadget *_gadget, + struct usb_endpoint_descriptor *desc, + struct usb_ss_ep_comp_descriptor *ep_comp) +{ + char name[8]; + struct usb_ep *ep; + u8 type; + + type = usb_endpoint_type(desc); + + if (type == USB_ENDPOINT_XFER_INT) { + /* ep-e, ep-f are PIO with only 64 byte fifos */ + ep = gadget_find_ep_by_name(_gadget, ep-e); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + ep = gadget_find_ep_by_name(_gadget, ep-f); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + } + + /* USB3380: use same address for usb and hardware endpoints */ + snprintf(name, sizeof(name), ep%d%s, usb_endpoint_num(desc), + usb_endpoint_dir_in(desc) ? in : out); + ep = gadget_find_ep_by_name(_gadget, name); + if (ep usb_gadget_ep_match_desc(_gadget, ep, desc, ep_comp)) + return ep; + + return NULL; +} + static int net2280_start(struct usb_gadget *_gadget, struct usb_gadget_driver *driver); static int net2280_stop(struct usb_gadget *_gadget); @@ -1561,6 +1591,7 @@ static const struct usb_gadget_ops net2280_ops = { .pullup = net2280_pullup, .udc_start = net2280_start, .udc_stop = net2280_stop, + .match_ep = net2280_match_ep, }; /*-*/ -- 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 12/46] usb: gadget: dummy-hcd: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/dummy_hcd.c | 95 -- 1 file changed, 80 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 181112c..1379ad4 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -127,23 +127,87 @@ static inline struct dummy_request *usb_request_to_dummy_request static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name,/* everyone has ep0 */ +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + /* everyone has ep0 */ + EP_INFO(ep0name, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), /* act like a pxa250: fifteen fixed function endpoints */ - ep1in-bulk, ep2out-bulk, ep3in-iso, ep4out-iso, ep5in-int, - ep6in-bulk, ep7out-bulk, ep8in-iso, ep9out-iso, ep10in-int, - ep11in-bulk, ep12out-bulk, ep13in-iso, ep14out-iso, - ep15in-int, - + EP_INFO(ep1in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep2out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep3in-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep4out-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep5in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep6in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep7out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep8in-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep9out-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep10in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep11in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep12out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep13in-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep14out-iso, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep15in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), /* or like sa1100: two fixed function endpoints */ - ep1out-bulk, ep2in-bulk, - + EP_INFO(ep1out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep2in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), /* and now some generic EPs so we have enough in multi config */ - ep3out, ep4in, ep5out, ep6out, ep7in, ep8out, ep9in, - ep10out, ep11out, ep12in, ep13out, ep14in, ep15out, + EP_INFO(ep3out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep4in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep5out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep6out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep7in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep8out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep9in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep10out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep11out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep12in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep13out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep14in, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep15out, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_OUT)), + +#undef EP_INFO }; -#define DUMMY_ENDPOINTSARRAY_SIZE(ep_name) + +#define DUMMY_ENDPOINTSARRAY_SIZE(ep_info) /*-*/ @@ -938,9 +1002,10 @@ static void init_dummy_udc_hw(struct dummy *dum) for (i = 0; i DUMMY_ENDPOINTS; i++) { struct dummy_ep *ep = dum-ep[i]; - if
[PATCH v5 09/46] usb: gadget: at91_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/at91_udc.c | 38 +- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c index 32f50a7..d0d1894 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c @@ -59,15 +59,34 @@ #defineDRIVER_VERSION 3 May 2006 static const char driver_name [] = at91_udc; -static const char * const ep_names[] = { - ep0, - ep1, - ep2, - ep3-int, - ep4, - ep5, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + + EP_INFO(ep0, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep1, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep2, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep3-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep4, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep5, + USB_EP_CAPS(USB_EP_CAPS_TYPE_ALL, USB_EP_CAPS_DIR_ALL)), + +#undef EP_INFO }; -#define ep0nameep_names[0] + +#define ep0nameep_info[0].name #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) @@ -1831,7 +1850,8 @@ static int at91udc_probe(struct platform_device *pdev) for (i = 0; i NUM_ENDPOINTS; i++) { ep = udc-ep[i]; - ep-ep.name = ep_names[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = at91_ep_ops; ep-udc = udc; ep-int_mask = BIT(i); -- 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 10/46] usb: gadget: bcm63xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bcm63xx_udc.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 9db968b..8cbb003 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -44,9 +44,29 @@ #define DRV_MODULE_NAMEbcm63xx_udc static const char bcm63xx_ep0name[] = ep0; -static const char *const bcm63xx_ep_name[] = { - bcm63xx_ep0name, - ep1in-bulk, ep2out-bulk, ep3in-int, ep4out-int, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} bcm63xx_ep_info[] = { +#define EP_INFO(_name, _caps) \ + { \ + .name = _name, \ + .caps = _caps, \ + } + + EP_INFO(bcm63xx_ep0name, + USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), + EP_INFO(ep1in-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep2out-bulk, + USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_OUT)), + EP_INFO(ep3in-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), + EP_INFO(ep4out-int, + USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_OUT)), + +#undef EP_INFO }; static bool use_fullspeed; @@ -943,7 +963,8 @@ static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc) for (i = 0; i BCM63XX_NUM_EP; i++) { struct bcm63xx_ep *bep = udc-bep[i]; - bep-ep.name = bcm63xx_ep_name[i]; + bep-ep.name = bcm63xx_ep_info[i].name; + bep-ep.caps = bcm63xx_ep_info[i].caps; bep-ep_num = i; bep-ep.ops = bcm63xx_udc_ep_ops; list_add_tail(bep-ep.ep_list, udc-gadget.ep_list); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Multiple drives on JMS56x-based sata-usb docking station.
On Fri, 31 Jul 2015, Giulio Bernardi wrote: On 31/07/2015 18:05, Alan Stern wrote: On Thu, 30 Jul 2015, Giulio Bernardi wrote: You should check that scsi_report_lun_scan() really does return 1. If it returns 0 instead (because BLIST_NOLUN is set in bflags or for any other reason), that would cause the behavior you see. I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed. It is a bug in scsi_get_device_flags_keyed(): In fact, my device reports these strings for model and vendor: vendor = Inateck 0101 model = 0101 That's not quite right. The vendor string is always exactly 8 bytes, the model string is always exactly 16 bytes, and the revision string is always exactly 4 bytes. Therefore your device actually reports vendor = Inateck , model = , and revision = 0101. and this matches with this entry in the global scsi device list: {, Scanner, 1.80, BLIST_NOLUN} In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so memcmp always passes, and the check on model passes because the code assumes that max length of model is 16: when trimming the string (which is exactly 16 spaces followed by 0101) it ends up with an empty string, which then matches whatever string for the same reason of the previous check. Yes, both of those checks are buggy. I'm surprised they weren't fixed long ago. I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it works, but I don't know if other devices do exist with a longer model string. Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not for USB devices? Those limits always hold for all SCSI devices, including USB. They are part of the SCSI specification. The right way to fix this is to change the tests, not to increase the max string length. Does the patch below fix the problem for you? I tried the patch but it doesn't work. I applied it without looking at it before, but the problem is that actually vendor variable is really Inateck 0101 (28 chars) and model is really 0101 (20 chars): at least, that's the data that is passed to scsi_get_device_flags_keyed(). Those variables are _not_ NUL-terminated strings. They are simply character arrays. model is an array of 8 characters and vendor is an array of 16 characters. So your code is never executed + while (max 0 model[max - 1] == ' ') + --max; + if (memcmp(devinfo-model, model, max) || + devinfo-model[max]) because max is already 0 from the previous loop. You mean that the while loop terminates immediately. That's okay; it's supposed to do that when every character in model is ' '. The memcmp call should return 0 because max is 0. But since devinfo-model[0] is 'S' (the first letter of Scanner), the if statement should succeed. Therefore your device should not match the devinfo entry. Maybe I should see where vendor and model come from? Maybe they are concatenated from the original vendor and model values reported from the device, so that might be why those strings are so long. That is exactly where they come from. The device does not report strings, however. It reports an array of 28 characters (8 for the vendor, 16 for the model, and 4 for the revision). Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Add commit 3f2cee73b650 (USB: usbfs: allow URBs to be reaped after disconnection) to -stable
On Fri, Jul 31, 2015 at 10:56:20AM -0400, Alan Stern wrote: Greg: The $SUBJECT commit was added in the 4.0 kernel, but I forgot to mark it for inclusion in the -stable kernels. The problem it fixes is a nasty one, affecting people who use libusb: When a device is disconnected while a libusb transfer is in progress, libusb never receives a completion notification for the transfer. This can result in a hang or a segmentation error, depending on how the userspace program tries to cope. The patch may require some context adjustment before it will apply to the longterm -stable trees, but I think it should be added. Now queued up to 3.10 and 3.14-stable, 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: Multiple drives on JMS56x-based sata-usb docking station.
On Fri, 31 Jul 2015, Giulio Bernardi wrote: Okay, i checked a little bit and now I understand, sorry. They are pointers to different offset of the same string (the inquiry result), that's why it's only meaningful to check first 8 and subsequent 16 characters. Sorry. The problem is that: {, Scanner} and {Inateck,} do match because an empty string always matches. So vendor matches because the entry from the list is empty, while model matches because the model of the actual device is empty. With my patch, empty strings do _not_ match. Not unless _both_ strings are empty. I am trying to think what the right solution might be. The {, Scanner} case seems to suggest that is meant as a wildcard. No, it doesn't. It means that the vendor is empty (all ' ' characters). Maybe the right solution would be that is a wildcard only in the device list, and not in the real device? That is, if a real device has as a vendor/model string, it should only match a device from a list that has , and not interpreted as a wildcard. These things are not wildcards. Go look more carefully at my patch and figure out what is really happening. Alan Stern -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Multiple drives on JMS56x-based sata-usb docking station.
On 31/07/2015 20:05, Giulio Bernardi wrote: On 31/07/2015 18:05, Alan Stern wrote: On Thu, 30 Jul 2015, Giulio Bernardi wrote: You should check that scsi_report_lun_scan() really does return 1. If it returns 0 instead (because BLIST_NOLUN is set in bflags or for any other reason), that would cause the behavior you see. I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed. It is a bug in scsi_get_device_flags_keyed(): In fact, my device reports these strings for model and vendor: vendor = Inateck 0101 model = 0101 That's not quite right. The vendor string is always exactly 8 bytes, the model string is always exactly 16 bytes, and the revision string is always exactly 4 bytes. Therefore your device actually reports vendor = Inateck , model = , and revision = 0101. and this matches with this entry in the global scsi device list: {, Scanner, 1.80, BLIST_NOLUN} In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so memcmp always passes, and the check on model passes because the code assumes that max length of model is 16: when trimming the string (which is exactly 16 spaces followed by 0101) it ends up with an empty string, which then matches whatever string for the same reason of the previous check. Yes, both of those checks are buggy. I'm surprised they weren't fixed long ago. I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it works, but I don't know if other devices do exist with a longer model string. Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not for USB devices? Those limits always hold for all SCSI devices, including USB. They are part of the SCSI specification. The right way to fix this is to change the tests, not to increase the max string length. Does the patch below fix the problem for you? I tried the patch but it doesn't work. I applied it without looking at it before, but the problem is that actually vendor variable is really Inateck 0101 (28 chars) and model is really 0101 (20 chars): at least, that's the data that is passed to scsi_get_device_flags_keyed(). So your code is never executed +while (max 0 model[max - 1] == ' ') +--max; +if (memcmp(devinfo-model, model, max) || +devinfo-model[max]) because max is already 0 from the previous loop. Maybe I should see where vendor and model come from? Maybe they are concatenated from the original vendor and model values reported from the device, so that might be why those strings are so long. Giulio Okay, i checked a little bit and now I understand, sorry. They are pointers to different offset of the same string (the inquiry result), that's why it's only meaningful to check first 8 and subsequent 16 characters. Sorry. The problem is that: {, Scanner} and {Inateck,} do match because an empty string always matches. So vendor matches because the entry from the list is empty, while model matches because the model of the actual device is empty. I am trying to think what the right solution might be. The {, Scanner} case seems to suggest that is meant as a wildcard. Maybe the right solution would be that is a wildcard only in the device list, and not in the real device? That is, if a real device has as a vendor/model string, it should only match a device from a list that has , and not interpreted as a wildcard. Giulio -- 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: Multiple drives on JMS56x-based sata-usb docking station.
On 31/07/2015 22:10, Giulio Bernardi wrote: On 31/07/2015 20:36, Alan Stern wrote: These things are not wildcards. Go look more carefully at my patch and figure out what is really happening. Alan Stern Ok, it turns out your patch is ok and I can confirm everything works as expected: this docking station is sometimes a bit loose so one of the drives was not completely inserted (again). Sorry for this, and also for having been too quick in making wrong assumptions. Thank you again, Giulio P.S: it looks like scsi_dev_info_list_del_keyed() shares the same code, so maybe it should be modified too? -- 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: Multiple drives on JMS56x-based sata-usb docking station.
On 31/07/2015 20:36, Alan Stern wrote: These things are not wildcards. Go look more carefully at my patch and figure out what is really happening. Alan Stern Ok, it turns out your patch is ok and I can confirm everything works as expected: this docking station is sometimes a bit loose so one of the drives was not completely inserted (again). Sorry for this, and also for having been too quick in making wrong assumptions. Thank you again, Giulio -- 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 net-next] r8152: disable the capability of zero length
From: Hayes Wang hayesw...@realtek.com Date: Fri, 31 Jul 2015 11:23:39 +0800 The UEFI driver would enable zero length, and the Linux driver doesn't need it. Zero length let the hw complete the transfer with length 0, when there is no received packet. It would add the load of USB host controller and reduce the performance. Signed-off-by: Hayes Wang hayesw...@realtek.com Applied. -- 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: Multiple drives on JMS56x-based sata-usb docking station.
On 31/07/2015 18:05, Alan Stern wrote: On Thu, 30 Jul 2015, Giulio Bernardi wrote: You should check that scsi_report_lun_scan() really does return 1. If it returns 0 instead (because BLIST_NOLUN is set in bflags or for any other reason), that would cause the behavior you see. I found the reason of this behavior: there is BLIST_NOLUN in bflags indeed. It is a bug in scsi_get_device_flags_keyed(): In fact, my device reports these strings for model and vendor: vendor = Inateck 0101 model = 0101 That's not quite right. The vendor string is always exactly 8 bytes, the model string is always exactly 16 bytes, and the revision string is always exactly 4 bytes. Therefore your device actually reports vendor = Inateck , model = , and revision = 0101. and this matches with this entry in the global scsi device list: {, Scanner, 1.80, BLIST_NOLUN} In fact: the check on vendor passes because strlen(devinfo-vendor) == 0 so memcmp always passes, and the check on model passes because the code assumes that max length of model is 16: when trimming the string (which is exactly 16 spaces followed by 0101) it ends up with an empty string, which then matches whatever string for the same reason of the previous check. Yes, both of those checks are buggy. I'm surprised they weren't fixed long ago. I am recompiling the kernel now, with max = 20 instead of max = 16 to see if it works, but I don't know if other devices do exist with a longer model string. Maybe those limits (8 for vendor, 16 for model) were true for real scsi and not for USB devices? Those limits always hold for all SCSI devices, including USB. They are part of the SCSI specification. The right way to fix this is to change the tests, not to increase the max string length. Does the patch below fix the problem for you? I tried the patch but it doesn't work. I applied it without looking at it before, but the problem is that actually vendor variable is really Inateck 0101 (28 chars) and model is really 0101 (20 chars): at least, that's the data that is passed to scsi_get_device_flags_keyed(). So your code is never executed + while (max 0 model[max - 1] == ' ') + --max; + if (memcmp(devinfo-model, model, max) || + devinfo-model[max]) because max is already 0 from the previous loop. Maybe I should see where vendor and model come from? Maybe they are concatenated from the original vendor and model values reported from the device, so that might be why those strings are so long. Giulio -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] extcon: Fix extcon_cable_get_state() from getting old state after notification
Hi Roger, On 07/06/2015 11:46 PM, Roger Quadros wrote: Currently the extcon code notifiers the interested listeners before it updates the extcon state with the new state. This will cause the listeners that use extcon_cable_get_state() to get the stale state and loose the new state. Fix this by first changing the extcon state variable and then notifying listeners. Signed-off-by: Roger Quadros rog...@ti.com --- drivers/extcon/extcon.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) Applied it. Thanks, Chanwoo Choi diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 868c6e2..26d1e1e 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -275,19 +275,25 @@ int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state) spin_lock_irqsave(edev-lock, flags); if (edev-state != ((edev-state ~mask) | (state mask))) { + u32 old_state; + if (check_mutually_exclusive(edev, (edev-state ~mask) | (state mask))) { spin_unlock_irqrestore(edev-lock, flags); return -EPERM; } + old_state = edev-state; + edev-state = ~mask; + edev-state |= state mask; + for (index = 0; index edev-max_supported; index++) { - if (is_extcon_changed(edev-state, state, index, attached)) - raw_notifier_call_chain(edev-nh[index], attached, edev); + if (is_extcon_changed(old_state, edev-state, index, + attached)) + raw_notifier_call_chain(edev-nh[index], + attached, edev); } - edev-state = ~mask; - edev-state |= state mask; /* This could be in interrupt handler */ prop_buf = (char *)get_zeroed_page(GFP_ATOMIC); -- 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 v9 4/4] USB: io_ti: Add heartbeat to keep idle EP/416 ports from disconnecting
From: Peter E. Berger pber...@brimson.com When using Edgeport/416 models with newer firmware (sometime after firmware version 4.80.0), idle ports are automatically bounced (disconnected and then reconnected) approximately every 60 seconds. This breaks programs (e.g: minicom) where idle periods are common, normal and expected. I confirmed with the manufacturer (Digi International) that Edgeport/416 models now ship from the factory with firmware that expects periodic heartbeat queries from the driver to keep idle ports alive. This patch implements heartbeat support using the mechanism Digi suggested (periodically requesting an I2C descriptor address) that appears effective on Edgeports running the newer firmware (that require it) and benign on Edgeport devices running older firmware. Since we know that Edgeport firmware version 4.80 (the version distributed in /lib/firmware/down3.bin and used for Edgeports that are either running still older versions or have no onboard non-volatile firmware image) does not require heartbeat support, this patch schedules heartbeats only on Edgeport/416 devices, and only if they are running firmware versions newer than 4.80. Signed-off-by: Peter E. Berger pber...@brimson.com --- drivers/usb/serial/io_ti.c | 93 +- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index efabfc6..c1c093a 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -120,7 +120,9 @@ struct edgeport_serial { struct mutex es_lock; int num_ports_open; struct usb_serial *serial; + struct delayed_work heartbeat_work; int fw_version; + bool use_heartbeat; }; @@ -225,6 +227,22 @@ static void edge_send(struct usb_serial_port *port, struct tty_struct *tty); static int edge_create_sysfs_attrs(struct usb_serial_port *port); static int edge_remove_sysfs_attrs(struct usb_serial_port *port); +/* + * Some release of Edgeport firmware down3.bin after version 4.80 + * introduced code to automatically disconnect idle devices on some + * Edgeport models after periods of inactivity, typically ~60 seconds. + * This occurs without regard to whether ports on the device are open + * or not. Digi International Tech Support suggested: + * + * 1. Adding driver heartbeat code to reset the firmware timer by + * requesting a descriptor record every 15 seconds, which should be + * effective with newer firmware versions that require it, and benign + * with older versions that do not. In practice 40 seconds seems often + * enough. + * 2. The heartbeat code is currently required only on Edgeport/416 models. + */ +#define FW_HEARTBEAT_VERSION_CUTOFF ((4 8) + 80) +#define FW_HEARTBEAT_SECS 40 /* Timeouts in msecs: firmware downloads take longer */ #define TI_VSEND_TIMEOUT_DEFAULT 1000 @@ -2415,6 +2433,35 @@ static void edge_break(struct tty_struct *tty, int break_state) __func__, status); } +static inline void edge_heartbeat_schedule(struct edgeport_serial *edge_serial) +{ + if (edge_serial-use_heartbeat) { + schedule_delayed_work(edge_serial-heartbeat_work, + FW_HEARTBEAT_SECS * HZ); + } +} + +static void edge_heartbeat_work(struct work_struct *work) +{ + struct edgeport_serial *serial; + struct ti_i2c_desc *rom_desc; + + serial = container_of(work, struct edgeport_serial, + heartbeat_work.work); + + rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); + + /* Descriptor address request is enough to reset the firmware timer */ + if (!rom_desc || !get_descriptor_addr(serial, I2C_DESC_TYPE_ION, + rom_desc)) { + dev_err(serial-serial-interface-dev, + %s - Incomplete heartbeat\n, __func__); + } + kfree(rom_desc); + + edge_heartbeat_schedule(serial); +} + static int edge_startup(struct usb_serial *serial) { struct edgeport_serial *edge_serial; @@ -2422,6 +2469,7 @@ static int edge_startup(struct usb_serial *serial) const struct firmware *fw; const char *fw_name = edgeport/down3.bin; struct device *dev = serial-interface-dev; + u16 product_id; /* create our private serial structure */ edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); @@ -2447,6 +2495,19 @@ static int edge_startup(struct usb_serial *serial) return status; } + product_id = le16_to_cpu( + edge_serial-serial-dev-descriptor.idProduct); + + /* Currently only the EP/416 models require heartbeat support */ + if (edge_serial-fw_version FW_HEARTBEAT_VERSION_CUTOFF + (product_id == ION_DEVICE_ID_TI_EDGEPORT_416 || + product_id == ION_DEVICE_ID_TI_EDGEPORT_416B)) { +
[PATCH v9 0/4] Fix idle port disconnects and firmware downloading
From: Peter E. Berger pber...@brimson.com I found that when using the Edgeport EP/416, idle ports are regularly bounced (disconnected and then reconnected). I discussed this with the manufacturer (Digi International) and learned that EP/416 devices now ship from the factory running firmware that requires periodic heartbeat messages from the driver, so I enclose a proposed patch to implement their suggested mechanism (which works both with old and new firmware). While developing my heartbeat patch, I discovered that the firmware download code was not working properly, so I also include three proposed patches to fix this. I welcome any comments or suggestions. Thanks. --Peter Changes since v8 [1] Addressing Sergei's and Johan's review comments. Thanks to you both! - Drop unneeded capitalization in check_fw_sanity dev_err messages. - Use u8 instead of int for checksum. - Use __le16 instead of u16 for build_number and length in edgeport_fw_hdr. - Drop __func__ from Incomplete firmware header and Failed to load image error messages. - Use dev instead of serial-interface-dev in edge_startup. - Add bool use_heartbeat to struct edgeport_serial, set it in edge_startup and check it in edge_heartbeat_schedule. [1]: v8: http://marc.info/?l=linux-usbm=143759139026354w=2 Peter E. Berger (4): USB: io_ti: Increase insufficient timeout for firmware downloads USB: io_ti: Fix firmware version handling USB: io_ti: Add firmware image sanity checks USB: io_ti: Add heartbeat to keep idle EP/416 ports from disconnecting drivers/usb/serial/io_ti.c | 277 ++--- 1 file changed, 211 insertions(+), 66 deletions(-) -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v9 2/4] USB: io_ti: Fix firmware version handling
From: Peter E. Berger pber...@brimson.com The io_ti driver fails to download firmware to Edgeport devices such as the EP/416, even when the on-disk firmware image (/lib/firmware/edgeport/down3.bin) is more current than the version on the EP/416. The current download code is broken in a few ways. Notably it mis-uses global variables OperationalMajorVersion and OperationalMinorVersion (reading their values before they've been properly initialized and subsequently initializing them multiple times without synchronization). This patch drops the global variables and replaces the redundant calls to request_firmware()/release_firmware() in download_fw() with a single call pair in edge_startup(); the firmware image pointer is then passed to download_fw() and build_i2c_fw_hdr(). Signed-off-by: Peter E. Berger pber...@brimson.com --- drivers/usb/serial/io_ti.c | 114 ++--- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 69378a7..b562665 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -71,6 +71,25 @@ struct product_info { __u8hardware_type; /* Type of hardware */ } __attribute__((packed)); +/* + * Edgeport firmware header + * + * build_number has been set to 0 in all three of the images I have + * seen, and Digi Tech Support suggests that it is safe to ignore it. + * + * length is the number of bytes of actual data following the header. + * + * checksum is the low order byte resulting from adding the values of + * all the data bytes. + */ +struct edgeport_fw_hdr { + u8 major_version; + u8 minor_version; + __le16 build_number; + __le16 length; + u8 checksum; +} __packed; + struct edgeport_port { __u16 uart_base; __u16 dma_address; @@ -101,6 +120,7 @@ struct edgeport_serial { struct mutex es_lock; int num_ports_open; struct usb_serial *serial; + int fw_version; }; @@ -187,10 +207,6 @@ static const struct usb_device_id id_table_combined[] = { MODULE_DEVICE_TABLE(usb, id_table_combined); -static unsigned char OperationalMajorVersion; -static unsigned char OperationalMinorVersion; -static unsigned short OperationalBuildNumber; - static int closing_wait = EDGE_CLOSING_WAIT; static bool ignore_cpu_rev; static int default_uart_mode; /* RS232 */ @@ -751,18 +767,17 @@ exit: } /* Build firmware header used for firmware update */ -static int build_i2c_fw_hdr(__u8 *header, struct device *dev) +static int build_i2c_fw_hdr(u8 *header, struct device *dev, + const struct firmware *fw) { __u8 *buffer; int buffer_size; int i; - int err; __u8 cs = 0; struct ti_i2c_desc *i2c_header; struct ti_i2c_image_header *img_header; struct ti_i2c_firmware_rec *firmware_rec; - const struct firmware *fw; - const char *fw_name = edgeport/down3.bin; + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data; /* In order to update the I2C firmware we must change the type 2 record * to type 0xF2. This will force the UMP to come up in Boot Mode. @@ -785,24 +800,11 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) // Set entire image of 0xffs memset(buffer, 0xff, buffer_size); - err = request_firmware(fw, fw_name, dev); - if (err) { - dev_err(dev, Failed to load image \%s\ err %d\n, - fw_name, err); - kfree(buffer); - return err; - } - - /* Save Download Version Number */ - OperationalMajorVersion = fw-data[0]; - OperationalMinorVersion = fw-data[1]; - OperationalBuildNumber = fw-data[2] | (fw-data[3] 8); - /* Copy version number into firmware record */ firmware_rec = (struct ti_i2c_firmware_rec *)buffer; - firmware_rec-Ver_Major = OperationalMajorVersion; - firmware_rec-Ver_Minor = OperationalMinorVersion; + firmware_rec-Ver_Major = fw_hdr-major_version; + firmware_rec-Ver_Minor = fw_hdr-minor_version; /* Pointer to fw_down memory image */ img_header = (struct ti_i2c_image_header *)fw-data[4]; @@ -811,8 +813,6 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) fw-data[4 + sizeof(struct ti_i2c_image_header)], le16_to_cpu(img_header-Length)); - release_firmware(fw); - for (i=0; i buffer_size; i++) { cs = (__u8)(cs + buffer[i]); } @@ -826,8 +826,8 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev) i2c_header-Type= I2C_DESC_TYPE_FIRMWARE_BLANK; i2c_header-Size= cpu_to_le16(buffer_size); i2c_header-CheckSum= cs; - firmware_rec-Ver_Major = OperationalMajorVersion; - firmware_rec-Ver_Minor =
[PATCH v9 3/4] USB: io_ti: Add firmware image sanity checks
From: Peter E. Berger pber...@brimson.com Do what we can to verify that the driver's firmware image is valid (before attempting to download it to the Edgeport) by adding a new function, check_fw_sanity(), and a call to it in in download_fw(). Note: It looks like some Edgeports (models like the EP/416 with on-board E2PROM) may be able to function even if the on-disk firmware image is bad or missing, iff their local E2PROM versions are valid. But most Edgeport models (I've tried EP/1 and EP/8) do not appear to have this capability and they always rely on the on-disk firmware image. I tested an implementation that calls the new check_fw_sanity() function at the top of download_fw() and, rather than simply returning an error if the firmware image is bad or missing, it saves the result and defers the decision until later when it may find that it is running on a E2PROM-equipped device with a valid image. But I think this is messier than it is worth (adding still more messiness to the already very messy download_fw()) for such a marginal possible benefit. So, at least for now, I have chosen the much simpler approach of returning an error whenever edge_startup() fails to load an on-disk firmware image, or check_fw_sanity() indicates that it is unusable. Signed-off-by: Peter E. Berger pber...@brimson.com --- drivers/usb/serial/io_ti.c | 40 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index b562665..efabfc6 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -928,6 +928,41 @@ static int ti_cpu_rev(struct edge_ti_manuf_descriptor *desc) return TI_GET_CPU_REVISION(desc-CpuRev_BoardRev); } +static int check_fw_sanity(struct edgeport_serial *serial, + const struct firmware *fw) +{ + u16 length_total; + u8 checksum = 0; + int pos; + struct device *dev = serial-serial-interface-dev; + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data; + + if (fw-size sizeof(struct edgeport_fw_hdr)) { + dev_err(dev, incomplete fw header\n); + return -EINVAL; + } + + length_total = le16_to_cpu(fw_hdr-length) + + sizeof(struct edgeport_fw_hdr); + + if (fw-size != length_total) { + dev_err(dev, bad fw size (expected: %u, got: %zu)\n, + length_total, fw-size); + return -EINVAL; + } + + for (pos = sizeof(struct edgeport_fw_hdr); pos fw-size; ++pos) + checksum = (checksum + fw-data[pos]) 0xFF; + + if (checksum != fw_hdr-checksum) { + dev_err(dev, bad fw checksum (expected: 0x%x, got: 0x%x)\n, + fw_hdr-checksum, checksum); + return -EINVAL; + } + + return 0; +} + /** * DownloadTIFirmware - Download run-time operating firmware to the TI5052 * @@ -946,11 +981,8 @@ static int download_fw(struct edgeport_serial *serial, int download_new_ver; struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data; - if (fw-size sizeof(struct edgeport_fw_hdr)) { - dev_err(serial-serial-interface-dev, - Incomplete firmware header.\n); + if (check_fw_sanity(serial, fw)) return -EINVAL; - } /* If on-board version is newer, fw_version will be updated below. */ serial-fw_version = (fw_hdr-major_version 8) + -- 1.8.3.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v9 1/4] USB: io_ti: Increase insufficient timeout for firmware downloads
From: Peter E. Berger pber...@brimson.com The io_ti driver fails to download firmware to Edgeport devices such as the EP/416 and EP/421 (devices with on-board E2PROM). One of the problems is that the default 1 second timeout in ti_vsend_sync() is insufficient for download operations. This patch increases the download timeout to 10 seconds. Signed-off-by: Peter E. Berger pber...@brimson.com --- drivers/usb/serial/io_ti.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index ddbb8fe..69378a7 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -210,6 +210,10 @@ static int edge_create_sysfs_attrs(struct usb_serial_port *port); static int edge_remove_sysfs_attrs(struct usb_serial_port *port); +/* Timeouts in msecs: firmware downloads take longer */ +#define TI_VSEND_TIMEOUT_DEFAULT 1000 +#define TI_VSEND_TIMEOUT_FW_DOWNLOAD 1 + static int ti_vread_sync(struct usb_device *dev, __u8 request, __u16 value, __u16 index, u8 *data, int size) { @@ -228,14 +232,14 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request, return 0; } -static int ti_vsend_sync(struct usb_device *dev, __u8 request, - __u16 value, __u16 index, u8 *data, int size) +static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value, + u16 index, u8 *data, int size, int timeout) { int status; status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), - value, index, data, size, 1000); + value, index, data, size, timeout); if (status 0) return status; if (status != size) { @@ -250,7 +254,8 @@ static int send_cmd(struct usb_device *dev, __u8 command, __u8 moduleid, __u16 value, u8 *data, int size) { - return ti_vsend_sync(dev, command, value, moduleid, data, size); + return ti_vsend_sync(dev, command, value, moduleid, data, size, + TI_VSEND_TIMEOUT_DEFAULT); } /* clear tx/rx buffers and fifo in TI UMP */ @@ -378,9 +383,9 @@ static int write_boot_mem(struct edgeport_serial *serial, } for (i = 0; i length; ++i) { - status = ti_vsend_sync(serial-serial-dev, - UMPC_MEMORY_WRITE, buffer[i], - (__u16)(i + start_address), NULL, 0); + status = ti_vsend_sync(serial-serial-dev, UMPC_MEMORY_WRITE, + buffer[i], (u16)(i + start_address), NULL, + 0, TI_VSEND_TIMEOUT_DEFAULT); if (status) return status; } @@ -421,10 +426,9 @@ static int write_i2c_mem(struct edgeport_serial *serial, * regardless of host byte order. */ be_start_address = swab16((u16)start_address); - status = ti_vsend_sync(serial-serial-dev, - UMPC_MEMORY_WRITE, (__u16)address_type, - be_start_address, - buffer, write_length); + status = ti_vsend_sync(serial-serial-dev, UMPC_MEMORY_WRITE, + (u16)address_type, be_start_address, + buffer, write_length, TI_VSEND_TIMEOUT_DEFAULT); if (status) { dev_dbg(dev, %s - ERROR %d\n, __func__, status); return status; @@ -454,9 +458,8 @@ static int write_i2c_mem(struct edgeport_serial *serial, */ be_start_address = swab16((u16)start_address); status = ti_vsend_sync(serial-serial-dev, UMPC_MEMORY_WRITE, - (__u16)address_type, - be_start_address, - buffer, write_length); + (u16)address_type, be_start_address, buffer, + write_length, TI_VSEND_TIMEOUT_DEFAULT); if (status) { dev_err(dev, %s - ERROR %d\n, __func__, status); return status; @@ -1129,7 +1132,8 @@ static int download_fw(struct edgeport_serial *serial) /* Reset UMP -- Back to BOOT MODE */ status = ti_vsend_sync(serial-serial-dev, UMPC_HARDWARE_RESET, - 0, 0, NULL, 0); + 0, 0, NULL, 0, + TI_VSEND_TIMEOUT_DEFAULT); dev_dbg(dev, %s - HARDWARE RESET return %d\n, __func__, status); @@ -1229,7 +1233,9
[PATCH 3/3] phy-sun4i-usb: Only check vbus-det on power-on on boards with vbus-det
data-vbus_det is always 1 on boards without a (working) vbus-det, skip the vbus_det test on such boards. This fixes the sun4i usb phy code never turning on Vbus on such boards. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/phy/phy-sun4i-usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index ddb9fd2..12c5e4eb 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -328,7 +328,8 @@ static int sun4i_usb_phy_power_on(struct phy *_phy) return 0; /* For phy0 only turn on Vbus if we don't have an ext. Vbus */ - if (phy-index == 0 data-vbus_det) + if (phy-index == 0 sun4i_usb_phy0_have_vbus_det(data) + data-vbus_det) return 0; ret = regulator_enable(phy-vbus); -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] phy-sun4i-usb: 3 misc. fixes
Hi Kishon, Here are 3 small patches for the phy-sun4i-usb code. The first patch is a small bugfix for building the sun4i musb code as module which seems to have fallen through the cracks. The second patch is a preparation patch for the third patch which fixes the case of boards with a working VBus regulator, but broken VBus detection support, yes unfortunately such boards exist. Can you please merge these 3 into linux-phy/next ? Thanks Regards, Hans -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] phy-sun4i-usb: Add missing EXPORT_SYMBOL for sun4i_usb_phy_set_squelch_detect
sun4i_usb_phy_set_squelch_detect is used by other code, which may be built as a module, so it should be exported. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v6: -New patch in v6 of the sunxi musb support series --- drivers/phy/phy-sun4i-usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index 5138843..d514a9b 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -347,6 +347,7 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) sun4i_usb_phy_write(phy, PHY_SQUELCH_DETECT, enabled ? 0 : 2, 2); } +EXPORT_SYMBOL(sun4i_usb_phy_set_squelch_detect); static struct phy_ops sun4i_usb_phy_ops = { .init = sun4i_usb_phy_init, -- 2.4.3 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] phy-sun4i-sub: Move vbus-detect helper functions up in the file
Move vbus-detect helper functions up in the file, just moving some code around, no functional changes what so ever. Signed-off-by: Hans de Goede hdego...@redhat.com --- drivers/phy/phy-sun4i-usb.c | 48 ++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index d514a9b..ddb9fd2 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -294,6 +294,30 @@ static int sun4i_usb_phy_exit(struct phy *_phy) return 0; } +static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data) +{ + if (data-vbus_det_gpio) + return gpiod_get_value_cansleep(data-vbus_det_gpio); + + if (data-vbus_power_supply) { + union power_supply_propval val; + int r; + + r = power_supply_get_property(data-vbus_power_supply, + POWER_SUPPLY_PROP_PRESENT, val); + if (r == 0) + return val.intval; + } + + /* Fallback: report vbus as high */ + return 1; +} + +static bool sun4i_usb_phy0_have_vbus_det(struct sun4i_usb_phy_data *data) +{ + return data-vbus_det_gpio || data-vbus_power_supply; +} + static int sun4i_usb_phy_power_on(struct phy *_phy) { struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); @@ -357,30 +381,6 @@ static struct phy_ops sun4i_usb_phy_ops = { .owner = THIS_MODULE, }; -static int sun4i_usb_phy0_get_vbus_det(struct sun4i_usb_phy_data *data) -{ - if (data-vbus_det_gpio) - return gpiod_get_value_cansleep(data-vbus_det_gpio); - - if (data-vbus_power_supply) { - union power_supply_propval val; - int r; - - r = power_supply_get_property(data-vbus_power_supply, - POWER_SUPPLY_PROP_PRESENT, val); - if (r == 0) - return val.intval; - } - - /* Fallback: report vbus as high */ - return 1; -} - -static bool sun4i_usb_phy0_have_vbus_det(struct sun4i_usb_phy_data *data) -{ - return data-vbus_det_gpio || data-vbus_power_supply; -} - static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work) { struct sun4i_usb_phy_data *data = -- 2.4.3 -- 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
Fwd: [Bug 102101] USB 3 storage device disconnects after S3 resume,and re-enumerate it.
There is a USB 3 bug . Are you have any suggests? Aaron Chou -- Forwarded message -- From: bugzilla-dae...@bugzilla.kernel.org Date: Wed, Jul 29, 2015 at 10:13 PM Subject: [Bug 102101] USB 3 storage device disconnects after S3 resume,and re-enumerate it. To: zhoubb.aa...@gmail.com https://bugzilla.kernel.org/show_bug.cgi?id=102101 --- Comment #1 from Greg Kroah-Hartman g...@kroah.com --- On Wed, Jul 29, 2015 at 07:52:12AM +, bugzilla-dae...@bugzilla.kernel.org wrote: https://bugzilla.kernel.org/show_bug.cgi?id=102101 Bug ID: 102101 Summary: USB 3 storage device disconnects after S3 resume,and re-enumerate it. Please send to the linux-usb@vger.kernel.org mailing list. -- You are receiving this mail because: You reported the bug. -- 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] drivers: usb: fsl: Workaround for USB erratum-A005275
Incoming packets in high speed are randomly corrupted by h/w resulting in multiple errors. This workaround makes FS as default mode in all affected socs by disabling HS chirp signalling.This errata does not affect FS and LS mode. Forces all HS devices to connect in FS mode for all socs affected by this erratum: P3041 and P2041 rev 1.0 and 1.1 P5020 and P5010 rev 1.0 and 2.0 P5040, P1010 and T4240 rev 1.0 Signed-off-by: Ramneek Mehresh ramneek.mehr...@freescale.com Signed-off-by: Nikhil Badola nikhil.bad...@freescale.com --- drivers/usb/host/ehci-fsl.c | 4 drivers/usb/host/ehci-hub.c | 7 +++ drivers/usb/host/ehci.h | 12 drivers/usb/host/fsl-mph-dr-of.c | 4 include/linux/fsl_devices.h | 1 + 5 files changed, 28 insertions(+) diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 202dafb..3b6eb21 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -278,6 +278,10 @@ static int ehci_fsl_usb_setup(struct ehci_hcd *ehci) out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x8000 | SNOOP_SIZE_2GB); } + /* Deal with USB erratum A-005275 */ + if (pdata-has_fsl_erratum_a005275 == 1) + ehci-has_fsl_hs_errata = 1; + if ((pdata-operating_mode == FSL_USB2_DR_HOST) || (pdata-operating_mode == FSL_USB2_DR_OTG)) if (ehci_fsl_setup_phy(hcd, pdata-phy_mode, 0)) diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 22abb68..fb381cf 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -1222,6 +1222,13 @@ int ehci_hub_control( ehci-reset_done [wIndex] = jiffies + msecs_to_jiffies (50); } + + /* Force full-speed connect for FSL high-speed erratum; +* disable HS Chirp by setting PFSC bit +*/ + if (ehci_has_fsl_hs_errata(ehci)) + temp |= (1 PORTSC_FSL_PFSC); + ehci_writel(ehci, temp, status_reg); break; diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index f700157..c232838 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h @@ -215,6 +215,7 @@ struct ehci_hcd { /* one per controller */ /* SILICON QUIRKS */ unsignedno_selective_suspend:1; unsignedhas_fsl_port_bug:1; /* FreeScale */ + unsignedhas_fsl_hs_errata:1;/* Freescale HS quirk */ unsignedbig_endian_mmio:1; unsignedbig_endian_desc:1; unsignedbig_endian_capbase:1; @@ -675,6 +676,17 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc) #defineehci_port_speed(ehci, portsc) USB_PORT_STAT_HIGH_SPEED #endif +#define PORTSC_FSL_PFSC24 /* Port Force Full-Speed Connect */ + +#if defined(CONFIG_PPC_85xx) +/* Some Freescale processors have an erratum (USB A-005275) in which + * incoming packets get corrupted in HS mode + */ +#define ehci_has_fsl_hs_errata(e) ((e)-has_fsl_hs_errata) +#else +#define ehci_has_fsl_hs_errata(e) (0) +#endif + /*-*/ #ifdef CONFIG_PPC_83xx diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 9f73141..534c4c5 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c @@ -221,6 +221,10 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) pdata-has_fsl_erratum_a007792 = 1; else pdata-has_fsl_erratum_a007792 = 0; + if (of_get_property(np, fsl,usb-erratum-a005275, NULL)) + pdata-has_fsl_erratum_a005275 = 1; + else + pdata-has_fsl_erratum_a005275 = 0; /* * Determine whether phy_clk_valid needs to be checked diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h index cebdbbb..f291291 100644 --- a/include/linux/fsl_devices.h +++ b/include/linux/fsl_devices.h @@ -99,6 +99,7 @@ struct fsl_usb2_platform_data { unsignedsuspended:1; unsignedalready_suspended:1; unsignedhas_fsl_erratum_a007792:1; + unsignedhas_fsl_erratum_a005275:1; unsignedcheck_phy_clk_valid:1; /* register save area for suspend/resume */ -- 2.1.0 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: gadget: mass_storage: Use static array for luns
This patch replace dynamicly allocated luns array with static one. This simplifies the code of mass storage function and modules. Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com -- IMPORTANT: This patch depends on patch: usb: gadget: mass_storage: Fix freeing luns sysfs implementation http://marc.info/?l=linux-usbm=143834268900540w=2 Changes since v1: - remove all luns before creating new (call fsg_common_remove_luns() in fsg_common_create_luns()) --- drivers/usb/gadget/function/f_mass_storage.c | 127 ++ drivers/usb/gadget/function/f_mass_storage.h |4 - drivers/usb/gadget/legacy/acm_ms.c |6 -- drivers/usb/gadget/legacy/mass_storage.c |6 -- drivers/usb/gadget/legacy/multi.c|6 -- drivers/usb/gadget/legacy/nokia.c| 14 +-- 6 files changed, 50 insertions(+), 113 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 9870913..04c3bb6 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -279,9 +279,8 @@ struct fsg_common { int cmnd_size; u8 cmnd[MAX_COMMAND_SIZE]; - unsigned intnluns; unsigned intlun; - struct fsg_lun **luns; + struct fsg_lun *luns[FSG_MAX_LUNS]; struct fsg_lun *curlun; unsigned intbulk_out_maxpacket; @@ -490,6 +489,16 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) spin_unlock(common-lock); } +static int _fsg_common_get_max_lun(struct fsg_common *common) +{ + int i = ARRAY_SIZE(common-luns) - 1; + + while (i = 0 !common-luns[i]) + --i; + + return i; +} + static int fsg_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) { @@ -533,7 +542,7 @@ static int fsg_setup(struct usb_function *f, w_length != 1) return -EDOM; VDBG(fsg, get max LUN\n); - *(u8 *)req-buf = fsg-common-nluns - 1; + *(u8 *)req-buf = _fsg_common_get_max_lun(fsg-common); /* Respond with data/status */ req-length = min((u16)1, w_length); @@ -2131,8 +2140,9 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) } /* Is the CBW meaningful? */ - if (cbw-Lun = FSG_MAX_LUNS || cbw-Flags ~US_BULK_FLAG_IN || - cbw-Length = 0 || cbw-Length MAX_COMMAND_SIZE) { + if (cbw-Lun = ARRAY_SIZE(common-luns) || + cbw-Flags ~US_BULK_FLAG_IN || cbw-Length = 0 || + cbw-Length MAX_COMMAND_SIZE) { DBG(fsg, non-meaningful CBW: lun = %u, flags = 0x%x, cmdlen %u\n, cbw-Lun, cbw-Flags, cbw-Length); @@ -2159,7 +2169,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) if (common-data_size == 0) common-data_dir = DATA_DIR_NONE; common-lun = cbw-Lun; - if (common-lun common-nluns) + if (common-lun ARRAY_SIZE(common-luns)) common-curlun = common-luns[common-lun]; else common-curlun = NULL; @@ -2307,7 +2317,7 @@ reset: } common-running = 1; - for (i = 0; i common-nluns; ++i) + for (i = 0; i ARRAY_SIZE(common-luns); ++i) if (common-luns[i]) common-luns[i]-unit_attention_data = SS_RESET_OCCURRED; @@ -2409,7 +2419,7 @@ static void handle_exception(struct fsg_common *common) if (old_state == FSG_STATE_ABORT_BULK_OUT) common-state = FSG_STATE_STATUS_PHASE; else { - for (i = 0; i common-nluns; ++i) { + for (i = 0; i ARRAY_SIZE(common-luns); ++i) { curlun = common-luns[i]; if (!curlun) continue; @@ -2453,7 +2463,7 @@ static void handle_exception(struct fsg_common *common) * a waste of time. Ditto for the INTERFACE_CHANGE and * CONFIG_CHANGE cases. */ - /* for (i = 0; i common-nluns; ++i) */ + /* for (i = 0; i common-ARRAY_SIZE(common-luns); ++i) */ /* if (common-luns[i]) */ /* common-luns[i]-unit_attention_data = */ /* SS_RESET_OCCURRED; */ @@ -2552,12 +2562,11 @@ static int fsg_main_thread(void *common_) if (!common-ops || !common-ops-thread_exits || common-ops-thread_exits(common) 0) { - struct fsg_lun **curlun_it = common-luns; - unsigned i = common-nluns; +
Re: [PATCH] usb: gadget: mass_storage: Fix freeing luns sysfs implementation
On Fri, Jul 31 2015, Krzysztof Opasiak wrote: Use device_is_registered() instad of sysfs flag to determine if we should free sysfs representation of particular LUN. […] Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com --- drivers/usb/gadget/function/f_mass_storage.c | 12 ++-- drivers/usb/gadget/function/f_mass_storage.h |2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index f94a8e2..9870913 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -2742,9 +2742,9 @@ error_release: } EXPORT_SYMBOL_GPL(fsg_common_set_num_buffers); -void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) +void fsg_common_remove_lun(struct fsg_lun *lun) { - if (sysfs) + if (device_is_registered(lun-dev)) device_unregister(lun-dev); fsg_lun_close(lun); kfree(lun); @@ -2757,7 +2757,7 @@ static void _fsg_common_remove_luns(struct fsg_common *common, int n) for (i = 0; i n; ++i) if (common-luns[i]) { - fsg_common_remove_lun(common-luns[i], common-sysfs); + fsg_common_remove_lun(common-luns[i]); common-luns[i] = NULL; } } @@ -2950,7 +2950,7 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg, return 0; error_lun: - if (common-sysfs) + if (device_is_registered(lun-dev)) device_unregister(lun-dev); fsg_lun_close(lun); common-luns[id] = NULL; @@ -3038,7 +3038,7 @@ static void fsg_common_release(struct kref *ref) if (!lun) continue; fsg_lun_close(lun); - if (common-sysfs) + if (device_is_registered(lun-dev)) device_unregister(lun-dev); kfree(lun); } @@ -3363,7 +3363,7 @@ static void fsg_lun_drop(struct config_group *group, struct config_item *item) unregister_gadget_item(gadget); } - fsg_common_remove_lun(lun_opts-lun, fsg_opts-common-sysfs); + fsg_common_remove_lun(lun_opts-lun); fsg_opts-common-luns[lun_opts-lun_id] = NULL; lun_opts-lun_id = 0; mutex_unlock(fsg_opts-lock); diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h index b4866fc..37bc94c 100644 --- a/drivers/usb/gadget/function/f_mass_storage.h +++ b/drivers/usb/gadget/function/f_mass_storage.h @@ -137,7 +137,7 @@ void fsg_common_free_buffers(struct fsg_common *common); int fsg_common_set_cdev(struct fsg_common *common, struct usb_composite_dev *cdev, bool can_stall); -void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs); +void fsg_common_remove_lun(struct fsg_lun *lun); void fsg_common_remove_luns(struct fsg_common *common); -- 1.7.9.5 -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz(o o) ooo +--m...@google.com--xmpp:min...@jabber.org--ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: gadget: mass_storage: Use static array for luns
Hi, On 07/30/2015 06:43 PM, Felipe Balbi wrote: Hi, On Thu, Jul 23, 2015 at 07:57:49PM +0200, Krzysztof Opasiak wrote: This patch replace dynamicly allocated luns array with static one. This simplifies the code of mass storage function and modules. Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com Acked-by: Michal Nazarewicz min...@mina86.com this actually regresses g_mass_storage: # modprobe g_mass_storage removable=1 [ 40.115294] Mass Storage Function, version: 2009/09/11 [ 40.120680] LUN: removable file: (no medium) [ 40.125374] Unable to handle kernel NULL pointer dereference at virtual address 0054 [ 40.133863] pgd = ed574000 [ 40.136689] [0054] *pgd= [ 40.140429] Internal error: Oops: 5 [#1] SMP ARM [ 40.145238] Modules linked in: g_mass_storage(+) usb_f_mass_storage libcomposite xhci_plat_hcd xhci_hcd usbcore joydev dwc3 udc_core usb_common evdev cpufreq_dt omapfb snd_soc_evm thermal_sys cfbfillrect cfbimgblt cfbcopyarea matrix_keypad hwmon leds_gpio led_class matrix_keymap pwm_bl panel_dpi snd_soc_tlv320aic3x snd_soc_davinci_mcasp snd_soc_edma snd_soc_omap snd_soc_core omapdss snd_compress snd_pcm_dmaengine snd_pcm dwc3_omap snd_timer lis3lv02d_i2c extcon pwm_tiecap snd lis3lv02d input_polldev soundcore rtc_omap spi_ti_qspi omap_wdt tps65218_pwrbutton phy_omap_usb2 ipv6 autofs4 [ 40.199522] CPU: 0 PID: 244 Comm: modprobe Not tainted 4.2.0-rc4-00060-g691ddfcf5846 #755 [ 40.208039] Hardware name: Generic AM43 (Flattened Device Tree) [ 40.214210] task: ed01e240 ti: ee7be000 task.ti: ee7be000 [ 40.219843] PC is at kernfs_find_ns+0xc/0x138 [ 40.224381] LR is at kernfs_find_and_get_ns+0x30/0x4c [ 40.229649] pc : [c01de508]lr : [c01de664]psr: 200f0013 [ 40.229649] sp : ee7bfc68 ip : 0002 fp : bf0aa740 [ 40.241609] r10: bf0aa788 r9 : ed3353c0 r8 : [ 40.247055] r7 : r6 : c06466a4 r5 : r4 : c0917840 [ 40.253851] r3 : c093c5d4 r2 : r1 : c06466a4 r0 : [ 40.260651] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 40.268085] Control: 10c5387d Table: ad574059 DAC: 0015 [ 40.274069] Process modprobe (pid: 244, stack limit = 0xee7be218) [ 40.280415] Stack: (0xee7bfc68 to 0xee7c) [ 40.284959] fc60: c0917840 c06466a4 ed214400 c01de664 [ 40.293478] fc80: c09474d0 ee56f438 ee56f430 c01e13d4 c09474a0 [ 40.301996] fca0: ee56f438 c03f6384 ee56f430 ee56f430 ed214598 c03ec6d0 bf0aa788 c008e820 [ 40.310519] fcc0: c015a7d4 ed01e240 ee56f430 ed2144d0 ed214598 ed21450c ed214400 c03ec8b8 [ 40.319048] fce0: ee56f400 bf10f304 ee533e00 ee533e04 bf0aa980 bf0aa54c 0001 bf10f374 [ 40.327572] fd00: bf115840 bf07ec18 fff0 bf0aa0a0 c05fe878 0001 0100 [ 40.336089] fd20: ed506098 bf2f8528 c0979e80 600f0093 c0091548 [ 40.344612] fd40: 0001 0080 bf2f8528 ed01e768 ed01e240 0004 [ 40.353137] fd60: 0006 12d341e8 bf0aa788 c008e820 c06008b8 ed01e240 0001 bf0aa694 [ 40.361654] fd80: c008e984 a00f0013 ed506088 ed506088 c06008b8 [ 40.370172] fda0: ed335301 0002 ed3353c0 bf0aa6bc [ 40.378690] fdc0: ed506170 12d341e8 bf07ea84 bf2e7d08 ee53b000 bf0aa6bc ee53b000 [ 40.387207] fde0: bf0aa6bc ed2cbd00 ee53b008 12d341e8 bf0aa788 bf0aa740 bf2e7b90 [ 40.395724] fe00: bf2e8308 bf0aa6bc ed2cbd00 bf0b bf2e7d44 c08c9ea0 [ 40.404241] fe20: c08c9ea0 c00097a4 0001 c0150fe4 eeef9000 [ 40.412766] fe40: ef7c8460 4000 001e c008ec68 ee5e1e40 00d0 00d0 c015ba10 [ 40.421283] fe60: ee7bff58 c008ec68 c08c63a8 600f0013 a00f0013 bf0aa740 bf0aa740 c0979fd4 [ 40.429811] fe80: ee5e1e40 ed2cbe40 0001 bf0aa788 bf0aa740 c05f7d28 c0979fd4 0001 [ 40.438334] fea0: ee7bff58 c0979fd4 0001 c00c88c4 bf0aa74c 7fff c00c606c [ 40.446857] fec0: c1153024 0124 bf0aa74c bf0aa95c ee7bff60 f03a29a4 bf0aa74c [ 40.455381] fee0: 02e401dd 000f 000181a4 0001 [ 40.463900] ff00: [ 40.472424] ff20: 7f643410 0005 7f643410 [ 40.480941] ff40: 017b c000f724 ee7be000 7f6431c8 c00c91c0 f0385000 0001d9f4 [ 40.489471] ff60: f03a2314 f039a942 f039b5e0 09a8 0e38 [ 40.497993] ff80: 002a 002b 0012 0016 000b 000b [ 40.506537] ffa0: 000b c000f540 000b 0005 7f643410 7f6431b0 [ 40.515062] ffc0: 000b 000b 017b 0004 000b 000b 7f6431c8 [ 40.523579] ffe0: bea6a9a0 bea6a990 7f62643f b6f52812 600f0030 0005
Re: [PATCH v3 3/5] usb: phy: add usb3.0 phy driver for mt65xx SoCs
On Fri, 2015-07-31 at 19:48 +0530, Kishon Vijay Abraham I wrote: Hi, On Friday 31 July 2015 05:55 PM, chunfeng yun wrote: hi, On Tue, 2015-07-28 at 11:17 +0530, Kishon Vijay Abraham I wrote: Hi, On Sunday 26 July 2015 08:21 AM, chunfeng yun wrote: hi, On Wed, 2015-07-22 at 09:21 -0500, Felipe Balbi wrote: Hi, On Wed, Jul 22, 2015 at 10:05:43PM +0800, Chunfeng Yun wrote: support usb3.0 phy of mt65xx SoCs Signed-off-by: Chunfeng Yun chunfeng@mediatek.com you missed Kishon here. Thank you. --- drivers/phy/Kconfig | 9 + drivers/phy/Makefile | 1 + drivers/phy/phy-mt65xx-usb3.c | 426 ++ 3 files changed, 436 insertions(+) create mode 100644 drivers/phy/phy-mt65xx-usb3.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index c0e6ede..019cf8b 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -193,6 +193,15 @@ config PHY_HIX5HD2_SATA help Support for SATA PHY on Hisilicon hix5hd2 Soc. +config PHY_MT65XX_USB3 + tristate Mediatek USB3.0 PHY Driver + depends on ARCH_MEDIATEK OF + select GENERIC_PHY + help + Say 'Y' here to add support for Mediatek USB3.0 PHY driver + for mt65xx SoCs. it supports two usb2.0 ports and + one usb3.0 port. + config PHY_SUN4I_USB tristate Allwinner sunxi SoC USB PHY driver depends on ARCH_SUNXI HAS_IOMEM OF diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index f344e1b..3ceff2a 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_TI_PIPE3)+= phy-ti-pipe3.o obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o obj-$(CONFIG_PHY_EXYNOS5250_SATA) += phy-exynos5250-sata.o obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o +obj-$(CONFIG_PHY_MT65XX_USB3) += phy-mt65xx-usb3.o obj-$(CONFIG_PHY_SUN4I_USB)+= phy-sun4i-usb.o obj-$(CONFIG_PHY_SUN9I_USB)+= phy-sun9i-usb.o obj-$(CONFIG_PHY_SAMSUNG_USB2) += phy-exynos-usb2.o diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c new file mode 100644 index 000..5da4534 --- /dev/null +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2015 MediaTek Inc. + * Author: Chunfeng.Yun chunfeng@mediatek.com + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/io.h +#include linux/module.h +#include linux/of_address.h +#include linux/of_device.h +#include linux/of_gpio.h +#include linux/of.h +#include linux/phy/phy.h +#include linux/platform_device.h +#include linux/pm_runtime.h +#include linux/regulator/consumer.h Lot of these #include are not required. Add only those what are required by this driver. The dummy header files will be removed later +#include linux/resource.h + +/* + * for sifslv2 register + * relative to USB3_SIF2_BASE base address + */ +#define SSUSB_SIFSLV_SPLLC (0x) +#define SSUSB_SIFSLV_U2PHY_COM_BASE(0x0800) Looks like all this base address can come from dt. The phy supports multi-ports, and these are sub-segment registers for port0, and other ports can be calculated from the bases. So I think it's better to use the same base address in dts Nope. Except for the register offsets everything else can come from dt. +#define SSUSB_SIFSLV_U3PHYD_BASE (0x0900) +#define SSUSB_USB30_PHYA_SIV_B_BASE(0x0b00) +#define SSUSB_SIFSLV_U3PHYA_DA_BASE(0x0c00) + +/*port1 refs. +0x800(refer to port0)*/ +#define U3P_PORT_INTERVAL (0x800) /*based on port0 */ +#define U3P_PHY_DELTA(index) ((U3P_PORT_INTERVAL) * (index)) + +#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +#define PA0_RG_U2PLL_FORCE_ON (0x1 15) + +#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define PA2_RG_SIF_U2PLL_FORCE_EN (0x1 18) + +#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define PA5_RG_U2_HSTX_SRCTRL (0x7 12) +#define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 (x)) 12) +#define PA5_RG_U2_HS_100U_U3_EN(0x1 11) + +#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define PA6_RG_U2_ISO_EN (0x1 31) +#define PA6_RG_U2_BC11_SW_EN (0x1 23) +#define
Re: [PATCH v3 2/5] dt-bindings: Add a binding for Mediatek xHCI host controller
hi, On Fri, 2015-07-31 at 14:37 +0100, Mark Rutland wrote: Hi, + - mediatek,usb-wakeup: to access usb wakeup control register What exactly does this property imply? There are some control registers for usb wakeup which are put in another module, here to get the node of that module, and then use regmap and syscon to operate it. Ok. You need to specify the type of this property (i.e. that it is a phandle to a syscon node). The description makes it sound like a boolean. Is it ok to add a prefix of syscon, and name it syscon-usb-wakeup? + - mediatek,wakeup-src: 1: ip sleep wakeup mode; 2: line state wakeup + mode; others means don't enable wakeup source of usb This sounds like configuration rather than a hardware property. Why do you think this needs to be in the DT? Yes, it's better to put it in the DT. That doesn't answer my question. _why_ do you think this needs to be in the DT? What do you think is better for it being there? It is unthoughtful to put it here; There is different configuration on platforms, such as on tablet which only needs line-state wakeup (because system can't enter suspend when plug in usb cable, so don't need ip-sleep-wakeup to remote wakeup system), and on box just needs ip-sleep wakeup mode. so it is better to put in each board's dts. + - mediatek,u2port-num: the number should not greater than the number + of phys What exactly does this property imply? On some platform, it only makes use of partial usb ports, so disable others to save power. What exactly do you mean by partial USB ports? If a phy isn't wired up, it won't be listed in the phys property, if it is then disabling it sounds like a run-time decision. Yes, you are right. This confuse me a little before. It was a property of old phy driver at first, and then ported it here, so did not remove it temp. After I re-write the phy driver, I will remove it. Thanks a lot. Thanks, Mark. -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] Doc: ABI: testing: configfs-usb-gadget-sourcesink
Fix the name of attribute Cc: sta...@vger.kernel.org Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/ABI/testing/configfs-usb-gadget-sourcesink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-usb-gadget-sourcesink b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink index 29477c3..bc7ff73 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-sourcesink +++ b/Documentation/ABI/testing/configfs-usb-gadget-sourcesink @@ -9,4 +9,4 @@ Description: isoc_maxpacket - 0 - 1023 (fs), 0 - 1024 (hs/ss) isoc_mult - 0..2 (hs/ss only) isoc_maxburst - 0..15 (ss only) - qlen- buffer length + buflen - buffer length -- 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 1/3] Doc: ABI: testing: configfs-usb-gadget-loopback
Fix the name of attribute Cc: sta...@vger.kernel.org Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/ABI/testing/configfs-usb-gadget-loopback | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-usb-gadget-loopback b/Documentation/ABI/testing/configfs-usb-gadget-loopback index 9aae5bf..06beefb 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-loopback +++ b/Documentation/ABI/testing/configfs-usb-gadget-loopback @@ -5,4 +5,4 @@ Description: The attributes: qlen- depth of loopback queue - bulk_buflen - buffer length + buflen - buffer length -- 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] usb: gadget: mass_storage: Fix freeing luns sysfs implementation
Use device_is_registered() instad of sysfs flag to determine if we should free sysfs representation of particular LUN. sysfs flag in fsg common determines if luns attributes should be exposed using sysfs. This flag is used when creating and freeing luns. Unfortunately there is no guarantee that this flag will not be changed between creation and removal of particular LUN. Especially because of lun.0 which is created during allocating instance of function. This may lead to resource leak or NULL pointer dereference: [ 62.539925] Unable to handle kernel NULL pointer dereference at virtual address 0044 [ 62.548014] pgd = ec994000 [ 62.550679] [0044] *pgd=6d7be831, *pte=, *ppte= [ 62.556933] Internal error: Oops: 17 [#1] PREEMPT SMP ARM [ 62.562310] Modules linked in: g_mass_storage(+) [ 62.566916] CPU: 2 PID: 613 Comm: insmod Not tainted 4.2.0-rc4-00077-ge29ee91-dirty #125 [ 62.574984] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 62.581061] task: eca56e80 ti: eca76000 task.ti: eca76000 [ 62.586450] PC is at kernfs_find_ns+0x8/0xe8 [ 62.590698] LR is at kernfs_find_and_get_ns+0x30/0x48 [ 62.595732] pc : [c01277c0]lr : [c0127b88]psr: 40010053 [ 62.595732] sp : eca77c40 ip : eca77c38 fp : 08c1 [ 62.607187] r10: 0001 r9 : c0082f38 r8 : ed41ce40 [ 62.612395] r7 : c05c1484 r6 : r5 : r4 : c0814488 [ 62.618904] r3 : r2 : r1 : c05c1484 r0 : [ 62.625417] Flags: nZcv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user [ 62.632620] Control: 10c5387d Table: 6c99404a DAC: 0015 [ 62.638348] Process insmod (pid: 613, stack limit = 0xeca76210) [ 62.644251] Stack: (0xeca77c40 to 0xeca78000) [ 62.648594] 7c40: c0814488 c05c1484 ed41ce40 c0127b88 c0824888 [ 62.656753] 7c60: ed41d038 ed41d030 ed41d000 c012af4c c0824858 ed41d038 c02e3314 [ 62.664912] 7c80: ed41d030 ed41ce04 c02d9e8c c070eda8 eca77cb4 08c1 c058317c [ 62.673071] 7ca0: 08c1 ed41d030 ed41ce00 ed41ce04 ed41d000 c02da044 ed41cf48 c0375870 [ 62.681230] 7cc0: ed9d3c04 ed9d3c00 ed52df80 bf000940 fff0 c03758f4 c03758c0 [ 62.689389] 7ce0: bf000564 c03614e0 ed9d3c04 bf000194 c0082f38 0001 c100 [ 62.697548] 7d00: c0814488 c0814488 c086b1dc c05893a8 ed7e8320 c0128b88 [ 62.705707] 7d20: ed8a6b40 ed410500 ed8a6b40 c0594818 ed7e8320 [ 62.713867] 7d40: c0129f20 c082c444 ed8a6b40 c012a684 1000 [ 62.722026] 7d60: c0594818 c082c444 ed52df80 ed52df80 [ 62.730185] 7d80: 0001 0002 ed8e9b70 ed52df80 bf0006d0 [ 62.738345] 7da0: ed8e9b70 ed410500 ed618340 c036129c ed8c1c00 bf0006d0 c080b158 ed8c1c00 [ 62.746504] 7dc0: bf0006d0 c080b158 ed8c1c08 ed410500 c0082f38 ed618340 08c1 c03640ac [ 62.754663] 7de0: bf0006d0 c082c8dc c080b158 c080b158 c03642d4 bf003000 [ 62.762822] 7e00: c0009784 0001 c05849b0 0002 ee7ab780 [ 62.770981] 7e20: 0002 ed4105c0 c53e 00d0 c0808600 eca77e5c 0004 [ 62.779140] 7e40: bf00 c0095680 c08075a0 ee001f00 ed4105c0 c00cadc0 ed52df80 bf000780 [ 62.787300] 7e60: ed4105c0 bf000780 0001 bf0007c8 c0082f38 ed618340 08c1 c0083e24 [ 62.795459] 7e80: 0001 bf000780 0001 eca77f58 0001 bf000780 0001 c00857f4 [ 62.803618] 7ea0: bf00078c 7fff c00835b4 eca77f58 c0082fac eca77f58 [ 62.811777] 7ec0: f05038c0 0003b008 bf000904 bf00078c 6e72656b 6c65 [ 62.819936] 7ee0: [ 62.828095] 7f00: [ 62.836255] 7f20: 0003 0003b008 [ 62.844414] 7f40: 017b c000f5c8 eca76000 0003b008 c0085df8 f04ef000 0001b8a9 [ 62.852573] 7f60: f0503258 f05030c2 f0509fe8 0968 0dc8 [ 62.860732] 7f80: 0029 002a 0011 000a 33f6eb00 0003b008 [ 62.868892] 7fa0: bef01cac c000f400 33f6eb00 0003b008 0003 0003b008 0003 [ 62.877051] 7fc0: 33f6eb00 0003b008 bef01cac 017b 0003b008 000b 0003b008 [ 62.885210] 7fe0: bef01ae0 bef01ad0 0001dc23 b6e8c162 800b0070 0003 c0c0c0c0 c0c0c0c0 [ 62.893380] [c01277c0] (kernfs_find_ns) from [c0824888] (pm_qos_latency_tolerance_attr_group+0x0/0x10) [ 62.903005] Code: e28dd00c e8bd80f0 e92d41f0 e2923000 (e1d0e4b4) [ 62.909115] ---[ end trace 02fb4373ef095c7b ]--- Signed-off-by: Krzysztof Opasiak k.opas...@samsung.com --- drivers/usb/gadget/function/f_mass_storage.c | 12 ++-- drivers/usb/gadget/function/f_mass_storage.h |2 +- 2 files
[PATCH 3/3] doc: usb: gadget-testing: using the updated testusb.c
testusb.c at http://www.linux-usb.org/usbtest/ is out of date, using the one at the kernel source folder. Cc: sta...@vger.kernel.org Signed-off-by: Peter Chen peter.c...@freescale.com --- Documentation/usb/gadget-testing.txt | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Documentation/usb/gadget-testing.txt b/Documentation/usb/gadget-testing.txt index 5926780..b24d3ef 100644 --- a/Documentation/usb/gadget-testing.txt +++ b/Documentation/usb/gadget-testing.txt @@ -237,9 +237,7 @@ Testing the LOOPBACK function - device: run the gadget -host: test-usb - -http://www.linux-usb.org/usbtest/testusb.c +host: test-usb (tools/usb/testusb.c) 8. MASS STORAGE function @@ -586,9 +584,8 @@ Testing the SOURCESINK function --- device: run the gadget -host: test-usb +host: test-usb (tools/usb/testusb.c) -http://www.linux-usb.org/usbtest/testusb.c 16. UAC1 function = -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v9 3/4] USB: io_ti: Add firmware image sanity checks
On Fri, Jul 31, 2015 at 01:55:07AM -0500, Peter E. Berger wrote: From: Peter E. Berger pber...@brimson.com +static int check_fw_sanity(struct edgeport_serial *serial, + const struct firmware *fw) +{ + u16 length_total; + u8 checksum = 0; + int pos; + struct device *dev = serial-serial-interface-dev; + struct edgeport_fw_hdr *fw_hdr = (struct edgeport_fw_hdr *)fw-data; + + if (fw-size sizeof(struct edgeport_fw_hdr)) { + dev_err(dev, incomplete fw header\n); + return -EINVAL; + } + + length_total = le16_to_cpu(fw_hdr-length) + + sizeof(struct edgeport_fw_hdr); + + if (fw-size != length_total) { + dev_err(dev, bad fw size (expected: %u, got: %zu)\n, + length_total, fw-size); + return -EINVAL; + } + + for (pos = sizeof(struct edgeport_fw_hdr); pos fw-size; ++pos) + checksum = (checksum + fw-data[pos]) 0xFF; I simplified this to checksum += fw-data[pos]; before applying. Thanks, 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