Skip to content

Commit db8db85

Browse files
QSchulzlag-linaro
authored andcommitted
mfd: rk8xx-core: Allow to customize RK806 reset mode
The RK806 PMIC has a bitfield for configuring the restart/reset behavior (which I assume Rockchip calls "function") whenever the PMIC is reset either programmatically (c.f. DEV_RST in the datasheet) or via PWRCTRL or RESETB pins. For RK806, the following values are possible for RST_FUN: 0b00 means "Restart PMU" 0b01 means "Reset all the power off reset registers, forcing the state to switch to ACTIVE mode" 0b10 means "Reset all the power off reset registers, forcing the state to switch to ACTIVE mode, and simultaneously pull down the RESETB PIN for 5mS before releasing" 0b11 means the same as for 0b10 just above. This adds the appropriate logic in the driver to parse the new rockchip,reset-mode DT property to pass this information. It just happens that the values in the binding match the values to write in the bitfield so no mapping is necessary. If it is missing, the register is left untouched and relies either on the silicon default or on whatever was set earlier in the boot stages (e.g. the bootloader). Signed-off-by: Quentin Schulz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 404005d commit db8db85

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

drivers/mfd/rk8xx-core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Author: Wadim Egorov <[email protected]>
1111
*/
1212

13+
#include <linux/bitfield.h>
1314
#include <linux/interrupt.h>
1415
#include <linux/mfd/rk808.h>
1516
#include <linux/mfd/core.h>
@@ -699,6 +700,7 @@ int rk8xx_probe(struct device *dev, int variant, unsigned int irq, struct regmap
699700
const struct mfd_cell *cells;
700701
int dual_support = 0;
701702
int nr_pre_init_regs;
703+
u32 rst_fun = 0;
702704
int nr_cells;
703705
int ret;
704706
int i;
@@ -726,6 +728,16 @@ int rk8xx_probe(struct device *dev, int variant, unsigned int irq, struct regmap
726728
cells = rk806s;
727729
nr_cells = ARRAY_SIZE(rk806s);
728730
dual_support = IRQF_SHARED;
731+
732+
ret = device_property_read_u32(dev, "rockchip,reset-mode", &rst_fun);
733+
if (ret)
734+
break;
735+
736+
ret = regmap_update_bits(rk808->regmap, RK806_SYS_CFG3, RK806_RST_FUN_MSK,
737+
FIELD_PREP(RK806_RST_FUN_MSK, rst_fun));
738+
if (ret)
739+
return dev_err_probe(dev, ret,
740+
"Failed to configure requested restart/reset behavior\n");
729741
break;
730742
case RK808_ID:
731743
rk808->regmap_irq_chip = &rk808_irq_chip;

include/linux/mfd/rk808.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,8 @@ enum rk806_pin_dr_sel {
812812
#define RK806_INT_POL_H BIT(1)
813813
#define RK806_INT_POL_L 0
814814

815+
/* SYS_CFG3 */
816+
#define RK806_RST_FUN_MSK GENMASK(7, 6)
815817
#define RK806_SLAVE_RESTART_FUN_MSK BIT(1)
816818
#define RK806_SLAVE_RESTART_FUN_EN BIT(1)
817819
#define RK806_SLAVE_RESTART_FUN_OFF 0

0 commit comments

Comments
 (0)