Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 14 | #ifndef __PMIC8058_OTHC_H__ |
| 15 | #define __PMIC8058_OTHC_H__ |
| 16 | |
| 17 | /* Accessory detecion flags */ |
| 18 | #define OTHC_MICBIAS_DETECT BIT(0) |
| 19 | #define OTHC_GPIO_DETECT BIT(1) |
| 20 | #define OTHC_SWITCH_DETECT BIT(2) |
| 21 | #define OTHC_ADC_DETECT BIT(3) |
| 22 | |
| 23 | enum othc_accessory_type { |
| 24 | OTHC_NO_DEVICE = 0, |
| 25 | OTHC_HEADSET = 1 << 0, |
| 26 | OTHC_HEADPHONE = 1 << 1, |
| 27 | OTHC_MICROPHONE = 1 << 2, |
| 28 | OTHC_ANC_HEADSET = 1 << 3, |
| 29 | OTHC_ANC_HEADPHONE = 1 << 4, |
| 30 | OTHC_ANC_MICROPHONE = 1 << 5, |
| 31 | OTHC_SVIDEO_OUT = 1 << 6, |
| 32 | }; |
| 33 | |
| 34 | struct accessory_adc_thres { |
| 35 | int min_threshold; |
| 36 | int max_threshold; |
| 37 | }; |
| 38 | |
| 39 | struct othc_accessory_info { |
| 40 | unsigned int accessory; |
| 41 | unsigned int detect_flags; |
| 42 | unsigned int gpio; |
| 43 | unsigned int active_low; |
| 44 | unsigned int key_code; |
| 45 | bool enabled; |
| 46 | struct accessory_adc_thres adc_thres; |
| 47 | }; |
| 48 | |
| 49 | enum othc_headset_type { |
| 50 | OTHC_HEADSET_NO, |
| 51 | OTHC_HEADSET_NC, |
| 52 | }; |
| 53 | |
| 54 | struct othc_regulator_config { |
| 55 | const char *regulator; |
| 56 | unsigned int max_uV; |
| 57 | unsigned int min_uV; |
| 58 | }; |
| 59 | |
| 60 | /* Signal control for OTHC module */ |
| 61 | enum othc_micbias_enable { |
| 62 | /* Turn off MICBIAS signal */ |
| 63 | OTHC_SIGNAL_OFF, |
| 64 | /* Turn on MICBIAS signal when TCXO is enabled */ |
| 65 | OTHC_SIGNAL_TCXO, |
| 66 | /* Turn on MICBIAS signal when PWM is high or TCXO is enabled */ |
| 67 | OTHC_SIGNAL_PWM_TCXO, |
| 68 | /* MICBIAS always enabled */ |
| 69 | OTHC_SIGNAL_ALWAYS_ON, |
| 70 | }; |
| 71 | |
| 72 | /* Number of MICBIAS lines supported by PMIC8058 */ |
| 73 | enum othc_micbias { |
| 74 | OTHC_MICBIAS_0, |
| 75 | OTHC_MICBIAS_1, |
| 76 | OTHC_MICBIAS_2, |
| 77 | OTHC_MICBIAS_MAX, |
| 78 | }; |
| 79 | |
| 80 | enum othc_micbias_capability { |
| 81 | /* MICBIAS used only for BIAS with on/off capability */ |
| 82 | OTHC_MICBIAS, |
| 83 | /* MICBIAS used to support HSED functionality */ |
| 84 | OTHC_MICBIAS_HSED, |
| 85 | }; |
| 86 | |
| 87 | struct othc_switch_info { |
| 88 | u32 min_adc_threshold; |
| 89 | u32 max_adc_threshold; |
| 90 | u32 key_code; |
| 91 | }; |
| 92 | |
| 93 | struct othc_n_switch_config { |
| 94 | u32 voltage_settling_time_ms; |
| 95 | u8 num_adc_samples; |
| 96 | uint32_t adc_channel; |
| 97 | struct othc_switch_info *switch_info; |
| 98 | u8 num_keys; |
| 99 | bool default_sw_en; |
| 100 | u8 default_sw_idx; |
| 101 | }; |
| 102 | |
| 103 | struct hsed_bias_config { |
| 104 | enum othc_headset_type othc_headset; |
| 105 | u16 othc_lowcurr_thresh_uA; |
| 106 | u16 othc_highcurr_thresh_uA; |
| 107 | u32 othc_hyst_prediv_us; |
| 108 | u32 othc_period_clkdiv_us; |
| 109 | u32 othc_hyst_clk_us; |
| 110 | u32 othc_period_clk_us; |
| 111 | int othc_wakeup; |
| 112 | }; |
| 113 | |
| 114 | /* Configuration data for HSED */ |
| 115 | struct othc_hsed_config { |
| 116 | struct hsed_bias_config *hsed_bias_config; |
| 117 | unsigned long detection_delay_ms; |
| 118 | /* Switch configuration */ |
| 119 | unsigned long switch_debounce_ms; |
| 120 | bool othc_support_n_switch; /* Set if supporting > 1 switch */ |
| 121 | struct othc_n_switch_config *switch_config; |
| 122 | /* Accessory configuration */ |
| 123 | bool accessories_support; |
| 124 | bool accessories_adc_support; |
| 125 | uint32_t accessories_adc_channel; |
| 126 | struct othc_accessory_info *accessories; |
| 127 | int othc_num_accessories; |
| 128 | int video_out_gpio; |
| 129 | int ir_gpio; |
| 130 | }; |
| 131 | |
| 132 | struct pmic8058_othc_config_pdata { |
| 133 | enum othc_micbias micbias_select; |
| 134 | enum othc_micbias_enable micbias_enable; |
| 135 | enum othc_micbias_capability micbias_capability; |
| 136 | struct othc_hsed_config *hsed_config; |
| 137 | const char *hsed_name; |
| 138 | struct othc_regulator_config *micbias_regulator; |
| 139 | }; |
| 140 | |
| 141 | int pm8058_micbias_enable(enum othc_micbias micbias, |
| 142 | enum othc_micbias_enable enable); |
| 143 | int pm8058_othc_svideo_enable(enum othc_micbias micbias, |
| 144 | bool enable); |
| 145 | |
| 146 | #endif /* __PMIC8058_OTHC_H__ */ |