18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * include/linux/extcon/extcon-adc-jack.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Analog Jack extcon driver with ADC-based detection capability. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2012 Samsung Electronics 88c2ecf20Sopenharmony_ci * MyungJoo Ham <myungjoo.ham@samsung.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _EXTCON_ADC_JACK_H_ 128c2ecf20Sopenharmony_ci#define _EXTCON_ADC_JACK_H_ __FILE__ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/module.h> 158c2ecf20Sopenharmony_ci#include <linux/extcon.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/** 188c2ecf20Sopenharmony_ci * struct adc_jack_cond - condition to use an extcon state 198c2ecf20Sopenharmony_ci * denotes the last adc_jack_cond element among the array) 208c2ecf20Sopenharmony_ci * @id: the unique id of each external connector 218c2ecf20Sopenharmony_ci * @min_adc: min adc value for this condition 228c2ecf20Sopenharmony_ci * @max_adc: max adc value for this condition 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means 258c2ecf20Sopenharmony_ci * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and 268c2ecf20Sopenharmony_ci * 1 are attached (1<<0 | 1<<1 == 0x3) 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Note that you don't need to describe condition for "no cable attached" 298c2ecf20Sopenharmony_ci * because when no adc_jack_cond is met, state = 0 is automatically chosen. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_cistruct adc_jack_cond { 328c2ecf20Sopenharmony_ci unsigned int id; 338c2ecf20Sopenharmony_ci u32 min_adc; 348c2ecf20Sopenharmony_ci u32 max_adc; 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/** 388c2ecf20Sopenharmony_ci * struct adc_jack_pdata - platform data for adc jack device. 398c2ecf20Sopenharmony_ci * @name: name of the extcon device. If null, "adc-jack" is used. 408c2ecf20Sopenharmony_ci * @consumer_channel: Unique name to identify the channel on the consumer 418c2ecf20Sopenharmony_ci * side. This typically describes the channels used within 428c2ecf20Sopenharmony_ci * the consumer. E.g. 'battery_voltage' 438c2ecf20Sopenharmony_ci * @cable_names: array of extcon id for supported cables. 448c2ecf20Sopenharmony_ci * @adc_contitions: array of struct adc_jack_cond conditions ending 458c2ecf20Sopenharmony_ci * with .state = 0 entry. This describes how to decode 468c2ecf20Sopenharmony_ci * adc values into extcon state. 478c2ecf20Sopenharmony_ci * @irq_flags: irq flags used for the @irq 488c2ecf20Sopenharmony_ci * @handling_delay_ms: in some devices, we need to read ADC value some 498c2ecf20Sopenharmony_ci * milli-seconds after the interrupt occurs. You may 508c2ecf20Sopenharmony_ci * describe such delays with @handling_delay_ms, which 518c2ecf20Sopenharmony_ci * is rounded-off by jiffies. 528c2ecf20Sopenharmony_ci * @wakeup_source: flag to wake up the system for extcon events. 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_cistruct adc_jack_pdata { 558c2ecf20Sopenharmony_ci const char *name; 568c2ecf20Sopenharmony_ci const char *consumer_channel; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci const unsigned int *cable_names; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /* The last entry's state should be 0 */ 618c2ecf20Sopenharmony_ci struct adc_jack_cond *adc_conditions; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci unsigned long irq_flags; 648c2ecf20Sopenharmony_ci unsigned long handling_delay_ms; /* in ms */ 658c2ecf20Sopenharmony_ci bool wakeup_source; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#endif /* _EXTCON_ADC_JACK_H */ 69