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> |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 7 | #include <device/device.h> |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 8 | #include <device/mmio.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 | |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 39 | /* |
| 40 | * The tables found in this file are derived from the Intel High Definition |
| 41 | * Audio Specification Revision 1.0a, published 17 June 2010 |
| 42 | * |
| 43 | * 7.3.3.31 Configuration Default (page 177) |
| 44 | */ |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 45 | enum azalia_pin_connection { |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 46 | AZALIA_JACK = 0x0, |
| 47 | AZALIA_NC = 0x1, |
| 48 | AZALIA_INTEGRATED = 0x2, |
| 49 | AZALIA_JACK_AND_INTEGRATED = 0x3, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 52 | enum azalia_pin_location_gross { |
Nicholas Sudsgaard | 4e8bbc1 | 2024-02-25 09:32:33 +0900 | [diff] [blame] | 53 | AZALIA_EXTERNAL_PRIMARY_CHASSIS = 0x00, |
| 54 | AZALIA_INTERNAL = 0x10, |
| 55 | AZALIA_SEPARATE_CHASSIS = 0x20, |
| 56 | AZALIA_LOCATION_OTHER = 0x30, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 59 | enum azalia_pin_location_geometric { |
| 60 | AZALIA_GEOLOCATION_NA = 0x0, |
| 61 | AZALIA_REAR = 0x1, |
| 62 | AZALIA_FRONT = 0x2, |
| 63 | AZALIA_LEFT = 0x3, |
| 64 | AZALIA_RIGHT = 0x4, |
| 65 | AZALIA_TOP = 0x5, |
| 66 | AZALIA_BOTTOM = 0x6, |
| 67 | AZALIA_SPECIAL7 = 0x7, |
| 68 | AZALIA_SPECIAL8 = 0x8, |
| 69 | AZALIA_SPECIAL9 = 0x9, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
Nicholas Sudsgaard | 4e8bbc1 | 2024-02-25 09:32:33 +0900 | [diff] [blame] | 72 | enum azalia_pin_location_special { |
| 73 | AZALIA_REAR_PANEL = AZALIA_EXTERNAL_PRIMARY_CHASSIS | AZALIA_SPECIAL7, |
| 74 | AZALIA_DRIVE_BAY = AZALIA_EXTERNAL_PRIMARY_CHASSIS | AZALIA_SPECIAL8, |
| 75 | AZALIA_RISER = AZALIA_INTERNAL | AZALIA_SPECIAL7, |
| 76 | AZALIA_DIGITAL_DISPLAY = AZALIA_INTERNAL | AZALIA_SPECIAL8, |
| 77 | AZALIA_ATAPI = AZALIA_INTERNAL | AZALIA_SPECIAL9, |
| 78 | AZALIA_MOBILE_LID_INSIDE = AZALIA_LOCATION_OTHER | AZALIA_SPECIAL7, |
| 79 | AZALIA_MOBILE_LID_OUTSIDE = AZALIA_LOCATION_OTHER | AZALIA_SPECIAL8, |
| 80 | }; |
| 81 | |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 82 | enum azalia_pin_device { |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 83 | AZALIA_LINE_OUT = 0x0, |
| 84 | AZALIA_SPEAKER = 0x1, |
| 85 | AZALIA_HP_OUT = 0x2, |
| 86 | AZALIA_CD = 0x3, |
| 87 | AZALIA_SPDIF_OUT = 0x4, |
| 88 | AZALIA_DIGITAL_OTHER_OUT = 0x5, |
| 89 | AZALIA_MODEM_LINE_SIDE = 0x6, |
| 90 | AZALIA_MODEM_HANDSET_SIDE = 0x7, |
| 91 | AZALIA_LINE_IN = 0x8, |
| 92 | AZALIA_AUX = 0x9, |
| 93 | AZALIA_MIC_IN = 0xa, |
| 94 | AZALIA_TELEPHONY = 0xb, |
| 95 | AZALIA_SPDIF_IN = 0xc, |
| 96 | AZALIA_DIGITAL_OTHER_IN = 0xd, |
| 97 | AZALIA_DEVICE_OTHER = 0xf, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 98 | }; |
| 99 | |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 100 | enum azalia_pin_type { |
| 101 | AZALIA_TYPE_UNKNOWN = 0x0, |
| 102 | AZALIA_STEREO_MONO_1_8 = 0x1, |
| 103 | AZALIA_STEREO_MONO_1_4 = 0x2, |
| 104 | AZALIA_ATAPI_INTERNAL = 0x3, |
| 105 | AZALIA_RCA = 0x4, |
| 106 | AZALIA_OPTICAL = 0x5, |
| 107 | AZALIA_OTHER_DIGITAL = 0x6, |
| 108 | AZALIA_OTHER_ANALOG = 0x7, |
| 109 | AZALIA_MULTICHANNEL_ANALOG = 0x8, |
| 110 | AZALIA_XLR = 0x9, |
| 111 | AZALIA_RJ_11 = 0xa, |
| 112 | AZALIA_COMBINATION = 0xb, |
| 113 | AZALIA_TYPE_OTHER = 0xf, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 114 | }; |
| 115 | |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 116 | enum azalia_pin_color { |
| 117 | AZALIA_COLOR_UNKNOWN = 0x0, |
| 118 | AZALIA_BLACK = 0x1, |
| 119 | AZALIA_GREY = 0x2, |
| 120 | AZALIA_BLUE = 0x3, |
| 121 | AZALIA_GREEN = 0x4, |
| 122 | AZALIA_RED = 0x5, |
| 123 | AZALIA_ORANGE = 0x6, |
| 124 | AZALIA_YELLOW = 0x7, |
| 125 | AZALIA_PURPLE = 0x8, |
| 126 | AZALIA_PINK = 0x9, |
| 127 | AZALIA_WHITE = 0xe, |
| 128 | AZALIA_COLOR_OTHER = 0xf, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 129 | }; |
| 130 | |
Nicholas Chin | 463a7bc | 2024-01-15 10:26:11 -0700 | [diff] [blame] | 131 | enum azalia_pin_misc { |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 132 | AZALIA_JACK_PRESENCE_DETECT = 0x0, |
| 133 | AZALIA_NO_JACK_PRESENCE_DETECT = 0x1, |
Nicholas Chin | 463a7bc | 2024-01-15 10:26:11 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
Nicholas Sudsgaard | 4e8bbc1 | 2024-02-25 09:32:33 +0900 | [diff] [blame] | 136 | #define AZALIA_PIN_DESC(conn, location, dev, type, color, misc, association, sequence) \ |
| 137 | ((((conn) << 30) & 0xc0000000) | \ |
| 138 | (((location) << 24) & 0x3f000000) | \ |
| 139 | (((dev) << 20) & 0x00f00000) | \ |
| 140 | (((type) << 16) & 0x000f0000) | \ |
| 141 | (((color) << 12) & 0x0000f000) | \ |
| 142 | (((misc) << 8) & 0x00000f00) | \ |
| 143 | (((association) << 4) & 0x000000f0) | \ |
Nicholas Sudsgaard | 4a62b8a | 2024-02-22 13:33:15 +0900 | [diff] [blame] | 144 | (((sequence) << 0) & 0x0000000f)) |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 145 | |
Lee Leahy | 6a566d7 | 2017-03-07 17:45:12 -0800 | [diff] [blame] | 146 | #define AZALIA_ARRAY_SIZES const u32 pc_beep_verbs_size = \ |
| 147 | ARRAY_SIZE(pc_beep_verbs); \ |
Vladimir Serbinenko | 75c8387 | 2014-09-05 01:01:31 +0200 | [diff] [blame] | 148 | const u32 cim_verb_data_size = sizeof(cim_verb_data) |
Vladimir Serbinenko | 6a3a8ce | 2014-08-17 23:48:42 +0200 | [diff] [blame] | 149 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 150 | #define AZALIA_VERB_12B(codec, pin, verb, val) \ |
| 151 | ((codec) << 28 | (pin) << 20 | (verb) << 8 | (val)) |
| 152 | |
| 153 | #define AZALIA_PIN_CFG(codec, pin, val) \ |
| 154 | AZALIA_VERB_12B(codec, pin, 0x71c, ((val) >> 0) & 0xff), \ |
| 155 | AZALIA_VERB_12B(codec, pin, 0x71d, ((val) >> 8) & 0xff), \ |
| 156 | AZALIA_VERB_12B(codec, pin, 0x71e, ((val) >> 16) & 0xff), \ |
| 157 | AZALIA_VERB_12B(codec, pin, 0x71f, ((val) >> 24) & 0xff) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 158 | |
Angel Pons | 779d0c6 | 2021-11-03 11:12:35 +0100 | [diff] [blame] | 159 | #define AZALIA_PIN_CFG_NC(n) (0x411111f0 | ((n) & 0xf)) |
Felix Singer | 1bdbcd7 | 2020-09-22 12:55:25 +0200 | [diff] [blame] | 160 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 161 | #define AZALIA_RESET(pin) \ |
| 162 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 163 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 164 | AZALIA_VERB_12B(0, pin, 0x7ff, 0), \ |
| 165 | AZALIA_VERB_12B(0, pin, 0x7ff, 0) |
Lijian Zhao | 5c9237f | 2018-11-08 17:57:33 -0800 | [diff] [blame] | 166 | |
Angel Pons | 05c4dcb | 2021-11-03 12:18:31 +0100 | [diff] [blame] | 167 | #define AZALIA_SUBVENDOR(codec, val) \ |
| 168 | AZALIA_VERB_12B(codec, 1, 0x720, ((val) >> 0) & 0xff), \ |
| 169 | AZALIA_VERB_12B(codec, 1, 0x721, ((val) >> 8) & 0xff), \ |
| 170 | AZALIA_VERB_12B(codec, 1, 0x722, ((val) >> 16) & 0xff), \ |
| 171 | AZALIA_VERB_12B(codec, 1, 0x723, ((val) >> 24) & 0xff) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 172 | |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 173 | #endif /* DEVICE_AZALIA_H */ |