coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
alc711.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
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/path.h>
8 #include <device/soundwire.h>
9 #include <mipi/ids.h>
10 #include <stdio.h>
11 
12 #include "chip.h"
13 
14 static struct soundwire_address alc711_address = {
16  .manufacturer_id = MIPI_MFG_ID_REALTEK,
17  .part_id = MIPI_DEV_ID_REALTEK_ALC711,
18  .class = MIPI_CLASS_NONE
19 };
20 
21 static struct soundwire_slave alc711_slave = {
22  .wake_up_unavailable = false,
23  .test_mode_supported = false,
24  .clock_stop_mode1_supported = true,
25  .simplified_clockstopprepare_sm_supported = true,
26  .clockstopprepare_hard_reset_behavior = false,
27  .highPHY_capable = false,
28  .paging_supported = false,
29  .bank_delay_supported = false,
30  .port15_read_behavior = false,
31  .source_port_list = SOUNDWIRE_PORT(2),
32  .sink_port_list = SOUNDWIRE_PORT(1),
33 };
34 
36  /* Bus frequency must be 1/2/4/8 divider of supported input frequencies. */
38  .bus_frequency_configs = {
39  9600 * KHz,
40  4800 * KHz,
41  2400 * KHz,
42  1200 * KHz,
43  12000 * KHz,
44  6000 * KHz,
45  3000 * KHz,
46  1500 * KHz,
47  12288 * KHz,
48  6144 * KHz,
49  3072 * KHz,
50  1536 * KHz
51  },
52  /* Support 16 KHz to 192 KHz sampling frequency */
53  .sampling_frequency_configs_count = 9,
54  .sampling_frequency_configs = {
55  16 * KHz,
56  22.05 * KHz,
57  24 * KHz,
58  32 * KHz,
59  44.1 * KHz,
60  48 * KHz,
61  88.2 * KHz,
62  96 * KHz,
63  192 * KHz
64  },
65  .prepare_channel_behavior = CHANNEL_PREPARE_ANY_FREQUENCY
66 };
67 
68 static struct soundwire_dpn alc711_dp = {
70  .port_wordlength_configs = { 32 },
71  .data_port_type = FULL_DATA_PORT,
72  .max_grouping_supported = BLOCK_GROUP_COUNT_1,
73  .simplified_channelprepare_sm = false,
74  .imp_def_dpn_interrupts_supported = 0,
75  .min_channel_number = 1,
76  .max_channel_number = 2,
77  .modes_supported = MODE_ISOCHRONOUS | MODE_TX_CONTROLLED |
79  .block_packing_mode = true,
80  .port_audio_mode_count = 1,
81  .port_audio_mode_list = { 0 }
82 };
83 
84 static const struct soundwire_codec alc711_codec = {
85  .slave = &alc711_slave,
86  .audio_mode = { &alc711_audio_mode },
87  .dpn = {
88  {
89  /* Data Input for Speaker Path */
90  .port = 1,
91  .sink = &alc711_dp
92  },
93  {
94  /* Data Output for DSP Path */
95  .port = 2,
96  .source = &alc711_dp
97  }
98  }
99 
100 };
101 
102 static void soundwire_alc711_fill_ssdt(const struct device *dev)
103 {
105  const char *scope = acpi_device_scope(dev);
106  struct acpi_dp *dsd;
107 
108  if (!scope)
109  return;
110 
111  acpigen_write_scope(scope);
113 
114  /* Set codec address IDs. */
117 
119  acpigen_write_name_string("_DDN", config->desc ? : dev->chip_ops->name);
121 
122  dsd = acpi_dp_new_table("_DSD");
124  acpi_dp_write(dsd);
125 
126  acpigen_pop_len(); /* Device */
127  acpigen_pop_len(); /* Scope */
128 }
129 
130 static const char *soundwire_alc711_acpi_name(const struct device *dev)
131 {
133  static char name[5];
134 
135  if (config->name)
136  return config->name;
137  snprintf(name, sizeof(name), "SW%1X%1X", dev->path.generic.id, dev->path.generic.subid);
138  return name;
139 }
140 
141 static struct device_operations soundwire_alc711_ops = {
143  .set_resources = noop_set_resources,
144  .acpi_name = soundwire_alc711_acpi_name,
145  .acpi_fill_ssdt = soundwire_alc711_fill_ssdt,
146 };
147 
148 static void soundwire_alc711_enable(struct device *dev)
149 {
150  dev->ops = &soundwire_alc711_ops;
151 }
152 
154  CHIP_NAME("Realtek ALC711 SoundWire Codec")
155  .enable_dev = soundwire_alc711_enable
156 };
void acpi_dp_write(struct acpi_dp *table)
Definition: device.c:898
int acpi_device_status(const struct device *dev)
Definition: device.c:193
const char * acpi_device_name(const struct device *dev)
Definition: device.c:49
struct acpi_dp * acpi_dp_new_table(const char *name)
Definition: device.c:930
const char * acpi_device_scope(const struct device *dev)
Definition: device.c:158
void soundwire_gen_codec(struct acpi_dp *dsd, const struct soundwire_codec *codec, soundwire_dp_prop_cb dp_prop_cb)
soundwire_gen_codec() - Generate SoundWire properties for codec device.
Definition: soundwire.c:338
void acpigen_pop_len(void)
Definition: acpigen.c:37
void acpigen_write_scope(const char *name)
Definition: acpigen.c:326
void acpigen_write_STA(uint8_t status)
Definition: acpigen.c:783
void acpigen_write_ADR_soundwire_device(const struct soundwire_address *address)
acpigen_write_ADR_soundwire_device() - SoundWire ACPI Device Address Encoding.
Definition: acpigen.c:2144
void acpigen_write_device(const char *name)
Definition: acpigen.c:769
void acpigen_write_name_string(const char *name, const char *string)
Definition: acpigen.c:176
struct chip_operations drivers_soundwire_alc711_ops
Definition: alc711.c:153
static const char * soundwire_alc711_acpi_name(const struct device *dev)
Definition: alc711.c:130
static struct soundwire_audio_mode alc711_audio_mode
Definition: alc711.c:35
static struct device_operations soundwire_alc711_ops
Definition: alc711.c:141
static struct soundwire_address alc711_address
Definition: alc711.c:14
static void soundwire_alc711_fill_ssdt(const struct device *dev)
Definition: alc711.c:102
static void soundwire_alc711_enable(struct device *dev)
Definition: alc711.c:148
static const struct soundwire_codec alc711_codec
Definition: alc711.c:84
static struct soundwire_slave alc711_slave
Definition: alc711.c:21
static struct soundwire_dpn alc711_dp
Definition: alc711.c:68
const char * name
Definition: mmu.c:92
#define KHz
Definition: helpers.h:79
#define MIPI_MFG_ID_REALTEK
Definition: ids.h:21
#define MIPI_DEV_ID_REALTEK_ALC711
Definition: ids.h:23
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define SOUNDWIRE_PORT(port)
Definition: soundwire.h:133
@ BLOCK_GROUP_COUNT_1
Definition: soundwire.h:265
@ MIPI_CLASS_NONE
Definition: soundwire.h:70
@ CHANNEL_PREPARE_ANY_FREQUENCY
Definition: soundwire.h:222
@ MODE_ISOCHRONOUS
Definition: soundwire.h:273
@ MODE_RX_CONTROLLED
Definition: soundwire.h:275
@ MODE_TX_CONTROLLED
Definition: soundwire.h:274
@ MODE_FULL_ASYNCHRONOUS
Definition: soundwire.h:276
@ FULL_DATA_PORT
Definition: soundwire.h:258
@ SOUNDWIRE_VERSION_1_1
Definition: soundwire.h:57
enum board_config config
Definition: memory.c:448
#define NULL
Definition: stddef.h:19
const char * name
Definition: device.h:29
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct generic_path generic
Definition: path.h:125
Definition: device.h:107
struct chip_operations * chip_ops
Definition: device.h:144
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int subid
Definition: path.h:97
unsigned int id
Definition: path.h:96
uint8_t link_id
Definition: soundwire.h:85
enum soundwire_version version
Definition: soundwire.h:84
uint8_t unique_id
Definition: soundwire.h:86
struct soundwire_audio_mode - Properties for each supported Audio Mode.
Definition: soundwire.h:243
size_t bus_frequency_configs_count
Definition: soundwire.h:246
struct soundwire_codec - Contains all configuration for a SoundWire codec slave device.
Definition: soundwire.h:419
struct soundwire_slave * slave
Definition: soundwire.h:420
struct soundwire_dpn - Configuration properties for SoundWire DPn Data Ports.
Definition: soundwire.h:318
size_t port_wordlength_configs_count
Definition: soundwire.h:321
struct soundwire_slave - SoundWire slave device properties.
Definition: soundwire.h:156
bool wake_up_unavailable
Definition: soundwire.h:157
int snprintf(char *buf, size_t size, const char *fmt,...)
Note: This file is only for POSIX compatibility, and is meant to be chain-included via string....
Definition: vsprintf.c:35