diff mbox series

[V2,7/8] soundwire: amd: handle soundwire wake enable interrupt

Message ID 20230213094031.2231058-8-Vijendar.Mukunda@amd.com
State Superseded
Headers show
Series [V2,1/8] soundwire: export sdw_compute_slave_ports() function | expand

Commit Message

Vijendar Mukunda Feb. 13, 2023, 9:40 a.m. UTC
Add wake enable interrupt support for both the soundwire manager
instances.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Mastan Katragadda <Mastan.Katragadda@amd.com>
---
 drivers/soundwire/amd_manager.c | 10 ++++++++++
 drivers/soundwire/amd_manager.h |  1 +
 2 files changed, 11 insertions(+)

Comments

Pierre-Louis Bossart Feb. 13, 2023, 6:24 p.m. UTC | #1
On 2/13/23 03:40, Vijendar Mukunda wrote:
> Add wake enable interrupt support for both the soundwire manager
> instances.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> Signed-off-by: Mastan Katragadda <Mastan.Katragadda@amd.com>
> ---
>  drivers/soundwire/amd_manager.c | 10 ++++++++++
>  drivers/soundwire/amd_manager.h |  1 +
>  2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
> index eced189ba6e0..e53dc67f8529 100644
> --- a/drivers/soundwire/amd_manager.c
> +++ b/drivers/soundwire/amd_manager.c
> @@ -934,6 +934,13 @@ static void amd_sdw_update_slave_status(u32 status_change_0to7, u32 status_chang
>  	}
>  }
>  
> +static void amd_sdw_process_wake_event(struct amd_sdw_manager *amd_manager)
> +{
> +	pm_request_resume(amd_manager->dev);
> +	acp_reg_writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance));
> +	acp_reg_writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11);
> +}
> +
>  static void amd_sdw_irq_thread(struct work_struct *work)
>  {
>  	struct amd_sdw_manager *amd_manager =
> @@ -945,6 +952,9 @@ static void amd_sdw_irq_thread(struct work_struct *work)
>  	status_change_0to7 = acp_reg_readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7);
>  	dev_dbg(amd_manager->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n",
>  		__func__, amd_manager->instance, status_change_0to7, status_change_8to11);
> +	if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK)
> +		return amd_sdw_process_wake_event(amd_manager);
> +

it's not clear what 8to11 might have to do with the wake enable?

Can't you have a wake for devices 1..7?


