1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <acpi/acpi_device.h>
5 #include <acpi/acpi_soundwire.h>
6 #include <device/device.h>
7 #include <device/soundwire.h>
13 static struct soundwire_address alc711_address
= {
14 #if CONFIG(DRIVERS_SOUNDWIRE_ALC722)
15 .version
= SOUNDWIRE_VERSION_1_2
,
16 .part_id
= MIPI_DEV_ID_REALTEK_ALC722
,
17 .class = MIPI_CLASS_SDCA
,
18 #elif CONFIG(DRIVERS_SOUNDWIRE_ALC721)
19 .version
= SOUNDWIRE_VERSION_1_2
,
20 .part_id
= MIPI_DEV_ID_REALTEK_ALC721
,
21 .class = MIPI_CLASS_SDCA
,
22 #elif CONFIG(DRIVERS_SOUNDWIRE_ALC711)
23 .version
= SOUNDWIRE_VERSION_1_1
,
24 .part_id
= MIPI_DEV_ID_REALTEK_ALC711
,
25 .class = MIPI_CLASS_NONE
,
27 #error "No Realtek SoundWire codec selected"
29 .manufacturer_id
= MIPI_MFG_ID_REALTEK
,
32 static struct soundwire_slave alc711_slave
= {
33 .wake_up_unavailable
= false,
34 .test_mode_supported
= false,
35 .clock_stop_mode1_supported
= true,
36 .simplified_clockstopprepare_sm_supported
= true,
37 .clockstopprepare_hard_reset_behavior
= false,
38 .highPHY_capable
= false,
39 .paging_supported
= false,
40 .bank_delay_supported
= false,
41 .port15_read_behavior
= false,
42 .source_port_list
= SOUNDWIRE_PORT(2),
43 .sink_port_list
= SOUNDWIRE_PORT(1),
46 static struct soundwire_audio_mode alc711_audio_mode
= {
47 /* Bus frequency must be 1/2/4/8 divider of supported input frequencies. */
48 .bus_frequency_configs_count
= 12,
49 .bus_frequency_configs
= {
63 /* Support 16 KHz to 192 KHz sampling frequency */
64 .sampling_frequency_configs_count
= 9,
65 .sampling_frequency_configs
= {
76 .prepare_channel_behavior
= CHANNEL_PREPARE_ANY_FREQUENCY
79 static struct soundwire_dpn alc711_dp
= {
80 .port_wordlength_configs_count
= 1,
81 .port_wordlength_configs
= { 32 },
82 .data_port_type
= FULL_DATA_PORT
,
83 .max_grouping_supported
= BLOCK_GROUP_COUNT_1
,
84 .simplified_channelprepare_sm
= false,
85 .imp_def_dpn_interrupts_supported
= 0,
86 .min_channel_number
= 1,
87 .max_channel_number
= 2,
88 .modes_supported
= MODE_ISOCHRONOUS
| MODE_TX_CONTROLLED
|
89 MODE_RX_CONTROLLED
| MODE_FULL_ASYNCHRONOUS
,
90 .block_packing_mode
= true,
91 .port_audio_mode_count
= 1,
92 .port_audio_mode_list
= { 0 }
95 static const struct soundwire_codec alc711_codec
= {
96 .slave
= &alc711_slave
,
97 .audio_mode
= { &alc711_audio_mode
},
100 /* Data Input for Speaker Path */
105 /* Data Output for DSP Path */
113 static void soundwire_alc711_fill_ssdt(const struct device
*dev
)
115 struct drivers_soundwire_alc711_config
*config
= dev
->chip_info
;
116 const char *scope
= acpi_device_scope(dev
);
122 acpigen_write_scope(scope
);
123 acpigen_write_device(acpi_device_name(dev
));
125 /* Set codec address IDs. */
126 alc711_address
.link_id
= dev
->path
.generic
.id
;
127 alc711_address
.unique_id
= dev
->path
.generic
.subid
;
129 acpigen_write_ADR_soundwire_device(&alc711_address
);
130 acpigen_write_name_string("_DDN", config
->desc
? : dev
->chip_ops
->name
);
131 acpigen_write_STA(acpi_device_status(dev
));
133 dsd
= acpi_dp_new_table("_DSD");
134 soundwire_gen_codec(dsd
, &alc711_codec
, NULL
);
137 acpigen_pop_len(); /* Device */
138 acpigen_pop_len(); /* Scope */
141 static const char *soundwire_alc711_acpi_name(const struct device
*dev
)
143 struct drivers_soundwire_alc711_config
*config
= dev
->chip_info
;
148 snprintf(name
, sizeof(name
), "SW%1X%1X", dev
->path
.generic
.id
, dev
->path
.generic
.subid
);
152 static struct device_operations soundwire_alc711_ops
= {
153 .read_resources
= noop_read_resources
,
154 .set_resources
= noop_set_resources
,
155 .acpi_name
= soundwire_alc711_acpi_name
,
156 .acpi_fill_ssdt
= soundwire_alc711_fill_ssdt
,
159 static void soundwire_alc711_enable(struct device
*dev
)
161 dev
->ops
= &soundwire_alc711_ops
;
164 struct chip_operations drivers_soundwire_alc711_ops
= {
165 #if CONFIG(DRIVERS_SOUNDWIRE_ALC_BASE_7XX)
166 .name
= "Realtek ALC 7 Series SoundWire Codec",
170 .enable_dev
= soundwire_alc711_enable