musb bogosity
Subsystems (7)
The musb code currently kills the SH randconfig build (and this will hose any platform that also selects HAVE_CLK -- a PPC or AVR32 randconfig would have also hit this eventually), as can be seen here:
http://kisskb.ellerman.id.au/kisskb/buildresult/41095/
This initial failure comes from the fact that musb handily uses "special" I/O routines that it handily wraps, after having failed at grepping for other users. Why this driver isn't using ioread/writeXX_rep() is beyond me, as that's the portable interface we have for doing precisely this sort of thing, without this bizarre PIO/MMIO wrapper munging that isn't even going to work on most platforms.
With that ifdef in place, it's on to the next integral build failure:
drivers/usb/musb/musb_core.c: In function 'fifo_setup':drivers/usb/musb/musb_core.c:1122: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function) drivers/usb/musb/musb_core.c:1122: error: (Each undeclared identifier is reported only once drivers/usb/musb/musb_core.c:1122: error: for each function it appears in.) drivers/usb/musb/musb_core.c: In function 'ep_config_from_table':drivers/usb/musb/musb_core.c:1246: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function) drivers/usb/musb/musb_core.c: In function 'musb_remove':drivers/usb/musb/musb_core.c:2131: warning: unused variable 'ctrl_base'
make[1]: *** [drivers/usb/musb/musb_core.o] Error 1
make: *** [drivers/usb/musb/musb_core.o] Error 2
...
$ git grep MUSB_C_RAM_BITS drivers/usb/musb drivers/usb/musb/musb_core.c:#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2)) drivers/usb/musb/tusb6010.h:#define MUSB_C_RAM_BITS 12
...
the comment above MUSB_C_RAM_BITS seems to suggest that it's entirely dependent on the chip, so moving it in to musb_core.c wouldn't be terribly productive. Which leaves us in a situation where the core is dependent on arbitrary driver definitions, while the driver itself is obviously only dependent on the core. Has anyone actually tested this with TUSB6010 support disabled?
A quick grep suggests that blackfin is also going to get bitten by this, so simply tossing a depends on (ARM && BROKEN) in wouldn't help matters either.
---
drivers/usb/musb/musb_io.h +1 -1
@@ -37,7 +37,7 @@#include <linux/io.h> -#ifndef CONFIG_ARM +#if !defined(CONFIG_ARM ) && !defined(CONFIG_SUPERH )static inline void readsl (const void __iomem *addr,void *buf,int len) {insl ((unsigned long )addr, buf, len); }static inline void readsw (const void __iomem *addr,void *buf,int len)
Quoted 50 lines · ext Paul Mundt
The musb code currently kills the SH randconfig build (and this will hose any platform that also selects
HAVE_CLK-- a PPC or AVR32 randconfig would have also hit this eventually), as can be seen here:http://kisskb.ellerman.id.au/kisskb/buildresult/41095/
This initial failure comes from the fact that musb handily uses "special" I/O routines that it handily wraps, after having failed at grepping for other users. Why this driver isn't using ioread/writeXX_rep() is beyond me, as that's the portable interface we have for doing precisely this sort of thing, without this bizarre PIO/MMIO wrapper munging that isn't even going to work on most platforms.
With that ifdef in place, it's on to the next integral build failure:
drivers/usb/musb/musb_core.c: In function 'fifo_setup':drivers/usb/musb/musb_core.c:1122: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c:1122: error: (Each undeclared identifier is reported only oncedrivers/usb/musb/musb_core.c:1122: error: for each function it appears in.)drivers/usb/musb/musb_core.c: In function 'ep_config_from_table':drivers/usb/musb/musb_core.c:1246: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c: In function 'musb_remove':drivers/usb/musb/musb_core.c:2131: warning: unused variable 'ctrl_base'
make[1]: *** [drivers/usb/musb/musb_core.o] Error 1
make: *** [drivers/usb/musb/musb_core.o] Error 2...
$ git grep MUSB_C_RAM_BITS drivers/usb/musb drivers/usb/musb/musb_core.c:#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2)) drivers/usb/musb/tusb6010.h:#define MUSB_C_RAM_BITS 12...
the comment above
MUSB_C_RAM_BITSseems to suggest that it's entirely dependent on the chip, so moving it in tomusb_core.cwouldn't be terribly productive. Which leaves us in a situation where the core is dependent on arbitrary driver definitions, while the driver itself is obviously only dependent on the core. Has anyone actually tested this with TUSB6010 support disabled?A quick grep suggests that blackfin is also going to get bitten by this, so simply tossing a depends on (ARM && BROKEN) in wouldn't help matters either.
---
drivers/usb/musb/musb_io.h +0
-0
drivers/usb/musb/musb_io.h line 43
Quoted 8 lines
drivers/usb/musb/musb_io.h +1
-1@@ -37,7 +37,7 @@#include <linux/io.h> -#ifndef CONFIG_ARM +#if !defined(CONFIG_ARM ) && !defined(CONFIG_SUPERH )static inline void readsl (const void __iomem *addr,void *buf,int len) {insl ((unsigned long )addr, buf, len); }static inline void readsw (const void __iomem *addr,void *buf,int len)
The right way to fix this would be by removing all those defines and make that configuration come from platform_data. I have a patch for that, I'll send it to Greg and try to be sure it gets applied. I've been using it quite a while and it seems stable.
Signature · 1 line
balbi
Quoted 8 lines · Felipe Balbi
Quoted 7 lines · ext Paul Mundt
This initial failure comes from the fact that musb handily uses "special" I/O routines that it handily wraps, after having failed at grepping for other users. Why this driver isn't using ioread/writeXX_rep() is beyond me, as that's the portable interface we have for doing precisely this sort of thing, without this bizarre PIO/MMIO wrapper munging that isn't even going to work on most platforms.
[snip]
Quoted 13 lines
Quoted 13 lines
A quick grep suggests that blackfin is also going to get bitten by this, so simply tossing a depends on (ARM && BROKEN) in wouldn't help matters either.
---
drivers/usb/musb/musb_io.h +0
-0@@ -37,7 +37,7 @@#include <linux/io.h>
Quoted 11 lines
drivers/usb/musb/musb_io.h line 43
Quoted 5 lines
drivers/usb/musb/musb_io.h +1
-1-#ifndef CONFIG_ARM +#if !defined(CONFIG_ARM ) && !defined(CONFIG_SUPERH )static inline void readsl (const void __iomem *addr,void *buf,int len) {insl ((unsigned long )addr, buf, len); }static inline void readsw (const void __iomem *addr,void *buf,int len)The right way to fix this would be by removing all those defines and make that configuration come from
platform_data. I have a patch for that, I'll send it to Greg and try to be sure it gets applied. I've been using it quite a while and it seems stable.
Great. The fact the I/O routines are broken and that this doesn't build on anything but ARM still remains a problem. Your generic ifdefs also seem to be using __raw_xxx() as MMIO accessors while using the xxx() variants as PIO accessors, irregardless of whether the platform sets NO_IOPORT or not. If you aren't going to use generic routines, then don't bother removing your architecture dependency in Kconfig. As it is, your driver's assumptions on I/O accesses are simply bogus, which is precisely why we have these portable interfaces in the first place.
Quoted 1 line · Felipe Balbi
Quoted 1 line
other users. Why this driver isn't using ioread/writeXX_rep() is beyond
I'll try to fix io routines asap. From your next mail I could see that it's really bogus :-p
Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/musb_core.c: In function 'fifo_setup':drivers/usb/musb/musb_core.c:1122: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c:1122: error: (Each undeclared identifier is reported only oncedrivers/usb/musb/musb_core.c:1122: error: for each function it appears in.)drivers/usb/musb/musb_core.c: In function 'ep_config_from_table':drivers/usb/musb/musb_core.c:1246: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c: In function 'musb_remove':drivers/usb/musb/musb_core.c:2131: warning: unused variable 'ctrl_base'
make[1]: *** [drivers/usb/musb/musb_core.o] Error 1
make: *** [drivers/usb/musb/musb_core.o] Error 2
Below is the patch that fixes it.
I don't have sh cross-compilers, so if you could try it out and be sure it works, I'd be glad.
==== cut here ====
Quoted 1 line
From
0bbc416e8170c4169608f7496b8d67be3828d76bMon Sep 17 00:00:00 2001
From: Felipe Balbi <[email protected]>
Date: Fri, 8 Aug 2008 11:39:41 +0300
Subject: [PATCH] usb: musb: pass configuration specifics via pdata
Use platform_data to pass musb configuration-specific details to musb driver.
This patch will prevent that other platforms selecting HAVE_CLK and enabling musb won't break tree building.
The other parts of it will come when linux-omap merge up more omap2/3 board-files.
--- arch/arm/mach-omap2/usb-tusb6010.c | 1 - drivers/usb/musb/musb_core.c | 37 ++++----- drivers/usb/musb/musb_core.h | 14 +--- drivers/usb/musb/tusb6010.h | 169 ------------------------------------ include/linux/usb/musb.h | 38 +++++++- 5 files changed, 51 insertions(+), 208 deletions(-)
arch/arm/mach-omap2/usb-tusb6010.c +0 -1
@@ -317,7 +317,6 @@ tusb6010_setup_interface(struct musb_hdrc_platform_data *data,printk (error,6 , status);return -ENODEV ; } - data->multipoint =1 ; tusb_device.dev.platform_data = data;/* REVISIT let the driver know what DMA channels work */
drivers/usb/musb/musb_core.c +16 -21
@@ -990,12 +990,6 @@ 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. */ -#ifdef MUSB_C_DYNFIFO_DEF -#define can_dynfifo () 1 -#else -#define can_dynfifo () 0 -#endif -#if defined(CONFIG_USB_TUSB6010 ) || \ defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP34XX )static ushort __initdata fifo_mode =4 ;
@@ -1008,8 +1002,6 @@ module_param(fifo_mode, ushort, 0);MODULE_PARM_DESC (fifo_mode,"initial endpoint configuration" ); -#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2)) -enum fifo_style {FIFO_RXTX ,FIFO_TX ,FIFO_RX } __attribute__ ((packed));enum buf_mode {BUF_SINGLE ,BUF_DOUBLE } __attribute__ ((packed));
@@ -1119,11 +1111,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, c_size = size -3 ;if (cfg->mode ==BUF_DOUBLE ) { -if ((offset + (maxpacket <<1 )) >DYN_FIFO_SIZE ) +if ((offset + (maxpacket <<1 )) > + (1 << (musb->config->ram_bits +2 )))return -EMSGSIZE ; c_size |=MUSB_FIFOSZ_DPB ; }else { -if ((offset + maxpacket) >DYN_FIFO_SIZE ) +if ((offset + maxpacket) > (1 << (musb->config->ram_bits +2 )))return -EMSGSIZE ; }
@@ -1219,13 +1212,13 @@ static int __init ep_config_from_table(struct musb *musb)/* assert(offset > 0) */ /* NOTE: for RTL versions >= 1.400 EPINFO and RAMINFO would -* be better than static MUSB_C_NUM_EPS and DYN_FIFO_SIZE... +* be better than static musb->config->num_eps and DYN_FIFO_SIZE... */ for (i =0 ; i < n; i++) {u8 epn = cfg->hw_ep_num; -if (epn >=MUSB_C_NUM_EPS ) { +if (epn >= musb->config->num_eps) {pr_debug ("%s: invalid ep %d\n" , musb_driver_name, epn);continue ;
@@ -1242,8 +1235,8 @@ static int __init ep_config_from_table(struct musb *musb)printk (KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n" , musb_driver_name, - n +1 ,MUSB_C_NUM_EPS *2 -1 , - offset,DYN_FIFO_SIZE ); + n +1 , musb->config->num_eps *2 -1 , + offset, (1 << (musb->config->ram_bits +2 )));#ifdef CONFIG_USB_MUSB_HDRC_HCD if (!musb->bulk_ep) {
@@ -1270,7 +1263,7 @@ static int __init ep_config_from_hw(struct musb *musb)/* FIXME pick up ep0 maxpacket size */ -for (epnum =1 ; epnum <MUSB_C_NUM_EPS ; epnum++) { +for (epnum =1 ; epnum < musb->config->num_eps; epnum++) {musb_ep_select (mbase, epnum); hw_ep = musb->endpoints + epnum;
@@ -1424,14 +1417,14 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) musb->epmask =1 ;if (reg &MUSB_CONFIGDATA_DYNFIFO ) { -if (can_dynfifo ()) +if (musb->config->dyn_fifo) status =ep_config_from_table (musb);else {ERR ("reconfigure software for Dynamic FIFOs\n" ); status = -ENODEV ; } }else { -if (!can_dynfifo ()) +if (!musb->config->dyn_fifo) status =ep_config_from_hw (musb);else {ERR ("reconfigure software for static FIFOs\n" );
@@ -1788,7 +1781,8 @@ static void musb_irq_work(struct work_struct *data)*/ static struct musb *__init -allocate_instance (struct device *dev,void __iomem *mbase) +allocate_instance (struct device *dev, +struct musb_hdrc_config *config,void __iomem *mbase) {struct musb *musb;struct musb_hw_ep *ep;
@@ -1820,8 +1814,9 @@ allocate_instance(struct device *dev, void __iomem *mbase) musb->mregs = mbase; musb->ctrl_base = mbase; musb->nIrq = -ENODEV ; + musb->config = config;for (epnum =0 , ep = musb->endpoints; - epnum <MUSB_C_NUM_EPS ; + epnum < musb->config->num_eps; epnum++, ep++) { ep->musb = musb;
@@ -1929,7 +1924,7 @@ bad_config: }/* allocate */ - musb =allocate_instance (dev, ctrl); + musb =allocate_instance (dev, plat->config, ctrl);if (!musb)return -ENOMEM ;
@@ -1987,7 +1982,7 @@ bad_config:musb_generic_disable (musb);/* setup musb parts of the core (especially endpoints) */ - status =musb_core_init (plat->multipoint + status =musb_core_init (plat->config->multipoint ?MUSB_CONTROLLER_MHDRC :MUSB_CONTROLLER_HDRC , musb);if (status <0 )
drivers/usb/musb/musb_core.h +2 -12
@@ -56,18 +56,6 @@ struct musb_ep;#include "musb_debug.h" #include "musb_dma.h" -#ifdef CONFIG_USB_MUSB_SOC -/* -* Get core configuration from a header converted (by cfg_conv) -* from the Verilog config file generated by the core config utility -* -* For now we assume that header is provided along with other -* arch-specific files. Discrete chips will need a build tweak. -* So will using AHB IDs from silicon that provides them. -*/ -#include <asm/arch/hdrc_cnf.h> -#endif -#include "musb_io.h" #include "musb_regs.h"
@@ -440,6 +428,8 @@ struct musb {struct usb_gadget_driver *gadget_driver;/* its driver */ #endif +struct musb_hdrc_config *config; +#ifdef MUSB_CONFIG_PROC_FS struct proc_dir_entry *proc_entry;#endif
drivers/usb/musb/tusb6010.h +0 -169
173 lines not on this page · raw message
include/linux/usb/musb.h +33 -5
@@ -19,6 +19,36 @@ enum musb_mode {struct clk ; +struct musb_hdrc_eps_bits { +const char name[16 ]; +u8 bits; +}; + +struct musb_hdrc_config { +/* MUSB configuration-specific details */ +unsigned multipoint:1 ;/* multipoint device */ +unsigned dyn_fifo:1 ;/* supports dynamic fifo sizing */ +unsigned soft_con:1 ;/* soft connect required */ +unsigned utm_16:1 ;/* utm data witdh is 16 bits */ +unsigned big_endian:1 ;/* true if CPU uses big-endian */ +unsigned mult_bulk_tx:1 ;/* Tx ep required for multbulk pkts */ +unsigned mult_bulk_rx:1 ;/* Rx ep required for multbulk pkts */ +unsigned high_iso_tx:1 ;/* Tx ep required for HB iso */ +unsigned high_iso_rx:1 ;/* Rx ep required for HD iso */ +unsigned dma:1 ;/* supports DMA */ +unsigned vendor_req:1 ;/* vendor registers required */ + +u8 num_eps;/* number of endpoints _with_ ep0 */ +u8 dma_channels;/* number of dma channels */ +u8 dyn_fifo_size;/* dynamic size in bytes */ +u8 vendor_ctrl;/* vendor control reg width */ +u8 vendor_stat;/* vendor status reg witdh */ +u8 dma_req_chan;/* bitmask for required dma channels */ +u8 ram_bits;/* ram address size */ + +struct musb_hdrc_eps_bits *eps_bits; +}; +struct musb_hdrc_platform_data {/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */ u8 mode;
@@ -38,16 +68,14 @@ struct musb_hdrc_platform_data {/* (HOST or OTG) msec/2 after VBUS on till power good */ u8 potpgt; -/* TBD: chip defaults should probably go someplace else, -* e.g. number of tx/rx endpoints, etc -*/ - unsigned multipoint:1; -/* Power the device on or off */ int (*set_power)(int state);/* Turn device clock on or off */ int (*set_clock)(struct clk *clock,int is_on); + +/* MUSB configuration-specific details */ +struct musb_hdrc_config *config; };
Signature · 4 lines
1.6.0.rc1.71.gfba5 -- balbi
Paul Mundt
Acked-byQuoted 17 lines · Felipe Balbi
Quoted 1 line · Felipe Balbi
Quoted 1 line
other users. Why this driver isn't using ioread/writeXX_rep() is beyond
I'll try to fix io routines asap. From your next mail I could see that it's really bogus :-p
Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/musb_core.c: In function 'fifo_setup':drivers/usb/musb/musb_core.c:1122: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c:1122: error: (Each undeclared identifier is reported only oncedrivers/usb/musb/musb_core.c:1122: error: for each function it appears in.)drivers/usb/musb/musb_core.c: In function 'ep_config_from_table':drivers/usb/musb/musb_core.c:1246: error: 'MUSB_C_RAM_BITS' undeclared (first use in this function)drivers/usb/musb/musb_core.c: In function 'musb_remove':drivers/usb/musb/musb_core.c:2131: warning: unused variable 'ctrl_base'
make[1]: *** [drivers/usb/musb/musb_core.o] Error 1
make: *** [drivers/usb/musb/musb_core.o] Error 2
Quoted 5 lines
Below is the patch that fixes it.
I don't have sh cross-compilers, so if you could try it out and be sure it works, I'd be glad.
Yes, that fixes that problem at least, thanks.
Now the I/O bits are the only outstanding issue, as I still need the CONFIG_SUPERH test in musb_io.h to get around conflicting definitions.
Presently ARM and SH are the only ones that define the readsl() variants anyways, so stubbing in an extra ifdef there is fine as a temporary measure, but it's not a long-term solution. The only reason SH defines them at all is because we ran in to this exact same problem the last time an ARM driver tried passing itself off as generic ;-)
Quoted 10 lines
==== cut here ====
From
0bbc416e8170c4169608f7496b8d67be3828d76bMon Sep 17 00:00:00 2001
From: Felipe Balbi <[email protected]>
Date: Fri, 8 Aug 2008 11:39:41 +0300
Subject: [PATCH] usb: musb: pass configuration specifics via pdataUse
platform_datato pass musb configuration-specific details to musb driver.
Quoted 7 lines
This patch will prevent that other platforms selecting
HAVE_CLKand enabling musb won't break tree building.The other parts of it will come when linux-omap merge up more omap2/3 board-files.
Signed-off-by Felipe Balbi <[email protected]>
Quoted 1 line · ext Paul Mundt
Yes, that fixes that problem at least, thanks.
Cool :-)
Quoted 2 lines
Now the I/O bits are the only outstanding issue, as I still need the
CONFIG_SUPERHtest inmusb_io.hto get around conflicting definitions.
I think we're gonna need that for a while, can you send a proper patch changing that ifndef ??
Feel free to put my Acked-by: Felipe Balbi <[email protected]> if you wish.
Quoted 5 lines
Presently ARM and SH are the only ones that define the
readsl()variants anyways, so stubbing in an extra ifdef there is fine as a temporary measure, but it's not a long-term solution. The only reason SH defines them at all is because we ran in to this exact same problem the last time an ARM driver tried passing itself off as generic ;-)
eheh... But this actually is a generic driver, we're only missing a pci bus glue to use the musb chip on the opt cards, that would be really nice :-)
Signature · 1 line
balbi