Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 2 | |
| 3 | #ifndef DEVICE_AZALIA_H |
| 4 | #define DEVICE_AZALIA_H |
| 5 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 6 | #include <acpi/acpi.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 7 | #include <device/mmio.h> |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 8 | #include <device/device.h> |
Elyes HAOUAS | 6d097b8 | 2020-08-03 15:42:23 +0200 | [diff] [blame] | 9 | #include <stdint.h> |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 10 | |
Elyes HAOUAS | 899d5bde | 2020-08-03 15:00:46 +0200 | [diff] [blame] | 11 | #define HDA_GCAP_REG 0x00 |
| 12 | #define HDA_GCTL_REG 0x08 |
| 13 | #define HDA_GCTL_CRST (1 << 0) |
| 14 | #define HDA_STATESTS_REG 0x0e |
| 15 | #define HDA_IC_REG 0x60 |
| 16 | #define HDA_IR_REG 0x64 |
| 17 | #define HDA_ICII_REG 0x68 |
| 18 | #define HDA_ICII_BUSY (1 << 0) |
| 19 | #define HDA_ICII_VALID (1 << 1) |
| 20 | |
Angel Pons | 61dd836 | 2020-12-05 18:02:32 +0100 | [diff] [blame] | 21 | int azalia_set_bits(void *port, u32 mask, u32 val); |
Angel Pons | 4919028 | 2020-12-05 18:52:38 +0100 | [diff] [blame] | 22 | int azalia_enter_reset(u8 *base); |
| 23 | int azalia_exit_reset(u8 *base); |
Angel Pons | d425ddd | 2020-12-05 18:22:58 +0100 | [diff] [blame] | 24 | u32 azalia_find_verb(const u32 *verb_table, u32 verb_table_bytes, u32 viddid, const u32 **verb); |
Angel Pons | 44c431e | 2021-02-08 12:37:56 +0100 | [diff] [blame] | 25 | int azalia_program_verb_table(u8 *base, const u32 *verbs, u32 verb_size); |
Angel Pons | 86dfd3c | 2021-11-10 17:58:12 +0100 | [diff] [blame] | 26 | void azalia_codec_init(u8 *base, int addr, const u32 *verb_table, u32 verb_table_bytes); |
Angel Pons | aae6b55 | 2021-11-10 18:10:38 +0100 | [diff] [blame] | 27 | void azalia_codecs_init(u8 *base, u16 codec_mask); |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 28 | void azalia_audio_init(struct device *dev); |
| 29 | extern struct device_operations default_azalia_audio_ops; |
| 30 | |
Angel Pons | d6d71ce | 2021-02-08 12:47:29 +0100 | [diff] [blame] | 31 | /* Optional hook to program codec settings that are only known at runtime */ |
| 32 | void mainboard_azalia_program_runtime_verbs(u8 *base, u32 viddid); |
| 33 | |
Vladimir Serbinenko | 75c8387 | 2014-09-05 01:01:31 +0200 | [diff] [blame] | 34 | extern const u32 cim_verb_data[]; |
| 35 | extern const u32 cim_verb_data_size; |
| 36 | extern const u32 pc_beep_verbs[]; |
| 37 | extern const u32 pc_beep_verbs_size; |
| 38 | |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 39 | enum azalia_pin_connection { |
| 40 | JACK = 0, |
| 41 | NC, |
| 42 | INTEGRATED, |
| 43 | JACK_AND_INTEGRATED, |
| 44 | }; |
| 45 | |
| 46 | enum azalia_pin_color { |
| 47 | COLOR_UNKNOWN = 0, |
| 48 | BLACK, |
| 49 | GREY, |
| 50 | BLUE, |
| 51 | GREEN, |
| 52 | RED, |
| 53 | ORANGE, |
| 54 | YELLOW, |
| 55 | PURPLE, |
| 56 | PINK, |
| 57 | WHITE = 0xe, |
| 58 | COLOR_OTHER = 0xf, |
| 59 | }; |
| 60 | |
| 61 | enum azalia_pin_type { |
| 62 | TYPE_UNKNOWN = 0, |
| 63 | STEREO_MONO_1_8, |
| 64 | STEREO_MONO_1_4, |
| 65 | ATAPI, |
| 66 | RCA, |
Patrick Rudolph | 9572dd8 | 2020-10-21 16:43:08 +0200 | [diff] [blame] | 67 | OPTICAL, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 68 | OTHER_DIGITAL, |
| 69 | OTHER_ANALOG, |
| 70 | MULTICHANNEL_ANALOG, |
| 71 | XLR, |
| 72 | RJ_11, |
| 73 | COMBINATION, |
| 74 | TYPE_OTHER = 0xf |
| 75 | }; |
| 76 | |
| 77 | enum azalia_pin_device { |
| 78 | LINE_OUT = 0, |
| 79 | SPEAKER, |
| 80 | HP_OUT, |
| 81 | CD, |
| 82 | SPDIF_OUT, |
| 83 | DIGITAL_OTHER_OUT, |
| 84 | MODEM_LINE_SIDE, |
| 85 | MODEM_HANDSET_SIDE, |
| 86 | LINE_IN, |
| 87 | AUX, |
| 88 | MIC_IN, |
| 89 | TELEPHONY, |
| 90 | SPDIF_IN, |
| 91 | DIGITAL_OTHER_IN, |
| 92 | DEVICE_OTHER = 0xf, |
| 93 | }; |
| 94 | |
| 95 | enum azalia_pin_location_1 { |
| 96 | NA = 0, |
| 97 | REAR, |
| 98 | FRONT, |
| 99 | LEFT, |
| 100 | RIGHT, |
| 101 | TOP, |
| 102 | BOTTOM, |
| 103 | SPECIAL7, |
| 104 | SPECIAL8, |
| 105 | SPECIAL9, |
| 106 | }; |
| 107 | |
| 108 | enum azalia_pin_location_2 { |
| 109 | EXTERNAL_PRIMARY_CHASSIS = 0, |
| 110 | INTERNAL, |
| 111 | SEPARATE_CHASSIS, |
| 112 | LOCATION_OTHER |
| 113 | }; |
| 114 | |
Nicholas Chin | 463a7bc | 2024-01-15 10:26:11 -0700 | [diff] [blame^] | 115 | enum azalia_pin_misc { |
| 116 | JACK_PRESENCE_DETECT = 0, |
| 117 | NO_JACK_PRESENCE_DETECT, |
| 118 | }; |
| 119 | |
| 120 | #define AZALIA_PIN_DESC(conn, location2, location1, dev, type, color, misc, \ |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 121 | association, sequence) \ |
| 122 | (((conn) << 30) | \ |
| 123 | ((location2) << 27) | \ |
| 124 | ((location1) << 24) | \ |
| 125 | ((dev) << 20) | \ |
| 126 | ((type) << 16) | \ |
| 127 | ((color) << 12) | \ |
Nicholas Chin | 463a7bc | 2024-01-15 10:26:11 -0700 | [diff] [blame^] | 128 | ((misc) << 8) | \ |
Patrick Rudolph | 15d6240 | 2020-08-28 10:59:45 +0200 | [diff] [blame] | 129 | ((association) << 4) | \ |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 130 | ((sequence) << 0)) |
| 131 | |
Lee Leahy | 6a566d7 | 2017-03-07 17:45:12 -0800 | [diff] [blame] | 132 | #define AZALIA_ARRAY_SIZES const u32 pc_beep_verbs_size = \ |
| 133 | ARRAY_SIZE(pc_beep_verbs); \ |
Vladimir Serbinenko | 75c8387 | 2014-09-05 01:01:31 +0200 | [diff] [blame] | 134 | const u32 cim_verb_data_size = sizeof(cim_verb_data) |
Vladimir Serbinenko | 6a3a8ce | 2014-08-17 23:48:42 +0200 | [diff] [blame] | 135 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 136 | #define AZALIA_VERB_12B(codec, pin, verb, val) \ |
| 137 | ((codec) << 28 | (pin) << 20 | (verb) << 8 | (val)) |
| 138 | |
| 139 | #define AZALIA_PIN_CFG(codec, pin, val) \ |
| 140 | AZALIA_VERB_12B(codec, pin, 0x71c, ((val) >> 0) & 0xff), \ |
| 141 | AZALIA_VERB_12B(codec, pin, 0x71d, ((val) >> 8) & 0xff), \ |
| 142 | AZALIA_VERB_12B(codec, pin, 0x71e, ((val) >> 16) & 0xff), \ |
| 143 | AZALIA_VERB_12B(codec, pin, 0x71f, ((val) >> 24) & 0xff) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 144 | |
Angel Pons | 779d0c6 | 2021-11-03 11:12:35 +0100 | [diff] [blame] | 145 | #define AZALIA_PIN_CFG_NC(n) (0x411111f0 | ((n) & 0xf)) |
Felix Singer | 1bdbcd7 | 2020-09-22 12:55:25 +0200 | [diff] [blame] | 146 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 147 | #define AZALIA_RESET(pin) \ |
| 148 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 149 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 150 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 151 | AZALIA_VERB_12B(0, pin, 0x7ff, 0) |
Lijian Zhao | 5c9237f | 2018-11-08 17:57:33 -0800 | [diff] [blame] | 152 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 153 | #define AZALIA_SUBVENDOR(codec, val) \ |
| 154 | AZALIA_VERB_12B(codec, 1, 0x720, ((val) >> 0) & 0xff), \ |
| 155 | AZALIA_VERB_12B(codec, 1, 0x721, ((val) >> 8) & 0xff), \ |
| 156 | AZALIA_VERB_12B(codec, 1, 0x722, ((val) >> 16) & 0xff), \ |
| 157 | AZALIA_VERB_12B(codec, 1, 0x723, ((val) >> 24) & 0xff) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 158 | |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 159 | #endif /* DEVICE_AZALIA_H */ |