* [PATCH 1/2 v2] musb: Add context save and restore support
@ 2009-11-26 6:39 Ajay Kumar Gupta
[not found] ` <1259217599-17793-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Ajay Kumar Gupta @ 2009-11-26 6:39 UTC (permalink / raw)
To: linux-usb; +Cc: linux-omap, felipe.balbi, Ajay Kumar Gupta, Anand Gadiyar
Adding support for MUSB register save and restore during system
suspend and resume.
Changes:
- Added musb_save/restore_context() functions
- Added platform specific musb_platform_save/restore_context()
to handle platform specific jobs.
- Maintaining BlackFin compatibility by adding read/write
functions for registers which are not available in BlackFin
Tested system suspend and resume on OMAP3EVM board.
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
---
Changes from previous version:
- Cleanups as Felipe suggested
- Removed save/restore of interrupt status registers
intr[r/t]x and intrusb
drivers/usb/musb/musb_core.c | 148 +++++++++++++++++++++++++++++++++++++++++-
drivers/usb/musb/musb_core.h | 39 +++++++++++
drivers/usb/musb/musb_regs.h | 90 +++++++++++++++++++++++++
drivers/usb/musb/omap2430.c | 16 +++++
4 files changed, 291 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 3a61ddb..0fd4105 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2167,21 +2167,163 @@ static int __devexit musb_remove(struct platform_device *pdev)
#ifdef CONFIG_PM
+static struct musb_context_registers musb_context;
+
+void musb_save_context(void __iomem *musb_base)
+{
+ int i;
+
+ musb_context.faddr = musb_readb(musb_base, MUSB_FADDR);
+ musb_context.power = musb_readb(musb_base, MUSB_POWER);
+ musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
+ musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE);
+ musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE);
+ musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
+ musb_context.index = musb_readb(musb_base, MUSB_INDEX);
+ musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
+ musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
+
+ for (i = 0; i < MUSB_C_NUM_EPS; ++i) {
+ musb_writeb(musb_base, MUSB_INDEX, i);
+ musb_context.index_regs[i].txmaxp =
+ musb_readw(musb_base, 0x10 + MUSB_TXMAXP);
+ musb_context.index_regs[i].txcsr =
+ musb_readw(musb_base, 0x10 + MUSB_TXCSR);
+ musb_context.index_regs[i].rxmaxp =
+ musb_readw(musb_base, 0x10 + MUSB_RXMAXP);
+ musb_context.index_regs[i].rxcsr =
+ musb_readw(musb_base, 0x10 + MUSB_RXCSR);
+ musb_context.index_regs[i].rxcount =
+ musb_readw(musb_base, 0x10 + MUSB_RXCOUNT);
+ musb_context.index_regs[i].txtype =
+ musb_readb(musb_base, 0x10 + MUSB_TXTYPE);
+ musb_context.index_regs[i].txinterval =
+ musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL);
+ musb_context.index_regs[i].rxtype =
+ musb_readb(musb_base, 0x10 + MUSB_RXTYPE);
+ musb_context.index_regs[i].rxinterval =
+ musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL);
+
+ musb_context.index_regs[i].txfifoadd =
+ musb_read_txfifoadd(musb_base);
+ musb_context.index_regs[i].rxfifoadd =
+ musb_read_rxfifoadd(musb_base);
+ musb_context.index_regs[i].txfifosz =
+ musb_read_txfifosz(musb_base);
+ musb_context.index_regs[i].rxfifosz =
+ musb_read_rxfifosz(musb_base);
+
+ musb_context.index_regs[i].txfunaddr =
+ musb_read_txfunaddr(musb_base, i);
+ musb_context.index_regs[i].txhubaddr =
+ musb_read_txhubaddr(musb_base, i);
+ musb_context.index_regs[i].txhubport =
+ musb_read_txhubport(musb_base, i);
+
+ musb_context.index_regs[i].rxfunaddr =
+ musb_read_rxfunaddr(musb_base, i);
+ musb_context.index_regs[i].rxhubaddr =
+ musb_read_rxhubaddr(musb_base, i);
+ musb_context.index_regs[i].rxhubport =
+ musb_read_rxhubport(musb_base, i);
+ }
+
+ musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
+
+ musb_platform_save_context(&musb_context);
+}
+
+void musb_restore_context(void __iomem *musb_base)
+{
+ int i;
+ void __iomem *ep_target_regs;
+
+ musb_platform_restore_context(&musb_context);
+
+ musb_writeb(musb_base, MUSB_FADDR, musb_context.faddr);
+ musb_writeb(musb_base, MUSB_POWER, musb_context.power);
+ musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe);
+ musb_writew(musb_base, MUSB_INTRRXE, musb_context.intrrxe);
+ musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe);
+ musb_writew(musb_base, MUSB_FRAME, musb_context.frame);
+ musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode);
+ musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl);
+
+ for (i = 0; i < MUSB_C_NUM_EPS; ++i) {
+ musb_writeb(musb_base, MUSB_INDEX, i);
+ musb_writew(musb_base, 0x10 + MUSB_TXMAXP,
+ musb_context.index_regs[i].txmaxp);
+ musb_writew(musb_base, 0x10 + MUSB_TXCSR,
+ musb_context.index_regs[i].txcsr);
+ musb_writew(musb_base, 0x10 + MUSB_RXMAXP,
+ musb_context.index_regs[i].rxmaxp);
+ musb_writew(musb_base, 0x10 + MUSB_RXCSR,
+ musb_context.index_regs[i].rxcsr);
+ musb_writew(musb_base, 0x10 + MUSB_RXCOUNT,
+ musb_context.index_regs[i].rxcount);
+ musb_writeb(musb_base, 0x10 + MUSB_TXTYPE,
+ musb_context.index_regs[i].txtype);
+ musb_writeb(musb_base, 0x10 + MUSB_TXINTERVAL,
+ musb_context.index_regs[i].txinterval);
+ musb_writeb(musb_base, 0x10 + MUSB_RXTYPE,
+ musb_context.index_regs[i].rxtype);
+ musb_writeb(musb_base, 0x10 + MUSB_RXINTERVAL,
+ musb_context.index_regs[i].rxinterval);
+
+ musb_write_txfifosz(musb_base,
+ musb_context.index_regs[i].txfifosz);
+ musb_write_rxfifosz(musb_base,
+ musb_context.index_regs[i].rxfifosz);
+ musb_write_txfifoadd(musb_base,
+ musb_context.index_regs[i].txfifoadd);
+ musb_write_rxfifoadd(musb_base,
+ musb_context.index_regs[i].rxfifoadd);
+
+ musb_write_txfunaddr(musb_base, i,
+ musb_context.index_regs[i].txfunaddr);
+ musb_write_txhubaddr(musb_base, i,
+ musb_context.index_regs[i].txhubaddr);
+ musb_write_txhubport(musb_base, i,
+ musb_context.index_regs[i].txhubport);
+
+ ep_target_regs = musb_read_target_reg_base(i, musb_base);
+
+ musb_write_rxfunaddr(ep_target_regs,
+ musb_context.index_regs[i].rxfunaddr);
+ musb_write_rxhubaddr(ep_target_regs,
+ musb_context.index_regs[i].rxhubaddr);
+ musb_write_rxhubport(ep_target_regs,
+ musb_context.index_regs[i].rxhubport);
+ }
+
+ musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
+}
+
static int musb_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
unsigned long flags;
struct musb *musb = dev_to_musb(&pdev->dev);
+ u8 reg;
if (!musb->clock)
return 0;
spin_lock_irqsave(&musb->lock, flags);
+ musb_save_context(musb->mregs);
+
if (is_peripheral_active(musb)) {
- /* FIXME force disconnect unless we know USB will wake
- * the system up quickly enough to respond ...
+ /* System is entering into suspend where gadget would not be
+ * able to respond to host and thus it will be in an unknown
+ * state for host.Re-enumemation of gadget is required after
+ * resume to make the gadget functional thus doing a force
+ * disconnect.
*/
+ reg = musb_readb(musb->mregs, MUSB_POWER);
+ reg &= ~MUSB_POWER_SOFTCONN;
+ musb_writeb(musb->mregs, MUSB_POWER, reg);
+
} else if (is_host_active(musb)) {
/* we know all the children are suspended; sometimes
* they will even be wakeup-enabled.
@@ -2209,6 +2351,8 @@ static int musb_resume_noirq(struct device *dev)
else
clk_enable(musb->clock);
+ musb_restore_context(musb->mregs);
+
/* for static cmos like DaVinci, register values were preserved
* unless for some reason the whole soc powered down or the USB
* module got reset through the PSC (vs just being disabled).
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 6aa5f22..0821d5a 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -453,6 +453,45 @@ struct musb {
#endif
};
+#ifdef CONFIG_PM
+struct musb_csr_regs {
+ /* FIFO registers */
+ u16 txmaxp, txcsr, rxmaxp, rxcsr, rxcount;
+ u16 rxfifoadd, txfifoadd;
+ u8 txtype, txinterval, rxtype, rxinterval;
+ u8 rxfifosz, txfifosz;
+ u8 txfunaddr, txhubaddr, txhubport;
+ u8 rxfunaddr, rxhubaddr, rxhubport;
+};
+
+struct musb_context_registers {
+
+#if defined(CONFIG_ARCH_OMAP34XX)
+ u32 otg_sysconfig, otg_forcestandby;
+#endif
+ u8 faddr, power;
+ u16 intrtxe, intrrxe;
+ u8 intrusbe;
+ u16 frame;
+ u8 index, testmode;
+
+ u8 devctl, misc;
+
+ struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
+};
+
+#if defined(CONFIG_ARCH_OMAP34XX) || defined(CONFIG_ARCH_OMAP2430)
+extern void musb_platform_save_context(struct musb_context_registers
+ *musb_context);
+extern void musb_platform_restore_context(struct musb_context_registers
+ *musb_context);
+#else
+#define musb_platform_save_context(x) do {} while (0)
+#define musb_platform_restore_context(x) do {} while (0)
+#endif
+
+#endif
+
static inline void musb_set_vbus(struct musb *musb, int is_on)
{
musb->board_set_vbus(musb, is_on);
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index cc1d71b..d4849d8 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -321,6 +321,26 @@ static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
musb_writew(mbase, MUSB_RXFIFOADD, c_off);
}
+static inline u8 musb_read_txfifosz(void __iomem *mbase)
+{
+ return musb_readb(mbase, MUSB_TXFIFOSZ);
+}
+
+static inline u16 musb_read_txfifoadd(void __iomem *mbase)
+{
+ return musb_readw(mbase, MUSB_TXFIFOADD);
+}
+
+static inline u8 musb_read_rxfifosz(void __iomem *mbase)
+{
+ return musb_readb(mbase, MUSB_RXFIFOSZ);
+}
+
+static inline u16 musb_read_rxfifoadd(void __iomem *mbase)
+{
+ return musb_readw(mbase, MUSB_RXFIFOADD);
+}
+
static inline u8 musb_read_configdata(void __iomem *mbase)
{
musb_writeb(mbase, MUSB_INDEX, 0);
@@ -376,6 +396,36 @@ static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
qh_h_port_reg);
}
+static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXFUNCADDR));
+}
+
+static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXHUBADDR));
+}
+
+static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_RXHUBPORT));
+}
+
+static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXFUNCADDR));
+}
+
+static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBADDR));
+}
+
+static inline u8 musb_read_txhubport(void __iomem *mbase, u8 epnum)
+{
+ return musb_readb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT));
+}
+
#else /* CONFIG_BLACKFIN */
#define USB_BASE USB_FADDR
@@ -455,6 +505,22 @@ static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
{
}
+static inline u8 musb_read_txfifosz(void __iomem *mbase)
+{
+}
+
+static inline u16 musb_read_txfifoadd(void __iomem *mbase)
+{
+}
+
+static inline u8 musb_read_rxfifosz(void __iomem *mbase)
+{
+}
+
+static inline u16 musb_read_rxfifoadd(void __iomem *mbase)
+{
+}
+
static inline u8 musb_read_configdata(void __iomem *mbase)
{
return 0;
@@ -500,6 +566,30 @@ static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
{
}
+static inline u8 musb_read_rxfunaddr(void __iomem *mbase, u8 epnum)
+{
+}
+
+static inline u8 musb_read_rxhubaddr(void __iomem *mbase, u8 epnum)
+{
+}
+
+static inline u8 musb_read_rxhubport(void __iomem *mbase, u8 epnum)
+{
+}
+
+static inline u8 musb_read_txfunaddr(void __iomem *mbase, u8 epnum)
+{
+}
+
+static inline u8 musb_read_txhubaddr(void __iomem *mbase, u8 epnum)
+{
+}
+
+static inline void musb_read_txhubport(void __iomem *mbase, u8 epnum)
+{
+}
+
#endif /* CONFIG_BLACKFIN */
#endif /* __MUSB_REGS_H__ */
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 3487520..84af3b3 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -255,6 +255,22 @@ int __init musb_platform_init(struct musb *musb)
return 0;
}
+#ifdef CONFIG_PM
+void musb_platform_save_context(struct musb_context_registers
+ *musb_context)
+{
+ musb_context->otg_sysconfig = omap_readl(OTG_SYSCONFIG);
+ musb_context->otg_forcestandby = omap_readl(OTG_FORCESTDBY);
+}
+
+void musb_platform_restore_context(struct musb_context_registers
+ *musb_context)
+{
+ omap_writel(musb_context->otg_sysconfig, OTG_SYSCONFIG);
+ omap_writel(musb_context->otg_forcestandby, OTG_FORCESTDBY);
+}
+#endif
+
int musb_platform_suspend(struct musb *musb)
{
u32 l;
--
1.6.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2 v2] musb: Add context save and restore support
[not found] ` <1259217599-17793-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
@ 2009-11-26 9:03 ` Romit Dasgupta
2009-11-26 10:03 ` Gupta, Ajay Kumar
2009-12-03 11:04 ` Felipe Balbi
1 sibling, 1 reply; 6+ messages in thread
From: Romit Dasgupta @ 2009-11-26 9:03 UTC (permalink / raw)
To: Gupta, Ajay Kumar
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org,
Gadiyar, Anand
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2167,21 +2167,163 @@ static int __devexit musb_remove(struct platform_device *pdev)
>
> #ifdef CONFIG_PM
>
> +static struct musb_context_registers musb_context;
> +
> +void musb_save_context(void __iomem *musb_base)
> +{
> + int i;
> +
> + musb_context.faddr = musb_readb(musb_base, MUSB_FADDR);
> + musb_context.power = musb_readb(musb_base, MUSB_POWER);
> + musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
> + musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE);
> + musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE);
> + musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
Not necessary for gadget
> + musb_context.index = musb_readb(musb_base, MUSB_INDEX);
> + musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
Not sure if it is necessary for gadget.
> + musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
> +
> + for (i = 0; i < MUSB_C_NUM_EPS; ++i) {
> + musb_writeb(musb_base, MUSB_INDEX, i);
> + musb_context.index_regs[i].txmaxp =
> + musb_readw(musb_base, 0x10 + MUSB_TXMAXP);
> + musb_context.index_regs[i].txcsr =
> + musb_readw(musb_base, 0x10 + MUSB_TXCSR);
> + musb_context.index_regs[i].rxmaxp =
> + musb_readw(musb_base, 0x10 + MUSB_RXMAXP);
> + musb_context.index_regs[i].rxcsr =
> + musb_readw(musb_base, 0x10 + MUSB_RXCSR);
> + musb_context.index_regs[i].rxcount =
> + musb_readw(musb_base, 0x10 + MUSB_RXCOUNT);
> + musb_context.index_regs[i].txtype =
> + musb_readb(musb_base, 0x10 + MUSB_TXTYPE);
> + musb_context.index_regs[i].txinterval =
> + musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL);
> + musb_context.index_regs[i].rxtype =
> + musb_readb(musb_base, 0x10 + MUSB_RXTYPE);
> + musb_context.index_regs[i].rxinterval =
> + musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL);
> +
> + musb_context.index_regs[i].txfifoadd =
> + musb_read_txfifoadd(musb_base);
> + musb_context.index_regs[i].rxfifoadd =
> + musb_read_rxfifoadd(musb_base);
> + musb_context.index_regs[i].txfifosz =
> + musb_read_txfifosz(musb_base);
> + musb_context.index_regs[i].rxfifosz =
> + musb_read_rxfifosz(musb_base);
If MUSB_CONFIGDATA_DYNFIFO is not set then saving FIFO address and sizes are
probably not necessary. Not sure if they are detrimental as well.
> +
> + musb_context.index_regs[i].txfunaddr =
> + musb_read_txfunaddr(musb_base, i);
> + musb_context.index_regs[i].txhubaddr =
> + musb_read_txhubaddr(musb_base, i);
> + musb_context.index_regs[i].txhubport =
> + musb_read_txhubport(musb_base, i);
> +
> + musb_context.index_regs[i].rxfunaddr =
> + musb_read_rxfunaddr(musb_base, i);
> + musb_context.index_regs[i].rxhubaddr =
> + musb_read_rxhubaddr(musb_base, i);
> + musb_context.index_regs[i].rxhubport =
> + musb_read_rxhubport(musb_base, i);
> + }
If we are in gadget mode, do we have to save this?
> +
> + musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
> +
> + musb_platform_save_context(&musb_context);
> +}
Similar for restore.
> static int musb_suspend(struct device *dev)
> {
> struct platform_device *pdev = to_platform_device(dev);
> unsigned long flags;
> struct musb *musb = dev_to_musb(&pdev->dev);
> + u8 reg;
>
> if (!musb->clock)
> return 0;
>
> spin_lock_irqsave(&musb->lock, flags);
>
> + musb_save_context(musb->mregs);
> +
> if (is_peripheral_active(musb)) {
> - /* FIXME force disconnect unless we know USB will wake
> - * the system up quickly enough to respond ...
> + /* System is entering into suspend where gadget would not be
> + * able to respond to host and thus it will be in an unknown
> + * state for host.Re-enumemation of gadget is required after
> + * resume to make the gadget functional thus doing a force
> + * disconnect.
> */
> + reg = musb_readb(musb->mregs, MUSB_POWER);
> + reg &= ~MUSB_POWER_SOFTCONN;
> + musb_writeb(musb->mregs, MUSB_POWER, reg);
After this softdisconnect when we subsequently get reconnected followed by a
reset we could have changed our speed (LS,FS, HS). In your resume routine we are
writing back our previous speed. I am not sure here but is it not possible that
we have reset the controller and then restored back the old speed overwriting
the new speed?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 1/2 v2] musb: Add context save and restore support
2009-11-26 9:03 ` Romit Dasgupta
@ 2009-11-26 10:03 ` Gupta, Ajay Kumar
[not found] ` <19F8576C6E063C45BE387C64729E739404370D7BF1-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Gupta, Ajay Kumar @ 2009-11-26 10:03 UTC (permalink / raw)
To: Dasgupta, Romit
Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
felipe.balbi@nokia.com, Gadiyar, Anand
Hi,
> -----Original Message-----
> From: Dasgupta, Romit
> Sent: Thursday, November 26, 2009 2:33 PM
> To: Gupta, Ajay Kumar
> Cc: linux-usb@vger.kernel.org; linux-omap@vger.kernel.org;
> felipe.balbi@nokia.com; Gadiyar, Anand
> Subject: Re: [PATCH 1/2 v2] musb: Add context save and restore support
>
> > --- a/drivers/usb/musb/musb_core.c
> > +++ b/drivers/usb/musb/musb_core.c
> > @@ -2167,21 +2167,163 @@ static int __devexit musb_remove(struct
> platform_device *pdev)
> >
> > #ifdef CONFIG_PM
> >
> > +static struct musb_context_registers musb_context;
> > +
> > +void musb_save_context(void __iomem *musb_base)
> > +{
> > + int i;
> > +
> > + musb_context.faddr = musb_readb(musb_base, MUSB_FADDR);
> > + musb_context.power = musb_readb(musb_base, MUSB_POWER);
> > + musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
> > + musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE);
> > + musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE);
> > + musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
> Not necessary for gadget
> > + musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
> Not sure if it is necessary for gadget.
Right!
..so we can all #ifdefs to save/restore gadget or host only registers.
> > + musb_context.index = musb_readb(musb_base, MUSB_INDEX);
>
>
<snip>
> > + musb_read_txfifosz(musb_base);
> > + musb_context.index_regs[i].rxfifosz =
> > + musb_read_rxfifosz(musb_base);
>
> If MUSB_CONFIGDATA_DYNFIFO is not set then saving FIFO address and sizes
> are probably not necessary. Not sure if they are detrimental as well.
We can add it within DYNFIFO check.
> > +
> > + musb_context.index_regs[i].txfunaddr =
> > + musb_read_txfunaddr(musb_base, i);
> > + musb_context.index_regs[i].txhubaddr =
<snip.>
> > */
> > + reg = musb_readb(musb->mregs, MUSB_POWER);
> > + reg &= ~MUSB_POWER_SOFTCONN;
> > + musb_writeb(musb->mregs, MUSB_POWER, reg);
> After this softdisconnect when we subsequently get reconnected followed by
> a reset we could have changed our speed (LS,FS, HS).
I didn't get it completely. I think as a peripheral USB speed will remain
same after resume for the gadget driver it was before suspend?
If we intend to change the gadget driver then we may have support for a
different speed but it would anyways happen after resume is completed.
Regards,
Ajay
> In your resume
> routine we are writing back our previous speed. I am not sure here but is
> it not possible that we have reset the controller and then restored back
> the old speed overwriting the new speed?
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 1/2 v2] musb: Add context save and restore support
[not found] ` <19F8576C6E063C45BE387C64729E739404370D7BF1-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
@ 2009-11-26 10:27 ` Gadiyar, Anand
0 siblings, 0 replies; 6+ messages in thread
From: Gadiyar, Anand @ 2009-11-26 10:27 UTC (permalink / raw)
To: Gupta, Ajay Kumar, Dasgupta, Romit
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org
> <snip.>
>
> > > */
> > > + reg = musb_readb(musb->mregs, MUSB_POWER);
> > > + reg &= ~MUSB_POWER_SOFTCONN;
> > > + musb_writeb(musb->mregs, MUSB_POWER, reg);
> > After this softdisconnect when we subsequently get reconnected followed by
> > a reset we could have changed our speed (LS,FS, HS).
>
> I didn't get it completely. I think as a peripheral USB speed will remain
> same after resume for the gadget driver it was before suspend?
>
> If we intend to change the gadget driver then we may have support for a
> different speed but it would anyways happen after resume is completed.
>
The host side might change, but that shouldn't affect us. This bit is
used to tell MUSB (acting as a peripheral) if it should attempt
to enumerate at HS or not - it will always fall back to FS if the host
does not support it.
So Ajay is correct in restoring this register.
- Anand
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2 v2] musb: Add context save and restore support
[not found] ` <1259217599-17793-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2009-11-26 9:03 ` Romit Dasgupta
@ 2009-12-03 11:04 ` Felipe Balbi
1 sibling, 0 replies; 6+ messages in thread
From: Felipe Balbi @ 2009-12-03 11:04 UTC (permalink / raw)
To: ext Ajay Kumar Gupta
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Balbi Felipe (Nokia-D/Helsinki), Anand Gadiyar
Hi,
On Thu, Nov 26, 2009 at 07:39:59AM +0100, ext Ajay Kumar Gupta wrote:
>Adding support for MUSB register save and restore during system
>suspend and resume.
>
>Changes:
> - Added musb_save/restore_context() functions
> - Added platform specific musb_platform_save/restore_context()
> to handle platform specific jobs.
> - Maintaining BlackFin compatibility by adding read/write
> functions for registers which are not available in BlackFin
>
>Tested system suspend and resume on OMAP3EVM board.
>
>Signed-off-by: Anand Gadiyar <gadiyar-l0cyMroinI0@public.gmane.org>
>Signed-off-by: Ajay Kumar Gupta <ajay.gupta-l0cyMroinI0@public.gmane.org>
will we have another version of this patch ??
--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2 v2] musb: Add context save and restore support
@ 2009-12-14 7:19 Gupta, Ajay Kumar
0 siblings, 0 replies; 6+ messages in thread
From: Gupta, Ajay Kumar @ 2009-12-14 7:19 UTC (permalink / raw)
To: linux-usb@vger.kernel.org
Cc: linux-omap@vger.kernel.org, felipe.balbi@nokia.com
>Adding support for MUSB register save and restore during system
>suspend and resume.
>
>Changes:
> - Added musb_save/restore_context() functions
> - Added platform specific musb_platform_save/restore_context()
> to handle platform specific jobs.
> - Maintaining BlackFin compatibility by adding read/write
> functions for registers which are not available in BlackFin
>
>Tested system suspend and resume on OMAP3EVM board.
>
>Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
>Signed-off-by: Ajay Kumar Gupta <ajay.gupta@ti.com>
> will we have another version of this patch ??
Yes, I need to resubmit this patch after fixing review comments.
-Ajay
--
balbi
--
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-14 7:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-26 6:39 [PATCH 1/2 v2] musb: Add context save and restore support Ajay Kumar Gupta
[not found] ` <1259217599-17793-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org>
2009-11-26 9:03 ` Romit Dasgupta
2009-11-26 10:03 ` Gupta, Ajay Kumar
[not found] ` <19F8576C6E063C45BE387C64729E739404370D7BF1-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-11-26 10:27 ` Gadiyar, Anand
2009-12-03 11:04 ` Felipe Balbi
-- strict thread matches above, loose matches on Subject: below --
2009-12-14 7:19 Gupta, Ajay Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox