From: Vinod Koul <vkoul@kernel.org>
To: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Cc: broonie@kernel.org, alsa-devel@alsa-project.org,
yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
Basavaraj.Hiregoudar@amd.com, Sunil-kumar.Dommati@amd.com,
venkataprasad.potturu@amd.com, Syed.SabaKareem@amd.com,
Mario.Limonciello@amd.com, Richard.Gong@amd.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/9] soundwire: amd: introduce struct amd_sdw_hw_ops dispatch framework
Date: Sat, 3 Oct 2026 09:56:23 +0200 [thread overview]
Message-ID: <asC1JwByZaJ8B2Pr@parshuram> (raw)
In-Reply-To: <20260917090407.3828816-7-Vijendar.Mukunda@amd.com>
On 17-09-26, 14:32, Vijendar Mukunda wrote:
> Add struct amd_sdw_hw_ops, a function-pointer dispatch table for
> hardware-revision-specific SoundWire manager operations. Add inline
> dispatch helpers for each callback and a const hw_ops pointer in
> struct amd_sdw_manager.
>
> The irq_thread and update_slave_status_work slots take
> struct amd_sdw_manager * so that different ACP revisions can register
> different handler logic. hw_ops is populated and call sites are wired
> through the dispatch helpers in subsequent patches.
Lets solve with one more level! Do you really need this...
>
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> ---
> drivers/soundwire/amd_manager.h | 193 ++++++++++++++++++++++++++++++
> include/linux/soundwire/sdw_amd.h | 4 +
> 2 files changed, 197 insertions(+)
>
> diff --git a/drivers/soundwire/amd_manager.h b/drivers/soundwire/amd_manager.h
> index 63fecff62079..2d08c6edd018 100644
> --- a/drivers/soundwire/amd_manager.h
> +++ b/drivers/soundwire/amd_manager.h
> @@ -274,4 +274,197 @@ static u32 sdw_manager_reg_mask_array[AMD_ACP63_SDW_MAX_MANAGER_COUNT] = {
> AMD_SDW0_EXT_INTR_MASK,
> AMD_SDW1_EXT_INTR_MASK
> };
> +
> +#define AMD_SDW_HW_OPS(amd_manager, cb) ((amd_manager)->hw_ops->cb)
> +
> +/**
> + * struct amd_sdw_hw_ops - hardware-revision-specific SoundWire manager ops
> + *
> + * @init_sdw_manager: enable the SoundWire manager hardware and perform bus reset
> + * @enable_sdw_manager: set the manager enable bit and wait for it to assert
> + * @disable_sdw_manager: clear the manager enable bit and wait for it to deassert
> + * @enable_sdw_interrupts: unmask ACP-level and per-manager interrupt bits
> + * @disable_sdw_interrupts: mask ACP-level and per-manager interrupt bits
> + * @set_frameshape: write the row/column frame-shape register
> + * @send_cmd_get_resp: issue an immediate command and return the response;
> + * returns 0 on success with the raw u64 response in @response,
> + * or negative on hardware timeout
> + * @wake_enable: enable or disable the in-band SoundWire wake interrupt
> + * @host_wake_enable: enable or disable the host-side wake interrupt
> + * @set_device_state: write the D0/D3 device power state for the manager instance
> + * @read_and_process_ping_status: issue a PING command and process the slave
> + * attach/detach status; called from the IRQ work path
> + * @process_wake_event: handle an in-band wake notification from a slave
> + * @irq_thread: hw_ops callback invoked by the thin work_struct wrapper on
> + * each interrupt; reads status registers and dispatches slave events
> + * @update_slave_status_work: hw_ops callback invoked by the status-update
> + * work item; reads slave status and updates the SoundWire core
> + * @clk_init_ctrl: set the clock divider and update the frame shape registers
> + * based on the current bus clock frequency
> + * @clock_stop_exit: restart the SoundWire bus clock after a CLK_STOP_MODE
> + * suspend; implementation differs across ACP revisions
> + * @suspend: system-suspend hook; stops the bus and powers down the manager
> + * @suspend_runtime: runtime-suspend hook; same sequence as @suspend
> + * @resume_runtime: runtime-resume hook; reinitialises the manager and restarts
> + * the bus after a POWER_OFF_MODE or CLK_STOP_MODE suspend
> + */
> +struct amd_sdw_hw_ops {
> + int (*init_sdw_manager)(struct amd_sdw_manager *amd_manager);
> + int (*enable_sdw_manager)(struct amd_sdw_manager *amd_manager);
> + int (*disable_sdw_manager)(struct amd_sdw_manager *amd_manager);
> + void (*enable_sdw_interrupts)(struct amd_sdw_manager *amd_manager);
> + void (*disable_sdw_interrupts)(struct amd_sdw_manager *amd_manager);
> + void (*set_frameshape)(struct amd_sdw_manager *amd_manager);
> + int (*send_cmd_get_resp)(struct amd_sdw_manager *amd_manager, u32 lower_data,
> + u32 upper_data, u64 *response);
> + void (*wake_enable)(struct amd_sdw_manager *amd_manager, bool enable);
> + int (*host_wake_enable)(struct amd_sdw_manager *amd_manager, bool enable);
> + int (*set_device_state)(struct amd_sdw_manager *amd_manager, u32 target_device_state);
> + void (*read_and_process_ping_status)(struct amd_sdw_manager *amd_manager);
> + void (*process_wake_event)(struct amd_sdw_manager *amd_manager);
> + void (*irq_thread)(struct amd_sdw_manager *amd_manager);
> + void (*update_slave_status_work)(struct amd_sdw_manager *amd_manager);
> + int (*clk_init_ctrl)(struct amd_sdw_manager *amd_manager);
> + int (*clock_stop_exit)(struct amd_sdw_manager *amd_manager);
> + int (*suspend)(struct amd_sdw_manager *amd_manager);
> + int (*suspend_runtime)(struct amd_sdw_manager *amd_manager);
> + int (*resume_runtime)(struct amd_sdw_manager *amd_manager);
I would suggest splitting the driver and add common code to a lib and
have specific drivers for older and new gen platforms...
--
~Vinod
next prev parent reply other threads:[~2026-10-03 7:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 9:02 [PATCH 0/9] soundwire: amd: introduce hw_ops dispatch and consolidate probe setup Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 1/9] soundwire: amd: rename AMD_SDW_MAX_MANAGER_COUNT macro Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 2/9] soundwire: amd: allocate pdevinfo and sdw_pdata by ACP revision in probe Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 3/9] soundwire: amd: allocate sdw_amd_ctx pdev array dynamically Vijendar Mukunda
2026-10-03 7:52 ` Vinod Koul
2026-09-17 9:02 ` [PATCH 4/9] soundwire: amd: rename hardware backend functions to amd_acp63_*() prefix Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 5/9] soundwire: amd: remove unused AMD_SDW_MAX_FREQ_NUM define Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 6/9] soundwire: amd: introduce struct amd_sdw_hw_ops dispatch framework Vijendar Mukunda
2026-10-03 7:56 ` Vinod Koul [this message]
2026-09-17 9:02 ` [PATCH 7/9] soundwire: amd: convert irq/work handlers to hw_ops callbacks Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 8/9] soundwire: amd: wire amd_acp63_*() call sites through acp_*() helpers Vijendar Mukunda
2026-09-17 9:02 ` [PATCH 9/9] soundwire: amd: consolidate revision-specific probe setup Vijendar Mukunda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=asC1JwByZaJ8B2Pr@parshuram \
--to=vkoul@kernel.org \
--cc=Basavaraj.Hiregoudar@amd.com \
--cc=Mario.Limonciello@amd.com \
--cc=Richard.Gong@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=Syed.SabaKareem@amd.com \
--cc=Vijendar.Mukunda@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=venkataprasad.potturu@amd.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®