Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_PMIC_DA903X_H
0003 #define __LINUX_PMIC_DA903X_H
0004 
0005 /* Unified sub device IDs for DA9030/DA9034/DA9035 */
0006 enum {
0007     DA9030_ID_LED_1,
0008     DA9030_ID_LED_2,
0009     DA9030_ID_LED_3,
0010     DA9030_ID_LED_4,
0011     DA9030_ID_LED_PC,
0012     DA9030_ID_VIBRA,
0013     DA9030_ID_WLED,
0014     DA9030_ID_BUCK1,
0015     DA9030_ID_BUCK2,
0016     DA9030_ID_LDO1,
0017     DA9030_ID_LDO2,
0018     DA9030_ID_LDO3,
0019     DA9030_ID_LDO4,
0020     DA9030_ID_LDO5,
0021     DA9030_ID_LDO6,
0022     DA9030_ID_LDO7,
0023     DA9030_ID_LDO8,
0024     DA9030_ID_LDO9,
0025     DA9030_ID_LDO10,
0026     DA9030_ID_LDO11,
0027     DA9030_ID_LDO12,
0028     DA9030_ID_LDO13,
0029     DA9030_ID_LDO14,
0030     DA9030_ID_LDO15,
0031     DA9030_ID_LDO16,
0032     DA9030_ID_LDO17,
0033     DA9030_ID_LDO18,
0034     DA9030_ID_LDO19,
0035     DA9030_ID_LDO_INT,  /* LDO Internal */
0036     DA9030_ID_BAT,      /* battery charger */
0037 
0038     DA9034_ID_LED_1,
0039     DA9034_ID_LED_2,
0040     DA9034_ID_VIBRA,
0041     DA9034_ID_WLED,
0042     DA9034_ID_TOUCH,
0043 
0044     DA9034_ID_BUCK1,
0045     DA9034_ID_BUCK2,
0046     DA9034_ID_LDO1,
0047     DA9034_ID_LDO2,
0048     DA9034_ID_LDO3,
0049     DA9034_ID_LDO4,
0050     DA9034_ID_LDO5,
0051     DA9034_ID_LDO6,
0052     DA9034_ID_LDO7,
0053     DA9034_ID_LDO8,
0054     DA9034_ID_LDO9,
0055     DA9034_ID_LDO10,
0056     DA9034_ID_LDO11,
0057     DA9034_ID_LDO12,
0058     DA9034_ID_LDO13,
0059     DA9034_ID_LDO14,
0060     DA9034_ID_LDO15,
0061 
0062     DA9035_ID_BUCK3,
0063 };
0064 
0065 /*
0066  * DA9030/DA9034 LEDs sub-devices uses generic "struct led_info"
0067  * as the platform_data
0068  */
0069 
0070 /* DA9030 flags for "struct led_info"
0071  */
0072 #define DA9030_LED_RATE_ON  (0 << 5)
0073 #define DA9030_LED_RATE_052S    (1 << 5)
0074 #define DA9030_LED_DUTY_1_16    (0 << 3)
0075 #define DA9030_LED_DUTY_1_8 (1 << 3)
0076 #define DA9030_LED_DUTY_1_4 (2 << 3)
0077 #define DA9030_LED_DUTY_1_2 (3 << 3)
0078 
0079 #define DA9030_VIBRA_MODE_1P3V  (0 << 1)
0080 #define DA9030_VIBRA_MODE_2P7V  (1 << 1)
0081 #define DA9030_VIBRA_FREQ_1HZ   (0 << 2)
0082 #define DA9030_VIBRA_FREQ_2HZ   (1 << 2)
0083 #define DA9030_VIBRA_FREQ_4HZ   (2 << 2)
0084 #define DA9030_VIBRA_FREQ_8HZ   (3 << 2)
0085 #define DA9030_VIBRA_DUTY_ON    (0 << 4)
0086 #define DA9030_VIBRA_DUTY_75P   (1 << 4)
0087 #define DA9030_VIBRA_DUTY_50P   (2 << 4)
0088 #define DA9030_VIBRA_DUTY_25P   (3 << 4)
0089 
0090 /* DA9034 flags for "struct led_info" */
0091 #define DA9034_LED_RAMP     (1 << 7)
0092 
0093 /* DA9034 touch screen platform data */
0094 struct da9034_touch_pdata {
0095     int interval_ms;    /* sampling interval while pen down */
0096     int x_inverted;
0097     int y_inverted;
0098 };
0099 
0100 struct da9034_backlight_pdata {
0101     int output_current; /* output current of WLED, from 0-31 (in mA) */
0102 };
0103 
0104 /* DA9030 battery charger data */
0105 struct power_supply_info;
0106 
0107 struct da9030_battery_info {
0108     /* battery parameters */
0109     struct power_supply_info *battery_info;
0110 
0111     /* current and voltage to use for battery charging */
0112     unsigned int charge_milliamp;
0113     unsigned int charge_millivolt;
0114 
0115     /* voltage thresholds (in millivolts) */
0116     int vbat_low;
0117     int vbat_crit;
0118     int vbat_charge_start;
0119     int vbat_charge_stop;
0120     int vbat_charge_restart;
0121 
0122     /* battery nominal minimal and maximal voltages in millivolts */
0123     int vcharge_min;
0124     int vcharge_max;
0125 
0126     /* Temperature thresholds. These are DA9030 register values
0127        "as is" and should be measured for each battery type */
0128     int tbat_low;
0129     int tbat_high;
0130     int tbat_restart;
0131 
0132 
0133     /* battery monitor interval (seconds) */
0134     unsigned int batmon_interval;
0135 
0136     /* platform callbacks for battery low and critical events */
0137     void (*battery_low)(void);
0138     void (*battery_critical)(void);
0139 };
0140 
0141 struct da903x_subdev_info {
0142     int     id;
0143     const char  *name;
0144     void        *platform_data;
0145 };
0146 
0147 struct da903x_platform_data {
0148     int num_subdevs;
0149     struct da903x_subdev_info *subdevs;
0150 };
0151 
0152 /* bit definitions for DA9030 events */
0153 #define DA9030_EVENT_ONKEY      (1 << 0)
0154 #define DA9030_EVENT_PWREN      (1 << 1)
0155 #define DA9030_EVENT_EXTON      (1 << 2)
0156 #define DA9030_EVENT_CHDET      (1 << 3)
0157 #define DA9030_EVENT_TBAT       (1 << 4)
0158 #define DA9030_EVENT_VBATMON        (1 << 5)
0159 #define DA9030_EVENT_VBATMON_TXON   (1 << 6)
0160 #define DA9030_EVENT_CHIOVER        (1 << 7)
0161 #define DA9030_EVENT_TCTO       (1 << 8)
0162 #define DA9030_EVENT_CCTO       (1 << 9)
0163 #define DA9030_EVENT_ADC_READY      (1 << 10)
0164 #define DA9030_EVENT_VBUS_4P4       (1 << 11)
0165 #define DA9030_EVENT_VBUS_4P0       (1 << 12)
0166 #define DA9030_EVENT_SESS_VALID     (1 << 13)
0167 #define DA9030_EVENT_SRP_DETECT     (1 << 14)
0168 #define DA9030_EVENT_WATCHDOG       (1 << 15)
0169 #define DA9030_EVENT_LDO15      (1 << 16)
0170 #define DA9030_EVENT_LDO16      (1 << 17)
0171 #define DA9030_EVENT_LDO17      (1 << 18)
0172 #define DA9030_EVENT_LDO18      (1 << 19)
0173 #define DA9030_EVENT_LDO19      (1 << 20)
0174 #define DA9030_EVENT_BUCK2      (1 << 21)
0175 
0176 /* bit definitions for DA9034 events */
0177 #define DA9034_EVENT_ONKEY      (1 << 0)
0178 #define DA9034_EVENT_EXTON      (1 << 2)
0179 #define DA9034_EVENT_CHDET      (1 << 3)
0180 #define DA9034_EVENT_TBAT       (1 << 4)
0181 #define DA9034_EVENT_VBATMON        (1 << 5)
0182 #define DA9034_EVENT_REV_IOVER      (1 << 6)
0183 #define DA9034_EVENT_CH_IOVER       (1 << 7)
0184 #define DA9034_EVENT_CH_TCTO        (1 << 8)
0185 #define DA9034_EVENT_CH_CCTO        (1 << 9)
0186 #define DA9034_EVENT_USB_DEV        (1 << 10)
0187 #define DA9034_EVENT_OTGCP_IOVER    (1 << 11)
0188 #define DA9034_EVENT_VBUS_4P55      (1 << 12)
0189 #define DA9034_EVENT_VBUS_3P8       (1 << 13)
0190 #define DA9034_EVENT_SESS_1P8       (1 << 14)
0191 #define DA9034_EVENT_SRP_READY      (1 << 15)
0192 #define DA9034_EVENT_ADC_MAN        (1 << 16)
0193 #define DA9034_EVENT_ADC_AUTO4      (1 << 17)
0194 #define DA9034_EVENT_ADC_AUTO5      (1 << 18)
0195 #define DA9034_EVENT_ADC_AUTO6      (1 << 19)
0196 #define DA9034_EVENT_PEN_DOWN       (1 << 20)
0197 #define DA9034_EVENT_TSI_READY      (1 << 21)
0198 #define DA9034_EVENT_UART_TX        (1 << 22)
0199 #define DA9034_EVENT_UART_RX        (1 << 23)
0200 #define DA9034_EVENT_HEADSET        (1 << 25)
0201 #define DA9034_EVENT_HOOKSWITCH     (1 << 26)
0202 #define DA9034_EVENT_WATCHDOG       (1 << 27)
0203 
0204 extern int da903x_register_notifier(struct device *dev,
0205         struct notifier_block *nb, unsigned int events);
0206 extern int da903x_unregister_notifier(struct device *dev,
0207         struct notifier_block *nb, unsigned int events);
0208 
0209 /* Status Query Interface */
0210 #define DA9030_STATUS_ONKEY     (1 << 0)
0211 #define DA9030_STATUS_PWREN1        (1 << 1)
0212 #define DA9030_STATUS_EXTON     (1 << 2)
0213 #define DA9030_STATUS_CHDET     (1 << 3)
0214 #define DA9030_STATUS_TBAT      (1 << 4)
0215 #define DA9030_STATUS_VBATMON       (1 << 5)
0216 #define DA9030_STATUS_VBATMON_TXON  (1 << 6)
0217 #define DA9030_STATUS_MCLKDET       (1 << 7)
0218 
0219 #define DA9034_STATUS_ONKEY     (1 << 0)
0220 #define DA9034_STATUS_EXTON     (1 << 2)
0221 #define DA9034_STATUS_CHDET     (1 << 3)
0222 #define DA9034_STATUS_TBAT      (1 << 4)
0223 #define DA9034_STATUS_VBATMON       (1 << 5)
0224 #define DA9034_STATUS_PEN_DOWN      (1 << 6)
0225 #define DA9034_STATUS_MCLKDET       (1 << 7)
0226 #define DA9034_STATUS_USB_DEV       (1 << 8)
0227 #define DA9034_STATUS_HEADSET       (1 << 9)
0228 #define DA9034_STATUS_HOOKSWITCH    (1 << 10)
0229 #define DA9034_STATUS_REMCON        (1 << 11)
0230 #define DA9034_STATUS_VBUS_VALID_4P55   (1 << 12)
0231 #define DA9034_STATUS_VBUS_VALID_3P8    (1 << 13)
0232 #define DA9034_STATUS_SESS_VALID_1P8    (1 << 14)
0233 #define DA9034_STATUS_SRP_READY     (1 << 15)
0234 
0235 extern int da903x_query_status(struct device *dev, unsigned int status);
0236 
0237 
0238 /* NOTE: the functions below are not intended for use outside
0239  * of the DA903x sub-device drivers
0240  */
0241 extern int da903x_write(struct device *dev, int reg, uint8_t val);
0242 extern int da903x_writes(struct device *dev, int reg, int len, uint8_t *val);
0243 extern int da903x_read(struct device *dev, int reg, uint8_t *val);
0244 extern int da903x_reads(struct device *dev, int reg, int len, uint8_t *val);
0245 extern int da903x_update(struct device *dev, int reg, uint8_t val, uint8_t mask);
0246 extern int da903x_set_bits(struct device *dev, int reg, uint8_t bit_mask);
0247 extern int da903x_clr_bits(struct device *dev, int reg, uint8_t bit_mask);
0248 #endif /* __LINUX_PMIC_DA903X_H */