extcon-adc-jack.h 2.3 KB

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