Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Maxim8925 Interface
0004  *
0005  * Copyright (C) 2009 Marvell International Ltd.
0006  *  Haojian Zhuang <haojian.zhuang@marvell.com>
0007  */
0008 
0009 #ifndef __LINUX_MFD_MAX8925_H
0010 #define __LINUX_MFD_MAX8925_H
0011 
0012 #include <linux/mutex.h>
0013 #include <linux/interrupt.h>
0014 
0015 /* Unified sub device IDs for MAX8925 */
0016 enum {
0017     MAX8925_ID_SD1,
0018     MAX8925_ID_SD2,
0019     MAX8925_ID_SD3,
0020     MAX8925_ID_LDO1,
0021     MAX8925_ID_LDO2,
0022     MAX8925_ID_LDO3,
0023     MAX8925_ID_LDO4,
0024     MAX8925_ID_LDO5,
0025     MAX8925_ID_LDO6,
0026     MAX8925_ID_LDO7,
0027     MAX8925_ID_LDO8,
0028     MAX8925_ID_LDO9,
0029     MAX8925_ID_LDO10,
0030     MAX8925_ID_LDO11,
0031     MAX8925_ID_LDO12,
0032     MAX8925_ID_LDO13,
0033     MAX8925_ID_LDO14,
0034     MAX8925_ID_LDO15,
0035     MAX8925_ID_LDO16,
0036     MAX8925_ID_LDO17,
0037     MAX8925_ID_LDO18,
0038     MAX8925_ID_LDO19,
0039     MAX8925_ID_LDO20,
0040     MAX8925_ID_MAX,
0041 };
0042 
0043 enum {
0044     /*
0045      * Charging current threshold trigger going from fast charge
0046      * to TOPOFF charge. From 5% to 20% of fasting charging current.
0047      */
0048     MAX8925_TOPOFF_THR_5PER,
0049     MAX8925_TOPOFF_THR_10PER,
0050     MAX8925_TOPOFF_THR_15PER,
0051     MAX8925_TOPOFF_THR_20PER,
0052 };
0053 
0054 enum {
0055     /* Fast charging current */
0056     MAX8925_FCHG_85MA,
0057     MAX8925_FCHG_300MA,
0058     MAX8925_FCHG_460MA,
0059     MAX8925_FCHG_600MA,
0060     MAX8925_FCHG_700MA,
0061     MAX8925_FCHG_800MA,
0062     MAX8925_FCHG_900MA,
0063     MAX8925_FCHG_1000MA,
0064 };
0065 
0066 /* Charger registers */
0067 #define MAX8925_CHG_IRQ1        (0x7e)
0068 #define MAX8925_CHG_IRQ2        (0x7f)
0069 #define MAX8925_CHG_IRQ1_MASK       (0x80)
0070 #define MAX8925_CHG_IRQ2_MASK       (0x81)
0071 #define MAX8925_CHG_STATUS      (0x82)
0072 
0073 /* GPM registers */
0074 #define MAX8925_SYSENSEL        (0x00)
0075 #define MAX8925_ON_OFF_IRQ1     (0x01)
0076 #define MAX8925_ON_OFF_IRQ1_MASK    (0x02)
0077 #define MAX8925_ON_OFF_STATUS       (0x03)
0078 #define MAX8925_ON_OFF_IRQ2     (0x0d)
0079 #define MAX8925_ON_OFF_IRQ2_MASK    (0x0e)
0080 #define MAX8925_RESET_CNFG      (0x0f)
0081 
0082 /* Touch registers */
0083 #define MAX8925_TSC_IRQ         (0x00)
0084 #define MAX8925_TSC_IRQ_MASK        (0x01)
0085 #define MAX8925_TSC_CNFG1       (0x02)
0086 #define MAX8925_ADC_SCHED       (0x10)
0087 #define MAX8925_ADC_RES_END     (0x6f)
0088 
0089 #define MAX8925_NREF_OK         (1 << 4)
0090 
0091 /* RTC registers */
0092 #define MAX8925_ALARM0_CNTL     (0x18)
0093 #define MAX8925_ALARM1_CNTL     (0x19)
0094 #define MAX8925_RTC_IRQ         (0x1c)
0095 #define MAX8925_RTC_IRQ_MASK        (0x1d)
0096 #define MAX8925_MPL_CNTL        (0x1e)
0097 
0098 /* WLED registers */
0099 #define MAX8925_WLED_MODE_CNTL      (0x84)
0100 #define MAX8925_WLED_CNTL       (0x85)
0101 
0102 /* MAX8925 Registers */
0103 #define MAX8925_SDCTL1          (0x04)
0104 #define MAX8925_SDCTL2          (0x07)
0105 #define MAX8925_SDCTL3          (0x0A)
0106 #define MAX8925_SDV1            (0x06)
0107 #define MAX8925_SDV2            (0x09)
0108 #define MAX8925_SDV3            (0x0C)
0109 #define MAX8925_LDOCTL1         (0x18)
0110 #define MAX8925_LDOCTL2         (0x1C)
0111 #define MAX8925_LDOCTL3         (0x20)
0112 #define MAX8925_LDOCTL4         (0x24)
0113 #define MAX8925_LDOCTL5         (0x28)
0114 #define MAX8925_LDOCTL6         (0x2C)
0115 #define MAX8925_LDOCTL7         (0x30)
0116 #define MAX8925_LDOCTL8         (0x34)
0117 #define MAX8925_LDOCTL9         (0x38)
0118 #define MAX8925_LDOCTL10        (0x3C)
0119 #define MAX8925_LDOCTL11        (0x40)
0120 #define MAX8925_LDOCTL12        (0x44)
0121 #define MAX8925_LDOCTL13        (0x48)
0122 #define MAX8925_LDOCTL14        (0x4C)
0123 #define MAX8925_LDOCTL15        (0x50)
0124 #define MAX8925_LDOCTL16        (0x10)
0125 #define MAX8925_LDOCTL17        (0x14)
0126 #define MAX8925_LDOCTL18        (0x72)
0127 #define MAX8925_LDOCTL19        (0x5C)
0128 #define MAX8925_LDOCTL20        (0x9C)
0129 #define MAX8925_LDOVOUT1        (0x1A)
0130 #define MAX8925_LDOVOUT2        (0x1E)
0131 #define MAX8925_LDOVOUT3        (0x22)
0132 #define MAX8925_LDOVOUT4        (0x26)
0133 #define MAX8925_LDOVOUT5        (0x2A)
0134 #define MAX8925_LDOVOUT6        (0x2E)
0135 #define MAX8925_LDOVOUT7        (0x32)
0136 #define MAX8925_LDOVOUT8        (0x36)
0137 #define MAX8925_LDOVOUT9        (0x3A)
0138 #define MAX8925_LDOVOUT10       (0x3E)
0139 #define MAX8925_LDOVOUT11       (0x42)
0140 #define MAX8925_LDOVOUT12       (0x46)
0141 #define MAX8925_LDOVOUT13       (0x4A)
0142 #define MAX8925_LDOVOUT14       (0x4E)
0143 #define MAX8925_LDOVOUT15       (0x52)
0144 #define MAX8925_LDOVOUT16       (0x12)
0145 #define MAX8925_LDOVOUT17       (0x16)
0146 #define MAX8925_LDOVOUT18       (0x74)
0147 #define MAX8925_LDOVOUT19       (0x5E)
0148 #define MAX8925_LDOVOUT20       (0x9E)
0149 
0150 /* bit definitions */
0151 #define CHG_IRQ1_MASK           (0x07)
0152 #define CHG_IRQ2_MASK           (0xff)
0153 #define ON_OFF_IRQ1_MASK        (0xff)
0154 #define ON_OFF_IRQ2_MASK        (0x03)
0155 #define TSC_IRQ_MASK            (0x03)
0156 #define RTC_IRQ_MASK            (0x0c)
0157 
0158 #define MAX8925_NAME_SIZE       (32)
0159 
0160 /* IRQ definitions */
0161 enum {
0162     MAX8925_IRQ_VCHG_DC_OVP,
0163     MAX8925_IRQ_VCHG_DC_F,
0164     MAX8925_IRQ_VCHG_DC_R,
0165     MAX8925_IRQ_VCHG_THM_OK_R,
0166     MAX8925_IRQ_VCHG_THM_OK_F,
0167     MAX8925_IRQ_VCHG_SYSLOW_F,
0168     MAX8925_IRQ_VCHG_SYSLOW_R,
0169     MAX8925_IRQ_VCHG_RST,
0170     MAX8925_IRQ_VCHG_DONE,
0171     MAX8925_IRQ_VCHG_TOPOFF,
0172     MAX8925_IRQ_VCHG_TMR_FAULT,
0173     MAX8925_IRQ_GPM_RSTIN,
0174     MAX8925_IRQ_GPM_MPL,
0175     MAX8925_IRQ_GPM_SW_3SEC,
0176     MAX8925_IRQ_GPM_EXTON_F,
0177     MAX8925_IRQ_GPM_EXTON_R,
0178     MAX8925_IRQ_GPM_SW_1SEC,
0179     MAX8925_IRQ_GPM_SW_F,
0180     MAX8925_IRQ_GPM_SW_R,
0181     MAX8925_IRQ_GPM_SYSCKEN_F,
0182     MAX8925_IRQ_GPM_SYSCKEN_R,
0183     MAX8925_IRQ_RTC_ALARM1,
0184     MAX8925_IRQ_RTC_ALARM0,
0185     MAX8925_IRQ_TSC_STICK,
0186     MAX8925_IRQ_TSC_NSTICK,
0187     MAX8925_NR_IRQS,
0188 };
0189 
0190 
0191 
0192 struct max8925_chip {
0193     struct device       *dev;
0194     struct i2c_client   *i2c;
0195     struct i2c_client   *adc;
0196     struct i2c_client   *rtc;
0197     struct mutex        io_lock;
0198     struct mutex        irq_lock;
0199 
0200     int         irq_base;
0201     int         core_irq;
0202     int         tsc_irq;
0203     unsigned int            wakeup_flag;
0204 };
0205 
0206 struct max8925_backlight_pdata {
0207     int lxw_scl;    /* 0/1 -- 0.8Ohm/0.4Ohm */
0208     int lxw_freq;   /* 700KHz ~ 1400KHz */
0209     int dual_string;    /* 0/1 -- single/dual string */
0210 };
0211 
0212 struct max8925_touch_pdata {
0213     unsigned int        flags;
0214 };
0215 
0216 struct max8925_power_pdata {
0217     int     (*set_charger)(int);
0218     unsigned    batt_detect:1;
0219     unsigned    topoff_threshold:2;
0220     unsigned    fast_charge:3;  /* charge current */
0221     unsigned    no_temp_support:1; /* set if no temperature detect */
0222     unsigned    no_insert_detect:1; /* set if no ac insert detect */
0223     char        **supplied_to;
0224     int     num_supplicants;
0225 };
0226 
0227 /*
0228  * irq_base: stores IRQ base number of MAX8925 in platform
0229  * tsc_irq: stores IRQ number of MAX8925 TSC
0230  */
0231 struct max8925_platform_data {
0232     struct max8925_backlight_pdata  *backlight;
0233     struct max8925_touch_pdata  *touch;
0234     struct max8925_power_pdata  *power;
0235     struct regulator_init_data  *sd1;
0236     struct regulator_init_data  *sd2;
0237     struct regulator_init_data  *sd3;
0238     struct regulator_init_data  *ldo1;
0239     struct regulator_init_data  *ldo2;
0240     struct regulator_init_data  *ldo3;
0241     struct regulator_init_data  *ldo4;
0242     struct regulator_init_data  *ldo5;
0243     struct regulator_init_data  *ldo6;
0244     struct regulator_init_data  *ldo7;
0245     struct regulator_init_data  *ldo8;
0246     struct regulator_init_data  *ldo9;
0247     struct regulator_init_data  *ldo10;
0248     struct regulator_init_data  *ldo11;
0249     struct regulator_init_data  *ldo12;
0250     struct regulator_init_data  *ldo13;
0251     struct regulator_init_data  *ldo14;
0252     struct regulator_init_data  *ldo15;
0253     struct regulator_init_data  *ldo16;
0254     struct regulator_init_data  *ldo17;
0255     struct regulator_init_data  *ldo18;
0256     struct regulator_init_data  *ldo19;
0257     struct regulator_init_data  *ldo20;
0258 
0259     int     irq_base;
0260     int     tsc_irq;
0261 };
0262 
0263 extern int max8925_reg_read(struct i2c_client *, int);
0264 extern int max8925_reg_write(struct i2c_client *, int, unsigned char);
0265 extern int max8925_bulk_read(struct i2c_client *, int, int, unsigned char *);
0266 extern int max8925_bulk_write(struct i2c_client *, int, int, unsigned char *);
0267 extern int max8925_set_bits(struct i2c_client *, int, unsigned char,
0268             unsigned char);
0269 
0270 extern int max8925_device_init(struct max8925_chip *,
0271                 struct max8925_platform_data *);
0272 extern void max8925_device_exit(struct max8925_chip *);
0273 #endif /* __LINUX_MFD_MAX8925_H */
0274