1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* Copyright (C) 2018 ROHM Semiconductors */
3
4 #ifndef __LINUX_MFD_ROHM_H__
5 #define __LINUX_MFD_ROHM_H__
6
7 #include <linux/regmap.h>
8 #include <linux/regulator/driver.h>
9
10 enum rohm_chip_type {
11 ROHM_CHIP_TYPE_BD71837 = 0,
12 ROHM_CHIP_TYPE_BD71847,
13 ROHM_CHIP_TYPE_BD70528,
14 ROHM_CHIP_TYPE_BD71828,
15 ROHM_CHIP_TYPE_AMOUNT
16 };
17
18 struct rohm_regmap_dev {
19 struct device *dev;
20 struct regmap *regmap;
21 };
22
23 enum {
24 ROHM_DVS_LEVEL_UNKNOWN,
25 ROHM_DVS_LEVEL_RUN,
26 ROHM_DVS_LEVEL_IDLE,
27 ROHM_DVS_LEVEL_SUSPEND,
28 ROHM_DVS_LEVEL_LPSR,
29 ROHM_DVS_LEVEL_MAX = ROHM_DVS_LEVEL_LPSR,
30 };
31
32 /**
33 * struct rohm_dvs_config - dynamic voltage scaling register descriptions
34 *
35 * @level_map: bitmap representing supported run-levels for this
36 * regulator
37 * @run_reg: register address for regulator config at 'run' state
38 * @run_mask: value mask for regulator voltages at 'run' state
39 * @run_on_mask: enable mask for regulator at 'run' state
40 * @idle_reg: register address for regulator config at 'idle' state
41 * @idle_mask: value mask for regulator voltages at 'idle' state
42 * @idle_on_mask: enable mask for regulator at 'idle' state
43 * @suspend_reg: register address for regulator config at 'suspend' state
44 * @suspend_mask: value mask for regulator voltages at 'suspend' state
45 * @suspend_on_mask: enable mask for regulator at 'suspend' state
46 * @lpsr_reg: register address for regulator config at 'lpsr' state
47 * @lpsr_mask: value mask for regulator voltages at 'lpsr' state
48 * @lpsr_on_mask: enable mask for regulator at 'lpsr' state
49 *
50 * Description of ROHM PMICs voltage configuration registers for different
51 * system states. This is used to correctly configure the PMIC at startup
52 * based on values read from DT.
53 */
54 struct rohm_dvs_config {
55 uint64_t level_map;
56 unsigned int run_reg;
57 unsigned int run_mask;
58 unsigned int run_on_mask;
59 unsigned int idle_reg;
60 unsigned int idle_mask;
61 unsigned int idle_on_mask;
62 unsigned int suspend_reg;
63 unsigned int suspend_mask;
64 unsigned int suspend_on_mask;
65 unsigned int lpsr_reg;
66 unsigned int lpsr_mask;
67 unsigned int lpsr_on_mask;
68 };
69
70 #if IS_ENABLED(CONFIG_REGULATOR_ROHM)
71 int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
72 struct device_node *np,
73 const struct regulator_desc *desc,
74 struct regmap *regmap);
75
76 #else
rohm_regulator_set_dvs_levels(const struct rohm_dvs_config * dvs,struct device_node * np,const struct regulator_desc * desc,struct regmap * regmap)77 static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
78 struct device_node *np,
79 const struct regulator_desc *desc,
80 struct regmap *regmap)
81 {
82 return 0;
83 }
84 #endif
85
86 #endif
87