Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4929901yba; Tue, 30 Apr 2019 06:41:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZ9Dxn6lHgBQTiWdR6v315Tds8Io4Hh+XQuAHrt2TXnWr1oFbzY5BdKaDKxoaVXH899O07 X-Received: by 2002:a62:415d:: with SMTP id o90mr70114038pfa.236.1556631664566; Tue, 30 Apr 2019 06:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556631664; cv=none; d=google.com; s=arc-20160816; b=SoGjATj9enHC8d7bLYbm6ot5NQN/O6U1ROJ6nqzSR+1Ah70HUCE2zqaC8/KMXN1Zsi HTiDmB+78RRsqOpg1vT2wkLZFNuViGkn68K/lXfG+47bZz/wr8HkkLDxqI5KExdvPvna zm6IXAhSDNCzKJDP6IwgO1sm6Q5gobKyQI6tK0Eu8G1oZAzucYjK7AEYk0B1pA9aR6se 5U6JPw6zgKpF0Jd0kVxAajhuuBbgKMhVIIffDipyEIxbYvtx80khhx3qaFeejB3ofXX8 oXnCoE8ZyPSRDRjnUAQ6vJPTUMI2SZp6Trc+MOoxLJ+rwkDVpgKrSpoSCavGbx98TsdD xSvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=itopA/ItRE7ZMWfQuGvoXaTCudQHZDXEixDU5B3vzos=; b=RsCDHWHvl0vVe43m/c6HnbbTdQXisupwlnp7fyhg7kt4PKtt1/XzH36RNTOZqm9Cii UXDDrv4qntEVCWMt053qE55cWb9u2mzkIt/8flC3FSKvmNMUNdv5If4vSO4wY+C3+NIw 3kui1UZSk/MmBIKqLfi3H/u8H996HGpEgRTv4EMiBtUQiFALGyt/rXgd4Ntgngm5QeSa TpzztHBD+728G63TAew5aGoY82KzPcfgEiWT1PGZch8o34XurMxfm8mdrAXly9LJAMFI RcEAzl1R9463q7ifUTXCh5rgwxhrop8xh7OG2YuViPzdzhcF/u2MbzCpshiMh0jRHsnW 5CbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hxATa+VE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q80si15237195pfq.160.2019.04.30.06.40.48; Tue, 30 Apr 2019 06:41:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hxATa+VE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727478AbfD3Ni5 (ORCPT + 99 others); Tue, 30 Apr 2019 09:38:57 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33859 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbfD3Ni4 (ORCPT ); Tue, 30 Apr 2019 09:38:56 -0400 Received: by mail-wr1-f68.google.com with SMTP id v16so18662630wrp.1 for ; Tue, 30 Apr 2019 06:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=itopA/ItRE7ZMWfQuGvoXaTCudQHZDXEixDU5B3vzos=; b=hxATa+VEqQe59yueuVRTCPUR5y+WfuYh2iPbJElIGltimA4qVtAgZ6VonBKccZRolN b8x6WnqvTL10fcbLkvyFf33CSGh5Y/iGV/ifZQbpxOIXUq/PUc0A5f9uNJ/zW/nA1pL9 Mf5mwGvlRaexP67OjHDNIAhFlsW0MQbxA5Z4OSZOjF4DAkoxN2/6w3S5Sqc2DNQI/jI0 Y43MU6UBI7wg+m8590tAZbZdiMNM176Fe/nu4sW8fc5J9AA+nbyBYYHFSRXKvS/8JjK+ DNYpv0ZPQRXVT2xT/9Uj27WwTqaIJd4Cv1hobBFYxf5dos6S3RgKrE+nztobtmwKG8mX Gewg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=itopA/ItRE7ZMWfQuGvoXaTCudQHZDXEixDU5B3vzos=; b=K7VNZA9d1b4+6SyJ04fCbLYoo/70khfv5TfwKy01nFASEiffl2yYCvYEw4cUnCOWsk aaUGhdknxTgtzi+5BHdO10tgHdWx3X+y33GDqH2G3E5yWXHLSwlbzEDkyxYhVZ1L1HnW 9JiwXhIX5fqIy9qzR9Z9ljtCmH/i8KiPRkPll3cZQPfK0iRBJol6BcB7T8DsJiTg2efN XrdbRwKIv1Ys8kPJIUAvLB5pDSKIV1X6wXZK8H9z30AOMVgArXnaHhe69ozZl7UCUCPp TAX9QV8xamGVrruWcQaoJMq/G+hMKnoalqMD/WlCNxGdh9rcU3khWayK2tVWfCk3VbbI MIzA== X-Gm-Message-State: APjAAAXf/z11c/zjtWZdSf8tVm4DqHwgmZH7Lyceft591MnTKPisTDBL YueJJ9pCXKM9lMTDYimM28oUzw== X-Received: by 2002:a5d:5447:: with SMTP id w7mr1041635wrv.325.1556631533884; Tue, 30 Apr 2019 06:38:53 -0700 (PDT) Received: from [192.168.0.41] (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.googlemail.com with ESMTPSA id o16sm25803167wro.63.2019.04.30.06.38.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 06:38:53 -0700 (PDT) Subject: Re: [PATCH v3 1/3] thermal: rockchip: fix up the tsadc pinctrl setting error To: Elaine Zhang , heiko@sntech.de Cc: rui.zhang@intel.com, edubezval@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, xxx@rock-chips.com, xf@rock-chips.com, huangtao@rock-chips.com References: <1556618986-18923-1-git-send-email-zhangqing@rock-chips.com> <1556618986-18923-2-git-send-email-zhangqing@rock-chips.com> From: Daniel Lezcano Message-ID: <785392a0-282a-1e51-a4d6-a6d5ca478949@linaro.org> Date: Tue, 30 Apr 2019 15:38:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1556618986-18923-2-git-send-email-zhangqing@rock-chips.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/2019 12:09, Elaine Zhang wrote: > Explicitly use the pinctrl to set/unset the right mode > instead of relying on the pinctrl init mode. > And it requires setting the tshut polarity before select pinctrl. > > When the temperature sensor mode is set to 0, it will automatically > reset the board via the Clock-Reset-Unit (CRU) if the over temperature > threshold is reached. However, when the pinctrl initializes, it does a > transition to "otp_out" which may lead the SoC restart all the time. > > "otp_out" IO may be connected to the RESET circuit on the hardware. > If the IO is in the wrong state, it will trigger RESET. > (similar to the effect of pressing the RESET button) > which will cause the soc to restart all the time. > > Signed-off-by: Elaine Zhang Reviewed-by: Daniel Lezcano > --- > drivers/thermal/rockchip_thermal.c | 36 +++++++++++++++++++++++++++++++++--- > 1 file changed, 33 insertions(+), 3 deletions(-) > > diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c > index 9c7643d62ed7..6dc7fc516abf 100644 > --- a/drivers/thermal/rockchip_thermal.c > +++ b/drivers/thermal/rockchip_thermal.c > @@ -172,6 +172,9 @@ struct rockchip_thermal_data { > int tshut_temp; > enum tshut_mode tshut_mode; > enum tshut_polarity tshut_polarity; > + struct pinctrl *pinctrl; > + struct pinctrl_state *gpio_state; > + struct pinctrl_state *otp_state; > }; > > /** > @@ -1242,6 +1245,8 @@ static int rockchip_thermal_probe(struct platform_device *pdev) > return error; > } > > + thermal->chip->control(thermal->regs, false); > + > error = clk_prepare_enable(thermal->clk); > if (error) { > dev_err(&pdev->dev, "failed to enable converter clock: %d\n", > @@ -1267,6 +1272,30 @@ static int rockchip_thermal_probe(struct platform_device *pdev) > thermal->chip->initialize(thermal->grf, thermal->regs, > thermal->tshut_polarity); > > + if (thermal->tshut_mode == TSHUT_MODE_GPIO) { > + thermal->pinctrl = devm_pinctrl_get(&pdev->dev); > + if (IS_ERR(thermal->pinctrl)) { > + dev_err(&pdev->dev, "failed to find thermal pinctrl\n"); > + return PTR_ERR(thermal->pinctrl); > + } > + > + thermal->gpio_state = pinctrl_lookup_state(thermal->pinctrl, > + "gpio"); > + if (IS_ERR_OR_NULL(thermal->gpio_state)) { > + dev_err(&pdev->dev, "failed to find thermal gpio state\n"); > + return -EINVAL; > + } > + > + thermal->otp_state = pinctrl_lookup_state(thermal->pinctrl, > + "otpout"); > + if (IS_ERR_OR_NULL(thermal->otp_state)) { > + dev_err(&pdev->dev, "failed to find thermal otpout state\n"); > + return -EINVAL; > + } > + > + pinctrl_select_state(thermal->pinctrl, thermal->otp_state); > + } > + > for (i = 0; i < thermal->chip->chn_num; i++) { > error = rockchip_thermal_register_sensor(pdev, thermal, > &thermal->sensors[i], > @@ -1337,8 +1366,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev) > > clk_disable(thermal->pclk); > clk_disable(thermal->clk); > - > - pinctrl_pm_select_sleep_state(dev); > + if (thermal->tshut_mode == TSHUT_MODE_GPIO) > + pinctrl_select_state(thermal->pinctrl, thermal->gpio_state); > > return 0; > } > @@ -1383,7 +1412,8 @@ static int __maybe_unused rockchip_thermal_resume(struct device *dev) > for (i = 0; i < thermal->chip->chn_num; i++) > rockchip_thermal_toggle_sensor(&thermal->sensors[i], true); > > - pinctrl_pm_select_default_state(dev); > + if (thermal->tshut_mode == TSHUT_MODE_GPIO) > + pinctrl_select_state(thermal->pinctrl, thermal->otp_state); > > return 0; > } > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog