sysreset: qcom-pshold: configure PON reset-type for reset via PS_HOLD
v2 cover sysreset: qcom-pshold: configure PON reset-type for reset via PS_HOLD
This is v2 of the PS_HOLD reset-type series, addressing review of v1 [1][2][3].
This series depends on the Snagboot support series for Lemans-EVK [4] (qcom-snagboot.config, qcom_lemans_snagboot_defconfig, CONFIG_QCOM_SNAGBOOT_MODE), since patch 2/2 modifies configs/qcom-snagboot.config.
Background
----------
In Snagboot mode, qcom_lemans_snagboot_defconfig disables CONFIG_PSCI_RESET (PSCI services are unavailable in this mode), so sysreset_walk() falls through to the qcom-pshold driver as the reset path.
On PMICs where the PS_HOLD reset sequence is implemented in the PON PBS (Programmable Boot Sequencer) block rather than directly dropping PS_HOLD a reset type needs to be configured. Otherwise, the board hangs on performing reset such as hard reset.
Reset types defines the behavior of the PMIC during a reset or shutdown event (e.g., warm reset or hard reset event). The type of reset event is determined by configuration register PON_PBS_PS_HOLD_SW_CTL in the PON module. Another register, PON_PBS_PS_HOLD_RESET_CTL2 contains the field S2_RESET_EN that enables reset. To configure PON_PBS_PS_HOLD_SW_CTL, the register PON_PBS_PS_HOLD_RESET_CTL2.S2_RESET_EN needs to be disabled before re-enabling it again.
Per the PMIC specification, a warm reset sequence additionally requires further software configuration and if that configuration is not performed, the PMIC's default behaviour for a warm reset request is to shut down instead. This series does not implement that configuration, so warm reset (SYSRESET_WARM) is not supported here.
Changes since v1
-----------------
- Patch 1: dropped the "qcom,pon", "qcom,pbs-pshold-sw-ctl" and "qcom,pbs-pshold-reset-ctl2" DT properties entirely. The PMIC PON node is now located via its "compatible" property, and an in-driver table maps that compatible node to the PON_PBS base and register offsets. No new DT properties or bindings are introduced. Warm reset support was dropped: per the PMIC specification an unconfigured warm reset defaults to a shutdown, which this driver does not want to trigger unexpectedly. Only hard reset and power-off are implemented. Reverted the unrelated U_BOOT_DRIVER() whitespace reformatting flagged in review.
- Patch 2 (was 3/3 in v1): implement SYSRESET_POWER_OFF (RESET_TYPE=SHUTDOWN) in the driver, and enable CONFIG_SYSRESET_CMD_POWEROFF in qcom-snagboot.config (rather than disabling CONFIG_CMD_POWEROFF as in v1), so "poweroff" works in Snagboot recovery mode where PSCI is unavailable.
- The v1 DT patch (2/3, "arm: dts: qcom: Configure Lemans PS_HOLD reset") is dropped from this series. Adding a qcom,pshold node requires it to also be added to the corresponding Linux devicetree. That patch is being prepared and will be posted separately for Linux DT review. Once accepted,the U-Boot DT enablement patch for Lemans IQ9075 will follow as v3 of this series (or a follow-up), referencing the accepted Linux patch.
[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/[email protected]/
[4] https://lore.kernel.org/u-boot/[email protected]/
Sumit Singh Dhami (2):
sysreset: qcom-pshold: configure PON reset type before deasserting
PS_HOLD
configs: qcom-snagboot: enable poweroff via sysreset uclass
configs/qcom-snagboot.config | 3 + drivers/sysreset/sysreset_qcom-pshold.c | 122 +++++++++++++++++++++++- 2 files changed, 124 insertions(+), 1 deletion(-)
Signature · 2 lines
Best regards, Sumit Singh Dhami
PATCH v2 1/2 sysreset: qcom-pshold: configure PON reset type before deasserting PS_HOLD
Reset types defines behavior of the PMIC during a reset or shutdown event (e.g. hard reset event). The type of reset event is determined by configuration register PON_PBS_PS_HOLD_SW_CTL in the PON module. PON_PBS_PS_HOLD_RESET_CTL2 register contains the field S2_RESET_EN that enables reset. To configure PON_PBS_PS_HOLD_SW_CTL, the register PON_PBS_PS_HOLD_RESET_CTL2.S2_RESET_EN needs to be disabled before re-enabling it again.
Configure PON_PBS_PS_HOLD_SW_CTL and PON_PBS_PS_HOLD_RESET_CTL2 registers before dropping PS_HOLD.
--- drivers/sysreset/sysreset_qcom-pshold.c | 122 +++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-)
drivers/sysreset/sysreset_qcom-pshold.c +121 -1
@@ -13,15 +13,92 @@#include <sysreset.h> #include <asm/io.h> #include <linux/delay.h> +#include <linux/errno.h> +#include <power/pmic.h> + +#define PON_PBS_RESET_TYPE_SHUTDOWN 0x04 +#define PON_PBS_RESET_TYPE_HARD 0x07 + +#define PON_PBS_RESET_CTL2_S2_RESET_EN_BMSK 0x80 + +struct qcom_pshold_pon_data { +const char *pon_compatible; +u32 pbs_base; +u8 sw_ctl_offset; +u8 reset_ctl2_offset; +}; + +static const struct qcom_pshold_pon_data qcom_pshold_pon_data_table[] = { + { + .pon_compatible ="qcom,pmk8350-pon" , + .pbs_base =0x800 , + .sw_ctl_offset =0x52 , + .reset_ctl2_offset =0x53 , + }, +};struct qcom_pshold_priv {phys_addr_t base; +bool have_pon; +struct udevice *pmic; +const struct qcom_pshold_pon_data *pon_data; }; +static int qcom_pshold_pon_cfg (struct qcom_pshold_priv *priv,u8 reset_type) +{ +u32 sw_ctl = priv->pon_data->pbs_base + priv->pon_data->sw_ctl_offset; +u32 reset_ctl2 = priv->pon_data->pbs_base + + priv->pon_data->reset_ctl2_offset; +int ret; + + ret =pmic_reg_write (priv->pmic, reset_ctl2,0x0 ); +if (ret) +return ret; + +udelay (100 ); + + ret =pmic_reg_write (priv->pmic, sw_ctl, reset_type); +if (ret) +return ret; + +udelay (300 ); + + ret =pmic_reg_write (priv->pmic, reset_ctl2, +PON_PBS_RESET_CTL2_S2_RESET_EN_BMSK ); +if (ret) +return ret; + +udelay (100 ); + +return 0 ; +} +static int qcom_pshold_request (struct udevice *dev,enum sysreset_t type) {struct qcom_pshold_priv *priv =dev_get_priv (dev); +if (priv->have_pon) { +u8 reset_type; +int ret; + +switch (type) { +case SYSRESET_COLD : +case SYSRESET_POWER : + reset_type =PON_PBS_RESET_TYPE_HARD ; +break ; +case SYSRESET_POWER_OFF : + reset_type =PON_PBS_RESET_TYPE_SHUTDOWN ; +break ; +default : +return -EPROTONOSUPPORT ; + } + + ret =qcom_pshold_pon_cfg (priv, reset_type); +if (ret) +debug ("%s: failed to configure PON reset type: %d\n" , + dev->name, ret); + } +writel (0 , priv->base);mdelay (10000 );
@@ -32,12 +109,55 @@ static struct sysreset_ops qcom_pshold_ops = { .request = qcom_pshold_request, }; +static ofnode qcom_pshold_find_pon (struct qcom_pshold_priv *priv) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (qcom_pshold_pon_data_table); i++) { +ofnode node; + + node =ofnode_by_compatible (ofnode_null (), + qcom_pshold_pon_data_table[i].pon_compatible); +if (ofnode_valid (node)) { + priv->pon_data = &qcom_pshold_pon_data_table[i]; +return node; + } + } + +return ofnode_null (); +} +static int qcom_pshold_probe (struct udevice *dev) {struct qcom_pshold_priv *priv =dev_get_priv (dev); +ofnode pon_node, pmic_node; +int ret; + + priv->have_pon = false; priv->base =dev_read_addr (dev); -return priv->base ==FDT_ADDR_T_NONE ? -EINVAL :0 ; +if (priv->base ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + pon_node =qcom_pshold_find_pon (priv); +if (!ofnode_valid (pon_node)) +return 0 ; + + pmic_node =ofnode_get_parent (pon_node); +if (!ofnode_valid (pmic_node)) { +debug ("%s: failed to get PON's parent PMIC node\n" , dev->name); +return 0 ; + } + + ret =uclass_get_device_by_ofnode (UCLASS_PMIC , pmic_node, &priv->pmic); +if (ret) { +debug ("%s: failed to get PMIC device: %d\n" , dev->name, ret); +return 0 ; + } + + priv->have_pon = true; + +return 0 ; }static const struct udevice_id qcom_pshold_ids[] = {
Signature · 1 line
2.55.0
PATCH v2 2/2 configs: qcom-snagboot: enable poweroff via sysreset uclass
In reply to Sumit Singh DhamiCONFIG_CMD_POWEROFF's do_poweroff() is normally provided by drivers/firmware/psci.c, which is unavailable in Snagboot mode since CONFIG_PSCI_RESET is disabled.
Enable CONFIG_SYSRESET_CMD_POWEROFF so that sysreset-uclass.c's do_poweroff() is used instead, routing through the qcom-pshold driver configuring the reset type to SHUTDOWN in PON_PBS_PS_HOLD_SW_CTL register.
--- configs/qcom-snagboot.config | 3 +++ 1 file changed, 3 insertions(+)
configs/qcom-snagboot.config +3 -0
@@ -31,3 +31,6 @@ CONFIG_FASTBOOT_FLASH_BLOCK_INTERFACE_NAME="scsi" CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID=4 CONFIG_FASTBOOT_GPT_NAME="gpt" CONFIG_FASTBOOT_MBR_NAME="mbr" + +# Enable Poweroff via Sysreset uclass +CONFIG_SYSRESET_CMD_POWEROFF=y
Signature · 1 line
2.55.0