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