Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef WCD9XXX_CODEC_COMMON |
| 14 | |
| 15 | #define WCD9XXX_CODEC_COMMON |
| 16 | |
Joonwoo Park | a08e055 | 2013-03-05 18:28:23 -0800 | [diff] [blame] | 17 | #include "wcd9xxx-resmgr.h" |
| 18 | |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 19 | #define WCD9XXX_CLSH_REQ_ENABLE true |
| 20 | #define WCD9XXX_CLSH_REQ_DISABLE false |
| 21 | |
| 22 | #define WCD9XXX_CLSH_EVENT_PRE_DAC 0x01 |
| 23 | #define WCD9XXX_CLSH_EVENT_POST_PA 0x02 |
| 24 | |
| 25 | /* Basic states for Class H state machine. |
| 26 | * represented as a bit mask within a u8 data type |
| 27 | * bit 0: EAR mode |
| 28 | * bit 1: HPH Left mode |
| 29 | * bit 2: HPH Right mode |
| 30 | * bit 3: Lineout mode |
| 31 | * bit 4: Ultrasound mode |
| 32 | */ |
| 33 | #define WCD9XXX_CLSH_STATE_IDLE 0x00 |
| 34 | #define WCD9XXX_CLSH_STATE_EAR (0x01 << 0) |
| 35 | #define WCD9XXX_CLSH_STATE_HPHL (0x01 << 1) |
| 36 | #define WCD9XXX_CLSH_STATE_HPHR (0x01 << 2) |
| 37 | #define WCD9XXX_CLSH_STATE_LO (0x01 << 3) |
| 38 | #define NUM_CLSH_STATES ((0x01 << 4) - 1) |
| 39 | |
| 40 | /* Derived State: Bits 1 and 2 should be set for Headphone stereo */ |
| 41 | #define WCD9XXX_CLSH_STATE_HPH_ST (WCD9XXX_CLSH_STATE_HPHL | \ |
| 42 | WCD9XXX_CLSH_STATE_HPHR) |
| 43 | |
| 44 | |
| 45 | struct wcd9xxx_reg_mask_val { |
| 46 | u16 reg; |
| 47 | u8 mask; |
| 48 | u8 val; |
| 49 | }; |
| 50 | |
| 51 | /* Class H data that the codec driver will maintain */ |
| 52 | struct wcd9xxx_clsh_cdc_data { |
| 53 | u8 state; |
| 54 | int buck_mv; |
Bhalchandra Gajare | 7c73952 | 2013-06-20 15:31:02 -0700 | [diff] [blame] | 55 | bool is_dynamic_vdd_cp; |
Joonwoo Park | a08e055 | 2013-03-05 18:28:23 -0800 | [diff] [blame] | 56 | struct wcd9xxx_resmgr *resmgr; |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 57 | }; |
| 58 | |
Simmi Pateriya | df675e9 | 2013-04-05 01:15:54 +0530 | [diff] [blame] | 59 | struct wcd9xxx_anc_header { |
| 60 | u32 reserved[3]; |
| 61 | u32 num_anc_slots; |
| 62 | }; |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 63 | |
| 64 | enum wcd9xxx_buck_volt { |
| 65 | WCD9XXX_CDC_BUCK_UNSUPPORTED = 0, |
| 66 | WCD9XXX_CDC_BUCK_MV_1P8 = 1800000, |
| 67 | WCD9XXX_CDC_BUCK_MV_2P15 = 2150000, |
| 68 | }; |
| 69 | |
| 70 | extern void wcd9xxx_clsh_fsm(struct snd_soc_codec *codec, |
| 71 | struct wcd9xxx_clsh_cdc_data *cdc_clsh_d, |
| 72 | u8 req_state, bool req_type, u8 clsh_event); |
| 73 | |
Joonwoo Park | a08e055 | 2013-03-05 18:28:23 -0800 | [diff] [blame] | 74 | extern void wcd9xxx_clsh_init(struct wcd9xxx_clsh_cdc_data *clsh, |
| 75 | struct wcd9xxx_resmgr *resmgr); |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 76 | |
Santosh Mardi | 93a6919 | 2013-07-03 23:37:29 +0530 | [diff] [blame] | 77 | extern void wcd9xxx_clsh_imped_config(struct snd_soc_codec *codec, |
| 78 | int imped); |
| 79 | |
Kiran Kandi | a1bed42 | 2013-05-28 18:29:12 -0700 | [diff] [blame] | 80 | enum wcd9xxx_codec_event { |
| 81 | WCD9XXX_CODEC_EVENT_CODEC_UP = 0, |
| 82 | }; |
| 83 | |
Phani Kumar Uppalapati | 01a77e1 | 2013-08-08 15:31:35 -0700 | [diff] [blame] | 84 | struct wcd9xxx_register_save_node { |
| 85 | struct list_head lh; |
| 86 | u16 reg; |
| 87 | u16 value; |
| 88 | }; |
| 89 | |
| 90 | extern int wcd9xxx_soc_update_bits_push(struct snd_soc_codec *codec, |
| 91 | struct list_head *lh, |
| 92 | uint16_t reg, uint8_t mask, |
| 93 | uint8_t value, int delay); |
| 94 | extern void wcd9xxx_restore_registers(struct snd_soc_codec *codec, |
| 95 | struct list_head *lh); |
Damir Didjusto | d6aea99 | 2013-09-03 21:18:59 -0700 | [diff] [blame] | 96 | enum { |
| 97 | RESERVED = 0, |
| 98 | AANC_LPF_FF_FB = 1, |
| 99 | AANC_LPF_COEFF_MSB, |
| 100 | AANC_LPF_COEFF_LSB, |
| 101 | HW_MAD_AUDIO_ENABLE, |
| 102 | HW_MAD_ULTR_ENABLE, |
| 103 | HW_MAD_BEACON_ENABLE, |
| 104 | HW_MAD_AUDIO_SLEEP_TIME, |
| 105 | HW_MAD_ULTR_SLEEP_TIME, |
| 106 | HW_MAD_BEACON_SLEEP_TIME, |
| 107 | HW_MAD_TX_AUDIO_SWITCH_OFF, |
| 108 | HW_MAD_TX_ULTR_SWITCH_OFF, |
| 109 | HW_MAD_TX_BEACON_SWITCH_OFF, |
| 110 | MAD_AUDIO_INT_DEST_SELECT_REG, |
| 111 | MAD_ULT_INT_DEST_SELECT_REG, |
| 112 | MAD_BEACON_INT_DEST_SELECT_REG, |
| 113 | MAD_CLIP_INT_DEST_SELECT_REG, |
| 114 | MAD_VBAT_INT_DEST_SELECT_REG, |
| 115 | MAD_AUDIO_INT_MASK_REG, |
| 116 | MAD_ULT_INT_MASK_REG, |
| 117 | MAD_BEACON_INT_MASK_REG, |
| 118 | MAD_CLIP_INT_MASK_REG, |
| 119 | MAD_VBAT_INT_MASK_REG, |
| 120 | MAD_AUDIO_INT_STATUS_REG, |
| 121 | MAD_ULT_INT_STATUS_REG, |
| 122 | MAD_BEACON_INT_STATUS_REG, |
| 123 | MAD_CLIP_INT_STATUS_REG, |
| 124 | MAD_VBAT_INT_STATUS_REG, |
| 125 | MAD_AUDIO_INT_CLEAR_REG, |
| 126 | MAD_ULT_INT_CLEAR_REG, |
| 127 | MAD_BEACON_INT_CLEAR_REG, |
| 128 | MAD_CLIP_INT_CLEAR_REG, |
| 129 | MAD_VBAT_INT_CLEAR_REG, |
| 130 | SB_PGD_PORT_TX_WATERMARK_N, |
| 131 | SB_PGD_PORT_TX_ENABLE_N, |
| 132 | SB_PGD_PORT_RX_WATERMARK_N, |
| 133 | SB_PGD_PORT_RX_ENABLE_N, |
| 134 | SB_PGD_TX_PORTn_MULTI_CHNL_0, |
| 135 | SB_PGD_TX_PORTn_MULTI_CHNL_1, |
| 136 | SB_PGD_RX_PORTn_MULTI_CHNL_0, |
| 137 | SB_PGD_RX_PORTn_MULTI_CHNL_1, |
| 138 | AANC_FF_GAIN_ADAPTIVE, |
| 139 | AANC_FFGAIN_ADAPTIVE_EN, |
| 140 | AANC_GAIN_CONTROL, |
| 141 | SPKR_CLIP_PIPE_BANK_SEL, |
| 142 | SPKR_CLIPDET_VAL0, |
| 143 | SPKR_CLIPDET_VAL1, |
| 144 | SPKR_CLIPDET_VAL2, |
| 145 | SPKR_CLIPDET_VAL3, |
| 146 | SPKR_CLIPDET_VAL4, |
| 147 | SPKR_CLIPDET_VAL5, |
| 148 | SPKR_CLIPDET_VAL6, |
| 149 | SPKR_CLIPDET_VAL7, |
| 150 | MAX_CFG_REGISTERS, |
| 151 | }; |
| 152 | |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 153 | #endif |