Re: [PATCH 6/8] usb: musb: Pass fifo_mode in platform data
Hi Tony, Thanks for this one too. On Mon, Nov-24-2014 at 11:05:04 AM -0800, Tony Lindgren wrote: > This allows setting the correct fifo_mode when multiple > MUSB glue layers are built-in. Applied on top of 3.18-rc6 mainline and tested successfully on JZ4740. Been able to use ethernet-over-usb to access the internet on device. No issue as far as I'm concerned. Acked-by: Apelete Seketeli > Cc: Fabio Baltieri > Cc: Lee Jones > Cc: Linus Walleij > Cc: Apelete Seketeli > Cc: Lars-Peter Clausen > Signed-off-by: Tony Lindgren > --- > drivers/usb/musb/blackfin.c | 1 + > drivers/usb/musb/da8xx.c | 1 + > drivers/usb/musb/jz4740.c| 1 + > drivers/usb/musb/musb_core.c | 21 ++--- > drivers/usb/musb/ux500.c | 1 + > 5 files changed, 10 insertions(+), 15 deletions(-) > > diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c > index c55fcfd..b8442b9 100644 > --- a/drivers/usb/musb/blackfin.c > +++ b/drivers/usb/musb/blackfin.c > @@ -474,6 +474,7 @@ static const struct musb_platform_ops bfin_ops = { > .writew = bfin_writew, > .readl = bfin_readl, > .writel = bfin_writel, > + .fifo_mode = 2, > .read_fifo = bfin_read_fifo, > .write_fifo = bfin_write_fifo, > .enable = bfin_musb_enable, > diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c > index c9079c8..5f9b486 100644 > --- a/drivers/usb/musb/da8xx.c > +++ b/drivers/usb/musb/da8xx.c > @@ -462,6 +462,7 @@ static const struct musb_platform_ops da8xx_ops = { > .init = da8xx_musb_init, > .exit = da8xx_musb_exit, > > + .fifo_mode = 2, > .enable = da8xx_musb_enable, > .disable= da8xx_musb_disable, > > diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c > index 40e9874..bb7b263 100644 > --- a/drivers/usb/musb/jz4740.c > +++ b/drivers/usb/musb/jz4740.c > @@ -107,6 +107,7 @@ static int jz4740_musb_exit(struct musb *musb) > > static const struct musb_platform_ops jz4740_musb_ops = { > .quirks = MUSB_INDEXED_EP, > + .fifo_mode = 2, > .init = jz4740_musb_init, > .exit = jz4740_musb_exit, > }; > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index 48ddc82..0875365 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -1116,21 +1116,7 @@ static void musb_shutdown(struct platform_device *pdev) > * We don't currently use dynamic fifo setup capability to do anything > * more than selecting one of a bunch of predefined configurations. > */ > -#if defined(CONFIG_USB_MUSB_TUSB6010)\ > - || defined(CONFIG_USB_MUSB_TUSB6010_MODULE) \ > - || defined(CONFIG_USB_MUSB_OMAP2PLUS) \ > - || defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE)\ > - || defined(CONFIG_USB_MUSB_AM35X) \ > - || defined(CONFIG_USB_MUSB_AM35X_MODULE)\ > - || defined(CONFIG_USB_MUSB_DSPS)\ > - || defined(CONFIG_USB_MUSB_DSPS_MODULE) > -static ushort fifo_mode = 4; > -#elif defined(CONFIG_USB_MUSB_UX500) \ > - || defined(CONFIG_USB_MUSB_UX500_MODULE) > -static ushort fifo_mode = 5; > -#else > -static ushort fifo_mode = 2; > -#endif > +static ushort fifo_mode; > > /* "modprobe ... fifo_mode=1" etc */ > module_param(fifo_mode, ushort, 0); > @@ -2040,6 +2026,11 @@ musb_init_controller(struct device *dev, int nIrq, > void __iomem *ctrl) > musb->io.ep_select = musb_flat_ep_select; > } > > + if (musb->ops->fifo_mode) > + fifo_mode = musb->ops->fifo_mode; > + else > + fifo_mode = 4; > + > if (musb->ops->fifo_offset) > musb->io.fifo_offset = musb->ops->fifo_offset; > else > diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c > index c170501..c372518 100644 > --- a/drivers/usb/musb/ux500.c > +++ b/drivers/usb/musb/ux500.c > @@ -191,6 +191,7 @@ static const struct musb_platform_ops ux500_ops = { > .quirks = MUSB_INDEXED_EP, > .init = ux500_musb_init, > .exit = ux500_musb_exit, > + .fifo_mode = 5, > > .set_vbus = ux500_musb_set_vbus, > }; > -- > 2.1.3 > -- Apelete -- 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 5/8] usb: musb: Change end point selection to use new IO access
Hi Tony, Thanks for the patch. On Mon, Nov-24-2014 at 11:05:03 AM -0800, Tony Lindgren wrote: > This allows the endpoints to work when multiple MUSB glue > layers are built in. Applied on top of 3.18-rc6 mainline and tested successfully on JZ4740. Been able to use ethernet-over-usb to access the internet on device. No issue as far as I'm concerned. Acked-by: Apelete Seketeli > Cc: Fabio Baltieri > Cc: Lee Jones > Cc: Linus Walleij > Cc: Apelete Seketeli > Cc: Lars-Peter Clausen > Signed-off-by: Tony Lindgren > --- > drivers/usb/musb/am35x.c | 1 + > drivers/usb/musb/da8xx.c | 1 + > drivers/usb/musb/jz4740.c| 1 + > drivers/usb/musb/musb_core.c | 38 +- > drivers/usb/musb/musb_core.h | 37 + > drivers/usb/musb/musb_dsps.c | 1 + > drivers/usb/musb/musb_io.h | 2 ++ > drivers/usb/musb/musb_regs.h | 11 --- > drivers/usb/musb/musbhsdma.c | 7 --- > drivers/usb/musb/tusb6010.c | 13 + > drivers/usb/musb/ux500.c | 1 + > 11 files changed, 62 insertions(+), 51 deletions(-) > > diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c > index 13d1d77..1ea4a67 100644 > --- a/drivers/usb/musb/am35x.c > +++ b/drivers/usb/musb/am35x.c > @@ -438,6 +438,7 @@ static void am35x_read_fifo(struct musb_hw_ep *hw_ep, u16 > len, u8 *dst) > } > > static const struct musb_platform_ops am35x_ops = { > + .quirks = MUSB_INDEXED_EP, > .init = am35x_musb_init, > .exit = am35x_musb_exit, > > diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c > index 058775e..c9079c8 100644 > --- a/drivers/usb/musb/da8xx.c > +++ b/drivers/usb/musb/da8xx.c > @@ -458,6 +458,7 @@ static int da8xx_musb_exit(struct musb *musb) > } > > static const struct musb_platform_ops da8xx_ops = { > + .quirks = MUSB_INDEXED_EP, > .init = da8xx_musb_init, > .exit = da8xx_musb_exit, > > diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c > index d118729..40e9874 100644 > --- a/drivers/usb/musb/jz4740.c > +++ b/drivers/usb/musb/jz4740.c > @@ -106,6 +106,7 @@ static int jz4740_musb_exit(struct musb *musb) > } > > static const struct musb_platform_ops jz4740_musb_ops = { > + .quirks = MUSB_INDEXED_EP, > .init = jz4740_musb_init, > .exit = jz4740_musb_exit, > }; > diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c > index 2fbe149..48ddc82 100644 > --- a/drivers/usb/musb/musb_core.c > +++ b/drivers/usb/musb/musb_core.c > @@ -229,6 +229,27 @@ static u32 musb_default_fifo_offset(u8 epnum) > return 0x20 + (epnum * 4); > } > > +/* "flat" mapping: each endpoint has its own i/o address */ > +static void musb_flat_ep_select(void __iomem *mbase, u8 epnum) > +{ > +} > + > +static u32 musb_flat_ep_offset(u8 epnum, u16 offset) > +{ > + return 0x100 + (0x10 * epnum) + offset; > +} > + > +/* "indexed" mapping: INDEX register controls register bank select */ > +static void musb_indexed_ep_select(void __iomem *mbase, u8 epnum) > +{ > + musb_writeb(mbase, MUSB_INDEX, epnum); > +} > + > +static u32 musb_indexed_ep_offset(u8 epnum, u16 offset) > +{ > + return 0x10 + offset; > +} > + > static u8 musb_default_readb(const void __iomem *addr, unsigned offset) > { > return __raw_readb(addr + offset); > @@ -1534,7 +1555,7 @@ static int musb_core_init(u16 musb_type, struct musb > *musb) > } > #endif > > - hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; > + hw_ep->regs = musb->io.ep_offset(i, 0) + mbase; > hw_ep->target_regs = musb_read_target_reg_base(i, mbase); > hw_ep->rx_reinit = 1; > hw_ep->tx_reinit = 1; > @@ -2004,6 +2025,21 @@ musb_init_controller(struct device *dev, int nIrq, > void __iomem *ctrl) > if (musb->ops->quirks) > musb->io.quirks = musb->ops->quirks; > > + /* At least tusb6010 has it's own offsets.. */ > + if (musb->ops->ep_offset) > + musb->io.ep_offset = musb->ops->ep_offset; > + if (musb->ops->ep_select) > + musb->io.ep_select = musb->ops->ep_select; > + > + /* ..and some devices use indexed offset or flat offset */ > + if (musb->io.quirks & MUSB_INDEXED_EP) { > + musb->io.ep_offset = musb_indexed_ep_offset; > + musb->io.ep_select = musb_indexed_ep_select; > + } else { > +
[PATCH v3] usb: musb: register nop transceiver driver for jz4740
Following the name change of the NOP transceiver driver in commit 4525bee (usb: phy: rename usb_nop_xceiv to usb_phy_generic), the transceiver driver was no longer operable under its old name. Register the transceiver driver before calling usb_get_phy() to make sure we are noticed by an error message if it is not available. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index 5f30537..d118729 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "musb_core.h" @@ -80,6 +81,7 @@ static struct musb_hdrc_platform_data jz4740_musb_platform_data = { static int jz4740_musb_init(struct musb *musb) { + usb_phy_generic_register(); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (!musb->xceiv) { pr_err("HS UDC: no transceiver configured\n"); @@ -182,6 +184,7 @@ static int jz4740_remove(struct platform_device *pdev) struct jz4740_glue *glue = platform_get_drvdata(pdev); platform_device_unregister(glue->musb); + usb_phy_generic_unregister(pdev); clk_disable_unprepare(glue->clk); return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3] Register NOP tranciever driver in JZ4740 musb glue layer
Hello, The name of the NOP transceiver driver was changed during v3.16 release cycle from usb_phy_gen_xceiv to usb_phy_generic. The patch that comes as a follow up of this message registers the NOP transceiver driver before calling usb_get_phy() to avoid issues related to accessing its data structure while it was not registered. Changes since v2: - reword commit message into something clearer. Changes since v1: - specify commit 4525bee summary line in parens in commit message. For notice, I updated corresponding platform data to rename NOP transceiver used for JZ4740 in a patch sent to linux-mips. Changes were rebased on top of the linux-usb master branch, built and tested successfully. The following changes since commit 80235c4: Merge tag 'v3.16-rc2' are available in the git repository at: git://git.seketeli.net/~apelete/linux-usb.git register-jz4740-phy Apelete Seketeli (1): usb: musb: register nop transceiver driver for jz4740 drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: musb: register nop transceiver driver for jz4740
Following the name change of the NOP transceiver driver in commit 4525bee (usb: phy: rename usb_nop_xceiv to usb_phy_generic), make sure to register the transceiver driver before calling usb_get_phy() to avoid issues related to accessing its data structure while it was not registered. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index 5f30537..d118729 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "musb_core.h" @@ -80,6 +81,7 @@ static struct musb_hdrc_platform_data jz4740_musb_platform_data = { static int jz4740_musb_init(struct musb *musb) { + usb_phy_generic_register(); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (!musb->xceiv) { pr_err("HS UDC: no transceiver configured\n"); @@ -182,6 +184,7 @@ static int jz4740_remove(struct platform_device *pdev) struct jz4740_glue *glue = platform_get_drvdata(pdev); platform_device_unregister(glue->musb); + usb_phy_generic_unregister(pdev); clk_disable_unprepare(glue->clk); return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] Register NOP tranciever driver in JZ4740 musb glue layer
Hello, The name of the NOP transceiver driver was changed during v3.16 release cycle from usb_phy_gen_xceiv to usb_phy_generic. The patch that comes as a follow up of this message registers the NOP transceiver driver before calling usb_get_phy() to avoid issues related to accessing its data structure while it was not registered. Changes since v1: - specify commit 4525bee summary line in parens in commit message. For notice, I updated corresponding platform data to rename NOP transceiver used for JZ4740 in a patch sent to linux-mips. Changes were rebased on top of the linux-usb master branch, built and tested successfully. The following changes since commit 80235c4: Merge tag 'v3.16-rc2' are available in the git repository at: git://git.seketeli.net/~apelete/linux-usb.git register-jz4740-phy Apelete Seketeli (1): usb: musb: register nop transceiver driver for jz4740 drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: musb: register nop transceiver driver for jz4740
Following the name change of the nop transceiver driver in commit 4525bee, make sure to register the transceiver driver before calling usb_get_phy() to avoid issues related to accessing its data structure while it was not registered. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c index 5f30537..d118729 100644 --- a/drivers/usb/musb/jz4740.c +++ b/drivers/usb/musb/jz4740.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "musb_core.h" @@ -80,6 +81,7 @@ static struct musb_hdrc_platform_data jz4740_musb_platform_data = { static int jz4740_musb_init(struct musb *musb) { + usb_phy_generic_register(); musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); if (!musb->xceiv) { pr_err("HS UDC: no transceiver configured\n"); @@ -182,6 +184,7 @@ static int jz4740_remove(struct platform_device *pdev) struct jz4740_glue *glue = platform_get_drvdata(pdev); platform_device_unregister(glue->musb); + usb_phy_generic_unregister(pdev); clk_disable_unprepare(glue->clk); return 0; -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Register NOP tranciever driver in JZ4740 musb glue layer
Hello, The name of the NOP transceiver driver was changed during v3.16 release cycle from usb_phy_gen_xceiv to usb_phy_generic. The patch that comes as a follow up of this message registers the NOP transceiver driver before calling usb_get_phy() to avoid issues related to accessing its data structure while it was not registered. For notice, I updated corresponding platform data to rename NOP transceiver used for JZ4740 in a patch sent today to linux-mips. Changes were rebased on top of the linux-usb master branch, built and tested successfully. The following changes since commit 80235c4: Merge tag 'v3.16-rc2' are available in the git repository at: git://git.seketeli.net/~apelete/linux-usb.git register-jz4740-phy Apelete Seketeli (1): usb: musb: register nop transceiver driver for jz4740 drivers/usb/musb/jz4740.c |3 +++ 1 file changed, 3 insertions(+) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RESEND PATCH v2] documentation: docbook: document process of writing an musb glue layer
Hi Felipe, On Mon, Apr-14-2014 at 10:12:56 PM +0200, Apelete Seketeli wrote: > Document the process of writing an musb glue layer by taking the > Ingenic JZ4740 glue layer as an example, as it seems more simple than > most glue layers due to the basic feature set of the JZ4740 USB device > controller. > > Signed-off-by: Apelete Seketeli This one wasn't part of the pull request for 3.15-rc3, so I was wondering if you are planning to pull it in the next round of fixes (if it qualifies as such) or just waiting for the 3.16 merge window ? Cheers. > --- > Documentation/DocBook/Makefile |3 +- > Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 > > 2 files changed, 875 insertions(+), 1 deletion(-) > create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl > > diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile > index b444f2e..bec0665 100644 > --- a/Documentation/DocBook/Makefile > +++ b/Documentation/DocBook/Makefile > @@ -14,7 +14,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ > genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ > 80211.xml debugobjects.xml sh.xml regulator.xml \ > alsa-driver-api.xml writing-an-alsa-driver.xml \ > - tracepoint.xml drm.xml media_api.xml w1.xml > + tracepoint.xml drm.xml media_api.xml w1.xml \ > + writing_musb_glue_layer.xml > > include Documentation/DocBook/media/Makefile > > diff --git a/Documentation/DocBook/writing_musb_glue_layer.tmpl > b/Documentation/DocBook/writing_musb_glue_layer.tmpl > new file mode 100644 > index 000..837eca7 > --- /dev/null > +++ b/Documentation/DocBook/writing_musb_glue_layer.tmpl > @@ -0,0 +1,873 @@ > + > + + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; []> > + > + > + > + Writing an MUSB Glue Layer > + > + > + > + Apelete > +Seketeli > + > + > + apelete at seketeli.net > + > + > + > + > + > + > + 2014 > + Apelete Seketeli > + > + > + > + > + This documentation is free software; you can redistribute it > + and/or modify it under the terms of the GNU General Public > + License as published by the Free Software Foundation; either > + version 2 of the License, or (at your option) any later version. > + > + > + > + This documentation 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. > + > + > + > + You should have received a copy of the GNU General Public License > + along with this documentation; if not, write to the Free Software > + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > + 02111-1307 USA > + > + > + > + For more details see the file COPYING in the Linux kernel source > + tree. > + > + > + > + > + > + > + > +Introduction > + > + The Linux MUSB subsystem is part of the larger Linux USB > + subsystem. It provides support for embedded USB Device Controllers > + (UDC) that do not use Universal Host Controller Interface (UHCI) > + or Open Host Controller Interface (OHCI). > + > + > + Instead, these embedded UDC rely on the USB On-the-Go (OTG) > + specification which they implement at least partially. The silicon > + reference design used in most cases is the Multipoint USB > + Highspeed Dual-Role Controller (MUSB HDRC) found in the Mentor > + Graphics Inventra™ design. > + > + > + As a self-taught exercise I have written an MUSB glue layer for > + the Ingenic JZ4740 SoC, modelled after the many MUSB glue layers > + in the kernel source tree. This layer can be found at > + drivers/usb/musb/jz4740.c. In this documentation I will walk > + through the basics of the jz4740.c glue layer, explaining the > + different pieces and what needs to be done in order to write your > + own device glue layer. > + > + > + > + > +Linux MUSB Basics > + > + To get started on the topic, please read USB On-the-Go Basics (see > + Resources) which provides an introduction of USB OTG operation at > + the hardware level. A couple of wiki pages by Texas Instruments > + and Analog Devices also provide an overview of the Linux kernel > + MUSB configuration, albeit focused on some specific devices > + provided by these companies
[RESEND PATCH v2] documentation: docbook: document process of writing an musb glue layer
Document the process of writing an musb glue layer by taking the Ingenic JZ4740 glue layer as an example, as it seems more simple than most glue layers due to the basic feature set of the JZ4740 USB device controller. Signed-off-by: Apelete Seketeli --- Documentation/DocBook/Makefile |3 +- Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 2 files changed, 875 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index b444f2e..bec0665 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -14,7 +14,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 80211.xml debugobjects.xml sh.xml regulator.xml \ alsa-driver-api.xml writing-an-alsa-driver.xml \ - tracepoint.xml drm.xml media_api.xml w1.xml + tracepoint.xml drm.xml media_api.xml w1.xml \ + writing_musb_glue_layer.xml include Documentation/DocBook/media/Makefile diff --git a/Documentation/DocBook/writing_musb_glue_layer.tmpl b/Documentation/DocBook/writing_musb_glue_layer.tmpl new file mode 100644 index 000..837eca7 --- /dev/null +++ b/Documentation/DocBook/writing_musb_glue_layer.tmpl @@ -0,0 +1,873 @@ + +http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; []> + + + + Writing an MUSB Glue Layer + + + + Apelete +Seketeli + + + apelete at seketeli.net + + + + + + + 2014 + Apelete Seketeli + + + + + This documentation is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + + + This documentation 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. + + + + You should have received a copy of the GNU General Public License + along with this documentation; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA + + + + For more details see the file COPYING in the Linux kernel source + tree. + + + + + + + +Introduction + + The Linux MUSB subsystem is part of the larger Linux USB + subsystem. It provides support for embedded USB Device Controllers + (UDC) that do not use Universal Host Controller Interface (UHCI) + or Open Host Controller Interface (OHCI). + + + Instead, these embedded UDC rely on the USB On-the-Go (OTG) + specification which they implement at least partially. The silicon + reference design used in most cases is the Multipoint USB + Highspeed Dual-Role Controller (MUSB HDRC) found in the Mentor + Graphics Inventra™ design. + + + As a self-taught exercise I have written an MUSB glue layer for + the Ingenic JZ4740 SoC, modelled after the many MUSB glue layers + in the kernel source tree. This layer can be found at + drivers/usb/musb/jz4740.c. In this documentation I will walk + through the basics of the jz4740.c glue layer, explaining the + different pieces and what needs to be done in order to write your + own device glue layer. + + + + +Linux MUSB Basics + + To get started on the topic, please read USB On-the-Go Basics (see + Resources) which provides an introduction of USB OTG operation at + the hardware level. A couple of wiki pages by Texas Instruments + and Analog Devices also provide an overview of the Linux kernel + MUSB configuration, albeit focused on some specific devices + provided by these companies. Finally, getting acquainted with the + USB specification at USB home page may come in handy, with + practical instance provided through the Writing USB Device Drivers + documentation (again, see Resources). + + + Linux USB stack is a layered architecture in which the MUSB + controller hardware sits at the lowest. The MUSB controller driver + abstract the MUSB controller hardware to the Linux USB stack. + + + + | | <--- drivers/usb/gadget + | Linux USB Core Stack | <--- drivers/usb/host + | | <--- drivers/usb/core + + ⬍ + -- + || <-- drivers/usb/musb/musb_gadget.c + | MUSB Controller driver | <-- drive
[RESEND PATCH v2] Add documentation on writing an musb glue layer
Hello, Following a few patches already in tree that add support for the USB device controller of the Ingenic JZ4740 MIPS SoC, I documented the process of writing an MUSB glue layer. The JZ4740 MUSB controller offers a basic feature set, which makes the glue layer implementation more simple than most current glue layers in tree. The patch that comes as a follow-up of this message is an attempt to provide a step-by-step walk-through of the process of writing an MUSB glue layer. Changes since v1: - add a line in legal notice paragraph to refer to COPYING file in kernel source tree. With 3.15-rc1 now released, please consider this for merge and let me know if there's something that need to be fixed in the document. Changes were rebased on top of Linus Torvalds' tree, with the documentation built and tested successfully. The following changes since commit c9eaa447e77efe77b7fa4c953bd62de8297fd6c5: Linux 3.15-rc1 are available in the git repository at: git://git.seketeli.net/~apelete/linux.git writing-musb-glue-layer Apelete Seketeli (1): documentation: docbook: document process of writing an musb glue layer Documentation/DocBook/Makefile |3 +- Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 2 files changed, 875 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl -- Apelete -- 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: [RESEND PATCH v2] documentation: docbook: document process of writing an musb glue layer
Hi, On Mon, Apr-07-2014 at 06:02:18 PM -0500, Felipe Balbi wrote: > Hi, > > On Mon, Apr 07, 2014 at 03:12:09PM -0700, Randy Dunlap wrote: > > On 04/05/2014 11:42 AM, Apelete Seketeli wrote: > > > Document the process of writing an musb glue layer by taking the > > > Ingenic JZ4740 glue layer as an example, as it seems more simple than > > > most glue layers due to the basic feature set of the JZ4740 USB device > > > controller. > > > > > > Signed-off-by: Apelete Seketeli > > > > Hi, > > > > You should be cc-ing the musb maintainer and the USB mailing list (so now > > done). That was my intent in the first place -- I mentioned the USB mailing list in the cover letter and then forgot to actually cc the people over there. Thanks for taking care of that. > > Felipe should probably be the person to merge this unless he wants me > > to do it... > > I'll merge it, just resend once -rc1 is out. Thanks Ok, I'll resend once -rc1 is out. Thanks for your time. Cheers. -- Apelete -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] documentation: docbook: document process of writing an musb glue layer
Hello Rob, On Mon, Feb-17-2014 at 01:45:52 AM +0100, Apelete Seketeli wrote: > Document the process of writing an musb glue layer by taking the > Ingenic JZ4740 glue layer as an example, as it seems more simple than > most glue layers due to the basic feature set of the JZ4740 USB device > controller. > > Signed-off-by: Apelete Seketeli This is a gentle reminder for a review about this patch. Any chance that you could review this anytime soon ? Thank you in advance, Cheers. > --- > Documentation/DocBook/Makefile |3 +- > Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 > > 2 files changed, 875 insertions(+), 1 deletion(-) > create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl > > diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile > index 0f9c6ff..0bf7370 100644 > --- a/Documentation/DocBook/Makefile > +++ b/Documentation/DocBook/Makefile > @@ -14,7 +14,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ > genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ > 80211.xml debugobjects.xml sh.xml regulator.xml \ > alsa-driver-api.xml writing-an-alsa-driver.xml \ > - tracepoint.xml drm.xml media_api.xml > + tracepoint.xml drm.xml media_api.xml \ > + writing_musb_glue_layer.xml > > include $(srctree)/Documentation/DocBook/media/Makefile > > diff --git a/Documentation/DocBook/writing_musb_glue_layer.tmpl > b/Documentation/DocBook/writing_musb_glue_layer.tmpl > new file mode 100644 > index 000..837eca7 > --- /dev/null > +++ b/Documentation/DocBook/writing_musb_glue_layer.tmpl > @@ -0,0 +1,873 @@ > + > + + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; []> > + > + > + > + Writing an MUSB Glue Layer > + > + > + > +Apelete > +Seketeli > + > + > + apelete at seketeli.net > + > + > + > + > + > + > + 2014 > + Apelete Seketeli > + > + > + > + > + This documentation is free software; you can redistribute it > + and/or modify it under the terms of the GNU General Public > + License as published by the Free Software Foundation; either > + version 2 of the License, or (at your option) any later version. > + > + > + > + This documentation 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. > + > + > + > + You should have received a copy of the GNU General Public License > + along with this documentation; if not, write to the Free Software > + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > + 02111-1307 USA > + > + > + > + For more details see the file COPYING in the Linux kernel source > + tree. > + > + > + > + > + > + > + > +Introduction > + > + The Linux MUSB subsystem is part of the larger Linux USB > + subsystem. It provides support for embedded USB Device Controllers > + (UDC) that do not use Universal Host Controller Interface (UHCI) > + or Open Host Controller Interface (OHCI). > + > + > + Instead, these embedded UDC rely on the USB On-the-Go (OTG) > + specification which they implement at least partially. The silicon > + reference design used in most cases is the Multipoint USB > + Highspeed Dual-Role Controller (MUSB HDRC) found in the Mentor > + Graphics Inventra™ design. > + > + > + As a self-taught exercise I have written an MUSB glue layer for > + the Ingenic JZ4740 SoC, modelled after the many MUSB glue layers > + in the kernel source tree. This layer can be found at > + drivers/usb/musb/jz4740.c. In this documentation I will walk > + through the basics of the jz4740.c glue layer, explaining the > + different pieces and what needs to be done in order to write your > + own device glue layer. > + > + > + > + > +Linux MUSB Basics > + > + To get started on the topic, please read USB On-the-Go Basics (see > + Resources) which provides an introduction of USB OTG operation at > + the hardware level. A couple of wiki pages by Texas Instruments > + and Analog Devices also provide an overview of the Linux kernel > + MUSB configuration, albeit focused on some specific devices > + provided by these companies. Finally, getting acquainted with the > + USB specification at USB
[PATCH v2] documentation: docbook: document process of writing an musb glue layer
Document the process of writing an musb glue layer by taking the Ingenic JZ4740 glue layer as an example, as it seems more simple than most glue layers due to the basic feature set of the JZ4740 USB device controller. Signed-off-by: Apelete Seketeli --- Documentation/DocBook/Makefile |3 +- Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 2 files changed, 875 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 0f9c6ff..0bf7370 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -14,7 +14,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \ genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 80211.xml debugobjects.xml sh.xml regulator.xml \ alsa-driver-api.xml writing-an-alsa-driver.xml \ - tracepoint.xml drm.xml media_api.xml + tracepoint.xml drm.xml media_api.xml \ + writing_musb_glue_layer.xml include $(srctree)/Documentation/DocBook/media/Makefile diff --git a/Documentation/DocBook/writing_musb_glue_layer.tmpl b/Documentation/DocBook/writing_musb_glue_layer.tmpl new file mode 100644 index 000..837eca7 --- /dev/null +++ b/Documentation/DocBook/writing_musb_glue_layer.tmpl @@ -0,0 +1,873 @@ + +http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; []> + + + + Writing an MUSB Glue Layer + + + + Apelete +Seketeli + + + apelete at seketeli.net + + + + + + + 2014 + Apelete Seketeli + + + + + This documentation is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + + + This documentation 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. + + + + You should have received a copy of the GNU General Public License + along with this documentation; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA + + + + For more details see the file COPYING in the Linux kernel source + tree. + + + + + + + +Introduction + + The Linux MUSB subsystem is part of the larger Linux USB + subsystem. It provides support for embedded USB Device Controllers + (UDC) that do not use Universal Host Controller Interface (UHCI) + or Open Host Controller Interface (OHCI). + + + Instead, these embedded UDC rely on the USB On-the-Go (OTG) + specification which they implement at least partially. The silicon + reference design used in most cases is the Multipoint USB + Highspeed Dual-Role Controller (MUSB HDRC) found in the Mentor + Graphics Inventra™ design. + + + As a self-taught exercise I have written an MUSB glue layer for + the Ingenic JZ4740 SoC, modelled after the many MUSB glue layers + in the kernel source tree. This layer can be found at + drivers/usb/musb/jz4740.c. In this documentation I will walk + through the basics of the jz4740.c glue layer, explaining the + different pieces and what needs to be done in order to write your + own device glue layer. + + + + +Linux MUSB Basics + + To get started on the topic, please read USB On-the-Go Basics (see + Resources) which provides an introduction of USB OTG operation at + the hardware level. A couple of wiki pages by Texas Instruments + and Analog Devices also provide an overview of the Linux kernel + MUSB configuration, albeit focused on some specific devices + provided by these companies. Finally, getting acquainted with the + USB specification at USB home page may come in handy, with + practical instance provided through the Writing USB Device Drivers + documentation (again, see Resources). + + + Linux USB stack is a layered architecture in which the MUSB + controller hardware sits at the lowest. The MUSB controller driver + abstract the MUSB controller hardware to the Linux USB stack. + + + + | | <--- drivers/usb/gadget + | Linux USB Core Stack | <--- drivers/usb/host + | | <--- drivers/usb/core + + ⬍ + -- + || <-- drivers/usb/musb/musb_gadget.c + | MUSB Controller driver | <-- drive
[PATCH v2] Add documentation on writing an musb glue layer
Hello, Following a few patches already in tree that add support for the USB device controller of the Ingenic JZ4740 MIPS SoC, I documented the process of writing an MUSB glue layer. The JZ4740 MUSB controller offers a basic feature set, which makes the glue layer implementation more simple than most current glue layers in tree. The patch that comes as a follow-up of this message is an attempt to provide a step-by-step walk-through of the process of writing an MUSB glue layer. Changes since v1: - add a line in legal notice paragraph to refer to COPYING file in kernel source tree. I'm also adding linux-usb in Cc: to let people there know about this just in case it went under the radar before. Please review and let me know if there's something that need to be fixed in the document. Changes were rebased on top of Linus Torvalds' tree, with the documentation built and tested successfully. The following changes since commit 6d0abeca3242a88cab8232e4acd7e2bf088f3bc2: Linux 3.14-rc3 are available in the git repository at: git://git.seketeli.net/~apelete/linux.git writing-musb-glue-layer Apelete Seketeli (1): documentation: docbook: document process of writing an musb glue layer Documentation/DocBook/Makefile |3 +- Documentation/DocBook/writing_musb_glue_layer.tmpl | 873 2 files changed, 875 insertions(+), 1 deletion(-) create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl -- Apelete -- 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 1/2] usb: musb: add support for JZ4740 usb device controller
On 04-Jan-14, Richard Weinberger wrote: > On Thu, Dec 19, 2013 at 9:42 PM, Apelete Seketeli > wrote: > > Add support for Ingenic JZ4740 USB Device Controller through a > > specific musb glue layer. > > > > JZ4740 UDC not being OTG compatible and missing some hardware > > registers, this musb glue layer is written from scratch to be used in > > gadget mode only and take silicon design specifics into account. > > > > Signed-off-by: Apelete Seketeli > > Signed-off-by: Lars-Peter Clausen > > --- > > drivers/usb/musb/Kconfig |8 +- > > drivers/usb/musb/Makefile |1 + > > drivers/usb/musb/jz4740.c | 201 > > + > > 3 files changed, 209 insertions(+), 1 deletion(-) > > create mode 100644 drivers/usb/musb/jz4740.c > > > > diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig > > index 57dfc0c..14d7e72 100644 > > --- a/drivers/usb/musb/Kconfig > > +++ b/drivers/usb/musb/Kconfig > > @@ -93,6 +93,12 @@ config USB_MUSB_BLACKFIN > > config USB_MUSB_UX500 > > tristate "Ux500 platforms" > > > > +config USB_MUSB_JZ4740 > > + tristate "JZ4740" > > + depends on MACH_JZ4740 || COMPILE_TEST > > + depends on USB_MUSB_GADGET > > + depends on USB_OTG_BLACKLIST_HUB > > + > > endchoice > > > > config USB_MUSB_AM335X_CHILD > > @@ -100,7 +106,7 @@ config USB_MUSB_AM335X_CHILD > > > > choice > > prompt 'MUSB DMA mode' > > - default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM > > + default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM || USB_MUSB_JZ4740 > > Just out of curiosity, why can't we use DMA? We wrote the musb glue layer for the Ben Nanonote handheld computer only to provide ethernet-over-usb functionality. I was thinking about adding DMA support later, but Lars-Peter Clausen did experiment with DMA, and found out that all ethernet packets were unaligned, while the DMA only works if they are aligned. As a consequence, the DMA was bypassed all the time, making it useless at least for the ethernet gadget we are interested in. That's why DMA didn't make it into the glue layer. Cheers. -- Apelete -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/2] usb: musb: add support for JZ4740 usb device controller
Add support for Ingenic JZ4740 USB Device Controller through a specific musb glue layer. JZ4740 UDC not being OTG compatible and missing some hardware registers, this musb glue layer is written from scratch to be used in gadget mode only and take silicon design specifics into account. Signed-off-by: Apelete Seketeli Signed-off-by: Lars-Peter Clausen --- drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile |1 + drivers/usb/musb/jz4740.c | 201 + 3 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb/jz4740.c diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 57dfc0c..14d7e72 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -93,6 +93,12 @@ config USB_MUSB_BLACKFIN config USB_MUSB_UX500 tristate "Ux500 platforms" +config USB_MUSB_JZ4740 + tristate "JZ4740" + depends on MACH_JZ4740 || COMPILE_TEST + depends on USB_MUSB_GADGET + depends on USB_OTG_BLACKLIST_HUB + endchoice config USB_MUSB_AM335X_CHILD @@ -100,7 +106,7 @@ config USB_MUSB_AM335X_CHILD choice prompt 'MUSB DMA mode' - default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM + default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM || USB_MUSB_JZ4740 default USB_UX500_DMA if USB_MUSB_UX500 default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN default USB_TI_CPPI_DMA if USB_MUSB_DAVINCI diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index c5ea5c6..ba49501 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_USB_MUSB_DAVINCI)+= davinci.o obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o obj-$(CONFIG_USB_MUSB_BLACKFIN)+= blackfin.o obj-$(CONFIG_USB_MUSB_UX500) += ux500.o +obj-$(CONFIG_USB_MUSB_JZ4740) += jz4740.o obj-$(CONFIG_USB_MUSB_AM335X_CHILD)+= musb_am335x.o diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c new file mode 100644 index 000..5f30537 --- /dev/null +++ b/drivers/usb/musb/jz4740.c @@ -0,0 +1,201 @@ +/* + * Ingenic JZ4740 "glue layer" + * + * Copyright (C) 2013, Apelete Seketeli + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include "musb_core.h" + +struct jz4740_glue { + struct device *dev; + struct platform_device *musb; + struct clk *clk; +}; + +static irqreturn_t jz4740_musb_interrupt(int irq, void *__hci) +{ + unsigned long flags; + irqreturn_t retval = IRQ_NONE; + struct musb *musb = __hci; + + spin_lock_irqsave(&musb->lock, flags); + + musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); + musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); + musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); + + /* +* The controller is gadget only, the state of the host mode IRQ bits is +* undefined. Mask them to make sure that the musb driver core will +* never see them set +*/ + musb->int_usb &= MUSB_INTR_SUSPEND | MUSB_INTR_RESUME | + MUSB_INTR_RESET | MUSB_INTR_SOF; + + if (musb->int_usb || musb->int_tx || musb->int_rx) + retval = musb_interrupt(musb); + + spin_unlock_irqrestore(&musb->lock, flags); + + return retval; +} + +static struct musb_fifo_cfg jz4740_musb_fifo_cfg[] = { +{ .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, +{ .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, +{ .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 64, }, +}; + +static struct musb_hdrc_config jz4740_musb_config = { + /* Silicon does not implement USB OTG. */ + .multipoint = 0, + /* Max EPs scanned, driver will decide which EP can be used. */ + .num_eps= 4, + /* RAMbits needed to configure EPs from table */ + .ram_bits = 9, + .fifo_cfg = jz4740_musb_fifo_cfg, + .fifo_cfg_size = ARRAY_SIZE(jz4740_musb_fifo_cfg), +}; + +static struct musb_hdrc_platform_data jz4740_musb_platform_data = { + .mode = MUSB_PERIPHERAL, + .config = &jz4740_musb_config, +}; + +static int jz4740_musb_init(struct musb *musb) +{ + musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); + if (!musb->xceiv) { + pr_err
[PATCH v3 0/2] Add USB support for Ingenic JZ4740
Hello, Following the fix I submitted a few weeks ago, here is a set of patches that adds USB support for the Ingenic JZ4740 MIPS SoC. The JZ4740 is found in the Ben NanoNote handheld computer which is built by the Qi-Hardware community. Even though Ben NanoNote is already supported in the kernel, we were relying on an out-of-tree gadget driver to make use of the JZ4740 USB Device Controller. The patches that come as a follow-up of this message are an attempt to provide USB support through an musb glue layer. Changes since v2: - usb: musb-jz4740: Add COMPILE_TEST dependency in Kconfig - usb: musb-jz4740: Split drivers/ files from arch/ files Changes since v1: - usb: musb-jz4740: Don't manually free device managed resources - usb: musb-jz4740: Move musb_hdrc_config to the glue driver - usb: musb-jz4740: Move jz4740 specific fifo config to the jz4740 glue - usb: musb-jz4740: Mask host mode only IRQ bits - usb: musb-jz4740: Remove set_vbus callback - usb: musb_gadget: Use is_otg flag to set gadget peripheral mode on reset Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built and tested on device successfully. The following changes since commit 7c0883d: Merge branch 'next' are available in the git repository at: git://seketeli.fr/~apelete/linux-usb.git musb-jz4740 Apelete Seketeli (2): usb: musb: add support for JZ4740 usb device controller usb: musb: fix setting JZ4740 gadget periphal mode on reset drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile |1 + drivers/usb/musb/jz4740.c | 201 drivers/usb/musb/musb_gadget.c | 10 +- 4 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 drivers/usb/musb/jz4740.c -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/2] usb: musb: fix setting JZ4740 gadget periphal mode on reset
JZ4740 USB Device Controller is not OTG compatible and does not have DEVCTL register in silicon. During ethernet-over-usb transactions, on reset, musb driver tries to read from DEVCTL and consequently sets device as host (A-Device) instead of peripheral (B-Device), which makes it a composite device to the USB gadget driver. This induces a kernel panic during power down where the USB gadget driver does a null pointer dereference when trying to access the composite device configuration. On reset, do not rely on DEVCTL value for setting gadget peripheral mode. Use is_otg flag instead to set it to B-Device. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/musb_gadget.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index c410a7f..d4aa779 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -2119,7 +2119,15 @@ __acquires(musb->lock) /* Normal reset, as B-Device; * or else after HNP, as A-Device */ - if (devctl & MUSB_DEVCTL_BDEVICE) { + if (!musb->g.is_otg) { + /* USB device controllers that are not OTG compatible +* may not have DEVCTL register in silicon. +* In that case, do not rely on devctl for setting +* peripheral mode. +*/ + musb->xceiv->state = OTG_STATE_B_PERIPHERAL; + musb->g.is_a_peripheral = 0; + } else if (devctl & MUSB_DEVCTL_BDEVICE) { musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->g.is_a_peripheral = 0; } else { -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/3] mips: qi_lb60: add defconfig for Ben NanoNote
Hello, On 18-Dec-13, Sergei Shtylyov wrote: > Hello. > > On 18-12-2013 3:55, Apelete Seketeli wrote: > > >Add defconfig for the Ben NanoNote handheld computer which is built > >around QI_LB60 board and Ingenic JZ4740 MIPS SoC. > > >Signed-off-by: Apelete Seketeli > >--- > > arch/mips/configs/qi_lb60_defconfig | 188 > > +++ > > 1 file changed, 188 insertions(+) > > create mode 100644 arch/mips/configs/qi_lb60_defconfig > >This should be sent to linux-m...@linux-mips.org and pushed thru > the MIPS tree. No need to send this patch to linux-usb. Understood, will send it to linux-m...@linux-mips.org. Please ignore this patch for USB tree. Cheers. -- Apelete -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/3] mips: qi_lb60: add defconfig for Ben NanoNote
Add defconfig for the Ben NanoNote handheld computer which is built around QI_LB60 board and Ingenic JZ4740 MIPS SoC. Signed-off-by: Apelete Seketeli --- arch/mips/configs/qi_lb60_defconfig | 188 +++ 1 file changed, 188 insertions(+) create mode 100644 arch/mips/configs/qi_lb60_defconfig diff --git a/arch/mips/configs/qi_lb60_defconfig b/arch/mips/configs/qi_lb60_defconfig new file mode 100644 index 000..2b96547 --- /dev/null +++ b/arch/mips/configs/qi_lb60_defconfig @@ -0,0 +1,188 @@ +CONFIG_MACH_JZ4740=y +# CONFIG_COMPACTION is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +CONFIG_HZ_100=y +CONFIG_PREEMPT=y +# CONFIG_SECCOMP is not set +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS_ALL=y +CONFIG_EMBEDDED=y +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_COMPAT_BRK is not set +CONFIG_SLAB=y +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_EFI_PARTITION is not set +# CONFIG_IOSCHED_CFQ is not set +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IP_MROUTE=y +CONFIG_IP_MROUTE_MULTIPLE_TABLES=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +# CONFIG_INET_DIAG is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BIC is not set +# CONFIG_TCP_CONG_CUBIC is not set +CONFIG_TCP_CONG_WESTWOOD=y +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_IPV6 is not set +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +# CONFIG_FIRMWARE_IN_KERNEL is not set +CONFIG_MTD=y +CONFIG_MTD_BLOCK=y +CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_JZ4740=y +CONFIG_MTD_UBI=y +CONFIG_NETDEVICES=y +# CONFIG_WLAN is not set +# CONFIG_INPUT_MOUSEDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_KEYBOARD_ATKBD is not set +CONFIG_KEYBOARD_GPIO=y +CONFIG_KEYBOARD_MATRIX=y +# CONFIG_INPUT_MOUSE is not set +CONFIG_INPUT_MISC=y +# CONFIG_SERIO is not set +CONFIG_LEGACY_PTY_COUNT=2 +# CONFIG_DEVKMEM is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +# CONFIG_SERIAL_8250_DMA is not set +CONFIG_SERIAL_8250_NR_UARTS=2 +CONFIG_SERIAL_8250_RUNTIME_UARTS=2 +# CONFIG_HW_RANDOM is not set +CONFIG_SPI=y +CONFIG_SPI_GPIO=y +CONFIG_POWER_SUPPLY=y +CONFIG_BATTERY_JZ4740=y +CONFIG_CHARGER_GPIO=y +# CONFIG_HWMON is not set +CONFIG_MFD_JZ4740_ADC=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_FB=y +CONFIG_FB_JZ4740=y +CONFIG_BACKLIGHT_LCD_SUPPORT=y +CONFIG_LCD_CLASS_DEVICE=y +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set +# CONFIG_VGA_CONSOLE is not set +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +# CONFIG_LOGO_LINUX_CLUT224 is not set +CONFIG_SOUND=y +CONFIG_SND=y +# CONFIG_SND_SUPPORT_OLD_API is not set +# CONFIG_SND_VERBOSE_PROCFS is not set +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_SPI is not set +# CONFIG_SND_MIPS is not set +CONFIG_SND_SOC=y +CONFIG_SND_JZ4740_SOC=y +CONFIG_SND_JZ4740_SOC_QI_LB60=y +CONFIG_USB=y +CONFIG_USB_OTG_BLACKLIST_HUB=y +CONFIG_USB_MUSB_HDRC=y +CONFIG_USB_MUSB_GADGET=y +CONFIG_USB_MUSB_JZ4740=y +CONFIG_NOP_USB_XCEIV=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DEBUG=y +CONFIG_USB_ETH=y +# CONFIG_USB_ETH_RNDIS is not set +CONFIG_MMC=y +CONFIG_MMC_UNSAFE_RESUME=y +# CONFIG_MMC_BLOCK_BOUNCE is not set +CONFIG_MMC_JZ4740=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_JZ4740=y +CONFIG_DMADEVICES=y +CONFIG_DMA_JZ4740=y +CONFIG_PWM=y +CONFIG_PWM_JZ4740=y +CONFIG_EXT2_FS=y +CONFIG_EXT3_FS=y +# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set +# CONFIG_EXT3_FS_XATTR is not set +# CONFIG_DNOTIFY is not set +CONFIG_VFAT_FS=y +CONFIG_PROC_KCORE=y +# CONFIG_PROC_PAGE_MONITOR is not set +CONFIG_TMPFS=y +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_SUMMARY=y +CONFIG_JFFS2_COMPRESSION_OPTIONS=y +# CONFIG_JFFS2_ZLIB is not set +CONFIG_UBIFS_FS=y +CONFIG_UBIFS_FS_ADVANCED_COMPR=y +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_CODEPAGE_737=y +CONFIG_NLS_CODEPAGE_775=y +CONFIG_NLS_CODEPAGE_850=y +CONFIG_NLS_CODEPAGE_852=y +CONFIG_NLS_CODEPAGE_855=y +CONFIG_NLS_CODEPAGE_857=y +CONFIG_NLS_CODEPAGE_860=y +CONFIG_NLS_CODEPAGE_861=y +CONFIG_NLS_CODEPAGE_862=y +CONFIG_NLS_CODEPAGE_863=y +CONFIG_NLS_CODEPAGE_864=y +CONFIG_NLS_CODEPAGE_865=y +CONFIG_NLS_CODEPAGE_866=y +CONFIG_NLS_CODEPAGE_869=y +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +CONFIG_NLS_CODEPAGE_949=y +CONFIG_NLS_CODEPAGE_874=y +CONFIG_NLS_ISO8859_8=y +CONFIG_NLS_CODEPAGE_1250=y +CONFIG_NLS_CODEPAGE_1251=y +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +CONFIG_NLS_ISO8859_2=y +CONFIG_NLS_ISO8859_3=y +CONFIG_NLS_ISO8859_4=y +CONFIG_NLS_ISO8859_5=y +CONFIG_NLS_I
[PATCH v2 2/3] usb: musb: add support for JZ4740 usb device controller
Add support for Ingenic JZ4740 USB Device Controller through a specific musb glue layer. The platform data already available in tree for that USB Device Controller was previously used by an out-of-tree USB gadget driver which was not relying on the musb driver and was written by Ingenic and the Qi-Hardware community. JZ4740 UDC not being OTG compatible and missing some hardware registers, this musb glue layer is written from scratch to be used in gadget mode only and take silicon design specifics into account. Signed-off-by: Apelete Seketeli Signed-off-by: Lars-Peter Clausen --- arch/mips/include/asm/mach-jz4740/platform.h |1 + arch/mips/jz4740/board-qi_lb60.c |1 + arch/mips/jz4740/platform.c | 40 +++-- drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile|1 + drivers/usb/musb/jz4740.c| 201 ++ 6 files changed, 235 insertions(+), 17 deletions(-) create mode 100644 drivers/usb/musb/jz4740.c diff --git a/arch/mips/include/asm/mach-jz4740/platform.h b/arch/mips/include/asm/mach-jz4740/platform.h index 05988c2..069b43a 100644 --- a/arch/mips/include/asm/mach-jz4740/platform.h +++ b/arch/mips/include/asm/mach-jz4740/platform.h @@ -21,6 +21,7 @@ extern struct platform_device jz4740_usb_ohci_device; extern struct platform_device jz4740_udc_device; +extern struct platform_device jz4740_udc_xceiv_device; extern struct platform_device jz4740_mmc_device; extern struct platform_device jz4740_rtc_device; extern struct platform_device jz4740_i2c_device; diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c index 8a5ec0e..c01900e 100644 --- a/arch/mips/jz4740/board-qi_lb60.c +++ b/arch/mips/jz4740/board-qi_lb60.c @@ -427,6 +427,7 @@ static struct platform_device qi_lb60_audio_device = { static struct platform_device *jz_platform_devices[] __initdata = { &jz4740_udc_device, + &jz4740_udc_xceiv_device, &jz4740_mmc_device, &jz4740_nand_device, &qi_lb60_keypad, diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c index df65677..1be41e2 100644 --- a/arch/mips/jz4740/platform.c +++ b/arch/mips/jz4740/platform.c @@ -21,6 +21,8 @@ #include +#include + #include #include #include @@ -56,29 +58,35 @@ struct platform_device jz4740_usb_ohci_device = { .resource = jz4740_usb_ohci_resources, }; -/* UDC (USB gadget controller) */ -static struct resource jz4740_usb_gdt_resources[] = { - { - .start = JZ4740_UDC_BASE_ADDR, - .end= JZ4740_UDC_BASE_ADDR + 0x1000 - 1, - .flags = IORESOURCE_MEM, +/* USB Device Controller */ +struct platform_device jz4740_udc_xceiv_device = { + .name = "usb_phy_gen_xceiv", + .id = 0, +}; + +static struct resource jz4740_udc_resources[] = { + [0] = { + .start = JZ4740_UDC_BASE_ADDR, + .end = JZ4740_UDC_BASE_ADDR + 0x1 - 1, + .flags = IORESOURCE_MEM, }, - { - .start = JZ4740_IRQ_UDC, - .end= JZ4740_IRQ_UDC, - .flags = IORESOURCE_IRQ, + [1] = { + .start = JZ4740_IRQ_UDC, + .end = JZ4740_IRQ_UDC, + .flags = IORESOURCE_IRQ, + .name = "mc", }, }; struct platform_device jz4740_udc_device = { - .name = "jz-udc", - .id = -1, - .dev = { - .dma_mask = &jz4740_udc_device.dev.coherent_dma_mask, + .name = "musb-jz4740", + .id = -1, + .dev = { + .dma_mask = &jz4740_udc_device.dev.coherent_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), }, - .num_resources = ARRAY_SIZE(jz4740_usb_gdt_resources), - .resource = jz4740_usb_gdt_resources, + .num_resources = ARRAY_SIZE(jz4740_udc_resources), + .resource = jz4740_udc_resources, }; /* MMC/SD controller */ diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 57dfc0c..a45ed15 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -93,6 +93,12 @@ config USB_MUSB_BLACKFIN config USB_MUSB_UX500 tristate "Ux500 platforms" +config USB_MUSB_JZ4740 + tristate "JZ4740" + depends on MACH_JZ4740 + depends on USB_MUSB_GADGET + depends on USB_OTG_BLACKLIST_HUB + endchoice config USB_MUSB_AM335X_CHILD @@ -100,7 +106,7 @@ config USB_MUSB_AM335X_CHILD choice prompt 'MUSB DMA mode' - default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM + default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM || USB_MUSB_JZ4740 default USB_UX500_DMA if USB_MUSB_UX500 default USB_INVENTRA_DMA if USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN def
[PATCH v2 0/3] Add USB support for Ingenic JZ4740
Hello, Following the fix I submitted a few weeks ago, here is a set of patches that adds USB support for the Ingenic JZ4740 MIPS SoC. The JZ4740 is found in the Ben NanoNote handheld computer which is built by the Qi-Hardware community. Even though Ben NanoNote is already supported in the kernel, we were relying on an out-of-tree gadget driver to make use of the JZ4740 USB Device Controller. The patches that come as a follow-up of this message are an attempt to provide USB support through an musb glue layer. Changes since v1: - usb: musb-jz4740: Don't manually free device managed resources - usb: musb-jz4740: Move musb_hdrc_config to the glue driver - usb: musb-jz4740: Move jz4740 specific fifo config to the jz4740 glue - usb: musb-jz4740: Mask host mode only IRQ bits - usb: musb-jz4740: Remove set_vbus callback - usb: musb_gadget: Use is_otg flag to set gadget peripheral mode on reset Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built and tested on device successfully. The following changes since commit 9bdff34517bc49d8e98558659e077ea9f9df3d60: Merge branch 'next' are available in the git repository at: git://seketeli.fr/~apelete/linux-usb.git musb-jz4740 Apelete Seketeli (3): mips: qi_lb60: add defconfig for Ben NanoNote usb: musb: add support for JZ4740 usb device controller usb: musb: fix setting JZ4740 gadget periphal mode on reset arch/mips/configs/qi_lb60_defconfig | 188 arch/mips/include/asm/mach-jz4740/platform.h |1 + arch/mips/jz4740/board-qi_lb60.c |1 + arch/mips/jz4740/platform.c | 40 +++-- drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile|1 + drivers/usb/musb/jz4740.c| 201 ++ drivers/usb/musb/musb_gadget.c | 10 +- 8 files changed, 432 insertions(+), 18 deletions(-) create mode 100644 arch/mips/configs/qi_lb60_defconfig create mode 100644 drivers/usb/musb/jz4740.c -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] usb: musb: fix setting JZ4740 gadget periphal mode on reset
JZ4740 USB Device Controller is not OTG compatible and does not have DEVCTL register in silicon. During ethernet-over-usb transactions, on reset, musb driver tries to read from DEVCTL and consequently sets device as host (A-Device) instead of peripheral (B-Device), which makes it a composite device to the USB gadget driver. This induces a kernel panic during power down where the USB gadget driver does a null pointer dereference when trying to access the composite device configuration. On reset, do not rely on DEVCTL value for setting gadget peripheral mode. Use is_otg flag instead to set it to B-Device. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/musb_gadget.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 32fb057..cb50163 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -2119,7 +2119,15 @@ __acquires(musb->lock) /* Normal reset, as B-Device; * or else after HNP, as A-Device */ - if (devctl & MUSB_DEVCTL_BDEVICE) { + if (!musb->g.is_otg) { + /* USB device controllers that are not OTG compatible +* may not have DEVCTL register in silicon. +* In that case, do not rely on devctl for setting +* peripheral mode. +*/ + musb->xceiv->state = OTG_STATE_B_PERIPHERAL; + musb->g.is_a_peripheral = 0; + } else if (devctl & MUSB_DEVCTL_BDEVICE) { musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->g.is_a_peripheral = 0; } else { -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] usb: musb: fix setting JZ4740 gadget periphal mode on reset
On 16-Dec-13, Felipe Balbi wrote: > On Sat, Dec 14, 2013 at 04:48:38AM +0100, Apelete Seketeli wrote: > > JZ4740 USB Device Controller is not OTG compatible and does not have DEVCTL > > register in silicon. > > > > During ethernet-over-usb transactions, on reset, musb driver tries to > > read from DEVCTL and consequently sets device as host (A-Device) > > instead of peripheral (B-Device), which makes it a composite device to > > the USB gadget driver. > > This induces a kernel panic during power down where the USB gadget > > driver does a null pointer dereference when trying to access the > > composite device configuration. > > > > On reset, do not rely on DEVCTL value for setting gadget peripheral > > mode: hardcode it instead to B-Device. > > > > Signed-off-by: Apelete Seketeli > > --- > > drivers/usb/musb/musb_gadget.c |9 + > > 1 file changed, 9 insertions(+) > > > > diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c > > index 32fb057..b4bea7a 100644 > > --- a/drivers/usb/musb/musb_gadget.c > > +++ b/drivers/usb/musb/musb_gadget.c > > @@ -2119,6 +2119,14 @@ __acquires(musb->lock) > > /* Normal reset, as B-Device; > > * or else after HNP, as A-Device > > */ > > +#if defined(CONFIG_USB_MUSB_JZ4740) || > > defined(CONFIG_USB_MUSB_JZ4740_MODULE) > > NAK, no ifdefs in this driver. Pass a quirk flag through platform_data > or something similar. I get that, makes sense to me, but problem is the driver has to read a valid value from DEVCTL hardware register when musb_g_reset() is called, and I do not see how this can be achieved through platform_data. Is it ok to use ifdefs in musb_regs.h to add specific hardware register indexes for JZ4740 instead ? I am actually thinking about fooling the musb driver into reading a valid value from another register instead of DEVCTL. Cheers. -- Apelete -- 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] mips: qi_lb60: add defconfig for Ben NanoNote
Add defconfig for the Ben NanoNote handheld computer which is built around QI_LB60 board and Ingenic JZ4740 MIPS SoC. Signed-off-by: Apelete Seketeli --- arch/mips/configs/qi_lb60_defconfig | 188 +++ 1 file changed, 188 insertions(+) create mode 100644 arch/mips/configs/qi_lb60_defconfig diff --git a/arch/mips/configs/qi_lb60_defconfig b/arch/mips/configs/qi_lb60_defconfig new file mode 100644 index 000..2b96547 --- /dev/null +++ b/arch/mips/configs/qi_lb60_defconfig @@ -0,0 +1,188 @@ +CONFIG_MACH_JZ4740=y +# CONFIG_COMPACTION is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +CONFIG_HZ_100=y +CONFIG_PREEMPT=y +# CONFIG_SECCOMP is not set +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS_ALL=y +CONFIG_EMBEDDED=y +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_COMPAT_BRK is not set +CONFIG_SLAB=y +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_EFI_PARTITION is not set +# CONFIG_IOSCHED_CFQ is not set +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_IP_MROUTE=y +CONFIG_IP_MROUTE_MULTIPLE_TABLES=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +# CONFIG_INET_DIAG is not set +CONFIG_TCP_CONG_ADVANCED=y +# CONFIG_TCP_CONG_BIC is not set +# CONFIG_TCP_CONG_CUBIC is not set +CONFIG_TCP_CONG_WESTWOOD=y +# CONFIG_TCP_CONG_HTCP is not set +# CONFIG_IPV6 is not set +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +# CONFIG_FIRMWARE_IN_KERNEL is not set +CONFIG_MTD=y +CONFIG_MTD_BLOCK=y +CONFIG_MTD_NAND=y +CONFIG_MTD_NAND_JZ4740=y +CONFIG_MTD_UBI=y +CONFIG_NETDEVICES=y +# CONFIG_WLAN is not set +# CONFIG_INPUT_MOUSEDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_KEYBOARD_ATKBD is not set +CONFIG_KEYBOARD_GPIO=y +CONFIG_KEYBOARD_MATRIX=y +# CONFIG_INPUT_MOUSE is not set +CONFIG_INPUT_MISC=y +# CONFIG_SERIO is not set +CONFIG_LEGACY_PTY_COUNT=2 +# CONFIG_DEVKMEM is not set +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +# CONFIG_SERIAL_8250_DMA is not set +CONFIG_SERIAL_8250_NR_UARTS=2 +CONFIG_SERIAL_8250_RUNTIME_UARTS=2 +# CONFIG_HW_RANDOM is not set +CONFIG_SPI=y +CONFIG_SPI_GPIO=y +CONFIG_POWER_SUPPLY=y +CONFIG_BATTERY_JZ4740=y +CONFIG_CHARGER_GPIO=y +# CONFIG_HWMON is not set +CONFIG_MFD_JZ4740_ADC=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_FB=y +CONFIG_FB_JZ4740=y +CONFIG_BACKLIGHT_LCD_SUPPORT=y +CONFIG_LCD_CLASS_DEVICE=y +# CONFIG_BACKLIGHT_CLASS_DEVICE is not set +# CONFIG_VGA_CONSOLE is not set +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_LOGO=y +# CONFIG_LOGO_LINUX_MONO is not set +# CONFIG_LOGO_LINUX_VGA16 is not set +# CONFIG_LOGO_LINUX_CLUT224 is not set +CONFIG_SOUND=y +CONFIG_SND=y +# CONFIG_SND_SUPPORT_OLD_API is not set +# CONFIG_SND_VERBOSE_PROCFS is not set +# CONFIG_SND_DRIVERS is not set +# CONFIG_SND_SPI is not set +# CONFIG_SND_MIPS is not set +CONFIG_SND_SOC=y +CONFIG_SND_JZ4740_SOC=y +CONFIG_SND_JZ4740_SOC_QI_LB60=y +CONFIG_USB=y +CONFIG_USB_OTG_BLACKLIST_HUB=y +CONFIG_USB_MUSB_HDRC=y +CONFIG_USB_MUSB_GADGET=y +CONFIG_USB_MUSB_JZ4740=y +CONFIG_NOP_USB_XCEIV=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DEBUG=y +CONFIG_USB_ETH=y +# CONFIG_USB_ETH_RNDIS is not set +CONFIG_MMC=y +CONFIG_MMC_UNSAFE_RESUME=y +# CONFIG_MMC_BLOCK_BOUNCE is not set +CONFIG_MMC_JZ4740=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_JZ4740=y +CONFIG_DMADEVICES=y +CONFIG_DMA_JZ4740=y +CONFIG_PWM=y +CONFIG_PWM_JZ4740=y +CONFIG_EXT2_FS=y +CONFIG_EXT3_FS=y +# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set +# CONFIG_EXT3_FS_XATTR is not set +# CONFIG_DNOTIFY is not set +CONFIG_VFAT_FS=y +CONFIG_PROC_KCORE=y +# CONFIG_PROC_PAGE_MONITOR is not set +CONFIG_TMPFS=y +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_SUMMARY=y +CONFIG_JFFS2_COMPRESSION_OPTIONS=y +# CONFIG_JFFS2_ZLIB is not set +CONFIG_UBIFS_FS=y +CONFIG_UBIFS_FS_ADVANCED_COMPR=y +# CONFIG_NETWORK_FILESYSTEMS is not set +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_CODEPAGE_737=y +CONFIG_NLS_CODEPAGE_775=y +CONFIG_NLS_CODEPAGE_850=y +CONFIG_NLS_CODEPAGE_852=y +CONFIG_NLS_CODEPAGE_855=y +CONFIG_NLS_CODEPAGE_857=y +CONFIG_NLS_CODEPAGE_860=y +CONFIG_NLS_CODEPAGE_861=y +CONFIG_NLS_CODEPAGE_862=y +CONFIG_NLS_CODEPAGE_863=y +CONFIG_NLS_CODEPAGE_864=y +CONFIG_NLS_CODEPAGE_865=y +CONFIG_NLS_CODEPAGE_866=y +CONFIG_NLS_CODEPAGE_869=y +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +CONFIG_NLS_CODEPAGE_949=y +CONFIG_NLS_CODEPAGE_874=y +CONFIG_NLS_ISO8859_8=y +CONFIG_NLS_CODEPAGE_1250=y +CONFIG_NLS_CODEPAGE_1251=y +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +CONFIG_NLS_ISO8859_2=y +CONFIG_NLS_ISO8859_3=y +CONFIG_NLS_ISO8859_4=y +CONFIG_NLS_ISO8859_5=y +CONFIG_NLS_I
[PATCH 2/3] usb: musb: add support for JZ4740 usb device controller
Add support for Ingenic JZ4740 USB Device Controller through a specific musb glue layer. The platform data already available in tree for that USB Device Controller was previously used by an out-of-tree USB gadget driver which was not relying on the musb driver and was written by Ingenic and the Qi-Hardware community. JZ4740 UDC not being OTG compatible and missing some hardware registers, this musb glue layer is written from scratch to be used in gadget mode only and take silicon design specifics into account. Signed-off-by: Apelete Seketeli --- arch/mips/include/asm/mach-jz4740/platform.h |1 + arch/mips/jz4740/board-qi_lb60.c |1 + arch/mips/jz4740/platform.c | 55 +-- drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile|1 + drivers/usb/musb/jz4740.c| 229 ++ drivers/usb/musb/musb_core.c | 14 ++ 7 files changed, 292 insertions(+), 17 deletions(-) create mode 100644 drivers/usb/musb/jz4740.c diff --git a/arch/mips/include/asm/mach-jz4740/platform.h b/arch/mips/include/asm/mach-jz4740/platform.h index 05988c2..069b43a 100644 --- a/arch/mips/include/asm/mach-jz4740/platform.h +++ b/arch/mips/include/asm/mach-jz4740/platform.h @@ -21,6 +21,7 @@ extern struct platform_device jz4740_usb_ohci_device; extern struct platform_device jz4740_udc_device; +extern struct platform_device jz4740_udc_xceiv_device; extern struct platform_device jz4740_mmc_device; extern struct platform_device jz4740_rtc_device; extern struct platform_device jz4740_i2c_device; diff --git a/arch/mips/jz4740/board-qi_lb60.c b/arch/mips/jz4740/board-qi_lb60.c index 8a5ec0e..c01900e 100644 --- a/arch/mips/jz4740/board-qi_lb60.c +++ b/arch/mips/jz4740/board-qi_lb60.c @@ -427,6 +427,7 @@ static struct platform_device qi_lb60_audio_device = { static struct platform_device *jz_platform_devices[] __initdata = { &jz4740_udc_device, + &jz4740_udc_xceiv_device, &jz4740_mmc_device, &jz4740_nand_device, &qi_lb60_keypad, diff --git a/arch/mips/jz4740/platform.c b/arch/mips/jz4740/platform.c index df65677..c55ff0a 100644 --- a/arch/mips/jz4740/platform.c +++ b/arch/mips/jz4740/platform.c @@ -21,6 +21,8 @@ #include +#include + #include #include #include @@ -56,29 +58,50 @@ struct platform_device jz4740_usb_ohci_device = { .resource = jz4740_usb_ohci_resources, }; -/* UDC (USB gadget controller) */ -static struct resource jz4740_usb_gdt_resources[] = { - { - .start = JZ4740_UDC_BASE_ADDR, - .end= JZ4740_UDC_BASE_ADDR + 0x1000 - 1, - .flags = IORESOURCE_MEM, +/* USB Device Controller */ +struct platform_device jz4740_udc_xceiv_device = { + .name = "usb_phy_gen_xceiv", + .id = 0, +}; + +static struct musb_hdrc_config jz4740_udc_config = { + /* Silicon does not implement USB OTG. */ + .multipoint = 0, + /* Max EPs scanned, driver will decide which EP can be used. */ + .num_eps= 4, + /* RAMbits needed to configure EPs from table */ + .ram_bits = 9, +}; + +static struct musb_hdrc_platform_data jz4740_udc_platform_data = { + .mode = MUSB_PERIPHERAL, + .config = &jz4740_udc_config, +}; + +static struct resource jz4740_udc_resources[] = { + [0] = { + .start = JZ4740_UDC_BASE_ADDR, + .end = JZ4740_UDC_BASE_ADDR + 0x1 - 1, + .flags = IORESOURCE_MEM, }, - { - .start = JZ4740_IRQ_UDC, - .end= JZ4740_IRQ_UDC, - .flags = IORESOURCE_IRQ, + [1] = { + .start = JZ4740_IRQ_UDC, + .end = JZ4740_IRQ_UDC, + .flags = IORESOURCE_IRQ, + .name = "mc", }, }; struct platform_device jz4740_udc_device = { - .name = "jz-udc", - .id = -1, - .dev = { - .dma_mask = &jz4740_udc_device.dev.coherent_dma_mask, + .name = "musb-jz4740", + .id = -1, + .dev = { + .dma_mask = &jz4740_udc_device.dev.coherent_dma_mask, .coherent_dma_mask = DMA_BIT_MASK(32), + .platform_data = &jz4740_udc_platform_data, }, - .num_resources = ARRAY_SIZE(jz4740_usb_gdt_resources), - .resource = jz4740_usb_gdt_resources, + .num_resources = ARRAY_SIZE(jz4740_udc_resources), + .resource = jz4740_udc_resources, }; /* MMC/SD controller */ diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 57dfc0c..a45ed15 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -93,6 +93,12 @@ config USB_MUSB_BLACKFIN config USB_MUSB_UX500 tristate "Ux500 platforms" +config USB_M
[PATCH 3/3] usb: musb: fix setting JZ4740 gadget periphal mode on reset
JZ4740 USB Device Controller is not OTG compatible and does not have DEVCTL register in silicon. During ethernet-over-usb transactions, on reset, musb driver tries to read from DEVCTL and consequently sets device as host (A-Device) instead of peripheral (B-Device), which makes it a composite device to the USB gadget driver. This induces a kernel panic during power down where the USB gadget driver does a null pointer dereference when trying to access the composite device configuration. On reset, do not rely on DEVCTL value for setting gadget peripheral mode: hardcode it instead to B-Device. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/musb_gadget.c |9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 32fb057..b4bea7a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -2119,6 +2119,14 @@ __acquires(musb->lock) /* Normal reset, as B-Device; * or else after HNP, as A-Device */ +#if defined(CONFIG_USB_MUSB_JZ4740) || defined(CONFIG_USB_MUSB_JZ4740_MODULE) + /* JZ4740 UDC Controller is not OTG compatible and does not +* have DEVCTL register in silicon: do not rely on devctl for +* setting peripheral mode. +*/ + musb->xceiv->state = OTG_STATE_B_PERIPHERAL; + musb->g.is_a_peripheral = 0; +#else if (devctl & MUSB_DEVCTL_BDEVICE) { musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->g.is_a_peripheral = 0; @@ -2126,6 +2134,7 @@ __acquires(musb->lock) musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->g.is_a_peripheral = 1; } +#endif /* start with default limits on VBUS power draw */ (void) musb_gadget_vbus_draw(&musb->g, 8); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] Add USB support for Ingenic JZ4740
Hello, Following the fix I submitted a few weeks ago, here is a set of patches that add USB support for the Ingenic JZ4740 MIPS SoC. The JZ4740 is found in the Ben NanoNote handheld computer which is built by the Qi-Hardware community. Even though Ben NanoNote is already supported in the kernel, we were relying on an out-of-tree gadget driver to make use of the JZ4740 USB Device Controller. The patches that come as a follow-up of this message are an attempt to provide USB support through an musb glue layer. Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built and tested on device successfully. The following changes since commit 9bdff34517bc49d8e98558659e077ea9f9df3d60: Merge branch 'next' are available in the git repository at: git://seketeli.fr/~apelete/linux-usb.git musb-jz4740 Apelete Seketeli (3): mips: qi_lb60: add defconfig for Ben NanoNote usb: musb: add support for JZ4740 usb device controller usb: musb: fix setting JZ4740 gadget periphal mode on reset arch/mips/configs/qi_lb60_defconfig | 188 + arch/mips/include/asm/mach-jz4740/platform.h |1 + arch/mips/jz4740/board-qi_lb60.c |1 + arch/mips/jz4740/platform.c | 55 +-- drivers/usb/musb/Kconfig |8 +- drivers/usb/musb/Makefile|1 + drivers/usb/musb/jz4740.c| 229 ++ drivers/usb/musb/musb_core.c | 14 ++ drivers/usb/musb/musb_gadget.c |9 + 9 files changed, 489 insertions(+), 17 deletions(-) create mode 100644 arch/mips/configs/qi_lb60_defconfig create mode 100644 drivers/usb/musb/jz4740.c -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/1] usb: fix musb gadget to enable OTG mode conditionally
The musb driver is usable in host, gadget or dual role mode depending on the kernel configuration. However, the musb gadget part of the driver is enabling OTG mode whether the driver is built for dual role or gadget only mode. This induces a bug for gadget only USB device controllers where the kernel tries to use Host Negotiation Protocol with such controllers, which causes a panic. This behaviour is now fixed by enabling OTG mode only when musb driver is built for dual role mode. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/musb_gadget.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 3671898..5bcd9d6 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1796,7 +1796,11 @@ int musb_gadget_setup(struct musb *musb) /* this "gadget" abstracts/virtualizes the controller */ musb->g.name = musb_driver_name; +#if IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE) musb->g.is_otg = 1; +#elif IS_ENABLED(CONFIG_USB_MUSB_GADGET) + musb->g.is_otg = 0; +#endif musb_g_init_endpoints(musb); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/1] usb: fix musb gadget to enable OTG mode conditionally
Hello, While working on an musb glue layer for an embedded USB device controller, I encountered the following issue. The aforementioned UDC is not OTG capable, so I built the musb driver as gadget only and noticed that the musb_gadget code was trying to enable the OTG side of the controller, which does exist in silicon. While testing the glue layer code, the musb core was then trying to use Host Negotiation Protocol, which induces a panic. The patch that comes as a follow-up of this message is an attempt to fix the issue before submitting the glue layer code which is still in progress. Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built successfully and tested on device without reproducing the issue. The following changes since commit 3fc848d423216db97a4db9b4b9633561244e100a: usb: fix musb gadget to enable OTG mode conditionally are available in the git repository at: git://seketeli.fr/~apelete/linux-usb.git musb-hnp-fix Apelete Seketeli (1): usb: fix musb gadget to enable OTG mode conditionally drivers/usb/musb/musb_gadget.c |4 1 file changed, 4 insertions(+) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/1] usb: fix musb gadget to enable OTG mode conditionally
The musb driver is usable in host, gadget or dual role mode depending on the kernel configuration. However, the musb gadget part of the driver is enabling OTG mode whether the driver is built for dual role or gadget only mode. This induces a bug for gadget only USB device controllers where the kernel tries to use Host Negotiation Protocol with such controllers, which causes a panic. This behaviour is now fixed by enabling OTG mode only when musb driver is built for dual role mode. Signed-off-by: Apelete Seketeli --- drivers/usb/musb/musb_gadget.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 3671898..5bcd9d6 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1796,7 +1796,11 @@ int musb_gadget_setup(struct musb *musb) /* this "gadget" abstracts/virtualizes the controller */ musb->g.name = musb_driver_name; +#if IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE) musb->g.is_otg = 1; +#elif IS_ENABLED(CONFIG_USB_MUSB_GADGET) + musb->g.is_otg = 0; +#endif musb_g_init_endpoints(musb); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/1] usb: fix musb gadget to enable OTG mode conditionally
Hello, While working on an musb glue layer for an embedded USB device controller, I encountered the following issue. The aforementioned UDC is not OTG capable, so I built the musb driver as gadget only and noticed that the musb_gadget code was trying to enable the OTG side of the controller, which does exist in silicon. While testing the glue layer code, the musb core was then trying to use Host Negotiation Protocol, which induces a panic. The patch that comes as a follow-up of this message is an attempt to fix the issue before submitting the glue layer code which is still in progress; v2 only fixes the Cc: list which wasn't picked up at first by git-send-email, sorry for the inconvenience. Changes were rebased on top of Felipe Balbi's USB Subsystem master branch, built successfully and tested on device without reproducing the issue. The following changes since commit 3fc848d423216db97a4db9b4b9633561244e100a: usb: fix musb gadget to enable OTG mode conditionally are available in the git repository at: git://seketeli.fr/~apelete/linux-usb.git musb-hnp-fix Apelete Seketeli (1): usb: fix musb gadget to enable OTG mode conditionally drivers/usb/musb/musb_gadget.c |4 1 file changed, 4 insertions(+) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html