mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-19 16:31:27 +01:00
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. For backward compatibility reasons, if the property is missing we set it to 0b10 (i.e. BIT(7)) like before this commit was merged instead of leaving it untouched like in the kernel driver. Note that this does nothing useful for U-Boot at the moment as the ways to reset the device (e.g. via `reset` command) doesn't interact with the RK8xx PMIC and simply does a CPU reset. Considering the upstream Linux kernel left this register untouched until (assumed) v6.17[1], this is useful for cases in which the U-Boot bootloader has this patch (and running with a DT with rockchip,reset-mode property set) and running an upstream kernel before (assumed) v6.17, or alternatively later without the property in the kernel DT. [1] https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/commit/?id=87b48d86b77686013f5c2a8866ed299312b671db Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
259 lines
4.5 KiB
C
259 lines
4.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Copyright (C) 2015 Google, Inc
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
*/
|
|
|
|
#ifndef _PMIC_RK8XX_H_
|
|
#define _PMIC_RK8XX_H_
|
|
|
|
enum {
|
|
REG_SECONDS = 0x00,
|
|
REG_MINUTES,
|
|
REG_HOURS,
|
|
REG_DAYS,
|
|
REG_MONTHS,
|
|
REG_YEARS,
|
|
REG_WEEKS,
|
|
REG_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VSEL,
|
|
REG_LDO7_ON_VSEL,
|
|
REG_LDO7_SLP_VSEL,
|
|
REG_LDO8_ON_VSEL,
|
|
REG_LDO8_SLP_VSEL,
|
|
REG_DEVCTRL,
|
|
REG_INT_STS1,
|
|
REG_INT_STS_MSK1,
|
|
REG_INT_STS2,
|
|
REG_INT_STS_MSK2,
|
|
REG_IO_POL,
|
|
REG_OTP_VDD_EN,
|
|
REG_H5V_EN,
|
|
REG_SLEEP_SET_OFF,
|
|
REG_BOOST_LDO9_ON_VSEL,
|
|
REG_BOOST_LDO9_SLP_VSEL,
|
|
REG_BOOST_CTRL,
|
|
|
|
/* Not sure what this does */
|
|
REG_DCDC_ILMAX = 0x90,
|
|
REG_CHRG_COMP = 0x9a,
|
|
REG_SUP_STS = 0xa0,
|
|
REG_USB_CTRL,
|
|
REG1_CHRG_CTRL,
|
|
REG2_CHRG_CTRL,
|
|
REG3_CHRG_CTRL,
|
|
REG_BAT_CTRL,
|
|
REG_BAT_HTS_TS1,
|
|
REG_BAT_LTS_TS1,
|
|
REG_BAT_HTS_TS2,
|
|
REG_BAT_LTS_TS2,
|
|
REG_TS_CTRL,
|
|
REG_ADC_CTRL,
|
|
REG_ON_SOURCE,
|
|
REG_OFF_SOURCE,
|
|
REG_GGCON,
|
|
REG_GGSTS,
|
|
REG_FRAME_SMP_INTERV,
|
|
REG_AUTO_SLP_CUR_THR,
|
|
REG3_GASCNT_CAL,
|
|
REG2_GASCNT_CAL,
|
|
REG1_GASCNT_CAL,
|
|
REG0_GASCNT_CAL,
|
|
REG3_GASCNT,
|
|
REG2_GASCNT,
|
|
REG1_GASCNT,
|
|
REG0_GASCNT,
|
|
REGH_BAT_CUR_AVG,
|
|
REGL_BAT_CUR_AVG,
|
|
REGH_TS1_ADC,
|
|
REGL_TS1_ADC,
|
|
REGH_TS2_ADC,
|
|
REGL_TS2_ADC,
|
|
REGH_BAT_OCV,
|
|
REGL_BAT_OCV,
|
|
REGH_BAT_VOL,
|
|
REGL_BAT_VOL,
|
|
REGH_RELAX_ENTRY_THRES,
|
|
REGL_RELAX_ENTRY_THRES,
|
|
REGH_RELAX_EXIT_THRES,
|
|
REGL_RELAX_EXIT_THRES,
|
|
REGH_RELAX_VOL1,
|
|
REGL_RELAX_VOL1,
|
|
REGH_RELAX_VOL2,
|
|
REGL_RELAX_VOL2,
|
|
REGH_BAT_CUR_R_CALC,
|
|
REGL_BAT_CUR_R_CALC,
|
|
REGH_BAT_VOL_R_CALC,
|
|
REGL_BAT_VOL_R_CALC,
|
|
REGH_CAL_OFFSET,
|
|
REGL_CAL_OFFSET,
|
|
REG_NON_ACT_TIMER_CNT,
|
|
REGH_VCALIB0,
|
|
REGL_VCALIB0,
|
|
REGH_VCALIB1,
|
|
REGL_VCALIB1,
|
|
REGH_IOFFSET,
|
|
REGL_IOFFSET,
|
|
REG_SOC,
|
|
REG3_REMAIN_CAP,
|
|
REG2_REMAIN_CAP,
|
|
REG1_REMAIN_CAP,
|
|
REG0_REMAIN_CAP,
|
|
REG_UPDAT_LEVE,
|
|
REG3_NEW_FCC,
|
|
REG2_NEW_FCC,
|
|
REG1_NEW_FCC,
|
|
REG0_NEW_FCC,
|
|
REG_NON_ACT_TIMER_CNT_SAVE,
|
|
REG_OCV_VOL_VALID,
|
|
REG_REBOOT_CNT,
|
|
REG_POFFSET,
|
|
REG_MISC_MARK,
|
|
REG_HALT_CNT,
|
|
REGH_CALC_REST,
|
|
REGL_CALC_REST,
|
|
SAVE_DATA19,
|
|
RK808_NUM_OF_REGS,
|
|
};
|
|
|
|
enum {
|
|
RK817_REG_SYS_CFG3 = 0xf4,
|
|
};
|
|
|
|
enum {
|
|
RK816_REG_DCDC_EN1 = 0x23,
|
|
RK816_REG_DCDC_EN2,
|
|
RK816_REG_DCDC_SLP_EN,
|
|
RK816_REG_LDO_SLP_EN,
|
|
RK816_REG_LDO_EN1 = 0x27,
|
|
RK816_REG_LDO_EN2,
|
|
};
|
|
|
|
enum {
|
|
RK806_POWER_SLP_EN0 = 0x06,
|
|
RK806_POWER_SLP_EN1,
|
|
RK806_POWER_SLP_EN2,
|
|
RK806_REG_SYS_CFG3 = 0x72,
|
|
RK806_WDT_REG,
|
|
RK806_ON_SOURCE,
|
|
RK806_OFF_SOURCE
|
|
};
|
|
|
|
enum {
|
|
RK805_ID = 0x8050,
|
|
RK806_ID = 0x8060,
|
|
RK808_ID = 0x0000,
|
|
RK809_ID = 0x8090,
|
|
RK816_ID = 0x8160,
|
|
RK817_ID = 0x8170,
|
|
RK818_ID = 0x8180,
|
|
};
|
|
|
|
enum {
|
|
RK817_POWER_EN0 = 0xb1,
|
|
RK817_POWER_EN1,
|
|
RK817_POWER_EN2,
|
|
RK817_POWER_EN3,
|
|
};
|
|
|
|
#define RK817_POWER_EN_SAVE0 0x99
|
|
#define RK817_POWER_EN_SAVE1 0xa4
|
|
|
|
#define RK806_RST_FUN_MSK GENMASK(7, 6)
|
|
|
|
#define RK806_POWER_EN(x) (0x00 + (x))
|
|
/* POWER_ENx register lower 4 bits are write-protected unless the associated top bit is set */
|
|
#define RK806_POWER_EN_CLRSETBITS(bit, val) (((val) << (bit)) | (1 << ((bit) + 4)))
|
|
|
|
#define RK806_POWER_SLP_EN(x) (0x06 + (x))
|
|
|
|
#define RK806_ID_MSB 0x5a
|
|
#define RK806_ID_LSB 0x5b
|
|
#define RK817_ID_MSB 0xed
|
|
#define RK817_ID_LSB 0xee
|
|
#define RK8XX_ID_MSK 0xfff0
|
|
|
|
#define RK817_PMIC_SYS_CFG3 0xf4
|
|
#define RK817_GPIO_INT_CFG 0xfe
|
|
|
|
#define RK8XX_ON_SOURCE 0xae
|
|
#define RK8XX_OFF_SOURCE 0xaf
|
|
#define RK817_BUCK4_CMIN 0xc6
|
|
#define RK817_ON_SOURCE 0xf5
|
|
#define RK817_OFF_SOURCE 0xf6
|
|
|
|
#define RK8XX_ON_PWRON BIT(7)
|
|
#define RK8XX_ON_PLUG_IN BIT(6)
|
|
|
|
struct reg_data {
|
|
u8 reg;
|
|
u8 val;
|
|
u8 mask;
|
|
};
|
|
struct rk8xx_reg_table {
|
|
char *name;
|
|
u8 reg_ctl;
|
|
u8 reg_vol;
|
|
};
|
|
|
|
struct rk8xx_priv {
|
|
int variant;
|
|
};
|
|
|
|
int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
|
|
|
|
#endif
|