Re: [PATCH 02/28] usb: musb: export some symbols for glue driver access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 13, 2010 at 11:02:42AM +0200, Felipe Balbi wrote:
On Mon, Dec 13, 2010 at 10:10:39AM +0200, Felipe Balbi wrote:
On Mon, Dec 13, 2010 at 01:01:36AM +0800, tom.leiming@xxxxxxxxx wrote:
From: Ming Lei <tom.leiming@xxxxxxxxx>

Export this functions so that glue drivers can see them if glue drivers
are built as modules.

Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx>
---
drivers/usb/musb/musb_core.c |    7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2bbf911..070725f 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -116,6 +116,7 @@


unsigned musb_debug;
+EXPORT_SYMBOL(musb_debug);

change all these to EXPORT_SYMBOL_GPL() is glue layer isn't GPL we don't
want it.

BTW, changing all DBG() to dev_dbg() on hw glue layer already kills most
of the complaints. I think it's better to say musb-omap2430 than
musb-hdrc on debug messages comming for omap2430.c as it's a better hint
of where the problem is.

otg_state_string() will be generalized soon with a patchset that's been
sent already, so most of the problems are killed.

I'm also not sure we want to build glue layer as module, it's just a
glue layer anyway, and instead of users just modprobe musb_hdrc they'll
have to modprobe musb-omap2430 && modprobe musb_hdrc, on that order
otherwise it doesn't work. So keep glue layer as bool, and the same
"behavior" is kept. That means a simple change to drivers/Makefile would
be enough. Something like:

diff --git a/drivers/Makefile b/drivers/Makefile
index 14cf907..9c66677 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -65,7 +65,7 @@ obj-$(CONFIG_TC)              += tc/
obj-$(CONFIG_UWB)              += uwb/
obj-$(CONFIG_USB_OTG_UTILS)    += usb/otg/
obj-$(CONFIG_USB)              += usb/
-obj-$(CONFIG_USB_MUSB_HDRC)    += usb/musb/
+obj-$(CONFIG_USB_MUSB)         += usb/musb/
obj-$(CONFIG_PCI)              += usb/
obj-$(CONFIG_USB_GADGET)       += usb/gadget/
obj-$(CONFIG_SERIO)            += input/serio/
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 4cbb7e4..98c0dc9 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -6,6 +6,9 @@
comment "Enable Host or Gadget support to see Inventra options"
       depends on !USB && USB_GADGET=n
+config USB_MUSB
+       bool
+
# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
config USB_MUSB_HDRC
       depends on (USB || USB_GADGET)
@@ -14,6 +17,7 @@ config USB_MUSB_HDRC
       select TWL4030_USB if MACH_OMAP_3430SDP
       select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA
       select USB_OTG_UTILS
+       select USB_MUSB
       tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
       help
         Say Y here if your system has a dual role high speed USB

of course, this also needs the changes to exported symbols. But also a
bit trivial.

not so trivial wrt IRQ, but maybe something like below will work for all
cases?

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index d5a3da3..e69c233 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -219,19 +219,15 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
 	mod_timer(&otg_workaround, timeout);
 }
-static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
+static int am35x_musb_interrupt(struct musb *musb)
 {
-	struct musb  *musb = hci;
 	void __iomem *reg_base = musb->ctrl_base;
 	struct device *dev = musb->controller;
 	struct musb_hdrc_platform_data *plat = dev->platform_data;
 	struct omap_musb_board_data *data = plat->board_data;
-	unsigned long flags;
 	irqreturn_t ret = IRQ_NONE;
 	u32 epintr, usbintr;
- spin_lock_irqsave(&musb->lock, flags);
-
 	/* Get endpoint interrupts */
 	epintr = musb_readl(reg_base, EP_INTR_SRC_MASKED_REG);
@@ -255,6 +251,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
 		musb->int_usb =
 			(usbintr & AM35X_INTR_USB_MASK) >> AM35X_INTR_USB_SHIFT;
 	}
+
 	/*
 	 * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
 	 * AM35x's missing ID change IRQ.  We need an ID change IRQ to
@@ -310,9 +307,6 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
 		ret = IRQ_HANDLED;
 	}
- if (musb->int_tx || musb->int_rx || musb->int_usb)
-		ret |= musb_interrupt(musb);
-
 eoi:
 	/* EOI needs to be written for the IRQ to be re-asserted. */
 	if (ret == IRQ_HANDLED || epintr || usbintr) {
@@ -327,8 +321,6 @@ eoi:
 	if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
 		mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
- spin_unlock_irqrestore(&musb->lock, flags);
-
 	return ret;
 }
@@ -383,8 +375,6 @@ static int am35x_musb_init(struct musb *musb) msleep(5); - musb->isr = am35x_musb_interrupt;
-
 	/* clear level interrupt */
 	if (data->clear_irq)
 		data->clear_irq();
@@ -452,6 +442,8 @@ static const struct musb_platform_ops am35x_ops = {
 	.try_idle	= am35x_musb_try_idle,
.set_vbus = am35x_musb_set_vbus,
+
+	.irq		= am35x_musb_interrupt,
 };
static u64 am35x_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 7816c01..64203d7 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1529,9 +1529,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
/*-------------------------------------------------------------------------*/ -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) || \
-	defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500) || \
-	defined(CONFIG_ARCH_U5500)
+static irqreturn_t musb_interrupt(struct musb *musb);
static irqreturn_t generic_interrupt(int irq, void *__hci)
 {
@@ -1541,22 +1539,18 @@ static irqreturn_t generic_interrupt(int irq, void *__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);
+	if (musb_platform_irq(musb) < 0)
+		goto out;
if (musb->int_usb || musb->int_tx || musb->int_rx)
 		retval = musb_interrupt(musb);
+out:
 	spin_unlock_irqrestore(&musb->lock, flags);
return retval;
 }
-#else
-#define generic_interrupt	NULL
-#endif
-
 /*
  * handle all the irqs defined by the HDRC core. for now we expect:  other
  * irq sources (phy, dma, etc) will be handled first, musb->int_* values
@@ -1564,7 +1558,7 @@ static irqreturn_t generic_interrupt(int irq, void *__hci)
  *
  * called in irq context with spinlock held, irqs blocked
  */
-irqreturn_t musb_interrupt(struct musb *musb)
+static irqreturn_t musb_interrupt(struct musb *musb)
 {
 	irqreturn_t	retval = IRQ_NONE;
 	u8		devctl, power;
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index d0c236f..649a359 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -274,6 +274,8 @@ struct musb_platform_ops {
int (*vbus_status)(struct musb *musb);
 	void	(*set_vbus)(struct musb *musb, int on);
+
+	int	(*irq)(struct musb *musb);
 };
/*
@@ -590,8 +592,6 @@ extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst);
extern void musb_load_testpacket(struct musb *); -extern irqreturn_t musb_interrupt(struct musb *);
-
 extern void musb_hnp_stop(struct musb *musb);
static inline void musb_platform_set_vbus(struct musb *musb, int is_on)
@@ -651,4 +651,15 @@ static inline int musb_platform_exit(struct musb *musb)
 	return musb->ops->exit(musb);
 }
+static inline int musb_platform_irq(struct musb *musb)
+{
+	if (!musb->ops->irq) {
+		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);
+	}
+
+	return musb->ops->irq(musb);
+}
+
 #endif	/* __MUSB_CORE_H__ */

this isn't finished, clearly, but it would also allow for dropping
musb->irq field and combine generic_interrupt() into musb_interrupt()

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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux