Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp341875ybv; Fri, 7 Feb 2020 00:11:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwO48I+EkYeP8YaF48uj7gWWKdN4UajNy2r6iSATV9drF55P986SDjL92fb2J5heq8fBXfE X-Received: by 2002:aca:af09:: with SMTP id y9mr1202509oie.101.1581063112342; Fri, 07 Feb 2020 00:11:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1581063112; cv=pass; d=google.com; s=arc-20160816; b=XatFxpofi2cFo9TlvJARf/AaKE+suVS+cCcjPdK1Phe60wke/HRY0OTQJPNoSXQGWs 5Z9ZDPce7LoK8jzLDqJVxEe/8rHppmFJNAM6mLSBTKXfXeM3aepYvLDW1EQaqz5cDsTc fpobGsMNgX000qwu4B7lwBWZdXYdUuaNXlwtFbv5UiGLi22Dg+g6FNrgMVQxO4yLY+qh oU1bthAwLGSfz8qsC/R3VLTtfGDqgoz/juCfSeoSSvW2Z9iwHYPFz5Ah4mS1Vf+0j1hf IAd1imYc3bpMNwf5FJOvkmt2Tl1Mj03GuOlZ7PW1rJVxzFzno21vDIOL5SYkJhnCxhN1 TdrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=tWpfQjQ8kJI8DTUzc69VkE9kwzJn0d+di+JsZZZjwtQ=; b=OJmAzMnskjj0IHylpYaNob218DJkJ37RHkjLYHDHZfv+kYK/QBoV453+9RoPYT24md A3Cn+pr4kL4g2rJiS6TAiAOaQ3YP4mc8gzufQ7ewvgz3QWtuuNy2HEkuV3Mi9Tn/ePJw KrinkZU9gxgQ/exE1dlAP0B83NKFMs8Rb+ZRUj0h2ZjhoLXL2HwFYvH6SXv5m68SStlE Hshgdk/v0Ja0Fqg6ZpmvS6VXMKvnNOR5Wv5pUgZEKFu9qNOeZcxrazz8qnAsLMpGhDSp ZbHZPRy3nscH75xpdyKZWTBKCzYWbx+T6WVbJX/wzB/652JJS292OZGNXTjQqUQah+H/ oJpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=j5eYJ8iZ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y8si1272207otg.309.2020.02.07.00.11.40; Fri, 07 Feb 2020 00:11:52 -0800 (PST) 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=@nxp.com header.s=selector2 header.b=j5eYJ8iZ; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbgBGIK3 (ORCPT + 99 others); Fri, 7 Feb 2020 03:10:29 -0500 Received: from mail-eopbgr00089.outbound.protection.outlook.com ([40.107.0.89]:12707 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726130AbgBGIK2 (ORCPT ); Fri, 7 Feb 2020 03:10:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CclBG4vWG8BW28zU4IStJ11FWF51MZOFpA7XxtralPBXaXTjjP3uRxpFbsiVyLZy+gBvNHZVtQwftJGe9zatlhlS+kgS+8jJpqxkuCmneLRvzmiyMBiDde0HNNdGs63EvzPIz1bTV2FNPfG2XMPrzYojTcoEchqWMYItYWCnQMKZzYWo7rLyoVEYJNmJYOto/FHJl4YuYotXn/2MEcEQ0JEn9F/ggL2edz5OrEaOMVbPW9ehKP07zoaBpxdPAQiIBwJYxLZXP7l1m4UZa6i0AUnCrjRwISLc4YxHExPQ3kSMVESAaLGtSoR9c73fnLsmDbsdrFCVbPveqofWPCbmvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tWpfQjQ8kJI8DTUzc69VkE9kwzJn0d+di+JsZZZjwtQ=; b=AfRWFwJWBsRt+4dJanhkUCn0kdfMqWw2WkHMERKi8CB6H1E3hp8+4XGHxfZ12gyaZOK3F+Sglt1WPYK/G5VVqoMKRh3ApgCNop/TavSu+cZ0YodccY6rL+ZxZrCMloTiPi4M1LR38lvrrerb4Mzh3neMCUNYyWj2pMKtb5SN0HCCqrfjOslwj4BTSwh8MMA7utJFnCG2EAfAlsyC45XyTj4/TWzedUeQCxW0aPNS2898PUEV1eqx38SkZy1q9kPwU95RWDnpDV+ILyuYN/NFY7m9izH83+S+KvNB7Ri/00TcGn98yuTTLqSIKtf5zvE+IM0w+VWQ0EewUALn704CHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tWpfQjQ8kJI8DTUzc69VkE9kwzJn0d+di+JsZZZjwtQ=; b=j5eYJ8iZjZjCEfv/RtWhOgQYhxhfnDwxYXX/RLcP/cXmwaX0JgoGYriW73vuZdHqTjYo/1LOPbZUz3y7POpMTOViUZuy5LCOaTYSMJoN7sjBzObyyrCpb9WdXHBgeDMmoDoqhk62yv593nFAXgdJAaaCLWmKeMnFXY4sj0WWCwM= Received: from VI1PR0402MB3485.eurprd04.prod.outlook.com (52.134.3.153) by VI1PR0402MB2831.eurprd04.prod.outlook.com (10.175.23.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.21; Fri, 7 Feb 2020 08:10:22 +0000 Received: from VI1PR0402MB3485.eurprd04.prod.outlook.com ([fe80::85e9:f844:f8b0:27d]) by VI1PR0402MB3485.eurprd04.prod.outlook.com ([fe80::85e9:f844:f8b0:27d%7]) with mapi id 15.20.2707.024; Fri, 7 Feb 2020 08:10:22 +0000 From: Horia Geanta To: =?iso-8859-2?Q?Andr=E9_Draszik?= , "linux-kernel@vger.kernel.org" CC: Anson Huang , Dmitry Torokhov , Aymen Sghaier , Herbert Xu , "David S. Miller" , Rob Herring , Mark Rutland , "linux-crypto@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-input@vger.kernel.org" , Robin Gong , dl-linux-imx Subject: Re: [PATCH 2/3] Input: snvs_pwrkey - enable snvs clock as needed Thread-Topic: [PATCH 2/3] Input: snvs_pwrkey - enable snvs clock as needed Thread-Index: AQHV164yHhXoESmTiUqzHJu+3DHGMA== Date: Fri, 7 Feb 2020 08:10:22 +0000 Message-ID: References: <20200130204516.4760-1-git@andred.net> <20200130204516.4760-2-git@andred.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=horia.geanta@nxp.com; x-originating-ip: [212.146.100.6] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 8580592e-cffa-4e3d-d394-08d7aba52de4 x-ms-traffictypediagnostic: VI1PR0402MB2831:|VI1PR0402MB2831: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0306EE2ED4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(4636009)(396003)(136003)(376002)(366004)(346002)(39860400002)(199004)(189003)(44832011)(71200400001)(478600001)(54906003)(110136005)(86362001)(52536014)(5660300002)(6506007)(53546011)(33656002)(7696005)(9686003)(7416002)(26005)(55016002)(2906002)(186003)(316002)(8676002)(4326008)(66446008)(76116006)(66476007)(91956017)(81156014)(66946007)(64756008)(66556008)(81166006)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB2831;H:VI1PR0402MB3485.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5i593SuVIV9VlrFODnta1JRZxl64VhMc52UqyZNe/iHQ3TjHU/NZK6KvXsgBuk1i8M0egru7iTPEX44Sr9M7qhGv5mqGR0qx7J0AqY63U2eRYS1zbh9PeSuTuX0h1dNVaSEA/zaWhdwZt31JcVMxwag3Owsf+DABF1VJnr15OjS7QwxG9sUNwmVG+TLolAg+oFolZTbbDQj2YRmO6tmOhMj5PxvwxuaxH8vbyBMwluDsyk1EANm20UHPVhq0PvCA304kHcqJvAYNhw+BWspLo8q6hpq9nf4QeseM2Ar2LWtucXSzq4CK156/h4LtYcXAwVzlsVXQkKcxma7P9awkSwHQA/ILXGw0DGBcq1I7B0L9nEErB2PqCWZ0Ca6DolBsKpeT5u4FOY+PKNjwbUW3cWS6QDT+98cnnhyhaiqQO2Swd3Cy087rsEzr3yc9jDck x-ms-exchange-antispam-messagedata: Bhp15MSc5oNhXwm9ztodemqNFKrR8LMyHqD0nq9Qe9HfUVi4abqGMgiz82+N9FDrfNeKX9AVklGOBCVvMmSubnGct0j432qeIQBvoyr+jLNDez5oQiAx5ck0q9xdXutmMGgZmKfLKqd1upQrQPJZqQ== Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8580592e-cffa-4e3d-d394-08d7aba52de4 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Feb 2020 08:10:22.3029 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Xb7V0opFCYwMk2eE4+4oWGRLomzYNRU0HQQnyoOW28xmUxdsbRHOSjCbWA2Z3PXxsZ0MDZ40JCigQ3+cVkeoow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2831 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/30/2020 10:45 PM, Andr=E9 Draszik wrote:=0A= > At the moment, enabling this driver without the SNVS RTC driver=0A= > being active will hang the kernel as soon as the power button=0A= > is pressed.=0A= > =0A= > The reason is that in that case the SNVS isn't enabled, and=0A= > any attempt to read the SNVS registers will simply hang forever.=0A= > =0A= > Ensure the clock is enabled (during the interrupt handler) to=0A= > make this driver work.=0A= > =0A= > Also see commit 7f8993995410 ("drivers/rtc/rtc-snvs: add clock support")= =0A= > and commit edb190cb1734=0A= > ("rtc: snvs: make sure clock is enabled for interrupt handle")=0A= > for similar updates to the snvs rtc driver.=0A= > =0A= > Signed-off-by: Andr=E9 Draszik =0A= > Cc: Anson Huang =0A= > Cc: Dmitry Torokhov =0A= > Cc: "Horia Geant=E3" =0A= > Cc: Aymen Sghaier =0A= > Cc: Herbert Xu =0A= > Cc: "David S. Miller" =0A= > Cc: Rob Herring =0A= > Cc: Mark Rutland =0A= > Cc: linux-crypto@vger.kernel.org=0A= > Cc: devicetree@vger.kernel.org=0A= > Cc: linux-input@vger.kernel.org=0A= > ---=0A= > drivers/input/keyboard/snvs_pwrkey.c | 27 +++++++++++++++++++++++++++=0A= > 1 file changed, 27 insertions(+)=0A= > =0A= > diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboar= d/snvs_pwrkey.c=0A= > index 2f5e3ab5ed63..c29711d8735c 100644=0A= > --- a/drivers/input/keyboard/snvs_pwrkey.c=0A= > +++ b/drivers/input/keyboard/snvs_pwrkey.c=0A= > @@ -16,6 +16,7 @@=0A= > #include =0A= > #include =0A= > #include =0A= > +#include =0A= > #include =0A= > #include =0A= > =0A= > @@ -38,6 +39,7 @@ struct pwrkey_drv_data {=0A= > int wakeup;=0A= > struct timer_list check_timer;=0A= > struct input_dev *input;=0A= > + struct clk *clk;=0A= > u8 minor_rev;=0A= > };=0A= > =0A= > @@ -72,6 +74,9 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, v= oid *dev_id)=0A= > struct input_dev *input =3D pdata->input;=0A= > u32 lp_status;=0A= > =0A= > + if (pdata->clk)=0A= > + clk_enable(pdata->clk);=0A= > +=0A= clk framework handles NULL pointers internally, the check is redundant.=0A= =0A= > pm_wakeup_event(input->dev.parent, 0);=0A= > =0A= > regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status);=0A= > @@ -96,6 +101,9 @@ static irqreturn_t imx_snvs_pwrkey_interrupt(int irq, = void *dev_id)=0A= > /* clear SPO status */=0A= > regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO);=0A= > =0A= > + if (pdata->clk)=0A= > + clk_disable(pdata->clk);=0A= > +=0A= > return IRQ_HANDLED;=0A= > }=0A= > =0A= > @@ -140,6 +148,25 @@ static int imx_snvs_pwrkey_probe(struct platform_dev= ice *pdev)=0A= > if (pdata->irq < 0)=0A= > return -EINVAL;=0A= > =0A= > + pdata->clk =3D devm_clk_get(&pdev->dev, "snvs-pwrkey");=0A= > + if (IS_ERR(pdata->clk)) {=0A= > + pdata->clk =3D NULL;=0A= Using devm_clk_get_optional() would simplify error handling.=0A= =0A= > + } else {=0A= > + error =3D clk_prepare_enable(pdata->clk);=0A= > + if (error) {=0A= > + dev_err(&pdev->dev,=0A= > + "Could not prepare or enable the snvs clock\n");=0A= > + return error;=0A= > + }=0A= > + error =3D devm_add_action_or_reset(&pdev->dev,=0A= > + (void(*)(void *))clk_disable_unprepare,=0A= > + pdata->clk);=0A= > + if (error) {=0A= > + dev_err(&pdev->dev, "failed to add reset action on 'snvs-pwrkey'");= =0A= > + return error;=0A= > + }=0A= > + }=0A= > +=0A= > regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid);=0A= > pdata->minor_rev =3D vid & 0xff;=0A= > =0A= > =0A=