soc: qcom: handle AON spi device when driver is not ready

Handle accessing the AON spi device when driver is not ready
& when device enter to shutdown path.

Change-Id: Ibebb2f526b289ee31517d7e52e48ca46ce705d1c
Signed-off-by: Praveen koya <quic_pkoya@quicinc.com>
This commit is contained in:
Praveen koya
2023-12-20 17:20:21 +05:30
parent fc9a5a5370
commit 65b80d06da

View File

@@ -352,7 +352,7 @@ static int slatecom_transfer(void *handle, uint8_t *tx_buf,
struct spi_transfer *tx_xfer;
struct slate_spi_priv *slate_spi;
struct slate_context *cntx;
struct spi_device *spi;
struct spi_device *spi = NULL;
int ret = 0;
if (!handle || !tx_buf)
@@ -428,8 +428,11 @@ void send_event(enum slatecom_event_type event,
void slatecom_slatedown_handler(void)
{
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!is_slatecom_ready())
return;
spi = get_spi_device();
g_slav_status_reg = 0;
atomic_set(&ok_to_sleep, 0);
pm_runtime_get_sync(&spi->dev);
@@ -863,7 +866,7 @@ int slatecom_ahb_read(void *handle, uint32_t ahb_start_addr,
int ret = 0;
uint8_t cmnd = 0;
uint32_t ahb_addr = 0;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!handle || !read_buf || num_words == 0
|| num_words > SLATE_SPI_MAX_WORDS) {
@@ -877,7 +880,7 @@ int slatecom_ahb_read(void *handle, uint32_t ahb_start_addr,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -928,7 +931,7 @@ int slatecom_ahb_write_bytes(void *handle, uint32_t ahb_start_addr,
uint8_t cmnd = 0;
uint32_t ahb_addr = 0;
uint32_t curr_num_bytes;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!handle || !write_buf || num_bytes == 0
|| num_bytes > (SLATE_SPI_MAX_WORDS * sizeof(int))) {
@@ -943,7 +946,7 @@ int slatecom_ahb_write_bytes(void *handle, uint32_t ahb_start_addr,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -998,7 +1001,7 @@ int slatecom_ahb_write(void *handle, uint32_t ahb_start_addr,
uint32_t ahb_addr = 0;
uint32_t curr_num_words;
uint32_t curr_num_bytes;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!handle || !write_buf || num_words == 0
|| num_words > SLATE_SPI_MAX_WORDS) {
@@ -1013,7 +1016,7 @@ int slatecom_ahb_write(void *handle, uint32_t ahb_start_addr,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -1062,13 +1065,11 @@ int slatecom_fifo_write(void *handle, uint32_t num_words,
uint32_t size;
int ret = 0;
uint8_t cmnd = 0;
struct spi_device *spi;
struct spi_device *spi = NULL;
if (!is_slatecom_ready())
return -ENODEV;
spi = get_spi_device();
if (!handle || !write_buf || num_words == 0
|| num_words > SLATE_SPI_MAX_WORDS) {
SLATECOM_ERR("Invalid param\n");
@@ -1079,7 +1080,7 @@ int slatecom_fifo_write(void *handle, uint32_t num_words,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -1116,7 +1117,7 @@ int slatecom_fifo_read(void *handle, uint32_t num_words,
uint32_t size;
uint8_t cmnd = 0;
int ret = 0;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!handle || !read_buf || num_words == 0
|| num_words > SLATE_SPI_MAX_WORDS) {
@@ -1131,7 +1132,7 @@ int slatecom_fifo_read(void *handle, uint32_t num_words,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -1216,8 +1217,9 @@ int slatecom_reg_write(void *handle, uint8_t reg_start_addr,
uint8_t num_regs, void *write_buf)
{
int ret = 0;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);
@@ -1294,7 +1296,7 @@ int slatecom_reg_read(void *handle, uint8_t reg_start_addr,
uint32_t size;
int ret = 0;
uint8_t cmnd = 0;
struct spi_device *spi = get_spi_device();
struct spi_device *spi = NULL;
if (!handle || !read_buf || num_regs == 0
|| num_regs > SLATE_SPI_MAX_REGS) {
@@ -1309,7 +1311,7 @@ int slatecom_reg_read(void *handle, uint8_t reg_start_addr,
SLATECOM_ERR("Device busy\n");
return -EBUSY;
}
spi = get_spi_device();
pm_runtime_get_sync(&spi->dev);
mutex_lock(&slate_task_mutex);