From patchwork Wed Aug 18 01:09:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 12442455 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19F7EC4338F for ; Wed, 18 Aug 2021 01:10:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 90F54604AC for ; Wed, 18 Aug 2021 01:10:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 90F54604AC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rock-chips.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bGbjoPeOcaHaZJMNc6D5YN6zV63uh1mSF8GBJrO+rwc=; b=nwe0cIP2Qun958 PZYeIkQscR6LpdJtnv0t5KyMjA1RA0X2mgoHFvVz1l7ae46wuMbM5sSCGgnB/JBUdtloTGEUPbKau cK3LLt7HaOdkAXvLd9+5y1thdOxEdLz841d4CdUxsfbvbK0oYHh424fE63tB40F7XnuctnQRfeSJz 7JI+R/jXTZymMaK1iSmBRYbnh/yJa7Bj3j/MhaPMbuMBMdT8KJovynAvsTmbjlu2bq1RS+XutML1D d3RHyGgNhTBGUxqiZdS8z+I81JxdzXWrnaKK/kJo7vosxbmxthXzpC9fm0EegyEHXhBdtZNO+SVYV S2+3Gj0aZHwm3wjx+iwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGA5p-003q7M-JY; Wed, 18 Aug 2021 01:10:09 +0000 Received: from lucky1.263xmail.com ([211.157.147.130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGA5m-003q64-Nu for linux-rockchip@lists.infradead.org; Wed, 18 Aug 2021 01:10:08 +0000 Received: from localhost (unknown [192.168.167.70]) by lucky1.263xmail.com (Postfix) with ESMTP id 6CDABD7844; Wed, 18 Aug 2021 09:09:59 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P4989T139771053602560S1629248997664310_; Wed, 18 Aug 2021 09:09:58 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <1202da6092116cff8f89b39414f39eb5> X-RL-SENDER: jay.xu@rock-chips.com X-SENDER: xjq@rock-chips.com X-LOGIN-NAME: jay.xu@rock-chips.com X-FST-TO: lgirdwood@gmail.com X-RCPT-COUNT: 9 X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: Jianqun Xu To: lgirdwood@gmail.com, broonie@kernel.org, ulf.hansson@linaro.org, lee.jones@linaro.org, zhangchangzhong@huawei.com, heiko@sntech.de Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jianqun Xu Subject: [PATCH v3] soc: rockchip: io-domain: set 3.3V before regulator disable Date: Wed, 18 Aug 2021 09:09:56 +0800 Message-Id: <20210818010956.1446770-1-jay.xu@rock-chips.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210817_181007_051979_AC269878 X-CRM114-Status: UNSURE ( 9.73 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Do a fix to rockchip io-domain, follow this orders: * system running state -> io-domain vsel to 3.3V (actually is done by pre-disable) -> regulator_enable -> vsel change according to regulator voltage * system running state -> io-domain vsel to 3.3V -> regulator_disable Found on some Rockchip SoCs, the regulator enable or disable without care about the io-domain maybe caused soc damaged. Tested on RV1126 EVB. Signed-off-by: Jianqun Xu Reported-by: kernel test robot Reported-by: kernel test robot --- v3: - abandon PRE-ENABLE patch - delete the EVENT_PRE_ENABLE case v2: none v1: first version drivers/soc/rockchip/io-domain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c index cf8182fc3642..3c59077fafb1 100644 --- a/drivers/soc/rockchip/io-domain.c +++ b/drivers/soc/rockchip/io-domain.c @@ -123,6 +123,12 @@ static int rockchip_iodomain_notify(struct notifier_block *nb, } else if (event & (REGULATOR_EVENT_VOLTAGE_CHANGE | REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE)) { uV = (unsigned long)data; + } else if (event & REGULATOR_EVENT_PRE_ENABLE) { + uV = MAX_VOLTAGE_3_3; + } else if (event & REGULATOR_EVENT_PRE_DISABLE) { + uV = MAX_VOLTAGE_3_3; + } else if (event & REGULATOR_EVENT_ENABLE) { + uV = regulator_get_voltage(supply->reg); } else { return NOTIFY_OK; }