Skip to content

Commit 7b54323

Browse files
vijendarmukundavinodkoul
authored andcommitted
soundwire: amd: refactor existing code for acp 6.3 platform
Refactor existing code by adding acp pci revision id coditional checks for ACP 6.3 platform. Rename the macros and structure names with ACP63 tag. Signed-off-by: Vijendar Mukunda <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent ced20ea commit 7b54323

File tree

3 files changed

+72
-43
lines changed

3 files changed

+72
-43
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,18 @@ static int amd_sdw_port_params(struct sdw_bus *bus, struct sdw_port_params *p_pa
433433
u32 frame_fmt_reg, dpn_frame_fmt;
434434

435435
dev_dbg(amd_manager->dev, "p_params->num:0x%x\n", p_params->num);
436-
switch (amd_manager->instance) {
437-
case ACP_SDW0:
438-
frame_fmt_reg = sdw0_manager_dp_reg[p_params->num].frame_fmt_reg;
439-
break;
440-
case ACP_SDW1:
441-
frame_fmt_reg = sdw1_manager_dp_reg[p_params->num].frame_fmt_reg;
436+
switch (amd_manager->acp_rev) {
437+
case ACP63_PCI_REV_ID:
438+
switch (amd_manager->instance) {
439+
case ACP_SDW0:
440+
frame_fmt_reg = acp63_sdw0_dp_reg[p_params->num].frame_fmt_reg;
441+
break;
442+
case ACP_SDW1:
443+
frame_fmt_reg = acp63_sdw1_dp_reg[p_params->num].frame_fmt_reg;
444+
break;
445+
default:
446+
return -EINVAL;
447+
}
442448
break;
443449
default:
444450
return -EINVAL;
@@ -465,20 +471,28 @@ static int amd_sdw_transport_params(struct sdw_bus *bus,
465471
u32 frame_fmt_reg, sample_int_reg, hctrl_dp0_reg;
466472
u32 offset_reg, lane_ctrl_ch_en_reg;
467473

468-
switch (amd_manager->instance) {
469-
case ACP_SDW0:
470-
frame_fmt_reg = sdw0_manager_dp_reg[params->port_num].frame_fmt_reg;
471-
sample_int_reg = sdw0_manager_dp_reg[params->port_num].sample_int_reg;
472-
hctrl_dp0_reg = sdw0_manager_dp_reg[params->port_num].hctrl_dp0_reg;
473-
offset_reg = sdw0_manager_dp_reg[params->port_num].offset_reg;
474-
lane_ctrl_ch_en_reg = sdw0_manager_dp_reg[params->port_num].lane_ctrl_ch_en_reg;
475-
break;
476-
case ACP_SDW1:
477-
frame_fmt_reg = sdw1_manager_dp_reg[params->port_num].frame_fmt_reg;
478-
sample_int_reg = sdw1_manager_dp_reg[params->port_num].sample_int_reg;
479-
hctrl_dp0_reg = sdw1_manager_dp_reg[params->port_num].hctrl_dp0_reg;
480-
offset_reg = sdw1_manager_dp_reg[params->port_num].offset_reg;
481-
lane_ctrl_ch_en_reg = sdw1_manager_dp_reg[params->port_num].lane_ctrl_ch_en_reg;
474+
switch (amd_manager->acp_rev) {
475+
case ACP63_PCI_REV_ID:
476+
switch (amd_manager->instance) {
477+
case ACP_SDW0:
478+
frame_fmt_reg = acp63_sdw0_dp_reg[params->port_num].frame_fmt_reg;
479+
sample_int_reg = acp63_sdw0_dp_reg[params->port_num].sample_int_reg;
480+
hctrl_dp0_reg = acp63_sdw0_dp_reg[params->port_num].hctrl_dp0_reg;
481+
offset_reg = acp63_sdw0_dp_reg[params->port_num].offset_reg;
482+
lane_ctrl_ch_en_reg =
483+
acp63_sdw0_dp_reg[params->port_num].lane_ctrl_ch_en_reg;
484+
break;
485+
case ACP_SDW1:
486+
frame_fmt_reg = acp63_sdw1_dp_reg[params->port_num].frame_fmt_reg;
487+
sample_int_reg = acp63_sdw1_dp_reg[params->port_num].sample_int_reg;
488+
hctrl_dp0_reg = acp63_sdw1_dp_reg[params->port_num].hctrl_dp0_reg;
489+
offset_reg = acp63_sdw1_dp_reg[params->port_num].offset_reg;
490+
lane_ctrl_ch_en_reg =
491+
acp63_sdw1_dp_reg[params->port_num].lane_ctrl_ch_en_reg;
492+
break;
493+
default:
494+
return -EINVAL;
495+
}
482496
break;
483497
default:
484498
return -EINVAL;
@@ -520,12 +534,20 @@ static int amd_sdw_port_enable(struct sdw_bus *bus,
520534
u32 dpn_ch_enable;
521535
u32 lane_ctrl_ch_en_reg;
522536

523-
switch (amd_manager->instance) {
524-
case ACP_SDW0:
525-
lane_ctrl_ch_en_reg = sdw0_manager_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg;
526-
break;
527-
case ACP_SDW1:
528-
lane_ctrl_ch_en_reg = sdw1_manager_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg;
537+
switch (amd_manager->acp_rev) {
538+
case ACP63_PCI_REV_ID:
539+
switch (amd_manager->instance) {
540+
case ACP_SDW0:
541+
lane_ctrl_ch_en_reg =
542+
acp63_sdw0_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg;
543+
break;
544+
case ACP_SDW1:
545+
lane_ctrl_ch_en_reg =
546+
acp63_sdw1_dp_reg[enable_ch->port_num].lane_ctrl_ch_en_reg;
547+
break;
548+
default:
549+
return -EINVAL;
550+
}
529551
break;
530552
default:
531553
return -EINVAL;
@@ -927,15 +949,21 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
927949
* information.
928950
*/
929951
amd_manager->bus.controller_id = 0;
930-
931-
switch (amd_manager->instance) {
932-
case ACP_SDW0:
933-
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
934-
amd_manager->num_din_ports = AMD_SDW0_MAX_RX_PORTS;
935-
break;
936-
case ACP_SDW1:
937-
amd_manager->num_dout_ports = AMD_SDW1_MAX_TX_PORTS;
938-
amd_manager->num_din_ports = AMD_SDW1_MAX_RX_PORTS;
952+
dev_dbg(dev, "acp_rev:0x%x\n", amd_manager->acp_rev);
953+
switch (amd_manager->acp_rev) {
954+
case ACP63_PCI_REV_ID:
955+
switch (amd_manager->instance) {
956+
case ACP_SDW0:
957+
amd_manager->num_dout_ports = AMD_ACP63_SDW0_MAX_TX_PORTS;
958+
amd_manager->num_din_ports = AMD_ACP63_SDW0_MAX_RX_PORTS;
959+
break;
960+
case ACP_SDW1:
961+
amd_manager->num_dout_ports = AMD_ACP63_SDW1_MAX_TX_PORTS;
962+
amd_manager->num_din_ports = AMD_ACP63_SDW1_MAX_RX_PORTS;
963+
break;
964+
default:
965+
return -EINVAL;
966+
}
939967
break;
940968
default:
941969
return -EINVAL;

drivers/soundwire/amd_manager.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@
155155
#define AMD_SDW_IRQ_MASK_8TO11 0x000c7777
156156
#define AMD_SDW_IRQ_ERROR_MASK 0xff
157157
#define AMD_SDW_MAX_FREQ_NUM 1
158-
#define AMD_SDW0_MAX_TX_PORTS 3
159-
#define AMD_SDW0_MAX_RX_PORTS 3
160-
#define AMD_SDW1_MAX_TX_PORTS 1
161-
#define AMD_SDW1_MAX_RX_PORTS 1
162-
#define AMD_SDW0_MAX_DAI 6
163-
#define AMD_SDW1_MAX_DAI 2
158+
#define AMD_ACP63_SDW0_MAX_TX_PORTS 3
159+
#define AMD_ACP63_SDW0_MAX_RX_PORTS 3
160+
#define AMD_ACP63_SDW1_MAX_TX_PORTS 1
161+
#define AMD_ACP63_SDW1_MAX_RX_PORTS 1
162+
#define AMD_ACP63_SDW0_MAX_DAI 6
163+
#define AMD_ACP63_SDW1_MAX_DAI 2
164164
#define AMD_SDW_SLAVE_0_ATTACHED 5
165165
#define AMD_SDW_SSP_COUNTER_VAL 3
166166

@@ -222,7 +222,7 @@ struct sdw_manager_dp_reg {
222222
* in SoundWire DMA driver.
223223
*/
224224

225-
static struct sdw_manager_dp_reg sdw0_manager_dp_reg[AMD_SDW0_MAX_DAI] = {
225+
static struct sdw_manager_dp_reg acp63_sdw0_dp_reg[AMD_ACP63_SDW0_MAX_DAI] = {
226226
{ACP_SW_AUDIO0_TX_FRAME_FORMAT, ACP_SW_AUDIO0_TX_SAMPLEINTERVAL, ACP_SW_AUDIO0_TX_HCTRL_DP0,
227227
ACP_SW_AUDIO0_TX_OFFSET_DP0, ACP_SW_AUDIO0_TX_CHANNEL_ENABLE_DP0},
228228
{ACP_SW_AUDIO1_TX_FRAME_FORMAT, ACP_SW_AUDIO1_TX_SAMPLEINTERVAL, ACP_SW_AUDIO1_TX_HCTRL,
@@ -237,7 +237,7 @@ static struct sdw_manager_dp_reg sdw0_manager_dp_reg[AMD_SDW0_MAX_DAI] = {
237237
ACP_SW_AUDIO2_RX_OFFSET, ACP_SW_AUDIO2_RX_CHANNEL_ENABLE_DP0},
238238
};
239239

240-
static struct sdw_manager_dp_reg sdw1_manager_dp_reg[AMD_SDW1_MAX_DAI] = {
240+
static struct sdw_manager_dp_reg acp63_sdw1_dp_reg[AMD_ACP63_SDW1_MAX_DAI] = {
241241
{ACP_SW_AUDIO1_TX_FRAME_FORMAT, ACP_SW_AUDIO1_TX_SAMPLEINTERVAL, ACP_SW_AUDIO1_TX_HCTRL,
242242
ACP_SW_AUDIO1_TX_OFFSET, ACP_SW_AUDIO1_TX_CHANNEL_ENABLE_DP0},
243243
{ACP_SW_AUDIO1_RX_FRAME_FORMAT, ACP_SW_AUDIO1_RX_SAMPLEINTERVAL, ACP_SW_AUDIO1_RX_HCTRL,

include/linux/soundwire/sdw_amd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define ACP_SDW0 0
2828
#define ACP_SDW1 1
2929
#define AMD_SDW_MAX_MANAGER_COUNT 2
30+
#define ACP63_PCI_REV_ID 0x63
3031

3132
struct acp_sdw_pdata {
3233
u16 instance;

0 commit comments

Comments
 (0)