Skip to content

Commit 65b3f50

Browse files
tmlindgregkh
authored andcommitted
usb: musb: Add PM runtime support for MUSB DSPS glue layer
We can now just use PM runtime autoidle support as musb core keeps things enabled when the devctl session bit is set. And there's no need for dsps_musb_try_idle() so let's just remove it. Note that as cppi41 dma is clocked by musb, this only makes PM work for dsps glue layer if CONFIG_MUSB_PIO_ONLY=y and cppi41.ko is unloaded. This will get fixed when cppi41.c has PM runtime implemented. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ae909fe commit 65b3f50

File tree

1 file changed

+17
-41
lines changed

1 file changed

+17
-41
lines changed

drivers/usb/musb/musb_dsps.c

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -145,43 +145,6 @@ static const struct debugfs_reg32 dsps_musb_regs[] = {
145145
{ "mode", 0xe8 },
146146
};
147147

148-
static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
149-
{
150-
struct device *dev = musb->controller;
151-
struct dsps_glue *glue = dev_get_drvdata(dev->parent);
152-
153-
if (timeout == 0)
154-
timeout = jiffies + msecs_to_jiffies(3);
155-
156-
/* Never idle if active, or when VBUS timeout is not set as host */
157-
if (musb->is_active || (musb->a_wait_bcon == 0 &&
158-
musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
159-
dev_dbg(musb->controller, "%s active, deleting timer\n",
160-
usb_otg_state_string(musb->xceiv->otg->state));
161-
del_timer(&glue->timer);
162-
glue->last_timer = jiffies;
163-
return;
164-
}
165-
if (musb->port_mode != MUSB_PORT_MODE_DUAL_ROLE)
166-
return;
167-
168-
if (!musb->g.dev.driver)
169-
return;
170-
171-
if (time_after(glue->last_timer, timeout) &&
172-
timer_pending(&glue->timer)) {
173-
dev_dbg(musb->controller,
174-
"Longer idle timer already pending, ignoring...\n");
175-
return;
176-
}
177-
glue->last_timer = timeout;
178-
179-
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
180-
usb_otg_state_string(musb->xceiv->otg->state),
181-
jiffies_to_msecs(timeout - jiffies));
182-
mod_timer(&glue->timer, timeout);
183-
}
184-
185148
/**
186149
* dsps_musb_enable - enable interrupts
187150
*/
@@ -206,7 +169,6 @@ static void dsps_musb_enable(struct musb *musb)
206169
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
207170
mod_timer(&glue->timer, jiffies +
208171
msecs_to_jiffies(wrp->poll_timeout));
209-
dsps_musb_try_idle(musb, 0);
210172
}
211173

212174
/**
@@ -236,6 +198,11 @@ static void otg_timer(unsigned long _musb)
236198
u8 devctl;
237199
unsigned long flags;
238200
int skip_session = 0;
201+
int err;
202+
203+
err = pm_runtime_get_sync(dev);
204+
if (err < 0)
205+
dev_err(dev, "Poll could not pm_runtime_get: %i\n", err);
239206

240207
/*
241208
* We poll because DSPS IP's won't expose several OTG-critical
@@ -279,6 +246,9 @@ static void otg_timer(unsigned long _musb)
279246
break;
280247
}
281248
spin_unlock_irqrestore(&musb->lock, flags);
249+
250+
pm_runtime_mark_last_busy(dev);
251+
pm_runtime_put_autosuspend(dev);
282252
}
283253

284254
static irqreturn_t dsps_interrupt(int irq, void *hci)
@@ -634,7 +604,6 @@ static struct musb_platform_ops dsps_ops = {
634604
.enable = dsps_musb_enable,
635605
.disable = dsps_musb_disable,
636606

637-
.try_idle = dsps_musb_try_idle,
638607
.set_mode = dsps_musb_set_mode,
639608
.recover = dsps_musb_recover,
640609
};
@@ -798,6 +767,8 @@ static int dsps_probe(struct platform_device *pdev)
798767

799768
platform_set_drvdata(pdev, glue);
800769
pm_runtime_enable(&pdev->dev);
770+
pm_runtime_use_autosuspend(&pdev->dev);
771+
pm_runtime_set_autosuspend_delay(&pdev->dev, 200);
801772

802773
ret = pm_runtime_get_sync(&pdev->dev);
803774
if (ret < 0) {
@@ -809,11 +780,15 @@ static int dsps_probe(struct platform_device *pdev)
809780
if (ret)
810781
goto err3;
811782

783+
pm_runtime_mark_last_busy(&pdev->dev);
784+
pm_runtime_put_autosuspend(&pdev->dev);
785+
812786
return 0;
813787

814788
err3:
815-
pm_runtime_put(&pdev->dev);
789+
pm_runtime_put_sync(&pdev->dev);
816790
err2:
791+
pm_runtime_dont_use_autosuspend(&pdev->dev);
817792
pm_runtime_disable(&pdev->dev);
818793
return ret;
819794
}
@@ -825,7 +800,8 @@ static int dsps_remove(struct platform_device *pdev)
825800
platform_device_unregister(glue->musb);
826801

827802
/* disable usbss clocks */
828-
pm_runtime_put(&pdev->dev);
803+
pm_runtime_dont_use_autosuspend(&pdev->dev);
804+
pm_runtime_put_sync(&pdev->dev);
829805
pm_runtime_disable(&pdev->dev);
830806

831807
return 0;

0 commit comments

Comments
 (0)