• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define ROHM_DVS_LEVEL_RUN		BIT(0)
24 #define ROHM_DVS_LEVEL_IDLE		BIT(1)
25 #define ROHM_DVS_LEVEL_SUSPEND		BIT(2)
26 #define ROHM_DVS_LEVEL_LPSR		BIT(3)
27 #define ROHM_DVS_LEVEL_VALID_AMOUNT	4
28 #define ROHM_DVS_LEVEL_UNKNOWN		0
29 
30 /**
31  * struct rohm_dvs_config - dynamic voltage scaling register descriptions
32  *
33  * @level_map:		bitmap representing supported run-levels for this
34  *			regulator
35  * @run_reg:		register address for regulator config at 'run' state
36  * @run_mask:		value mask for regulator voltages at 'run' state
37  * @run_on_mask:	enable mask for regulator at 'run' state
38  * @idle_reg:		register address for regulator config at 'idle' state
39  * @idle_mask:		value mask for regulator voltages at 'idle' state
40  * @idle_on_mask:	enable mask for regulator at 'idle' state
41  * @suspend_reg:	register address for regulator config at 'suspend' state
42  * @suspend_mask:	value mask for regulator voltages at 'suspend' state
43  * @suspend_on_mask:	enable mask for regulator at 'suspend' state
44  * @lpsr_reg:		register address for regulator config at 'lpsr' state
45  * @lpsr_mask:		value mask for regulator voltages at 'lpsr' state
46  * @lpsr_on_mask:	enable mask for regulator at 'lpsr' state
47  *
48  * Description of ROHM PMICs voltage configuration registers for different
49  * system states. This is used to correctly configure the PMIC at startup
50  * based on values read from DT.
51  */
52 struct rohm_dvs_config {
53 	uint64_t level_map;
54 	unsigned int run_reg;
55 	unsigned int run_mask;
56 	unsigned int run_on_mask;
57 	unsigned int idle_reg;
58 	unsigned int idle_mask;
59 	unsigned int idle_on_mask;
60 	unsigned int suspend_reg;
61 	unsigned int suspend_mask;
62 	unsigned int suspend_on_mask;
63 	unsigned int lpsr_reg;
64 	unsigned int lpsr_mask;
65 	unsigned int lpsr_on_mask;
66 };
67 
68 #if IS_ENABLED(CONFIG_REGULATOR_ROHM)
69 int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
70 				  struct device_node *np,
71 				  const struct regulator_desc *desc,
72 				  struct regmap *regmap);
73 
74 #else
rohm_regulator_set_dvs_levels(const struct rohm_dvs_config * dvs,struct device_node * np,const struct regulator_desc * desc,struct regmap * regmap)75 static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
76 						struct device_node *np,
77 						const struct regulator_desc *desc,
78 						struct regmap *regmap)
79 {
80 	return 0;
81 }
82 #endif
83 
84 #endif
85