From f1c9cf074b6abb4c7cbb163d193470c93cb1ad5b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 10 Jun 2013 16:57:09 +0200 Subject: 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 Cc: Dmitry Torokhov Cc: Kevin Hilman Cc: Greg Kroah-Hartman Cc: Stephen Warren Cc: Wolfram Sang Acked-by: Mark Brown Signed-off-by: Linus Walleij --- drivers/spi/spi-pl022.c | 65 ++++++------------------------------------------- 1 file changed, 8 insertions(+), 57 deletions(-) (limited to 'drivers/spi/spi-pl022.c') diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 371cc66f1a0..5b8cd152418 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -368,11 +368,6 @@ struct pl022 { resource_size_t phybase; void __iomem *virtbase; 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 pl022_ssp_controller *master_info; /* Message per-transfer pump */ @@ -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), GFP_KERNEL); - pl022->pinctrl = devm_pinctrl_get(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"); + pinctrl_pm_select_default_state(dev); /* * 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) amba_release_regions(adev); err_no_ioregion: err_no_gpio: - err_no_pinctrl: spi_master_put(master); return status; } @@ -2353,39 +2322,21 @@ static void pl022_suspend_resources(struct pl022 *pl022, bool runtime) clk_disable(pl022->clk); - pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep; - /* Optionally let pins go into sleep states */ - if (!IS_ERR(pins_state)) { - ret = pinctrl_select_state(pl022->pinctrl, pins_state); - if (ret) - dev_err(&pl022->adev->dev, "could not set %s pins\n", - runtime ? "idle" : "sleep"); - } + if (runtime) + pinctrl_pm_select_idle_state(&pl022->adev->dev); + else + pinctrl_pm_select_sleep_state(&pl022->adev->dev); } static void pl022_resume_resources(struct pl022 *pl022, bool runtime) { int ret; - /* Optionaly enable pins to be muxed in and configured */ /* First go to the default state */ - if (!IS_ERR(pl022->pins_default)) { - ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default); - if (ret) - dev_err(&pl022->adev->dev, - "could not set default pins\n"); - } - - if (!runtime) { + pinctrl_pm_select_default_state(&pl022->adev->dev); + if (!runtime) /* Then let's idle the pins until the next transfer happens */ - if (!IS_ERR(pl022->pins_idle)) { - ret = pinctrl_select_state(pl022->pinctrl, - pl022->pins_idle); - if (ret) - dev_err(&pl022->adev->dev, - "could not set idle pins\n"); - } - } + pinctrl_pm_select_idle_state(&pl022->adev->dev); clk_enable(pl022->clk); } -- cgit v1.2.3