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 max98363_address
= {
14 .version
= SOUNDWIRE_VERSION_1_2
,
15 .manufacturer_id
= MIPI_MFG_ID_MAXIM
,
16 .part_id
= MIPI_DEV_ID_MAXIM_MAX98363
,
17 .class = MIPI_CLASS_NONE
20 static struct soundwire_slave max98363_slave
= {
21 .wake_up_unavailable
= false,
22 .test_mode_supported
= false,
23 .clock_stop_mode1_supported
= true,
24 .simplified_clockstopprepare_sm_supported
= true,
25 .clockstopprepare_hard_reset_behavior
= false,
26 .highPHY_capable
= false,
27 .paging_supported
= false,
28 .bank_delay_supported
= false,
29 .port15_read_behavior
= false,
30 .source_port_list
= 0,
31 .sink_port_list
= SOUNDWIRE_PORT(1),
34 static struct soundwire_audio_mode max98363_audio_mode
= {
35 /* Bus frequency must be 2/4/8/16 divider of supported input frequencies. */
36 .bus_frequency_configs_count
= 19,
37 .bus_frequency_configs
= {
38 9600 * KHz
, 4800 * KHz
, 2400 * KHz
, 1200 * KHz
, /* 19.2 MHz */
39 11289600, 5644800, 2822400, 1411200, /* 22.5792 MHz */
40 12000 * KHz
, 6000 * KHz
, 3000 * KHz
, 1500 * KHz
, /* 24 MHz */
41 12288 * KHz
, 6144 * KHz
, 3072 * KHz
, 1536 * KHz
, /* 24.576 MHz */
42 8000 * KHz
, 4000 * KHz
, 2000 * KHz
, /* 32 MHz (no /2) */
44 /* Support 16 KHz to 96 KHz sampling frequency */
45 .sampling_frequency_configs_count
= 8,
46 .sampling_frequency_configs
= {
56 .prepare_channel_behavior
= CHANNEL_PREPARE_ANY_FREQUENCY
59 static struct soundwire_dpn max98363_dp1
= {
60 .port_wordlength_configs_count
= 1,
61 .port_wordlength_configs
= { 32 },
62 .data_port_type
= FULL_DATA_PORT
,
63 .max_grouping_supported
= BLOCK_GROUP_COUNT_1
,
64 .simplified_channelprepare_sm
= false,
65 .imp_def_dpn_interrupts_supported
= 0,
66 .min_channel_number
= 1,
67 .max_channel_number
= 1,
68 .modes_supported
= MODE_ISOCHRONOUS
| MODE_TX_CONTROLLED
|
69 MODE_RX_CONTROLLED
| MODE_FULL_ASYNCHRONOUS
,
70 .block_packing_mode
= true,
71 .port_audio_mode_count
= 1,
72 .port_audio_mode_list
= { 0 }
75 static const struct soundwire_codec max98363_codec
= {
76 .slave
= &max98363_slave
,
77 .audio_mode
= { &max98363_audio_mode
},
80 /* Data Input for Speaker Path */
87 static void soundwire_max98363_fill_ssdt(const struct device
*dev
)
89 struct drivers_soundwire_max98363_config
*config
= dev
->chip_info
;
90 const char *scope
= acpi_device_scope(dev
);
96 acpigen_write_scope(scope
);
97 acpigen_write_device(acpi_device_name(dev
));
99 /* Set codec address IDs. */
100 max98363_address
.link_id
= dev
->path
.generic
.id
;
101 max98363_address
.unique_id
= dev
->path
.generic
.subid
;
103 acpigen_write_ADR_soundwire_device(&max98363_address
);
104 acpigen_write_name_string("_DDN", config
->desc
? : dev
->chip_ops
->name
);
105 acpigen_write_STA(acpi_device_status(dev
));
107 dsd
= acpi_dp_new_table("_DSD");
108 soundwire_gen_codec(dsd
, &max98363_codec
, NULL
);
111 acpigen_pop_len(); /* Device */
112 acpigen_pop_len(); /* Scope */
115 static const char *soundwire_max98363_acpi_name(const struct device
*dev
)
117 struct drivers_soundwire_max98363_config
*config
= dev
->chip_info
;
118 if (config
->acpi_name
[0] != 0)
119 return config
->acpi_name
;
120 snprintf(config
->acpi_name
, sizeof(config
->acpi_name
), "SW%1X%1X",
121 dev
->path
.generic
.id
, dev
->path
.generic
.subid
);
122 return config
->acpi_name
;
125 static struct device_operations soundwire_max98363_ops
= {
126 .read_resources
= noop_read_resources
,
127 .set_resources
= noop_set_resources
,
128 .acpi_name
= soundwire_max98363_acpi_name
,
129 .acpi_fill_ssdt
= soundwire_max98363_fill_ssdt
,
132 static void soundwire_max98363_enable(struct device
*dev
)
134 dev
->ops
= &soundwire_max98363_ops
;
137 struct chip_operations drivers_soundwire_max98363_ops
= {
138 .name
= "Maxim MAX98363 SoundWire Codec",
139 .enable_dev
= soundwire_max98363_enable