aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-11-24 06:06:47 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 12:59:58 -0500
commit96a274d1da950a96cb31ac1bed044e049d770980 (patch)
tree6069c17f492e3bfbc75d59b3d6d47a81bf7ae7d6 /drivers/usb/musb
parentaa69a8093ff985873cb44fe1157bd6db29a20fe4 (diff)
USB: musb: sysfs mode updates
Fix three omissions in the "mode" sysfs attribute support: (a) inability to report errors; (b) no DaVinci support ... just report an error; (c) for omap2430, accepting unsupportable values The 2430 stuff is still odd.... Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/davinci.c6
-rw-r--r--drivers/usb/musb/musb_core.c17
-rw-r--r--drivers/usb/musb/musb_core.h2
-rw-r--r--drivers/usb/musb/omap2430.c11
-rw-r--r--drivers/usb/musb/tusb6010.c7
5 files changed, 32 insertions, 11 deletions
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index dfb3bcbe00fc..87aef82fbcd0 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -364,6 +364,12 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
364 return IRQ_HANDLED; 364 return IRQ_HANDLED;
365} 365}
366 366
367int musb_platform_set_mode(struct musb *musb, u8 mode)
368{
369 /* EVM can't do this (right?) */
370 return -EIO;
371}
372
367int __init musb_platform_init(struct musb *musb) 373int __init musb_platform_init(struct musb *musb)
368{ 374{
369 void __iomem *tibase = musb->ctrl_base; 375 void __iomem *tibase = musb->ctrl_base;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0b742ebe5c8c..de7f8bec6bde 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1671,17 +1671,20 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
1671{ 1671{
1672 struct musb *musb = dev_to_musb(dev); 1672 struct musb *musb = dev_to_musb(dev);
1673 unsigned long flags; 1673 unsigned long flags;
1674 int status;
1674 1675
1675 spin_lock_irqsave(&musb->lock, flags); 1676 spin_lock_irqsave(&musb->lock, flags);
1676 if (!strncmp(buf, "host", 4)) 1677 if (sysfs_streq(buf, "host"))
1677 musb_platform_set_mode(musb, MUSB_HOST); 1678 status = musb_platform_set_mode(musb, MUSB_HOST);
1678 if (!strncmp(buf, "peripheral", 10)) 1679 else if (sysfs_streq(buf, "peripheral"))
1679 musb_platform_set_mode(musb, MUSB_PERIPHERAL); 1680 status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
1680 if (!strncmp(buf, "otg", 3)) 1681 else if (sysfs_streq(buf, "otg"))
1681 musb_platform_set_mode(musb, MUSB_OTG); 1682 status = musb_platform_set_mode(musb, MUSB_OTG);
1683 else
1684 status = -EINVAL;
1682 spin_unlock_irqrestore(&musb->lock, flags); 1685 spin_unlock_irqrestore(&musb->lock, flags);
1683 1686
1684 return n; 1687 return (status == 0) ? n : status;
1685} 1688}
1686static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store); 1689static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
1687 1690
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 82227251931b..b3d605073071 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -467,7 +467,7 @@ extern void musb_platform_disable(struct musb *musb);
467 467
468extern void musb_hnp_stop(struct musb *musb); 468extern void musb_hnp_stop(struct musb *musb);
469 469
470extern void musb_platform_set_mode(struct musb *musb, u8 musb_mode); 470extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
471 471
472#if defined(CONFIG_USB_TUSB6010) || \ 472#if defined(CONFIG_USB_TUSB6010) || \
473 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 473 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index ce6c162920f7..52988a403b5c 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -196,7 +196,7 @@ static int omap_set_power(struct otg_transceiver *x, unsigned mA)
196 196
197static int musb_platform_resume(struct musb *musb); 197static int musb_platform_resume(struct musb *musb);
198 198
199void musb_platform_set_mode(struct musb *musb, u8 musb_mode) 199int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
200{ 200{
201 u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 201 u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
202 202
@@ -204,15 +204,24 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
204 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); 204 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
205 205
206 switch (musb_mode) { 206 switch (musb_mode) {
207#ifdef CONFIG_USB_MUSB_HDRC_HCD
207 case MUSB_HOST: 208 case MUSB_HOST:
208 otg_set_host(&musb->xceiv, musb->xceiv.host); 209 otg_set_host(&musb->xceiv, musb->xceiv.host);
209 break; 210 break;
211#endif
212#ifdef CONFIG_USB_GADGET_MUSB_HDRC
210 case MUSB_PERIPHERAL: 213 case MUSB_PERIPHERAL:
211 otg_set_peripheral(&musb->xceiv, musb->xceiv.gadget); 214 otg_set_peripheral(&musb->xceiv, musb->xceiv.gadget);
212 break; 215 break;
216#endif
217#ifdef CONFIG_USB_MUSB_OTG
213 case MUSB_OTG: 218 case MUSB_OTG:
214 break; 219 break;
220#endif
221 default:
222 return -EINVAL;
215 } 223 }
224 return 0;
216} 225}
217 226
218int __init musb_platform_init(struct musb *musb) 227int __init musb_platform_init(struct musb *musb)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ee8fca92a4ac..9e20fd070d71 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -598,7 +598,7 @@ static void tusb_source_power(struct musb *musb, int is_on)
598 * and peripheral modes in non-OTG configurations by reconfiguring hardware 598 * and peripheral modes in non-OTG configurations by reconfiguring hardware
599 * and then setting musb->board_mode. For now, only support OTG mode. 599 * and then setting musb->board_mode. For now, only support OTG mode.
600 */ 600 */
601void musb_platform_set_mode(struct musb *musb, u8 musb_mode) 601int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
602{ 602{
603 void __iomem *tbase = musb->ctrl_base; 603 void __iomem *tbase = musb->ctrl_base;
604 u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; 604 u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf;
@@ -641,7 +641,8 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
641#endif 641#endif
642 642
643 default: 643 default:
644 DBG(2, "Trying to set unknown mode %i\n", musb_mode); 644 DBG(2, "Trying to set mode %i\n", musb_mode);
645 return -EINVAL;
645 } 646 }
646 647
647 musb_writel(tbase, TUSB_PHY_OTG_CTRL, 648 musb_writel(tbase, TUSB_PHY_OTG_CTRL,
@@ -655,6 +656,8 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
655 !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) 656 !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS))
656 INFO("Cannot be peripheral with mini-A cable " 657 INFO("Cannot be peripheral with mini-A cable "
657 "otg_stat: %08x\n", otg_stat); 658 "otg_stat: %08x\n", otg_stat);
659
660 return 0;
658} 661}
659 662
660static inline unsigned long 663static inline unsigned long