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