home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / include / linux / pmic_external.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-09  |  18.5 KB  |  1,135 lines

  1. /*
  2.  * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
  3.  */
  4.  
  5. /*
  6.  * The code contained herein is licensed under the GNU General Public
  7.  * License. You may obtain a copy of the GNU General Public License
  8.  * Version 2 or later at the following locations:
  9.  *
  10.  * http://www.opensource.org/licenses/gpl-license.html
  11.  * http://www.gnu.org/copyleft/gpl.html
  12.  */
  13. #ifndef __ASM_ARCH_MXC_PMIC_EXTERNAL_H__
  14. #define __ASM_ARCH_MXC_PMIC_EXTERNAL_H__
  15.  
  16. #ifdef __KERNEL__
  17. #include <linux/list.h>
  18. #endif
  19.  
  20. /*!
  21.  * @defgroup PMIC_DRVRS PMIC Drivers
  22.  */
  23.  
  24. /*!
  25.  * @defgroup PMIC_CORE PMIC Protocol Drivers
  26.  * @ingroup PMIC_DRVRS
  27.  */
  28.  
  29. /*!
  30.  * @file arch-mxc/pmic_external.h
  31.  * @brief This file contains interface of PMIC protocol driver.
  32.  *
  33.  * @ingroup PMIC_CORE
  34.  */
  35.  
  36. #include <linux/ioctl.h>
  37. #include <linux/pmic_status.h>
  38.  
  39. /*!
  40.  * This is the enumeration of versions of PMIC
  41.  */
  42. typedef enum {
  43.     PMIC_MC13783 = 1,    /*!< MC13783 */
  44.     PMIC_SC55112 = 2,    /*!< SC55112 */
  45.     PMIC_MC13892 = 3,
  46.     PMIC_MC34704 = 4
  47. } pmic_id_t;
  48.  
  49. /*!
  50.  * @struct pmic_version_t
  51.  * @brief PMIC version and revision
  52.  */
  53. typedef struct {
  54.     /*!
  55.      * PMIC version identifier.
  56.      */
  57.     pmic_id_t id;
  58.     /*!
  59.      * Revision of the PMIC.
  60.      */
  61.     int revision;
  62. } pmic_version_t;
  63.  
  64. /*!
  65.  * struct pmic_event_callback_t
  66.  * @brief This structure contains callback function pointer and its
  67.  * parameter to be used when un/registering and launching a callback
  68.  * for an event.
  69.  */
  70. typedef struct {
  71.     /*!
  72.      * call back function
  73.      */
  74.     void (*func) (void *);
  75.  
  76.     /*!
  77.      * call back function parameter
  78.      */
  79.     void *param;
  80. } pmic_event_callback_t;
  81.  
  82. /*!
  83.  * This structure is used with IOCTL.
  84.  * It defines register, register value, register mask and event number
  85.  */
  86. typedef struct {
  87.     /*!
  88.      * register number
  89.      */
  90.     int reg;
  91.     /*!
  92.      * value of register
  93.      */
  94.     unsigned int reg_value;
  95.     /*!
  96.      * mask of bits, only used with PMIC_WRITE_REG
  97.      */
  98.     unsigned int reg_mask;
  99. } register_info;
  100.  
  101. /*!
  102.  * @name IOCTL definitions for sc55112 core driver
  103.  */
  104. /*! @{ */
  105. /*! Read a PMIC register */
  106. #define PMIC_READ_REG          _IOWR('P', 0xa0, register_info*)
  107. /*! Write a PMIC register */
  108. #define PMIC_WRITE_REG         _IOWR('P', 0xa1, register_info*)
  109. /*! Subscribe a PMIC interrupt event */
  110. #define PMIC_SUBSCRIBE         _IOR('P', 0xa2, int)
  111. /*! Unsubscribe a PMIC interrupt event */
  112. #define PMIC_UNSUBSCRIBE       _IOR('P', 0xa3, int)
  113. /*! Subscribe a PMIC event for user notification*/
  114. #define PMIC_NOTIFY_USER       _IOR('P', 0xa4, int)
  115. /*! Get the PMIC event occured for which user recieved notification */
  116. #define PMIC_GET_NOTIFY           _IOW('P', 0xa5, int)
  117. /*! @} */
  118.  
  119. /*!
  120.  * This is PMIC registers valid bits
  121.  */
  122. #define PMIC_ALL_BITS           0xFFFFFF
  123. #define PMIC_MAX_EVENTS        48
  124.  
  125. #define PMIC_ARBITRATION    "NULL"
  126.  
  127. #ifdef CONFIG_MXC_PMIC_MC13783
  128. /*!
  129.  * This is the enumeration of register names of MC13783
  130.  */
  131. typedef enum {
  132.     /*!
  133.      * REG_INTERRUPT_STATUS_0
  134.      */
  135.     REG_INTERRUPT_STATUS_0 = 0,
  136.     /*!
  137.      * REG_INTERRUPT_MASK_0
  138.      */
  139.     REG_INTERRUPT_MASK_0,
  140.     /*!
  141.      * REG_INTERRUPT_SENSE_0
  142.      */
  143.     REG_INTERRUPT_SENSE_0,
  144.     /*!
  145.      * REG_INTERRUPT_STATUS_1
  146.      */
  147.     REG_INTERRUPT_STATUS_1,
  148.     /*!
  149.      * REG_INTERRUPT_MASK_1
  150.      */
  151.     REG_INTERRUPT_MASK_1,
  152.     /*!
  153.      * REG_INTERRUPT_SENSE_1
  154.      */
  155.     REG_INTERRUPT_SENSE_1,
  156.     /*!
  157.      * REG_POWER_UP_MODE_SENSE
  158.      */
  159.     REG_POWER_UP_MODE_SENSE,
  160.     /*!
  161.      * REG_REVISION
  162.      */
  163.     REG_REVISION,
  164.     /*!
  165.      * REG_SEMAPHORE
  166.      */
  167.     REG_SEMAPHORE,
  168.     /*!
  169.      * REG_ARBITRATION_PERIPHERAL_AUDIO
  170.      */
  171.     REG_ARBITRATION_PERIPHERAL_AUDIO,
  172.     /*!
  173.      * REG_ARBITRATION_SWITCHERS
  174.      */
  175.     REG_ARBITRATION_SWITCHERS,
  176.     /*!
  177.      * REG_ARBITRATION_REGULATORS_0
  178.      */
  179.     REG_ARBITRATION_REGULATORS_0,
  180.     /*!
  181.      * REG_ARBITRATION_REGULATORS_1
  182.      */
  183.     REG_ARBITRATION_REGULATORS_1,
  184.     /*!
  185.      * REG_POWER_CONTROL_0
  186.      */
  187.     REG_POWER_CONTROL_0,
  188.     /*!
  189.      * REG_POWER_CONTROL_1
  190.      */
  191.     REG_POWER_CONTROL_1,
  192.     /*!
  193.      * REG_POWER_CONTROL_2
  194.      */
  195.     REG_POWER_CONTROL_2,
  196.     /*!
  197.      * REG_REGEN_ASSIGNMENT
  198.      */
  199.     REG_REGEN_ASSIGNMENT,
  200.     /*!
  201.      * REG_CONTROL_SPARE
  202.      */
  203.     REG_CONTROL_SPARE,
  204.     /*!
  205.      * REG_MEMORY_A
  206.      */
  207.     REG_MEMORY_A,
  208.     /*!
  209.      * REG_MEMORY_B
  210.      */
  211.     REG_MEMORY_B,
  212.     /*!
  213.      * REG_RTC_TIME
  214.      */
  215.     REG_RTC_TIME,
  216.     /*!
  217.      * REG_RTC_ALARM
  218.      */
  219.     REG_RTC_ALARM,
  220.     /*!
  221.      * REG_RTC_DAY
  222.      */
  223.     REG_RTC_DAY,
  224.     /*!
  225.      * REG_RTC_DAY_ALARM
  226.      */
  227.     REG_RTC_DAY_ALARM,
  228.     /*!
  229.      * REG_SWITCHERS_0
  230.      */
  231.     REG_SWITCHERS_0,
  232.     /*!
  233.      * REG_SWITCHERS_1
  234.      */
  235.     REG_SWITCHERS_1,
  236.     /*!
  237.      * REG_SWITCHERS_2
  238.      */
  239.     REG_SWITCHERS_2,
  240.     /*!
  241.      * REG_SWITCHERS_3
  242.      */
  243.     REG_SWITCHERS_3,
  244.     /*!
  245.      * REG_SWITCHERS_4
  246.      */
  247.     REG_SWITCHERS_4,
  248.     /*!
  249.      * REG_SWITCHERS_5
  250.      */
  251.     REG_SWITCHERS_5,
  252.     /*!
  253.      * REG_REGULATOR_SETTING_0
  254.      */
  255.     REG_REGULATOR_SETTING_0,
  256.     /*!
  257.      * REG_REGULATOR_SETTING_1
  258.      */
  259.     REG_REGULATOR_SETTING_1,
  260.     /*!
  261.      * REG_REGULATOR_MODE_0
  262.      */
  263.     REG_REGULATOR_MODE_0,
  264.     /*!
  265.      * REG_REGULATOR_MODE_1
  266.      */
  267.     REG_REGULATOR_MODE_1,
  268.     /*!
  269.      * REG_POWER_MISCELLANEOUS
  270.      */
  271.     REG_POWER_MISCELLANEOUS,
  272.     /*!
  273.      * REG_POWER_SPARE
  274.      */
  275.     REG_POWER_SPARE,
  276.     /*!
  277.      * REG_AUDIO_RX_0
  278.      */
  279.     REG_AUDIO_RX_0,
  280.     /*!
  281.      * REG_AUDIO_RX_1
  282.      */
  283.     REG_AUDIO_RX_1,
  284.     /*!
  285.      * REG_AUDIO_TX
  286.      */
  287.     REG_AUDIO_TX,
  288.     /*!
  289.      * REG_AUDIO_SSI_NETWORK
  290.      */
  291.     REG_AUDIO_SSI_NETWORK,
  292.     /*!
  293.      * REG_AUDIO_CODEC
  294.      */
  295.     REG_AUDIO_CODEC,
  296.     /*!
  297.      * REG_AUDIO_STEREO_DAC
  298.      */
  299.     REG_AUDIO_STEREO_DAC,
  300.     /*!
  301.      * REG_AUDIO_SPARE
  302.      */
  303.     REG_AUDIO_SPARE,
  304.     /*!
  305.      * REG_ADC_0
  306.      */
  307.     REG_ADC_0,
  308.     /*!
  309.      * REG_ADC_1
  310.      */
  311.     REG_ADC_1,
  312.     /*!
  313.      * REG_ADC_2
  314.      */
  315.     REG_ADC_2,
  316.     /*!
  317.      * REG_ADC_3
  318.      */
  319.     REG_ADC_3,
  320.     /*!
  321.      * REG_ADC_4
  322.      */
  323.     REG_ADC_4,
  324.     /*!
  325.      * REG_CHARGER
  326.      */
  327.     REG_CHARGER,
  328.     /*!
  329.      * REG_USB
  330.      */
  331.     REG_USB,
  332.     /*!
  333.      * REG_CHARGE_USB_SPARE
  334.      */
  335.     REG_CHARGE_USB_SPARE,
  336.     /*!
  337.      * REG_LED_CONTROL_0
  338.      */
  339.     REG_LED_CONTROL_0,
  340.     /*!
  341.      * REG_LED_CONTROL_1
  342.      */
  343.     REG_LED_CONTROL_1,
  344.     /*!
  345.      * REG_LED_CONTROL_2
  346.      */
  347.     REG_LED_CONTROL_2,
  348.     /*!
  349.      * REG_LED_CONTROL_3
  350.      */
  351.     REG_LED_CONTROL_3,
  352.     /*!
  353.      * REG_LED_CONTROL_4
  354.      */
  355.     REG_LED_CONTROL_4,
  356.     /*!
  357.      * REG_LED_CONTROL_5
  358.      */
  359.     REG_LED_CONTROL_5,
  360.     /*!
  361.      * REG_SPARE
  362.      */
  363.     REG_SPARE,
  364.     /*!
  365.      * REG_TRIM_0
  366.      */
  367.     REG_TRIM_0,
  368.     /*!
  369.      * REG_TRIM_1
  370.      */
  371.     REG_TRIM_1,
  372.     /*!
  373.      * REG_TEST_0
  374.      */
  375.     REG_TEST_0,
  376.     /*!
  377.      * REG_TEST_1
  378.      */
  379.     REG_TEST_1,
  380.     /*!
  381.      * REG_TEST_2
  382.      */
  383.     REG_TEST_2,
  384.     /*!
  385.      * REG_TEST_3
  386.      */
  387.     REG_TEST_3,
  388.     /*!
  389.      * REG_NB
  390.      */
  391.     REG_NB,
  392. } pmic_reg;
  393.  
  394. /*!
  395.  * This is event list of mc13783 interrupt
  396.  */
  397.  
  398. typedef enum {
  399.     /*!
  400.      * ADC has finished requested conversions
  401.      */
  402.     EVENT_ADCDONEI = 0,
  403.     /*!
  404.      * ADCBIS has finished requested conversions
  405.      */
  406.     EVENT_ADCBISDONEI = 1,
  407.     /*!
  408.      * Touchscreen wakeup
  409.      */
  410.     EVENT_TSI = 2,
  411.     /*!
  412.      * ADC reading above high limit
  413.      */
  414.     EVENT_WHIGHI = 3,
  415.     /*!
  416.      * ADC reading below low limit
  417.      */
  418.     EVENT_WLOWI = 4,
  419.     /*!
  420.      * Charger attach and removal
  421.      */
  422.     EVENT_CHGDETI = 6,
  423.     /*!
  424.      * Charger over-voltage detection
  425.      */
  426.     EVENT_CHGOVI = 7,
  427.     /*!
  428.      * Charger path reverse current
  429.      */
  430.     EVENT_CHGREVI = 8,
  431.     /*!
  432.      * Charger path short circuit
  433.      */
  434.     EVENT_CHGSHORTI = 9,
  435.     /*!
  436.      * BP regulator current or voltage regulation
  437.      */
  438.     EVENT_CCCVI = 10,
  439.     /*!
  440.      * Charge current below threshold
  441.      */
  442.     EVENT_CHRGCURRI = 11,
  443.     /*!
  444.      * BP turn on threshold detection
  445.      */
  446.     EVENT_BPONI = 12,
  447.     /*!
  448.      * End of life / low battery detect
  449.      */
  450.     EVENT_LOBATLI = 13,
  451.     /*!
  452.      * Low battery warning
  453.      */
  454.     EVENT_LOBATHI = 14,
  455.     /*!
  456.      * USB detect
  457.      */
  458.     EVENT_USBI = 16,
  459.     /*!
  460.      * USB ID Line detect
  461.      */
  462.     EVENT_IDI = 19,
  463.     /*!
  464.      * Single ended 1 detect
  465.      */
  466.     EVENT_SE1I = 21,
  467.     /*!
  468.      * Car-kit detect
  469.      */
  470.     EVENT_CKDETI = 22,
  471.     /*!
  472.      * 1 Hz time-tick
  473.      */
  474.     EVENT_E1HZI = 24,
  475.     /*!
  476.      * Time of day alarm
  477.      */
  478.     EVENT_TODAI = 25,
  479.     /*!
  480.      * ON1B event
  481.      */
  482.     EVENT_ONOFD1I = 27,
  483.     /*!
  484.      * ON2B event
  485.      */
  486.     EVENT_ONOFD2I = 28,
  487.     /*!
  488.      * ON3B event
  489.      */
  490.     EVENT_ONOFD3I = 29,
  491.     /*!
  492.      * System reset
  493.      */
  494.     EVENT_SYSRSTI = 30,
  495.     /*!
  496.      * RTC reset occurred
  497.      */
  498.     EVENT_RTCRSTI = 31,
  499.     /*!
  500.      * Power cut event
  501.      */
  502.     EVENT_PCI = 32,
  503.     /*!
  504.      * Warm start event
  505.      */
  506.     EVENT_WARMI = 33,
  507.     /*!
  508.      * Memory hold event
  509.      */
  510.     EVENT_MEMHLDI = 34,
  511.     /*!
  512.      * Power ready
  513.      */
  514.     EVENT_PWRRDYI = 35,
  515.     /*!
  516.      * Thermal warning lower threshold
  517.      */
  518.     EVENT_THWARNLI = 36,
  519.     /*!
  520.      * Thermal warning higher threshold
  521.      */
  522.     EVENT_THWARNHI = 37,
  523.     /*!
  524.      * Clock source change
  525.      */
  526.     EVENT_CLKI = 38,
  527.     /*!
  528.      * Semaphore
  529.      */
  530.     EVENT_SEMAFI = 39,
  531.     /*!
  532.      * Microphone bias 2 detect
  533.      */
  534.     EVENT_MC2BI = 41,
  535.     /*!
  536.      * Headset attach
  537.      */
  538.     EVENT_HSDETI = 42,
  539.     /*!
  540.      * Stereo headset detect
  541.      */
  542.     EVENT_HSLI = 43,
  543.     /*!
  544.      * Thermal shutdown ALSP
  545.      */
  546.     EVENT_ALSPTHI = 44,
  547.     /*!
  548.      * Short circuit on AHS outputs
  549.      */
  550.     EVENT_AHSSHORTI = 45,
  551.     /*!
  552.      * number of event
  553.      */
  554.     EVENT_NB,
  555. } type_event;
  556.  
  557. /*!
  558.  * This enumeration all senses of MC13783.
  559.  */
  560. typedef enum {
  561.     /*!
  562.      * Charger attach sense
  563.      */
  564.     SENSE_CHGDETS = 6,
  565.     /*!
  566.      * Charger over-voltage sense
  567.      */
  568.     SENSE_CHGOVS,
  569.     /*!
  570.      * Charger reverse current
  571.      * If 1 current flows into phone
  572.      */
  573.     SENSE_CHGREVS,
  574.     /*!
  575.      * Charger short circuit
  576.      */
  577.     SENSE_CHGSHORTS,
  578.     /*!
  579.      * Charger regulator operating mode
  580.      */
  581.     SENSE_CCCVS,
  582.     /*!
  583.      * Charger current below threshold
  584.      */
  585.     SENSE_CHGCURRS,
  586.     /*!
  587.      * BP turn on
  588.      */
  589.     SENSE_BPONS,
  590.     /*!
  591.      * Low bat detect
  592.      */
  593.     SENSE_LOBATLS,
  594.     /*!
  595.      * Low bat warning
  596.      */
  597.     SENSE_LOBATHS,
  598.     /*!
  599.      * UDPS
  600.      */
  601.     SENSE_UDPS,
  602.     /*!
  603.      * USB 4V4
  604.      */
  605.     SENSE_USB4V4S,
  606.     /*!
  607.      * USB 2V0
  608.      */
  609.     SENSE_USB2V0S,
  610.     /*!
  611.      * USB 0V8
  612.      */
  613.     SENSE_USB0V8S,
  614.     /*!
  615.      * ID Floats
  616.      */
  617.     SENSE_ID_FLOATS,
  618.     /*!
  619.      * ID Gnds
  620.      */
  621.     SENSE_ID_GNDS,
  622.     /*!
  623.      * Single ended
  624.      */
  625.     SENSE_SE1S,
  626.     /*!
  627.      * Car-kit detect
  628.      */
  629.     SENSE_CKDETS,
  630.     /*!
  631.      * UDMS
  632.      */
  633.     SENSE_UDMS,
  634.     /*!
  635.      * mic bias detect
  636.      */
  637.     SENSE_MC2BS,
  638.     /*!
  639.      * headset attached
  640.      */
  641.     SENSE_HSDETS,
  642.     /*!
  643.      * ST headset attached
  644.      */
  645.     SENSE_HSLS,
  646.     /*!
  647.      * Thermal shutdown ALSP
  648.      */
  649.     SENSE_ALSPTHS,
  650.     /*!
  651.      * short circuit on AHS
  652.      */
  653.     SENSE_AHSSHORTS,
  654.     /*!
  655.      * ON1B pin is hight
  656.      */
  657.     SENSE_ONOFD1S,
  658.     /*!
  659.      * ON2B pin is hight
  660.      */
  661.     SENSE_ONOFD2S,
  662.     /*!
  663.      * ON3B pin is hight
  664.      */
  665.     SENSE_ONOFD3S,
  666.     /*!
  667.      * System reset power ready
  668.      */
  669.     SENSE_PWRRDYS,
  670.     /*!
  671.      * Thermal warning higher threshold
  672.      */
  673.     SENSE_THWARNHS,
  674.     /*!
  675.      * Thermal warning lower threshold
  676.      */
  677.     SENSE_THWARNLS,
  678.     /*!
  679.      * Clock source is XTAL
  680.      */
  681.     SENSE_CLKS,
  682. } t_sensor;
  683.  
  684. /*!
  685.  * This structure is used to read all sense bits of MC13783.
  686.  */
  687. typedef struct {
  688.     /*!
  689.      * Charger attach sense
  690.      */
  691.     bool sense_chgdets;
  692.     /*!
  693.      * Charger over-voltage sense
  694.      */
  695.     bool sense_chgovs;
  696.     /*!
  697.      * Charger reverse current
  698.      * If 1 current flows into phone
  699.      */
  700.     bool sense_chgrevs;
  701.     /*!
  702.      * Charger short circuit
  703.      */
  704.     bool sense_chgshorts;
  705.     /*!
  706.      * Charger regulator operating mode
  707.      */
  708.     bool sense_cccvs;
  709.     /*!
  710.      * Charger current below threshold
  711.      */
  712.     bool sense_chgcurrs;
  713.     /*!
  714.      * BP turn on
  715.      */
  716.     bool sense_bpons;
  717.     /*!
  718.      * Low bat detect
  719.      */
  720.     bool sense_lobatls;
  721.     /*!
  722.      * Low bat warning
  723.      */
  724.     bool sense_lobaths;
  725.     /*!
  726.      * USB 4V4
  727.      */
  728.     bool sense_usb4v4s;
  729.     /*!
  730.      * USB 2V0
  731.      */
  732.     bool sense_usb2v0s;
  733.     /*!
  734.      * USB 0V8
  735.      */
  736.     bool sense_usb0v8s;
  737.     /*!
  738.      * ID Floats
  739.      */
  740.     bool sense_id_floats;
  741.     /*!
  742.      * ID Gnds
  743.      */
  744.     bool sense_id_gnds;
  745.     /*!
  746.      * Single ended
  747.      */
  748.     bool sense_se1s;
  749.     /*!
  750.      * Car-kit detect
  751.      */
  752.     bool sense_ckdets;
  753.     /*!
  754.      * mic bias detect
  755.      */
  756.     bool sense_mc2bs;
  757.     /*!
  758.      * headset attached
  759.      */
  760.     bool sense_hsdets;
  761.     /*!
  762.      * ST headset attached
  763.      */
  764.     bool sense_hsls;
  765.     /*!
  766.      * Thermal shutdown ALSP
  767.      */
  768.     bool sense_alspths;
  769.     /*!
  770.      * short circuit on AHS
  771.      */
  772.     bool sense_ahsshorts;
  773.     /*!
  774.      * ON1B pin is hight
  775.      */
  776.     bool sense_onofd1s;
  777.     /*!
  778.      * ON2B pin is hight
  779.      */
  780.     bool sense_onofd2s;
  781.     /*!
  782.      * ON3B pin is hight
  783.      */
  784.     bool sense_onofd3s;
  785.     /*!
  786.      * System reset power ready
  787.      */
  788.     bool sense_pwrrdys;
  789.     /*!
  790.      * Thermal warning higher threshold
  791.      */
  792.     bool sense_thwarnhs;
  793.     /*!
  794.      * Thermal warning lower threshold
  795.      */
  796.     bool sense_thwarnls;
  797.     /*!
  798.      * Clock source is XTAL
  799.      */
  800.     bool sense_clks;
  801. } t_sensor_bits;
  802.  
  803. #endif                /*CONFIG_MXC_PMIC_MC13783 */
  804.  
  805. #if defined(CONFIG_MXC_PMIC_MC13892_MODULE) || defined(CONFIG_MXC_PMIC_MC13892)
  806. enum {
  807.     REG_INT_STATUS0 = 0,
  808.     REG_INT_MASK0,
  809.     REG_INT_SENSE0,
  810.     REG_INT_STATUS1,
  811.     REG_INT_MASK1,
  812.     REG_INT_SENSE1,
  813.     REG_PU_MODE_S,
  814.     REG_IDENTIFICATION,
  815.     REG_UNUSED0,
  816.     REG_ACC0,
  817.     REG_ACC1,        /*10 */
  818.     REG_UNUSED1,
  819.     REG_UNUSED2,
  820.     REG_POWER_CTL0,
  821.     REG_POWER_CTL1,
  822.     REG_POWER_CTL2,
  823.     REG_REGEN_ASSIGN,
  824.     REG_UNUSED3,
  825.     REG_MEM_A,
  826.     REG_MEM_B,
  827.     REG_RTC_TIME,        /*20 */
  828.     REG_RTC_ALARM,
  829.     REG_RTC_DAY,
  830.     REG_RTC_DAY_ALARM,
  831.     REG_SW_0,
  832.     REG_SW_1,
  833.     REG_SW_2,
  834.     REG_SW_3,
  835.     REG_SW_4,
  836.     REG_SW_5,
  837.     REG_SETTING_0,        /*30 */
  838.     REG_SETTING_1,
  839.     REG_MODE_0,
  840.     REG_MODE_1,
  841.     REG_POWER_MISC,
  842.     REG_UNUSED4,
  843.     REG_UNUSED5,
  844.     REG_UNUSED6,
  845.     REG_UNUSED7,
  846.     REG_UNUSED8,
  847.     REG_UNUSED9,        /*40 */
  848.     REG_UNUSED10,
  849.     REG_UNUSED11,
  850.     REG_ADC0,
  851.     REG_ADC1,
  852.     REG_ADC2,
  853.     REG_ADC3,
  854.     REG_ADC4,
  855.     REG_CHARGE,
  856.     REG_USB0,
  857.     REG_USB1,        /*50 */
  858.     REG_LED_CTL0,
  859.     REG_LED_CTL1,
  860.     REG_LED_CTL2,
  861.     REG_LED_CTL3,
  862.     REG_UNUSED12,
  863.     REG_UNUSED13,
  864.     REG_TRIM0,
  865.     REG_TRIM1,
  866.     REG_TEST0,
  867.     REG_TEST1,        /*60 */
  868.     REG_TEST2,
  869.     REG_TEST3,
  870.     REG_TEST4,
  871. };
  872.  
  873. typedef enum {
  874.     EVENT_ADCDONEI = 0,
  875.     EVENT_ADCBISDONEI = 1,
  876.     EVENT_TSI = 2,
  877.     EVENT_VBUSVI = 3,
  878.     EVENT_IDFACI = 4,
  879.     EVENT_USBOVI = 5,
  880.     EVENT_CHGDETI = 6,
  881.     EVENT_CHGFAULTI = 7,
  882.     EVENT_CHGREVI = 8,
  883.     EVENT_CHGRSHORTI = 9,
  884.     EVENT_CCCVI = 10,
  885.     EVENT_CHGCURRI = 11,
  886.     EVENT_BPONI = 12,
  887.     EVENT_LOBATLI = 13,
  888.     EVENT_LOBATHI = 14,
  889.     EVENT_IDFLOATI = 19,
  890.     EVENT_IDGNDI = 20,
  891.     EVENT_SE1I = 21,
  892.     EVENT_CKDETI = 22,
  893.     EVENT_1HZI = 24,
  894.     EVENT_TODAI = 25,
  895.     EVENT_PWRONI = 27,
  896.     EVENT_WDIRESETI = 29,
  897.     EVENT_SYSRSTI = 30,
  898.     EVENT_RTCRSTI = 31,
  899.     EVENT_PCI = 32,
  900.     EVENT_WARMI = 33,
  901.     EVENT_MEMHLDI = 34,
  902.     EVENT_THWARNLI = 36,
  903.     EVENT_THWARNHI = 37,
  904.     EVENT_CLKI = 38,
  905.     EVENT_SCPI = 40,
  906.     EVENT_LBPI = 44,
  907.     EVENT_NB,
  908. } type_event;
  909.  
  910. typedef enum {
  911.     SENSE_VBUSVS = 3,
  912.     SENSE_IDFACS = 4,
  913.     SENSE_USBOVS = 5,
  914.     SENSE_CHGDETS = 6,
  915.     SENSE_CHGREVS = 8,
  916.     SENSE_CHGRSHORTS = 9,
  917.     SENSE_CCCVS = 10,
  918.     SENSE_CHGCURRS = 11,
  919.     SENSE_BPONS = 12,
  920.     SENSE_LOBATLS = 13,
  921.     SENSE_LOBATHS = 14,
  922.     SENSE_IDFLOATS = 19,
  923.     SENSE_IDGNDS = 20,
  924.     SENSE_SE1S = 21,
  925.     SENSE_PWRONS = 27,
  926.     SENSE_THWARNLS = 36,
  927.     SENSE_THWARNHS = 37,
  928.     SENSE_CLKS = 38,
  929.     SENSE_LBPS = 44,
  930.     SENSE_NB,
  931. } t_sensor;
  932.  
  933. typedef struct {
  934.     bool sense_vbusvs;
  935.     bool sense_idfacs;
  936.     bool sense_usbovs;
  937.     bool sense_chgdets;
  938.     bool sense_chgrevs;
  939.     bool sense_chgrshorts;
  940.     bool sense_cccvs;
  941.     bool sense_chgcurrs;
  942.     bool sense_bpons;
  943.     bool sense_lobatls;
  944.     bool sense_lobaths;
  945.     bool sense_idfloats;
  946.     bool sense_idgnds;
  947.     bool sense_se1s;
  948.     bool sense_pwrons;
  949.     bool sense_thwarnls;
  950.     bool sense_thwarnhs;
  951.     bool sense_clks;
  952.     bool sense_lbps;
  953. } t_sensor_bits;
  954.  
  955. extern struct i2c_client *mc13892_client;
  956. int pmic_i2c_24bit_read(struct i2c_client *client, unsigned int reg_num,
  957.             unsigned int *value);
  958. int pmic_read(int reg_num, unsigned int *reg_val);
  959. int pmic_write(int reg_num, const unsigned int reg_val);
  960. void gpio_pmic_active(void);
  961. void pmic_event_list_init(void);
  962. void mc13892_power_off(void);
  963.  
  964. #endif
  965.  
  966. #if defined(CONFIG_MXC_PMIC_MC34704_MODULE) || defined(CONFIG_MXC_PMIC_MC34704)
  967.  
  968. typedef enum {
  969.     /* register names for mc34704 */
  970.     REG_MC34704_GENERAL1 = 0x01,
  971.     REG_MC34704_GENERAL2 = 0x02,
  972.     REG_MC34704_GENERAL3 = 0x03,
  973.     REG_MC34704_VGSET1 = 0x04,
  974.     REG_MC34704_VGSET2 = 0x05,
  975.     REG_MC34704_REG2SET1 = 0x06,
  976.     REG_MC34704_REG2SET2 = 0x07,
  977.     REG_MC34704_REG3SET1 = 0x08,
  978.     REG_MC34704_REG3SET2 = 0x09,
  979.     REG_MC34704_REG4SET1 = 0x0A,
  980.     REG_MC34704_REG4SET2 = 0x0B,
  981.     REG_MC34704_REG5SET1 = 0x0C,
  982.     REG_MC34704_REG5SET2 = 0x0D,
  983.     REG_MC34704_REG5SET3 = 0x0E,
  984.     REG_MC34704_REG6SET1 = 0x0F,
  985.     REG_MC34704_REG6SET2 = 0x10,
  986.     REG_MC34704_REG6SET3 = 0x11,
  987.     REG_MC34704_REG7SET1 = 0x12,
  988.     REG_MC34704_REG7SET2 = 0x13,
  989.     REG_MC34704_REG7SET3 = 0x14,
  990.     REG_MC34704_REG8SET1 = 0x15,
  991.     REG_MC34704_REG8SET2 = 0x16,
  992.     REG_MC34704_REG8SET3 = 0x17,
  993.     REG_MC34704_FAULTS = 0x18,
  994.     REG_MC34704_I2CSET1 = 0x19,
  995.     REG_MC34704_REG3DAC = 0x49,
  996.     REG_MC34704_REG7CR0 = 0x58,
  997.     REG_MC34704_REG7DAC = 0x59,
  998.     REG_NB = 0x60,
  999. } pmic_reg;
  1000.  
  1001. typedef enum {
  1002.     /* events for mc34704 */
  1003.     EVENT_FLT1 = 0,
  1004.     EVENT_FLT2,
  1005.     EVENT_FLT3,
  1006.     EVENT_FLT4,
  1007.     EVENT_FLT5,
  1008.     EVENT_FLT6,
  1009.     EVENT_FLT7,
  1010.     EVENT_FLT8,
  1011.     EVENT_NB,
  1012. } type_event;
  1013.  
  1014. typedef enum {
  1015.     MCU_SENSOR_NOT_SUPPORT
  1016. } t_sensor;
  1017.  
  1018. typedef enum {
  1019.     MCU_SENSOR_BIT_NOT_SUPPORT
  1020. } t_sensor_bits;
  1021.  
  1022. #endif                /* MXC_PMIC_MC34704 */
  1023.  
  1024. /* EXPORTED FUNCTIONS */
  1025. #ifdef __KERNEL__
  1026.  
  1027. #if defined(CONFIG_MXC_PMIC)
  1028. /*!
  1029.  * This function is used to determine the PMIC type and its revision.
  1030.  *
  1031.  * @return      Returns the PMIC type and its revision.
  1032.  */
  1033. pmic_version_t pmic_get_version(void);
  1034.  
  1035. /*!
  1036.  * This function is called by PMIC clients to read a register on PMIC.
  1037.  *
  1038.  * @param        priority   priority of access
  1039.  * @param        reg        number of register
  1040.  * @param        reg_value   return value of register
  1041.  *
  1042.  * @return       This function returns PMIC_SUCCESS if successful.
  1043.  */
  1044. PMIC_STATUS pmic_read_reg(int reg, unsigned int *reg_value,
  1045.               unsigned int reg_mask);
  1046. /*!
  1047.  * This function is called by PMIC clients to write a register on MC13783.
  1048.  *
  1049.  * @param        priority   priority of access
  1050.  * @param        reg        number of register
  1051.  * @param        reg_value  New value of register
  1052.  * @param        reg_mask   Bitmap mask indicating which bits to modify
  1053.  *
  1054.  * @return       This function returns PMIC_SUCCESS if successful.
  1055.  */
  1056. PMIC_STATUS pmic_write_reg(int reg, unsigned int reg_value,
  1057.                unsigned int reg_mask);
  1058.  
  1059. /*!
  1060.  * This function is called by PMIC clients to subscribe on an event.
  1061.  *
  1062.  * @param        event_sub   structure of event, it contains type of event and callback
  1063.  *
  1064.  * @return       This function returns PMIC_SUCCESS if successful.
  1065.  */
  1066. PMIC_STATUS pmic_event_subscribe(type_event event,
  1067.                  pmic_event_callback_t callback);
  1068. /*!
  1069. * This function is called by PMIC clients to un-subscribe on an event.
  1070. *
  1071. * @param        event_unsub   structure of event, it contains type of event and callback
  1072. *
  1073. * @return       This function returns PMIC_SUCCESS if successful.
  1074. */
  1075. PMIC_STATUS pmic_event_unsubscribe(type_event event,
  1076.                    pmic_event_callback_t callback);
  1077. /*!
  1078. * This function is called to read all sensor bits of PMIC.
  1079. *
  1080. * @param        sensor    Sensor to be checked.
  1081. *
  1082. * @return       This function returns true if the sensor bit is high;
  1083. *               or returns false if the sensor bit is low.
  1084. */
  1085. bool pmic_check_sensor(t_sensor sensor);
  1086.  
  1087. /*!
  1088. * This function checks one sensor of PMIC.
  1089. *
  1090. * @param        sensor_bits  structure of all sensor bits.
  1091. *
  1092. * @return       This function returns PMIC_SUCCESS if successful.
  1093. */
  1094. PMIC_STATUS pmic_get_sensors(t_sensor_bits * sensor_bits);
  1095.  
  1096. void pmic_event_callback(type_event event);
  1097. void pmic_event_list_init(void);
  1098.  
  1099. #ifdef CONFIG_REGULATOR_MC13783
  1100. /*!
  1101.  * This function is used to initialize the regulator for MC13783.
  1102.  *
  1103.  * @return      Returns 0.
  1104.  */
  1105. int reg_mc13783_probe(struct device *dev);
  1106. #else
  1107. static inline int reg_mc13783_probe(struct device *dev)
  1108. {
  1109.     return 0;
  1110. };
  1111. #endif
  1112.  
  1113. #ifdef CONFIG_REGULATOR_MC13892
  1114. int mc13892_regulator_i2c_init(struct i2c_client *client);
  1115. #else
  1116. static inline int mc13892_regulator_i2c_init(struct i2c_client *client)
  1117. {
  1118.     return 0;
  1119. };
  1120. #endif
  1121.  
  1122. #ifdef CONFIG_REGULATOR_MC34704
  1123. int reg_mc34704_probe(void);
  1124. #else
  1125. static inline int reg_mc34704_probe(void)
  1126. {
  1127.     return 0;
  1128. };
  1129. #endif
  1130. #endif                /*CONFIG_MXC_PMIC*/
  1131. #endif                /* __KERNEL__ */
  1132. /* CONFIG_MXC_PMIC_MC13783 || CONFIG_MXC_PMIC_MC9SDZ60 */
  1133.  
  1134. #endif                /* __ASM_ARCH_MXC_PMIC_EXTERNAL_H__ */
  1135.