Merge branch 'spi-pl022' into spi-next
This commit is contained in:
commit
b4482afeb7
@ -371,6 +371,7 @@ struct pl022 {
|
|||||||
/* Two optional pin states - default & sleep */
|
/* Two optional pin states - default & sleep */
|
||||||
struct pinctrl *pinctrl;
|
struct pinctrl *pinctrl;
|
||||||
struct pinctrl_state *pins_default;
|
struct pinctrl_state *pins_default;
|
||||||
|
struct pinctrl_state *pins_idle;
|
||||||
struct pinctrl_state *pins_sleep;
|
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;
|
||||||
@ -2116,6 +2117,11 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
|
|||||||
} else
|
} else
|
||||||
dev_err(dev, "could not get default pinstate\n");
|
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,
|
pl022->pins_sleep = pinctrl_lookup_state(pl022->pinctrl,
|
||||||
PINCTRL_STATE_SLEEP);
|
PINCTRL_STATE_SLEEP);
|
||||||
if (IS_ERR(pl022->pins_sleep))
|
if (IS_ERR(pl022->pins_sleep))
|
||||||
@ -2249,10 +2255,9 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
|
|||||||
pm_runtime_set_autosuspend_delay(dev,
|
pm_runtime_set_autosuspend_delay(dev,
|
||||||
platform_info->autosuspend_delay);
|
platform_info->autosuspend_delay);
|
||||||
pm_runtime_use_autosuspend(dev);
|
pm_runtime_use_autosuspend(dev);
|
||||||
pm_runtime_put_autosuspend(dev);
|
|
||||||
} else {
|
|
||||||
pm_runtime_put(dev);
|
|
||||||
}
|
}
|
||||||
|
pm_runtime_put(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_spi_register:
|
err_spi_register:
|
||||||
@ -2307,35 +2312,47 @@ pl022_remove(struct amba_device *adev)
|
|||||||
* the runtime counterparts to handle external resources like
|
* the runtime counterparts to handle external resources like
|
||||||
* clocks, pins and regulators when going to sleep.
|
* clocks, pins and regulators when going to sleep.
|
||||||
*/
|
*/
|
||||||
static void pl022_suspend_resources(struct pl022 *pl022)
|
static void pl022_suspend_resources(struct pl022 *pl022, bool runtime)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
struct pinctrl_state *pins_state;
|
||||||
|
|
||||||
clk_disable(pl022->clk);
|
clk_disable(pl022->clk);
|
||||||
|
|
||||||
|
pins_state = runtime ? pl022->pins_idle : pl022->pins_sleep;
|
||||||
/* Optionally let pins go into sleep states */
|
/* Optionally let pins go into sleep states */
|
||||||
if (!IS_ERR(pl022->pins_sleep)) {
|
if (!IS_ERR(pins_state)) {
|
||||||
ret = pinctrl_select_state(pl022->pinctrl,
|
ret = pinctrl_select_state(pl022->pinctrl, pins_state);
|
||||||
pl022->pins_sleep);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(&pl022->adev->dev,
|
dev_err(&pl022->adev->dev, "could not set %s pins\n",
|
||||||
"could not set pins to sleep state\n");
|
runtime ? "idle" : "sleep");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pl022_resume_resources(struct pl022 *pl022)
|
static void pl022_resume_resources(struct pl022 *pl022, bool runtime)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Optionaly enable pins to be muxed in and configured */
|
/* Optionaly enable pins to be muxed in and configured */
|
||||||
|
/* First go to the default state */
|
||||||
if (!IS_ERR(pl022->pins_default)) {
|
if (!IS_ERR(pl022->pins_default)) {
|
||||||
ret = pinctrl_select_state(pl022->pinctrl,
|
ret = pinctrl_select_state(pl022->pinctrl, pl022->pins_default);
|
||||||
pl022->pins_default);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
dev_err(&pl022->adev->dev,
|
dev_err(&pl022->adev->dev,
|
||||||
"could not set default pins\n");
|
"could not set default pins\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clk_enable(pl022->clk);
|
clk_enable(pl022->clk);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2351,7 +2368,9 @@ static int pl022_suspend(struct device *dev)
|
|||||||
dev_warn(dev, "cannot suspend master\n");
|
dev_warn(dev, "cannot suspend master\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
pl022_suspend_resources(pl022);
|
|
||||||
|
pm_runtime_get_sync(dev);
|
||||||
|
pl022_suspend_resources(pl022, false);
|
||||||
|
|
||||||
dev_dbg(dev, "suspended\n");
|
dev_dbg(dev, "suspended\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -2362,7 +2381,8 @@ static int pl022_resume(struct device *dev)
|
|||||||
struct pl022 *pl022 = dev_get_drvdata(dev);
|
struct pl022 *pl022 = dev_get_drvdata(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pl022_resume_resources(pl022);
|
pl022_resume_resources(pl022, false);
|
||||||
|
pm_runtime_put(dev);
|
||||||
|
|
||||||
/* Start the queue running */
|
/* Start the queue running */
|
||||||
ret = spi_master_resume(pl022->master);
|
ret = spi_master_resume(pl022->master);
|
||||||
@ -2380,7 +2400,7 @@ static int pl022_runtime_suspend(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct pl022 *pl022 = dev_get_drvdata(dev);
|
struct pl022 *pl022 = dev_get_drvdata(dev);
|
||||||
|
|
||||||
pl022_suspend_resources(pl022);
|
pl022_suspend_resources(pl022, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2388,7 +2408,7 @@ static int pl022_runtime_resume(struct device *dev)
|
|||||||
{
|
{
|
||||||
struct pl022 *pl022 = dev_get_drvdata(dev);
|
struct pl022 *pl022 = dev_get_drvdata(dev);
|
||||||
|
|
||||||
pl022_resume_resources(pl022);
|
pl022_resume_resources(pl022, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user