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); |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 26 | void azalia_audio_init(struct device *dev); |
| 27 | extern struct device_operations default_azalia_audio_ops; |
| 28 | |
Vladimir Serbinenko | 75c8387 | 2014-09-05 01:01:31 +0200 | [diff] [blame] | 29 | extern const u32 cim_verb_data[]; |
| 30 | extern const u32 cim_verb_data_size; |
| 31 | extern const u32 pc_beep_verbs[]; |
| 32 | extern const u32 pc_beep_verbs_size; |
| 33 | |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 34 | enum azalia_pin_connection { |
| 35 | JACK = 0, |
| 36 | NC, |
| 37 | INTEGRATED, |
| 38 | JACK_AND_INTEGRATED, |
| 39 | }; |
| 40 | |
| 41 | enum azalia_pin_color { |
| 42 | COLOR_UNKNOWN = 0, |
| 43 | BLACK, |
| 44 | GREY, |
| 45 | BLUE, |
| 46 | GREEN, |
| 47 | RED, |
| 48 | ORANGE, |
| 49 | YELLOW, |
| 50 | PURPLE, |
| 51 | PINK, |
| 52 | WHITE = 0xe, |
| 53 | COLOR_OTHER = 0xf, |
| 54 | }; |
| 55 | |
| 56 | enum azalia_pin_type { |
| 57 | TYPE_UNKNOWN = 0, |
| 58 | STEREO_MONO_1_8, |
| 59 | STEREO_MONO_1_4, |
| 60 | ATAPI, |
| 61 | RCA, |
Patrick Rudolph | 9572dd8 | 2020-10-21 16:43:08 +0200 | [diff] [blame] | 62 | OPTICAL, |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 63 | OTHER_DIGITAL, |
| 64 | OTHER_ANALOG, |
| 65 | MULTICHANNEL_ANALOG, |
| 66 | XLR, |
| 67 | RJ_11, |
| 68 | COMBINATION, |
| 69 | TYPE_OTHER = 0xf |
| 70 | }; |
| 71 | |
| 72 | enum azalia_pin_device { |
| 73 | LINE_OUT = 0, |
| 74 | SPEAKER, |
| 75 | HP_OUT, |
| 76 | CD, |
| 77 | SPDIF_OUT, |
| 78 | DIGITAL_OTHER_OUT, |
| 79 | MODEM_LINE_SIDE, |
| 80 | MODEM_HANDSET_SIDE, |
| 81 | LINE_IN, |
| 82 | AUX, |
| 83 | MIC_IN, |
| 84 | TELEPHONY, |
| 85 | SPDIF_IN, |
| 86 | DIGITAL_OTHER_IN, |
| 87 | DEVICE_OTHER = 0xf, |
| 88 | }; |
| 89 | |
| 90 | enum azalia_pin_location_1 { |
| 91 | NA = 0, |
| 92 | REAR, |
| 93 | FRONT, |
| 94 | LEFT, |
| 95 | RIGHT, |
| 96 | TOP, |
| 97 | BOTTOM, |
| 98 | SPECIAL7, |
| 99 | SPECIAL8, |
| 100 | SPECIAL9, |
| 101 | }; |
| 102 | |
| 103 | enum azalia_pin_location_2 { |
| 104 | EXTERNAL_PRIMARY_CHASSIS = 0, |
| 105 | INTERNAL, |
| 106 | SEPARATE_CHASSIS, |
| 107 | LOCATION_OTHER |
| 108 | }; |
| 109 | |
| 110 | #define AZALIA_PIN_DESC(conn, location2, location1, dev, type, color, no_presence_detect, \ |
| 111 | association, sequence) \ |
| 112 | (((conn) << 30) | \ |
| 113 | ((location2) << 27) | \ |
| 114 | ((location1) << 24) | \ |
| 115 | ((dev) << 20) | \ |
| 116 | ((type) << 16) | \ |
| 117 | ((color) << 12) | \ |
| 118 | ((no_presence_detect) << 8) | \ |
Patrick Rudolph | 15d6240 | 2020-08-28 10:59:45 +0200 | [diff] [blame] | 119 | ((association) << 4) | \ |
Patrick Rudolph | 9a521d7 | 2020-03-20 10:07:53 +0100 | [diff] [blame] | 120 | ((sequence) << 0)) |
| 121 | |
Lee Leahy | 6a566d7 | 2017-03-07 17:45:12 -0800 | [diff] [blame] | 122 | #define AZALIA_ARRAY_SIZES const u32 pc_beep_verbs_size = \ |
| 123 | ARRAY_SIZE(pc_beep_verbs); \ |
Vladimir Serbinenko | 75c8387 | 2014-09-05 01:01:31 +0200 | [diff] [blame] | 124 | const u32 cim_verb_data_size = sizeof(cim_verb_data) |
Vladimir Serbinenko | 6a3a8ce | 2014-08-17 23:48:42 +0200 | [diff] [blame] | 125 | |
Lee Leahy | 6a566d7 | 2017-03-07 17:45:12 -0800 | [diff] [blame] | 126 | #define AZALIA_PIN_CFG(codec, pin, val) \ |
| 127 | (((codec) << 28) | ((pin) << 20) | (0x71c << 8) \ |
| 128 | | ((val) & 0xff)), \ |
| 129 | (((codec) << 28) | ((pin) << 20) | (0x71d << 8) \ |
| 130 | | (((val) >> 8) & 0xff)), \ |
| 131 | (((codec) << 28) | ((pin) << 20) | (0x71e << 8) \ |
| 132 | | (((val) >> 16) & 0xff)), \ |
| 133 | (((codec) << 28) | ((pin) << 20) | (0x71f << 8) \ |
| 134 | | (((val) >> 24) & 0xff)) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 135 | |
Felix Singer | 1bdbcd7 | 2020-09-22 12:55:25 +0200 | [diff] [blame] | 136 | #define AZALIA_PIN_CFG_NC(n) (0x411111f0 | (n & 0xf)) |
| 137 | |
Lijian Zhao | 5c9237f | 2018-11-08 17:57:33 -0800 | [diff] [blame] | 138 | #define AZALIA_RESET(pin) \ |
| 139 | (((pin) << 20) | 0x7ff00), (((pin) << 20) | 0x7ff00), \ |
| 140 | (((pin) << 20) | 0x7ff00), (((pin) << 20) | 0x7ff00) |
| 141 | |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 142 | #define AZALIA_SUBVENDOR(codec, val) \ |
Lee Leahy | f00e446 | 2017-03-07 13:17:49 -0800 | [diff] [blame] | 143 | (((codec) << 28) | (0x01720 << 8) | ((val) & 0xff)), \ |
| 144 | (((codec) << 28) | (0x01721 << 8) | (((val) >> 8) & 0xff)), \ |
| 145 | (((codec) << 28) | (0x01722 << 8) | (((val) >> 16) & 0xff)), \ |
| 146 | (((codec) << 28) | (0x01723 << 8) | (((val) >> 24) & 0xff)) |
Vladimir Serbinenko | 8f0da58 | 2014-09-04 21:34:13 +0200 | [diff] [blame] | 147 | |
Andrew Wu | b7bb70d | 2013-08-12 20:07:47 +0800 | [diff] [blame] | 148 | #endif /* DEVICE_AZALIA_H */ |