| /* |
| * extcon-madera.h - public extcon driver API for Cirrus Logic Madera codecs |
| * |
| * Copyright 2015-2016 Cirrus Logic |
| * |
| * This program is free software; you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 2 as |
| * published by the Free Software Foundation. |
| */ |
| |
| #ifndef _EXTCON_MADERA_H_ |
| #define _EXTCON_MADERA_H_ |
| |
| #include <linux/mfd/madera/registers.h> |
| |
| #define MADERA_MICD_LVL_1_TO_7 \ |
| (MADERA_MICD_LVL_1 | MADERA_MICD_LVL_2 | \ |
| MADERA_MICD_LVL_3 | MADERA_MICD_LVL_4 | \ |
| MADERA_MICD_LVL_5 | MADERA_MICD_LVL_6 | \ |
| MADERA_MICD_LVL_7) |
| |
| #define MADERA_MICD_LVL_0_TO_7 (MADERA_MICD_LVL_0 | MADERA_MICD_LVL_1_TO_7) |
| |
| #define MADERA_MICD_LVL_0_TO_8 (MADERA_MICD_LVL_0_TO_7 | MADERA_MICD_LVL_8) |
| |
| /* Notify data structure for MADERA_NOTIFY_HPDET */ |
| struct madera_hpdet_notify_data { |
| unsigned int impedance_x100; /* ohms * 100 */ |
| }; |
| |
| /* Notify data structure for MADERA_NOTIFY_MICDET */ |
| struct madera_micdet_notify_data { |
| unsigned int impedance_x100; /* ohms * 100 */ |
| bool present; |
| int out_num; /* 1 = OUT1, 2 = OUT2 */ |
| }; |
| |
| struct madera_extcon_info; |
| |
| enum madera_accdet_mode { |
| MADERA_ACCDET_MODE_MIC, |
| MADERA_ACCDET_MODE_HPL, |
| MADERA_ACCDET_MODE_HPR, |
| MADERA_ACCDET_MODE_HPM, |
| MADERA_ACCDET_MODE_ADC, |
| MADERA_ACCDET_MODE_INVALID, |
| }; |
| |
| struct madera_jd_state { |
| enum madera_accdet_mode mode; |
| |
| int (*start)(struct madera_extcon_info *); |
| void (*restart)(struct madera_extcon_info *); |
| int (*reading)(struct madera_extcon_info *, int); |
| void (*stop)(struct madera_extcon_info *); |
| |
| int (*timeout_ms)(struct madera_extcon_info *); |
| void (*timeout)(struct madera_extcon_info *); |
| }; |
| |
| int madera_jds_set_state(struct madera_extcon_info *info, |
| const struct madera_jd_state *new_state); |
| |
| extern void madera_set_headphone_imp(struct madera_extcon_info *info, |
| int imp); |
| |
| extern const struct madera_jd_state madera_hpdet_left; |
| extern const struct madera_jd_state madera_hpdet_right; |
| extern const struct madera_jd_state madera_hpdet_moisture; |
| extern const struct madera_jd_state madera_micd_button; |
| extern const struct madera_jd_state madera_micd_microphone; |
| extern const struct madera_jd_state madera_micd_adc_mic; |
| |
| extern int madera_hpdet_start(struct madera_extcon_info *info); |
| extern void madera_hpdet_restart(struct madera_extcon_info *info); |
| extern void madera_hpdet_stop(struct madera_extcon_info *info); |
| extern int madera_hpdet_reading(struct madera_extcon_info *info, int val); |
| |
| extern int madera_micd_start(struct madera_extcon_info *info); |
| extern void madera_micd_stop(struct madera_extcon_info *info); |
| extern int madera_micd_button_reading(struct madera_extcon_info *info, int val); |
| |
| extern int madera_micd_mic_start(struct madera_extcon_info *info); |
| extern void madera_micd_mic_stop(struct madera_extcon_info *info); |
| extern int madera_micd_mic_reading(struct madera_extcon_info *info, int val); |
| extern int madera_micd_mic_timeout_ms(struct madera_extcon_info *info); |
| extern void madera_micd_mic_timeout(struct madera_extcon_info *info); |
| |
| extern void madera_extcon_report(struct madera_extcon_info *info, int state); |
| |
| #endif |