mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
![Matti Vaittinen](/assets/img/avatar_default.png)
[ Upstream commitc294554111
] The ROHM BD718x7 and BD71828 drivers support setting HW state specific voltages from device-tree. This is used also by various in-tree DTS files. These drivers do incorrectly try to compose bit-map using enum values. By a chance this works for first two valid levels having values 1 and 2 - but setting values for the rest of the levels do indicate capability of setting values for first levels as well. Luckily the regulators which support setting values for SUSPEND/LPSR do usually also support setting values for RUN and IDLE too - thus this has not been such a fatal issue. Fix this by defining the old enum values as bits and fixing the parsing code. This allows keeping existing IC specific drivers intact and only slightly changing the rohm-regulator.c Fixes:21b72156ed
("regulator: bd718x7: Split driver to common and bd718x7 specific parts") Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Acked-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20210212080023.GA880728@localhost.localdomain Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
84 lines
2.5 KiB
C
84 lines
2.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/* Copyright (C) 2018 ROHM Semiconductors */
|
|
|
|
#ifndef __LINUX_MFD_ROHM_H__
|
|
#define __LINUX_MFD_ROHM_H__
|
|
|
|
#include <linux/regmap.h>
|
|
#include <linux/regulator/driver.h>
|
|
|
|
enum rohm_chip_type {
|
|
ROHM_CHIP_TYPE_BD71837 = 0,
|
|
ROHM_CHIP_TYPE_BD71847,
|
|
ROHM_CHIP_TYPE_BD70528,
|
|
ROHM_CHIP_TYPE_BD71828,
|
|
ROHM_CHIP_TYPE_AMOUNT
|
|
};
|
|
|
|
struct rohm_regmap_dev {
|
|
struct device *dev;
|
|
struct regmap *regmap;
|
|
};
|
|
|
|
#define ROHM_DVS_LEVEL_RUN BIT(0)
|
|
#define ROHM_DVS_LEVEL_IDLE BIT(1)
|
|
#define ROHM_DVS_LEVEL_SUSPEND BIT(2)
|
|
#define ROHM_DVS_LEVEL_LPSR BIT(3)
|
|
#define ROHM_DVS_LEVEL_VALID_AMOUNT 4
|
|
#define ROHM_DVS_LEVEL_UNKNOWN 0
|
|
|
|
/**
|
|
* struct rohm_dvs_config - dynamic voltage scaling register descriptions
|
|
*
|
|
* @level_map: bitmap representing supported run-levels for this
|
|
* regulator
|
|
* @run_reg: register address for regulator config at 'run' state
|
|
* @run_mask: value mask for regulator voltages at 'run' state
|
|
* @run_on_mask: enable mask for regulator at 'run' state
|
|
* @idle_reg: register address for regulator config at 'idle' state
|
|
* @idle_mask: value mask for regulator voltages at 'idle' state
|
|
* @idle_on_mask: enable mask for regulator at 'idle' state
|
|
* @suspend_reg: register address for regulator config at 'suspend' state
|
|
* @suspend_mask: value mask for regulator voltages at 'suspend' state
|
|
* @suspend_on_mask: enable mask for regulator at 'suspend' state
|
|
* @lpsr_reg: register address for regulator config at 'lpsr' state
|
|
* @lpsr_mask: value mask for regulator voltages at 'lpsr' state
|
|
* @lpsr_on_mask: enable mask for regulator at 'lpsr' state
|
|
*
|
|
* Description of ROHM PMICs voltage configuration registers for different
|
|
* system states. This is used to correctly configure the PMIC at startup
|
|
* based on values read from DT.
|
|
*/
|
|
struct rohm_dvs_config {
|
|
uint64_t level_map;
|
|
unsigned int run_reg;
|
|
unsigned int run_mask;
|
|
unsigned int run_on_mask;
|
|
unsigned int idle_reg;
|
|
unsigned int idle_mask;
|
|
unsigned int idle_on_mask;
|
|
unsigned int suspend_reg;
|
|
unsigned int suspend_mask;
|
|
unsigned int suspend_on_mask;
|
|
unsigned int lpsr_reg;
|
|
unsigned int lpsr_mask;
|
|
unsigned int lpsr_on_mask;
|
|
};
|
|
|
|
#if IS_ENABLED(CONFIG_REGULATOR_ROHM)
|
|
int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
|
|
struct device_node *np,
|
|
const struct regulator_desc *desc,
|
|
struct regmap *regmap);
|
|
|
|
#else
|
|
static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs,
|
|
struct device_node *np,
|
|
const struct regulator_desc *desc,
|
|
struct regmap *regmap)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif
|