提交 f1c9cf07 编写于 作者: L Linus Walleij

spi: pl022: use pinctrl PM helpers

This utilize the new pinctrl core PM helpers to transition
the driver to "sleep" and "idle" states, cutting away some
boilerplate code.

Cc: Hebbar Gururaja <gururaja.hebbar@ti.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Kevin Hilman <khilman@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Acked-by: NMark Brown <broonie@kernel.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 7f884b64
...@@ -368,11 +368,6 @@ struct pl022 { ...@@ -368,11 +368,6 @@ struct pl022 {
resource_size_t phybase; resource_size_t phybase;
void __iomem *virtbase; void __iomem *virtbase;
struct clk *clk; struct clk *clk;
/* Two optional pin states - default & sleep */
struct pinctrl *pinctrl;
struct pinctrl_state *pins_default;
struct pinctrl_state *pins_idle;
struct pinctrl_state *pins_sleep;
struct spi_master *master; struct spi_master *master;
struct pl022_ssp_controller *master_info; struct pl022_ssp_controller *master_info;
/* Message per-transfer pump */ /* Message per-transfer pump */
...@@ -2133,32 +2128,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2133,32 +2128,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
GFP_KERNEL); GFP_KERNEL);
pl022->pinctrl = devm_pinctrl_get(dev); pinctrl_pm_select_default_state(dev);
if (IS_ERR(pl022->pinctrl)) {
status = PTR_ERR(pl022->pinctrl);
goto err_no_pinctrl;
}
pl022->pins_default = pinctrl_lookup_state(pl022->pinctrl,
PINCTRL_STATE_DEFAULT);
/* enable pins to be muxed in and configured */
if (!IS_ERR(pl022->pins_default)) {
status = pinctrl_select_state(pl022->pinctrl,
pl022->pins_default);
if (status)
dev_err(dev, "could not set default pins\n");
} else
dev_err(dev, "could not get default pinstate\n");
pl022->pins_idle = pinctrl_lookup_state(pl022->pinctrl,
PINCTRL_STATE_IDLE);
if (IS_ERR(pl022->pins_idle))
dev_dbg(dev, "could not get idle pinstate\n");
pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl,
PINCTRL_STATE_SLEEP);
if (IS_ERR(pl022->pins_sleep))
dev_dbg(dev, "could not get sleep pinstate\n");
/* /*
* Bus Number Which has been Assigned to this SSP controller * Bus Number Which has been Assigned to this SSP controller
...@@ -2308,7 +2278,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2308,7 +2278,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
amba_release_regions(adev); amba_release_regions(adev);
err_no_ioregion: err_no_ioregion:
err_no_gpio: err_no_gpio:
err_no_pinctrl:
spi_master_put(master); spi_master_put(master);
return status; return status;
} }
...@@ -2353,39 +2322,21 @@ static void pl022_suspend_resources(struct pl022 *pl022, bool runtime) ...@@ -2353,39 +2322,21 @@ static void pl022_suspend_resources(struct pl022 *pl022, bool runtime)
clk_disable(pl022->clk); clk_disable(pl022->clk);
pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep; if (runtime)
/* Optionally let pins go into sleep states */ pinctrl_pm_select_idle_state(&pl022->adev->dev);
if (!IS_ERR(pins_state)) { else
ret = pinctrl_select_state(pl022->pinctrl, pins_state); pinctrl_pm_select_sleep_state(&pl022->adev->dev);
if (ret)
dev_err(&pl022->adev->dev, "could not set %s pins\n",
runtime ? "idle" : "sleep");
}
} }
static void pl022_resume_resources(struct pl022 *pl022, bool runtime) static void pl022_resume_resources(struct pl022 *pl022, bool runtime)
{ {
int ret; int ret;
/* Optionaly enable pins to be muxed in and configured */
/* First go to the default state */ /* First go to the default state */
if (!IS_ERR(pl022->pins_default)) { pinctrl_pm_select_default_state(&pl022->adev->dev);
ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default); if (!runtime)
if (ret)
dev_err(&pl022->adev->dev,
"could not set default pins\n");
}
if (!runtime) {
/* Then let's idle the pins until the next transfer happens */ /* Then let's idle the pins until the next transfer happens */
if (!IS_ERR(pl022->pins_idle)) { pinctrl_pm_select_idle_state(&pl022->adev->dev);
ret = pinctrl_select_state(pl022->pinctrl,
pl022->pins_idle);
if (ret)
dev_err(&pl022->adev->dev,
"could not set idle pins\n");
}
}
clk_enable(pl022->clk); clk_enable(pl022->clk);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册