From nobody Wed Oct 8 15:13:06 2025 Received: from smtp-8fa9.mail.infomaniak.ch (smtp-8fa9.mail.infomaniak.ch [83.166.143.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEE8B1917FB for ; Fri, 27 Jun 2025 11:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751022034; cv=none; b=P/f32azkM2Zy/K0qF5maiCbxuelSIEzw2kdZWCdwugG69tJDg9HmNvlYAaP8r6f9XBotWNbRE1dYu9s5H1bm/dkiXELaCnO+bXmx762gJS803i54R9CvY+JsDvI3BN6x3Wpug3C6CUYXnqLSCQLvscFKJeCF3AbSgqQnOC4B5NU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751022034; c=relaxed/simple; bh=6IQyvKuNPWfXTg0M6rLgs9YlTBI3PR96YEbujeEt3os=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eSMEo3TqMPjampu849P7ekVJgPPkfJlNUAV9DGwjG7StTMZmef8j12C+hxSEEOrHMxP0NgurZWVx2y3+1aYpL8RXRyhP6cs8AOGmbgujiJeT2fWOl732nirZoaRBdWgzN0XC85TFe7Kv81gTrwFmCP2lB356JnSgQxLtxsAaWKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net; spf=pass smtp.mailfrom=0leil.net; arc=none smtp.client-ip=83.166.143.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=0leil.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=0leil.net Received: from smtp-4-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10::a6c]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4bTC9L4pN1zW0Y; Fri, 27 Jun 2025 12:54:14 +0200 (CEST) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4bTC9K3SKyzx9C; Fri, 27 Jun 2025 12:54:13 +0200 (CEST) From: Quentin Schulz Date: Fri, 27 Jun 2025 12:53:54 +0200 Subject: [PATCH v4 2/5] mfd: rk8xx-core: allow to customize RK806 reset mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250627-rk8xx-rst-fun-v4-2-ce05d041b45f@cherry.de> References: <20250627-rk8xx-rst-fun-v4-0-ce05d041b45f@cherry.de> In-Reply-To: <20250627-rk8xx-rst-fun-v4-0-ce05d041b45f@cherry.de> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Sebastian Reichel Cc: Lukasz Czechowski , Daniel Semkowicz , Nicolas Frattaroli , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Quentin Schulz X-Mailer: b4 0.14.2 X-Infomaniak-Routing: alpha From: Quentin Schulz 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 --- drivers/mfd/rk8xx-core.c | 12 ++++++++++++ include/linux/mfd/rk808.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c index 71c2b80a4678d627e86cfbec8135f08e262559d3..def4587fdfb8b82e5548e70310d= 3e16e6d07d7af 100644 --- a/drivers/mfd/rk8xx-core.c +++ b/drivers/mfd/rk8xx-core.c @@ -10,6 +10,7 @@ * Author: Wadim Egorov */ =20 +#include #include #include #include @@ -699,6 +700,7 @@ int rk8xx_probe(struct device *dev, int variant, unsign= ed int irq, struct regmap const struct mfd_cell *cells; int dual_support =3D 0; int nr_pre_init_regs; + u32 rst_fun =3D 0; int nr_cells; int ret; int i; @@ -726,6 +728,16 @@ int rk8xx_probe(struct device *dev, int variant, unsig= ned int irq, struct regmap cells =3D rk806s; nr_cells =3D ARRAY_SIZE(rk806s); dual_support =3D IRQF_SHARED; + + ret =3D device_property_read_u32(dev, "rockchip,reset-mode", &rst_fun); + if (ret) + break; + + ret =3D regmap_update_bits(rk808->regmap, RK806_SYS_CFG3, RK806_RST_FUN_= MSK, + FIELD_PREP(RK806_RST_FUN_MSK, rst_fun)); + if (ret) + return dev_err_probe(dev, ret, + "Failed to configure requested restart/reset behavior\n"); break; case RK808_ID: rk808->regmap_irq_chip =3D &rk808_irq_chip; diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h index 69cbea78b430b562a23d995263369d475daa6287..28170ee08898ca59c76a741a1d4= 2763a42b72380 100644 --- a/include/linux/mfd/rk808.h +++ b/include/linux/mfd/rk808.h @@ -812,6 +812,8 @@ enum rk806_pin_dr_sel { #define RK806_INT_POL_H BIT(1) #define RK806_INT_POL_L 0 =20 +/* SYS_CFG3 */ +#define RK806_RST_FUN_MSK GENMASK(7, 6) #define RK806_SLAVE_RESTART_FUN_MSK BIT(1) #define RK806_SLAVE_RESTART_FUN_EN BIT(1) #define RK806_SLAVE_RESTART_FUN_OFF 0 --=20 2.50.0