Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Samsung Electronics |
| 3 | * Alim Akhtar <alim.akhtar@samsung.com> |
| 4 | * |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef __MAX77686_H_ |
| 17 | #define __MAX77686_H_ |
| 18 | |
| 19 | enum max77686_regnum { |
| 20 | PMIC_BUCK1 = 0, |
| 21 | PMIC_BUCK2, |
| 22 | PMIC_BUCK3, |
| 23 | PMIC_BUCK4, |
| 24 | PMIC_BUCK5, |
| 25 | PMIC_BUCK6, |
| 26 | PMIC_BUCK7, |
| 27 | PMIC_BUCK8, |
| 28 | PMIC_BUCK9, |
| 29 | PMIC_LDO1, |
| 30 | PMIC_LDO2, |
| 31 | PMIC_LDO3, |
| 32 | PMIC_LDO4, |
| 33 | PMIC_LDO5, |
| 34 | PMIC_LDO6, |
| 35 | PMIC_LDO7, |
| 36 | PMIC_LDO8, |
| 37 | PMIC_LDO9, |
| 38 | PMIC_LDO10, |
| 39 | PMIC_LDO11, |
| 40 | PMIC_LDO12, |
| 41 | PMIC_LDO13, |
| 42 | PMIC_LDO14, |
| 43 | PMIC_LDO15, |
| 44 | PMIC_LDO16, |
| 45 | PMIC_LDO17, |
| 46 | PMIC_LDO18, |
| 47 | PMIC_LDO19, |
| 48 | PMIC_LDO20, |
| 49 | PMIC_LDO21, |
| 50 | PMIC_LDO22, |
| 51 | PMIC_LDO23, |
| 52 | PMIC_LDO24, |
| 53 | PMIC_LDO25, |
| 54 | PMIC_LDO26, |
| 55 | PMIC_EN32KHZ_CP, |
| 56 | }; |
| 57 | |
| 58 | /** |
| 59 | * struct max77686_para - max77686 register parameters |
| 60 | * @param vol_addr i2c address of the given buck/ldo register |
| 61 | * @param vol_bitpos bit position to be set or clear within register |
| 62 | * @param vol_bitmask bit mask value |
| 63 | * @param reg_enaddr control register address, which enable the given |
| 64 | * given buck/ldo. |
| 65 | * @param reg_enbitpos bit position to be enabled |
| 66 | * @param reg_enbiton value to be written to buck/ldo to make it ON |
| 67 | * @param reg_enbitoff value to be written to buck/ldo to make it OFF |
| 68 | * @param vol_min minimum voltage level supported by given buck/ldo |
| 69 | * @param vol_div voltage division value of given buck/ldo |
| 70 | */ |
| 71 | struct max77686_para { |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 72 | u8 vol_addr; |
| 73 | u8 vol_bitpos; |
| 74 | u8 vol_bitmask; |
| 75 | u8 reg_enaddr; |
| 76 | u8 reg_enbitpos; |
| 77 | u8 reg_enbitmask; |
| 78 | u8 reg_enbiton; |
| 79 | u8 reg_enbitoff; |
David Hendricks | 1d5390e | 2013-01-09 16:26:26 -0800 | [diff] [blame] | 80 | u16 vol_min; |
| 81 | u16 vol_div; |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | /* I2C device address for pmic max77686 */ |
| 85 | #define MAX77686_I2C_ADDR (0x12 >> 1) |
| 86 | |
| 87 | enum { |
| 88 | REG_DISABLE = 0, |
| 89 | REG_ENABLE |
| 90 | }; |
| 91 | |
| 92 | enum { |
| 93 | MAX77686_MV = 0, /* mili volt */ |
| 94 | MAX77686_UV /* micro volt */ |
| 95 | }; |
| 96 | |
| 97 | /** |
| 98 | * This function enables the 32KHz coprocessor clock. |
| 99 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 100 | * @param bus i2c bus |
| 101 | * |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 102 | * Return 0 if ok, else -1 |
| 103 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 104 | int max77686_enable_32khz_cp(unsigned int bus); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Set the required voltage level of pmic |
| 108 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 109 | * @param bus i2c bus |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 110 | * @param reg register number of buck/ldo to be set |
| 111 | * @param volt voltage level to be set |
| 112 | * @param enable enable or disable bit |
| 113 | * @param volt_units MAX77686_MV or MAX77686_UV, unit of the |
| 114 | * voltage parameters |
| 115 | * |
| 116 | * @return Return 0 if ok, else -1 |
| 117 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 118 | int max77686_volsetting(unsigned int bus, enum max77686_regnum reg, |
| 119 | unsigned int volt, int enable, int volt_units); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Disable charging of the RTC backup battery |
| 123 | * |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 124 | * @param bus i2c bus |
| 125 | * |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 126 | * @return Return 0 if ok, else -1 |
| 127 | */ |
David Hendricks | b959fbb | 2013-04-05 16:11:12 -0700 | [diff] [blame] | 128 | int max77686_disable_backup_batt(unsigned int bus); |
Ronald G. Minnich | f2e13b0 | 2012-11-28 10:44:12 -0800 | [diff] [blame] | 129 | |
| 130 | #endif /* __MAX77686_PMIC_H_ */ |