>  	if (status_change_8to11 & AMD_SDW_PREQ_INTR_STAT) {
>  		amd_sdw_read_and_process_ping_status(amd_manager);
>  	} else {
> diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h
> index 6ec37612ae4e..86bc6d4f48bf 100644
> --- a/drivers/soundwire/amd_manager.h
> +++ b/drivers/soundwire/amd_manager.h
> @@ -190,6 +190,7 @@
>  #define AMD_SDW_CLK_STOP_DONE				1
>  #define AMD_SDW_CLK_RESUME_REQ				2
>  #define AMD_SDW_CLK_RESUME_DONE				3
> +#define AMD_SDW_WAKE_STAT_MASK				BIT(16)
>  
>  enum amd_sdw_cmd_type {
>  	AMD_SDW_CMD_PING = 0,
Vijendar Mukunda Feb. 14, 2023, 6:15 a.m. UTC | #2
On 13/02/23 23:54, Pierre-Louis Bossart wrote:
>
> On 2/13/23 03:40, Vijendar Mukunda wrote:
>> Add wake enable interrupt support for both the soundwire manager
>> instances.
>>
>> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
>> Signed-off-by: Mastan Katragadda <Mastan.Katragadda@amd.com>
>> ---
>>  drivers/soundwire/amd_manager.c | 10 ++++++++++
>>  drivers/soundwire/amd_manager.h |  1 +
>>  2 files changed, 11 insertions(+)
>>
>> diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
>> index eced189ba6e0..e53dc67f8529 100644
>> --- a/drivers/soundwire/amd_manager.c
>> +++ b/drivers/soundwire/amd_manager.c
>> @@ -934,6 +934,13 @@ static void amd_sdw_update_slave_status(u32 status_change_0to7, u32 status_chang
>>  	}
>>  }
>>  
>> +static void amd_sdw_process_wake_event(struct amd_sdw_manager *amd_manager)
>> +{
>> +	pm_request_resume(amd_manager->dev);
>> +	acp_reg_writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance));
>> +	acp_reg_writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11);
>> +}
>> +
>>  static void amd_sdw_irq_thread(struct work_struct *work)
>>  {
>>  	struct amd_sdw_manager *amd_manager =
>> @@ -945,6 +952,9 @@ static void amd_sdw_irq_thread(struct work_struct *work)
>>  	status_change_0to7 = acp_reg_readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7);
>>  	dev_dbg(amd_manager->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n",
>>  		__func__, amd_manager->instance, status_change_0to7, status_change_8to11);
>> +	if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK)
>> +		return amd_sdw_process_wake_event(amd_manager);
>> +
> it's not clear what 8to11 might have to do with the wake enable?
>
> Can't you have a wake for devices 1..7?
It can wake any device from 1..11 .
SoundWire Wake interrupt status bit is part of 8to11 register.
>
>
>>  	if (status_change_8to11 & AMD_SDW_PREQ_INTR_STAT) {
>>  		amd_sdw_read_and_process_ping_status(amd_manager);
>>  	} else {
>> diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h
>> index 6ec37612ae4e..86bc6d4f48bf 100644
>> --- a/drivers/soundwire/amd_manager.h
>> +++ b/drivers/soundwire/amd_manager.h
>> @@ -190,6 +190,7 @@
>>  #define AMD_SDW_CLK_STOP_DONE				1
>>  #define AMD_SDW_CLK_RESUME_REQ				2
>>  #define AMD_SDW_CLK_RESUME_DONE				3
>> +#define AMD_SDW_WAKE_STAT_MASK				BIT(16)
>>  
>>  enum amd_sdw_cmd_type {
>>  	AMD_SDW_CMD_PING = 0,
Pierre-Louis Bossart Feb. 14, 2023, 1:35 p.m. UTC | #3
>>>  static void amd_sdw_irq_thread(struct work_struct *work)
>>>  {
>>>  	struct amd_sdw_manager *amd_manager =
>>> @@ -945,6 +952,9 @@ static void amd_sdw_irq_thread(struct work_struct *work)
>>>  	status_change_0to7 = acp_reg_readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7);
>>>  	dev_dbg(amd_manager->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n",
>>>  		__func__, amd_manager->instance, status_change_0to7, status_change_8to11);
>>> +	if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK)
>>> +		return amd_sdw_process_wake_event(amd_manager);
>>> +
>> it's not clear what 8to11 might have to do with the wake enable?
>>
>> Can't you have a wake for devices 1..7?
> It can wake any device from 1..11 .
> SoundWire Wake interrupt status bit is part of 8to11 register.

You probably want to explain what status_change_0to7 and
status_change_8to11 actually control, it's not very intuitive for me to
see device 1 interrupt being handled in status_change_8to11?
Vijendar Mukunda Feb. 14, 2023, 9:24 p.m. UTC | #4
On 14/02/23 19:05, Pierre-Louis Bossart wrote:
>
>>>>  static void amd_sdw_irq_thread(struct work_struct *work)
>>>>  {
>>>>  	struct amd_sdw_manager *amd_manager =
>>>> @@ -945,6 +952,9 @@ static void amd_sdw_irq_thread(struct work_struct *work)
>>>>  	status_change_0to7 = acp_reg_readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7);
>>>>  	dev_dbg(amd_manager->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n",
>>>>  		__func__, amd_manager->instance, status_change_0to7, status_change_8to11);
>>>> +	if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK)
>>>> +		return amd_sdw_process_wake_event(amd_manager);
>>>> +
>>> it's not clear what 8to11 might have to do with the wake enable?
>>>
>>> Can't you have a wake for devices 1..7?
>> It can wake any device from 1..11 .
>> SoundWire Wake interrupt status bit is part of 8to11 register.
> You probably want to explain what status_change_0to7 and
> status_change_8to11 actually control, it's not very intuitive for me to
> see device 1 interrupt being handled in status_change_8to11?
Peripheral device status interrupts on manager side will be read by reading
0to7 (for devices 1..7) and 8to11 (for devices 8 ..11) registers.
8to11 register will contain field for reading Soundwire wake enable status
for Soundwire manager instance.
diff mbox series

Patch

diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
index eced189ba6e0..e53dc67f8529 100644
--- a/drivers/soundwire/amd_manager.c
+++ b/drivers/soundwire/amd_manager.c
@@ -934,6 +934,13 @@  static void amd_sdw_update_slave_status(u32 status_change_0to7, u32 status_chang
 	}
 }
 
+static void amd_sdw_process_wake_event(struct amd_sdw_manager *amd_manager)
+{
+	pm_request_resume(amd_manager->dev);
+	acp_reg_writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance));
+	acp_reg_writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11);
+}
+
 static void amd_sdw_irq_thread(struct work_struct *work)
 {
 	struct amd_sdw_manager *amd_manager =
@@ -945,6 +952,9 @@  static void amd_sdw_irq_thread(struct work_struct *work)
 	status_change_0to7 = acp_reg_readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7);
 	dev_dbg(amd_manager->dev, "%s [SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n",
 		__func__, amd_manager->instance, status_change_0to7, status_change_8to11);
+	if (status_change_8to11 & AMD_SDW_WAKE_STAT_MASK)
+		return amd_sdw_process_wake_event(amd_manager);
+
 	if (status_change_8to11 & AMD_SDW_PREQ_INTR_STAT) {
 		amd_sdw_read_and_process_ping_status(amd_manager);
 	} else {
diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h
index 6ec37612ae4e..86bc6d4f48bf 100644
--- a/drivers/soundwire/amd_manager.h
+++ b/drivers/soundwire/amd_manager.h
@@ -190,6 +190,7 @@ 
 #define AMD_SDW_CLK_STOP_DONE				1
 #define AMD_SDW_CLK_RESUME_REQ				2
 #define AMD_SDW_CLK_RESUME_DONE				3
+#define AMD_SDW_WAKE_STAT_MASK				BIT(16)
 
 enum amd_sdw_cmd_type {
 	AMD_SDW_CMD_PING = 0,