extcon-adc-jack.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * include/linux/extcon/extcon-adc-jack.h
  4. *
  5. * Analog Jack extcon driver with ADC-based detection capability.
  6. *
  7. * Copyright (C) 2012 Samsung Electronics
  8. * MyungJoo Ham <[email protected]>
  9. */
  10. #ifndef _EXTCON_ADC_JACK_H_
  11. #define _EXTCON_ADC_JACK_H_ __FILE__
  12. #include <linux/module.h>
  13. #include <linux/extcon.h>
  14. /**
  15. * struct adc_jack_cond - condition to use an extcon state
  16. * denotes the last adc_jack_cond element among the array)
  17. * @id: the unique id of each external connector
  18. * @min_adc: min adc value for this condition
  19. * @max_adc: max adc value for this condition
  20. *
  21. * For example, if { .state = 0x3, .min_adc = 100, .max_adc = 200}, it means
  22. * that if ADC value is between (inclusive) 100 and 200, than the cable 0 and
  23. * 1 are attached (1<<0 | 1<<1 == 0x3)
  24. *
  25. * Note that you don't need to describe condition for "no cable attached"
  26. * because when no adc_jack_cond is met, state = 0 is automatically chosen.
  27. */
  28. struct adc_jack_cond {
  29. unsigned int id;
  30. u32 min_adc;
  31. u32 max_adc;
  32. };
  33. /**
  34. * struct adc_jack_pdata - platform data for adc jack device.
  35. * @name: name of the extcon device. If null, "adc-jack" is used.
  36. * @consumer_channel: Unique name to identify the channel on the consumer
  37. * side. This typically describes the channels used within
  38. * the consumer. E.g. 'battery_voltage'
  39. * @cable_names: array of extcon id for supported cables.
  40. * @adc_contitions: array of struct adc_jack_cond conditions ending
  41. * with .state = 0 entry. This describes how to decode
  42. * adc values into extcon state.
  43. * @irq_flags: irq flags used for the @irq
  44. * @handling_delay_ms: in some devices, we need to read ADC value some
  45. * milli-seconds after the interrupt occurs. You may
  46. * describe such delays with @handling_delay_ms, which
  47. * is rounded-off by jiffies.
  48. * @wakeup_source: flag to wake up the system for extcon events.
  49. */
  50. struct adc_jack_pdata {
  51. const char *name;
  52. const char *consumer_channel;
  53. const unsigned int *cable_names;
  54. /* The last entry's state should be 0 */
  55. struct adc_jack_cond *adc_conditions;
  56. unsigned long irq_flags;
  57. unsigned long handling_delay_ms; /* in ms */
  58. bool wakeup_source;
  59. };
  60. #endif /* _EXTCON_ADC_JACK_H */