* [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled
2014-08-27 23:28 [PATCH 0/5] Clean-up for twl4030-usb Tony Lindgren
@ 2014-08-27 23:28 ` Tony Lindgren
2014-08-28 2:20 ` Felipe Balbi
2014-08-27 23:28 ` [PATCH 2/5] usb: phy: twl4030-usb: Simplify phy init to use runtime PM Tony Lindgren
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Tony Lindgren @ 2014-08-27 23:28 UTC (permalink / raw)
To: kishon; +Cc: balbi, linux-kernel, linux-usb, linux-omap
It's not being used any longer.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/phy/phy-twl4030-usb.c | 2 --
drivers/usb/phy/phy-twl6030-usb.c | 2 --
2 files changed, 4 deletions(-)
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 9cd33a4..bc28ecc 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -164,7 +164,6 @@ struct twl4030_usb {
enum omap_musb_vbus_id_status linkstat;
bool vbus_supplied;
u8 asleep;
- bool irq_enabled;
struct delayed_work id_workaround_work;
};
@@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
* set_host() and/or set_peripheral() ... OTG_capable boards
* need both handles, otherwise just one suffices.
*/
- twl->irq_enabled = true;
status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
twl4030_usb_irq, IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
index 04778cf..44ea082 100644
--- a/drivers/usb/phy/phy-twl6030-usb.c
+++ b/drivers/usb/phy/phy-twl6030-usb.c
@@ -104,7 +104,6 @@ struct twl6030_usb {
int irq2;
enum omap_musb_vbus_id_status linkstat;
u8 asleep;
- bool irq_enabled;
bool vbus_enable;
const char *regulator;
};
@@ -373,7 +372,6 @@ static int twl6030_usb_probe(struct platform_device *pdev)
INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work);
- twl->irq_enabled = true;
status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq,
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT,
"twl6030_usb", twl);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* Re: [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled
2014-08-27 23:28 ` [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled Tony Lindgren
@ 2014-08-28 2:20 ` Felipe Balbi
0 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2014-08-28 2:20 UTC (permalink / raw)
To: Tony Lindgren; +Cc: kishon, balbi, linux-kernel, linux-usb, linux-omap
[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]
Hi,
On Wed, Aug 27, 2014 at 04:28:07PM -0700, Tony Lindgren wrote:
> It's not being used any longer.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/phy/phy-twl4030-usb.c | 2 --
> drivers/usb/phy/phy-twl6030-usb.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> index 9cd33a4..bc28ecc 100644
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -164,7 +164,6 @@ struct twl4030_usb {
> enum omap_musb_vbus_id_status linkstat;
> bool vbus_supplied;
> u8 asleep;
> - bool irq_enabled;
>
> struct delayed_work id_workaround_work;
> };
> @@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
> * set_host() and/or set_peripheral() ... OTG_capable boards
> * need both handles, otherwise just one suffices.
> */
> - twl->irq_enabled = true;
> status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
> twl4030_usb_irq, IRQF_TRIGGER_FALLING |
> IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
can you split this into two patches ? drivers/phy will be taken by
Kishon and drivers/usb/phy by me. another possibility is that I get an
Acked-by from Kishon and I can take $subject as is.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled
@ 2014-08-28 2:20 ` Felipe Balbi
0 siblings, 0 replies; 16+ messages in thread
From: Felipe Balbi @ 2014-08-28 2:20 UTC (permalink / raw)
To: Tony Lindgren; +Cc: kishon, balbi, linux-kernel, linux-usb, linux-omap
[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]
Hi,
On Wed, Aug 27, 2014 at 04:28:07PM -0700, Tony Lindgren wrote:
> It's not being used any longer.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/phy/phy-twl4030-usb.c | 2 --
> drivers/usb/phy/phy-twl6030-usb.c | 2 --
> 2 files changed, 4 deletions(-)
>
> diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> index 9cd33a4..bc28ecc 100644
> --- a/drivers/phy/phy-twl4030-usb.c
> +++ b/drivers/phy/phy-twl4030-usb.c
> @@ -164,7 +164,6 @@ struct twl4030_usb {
> enum omap_musb_vbus_id_status linkstat;
> bool vbus_supplied;
> u8 asleep;
> - bool irq_enabled;
>
> struct delayed_work id_workaround_work;
> };
> @@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
> * set_host() and/or set_peripheral() ... OTG_capable boards
> * need both handles, otherwise just one suffices.
> */
> - twl->irq_enabled = true;
> status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
> twl4030_usb_irq, IRQF_TRIGGER_FALLING |
> IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
can you split this into two patches ? drivers/phy will be taken by
Kishon and drivers/usb/phy by me. another possibility is that I get an
Acked-by from Kishon and I can take $subject as is.
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread[parent not found: <20140828022051.GB5273-HgARHv6XitL9zxVx7UNMDg@public.gmane.org>]
* Re: [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled
2014-08-28 2:20 ` Felipe Balbi
@ 2014-08-28 18:14 ` Tony Lindgren
-1 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2014-08-28 18:14 UTC (permalink / raw)
To: Felipe Balbi
Cc: kishon-l0cyMroinI0, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-omap-u79uwXL29TY76Z2rM5mHXA
* Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org> [140827 19:21]:
> Hi,
>
> On Wed, Aug 27, 2014 at 04:28:07PM -0700, Tony Lindgren wrote:
> > It's not being used any longer.
> >
> > Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> > ---
> > drivers/phy/phy-twl4030-usb.c | 2 --
> > drivers/usb/phy/phy-twl6030-usb.c | 2 --
> > 2 files changed, 4 deletions(-)
> >
> > diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> > index 9cd33a4..bc28ecc 100644
> > --- a/drivers/phy/phy-twl4030-usb.c
> > +++ b/drivers/phy/phy-twl4030-usb.c
> > @@ -164,7 +164,6 @@ struct twl4030_usb {
> > enum omap_musb_vbus_id_status linkstat;
> > bool vbus_supplied;
> > u8 asleep;
> > - bool irq_enabled;
> >
> > struct delayed_work id_workaround_work;
> > };
> > @@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
> > * set_host() and/or set_peripheral() ... OTG_capable boards
> > * need both handles, otherwise just one suffices.
> > */
> > - twl->irq_enabled = true;
> > status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
> > twl4030_usb_irq, IRQF_TRIGGER_FALLING |
> > IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
>
> can you split this into two patches ? drivers/phy will be taken by
> Kishon and drivers/usb/phy by me. another possibility is that I get an
> Acked-by from Kishon and I can take $subject as is.
Oops yes sorry I already forgot I'm patching twl6030 too. Below
is the updated version of this patch for Kishon with just the
twl4030 changes. I will post the twl6030 changes separately.
Regards,
Tony
8< ---------------------
From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Date: Mon, 18 Aug 2014 07:54:16 -0700
Subject: [PATCH] usb: phy: twl4030-usb: Remove unused irq_enabled
It's not being used any longer.
Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -164,7 +164,6 @@ struct twl4030_usb {
enum omap_musb_vbus_id_status linkstat;
bool vbus_supplied;
u8 asleep;
- bool irq_enabled;
struct delayed_work id_workaround_work;
};
@@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
* set_host() and/or set_peripheral() ... OTG_capable boards
* need both handles, otherwise just one suffices.
*/
- twl->irq_enabled = true;
status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
twl4030_usb_irq, IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
--
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] 16+ messages in thread* Re: [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled
@ 2014-08-28 18:14 ` Tony Lindgren
0 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2014-08-28 18:14 UTC (permalink / raw)
To: Felipe Balbi; +Cc: kishon, linux-kernel, linux-usb, linux-omap
* Felipe Balbi <balbi@ti.com> [140827 19:21]:
> Hi,
>
> On Wed, Aug 27, 2014 at 04:28:07PM -0700, Tony Lindgren wrote:
> > It's not being used any longer.
> >
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> > drivers/phy/phy-twl4030-usb.c | 2 --
> > drivers/usb/phy/phy-twl6030-usb.c | 2 --
> > 2 files changed, 4 deletions(-)
> >
> > diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
> > index 9cd33a4..bc28ecc 100644
> > --- a/drivers/phy/phy-twl4030-usb.c
> > +++ b/drivers/phy/phy-twl4030-usb.c
> > @@ -164,7 +164,6 @@ struct twl4030_usb {
> > enum omap_musb_vbus_id_status linkstat;
> > bool vbus_supplied;
> > u8 asleep;
> > - bool irq_enabled;
> >
> > struct delayed_work id_workaround_work;
> > };
> > @@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
> > * set_host() and/or set_peripheral() ... OTG_capable boards
> > * need both handles, otherwise just one suffices.
> > */
> > - twl->irq_enabled = true;
> > status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
> > twl4030_usb_irq, IRQF_TRIGGER_FALLING |
> > IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
>
> can you split this into two patches ? drivers/phy will be taken by
> Kishon and drivers/usb/phy by me. another possibility is that I get an
> Acked-by from Kishon and I can take $subject as is.
Oops yes sorry I already forgot I'm patching twl6030 too. Below
is the updated version of this patch for Kishon with just the
twl4030 changes. I will post the twl6030 changes separately.
Regards,
Tony
8< ---------------------
From: Tony Lindgren <tony@atomide.com>
Date: Mon, 18 Aug 2014 07:54:16 -0700
Subject: [PATCH] usb: phy: twl4030-usb: Remove unused irq_enabled
It's not being used any longer.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -164,7 +164,6 @@ struct twl4030_usb {
enum omap_musb_vbus_id_status linkstat;
bool vbus_supplied;
u8 asleep;
- bool irq_enabled;
struct delayed_work id_workaround_work;
};
@@ -755,7 +754,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
* set_host() and/or set_peripheral() ... OTG_capable boards
* need both handles, otherwise just one suffices.
*/
- twl->irq_enabled = true;
status = devm_request_threaded_irq(twl->dev, twl->irq, NULL,
twl4030_usb_irq, IRQF_TRIGGER_FALLING |
IRQF_TRIGGER_RISING | IRQF_ONESHOT, "twl4030_usb", twl);
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/5] usb: phy: twl4030-usb: Simplify phy init to use runtime PM
2014-08-27 23:28 [PATCH 0/5] Clean-up for twl4030-usb Tony Lindgren
2014-08-27 23:28 ` [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled Tony Lindgren
@ 2014-08-27 23:28 ` Tony Lindgren
2014-08-27 23:28 ` [PATCH 3/5] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls Tony Lindgren
` (2 subsequent siblings)
4 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2014-08-27 23:28 UTC (permalink / raw)
To: kishon; +Cc: balbi, linux-kernel, linux-usb, linux-omap
We can now let the interrupt and delayed work do all that's
needed with runtime PM.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/phy/phy-twl4030-usb.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index bc28ecc..a292db0 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -471,16 +471,8 @@ static int twl4030_phy_power_on(struct phy *phy)
twl4030_usb_set_mode(twl, twl->usb_mode);
if (twl->usb_mode == T2_USB_MODE_ULPI)
twl4030_i2c_access(twl, 0);
+ schedule_delayed_work(&twl->id_workaround_work, 0);
- /*
- * XXX When VBUS gets driven after musb goes to A mode,
- * ID_PRES related interrupts no longer arrive, why?
- * Register itself is updated fine though, so we must poll.
- */
- if (twl->linkstat == OMAP_MUSB_ID_GROUND) {
- cancel_delayed_work(&twl->id_workaround_work);
- schedule_delayed_work(&twl->id_workaround_work, HZ);
- }
return 0;
}
@@ -612,16 +604,9 @@ static void twl4030_id_workaround_work(struct work_struct *work)
static int twl4030_phy_init(struct phy *phy)
{
struct twl4030_usb *twl = phy_get_drvdata(phy);
- enum omap_musb_vbus_id_status status;
pm_runtime_get_sync(twl->dev);
- status = twl4030_usb_linkstat(twl);
- twl->linkstat = status;
-
- if (status == OMAP_MUSB_ID_GROUND || status == OMAP_MUSB_VBUS_VALID)
- omap_musb_mailbox(twl->linkstat);
-
- sysfs_notify(&twl->dev->kobj, NULL, "vbus");
+ schedule_delayed_work(&twl->id_workaround_work, 0);
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put_autosuspend(twl->dev);
@@ -698,6 +683,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl->dev = &pdev->dev;
twl->irq = platform_get_irq(pdev, 0);
twl->vbus_supplied = false;
+ twl->linkstat = -EINVAL;
twl->asleep = 1;
twl->linkstat = OMAP_MUSB_UNKNOWN;
--
1.8.1.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 3/5] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls
2014-08-27 23:28 [PATCH 0/5] Clean-up for twl4030-usb Tony Lindgren
2014-08-27 23:28 ` [PATCH 1/5] usb: phy: twl4030-usb: Remove unused irq_enabled Tony Lindgren
2014-08-27 23:28 ` [PATCH 2/5] usb: phy: twl4030-usb: Simplify phy init to use runtime PM Tony Lindgren
@ 2014-08-27 23:28 ` Tony Lindgren
[not found] ` <1409182091-31191-4-git-send-email-tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-08-27 23:28 ` [PATCH 4/5] usb: phy: twl4030-usb: Remove asleep and rely on runtime PM Tony Lindgren
2014-08-27 23:28 ` [PATCH 5/5] usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data Tony Lindgren
4 siblings, 1 reply; 16+ messages in thread
From: Tony Lindgren @ 2014-08-27 23:28 UTC (permalink / raw)
To: kishon; +Cc: balbi, linux-kernel, linux-usb, linux-omap
We don't need twl4030_phy_power() any longer now that we have
the runtime PM calls. Let's get rid of it as it's confusing.
No functional changes, just move the code and use res instead
of ret as we are not returning that value.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/phy/phy-twl4030-usb.c | 72 +++++++++++++++++++------------------------
1 file changed, 31 insertions(+), 41 deletions(-)
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index a292db0..519cc90 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -383,45 +383,6 @@ static void __twl4030_phy_power(struct twl4030_usb *twl, int on)
WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
}
-static void twl4030_phy_power(struct twl4030_usb *twl, int on)
-{
- int ret;
-
- if (on) {
- ret = regulator_enable(twl->usb3v1);
- if (ret)
- dev_err(twl->dev, "Failed to enable usb3v1\n");
-
- ret = regulator_enable(twl->usb1v8);
- if (ret)
- dev_err(twl->dev, "Failed to enable usb1v8\n");
-
- /*
- * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP
- * in twl4030) resets the VUSB_DEDICATED2 register. This reset
- * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to
- * SLEEP. We work around this by clearing the bit after usv3v1
- * is re-activated. This ensures that VUSB3V1 is really active.
- */
- twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
-
- ret = regulator_enable(twl->usb1v5);
- if (ret)
- dev_err(twl->dev, "Failed to enable usb1v5\n");
-
- __twl4030_phy_power(twl, 1);
- twl4030_usb_write(twl, PHY_CLK_CTRL,
- twl4030_usb_read(twl, PHY_CLK_CTRL) |
- (PHY_CLK_CTRL_CLOCKGATING_EN |
- PHY_CLK_CTRL_CLK32K_EN));
- } else {
- __twl4030_phy_power(twl, 0);
- regulator_disable(twl->usb1v5);
- regulator_disable(twl->usb1v8);
- regulator_disable(twl->usb3v1);
- }
-}
-
static int twl4030_usb_runtime_suspend(struct device *dev)
{
struct twl4030_usb *twl = dev_get_drvdata(dev);
@@ -430,7 +391,10 @@ static int twl4030_usb_runtime_suspend(struct device *dev)
if (twl->asleep)
return 0;
- twl4030_phy_power(twl, 0);
+ __twl4030_phy_power(twl, 0);
+ regulator_disable(twl->usb1v5);
+ regulator_disable(twl->usb1v8);
+ regulator_disable(twl->usb3v1);
twl->asleep = 1;
return 0;
@@ -439,12 +403,38 @@ static int twl4030_usb_runtime_suspend(struct device *dev)
static int twl4030_usb_runtime_resume(struct device *dev)
{
struct twl4030_usb *twl = dev_get_drvdata(dev);
+ int res;
dev_dbg(twl->dev, "%s\n", __func__);
if (!twl->asleep)
return 0;
- twl4030_phy_power(twl, 1);
+ res = regulator_enable(twl->usb3v1);
+ if (res)
+ dev_err(twl->dev, "Failed to enable usb3v1\n");
+
+ res = regulator_enable(twl->usb1v8);
+ if (res)
+ dev_err(twl->dev, "Failed to enable usb1v8\n");
+
+ /*
+ * Disabling usb3v1 regulator (= writing 0 to VUSB3V1_DEV_GRP
+ * in twl4030) resets the VUSB_DEDICATED2 register. This reset
+ * enables VUSB3V1_SLEEP bit that remaps usb3v1 ACTIVE state to
+ * SLEEP. We work around this by clearing the bit after usv3v1
+ * is re-activated. This ensures that VUSB3V1 is really active.
+ */
+ twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
+
+ res = regulator_enable(twl->usb1v5);
+ if (res)
+ dev_err(twl->dev, "Failed to enable usb1v5\n");
+
+ __twl4030_phy_power(twl, 1);
+ twl4030_usb_write(twl, PHY_CLK_CTRL,
+ twl4030_usb_read(twl, PHY_CLK_CTRL) |
+ (PHY_CLK_CTRL_CLOCKGATING_EN |
+ PHY_CLK_CTRL_CLK32K_EN));
twl->asleep = 0;
return 0;
--
1.8.1.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 4/5] usb: phy: twl4030-usb: Remove asleep and rely on runtime PM
2014-08-27 23:28 [PATCH 0/5] Clean-up for twl4030-usb Tony Lindgren
` (2 preceding siblings ...)
2014-08-27 23:28 ` [PATCH 3/5] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls Tony Lindgren
@ 2014-08-27 23:28 ` Tony Lindgren
2014-08-27 23:28 ` [PATCH 5/5] usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data Tony Lindgren
4 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2014-08-27 23:28 UTC (permalink / raw)
To: kishon; +Cc: balbi, linux-kernel, linux-usb, linux-omap
There's no longer need for tracking the phy state in the driver
with asleep, we can now rely on runtime PM.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/phy/phy-twl4030-usb.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 519cc90..24ff3c6 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -163,7 +163,6 @@ struct twl4030_usb {
int irq;
enum omap_musb_vbus_id_status linkstat;
bool vbus_supplied;
- u8 asleep;
struct delayed_work id_workaround_work;
};
@@ -388,14 +387,13 @@ static int twl4030_usb_runtime_suspend(struct device *dev)
struct twl4030_usb *twl = dev_get_drvdata(dev);
dev_dbg(twl->dev, "%s\n", __func__);
- if (twl->asleep)
+ if (pm_runtime_suspended(dev))
return 0;
__twl4030_phy_power(twl, 0);
regulator_disable(twl->usb1v5);
regulator_disable(twl->usb1v8);
regulator_disable(twl->usb3v1);
- twl->asleep = 1;
return 0;
}
@@ -406,7 +404,7 @@ static int twl4030_usb_runtime_resume(struct device *dev)
int res;
dev_dbg(twl->dev, "%s\n", __func__);
- if (!twl->asleep)
+ if (pm_runtime_active(dev))
return 0;
res = regulator_enable(twl->usb3v1);
@@ -435,7 +433,6 @@ static int twl4030_usb_runtime_resume(struct device *dev)
twl4030_usb_read(twl, PHY_CLK_CTRL) |
(PHY_CLK_CTRL_CLOCKGATING_EN |
PHY_CLK_CTRL_CLK32K_EN));
- twl->asleep = 0;
return 0;
}
@@ -560,10 +557,10 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
*/
if ((status == OMAP_MUSB_VBUS_VALID) ||
(status == OMAP_MUSB_ID_GROUND)) {
- if (twl->asleep)
+ if (pm_runtime_suspended(twl->dev))
pm_runtime_get_sync(twl->dev);
} else {
- if (!twl->asleep) {
+ if (pm_runtime_active(twl->dev)) {
pm_runtime_mark_last_busy(twl->dev);
pm_runtime_put_autosuspend(twl->dev);
}
@@ -572,7 +569,7 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
}
/* don't schedule during sleep - irq works right then */
- if (status == OMAP_MUSB_ID_GROUND && !twl->asleep) {
+ if (status == OMAP_MUSB_ID_GROUND && pm_runtime_active(twl->dev)) {
cancel_delayed_work(&twl->id_workaround_work);
schedule_delayed_work(&twl->id_workaround_work, HZ);
}
@@ -674,7 +671,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
twl->irq = platform_get_irq(pdev, 0);
twl->vbus_supplied = false;
twl->linkstat = -EINVAL;
- twl->asleep = 1;
twl->linkstat = OMAP_MUSB_UNKNOWN;
twl->phy.dev = twl->dev;
--
1.8.1.1
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH 5/5] usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data
2014-08-27 23:28 [PATCH 0/5] Clean-up for twl4030-usb Tony Lindgren
` (3 preceding siblings ...)
2014-08-27 23:28 ` [PATCH 4/5] usb: phy: twl4030-usb: Remove asleep and rely on runtime PM Tony Lindgren
@ 2014-08-27 23:28 ` Tony Lindgren
4 siblings, 0 replies; 16+ messages in thread
From: Tony Lindgren @ 2014-08-27 23:28 UTC (permalink / raw)
To: kishon; +Cc: balbi, linux-kernel, linux-usb, linux-omap
We're using threaded irq on a I2C bus and we're sleeping in
twl4030_usb_irq() as it calls twl4030_usb_linkstat() which
calls the i2c functions. If we ever need to lock for longer
I2C transaction sequences a mutex will allow us to do that
easily.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/phy/phy-twl4030-usb.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index 24ff3c6..1e0e2d1 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -28,7 +28,6 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
-#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/io.h>
#include <linux/delay.h>
@@ -155,7 +154,7 @@ struct twl4030_usb {
struct regulator *usb3v1;
/* for vbus reporting with irqs disabled */
- spinlock_t lock;
+ struct mutex lock;
/* pin configuration */
enum twl4030_usb_mode usb_mode;
@@ -516,13 +515,12 @@ static ssize_t twl4030_usb_vbus_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct twl4030_usb *twl = dev_get_drvdata(dev);
- unsigned long flags;
int ret = -EINVAL;
- spin_lock_irqsave(&twl->lock, flags);
+ mutex_lock(&twl->lock);
ret = sprintf(buf, "%s\n",
twl->vbus_supplied ? "on" : "off");
- spin_unlock_irqrestore(&twl->lock, flags);
+ mutex_unlock(&twl->lock);
return ret;
}
@@ -536,12 +534,12 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
status = twl4030_usb_linkstat(twl);
- spin_lock_irq(&twl->lock);
+ mutex_lock(&twl->lock);
if (status >= 0 && status != twl->linkstat) {
twl->linkstat = status;
status_changed = true;
}
- spin_unlock_irq(&twl->lock);
+ mutex_unlock(&twl->lock);
if (status_changed) {
/* FIXME add a set_power() method so that B-devices can
@@ -695,8 +693,8 @@ static int twl4030_usb_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
- /* init spinlock for workqueue */
- spin_lock_init(&twl->lock);
+ /* init mutex for workqueue */
+ mutex_init(&twl->lock);
INIT_DELAYED_WORK(&twl->id_workaround_work, twl4030_id_workaround_work);
--
1.8.1.1
^ permalink raw reply related [flat|nested] 16+ messages in thread