Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 2 | |
| 3 | #ifndef __MAX77686_H_ |
| 4 | #define __MAX77686_H_ |
| 5 | |
| 6 | enum max77686_regnum { |
| 7 | PMIC_BUCK1 = 0, |
| 8 | PMIC_BUCK2, |
| 9 | PMIC_BUCK3, |
| 10 | PMIC_BUCK4, |
| 11 | PMIC_BUCK5, |
| 12 | PMIC_BUCK6, |
| 13 | PMIC_BUCK7, |
| 14 | PMIC_BUCK8, |
| 15 | PMIC_BUCK9, |
| 16 | PMIC_LDO1, |
| 17 | PMIC_LDO2, |
| 18 | PMIC_LDO3, |
| 19 | PMIC_LDO4, |
| 20 | PMIC_LDO5, |
| 21 | PMIC_LDO6, |
| 22 | PMIC_LDO7, |
| 23 | PMIC_LDO8, |
| 24 | PMIC_LDO9, |
| 25 | PMIC_LDO10, |
| 26 | PMIC_LDO11, |
| 27 | PMIC_LDO12, |
| 28 | PMIC_LDO13, |
| 29 | PMIC_LDO14, |
| 30 | PMIC_LDO15, |
| 31 | PMIC_LDO16, |
| 32 | PMIC_LDO17, |
| 33 | PMIC_LDO18, |
| 34 | PMIC_LDO19, |
| 35 | PMIC_LDO20, |
| 36 | PMIC_LDO21, |
| 37 | PMIC_LDO22, |
| 38 | PMIC_LDO23, |
| 39 | PMIC_LDO24, |
| 40 | PMIC_LDO25, |
| 41 | PMIC_LDO26, |
| 42 | PMIC_EN32KHZ_CP, |
| 43 | }; |
| 44 | |
| 45 | /** |
| 46 | * struct max77686_para - max77686 register parameters |
| 47 | * @param vol_addr i2c address of the given buck/ldo register |
| 48 | * @param vol_bitpos bit position to be set or clear within register |
| 49 | * @param vol_bitmask bit mask value |
| 50 | * @param reg_enaddr control register address, which enable the given |
Elyes HAOUAS | c366501 | 2021-01-16 14:59:52 +0100 | [diff] [blame] | 51 | * buck/ldo. |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 52 | * @param reg_enbitpos bit position to be enabled |
| 53 | * @param reg_enbiton value to be written to buck/ldo to make it ON |
| 54 | * @param reg_enbitoff value to be written to buck/ldo to make it OFF |
| 55 | * @param vol_min minimum voltage level supported by given buck/ldo |
| 56 | * @param vol_div voltage division value of given buck/ldo |
| 57 | */ |
| 58 | struct max77686_para { |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 59 | u8 vol_addr; |
| 60 | u8 vol_bitpos; |
| 61 | u8 vol_bitmask; |
| 62 | u8 reg_enaddr; |
| 63 | u8 reg_enbitpos; |
| 64 | u8 reg_enbitmask; |
| 65 | u8 reg_enbiton; |
| 66 | u8 reg_enbitoff; |
David Hendricks | 1d5390e | 2013-01-09 16:26:26 -0800 | [diff] [blame] | 67 | u16 vol_min; |
| 68 | u16 vol_div; |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | /* I2C device address for pmic max77686 */ |
| 72 | #define MAX77686_I2C_ADDR (0x12 >> 1) |
| 73 | |
| 74 | enum { |
| 75 | REG_DISABLE = 0, |
| 76 | REG_ENABLE |
| 77 | }; |
| 78 | |
| 79 | enum { |
Martin Roth | 3e25f85 | 2023-09-04 15:37:07 -0600 | [diff] [blame^] | 80 | MAX77686_MV = 0, /* millivolt */ |
| 81 | MAX77686_UV /* microvolt */ |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /** |
| 85 | * This function enables the 32KHz coprocessor clock. |
| 86 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 87 | * @param bus i2c bus |
| 88 | * |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 89 | * Return 0 if ok, else -1 |
| 90 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 91 | int max77686_enable_32khz_cp(unsigned int bus); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Set the required voltage level of pmic |
| 95 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 96 | * @param bus i2c bus |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 97 | * @param reg register number of buck/ldo to be set |
| 98 | * @param volt voltage level to be set |
| 99 | * @param enable enable or disable bit |
| 100 | * @param volt_units MAX77686_MV or MAX77686_UV, unit of the |
| 101 | * voltage parameters |
| 102 | * |
| 103 | * @return Return 0 if ok, else -1 |
| 104 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 105 | int max77686_volsetting(unsigned int bus, enum max77686_regnum reg, |
| 106 | unsigned int volt, int enable, int volt_units); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Disable charging of the RTC backup battery |
| 110 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 111 | * @param bus i2c bus |
| 112 | * |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 113 | * @return Return 0 if ok, else -1 |
| 114 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 115 | int max77686_disable_backup_batt(unsigned int bus); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 116 | |
Martin Roth | fd277d8 | 2016-01-11 12:47:30 -0700 | [diff] [blame] | 117 | #endif /* __MAX77686_H_ */ |