diff options
Diffstat (limited to 'include/linux/mfd/axp20x.h')
| -rw-r--r-- | include/linux/mfd/axp20x.h | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h new file mode 100644 index 000000000000..d0e31a2287ac --- /dev/null +++ b/include/linux/mfd/axp20x.h | |||
| @@ -0,0 +1,180 @@ | |||
| 1 | /* | ||
| 2 | * Functions and registers to access AXP20X power management chip. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Carlo Caione <carlo@caione.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __LINUX_MFD_AXP20X_H | ||
| 12 | #define __LINUX_MFD_AXP20X_H | ||
| 13 | |||
| 14 | enum { | ||
| 15 | AXP202_ID = 0, | ||
| 16 | AXP209_ID, | ||
| 17 | }; | ||
| 18 | |||
| 19 | #define AXP20X_DATACACHE(m) (0x04 + (m)) | ||
| 20 | |||
| 21 | /* Power supply */ | ||
| 22 | #define AXP20X_PWR_INPUT_STATUS 0x00 | ||
| 23 | #define AXP20X_PWR_OP_MODE 0x01 | ||
| 24 | #define AXP20X_USB_OTG_STATUS 0x02 | ||
| 25 | #define AXP20X_PWR_OUT_CTRL 0x12 | ||
| 26 | #define AXP20X_DCDC2_V_OUT 0x23 | ||
| 27 | #define AXP20X_DCDC2_LDO3_V_SCAL 0x25 | ||
| 28 | #define AXP20X_DCDC3_V_OUT 0x27 | ||
| 29 | #define AXP20X_LDO24_V_OUT 0x28 | ||
| 30 | #define AXP20X_LDO3_V_OUT 0x29 | ||
| 31 | #define AXP20X_VBUS_IPSOUT_MGMT 0x30 | ||
| 32 | #define AXP20X_V_OFF 0x31 | ||
| 33 | #define AXP20X_OFF_CTRL 0x32 | ||
| 34 | #define AXP20X_CHRG_CTRL1 0x33 | ||
| 35 | #define AXP20X_CHRG_CTRL2 0x34 | ||
| 36 | #define AXP20X_CHRG_BAK_CTRL 0x35 | ||
| 37 | #define AXP20X_PEK_KEY 0x36 | ||
| 38 | #define AXP20X_DCDC_FREQ 0x37 | ||
| 39 | #define AXP20X_V_LTF_CHRG 0x38 | ||
| 40 | #define AXP20X_V_HTF_CHRG 0x39 | ||
| 41 | #define AXP20X_APS_WARN_L1 0x3a | ||
| 42 | #define AXP20X_APS_WARN_L2 0x3b | ||
| 43 | #define AXP20X_V_LTF_DISCHRG 0x3c | ||
| 44 | #define AXP20X_V_HTF_DISCHRG 0x3d | ||
| 45 | |||
| 46 | /* Interrupt */ | ||
| 47 | #define AXP20X_IRQ1_EN 0x40 | ||
| 48 | #define AXP20X_IRQ2_EN 0x41 | ||
| 49 | #define AXP20X_IRQ3_EN 0x42 | ||
| 50 | #define AXP20X_IRQ4_EN 0x43 | ||
| 51 | #define AXP20X_IRQ5_EN 0x44 | ||
| 52 | #define AXP20X_IRQ1_STATE 0x48 | ||
| 53 | #define AXP20X_IRQ2_STATE 0x49 | ||
| 54 | #define AXP20X_IRQ3_STATE 0x4a | ||
| 55 | #define AXP20X_IRQ4_STATE 0x4b | ||
| 56 | #define AXP20X_IRQ5_STATE 0x4c | ||
| 57 | |||
| 58 | /* ADC */ | ||
| 59 | #define AXP20X_ACIN_V_ADC_H 0x56 | ||
| 60 | #define AXP20X_ACIN_V_ADC_L 0x57 | ||
| 61 | #define AXP20X_ACIN_I_ADC_H 0x58 | ||
| 62 | #define AXP20X_ACIN_I_ADC_L 0x59 | ||
| 63 | #define AXP20X_VBUS_V_ADC_H 0x5a | ||
| 64 | #define AXP20X_VBUS_V_ADC_L 0x5b | ||
| 65 | #define AXP20X_VBUS_I_ADC_H 0x5c | ||
| 66 | #define AXP20X_VBUS_I_ADC_L 0x5d | ||
| 67 | #define AXP20X_TEMP_ADC_H 0x5e | ||
| 68 | #define AXP20X_TEMP_ADC_L 0x5f | ||
| 69 | #define AXP20X_TS_IN_H 0x62 | ||
| 70 | #define AXP20X_TS_IN_L 0x63 | ||
| 71 | #define AXP20X_GPIO0_V_ADC_H 0x64 | ||
| 72 | #define AXP20X_GPIO0_V_ADC_L 0x65 | ||
| 73 | #define AXP20X_GPIO1_V_ADC_H 0x66 | ||
| 74 | #define AXP20X_GPIO1_V_ADC_L 0x67 | ||
| 75 | #define AXP20X_PWR_BATT_H 0x70 | ||
| 76 | #define AXP20X_PWR_BATT_M 0x71 | ||
| 77 | #define AXP20X_PWR_BATT_L 0x72 | ||
| 78 | #define AXP20X_BATT_V_H 0x78 | ||
| 79 | #define AXP20X_BATT_V_L 0x79 | ||
| 80 | #define AXP20X_BATT_CHRG_I_H 0x7a | ||
| 81 | #define AXP20X_BATT_CHRG_I_L 0x7b | ||
| 82 | #define AXP20X_BATT_DISCHRG_I_H 0x7c | ||
| 83 | #define AXP20X_BATT_DISCHRG_I_L 0x7d | ||
| 84 | #define AXP20X_IPSOUT_V_HIGH_H 0x7e | ||
| 85 | #define AXP20X_IPSOUT_V_HIGH_L 0x7f | ||
| 86 | |||
| 87 | /* Power supply */ | ||
| 88 | #define AXP20X_DCDC_MODE 0x80 | ||
| 89 | #define AXP20X_ADC_EN1 0x82 | ||
| 90 | #define AXP20X_ADC_EN2 0x83 | ||
| 91 | #define AXP20X_ADC_RATE 0x84 | ||
| 92 | #define AXP20X_GPIO10_IN_RANGE 0x85 | ||
| 93 | #define AXP20X_GPIO1_ADC_IRQ_RIS 0x86 | ||
| 94 | #define AXP20X_GPIO1_ADC_IRQ_FAL 0x87 | ||
| 95 | #define AXP20X_TIMER_CTRL 0x8a | ||
| 96 | #define AXP20X_VBUS_MON 0x8b | ||
| 97 | #define AXP20X_OVER_TMP 0x8f | ||
| 98 | |||
| 99 | /* GPIO */ | ||
| 100 | #define AXP20X_GPIO0_CTRL 0x90 | ||
| 101 | #define AXP20X_LDO5_V_OUT 0x91 | ||
| 102 | #define AXP20X_GPIO1_CTRL 0x92 | ||
| 103 | #define AXP20X_GPIO2_CTRL 0x93 | ||
| 104 | #define AXP20X_GPIO20_SS 0x94 | ||
| 105 | #define AXP20X_GPIO3_CTRL 0x95 | ||
| 106 | |||
| 107 | /* Battery */ | ||
| 108 | #define AXP20X_CHRG_CC_31_24 0xb0 | ||
| 109 | #define AXP20X_CHRG_CC_23_16 0xb1 | ||
| 110 | #define AXP20X_CHRG_CC_15_8 0xb2 | ||
| 111 | #define AXP20X_CHRG_CC_7_0 0xb3 | ||
| 112 | #define AXP20X_DISCHRG_CC_31_24 0xb4 | ||
| 113 | #define AXP20X_DISCHRG_CC_23_16 0xb5 | ||
| 114 | #define AXP20X_DISCHRG_CC_15_8 0xb6 | ||
| 115 | #define AXP20X_DISCHRG_CC_7_0 0xb7 | ||
| 116 | #define AXP20X_CC_CTRL 0xb8 | ||
| 117 | #define AXP20X_FG_RES 0xb9 | ||
| 118 | |||
| 119 | /* Regulators IDs */ | ||
| 120 | enum { | ||
| 121 | AXP20X_LDO1 = 0, | ||
| 122 | AXP20X_LDO2, | ||
| 123 | AXP20X_LDO3, | ||
| 124 | AXP20X_LDO4, | ||
| 125 | AXP20X_LDO5, | ||
| 126 | AXP20X_DCDC2, | ||
| 127 | AXP20X_DCDC3, | ||
| 128 | AXP20X_REG_ID_MAX, | ||
| 129 | }; | ||
| 130 | |||
| 131 | /* IRQs */ | ||
| 132 | enum { | ||
| 133 | AXP20X_IRQ_ACIN_OVER_V = 1, | ||
| 134 | AXP20X_IRQ_ACIN_PLUGIN, | ||
| 135 | AXP20X_IRQ_ACIN_REMOVAL, | ||
| 136 | AXP20X_IRQ_VBUS_OVER_V, | ||
| 137 | AXP20X_IRQ_VBUS_PLUGIN, | ||
| 138 | AXP20X_IRQ_VBUS_REMOVAL, | ||
| 139 | AXP20X_IRQ_VBUS_V_LOW, | ||
| 140 | AXP20X_IRQ_BATT_PLUGIN, | ||
| 141 | AXP20X_IRQ_BATT_REMOVAL, | ||
| 142 | AXP20X_IRQ_BATT_ENT_ACT_MODE, | ||
| 143 | AXP20X_IRQ_BATT_EXIT_ACT_MODE, | ||
| 144 | AXP20X_IRQ_CHARG, | ||
| 145 | AXP20X_IRQ_CHARG_DONE, | ||
| 146 | AXP20X_IRQ_BATT_TEMP_HIGH, | ||
| 147 | AXP20X_IRQ_BATT_TEMP_LOW, | ||
| 148 | AXP20X_IRQ_DIE_TEMP_HIGH, | ||
| 149 | AXP20X_IRQ_CHARG_I_LOW, | ||
| 150 | AXP20X_IRQ_DCDC1_V_LONG, | ||
| 151 | AXP20X_IRQ_DCDC2_V_LONG, | ||
| 152 | AXP20X_IRQ_DCDC3_V_LONG, | ||
| 153 | AXP20X_IRQ_PEK_SHORT = 22, | ||
| 154 | AXP20X_IRQ_PEK_LONG, | ||
| 155 | AXP20X_IRQ_N_OE_PWR_ON, | ||
| 156 | AXP20X_IRQ_N_OE_PWR_OFF, | ||
| 157 | AXP20X_IRQ_VBUS_VALID, | ||
| 158 | AXP20X_IRQ_VBUS_NOT_VALID, | ||
| 159 | AXP20X_IRQ_VBUS_SESS_VALID, | ||
| 160 | AXP20X_IRQ_VBUS_SESS_END, | ||
| 161 | AXP20X_IRQ_LOW_PWR_LVL1, | ||
| 162 | AXP20X_IRQ_LOW_PWR_LVL2, | ||
| 163 | AXP20X_IRQ_TIMER, | ||
| 164 | AXP20X_IRQ_PEK_RIS_EDGE, | ||
| 165 | AXP20X_IRQ_PEK_FAL_EDGE, | ||
| 166 | AXP20X_IRQ_GPIO3_INPUT, | ||
| 167 | AXP20X_IRQ_GPIO2_INPUT, | ||
| 168 | AXP20X_IRQ_GPIO1_INPUT, | ||
| 169 | AXP20X_IRQ_GPIO0_INPUT, | ||
| 170 | }; | ||
| 171 | |||
| 172 | struct axp20x_dev { | ||
| 173 | struct device *dev; | ||
| 174 | struct i2c_client *i2c_client; | ||
| 175 | struct regmap *regmap; | ||
| 176 | struct regmap_irq_chip_data *regmap_irqc; | ||
| 177 | long variant; | ||
| 178 | }; | ||
| 179 | |||
| 180 | #endif /* __LINUX_MFD_AXP20X_H */ | ||
