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 | |
Bhalchandra Gajare | 87fef4c | 2013-02-19 14:57:03 -0800 | [diff] [blame] | 84 | #endif |