spi: intel: Move suspend and resume hooks to pm_ops
The suspend and resume hooks in the spi_driver_api struct are relics from before the current power management infrastructure was in place. The correct way to implement this now is through the device_pm_ops struct, by way of the DEFINE_DEVICE_PM_OPS and DEVICE_AND_API_INIT_PM macros, which make the hooks available through a generic mechanism for all devices, rather than using per-type APIs. Since the existing spi_suspend() and spi_resume() functions don't check if the driver_api hooks are NULL, there's now a place holder function to prevent breaking functionality until the hooks are removed. Change-Id: I48287c58e9a8649d3e1be7547e3d0d293c84327a Signed-off-by: Iván Briano <ivan.briano@intel.com>
This commit is contained in:
parent
c0eda9ec7e
commit
bce65437c0
1 changed files with 42 additions and 32 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
|
||||||
#include <sys_io.h>
|
#include <sys_io.h>
|
||||||
|
#include <power.h>
|
||||||
|
|
||||||
#include <spi.h>
|
#include <spi.h>
|
||||||
#include <spi/spi_intel.h>
|
#include <spi/spi_intel.h>
|
||||||
|
@ -301,30 +302,6 @@ static int spi_intel_transceive(struct device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spi_intel_suspend(struct device *dev)
|
|
||||||
{
|
|
||||||
struct spi_intel_config *info = dev->config->config_info;
|
|
||||||
|
|
||||||
SYS_LOG_DBG("spi_intel_suspend: %p", dev);
|
|
||||||
|
|
||||||
clear_bit_sscr0_sse(info->regs);
|
|
||||||
irq_disable(info->irq);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int spi_intel_resume(struct device *dev)
|
|
||||||
{
|
|
||||||
struct spi_intel_config *info = dev->config->config_info;
|
|
||||||
|
|
||||||
SYS_LOG_DBG("spi_intel_resume: %p", dev);
|
|
||||||
|
|
||||||
set_bit_sscr0_sse(info->regs);
|
|
||||||
irq_enable(info->irq);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spi_intel_isr(void *arg)
|
void spi_intel_isr(void *arg)
|
||||||
{
|
{
|
||||||
struct device *dev = arg;
|
struct device *dev = arg;
|
||||||
|
@ -356,12 +333,17 @@ out:
|
||||||
completed(dev, error);
|
completed(dev, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int toberemoved(struct device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static struct spi_driver_api intel_spi_api = {
|
static struct spi_driver_api intel_spi_api = {
|
||||||
.configure = spi_intel_configure,
|
.configure = spi_intel_configure,
|
||||||
.slave_select = NULL,
|
.slave_select = NULL,
|
||||||
.transceive = spi_intel_transceive,
|
.transceive = spi_intel_transceive,
|
||||||
.suspend = spi_intel_suspend,
|
.suspend = toberemoved,
|
||||||
.resume = spi_intel_resume,
|
.resume = toberemoved,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
|
@ -415,6 +397,34 @@ int spi_intel_init(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEVICE_POWER_MANAGEMENT
|
||||||
|
static int spi_intel_suspend(struct device *dev, int pm_policy)
|
||||||
|
{
|
||||||
|
struct spi_intel_config *info = dev->config->config_info;
|
||||||
|
|
||||||
|
SYS_LOG_DBG("spi_intel_suspend: %p", dev);
|
||||||
|
|
||||||
|
clear_bit_sscr0_sse(info->regs);
|
||||||
|
irq_disable(info->irq);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int spi_intel_resume(struct device *dev, int pm_policy)
|
||||||
|
{
|
||||||
|
struct spi_intel_config *info = dev->config->config_info;
|
||||||
|
|
||||||
|
SYS_LOG_DBG("spi_intel_resume: %p", dev);
|
||||||
|
|
||||||
|
set_bit_sscr0_sse(info->regs);
|
||||||
|
irq_enable(info->irq);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEFINE_DEVICE_PM_OPS(spi, spi_intel_suspend, spi_intel_resume);
|
||||||
|
|
||||||
/* system bindings */
|
/* system bindings */
|
||||||
#ifdef CONFIG_SPI_0
|
#ifdef CONFIG_SPI_0
|
||||||
|
|
||||||
|
@ -441,9 +451,9 @@ struct spi_intel_config spi_intel_config_0 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* SPI may use GPIO pin for CS, thus it needs to be initialized after GPIO */
|
/* SPI may use GPIO pin for CS, thus it needs to be initialized after GPIO */
|
||||||
DEVICE_INIT(spi_intel_port_0, CONFIG_SPI_0_NAME, spi_intel_init,
|
DEVICE_INIT_PM(spi_intel_port_0, CONFIG_SPI_0_NAME, spi_intel_init,
|
||||||
&spi_intel_data_port_0, &spi_intel_config_0,
|
DEVICE_PM_OPS_GET(spi), &spi_intel_data_port_0,
|
||||||
SECONDARY, CONFIG_SPI_INIT_PRIORITY);
|
&spi_intel_config_0, SECONDARY, CONFIG_SPI_INIT_PRIORITY);
|
||||||
|
|
||||||
void spi_config_0_irq(void)
|
void spi_config_0_irq(void)
|
||||||
{
|
{
|
||||||
|
@ -478,9 +488,9 @@ struct spi_intel_config spi_intel_config_1 = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* SPI may use GPIO pin for CS, thus it needs to be initialized after GPIO */
|
/* SPI may use GPIO pin for CS, thus it needs to be initialized after GPIO */
|
||||||
DEVICE_INIT(spi_intel_port_1, CONFIG_SPI_1_NAME, spi_intel_init,
|
DEVICE_INIT_PM(spi_intel_port_1, CONFIG_SPI_1_NAME, spi_intel_init,
|
||||||
&spi_intel_data_port_1, &spi_intel_config_1,
|
DEVICE_PM_OPS_GET(spi), &spi_intel_data_port_1,
|
||||||
SECONDARY, CONFIG_SPI_INIT_PRIORITY);
|
&spi_intel_config_1, SECONDARY, CONFIG_SPI_INIT_PRIORITY);
|
||||||
|
|
||||||
void spi_config_1_irq(void)
|
void spi_config_1_irq(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue