From patchwork Mon Mar 4 15:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271067rwb; Mon, 4 Mar 2024 07:40:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVzw1oaoDltPbI3hmKYIglQHiS3dG80e9x3k6th9O5bSZWVn6YzDRxeLxDb2lukb9JFPhTMRJa8h3fmsLJhhEu8Bkh1xA== X-Google-Smtp-Source: AGHT+IGhgR4BEACeMR3pYoNd8cUr3GWBUfY7lANCp7dDzgQxMuwcBbTdk+qz2lRSD+cJwF1M3dxJ X-Received: by 2002:a4a:55cb:0:b0:5a1:34cf:400c with SMTP id e194-20020a4a55cb000000b005a134cf400cmr3020135oob.9.1709566808466; Mon, 04 Mar 2024 07:40:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566808; cv=pass; d=google.com; s=arc-20160816; b=u4JxKeCpKFawqERjvlCvmTERh6sfOP0a0y33w5wKuNEZohUkNNThXGzNqBIYpvT3PK GwzS6gShsvlFtyCMxfMQQeRI/oQXeTnC327cY1rLxo8kTGeKakJy+VrPEwZ9U1ZWYyi1 XNxzMyP2Qpt6mvTNvrywEJS0fUmJPDdCfSi2oPY+6SM1LSbf7ArmYcmDXclB/OelVwM/ Z72HpKtUpbTJTxaMJCch60rfe/JMUANAP9rGjdgAAjswp1Mm09q9prwKUYymPlJ6e1tw JE+prxoh4+wWUAVMeaXnbMB16xESfP6CSwQLPi/Scc8VYENEbL9JWGAeCjLi+CPJ1Ha6 HOCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=S70Ysmy7GOlawn6RWq9qzGyOkNk33BPaQBIqrV30L4w=; fh=VrsRFtkD0hMWNKyj9pS5kb8sMdNdbsISh0SCB8JLgwo=; b=mpdIdzKwTznV6RU3aYheU7ncFCzwXgh7oTHXvaeXdk2qAoZhFT2tLneNecczjNSVTg IGBqy+8KI3P1d5aTnL/3yNk5rP33Ox4SsGeO9PaHExbGP1aji1/6f1XNvP3grnP1lDcE bbMWXjA+CYN6sG3T8rIHpDHFf7ycpoqcK0CUhZ+Cjd6m9XoqC2ncR5x7ZEwuUVvJSWzz izmsGxK9rC4u11wd7/Mdr431YoEXNliCasrVPrd3p+Mhn1sanvMYXayltnswXDGwgdNF w5iw3iClFUqxAo9j51KA6Gnkv76zsgIi16sXxZLop03cj3IIJDlmjsmFYsoqp76f9KCX xhoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SoKAV7l1; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r33-20020a635161000000b005e45abc35dfsi8297235pgl.239.2024.03.04.07.40.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SoKAV7l1; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90840-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90840-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 18E60280354 for ; Mon, 4 Mar 2024 15:37:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 545074CB37; Mon, 4 Mar 2024 15:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SoKAV7l1" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 AD24645945; Mon, 4 Mar 2024 15:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566575; cv=none; b=plB0pAyk8TuQSCT821nklXNKVPsmHsWTk+qOYykykcCt2RFqdS7NXKGUJI3eMtqhJrxUym5IwrEWUIIUnqlCDOJNIHcBmd6FcVm9HHJjZwzczmUUfoa5Z7YSL5Z1cyw4LHpuwsq6+yDO4J+D4yCyaOEa5oClD9H/sbiH9DNo7hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566575; c=relaxed/simple; bh=OyHx7ZZ4/h8Wstp56SurooyJvSWdHdopw96/iRKHd8A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YdSjZGdXNjsB3ihLnP3ZNgVEOnk4gy5Gz/hEB1QKdDkHvzXz7+my3m3tu7Pofuivqu/UwhlyUvatfXckMfXnW9QvK3sg/j/QGJpSD/waaKCWFTSoDgizUybEE4JUQl0Rit1xGocWIoyYcNZ+yE5RTQkMgIlyO15rI8tJtVxWsrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SoKAV7l1; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 360FF1BF210; Mon, 4 Mar 2024 15:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S70Ysmy7GOlawn6RWq9qzGyOkNk33BPaQBIqrV30L4w=; b=SoKAV7l1oULBbize5FjHEPjME+6LADGMzeXVTkq+CIh7y7M/Ycx5mrDbeTJuHw/sUhWu4l +EkdGkyaoBEtZLLmGRY6YB1lx+oj3LIiIdiHE5vmXhwNgGI6TMDQVyJkFFAvvA4hU4rhub gIxKMAMM+dHWDq9IhtMNoSB38D/F7Sd7T2q+qhYkt6L2e9UqV6aAvf9QFDuvQRq7jV/jtX fFQnfWNJLhgDowZwlqqoGQmkQd9lK69dtlpb2R5H39CWFoFau1tSoES584IumVVsShNhnc 6zbshGVKikIKdBoDBdZUXS9enzShujTMDAUSYpvoFWK2DV04KUKRSDzH2asO1g== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:44 +0100 Subject: [PATCH v4 01/18] gpio: pca953x: move suspend()/resume() to suspend_noirq()/resume_noirq() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-1-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Bartosz Golaszewski , Andy Shevchenko X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610725503898020 X-GMAIL-MSGID: 1792610725503898020 Some IOs can be needed during suspend_noirq()/resume_noirq(). So move suspend()/resume() to noirq. Reviewed-by: Andi Shyti Acked-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Signed-off-by: Thomas Richard --- drivers/gpio/gpio-pca953x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 00ffa168e405..6e495fc67a93 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -1234,7 +1234,7 @@ static void pca953x_save_context(struct pca953x_chip *chip) regcache_cache_only(chip->regmap, true); } -static int pca953x_suspend(struct device *dev) +static int pca953x_suspend_noirq(struct device *dev) { struct pca953x_chip *chip = dev_get_drvdata(dev); @@ -1248,7 +1248,7 @@ static int pca953x_suspend(struct device *dev) return 0; } -static int pca953x_resume(struct device *dev) +static int pca953x_resume_noirq(struct device *dev) { struct pca953x_chip *chip = dev_get_drvdata(dev); int ret; @@ -1268,7 +1268,8 @@ static int pca953x_resume(struct device *dev) return ret; } -static DEFINE_SIMPLE_DEV_PM_OPS(pca953x_pm_ops, pca953x_suspend, pca953x_resume); +static DEFINE_NOIRQ_DEV_PM_OPS(pca953x_pm_ops, + pca953x_suspend_noirq, pca953x_resume_noirq); /* convenience to stop overlong match-table lines */ #define OF_653X(__nrgpio, __int) ((void *)(__nrgpio | PCAL653X_TYPE | __int)) From patchwork Mon Mar 4 15:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271229rwb; Mon, 4 Mar 2024 07:40:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXCV95u9/Ez8QuRRPRCKKZalHw6sum/0PWAK6e/PG8DC9beuXRDrUPe8UpOwYe19b4OF57fCyeuNYJ1yMxx4a3wn1d1xw== X-Google-Smtp-Source: AGHT+IErBbE+6S5NTak3RaBtbdGrprd59uxlYHSgDl+pZhL6jcXetPHsyCWh7jB3YZAnRXQrAMVM X-Received: by 2002:a05:6a00:4fce:b0:6e4:f11b:166b with SMTP id le14-20020a056a004fce00b006e4f11b166bmr11212025pfb.11.1709566829954; Mon, 04 Mar 2024 07:40:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566829; cv=pass; d=google.com; s=arc-20160816; b=LP9Evp2ECfNRnDb2rZG3ay9x3weVVlpj2hWzUsmQQguZtNLSGcQIpG8RZkV364h48f pAsyycZ6WUfi8j4W6TUJLytZdVmEVAHWx7x8wwP4wYc33bdUkUGYhLfmbS2pImdZ6+gK w0uVYT3EzQ5iBIpHN4jtnbsmRimQ4zZg4Q2knXchWBM8l4aTnmqaT5vbSfBKTlBWrVZa Vus7hqrxPnencl3aIqGBno5Kj7ZYJqKmPw5W2dmLlSyOaNeKT9SoK3wOP2YXR5gjcRCg 8ygatoNlmgNWcRfEfbN01+zCt4OXrdSqOvjTyJiNa23gXcxqQ9s01ySORJf85T6y7Isa JfNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=aDSdXnXZZ/5NY8WXefk2LzOT1GQOCIJxtJenx3zvKZU=; fh=IdcPguBdl6oDYUsmgxrzqe5bef7Dh5cZ5ixdfnbmY2g=; b=KzaDEKWjt17AL+q590V03ZN6hmO20dxgrbAWdHDJx3Rj1TbJYIqcaeMmkR1OZJ1FTG XlK76ZDyrUxcOqJpFDbG1f6Lu8QtjlUShLCrcSm1Mb8K8cHoBmKL4AesKMhBwalQ7pnN NGEq8//8Bd6V/e5vQ3ihQtlnYfLBXbFAiLMxCM0nPwGLAf1kNH1+xZR27sM0KXwPbuWU pnVt2tL8thusQv2wktIJDQTX+JVjn+lJSbCrbAsSaxRTSgp0zr++wHG3j5Y22XRLBric 4QXymEASaf5lzFc0ma1906VBrrpUQqRIwTLHLcIO2Jn9kRHRorHlFMPxluvZttWxZ3K2 xwmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L9gcfnpx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90841-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a40-20020a056a001d2800b006e60f5af182si2816091pfx.90.2024.03.04.07.40.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L9gcfnpx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90841-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90841-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 27FAA283629 for ; Mon, 4 Mar 2024 15:37:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1C0C4D5B7; Mon, 4 Mar 2024 15:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="L9gcfnpx" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 7F109481A5; Mon, 4 Mar 2024 15:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566577; cv=none; b=IA3kg4hkJa75HdqSFzIDqSGAPfDtSFu5kQM4fObTvWcRzLjgOOpj3V8ik1ghvdJi8ahLGM1pHclKydQ+1Kr3ezLhq5RrteiliBjJP1l12XAB9066uz+I4nYrX+hHzY110LkRM3G+wtX59ssO8TqxQg8OUHt07SxFacPCTKbzD0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566577; c=relaxed/simple; bh=q5g9w2LIy+fdicX1VZH/5+1jD99A7D83QQXIBIrBT58=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WNVd8fCnEgBaKem2EAIV3goq244+Xtl5Ss44lrRRai0ESVkNkxuRdE8XOu+IBwp9RgLioVkQ6TmARO3pJd0cNVwz8ljfX7cGxKbbikYelqb/sfsCkymDVnak+kiVaJ66gmIwHkQeVyrzV0xPHgRWEa/UmpHAkKtkqGwWDu+uSWM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=L9gcfnpx; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2CF251BF206; Mon, 4 Mar 2024 15:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aDSdXnXZZ/5NY8WXefk2LzOT1GQOCIJxtJenx3zvKZU=; b=L9gcfnpxclDI7aWK0k287Bw2zily1E6V4OBDUOmCgHFuMwtlTLxsZXjhY0yAaIolBQ/H5Z p6H3l71mRdh6Ugil8bst7Tyatr8UzCpkqRWriNLmgtQk08Mo2S+iLQii4tL6w6iGLUsSYI DPifmPExQfvsmXkFGv/1Olrn4v0CLoa/KmNqQYcYW50cRLQYwHRxgbEabXrm9OyBZgElBm cHb2Dmxdx60kEc2kIVWS8cjZDN1rgmuwPLcpPK2RPt93wrZpd2o27drdMriPh2Yx8OMRP4 Y0yyD4GTAGcNTvsTK1g6tV7cdAoXe2bKuLUEoO2izsXueMBvAmAubNEv42SSTw== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:45 +0100 Subject: [PATCH v4 02/18] pinctrl: pinctrl-single: move suspend()/resume() callbacks to noirq Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-2-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Andy Shevchenko X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610747959839010 X-GMAIL-MSGID: 1792610747959839010 The goal is to extend the active period of pinctrl. Some devices may need active pinctrl after suspend() and/or before resume(). So move suspend()/resume() to suspend_noirq()/resume_noirq() in order to have active pinctrl until suspend_noirq() (included), and from resume_noirq() (included). The deprecated API has been removed to use the new one (dev_pm_ops struct). No need to check the pointer returned by dev_get_drvdata(), as platform_set_drvdata() is called during the probe. Reviewed-by: Linus Walleij Reviewed-by: Andy Shevchenko Signed-off-by: Thomas Richard --- drivers/pinctrl/pinctrl-single.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 19cc0db771a5..0dd4b0e11adf 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -1625,7 +1625,6 @@ static int pcs_irq_init_chained_handler(struct pcs_device *pcs, return 0; } -#ifdef CONFIG_PM static int pcs_save_context(struct pcs_device *pcs) { int i, mux_bytes; @@ -1690,14 +1689,9 @@ static void pcs_restore_context(struct pcs_device *pcs) } } -static int pinctrl_single_suspend(struct platform_device *pdev, - pm_message_t state) +static int pinctrl_single_suspend_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) { int ret; @@ -1710,20 +1704,19 @@ static int pinctrl_single_suspend(struct platform_device *pdev, return pinctrl_force_sleep(pcs->pctl); } -static int pinctrl_single_resume(struct platform_device *pdev) +static int pinctrl_single_resume_noirq(struct device *dev) { - struct pcs_device *pcs; - - pcs = platform_get_drvdata(pdev); - if (!pcs) - return -EINVAL; + struct pcs_device *pcs = dev_get_drvdata(dev); if (pcs->flags & PCS_CONTEXT_LOSS_OFF) pcs_restore_context(pcs); return pinctrl_force_default(pcs->pctl); } -#endif + +static DEFINE_NOIRQ_DEV_PM_OPS(pinctrl_single_pm_ops, + pinctrl_single_suspend_noirq, + pinctrl_single_resume_noirq); /** * pcs_quirk_missing_pinctrl_cells - handle legacy binding @@ -1986,11 +1979,8 @@ static struct platform_driver pcs_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = pcs_of_match, + .pm = pm_sleep_ptr(&pinctrl_single_pm_ops), }, -#ifdef CONFIG_PM - .suspend = pinctrl_single_suspend, - .resume = pinctrl_single_resume, -#endif }; module_platform_driver(pcs_driver); From patchwork Mon Mar 4 15:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp287954rwb; Mon, 4 Mar 2024 08:07:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVAV7BUpwRqNd8eexeVjh9c3I5gYzFBHTVKrR5BBWc2I071b0XBQhY76HI4j5aXoGdWdTx+jbFjN5tj8mlwoSaEim7qEQ== X-Google-Smtp-Source: AGHT+IErBuB0G+VsLbPrIC1+mDRcFqHFju5dNdqcGlRu+La8N+9mz0/y7OzaLgPsaWFsmUAwBwbJ X-Received: by 2002:a17:90a:b005:b0:29b:3cec:497d with SMTP id x5-20020a17090ab00500b0029b3cec497dmr2993437pjq.35.1709568469174; Mon, 04 Mar 2024 08:07:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709568469; cv=pass; d=google.com; s=arc-20160816; b=J/KJy6+LBYcocngyYXFVItVJDgGBd3ZmWNaq68wIlEzaWiLBW8Ql/orFoLWF4G/hRr Pe6ViDbcRIPqH4XTuXN9C9PQxC5rFnlwu++0TtfoJcZtTlAVCue88GG1I+HgSsseN8aL AkbHJpU+RPkDzJt8hLYrqwq486oqrvhW+HdP1+D9jCAZkg8Nt0vQCT3N6vH+s5XNQ6NS teDbGIh2FBKMfRM/2j7cRfKhEUicoGHqtTfBTBdx0K9a7bnZmKmy1RdWCbB3AiOnCtRB wd4MClXSl93i3/I7dcgOLKuYu3XBBJ2dnrh+KRksOuLR8d++EkB8T9RVOYGKWbVwCzoZ v1Iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=gl1VkLUtlzwgjyFHXIWhWfMxiJmBAtrbqfGEcOsrt6A=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=gY68idVJAWk6Pp3QuusDyUuRXx5qtqM625grE+5Kf4nQlgwZIgJFIF0uvxzcPtwJEE nnvyQE1SgOMJ+ol5ueb/Njy9MTT3etBEHqEThT7LmUco2EsHLCIYX38eaD2l4wG1uM/c iRJAAC+ztgHyMmIJRms/6TXbRZR0Ne5PH9tfOr9/iIjSruHlSxRO+oEWrii8azEQV84V +53Zr4TgGoV4rjmqyN+GAm/Vc+4BaXU6q0Tccm/SDoD43TWbrntLD182BRe3BhH1mbdT Hyb/WcDuOyQewn6P2qi2iFiD9hO0B6QDzAApFiTvTX63jVZmAcBURYImFcGzBQVE73FT jxtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KEWC1IKF; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90842-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90842-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s24-20020a17090aad9800b0029ac01b0281si10381928pjq.180.2024.03.04.08.07.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:07:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90842-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KEWC1IKF; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90842-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90842-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E19D9B26925 for ; Mon, 4 Mar 2024 15:37:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F7D44E1C1; Mon, 4 Mar 2024 15:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="KEWC1IKF" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 679C8487AE; Mon, 4 Mar 2024 15:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566578; cv=none; b=nfUTMv73tLndztqcLkIyonpIm2LvUn3ghKywhM6vrz3BkyeI2+BJEAoOD0TiPswmKxcqSrDXstwmtcJQP02MHUz2wmfYzrco5x+82iMdhFD8fgyn75h9nZdhKP4MXkXOiw+aSJt3f3MYPqs2hIFh2vrz5BG5QUXsCzeLioTtAc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566578; c=relaxed/simple; bh=Ff5habTJBwpnMGCWcJcXduOtk4oykNyYJ1ARoENGFO4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L8JZb2u0jY6P4VBVMX98e/k1NBP38UzEIDH0LwY9u1It0DX6LZWBqUnCmoLEDW/6l8zJyUe95WbdVf6t661c72jmpAD5yxcUrOM5nQ7ppC8Tnv+oMqWhZky4T92a7bWUHCYU1eX8SDck65A8vpqbynFPohsbtW+rpYYMg7JShI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=KEWC1IKF; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0A9B61BF20A; Mon, 4 Mar 2024 15:36:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gl1VkLUtlzwgjyFHXIWhWfMxiJmBAtrbqfGEcOsrt6A=; b=KEWC1IKFF6+WH764Ea9IkJgO1K0u3tppkwQfA0RE2+3oC4gLo8ZNlA2jHd4/2XDAe4PmK0 TMiqXGm31hhI4L5f7IOPlKybsmyogXbRtpAQaI3hwmg0ibql2l4y7t3NmeUdGGFoQkFwM1 tIEszKtCKzxUKAVMKyy1Qam5JZwCrUDzidj0FFO+ZFhBbhXgEJMHIaJF0+nWSZoJ32pdh3 N2cNG9JALpmFvLzLB0Nf9aP3kgiFHcVK/4aWQ0ULdXTXW/6VX8D6FZ3UEWEXTSGRYbBGsM rZ0om+g5FXbQDL5fk4mi4A6muXj3dpVWn1V+wqf867eqall84fE/FZ2xC7aObA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:46 +0100 Subject: [PATCH v4 03/18] i2c: omap: wakeup the controller during suspend() callback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-3-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792612466981082021 X-GMAIL-MSGID: 1792612466981082021 A device may need the controller up during suspend_noirq() or resume_noirq(). But if the controller is autosuspended, there is no way to wakeup it during suspend_noirq() or resume_noirq() because runtime pm is disabled at this time. The suspend() callback wakes up the controller, so it is available until its suspend_noirq() callback (pm_runtime_force_suspend()). During the resume, it's restored by resume_noirq() callback (pm_runtime_force_resume()). Then resume() callback enables autosuspend. So the controller is up during a little time slot in suspend and resume sequences even if it's not used. Signed-off-by: Thomas Richard --- drivers/i2c/busses/i2c-omap.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 42165ef57946..28417b2a18b0 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -1575,9 +1575,31 @@ static int __maybe_unused omap_i2c_runtime_resume(struct device *dev) return 0; } +static int omap_i2c_suspend(struct device *dev) +{ + /* + * If the controller is autosuspended, there is no way to wakeup it once + * runtime pm is disabled (in suspend_late()). + * But a device may need the controller up during suspend_noirq() or + * resume_noirq(). + * Wakeup the controller while runtime pm is enabled, so it is available + * until its suspend_noirq(), and from resume_noirq(). + */ + return pm_runtime_resume_and_get(dev); +} + +static int omap_i2c_resume(struct device *dev) +{ + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return 0; +} + static const struct dev_pm_ops omap_i2c_pm_ops = { SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(omap_i2c_suspend, omap_i2c_resume) SET_RUNTIME_PM_OPS(omap_i2c_runtime_suspend, omap_i2c_runtime_resume, NULL) }; From patchwork Mon Mar 4 15:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271463rwb; Mon, 4 Mar 2024 07:40:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVfMDul3Hb3m5/+szabtAwco4N6DcYocGfm9RtqRAbQjPOOuJ5T6N4xbnmMQ+rVX4jCNewz2yMoDxtZzryW7hVo/4lNUw== X-Google-Smtp-Source: AGHT+IGDMJ56Of+qGJzXa22G4bQ7I+xk5fOhYALN9t8eaRRNNQwq/WMRW7wz1xA6Pc05EW8P5QPb X-Received: by 2002:a05:6a00:1a87:b0:6e6:211e:1849 with SMTP id e7-20020a056a001a8700b006e6211e1849mr3107034pfv.11.1709566856027; Mon, 04 Mar 2024 07:40:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566856; cv=pass; d=google.com; s=arc-20160816; b=IVC2ePbhqxWytVCfof4BLsIr7uo3/rPAd9TwMbCZ0WFh9bdv7lCplQ5k0jdVRdxKhE 9dutdw6oLlLEVjxvJVj2vP2SxKEKmbxVbnTwOJaQE3ri72ZGMSq1evlEhtb7GnFUq4Qe nEmscba4UFC/SqYJ7bgGLKD2Wpvqw7oi5yo8wCVuUSpoJR4yw7eMlDwZokt+XelGVcxm tB9R1TR2K+bgk/5GImtqLFHbrvtRMGMmnjM9RIl3aCl4BBhORYgRxPEBSw5AXHg1Frj0 b07WN2qN0bK4o48jAmMModwwuWW8ZL0xqq5gEWwt36JcvbfOCzcRmkKUN/UU3q41+G7Y Xylw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=N+wkZZoLT0Vq8kTdRlFm+WcHMzeYn9ukxLpZ0zVifpE=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=w5qL/RdCOoMRGVhjYU9c1omhoqIwTncw1GilO3XrhxsFsdPicbT77sOk3zgAqrjkSB CtGxn12Y6pr/L1JRp7rdvW9WxSMck4PMNXX7FoLUBDKmvUf2Q8P51lykrNVvDrp05Cie 8sycbwI7C7lRUP4VGcJrsKKi2MZHkyycm5tEDagkEzSGfxZo3TgcxSUF6A/S2/Nn928h 3snEQfZlf9IR69Y3SXaO7wS7dVSCcxQ9ZMniZ3OjRBpbSokKxyJOzbTqXZgL0EQsk2M+ wFBR0CzKTPzP+xX0LiK+xKPqvi7Xn0/K6sVfYpMocYZPo9fUPD9csMqTvOO+nLiLWBaA H+6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Nddqbk+p; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90843-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90843-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a40-20020a056a001d2800b006e60f5af182si2816091pfx.90.2024.03.04.07.40.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90843-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Nddqbk+p; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90843-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90843-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BB31B288614 for ; Mon, 4 Mar 2024 15:38:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD81150275; Mon, 4 Mar 2024 15:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Nddqbk+p" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 718234CB46; Mon, 4 Mar 2024 15:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566581; cv=none; b=dzHvua12n8wUa95oyAWpbGZ60TB7Uk/N5UUKwCwwLdwgFqZH0kuWvMmk6YykorPPmXokZd6oA1RxJ7R5wXWv1jpj5vgQJW+FmHxuz4oVKqkaKHYYWgDn3ut1aQuZOh8sLsAC9pXj9YoYVBvRH2sYkADNEzddMaJDNyLU+nfTftY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566581; c=relaxed/simple; bh=bhAcdQhNVtJ/WY7T35xnlNhq8WgY2YmZ/UU091QPnqA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y/sMnXfYGobwfHXgk6ikoQ2f3ht6ixLQI5ZqSKnZhiccjQVLnmetKvivW2zpJM29SwMI3w4TSWzPJQQhQSs8+hZp9tJHdbY8HJbMTjKh3S0XOBxx1+vCcrGBTPdqFAGw2+8P+rQFXvVOxCO5K3C8VCD5WY8mZF7kMyTksB4hXDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Nddqbk+p; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E0A431BF20B; Mon, 4 Mar 2024 15:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N+wkZZoLT0Vq8kTdRlFm+WcHMzeYn9ukxLpZ0zVifpE=; b=Nddqbk+pnI5GQTwJOSSeWAzxXi5gSfG5PpAV94Uq5te126mltno/izPKS64YRUTqXKDTnm +Gp5xWr6NztvDTcDfj/s1ytS/ahX7cwiNQoGEGWpS63q9eQpf+MHfqygyMrNH3PPdOVL/U pPvOKKdtZB6sGHKS+T5CM/txXhSuYxu9dXW2fBRF5uDkDiU+bc9fw1EaMRrdboy2C1E+U7 RgnAtiyRcXJiz4keIm/8ucfWJOlRtAqj9V0617CC2uTPY/YIBLj3I4La4veDTPfL+8L4Vz mZ7UDFy88LEfitW8/gzny0fz6MMMuSNKCGpurLDN1rEszy0q2htWNQt8xmeUEg== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:47 +0100 Subject: [PATCH v4 04/18] mux: add mux_chip_resume() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-4-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610775616646246 X-GMAIL-MSGID: 1792610775616646246 The mux_chip_resume() function restores a mux_chip using the cached state of each mux. Signed-off-by: Thomas Richard --- drivers/mux/core.c | 29 +++++++++++++++++++++++++++++ include/linux/mux/driver.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 775816112932..0742aa2a7c73 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -215,6 +215,35 @@ void mux_chip_free(struct mux_chip *mux_chip) } EXPORT_SYMBOL_GPL(mux_chip_free); +/** + * mux_chip_resume() - restores the mux-chip state + * @mux_chip: The mux-chip to resume. + * + * Restores the mux-chip state. + * + * Return: Zero on success or a negative errno on error. + */ +int mux_chip_resume(struct mux_chip *mux_chip) +{ + int ret, i; + + for (i = 0; i < mux_chip->controllers; ++i) { + struct mux_control *mux = &mux_chip->mux[i]; + + if (mux->cached_state == MUX_CACHE_UNKNOWN) + continue; + + ret = mux_control_set(mux, mux->cached_state); + if (ret < 0) { + dev_err(&mux_chip->dev, "unable to restore state\n"); + return ret; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(mux_chip_resume); + static void devm_mux_chip_release(struct device *dev, void *res) { struct mux_chip *mux_chip = *(struct mux_chip **)res; diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h index 18824064f8c0..2a7e5ec5d540 100644 --- a/include/linux/mux/driver.h +++ b/include/linux/mux/driver.h @@ -88,6 +88,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev, int mux_chip_register(struct mux_chip *mux_chip); void mux_chip_unregister(struct mux_chip *mux_chip); void mux_chip_free(struct mux_chip *mux_chip); +int mux_chip_resume(struct mux_chip *mux_chip); struct mux_chip *devm_mux_chip_alloc(struct device *dev, unsigned int controllers, From patchwork Mon Mar 4 15:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1501078dyc; Mon, 4 Mar 2024 07:39:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV6XcOCb2GzRBqFfEhEc5viELye4oua39BObzYnvPGCFvIOwx8SfNVMVMz+ddSAWYKz9KALEYg2CFuIA2AWxtul+YnnJw== X-Google-Smtp-Source: AGHT+IGdm7K2bW+D5SlmK6ukpx/PZnorDLldqqC9uebGOsF1TFxhocArr2/4DEJ0ROCtlH6d972V X-Received: by 2002:a50:cc47:0:b0:567:504e:e788 with SMTP id n7-20020a50cc47000000b00567504ee788mr2207036edi.11.1709566766233; Mon, 04 Mar 2024 07:39:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566766; cv=pass; d=google.com; s=arc-20160816; b=U38OyRziCBfVwVHTnKGBl3kmBjKYORkuoeJKwk0bJUcq1veU1LqjI7uxCYwZH6kh4k VpKqxftuRKCaIs7nKbFeBBZMfqL51qYeXWvSUYsxusaPF4KVqOSqadp78RJw6tl582k1 wyV87BCnQLcnwOVFCHq6m/lptX5UsacfGZUEl/YABx7fOAvAJrau+5pwEKsh1thLoweJ kY3OabOO+YXkuSIATOTHI/sawWSHd1r/pbeZWtXtxMzRFTt3V047DDk9405x216TI1de i/71o7bCl7Nw8h91o59cGswuvVDCUrTW0HEuRLTbVtnrL+cYOkVRv4nmWx9RZ2FLhv5H n75w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=jPqUbSf1Qdf1yloJtVBeCvPFg+XlI7QIXeQdbRho+l4=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=aJHuHrHQKFHMT6H8qH/n/DvxKTQQbLGNfP4HkSEiaP8YalJuzWHcJFWekoOE3lqwwR mUJkZ3QytEOmfK33bwWiK3Flw7Sp72IfLTyi3ZYp+l0g/kq0Tar2XBq0hMB/36tSmUkT nn7kQXq8Jz54xPDiq4j0+yYlhfd4WKtRhGvK9ppZ6R8tcaXRuGW2AQ9T89xaPWKLQ4nR oPnopUZho6OsBnKIVtcC8qSf7kpCcRp/zuH9ofDoqfkY3Sd7ocgEEsF9PvxmbA0M5C8o 2BOXcqi45wPYDrIgjON+a3vU/6HZdwxmzyg8lARHwG5nCw0XDBhhV+kUxSOqSHct1zoT M4lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iljZMdmR; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90844-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90844-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s12-20020a056402520c00b0056382b02f44si4252645edd.37.2024.03.04.07.39.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:39:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90844-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iljZMdmR; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90844-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90844-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4BA771F278E8 for ; Mon, 4 Mar 2024 15:38:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAAA45025C; Mon, 4 Mar 2024 15:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="iljZMdmR" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 696824DA04; Mon, 4 Mar 2024 15:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566583; cv=none; b=pAkbKs+0kyiqtFWwsiEy8q03CkHpmJZlLA22Bp14GNdMzrfAYP+FvS0o6lAOgftE9+Ef3KxVDII3fNaf8vNJnEQFc1fufM+3sWsCUEKfy/JqG6O5YOL9WsuiMjEOmVd+wH1MDAHtxR2kaLUo67bmtkD7Yo5Ceg2vHyl3A45GqH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566583; c=relaxed/simple; bh=KoeKOC9BxNbULIOx5THehrA2LvyMrmoh0J2kqk1uxqk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eh04xL53d7l350a54k+4Qu9WRFavM/UIdJVxb/1XbUNf0aEXa1ytxwCdG5Fp1sn2NO6KHg5dlE/rR6TuxeARsAG36OZL+8TWo0kDI/bJZgK4KF/w15dxyayZKpoJvVVpPSfJfP0eZpYEuoXMST3uj+TFw0ngXKrqK8VCD024uo8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=iljZMdmR; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id E36641BF213; Mon, 4 Mar 2024 15:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jPqUbSf1Qdf1yloJtVBeCvPFg+XlI7QIXeQdbRho+l4=; b=iljZMdmRr0tNgzJK8i8VPTg8h7bHYkCzTSkGwJIhjCEjBBcw7oLlZonEqBI98qgCUaw+A6 ciopRah50UFE4MW1Dps+6X2It29g3ZyxL6hGFdXVoyHdIvsNFx1ZAkz1bqSey3SNIITiDU 2krSea/emSeDeavgElkWrdNOpPrGFCsl/2uk2OfRJOj7uUrzi8TOIGrP4QbEPduhgghnCS Y/Z/84Ytj45cR87v+fcOvdTTRITU/dtO6tk5Hw2yhC6MX9Y089sUv1KVeZqBTtTnqsqhWn l5bX8RVeVQi1vSyJ3ZS6zB4Ls1pUrXO4WVL95vKKyFlgFUfGaUltUsngq64U8A== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:48 +0100 Subject: [PATCH v4 05/18] mux: mmio: add resume support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-5-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610681689754711 X-GMAIL-MSGID: 1792610681689754711 From: Théo Lebrun No need to save something during the suspend stage, as the mux core has an internal cache to store the state of muxes. This cache is used by mux_chip_resume() to restore all muxes. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/mux/mmio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mux/mmio.c b/drivers/mux/mmio.c index 30a952c34365..00405abe3ce3 100644 --- a/drivers/mux/mmio.c +++ b/drivers/mux/mmio.c @@ -130,13 +130,25 @@ static int mux_mmio_probe(struct platform_device *pdev) mux_chip->ops = &mux_mmio_ops; + dev_set_drvdata(dev, mux_chip); + return devm_mux_chip_register(dev, mux_chip); } +static int mux_mmio_resume_noirq(struct device *dev) +{ + struct mux_chip *mux_chip = dev_get_drvdata(dev); + + return mux_chip_resume(mux_chip); +} + +static DEFINE_NOIRQ_DEV_PM_OPS(mux_mmio_pm_ops, NULL, mux_mmio_resume_noirq); + static struct platform_driver mux_mmio_driver = { .driver = { .name = "mmio-mux", .of_match_table = mux_mmio_dt_ids, + .pm = pm_sleep_ptr(&mux_mmio_pm_ops), }, .probe = mux_mmio_probe, }; From patchwork Mon Mar 4 15:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271679rwb; Mon, 4 Mar 2024 07:41:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUNtMmKmVWuP06/Mt2nIDPnj9Qq462LSioHAcoVDq+qn66tQaZX8Qjr2TH5ThCvkt3RAMgS5F7PbqiNidAd8Ejle+MusA== X-Google-Smtp-Source: AGHT+IGT8E2Xa1j/TOmgNsvnQlqj/p9p083xCSThFGECF9UbQ/SwNFoDsR24I1jz6nUZMIOPNKbT X-Received: by 2002:a05:6a20:9383:b0:1a0:d2b6:5f39 with SMTP id x3-20020a056a20938300b001a0d2b65f39mr12198892pzh.23.1709566882250; Mon, 04 Mar 2024 07:41:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566882; cv=pass; d=google.com; s=arc-20160816; b=XILRs4M+dJnii+grzL8Ex6PocqKwBsLVZy3Ibkviv/x9E2wibpfDEYPlj/FaXFfTQq JeTxbXtMEgYoZVJm5mM0f3YW49mvm0t9uYdx7j4mzVuYBs4FsxToBsM3J47jVBhL3uzs A/ZbbLO4mtQ8zht4S55MuiXovQyBlMrEXXi/q9nz7qbDyyMfOTNViSCHsxh74IGYog91 xTI63rTbsPHruIBn8ocYux2ZkkVgYW4PK9mykTj1QjhAHGXlObvrYLJgWkGCkFm20dE2 jfzt5TH4q5xVbqmBF9/9YQaciUY3lH3MgHbj60pUbrgw8xhlPuP46txS/9vgB65SUel6 Hc3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=9MU9XELe1rM5Qiqxbtkg8dW/yfnlPXWOR1yK6MM7gxg=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=WctqBcdpLejVs1x+Edaqvh9g7LhQnYkZs5Mz5BYqtX3gKSIhhz2NcEKjhhs+k9+2C6 cxTx7ldgCFpNBE+8ownmr1vX/5s6kx8WfyPpnvgzRq9lFgUHAQB6eXzSCJFgKv+cZvxt 7vOwgN+Kphgy+6zslNKzMc9ikuerKUDUqBqO9IlHrYbJIml64j6PfnLccHlvGxYosm+b 4hebOLqhYRfsb73qJ+D/gFPzwflQ7WIPxTKNPOalzDaBcwspAphGNg3ORGhSAjyoBQvb VSRPnSVGWGAVG6zoyOstbSkqoQ68Jex4RPb2i9uvTxM5EybxCc7SNH5NKaogzbiAv/Wd JcfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oXi19VKF; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90845-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90845-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k12-20020a633d0c000000b005dc42bb64aesi8488300pga.617.2024.03.04.07.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90845-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oXi19VKF; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90845-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90845-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AD4A528A9AE for ; Mon, 4 Mar 2024 15:38:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90340535D6; Mon, 4 Mar 2024 15:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oXi19VKF" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 37808487AE; Mon, 4 Mar 2024 15:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566584; cv=none; b=q5oJbsa5/pY7wKsJkwpbWgWDmQZHXuS4hEGCCcGlNxIxcdm8CalAVkj73Zfj8QTZGLkIQZu5c6znxq8teBRG0Vcrc0kEBgdmKqjbNNUF/xcHNEMJLpmttIF91r3QVVvjyDM/arL5SfcttQQ9T8K9i6MPE9q60xaCQS2tkcjppUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566584; c=relaxed/simple; bh=gDGwcPUlhrJ58tTxtAf4S10aFgybKlZmlLgO5JE33HE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aU8DvyJ8G9Tu5eP8h2/LTIispX6OWIcr/zs4YSY3QKnhhm+kRPt1rsZ0X3QkUeB4xjMTicjv+pqgii1BbeIWq4mjxgVg2xsQGAg46wXE5bzMYw+AFZQC06KxWEHQJzBCGZ5EguRbDQGAV2sRGFLk5UYLxTF6NxKyrH9r6hXIkCw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=oXi19VKF; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id D52811BF20E; Mon, 4 Mar 2024 15:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9MU9XELe1rM5Qiqxbtkg8dW/yfnlPXWOR1yK6MM7gxg=; b=oXi19VKF5yDJqVZZ865hfvPY/iEeC1bAFreQVtJL0SApnx/uRhJ7RNklpOZYjjEA+5BSQa 3wMtRucKkBiDFCiijlJfqBp2XS866d49WvtD3qtAiG6KHrIPXvP/UZmY/N5tzyfoKNfoH/ HSc40iBTcFg6kQ2ZDy8lhjdQvN3reu2FuzP+i6WwX6+Bn/UfDs7fRnO517BH8mYJyian3z oIrpuRLcM4kuBujFJLg4NSxZdOBQ+KSRFMnrGoIDwVc0s9WszTijFN06rVUfuPY1KJyDwt yFV2QBNrddPjzDWGEmIE/lofQj85aNE0vOeywP1KfaI0ABAPIcTUQTDwo66JWA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:49 +0100 Subject: [PATCH v4 06/18] phy: ti: phy-j721e-wiz: use dev_err_probe() instead of dev_err() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-6-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610802894458873 X-GMAIL-MSGID: 1792610802894458873 Use dev_err_probe() instead of dev_err() in wiz_clock_init() to simplify the code and standardize the error output. Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 46 +++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 00d7e6a6de03..5fea4df9404e 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1088,11 +1088,10 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) int i; clk = devm_clk_get(dev, "core_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref_clk clock not found\n"); + wiz->input_clks[WIZ_CORE_REFCLK] = clk; rate = clk_get_rate(clk); @@ -1122,11 +1121,10 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) if (wiz->data->pma_cmn_refclk1_int_mode) { clk = devm_clk_get(dev, "core_ref1_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "core_ref1_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref1_clk clock not found\n"); + wiz->input_clks[WIZ_CORE_REFCLK1] = clk; rate = clk_get_rate(clk); @@ -1137,11 +1135,10 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) } clk = devm_clk_get(dev, "ext_ref_clk"); - if (IS_ERR(clk)) { - dev_err(dev, "ext_ref_clk clock not found\n"); - ret = PTR_ERR(clk); - return ret; - } + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "ext_ref_clk clock not found\n"); + wiz->input_clks[WIZ_EXT_REFCLK] = clk; rate = clk_get_rate(clk); @@ -1157,8 +1154,9 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) case J721S2_WIZ_10G: ret = wiz_clock_register(wiz); if (ret) - dev_err(dev, "Failed to register wiz clocks\n"); - return ret; + return dev_err_probe(dev, ret, "Failed to register wiz clocks\n"); + + return 0; default: break; } @@ -1167,16 +1165,15 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) node_name = clk_mux_sel[i].node_name; clk_node = of_get_child_by_name(node, node_name); if (!clk_node) { - dev_err(dev, "Unable to get %s node\n", node_name); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_name); goto err; } ret = wiz_mux_of_clk_register(wiz, clk_node, wiz->mux_sel_field[i], clk_mux_sel[i].table); if (ret) { - dev_err(dev, "Failed to register %s clock\n", - node_name); + dev_err_probe(dev, ret, "Failed to register %s clock\n", + node_name); of_node_put(clk_node); goto err; } @@ -1188,16 +1185,15 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) node_name = clk_div_sel[i].node_name; clk_node = of_get_child_by_name(node, node_name); if (!clk_node) { - dev_err(dev, "Unable to get %s node\n", node_name); - ret = -EINVAL; + ret = dev_err_probe(dev, -EINVAL, "Unable to get %s node\n", node_name); goto err; } ret = wiz_div_clk_register(wiz, clk_node, wiz->div_sel_field[i], clk_div_sel[i].table); if (ret) { - dev_err(dev, "Failed to register %s clock\n", - node_name); + dev_err_probe(dev, ret, "Failed to register %s clock\n", + node_name); of_node_put(clk_node); goto err; } From patchwork Mon Mar 4 15:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp270910rwb; Mon, 4 Mar 2024 07:39:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWAdFmfkmKPcMnZ6lKWLobMoDi4uD8CN7y/GLfHYcJa3J3qH87yU0CW4EoKEGk3faE1R3JJL9qax7rsSZEA/gLuCQic/Q== X-Google-Smtp-Source: AGHT+IGastw5UU7vkI4+cERFJ4g6UKZbdg5g/cPbHSOobLAmfXBgEVRqAyH5h/0K/mQpiKurZVRa X-Received: by 2002:ac8:5c47:0:b0:42e:fa7c:28fd with SMTP id j7-20020ac85c47000000b0042efa7c28fdmr750654qtj.1.1709566754280; Mon, 04 Mar 2024 07:39:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566754; cv=pass; d=google.com; s=arc-20160816; b=jukINZgiRKgGOmfWMbxLvf3z7wdDPfFEYpuPSjlZEhCsIYZPoEh+LCWP4tXSwYhxQy QYlPiVSB5xmEyXkD1uIzhrBZbkFw2yo6ttaP7veccMNNKl/oo4yPlP6YtunLk1cDUvYd 6J+GSStP4UXi3cM+3v4Gr4ym/uPRwD+DIYDeTr0xhQ8odiAD1rxW/BzisALp8q1NpMO8 v2FH5HrZiGkaVR189KB36xKksprVeujR4CDZCwrYcJv/UklqppsyWugn07P5ODuqSAv3 A7gHhTYoCsxFGa6QJuqtSvvsfj0qUP0Iq92/3N/V0nJf1LXiMoy3Hlg85GAdfd1nDSPY /DDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=atrvTInBTa9ftnt4eeX7cpQDhxNmTdh+W88IDH8sTxw=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=NbQb+CczUiaHUx/doyiIINujyxIXRobMsn4iIpe3uJmpHOahAMSzh39tIgU6sjYl+j lbahieV9oA+uB5QMwo38Igk8hJj2lZRCVc2yOPoZXb0/1ig7SsK4sfu7qYmWSEDrdn3i LKPu7mdyOCgc4rJsJEKD9sBmEtBd3xf/JzJNE3EUTPnXGqDklXPyXRJgLN67Lq7kj/VE SF1wmLb2w12MZLOH7X5chPL1t3z6PoEs3TQnXKr6gSn+/lsqpcjsIudD3A4T/RRuPQIX 4cfZbxBN9jYGjumiEAnyntvYEsYgHdZp83K1Lk5lhUZTq6ZZiB9/MnlZMWhz5sTRdCOA DnPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X03KZaMn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90846-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90846-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h13-20020ac85e0d000000b0042aaa53f36dsi10183234qtx.573.2024.03.04.07.39.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:39:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90846-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X03KZaMn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90846-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90846-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 092C31C22092 for ; Mon, 4 Mar 2024 15:39:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 72F58548E8; Mon, 4 Mar 2024 15:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="X03KZaMn" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 E700650A60; Mon, 4 Mar 2024 15:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566586; cv=none; b=oh4WbThTEqiBwvb04J97Kwii2VvJcu2cK/I2CT/M9lqRG3nZanpdykVTfd/yIi24a5JLy8G90RozbA6xH8ubXfnTx3r2T8xM9D3NNSMlZ5xTdUwfHVmd+T63FW7KXxI2+/IyVy73figvJSm/QwRyxBYSgYXcfl61dFsasYj2sUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566586; c=relaxed/simple; bh=osgmdvXSJkfMV1DA1d133SaaMOhn/y5ZbIIEQNjoG3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qLzIdD2eyufh3/zY5S5cBLaIx4nLM2rdfaCGFYEljUDCLQy0rS9Z5bPmCOC33ZAeRaJDfuz1h27qKwxj/LRe2/8v18iaPjA8eTr6cPQDMoBG97A3g0azeEN4F2yTpxIO2f/DD3W1i1UUGOAA87vGiKoeCsSMMFFBjfU4ivDGla8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=X03KZaMn; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id B7D041BF20F; Mon, 4 Mar 2024 15:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=atrvTInBTa9ftnt4eeX7cpQDhxNmTdh+W88IDH8sTxw=; b=X03KZaMnWcCRGT68bktpQfrNroVp3VtpQkl5woOBUaf3UYJV1shpZHNcYvQYTA1JqhAmQ3 uHVpfl7dR/RzKXB90qOYy2fe1QyCoQVQNf8kL0Honv54htsH0aofSW34InidaoLQJisVB/ xSIEd/+t+dW5Dppc56fC+M4MR74fQMXaPVgXGAhpKIymZsbUpbAGhZP44IrOFIzslfnb8B r1y/7Rmsm9xqfTj7Ig5mobitM/gBV4MF1X2p3ERVOXTd4cmgLXuzwO73X8G6mIn50pI+RO noSKKK9vjPwnKJBsxo6ot75ctGaiKYBtWx85UVqvpQ++r3AQ6DvyMy5KQtGQ+A== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:50 +0100 Subject: [PATCH v4 07/18] phy: ti: phy-j721e-wiz: split wiz_clock_init() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-7-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610668701960787 X-GMAIL-MSGID: 1792610668701960787 The wiz_clock_init() function mixes probe and hardware configuration. Rename the wiz_clock_init() to wiz_clock_probe() and move the hardware configuration part in a new function named wiz_clock_init(). This hardware configuration sequence must be called during the resume stage of the driver. Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 67 ++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 5fea4df9404e..0e3cb1ed5a52 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1076,26 +1076,12 @@ static int wiz_clock_register(struct wiz *wiz) return ret; } -static int wiz_clock_init(struct wiz *wiz, struct device_node *node) +static void wiz_clock_init(struct wiz *wiz) { - const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; - struct device *dev = wiz->dev; - struct device_node *clk_node; - const char *node_name; unsigned long rate; - struct clk *clk; - int ret; - int i; - - clk = devm_clk_get(dev, "core_ref_clk"); - if (IS_ERR(clk)) - return dev_err_probe(dev, PTR_ERR(clk), - "core_ref_clk clock not found\n"); - wiz->input_clks[WIZ_CORE_REFCLK] = clk; - - rate = clk_get_rate(clk); - if (rate >= 100000000) + rate = clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK]); + if (rate >= REF_CLK_100MHZ) regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x1); else regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x3); @@ -1119,6 +1105,39 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) break; } + if (wiz->input_clks[WIZ_CORE_REFCLK1]) { + rate = clk_get_rate(wiz->input_clks[WIZ_CORE_REFCLK1]); + if (rate >= REF_CLK_100MHZ) + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); + else + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); + + } + + rate = clk_get_rate(wiz->input_clks[WIZ_EXT_REFCLK]); + if (rate >= REF_CLK_100MHZ) + regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); + else + regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); +} + +static int wiz_clock_probe(struct wiz *wiz, struct device_node *node) +{ + const struct wiz_clk_mux_sel *clk_mux_sel = wiz->clk_mux_sel; + struct device *dev = wiz->dev; + struct device_node *clk_node; + const char *node_name; + struct clk *clk; + int ret; + int i; + + clk = devm_clk_get(dev, "core_ref_clk"); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), + "core_ref_clk clock not found\n"); + + wiz->input_clks[WIZ_CORE_REFCLK] = clk; + if (wiz->data->pma_cmn_refclk1_int_mode) { clk = devm_clk_get(dev, "core_ref1_clk"); if (IS_ERR(clk)) @@ -1126,12 +1145,6 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) "core_ref1_clk clock not found\n"); wiz->input_clks[WIZ_CORE_REFCLK1] = clk; - - rate = clk_get_rate(clk); - if (rate >= 100000000) - regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); - else - regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); } clk = devm_clk_get(dev, "ext_ref_clk"); @@ -1141,11 +1154,7 @@ static int wiz_clock_init(struct wiz *wiz, struct device_node *node) wiz->input_clks[WIZ_EXT_REFCLK] = clk; - rate = clk_get_rate(clk); - if (rate >= 100000000) - regmap_field_write(wiz->pma_cmn_refclk_mode, 0x0); - else - regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); + wiz_clock_init(wiz); switch (wiz->type) { case AM64_WIZ_10G: @@ -1589,7 +1598,7 @@ static int wiz_probe(struct platform_device *pdev) goto err_get_sync; } - ret = wiz_clock_init(wiz, node); + ret = wiz_clock_probe(wiz, node); if (ret < 0) { dev_warn(dev, "Failed to initialize clocks\n"); goto err_get_sync; From patchwork Mon Mar 4 15:35:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271902rwb; Mon, 4 Mar 2024 07:41:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkSPEC/LJO6atL4oJVOYjWdY2uy9E5x0wiAuiTa0sCF1vSTV20gM/4khAdNoY1xZvnPhu6SeuZuNOgeY+awWOx9DMf2Q== X-Google-Smtp-Source: AGHT+IESJ/MW4PfjWP2jk2yB6NhhUxsSYfyueXhHNGRxAT3rnRkQ0Ha4TV/snji/vKwNXI8R7Tv2 X-Received: by 2002:a17:90b:3ccf:b0:299:3ebf:d180 with SMTP id qd15-20020a17090b3ccf00b002993ebfd180mr7431412pjb.6.1709566906133; Mon, 04 Mar 2024 07:41:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566906; cv=pass; d=google.com; s=arc-20160816; b=Nefn5S9TUcZrsxHVaxYkRVIbsmzHBkYspfgdWfHk/S3ntbOkaZ+Eg3baITnM4H0goO y67N8wCgYz65kc4Eb8KM38F2GRPFlzo5aVjZOTMi/DZwOugmVkUy53rTdVulQbcbsI/0 KsPh5Xs5SazZfX/rvzx84qDd4Qhnb/6N7gPmD3fzAwOXf70+i9YvJdTvoKXw7hEmfrTN yUpe8jGwYfiUpOvzO86ZSwYo9monCBX6QFIz7Zbi92g6tuicUiJ96Gik8A3wauh7AvuE Xn69eC/CrKV5YHUfbPrdncMd2XWivjCn9jcJDtLzqnqm0yq5/WD5NwjJ1d3VGRaus5wN OCuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=O2OqSyPPWtiaASZZ8fL+0nOgh8uzFroOQ4LwJV+N5EE=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=Gx3M3aB1hZL0WxTdcde2X3xf91XKGNJygGcb48i1NCwcxM3EHTOTPmLV3QHOjCq1KG oshGiGkNIsVXSS2an4Ht4wvQR75Hv4doPFQlzSErh7b0f/liJy0S4iigsfmfpz6LDXYv 2HstwlpJwfQS75/4BX0qhSzx5/T4IfIP4CVLu93w0nsEsD4I2qUxBFVv/O83VsbnQFPA d1dUHVxwfQlCIn+/nXBnkO/5XJZ3JQgKlpxY2Y1iAUvGW5zKHJorj7+JJxHz2aUTzAHW UN0Jfckq4DJ5cL7WjDth74OEFAACldReJgf8Qm7KXCw3v3SqBzU8lixFOOw2khQNZyZQ R9+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Upw1ehRr; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90847-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90847-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id nu11-20020a17090b1b0b00b0029b08d76286si8950793pjb.37.2024.03.04.07.41.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:41:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90847-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Upw1ehRr; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90847-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90847-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EA6E928AFE2 for ; Mon, 4 Mar 2024 15:39:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FAF254908; Mon, 4 Mar 2024 15:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Upw1ehRr" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 9B9B545BFD; Mon, 4 Mar 2024 15:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566587; cv=none; b=YDTmVXuntU+Pf1LKOBP0GQA61HhPLSyMuY9ilRv6zhMPv0+KY1Gxn+rcj7iwBMLxY4nBQAjx56IyxbAmXplucHA1CwVv+MiKOb6SzzUfna3kEzUShWSuWj/ZM/9JUijqRBwq94LZ4bZb3nqQF2gX0LPdEEQ2TyClTm1EaBt2fxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566587; c=relaxed/simple; bh=gNPojeRs7uaeynf3JtSmScZnTJITifyQp2nnjKqNJJs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dhoqaD5c6ZWaytjgMEkE7bR9EIHSGZvgWrhXaITStcBDCPHZE4tYSJY8mNUCMUyL9pAwVxVo2LWflvp50R1TTBNPSPxVm0Ar3yJ9O1FGU5IZbwl0O6P+cPAuyCRb/oPmoFkraJuMVabB4nB1RQ438UlBOxLPzpO69JFO6mlOlao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Upw1ehRr; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 948841BF214; Mon, 4 Mar 2024 15:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O2OqSyPPWtiaASZZ8fL+0nOgh8uzFroOQ4LwJV+N5EE=; b=Upw1ehRrYckmxR7s0sIaRde2rNTfRmIGymX3WOWIMcmwJn2tnZ5SJSZeFZzhVRZdPirmKr bni3uAVKVIw4fu7A1VZWffvCAqJQF060OqoWZNXHu/UiVrELnfqu195k/GHe8HsIAEZ3CC 7/ZYFec/AvlECjmYdwdzofKDYrpV20COkdQuetKUMQYw3lgKkROpYFIabNg8YvW38scIfM H04oJxv1HlhO9xpzMYEDGpylIN0kcTkZCvzKR3RcufYUsc69vIyKwhhn7KxCVNQND8IVrp 4izfZHh51RkXyhEVkG83Es2QoNVlTLtNZ9auBiCBaYRyFkJauy7nD1jV2SiOmA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:51 +0100 Subject: [PATCH v4 08/18] phy: ti: phy-j721e-wiz: add resume support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-8-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610828141074275 X-GMAIL-MSGID: 1792610828141074275 Add resume support. It has been tested on J7200 SR1.0 and SR2.0. Co-developed-by: Théo Lebrun Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/ti/phy-j721e-wiz.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c index 0e3cb1ed5a52..b2320f2efb72 100644 --- a/drivers/phy/ti/phy-j721e-wiz.c +++ b/drivers/phy/ti/phy-j721e-wiz.c @@ -1660,12 +1660,41 @@ static void wiz_remove(struct platform_device *pdev) pm_runtime_disable(dev); } +static int wiz_resume_noirq(struct device *dev) +{ + struct device_node *node = dev->of_node; + struct wiz *wiz = dev_get_drvdata(dev); + int ret; + + /* Enable supplemental Control override if available */ + if (wiz->sup_legacy_clk_override) + regmap_field_write(wiz->sup_legacy_clk_override, 1); + + wiz_clock_init(wiz); + + ret = wiz_init(wiz); + if (ret) { + dev_err(dev, "WIZ initialization failed\n"); + goto err_wiz_init; + } + + return 0; + +err_wiz_init: + wiz_clock_cleanup(wiz, node); + + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(wiz_pm_ops, NULL, wiz_resume_noirq); + static struct platform_driver wiz_driver = { .probe = wiz_probe, .remove_new = wiz_remove, .driver = { .name = "wiz", .of_match_table = wiz_id_table, + .pm = pm_sleep_ptr(&wiz_pm_ops), }, }; module_platform_driver(wiz_driver); From patchwork Mon Mar 4 15:35:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209600 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271024rwb; Mon, 4 Mar 2024 07:40:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVt8Mht9Zm+BI9ngm5XKFxa0yWJ5Wz4LKsyUUcBosMZ6v7lb0nWM8JWDKb4eoYNnL3Rv42tiGVvQIxU6fMIoblCJ9mAJQ== X-Google-Smtp-Source: AGHT+IGdgAkonMaHFkVV4S4RvvNoKHnJ57T7nvvh4lNCXQpt89qXfeU3LMCtHaTm3cjQYdY8iij9 X-Received: by 2002:ac2:51b3:0:b0:512:fd84:66ce with SMTP id f19-20020ac251b3000000b00512fd8466cemr5676728lfk.65.1709566803080; Mon, 04 Mar 2024 07:40:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566803; cv=pass; d=google.com; s=arc-20160816; b=BfUMGBd9+xj48JwrjHETdteeMnLTN0sAZI1W39OofsfS1+nVqNODwGQu0vl6Di+tDk 7QLqA+m21S2d94fJlNdMQa2E2lSmfKZZpfiqKEYAp/3F7cp9spXdjIRWPiEIrm8wiNrA o4kykKusqr/73QizZXwjaCRWqWZ4qyUouH0Ti4m3+7kbs/wTHroLzp4zcSMl/OG2jc/r XBJPVX/Y5oQ+iViQORy7aE9t96FRVuHXxdPOueoJ+ln/m7tbp53uzOIfZ6iD3RoKviZv CsqINp8Aass7ngDJadXgQld5D/VcROZxhDZAzlP/xTE0ZdGLZ7JvUbfzh+locwxsfUZu r6IQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=sztGcTF1zNnT//0yUibe2G7ihiKGeSnHpVbJVpHAUPU=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=mWzpM7vMaqZzf50JfrMBpT6bQhDUkT2Yj+Hzpu1ICWwyFe4Z8XoJ4DRVeEuemt+Vqp V6NLAo4HjGuU4px96HZO1wcZFrbWBssMh1q62aab0gGZHRD/NM7oTsaRkrpKii7yiRvQ lizb5WVopvsEzv/a9FLe7G2nkWw3Blw4mI+aJtt/CXZOUvhaic2euVHeYu0qYZWvTnGT oCGTuFeU74VtDXVAYyB06gqhhCTDgrgmCfgDHJM8fZRL2PXeCcPGFXNU7syavax4ftSi LY+F8yZach5jWPNCmpLSAVwC6gwaZD65/UXf7+98AV6vKYWN8zp+XOmlu2VH4ZzTn+Kl AspA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XhUhcsxz; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90848-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90848-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lg8-20020a170906f88800b00a453735c2b0si1084510ejb.872.2024.03.04.07.40.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90848-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XhUhcsxz; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90848-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90848-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D30CC1F241E5 for ; Mon, 4 Mar 2024 15:39:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DDDC54FAF; Mon, 4 Mar 2024 15:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XhUhcsxz" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 7FA95535D1; Mon, 4 Mar 2024 15:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566589; cv=none; b=MGUO5/Np5LjEscrvL3+Mlt4xR5rurzHFsSwW10e0h9YHJfCKN620Ht5JXcFMu8IAyD6Gv3tXRYFZV8Vcq76Z0h+kPmtfhIgY7HREfwWLhLTAm/ezvHisvkCGyVa6gPUUpscFyo+msOyIC281e+sk+toy3cu7cFmaxMWhCP5ijxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566589; c=relaxed/simple; bh=qXrncApu3ZH2u++c1fiMA0V7EGCJUkhdKcLX17WxyVY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E9ASO3ChamqT4DOzqEsZJd8sk18R+jMHHqvTNhQqFHikJBvotWR1v4jO0ZOKBTpJFj/sc+qPmBHD6BIuQOaojZ4JU7syFEmIJ8B4NbAARiT957yy3KyF1ol/VR6cdl2OqsRKV2VJluGtFHVfmEon6sGrRGfSchLCp1gpB2nnB6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XhUhcsxz; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 5B7AE1BF20A; Mon, 4 Mar 2024 15:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sztGcTF1zNnT//0yUibe2G7ihiKGeSnHpVbJVpHAUPU=; b=XhUhcsxz5kqKybZ+IslbKDjzFBEMPd3pYU8SMD9mtQJOmvIF2Oe4kdsywdRL7c0/txh+OT C1VUnu18E7+RX/0hxOvd7tTkBa5fsBOpPAXi/ur7w34iqzsnK/fYQVGEpnGEfZR6Xh2g3x 1BLQiJz2eAzdKGP4TtbpEI4+Z5mDW5CaCLRUnUWRkzIbXxVSgBAjgyLZ8tjrw43qgDXS4o gUwlLOag6tSHf56Nu8f4idZeMEIMCTTPD4dZLfpxJBI69kbqULvWheg6kkm/Q2GIVQj+ne XetoYoxbYZmJtYFW2zNH3eyDpy1+0efrvgWEgg4IqAcXoraaRAH+xl9xIACw2g== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:52 +0100 Subject: [PATCH v4 09/18] phy: cadence-torrent: extract calls to clk_get from cdns_torrent_clk Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-9-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610720082336020 X-GMAIL-MSGID: 1792610720082336020 Extract calls to clk_get from cdns_torrent_clk into a separate function. It needs to call cdns_torrent_clk at resume without looking up the clock. Co-developed-by: Théo Lebrun Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index a75c96385c57..803a76acf2fd 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2681,18 +2681,21 @@ static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) return 0; } +static int cdns_torrent_of_get_clk(struct cdns_torrent_phy *cdns_phy) +{ + cdns_phy->clk = devm_clk_get(cdns_phy->dev, "refclk"); + if (IS_ERR(cdns_phy->clk)) + return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk), + "phy ref clock not found\n"); + + return 0; +} + static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) { - struct device *dev = cdns_phy->dev; unsigned long ref_clk_rate; int ret; - cdns_phy->clk = devm_clk_get(dev, "refclk"); - if (IS_ERR(cdns_phy->clk)) { - dev_err(dev, "phy ref clock not found\n"); - return PTR_ERR(cdns_phy->clk); - } - ret = clk_prepare_enable(cdns_phy->clk); if (ret) { dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); @@ -2776,6 +2779,10 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) return ret; + ret = cdns_torrent_of_get_clk(cdns_phy); + if (ret) + goto clk_cleanup; + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); if (!already_configured) { From patchwork Mon Mar 4 15:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271037rwb; Mon, 4 Mar 2024 07:40:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTai6mFWPuW1a1k8qM3d29JHJOWyWnIh7Orz/jBYWznrGFS77CiV6LTFKBNwcc1YQ+ZljxnfHvnjfk+cDUn0T0xhOjgg== X-Google-Smtp-Source: AGHT+IECi6PwPgO0ZeMApJVD4Wnl4pEdBkuOkV+3gB1iG3Vl61ilJ5cQDy7egxGICtvIM/F+jNsy X-Received: by 2002:a05:620a:a18:b0:788:23f1:6d54 with SMTP id i24-20020a05620a0a1800b0078823f16d54mr4801668qka.25.1709566804379; Mon, 04 Mar 2024 07:40:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566804; cv=pass; d=google.com; s=arc-20160816; b=KBA1Dl8ut3vc+iFdGT2ExXuZl7tx6zNAyTZYDk21haDU5dAwpo30qpT+mJqVR64TwQ X6Wqs40LRs86mOqgAe9N2EqRlQg3VkcevzHLJmpc2I4OQb63BPrbXdbFRAHKtuwUJ0lr izvv00O0U6j/5hNHBWWWyhKD20LigFJ6scNuvFhvSUq5J1RIOgkeoVK85Tm2yr13s+0Z zf9x40Nqcg9IiXgfqvGYVUc3588skHBRU+RjNb2OCFo+zn9b8TQpjqXg4ywnsvKXq/HI tz663C0Sjper+zYp4mRk3IC6Na6ZxfIMXeeClsfWuQ4TGa/NW01SBHGJCxbzV+B1u+GX Folw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ZY4zwQDv37yWJBGtlc4HVZQiyWGnejxAqR+BxRsb2To=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=cM3wMCBfpXman7Xb9XgKkXi6k+TVtFgoufMOCq24rEnTz146qNa2n0FtltRRJdLdr0 hXD/evClio2RLlF9pkJ0+bjqwtbTF7XjgYb9Ed0Q/eafdilrLg1S6LgPGEi6bZd39xBT cjRLYDNq9HV9l9qW683+zyrojtrLyvNFjQXc1lPofcYnqvUtOelcw1qinNL3wryMJ/C1 m/uSb/bJb+cyuZ/kpW4fNXsbhITiXRNDsuH5Wx8g9/ITtH3SmS/kLITdShGD8ng5+t/k 1yqO6uuy4tX4hNw19j+gRPXj1Gylq4n0D4l94d0zH/3J8W2BG902/2FB6dLI8OQDfsqH m+ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Q+he/qon"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90849-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y16-20020a05620a0e1000b0078777310b0fsi9780406qkm.687.2024.03.04.07.40.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="Q+he/qon"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90849-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90849-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 36D751C2268D for ; Mon, 4 Mar 2024 15:40:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F6A2482CA; Mon, 4 Mar 2024 15:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Q+he/qon" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 52DE1548E5; Mon, 4 Mar 2024 15:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566591; cv=none; b=QfJ/J9F1gMUqS5hB5YxmP4Jir2MnzHTsDFIJIbWCetNNS4xKHQSwfM0JIDShkH1MKhZCwWYFvrHbsW/36U5uJNed6mL3jg52ndaT57KBM/BCJREj0xo3RGf2cW90Twu7EpmOqc3PmwMGxZ5VmJ1ggXDQrrZuEG3ZW8FOEh3xLos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566591; c=relaxed/simple; bh=58Rx/Fpi5lkN1ZhQHKIMYHT21sc+k4stqHUV7CqcV3I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XCbjKiPjEz95oTntah9431QcLtbZx1Gp7nm9iEmGOGh9kc0FegDwTJI08Vvff9gI+QckuN4uW2A5VJ+tOwZN1sRoiIAEFy5mwSQidMnWjSFIg6irClhcC9MOAC9iGEnDV71mzUls2x3yd6grJ8KzdXjBGiwu1iUnDjghg9ulJVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Q+he/qon; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 203261BF20E; Mon, 4 Mar 2024 15:36:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566587; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZY4zwQDv37yWJBGtlc4HVZQiyWGnejxAqR+BxRsb2To=; b=Q+he/qonM7ce+3DcO7pg2cLmmB2q17k26lCCSFkwtjGa5ylJuU59mevM2Qvtcb8PVuFEHy Q1sTqNqifckyCGoQuPW1izOlHIMCR4bbcsOOv/NcRFU3eM7iS8eMFBNC14VMGrfxr4R9n/ ZvchPop/U9fSn4YT3Gr6Ebjj22hiRGuGiuq90/oQ8NZXHdM1Ul17kDCjfyR6UWJtqBLmrs rtZp6uR83vPpeH5ZqPf+eDnjPPMPt2EDVQd7ZhVlProjbqimFEnUX64LZ8Q/KKk6YmALdy 6AARmY9OozTj8oklubGUHFRfiibRXsDrBr9hUDQaQ+CZtHolyXzZ3q0TMMJTmg== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:53 +0100 Subject: [PATCH v4 10/18] phy: cadence-torrent: register resets even if the phy is already configured Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-10-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610721186895231 X-GMAIL-MSGID: 1792610721186895231 Resets are needed during suspend and resume stages. So they shall be registered during the probe even the phy is already initialized. The function cdns_torrent_reset is renamed cdns_torrent_of_get_reset() to make it clear. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 803a76acf2fd..bba10ca0bfdd 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -2660,7 +2660,7 @@ static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) return 0; } -static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) +static int cdns_torrent_of_get_reset(struct cdns_torrent_phy *cdns_phy) { struct device *dev = cdns_phy->dev; @@ -2779,6 +2779,10 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) return ret; + ret = cdns_torrent_of_get_reset(cdns_phy); + if (ret) + goto clk_cleanup; + ret = cdns_torrent_of_get_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2786,10 +2790,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); if (!already_configured) { - ret = cdns_torrent_reset(cdns_phy); - if (ret) - goto clk_cleanup; - ret = cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; From patchwork Mon Mar 4 15:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp272221rwb; Mon, 4 Mar 2024 07:42:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV1lsbv9VBg+oxIxx8lwiotbdT9XxomRAiGYLRxIwX4HzG9+aevndS5BRsauxEuKJ7CZbo5hybxCnuniuP8s5XrDbpD3A== X-Google-Smtp-Source: AGHT+IH+fQh2CqDof5d1M8buSTYWTcbi5n1/ZtHrIjlOAWVovCqm1YHD10rmENkHy27DihnoHtVN X-Received: by 2002:a17:903:1111:b0:1dc:d73e:a202 with SMTP id n17-20020a170903111100b001dcd73ea202mr11131748plh.59.1709566944495; Mon, 04 Mar 2024 07:42:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566944; cv=pass; d=google.com; s=arc-20160816; b=HISZ28OFAd0/0c4GakoawNWoehXYrKRlbO81KpcGLfb9iDvgJZlYA960Ku4tVug4K7 NTdZpBIpJWh6CJ6RF7Erg47/DW9rbWzuAMJwaGZuOez4u7JzGp7OzCHf39iMp6Z/jvBv I1DTFv5Fd35tsjd8vBA1rXsf5P/sWz5HcbWSpSnpew9G2/3kyvbJtULqnTOXWd9xXTi4 ddrV79P9kkF8ugi0ciyeMOoKG/oWgeaVg/TNAP0835rgDbm/baEK5r66oDIigZmjHk+h AQ5S4u4T3J9Md2/Ct9G0aHVTN2BRgDlVpMFiKl9XHfKfsWMfHgCV3AHvZd47EWTks0wi HCXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=pYylQruqGYeQlChK9yp+O0x5NERS4bDbicxfArQ0TLI=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=W/b271ZM5gqNBPZ/lsC62BRPnGT4zvpVRLPqd/YW1CMbBddm/Ok5PQub/SFKIf3zj3 T0guVG2YTxNhibR7rft4dQdxRNsYTn4YdM3y65V80//USn3JiP404AW06v/h+GvlWxE/ iQP5+EMfkBisLRNXSuwU8L1EjSev/e5TKXEsnwjJx8bRDWVeK4a4eVrd/4j6pjFfS1Uj 6IPEr7gTL0dN3PY0MH/hOnZPfyBz0mGMe+OfQRihpIeh7aelK7bDE8XfYF1S+1dAmcm8 S5KqVIG2r7nLoUNnr2BFxUtQKJAvhu3M3ZZbJie3TiVqa6b2vILloPdDcqZ6PXU2k8V2 squg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=E2zbC+yq; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90850-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90850-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p16-20020a1709027ed000b001dcb3207229si8144220plb.209.2024.03.04.07.42.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:42:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90850-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=E2zbC+yq; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90850-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90850-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A6FE282481 for ; Mon, 4 Mar 2024 15:40:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C21056774; Mon, 4 Mar 2024 15:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="E2zbC+yq" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 E8D2C54911; Mon, 4 Mar 2024 15:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566593; cv=none; b=OnwsOQxubE/E9khrzSLiIRbB3NBWflLaiTyBO26S8qM4OQr8/BR16xTz2JefW39qaxJP70lYIsdtXtYTlV01mKSvqeM0nwxeRoCcU3ZqbYYNp/tIm8HMXB59X5Qlpp5Q9+V/ot1kXtyqS74LZuUK5BCxiRtNS8EVLhWimk1PKcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566593; c=relaxed/simple; bh=UqAZwTrAzmCyHsH2izjqH7bw1MyDaTQpcy6c25J6btU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NsAuITHXzhwykt1FfVCxz341a98kEFYHMPK/CzMfJO2ZyeF4Rmb4xrY1KlAz2sF1zFBc1xYsPUnsFEl4E8+XnHbLlK68RDSJqh5HK7jxGocCnYmmghTboHidmse6GjeEYA5/swL2Nz84zE+6y8vDtehhoJ6F6Zi/iFWlLx+qY4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=E2zbC+yq; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id DAED21BF208; Mon, 4 Mar 2024 15:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pYylQruqGYeQlChK9yp+O0x5NERS4bDbicxfArQ0TLI=; b=E2zbC+yqxH66Y+sgHXfmfZEJlUauI8MAjGg9gvo0YqhU6jEQo1+fykcbR8/rbe4Lr/hjFE PUGrU1vAad8WxrR9izlR1IeliCl8pryvt4qPkzsN1H0/FiNyHRkYcraJZ+6ncS3t2TBVVm AsFvm4Hz7lWgW5QzixDELPAzH1bdPznet9aVsRqJSnCkK5PmZIA5HRELvwyHzutgvaQTBK Ons2kyGwWN46QFCL2/6v3b+qLJV+9XAQZPaK7pXizi5B01ponQ6XafIVVxyd+ML2qNJkNV 4V3y3YAh504XdzggzA+J7bId67/5dVy0gmn0DfvK/bDkij1GT6YwUlEGTL/QcQ== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:54 +0100 Subject: [PATCH v4 11/18] phy: cadence-torrent: add already_configured to struct cdns_torrent_phy Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-11-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610868338259025 X-GMAIL-MSGID: 1792610868338259025 Add already_configured to struct cdns_torrent_phy, so it can be used at differents stages. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index bba10ca0bfdd..b35fbc8a60e5 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -358,6 +358,7 @@ struct cdns_torrent_phy { enum cdns_torrent_ref_clk ref_clk_rate; struct cdns_torrent_inst phys[MAX_NUM_LANES]; int nsubnodes; + int already_configured; const struct cdns_torrent_data *init_data; struct regmap *regmap_common_cdb; struct regmap *regmap_phy_pcs_common_cdb; @@ -2740,7 +2741,6 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) struct device_node *child; int ret, subnodes, node = 0, i; u32 total_num_lanes = 0; - int already_configured; u8 init_dp_regmap = 0; u32 phy_type; @@ -2787,9 +2787,9 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) if (ret) goto clk_cleanup; - regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); + regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &cdns_phy->already_configured); - if (!already_configured) { + if (!cdns_phy->already_configured) { ret = cdns_torrent_clk(cdns_phy); if (ret) goto clk_cleanup; @@ -2869,7 +2869,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); - if (!already_configured) + if (!cdns_phy->already_configured) gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); else gphy = devm_phy_create(dev, child, &noop_ops); @@ -2955,7 +2955,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) goto put_lnk_rst; } - if (cdns_phy->nsubnodes > 1 && !already_configured) { + if (cdns_phy->nsubnodes > 1 && !cdns_phy->already_configured) { ret = cdns_torrent_phy_configure_multilink(cdns_phy); if (ret) goto put_lnk_rst; From patchwork Mon Mar 4 15:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271303rwb; Mon, 4 Mar 2024 07:40:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXayhd1JjwkyEYRU72KG2iUMRDW8kqR3g1UmWGrW7t6tsWhKlfV4WDg/bsGM48RbRsgUx6wIILK6qlCVndLkah/oKk1Q== X-Google-Smtp-Source: AGHT+IFIpK65lNlkzKGsNrfsAd16bkIalYo470BY+LXnF7SDelaeVQhhVTSfe7/t84ghLy3VNPzF X-Received: by 2002:a17:906:aa0f:b0:a45:5313:bfb3 with SMTP id ko15-20020a170906aa0f00b00a455313bfb3mr1697598ejb.40.1709566838562; Mon, 04 Mar 2024 07:40:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566838; cv=pass; d=google.com; s=arc-20160816; b=wEnSrisau4pWDs7NW0GBy4ELHlpYisHa8TXkRsUQrotQyYDTRGpJ3PGt4RBTufTsxp e17C5nY26AeceHW6KbvdT8DCc4hRxldAgpkZXIU6p/MsBZxAH6MNRpPo/+JeRiseD7zb h20kLSecGWItjn525RsI2ie1o2C03bUAdosfRjXqymQyAMjbT9EnbNCMl1Q9V6VhcHm+ aLwxhK2zPxpQP45Kxx7zOfq7o11XTTt2YCKaXgwlCZmos76gbikGo8Zk8jOG0Bwqix7+ vIr7o7zglt/xWkUDjKLhEdrRXApicAF5eYeCqyV2wD2pC8Db5dTPCBDWj3CS4sDHV4tD 5Acw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=Kd9Oz4mdVW+hDLej27Xfdp5hp9Tma/hgJ2XUMzL0uAo=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=pbtTNcpYepG0Qkm36br6L0KeTVNugaLWjS4O69EuDBYXV793ztid5cMBqRGJiBRQMn gO1fBgf5RV0ZxW6QtaDCHpGAR0SMHG2fRTJwKgb/1ugfx9e1rfHLaNS++Quc6xUHk4lD 9m83XTIShQDUHGBhf0Dx/1FbkNisv6+GlFq6K660Ob+g/nJey+6De22Pb2n8RxvwL80y acSps8+juN6z1J0sZanwyPxfzDVaK7QHnftot4KXiJtfdglwbwFNPgfUUnyi8Ilc8d9I 4dUYMHQ33kqLSeJwUw0kbjGtiYLmxzLIp8yQG+KMZxHa+Xlj12htSfvWGE5acNChb6GW rXmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L4Zzf4vI; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90851-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90851-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hv10-20020a17090760ca00b00a446b381830si3395429ejc.946.2024.03.04.07.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90851-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=L4Zzf4vI; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90851-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90851-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 39FB71F21BCC for ; Mon, 4 Mar 2024 15:40:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29ED957878; Mon, 4 Mar 2024 15:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="L4Zzf4vI" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 D96DA55784; Mon, 4 Mar 2024 15:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566595; cv=none; b=k9I+Ggp4NenmG2Ry47As05tskkecmZadrFsbW0Td2dco/qWbtCKMwv8wdyfHjQzVTpabXBDVyJtJ72+wsE67FQGkF14xVPtI6o8ALIkGUdRY9ak5FGk8ZbV+xrOx5NneHyQpQBABc2B8Cnbgx2YcSlk31DJKCISe0BNHGmDUjRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566595; c=relaxed/simple; bh=vN8vnshRL6hQY9u+MN7pyGYmpKbakAsxcQa8lsNHH2w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uImqF/Zsrc7VCorQtEDcWdpi9cb0WCc3vsNlarggB4vXscYszF4KUydeGthzTPoEjiKLA9PdHU38Ii3mYG4x5FDWg4tV7mO5+TblYxu3OFdrk5fxkrsyJI/bPVIjtK3uP24SVbjIUPjOEAY5rMkMX93+1gNqTYvafEIdfQN8T78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=L4Zzf4vI; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id AE0981BF204; Mon, 4 Mar 2024 15:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566591; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kd9Oz4mdVW+hDLej27Xfdp5hp9Tma/hgJ2XUMzL0uAo=; b=L4Zzf4vINewbTLzOek8ywqdNRQTcMGgT1T78dNAvJ08wb1UOFzcnMRT3lboAucDV4zWxff oWdtgYF2g/GzqrBm6YyEvtxZPTrHS0tIu23sU2VVrTFodL4CqJ/EFZHB8IPYKivor/38SN L53+UVOCAES0QA6BpVlBCh5Owts47tgyrirQdAnyGLy77S+P889nWs1HjxeIMVNMzm7rcM TZLXnZbK3nZVFX4wq2etkQUWrpDV7k7d2BXMnjZxW4AH/gb+tJIB1BCNn7F0dvIk2mv3zP yNGljErCqNGOPns14qcLeQ8hLYQSFUUKJAGEsF5fe4L7Nl6XTNm2FmFUrLQs3w== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:55 +0100 Subject: [PATCH v4 12/18] phy: cadence-torrent: remove noop_ops phy operations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-12-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610757234435170 X-GMAIL-MSGID: 1792610757234435170 Even if a PHY is already configured, the PHY operations are needed during resume stage, as the PHY is in reset state. The noop_ops PHY operations is removed to always have PHY operations. The already_configured flag is checked at the begening of init, configure and poweron operations to keep the already_configured behaviour. Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index b35fbc8a60e5..52cadca4c07b 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -1593,6 +1593,9 @@ static int cdns_torrent_dp_configure(struct phy *phy, struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); int ret; + if (cdns_phy->already_configured) + return 0; + ret = cdns_torrent_dp_verify_config(inst, &opts->dp); if (ret) { dev_err(&phy->dev, "invalid params for phy configure\n"); @@ -1628,6 +1631,12 @@ static int cdns_torrent_phy_on(struct phy *phy) u32 read_val; int ret; + if (cdns_phy->already_configured) { + /* Give 5ms to 10ms delay for the PIPE clock to be stable */ + usleep_range(5000, 10000); + return 0; + } + if (cdns_phy->nsubnodes == 1) { /* Take the PHY lane group out of reset */ reset_control_deassert(inst->lnk_rst); @@ -2306,6 +2315,9 @@ static int cdns_torrent_phy_init(struct phy *phy) u32 num_regs; int i, j; + if (cdns_phy->already_configured) + return 0; + if (cdns_phy->nsubnodes > 1) { if (phy_type == TYPE_DP) return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy); @@ -2443,19 +2455,6 @@ static const struct phy_ops cdns_torrent_phy_ops = { .owner = THIS_MODULE, }; -static int cdns_torrent_noop_phy_on(struct phy *phy) -{ - /* Give 5ms to 10ms delay for the PIPE clock to be stable */ - usleep_range(5000, 10000); - - return 0; -} - -static const struct phy_ops noop_ops = { - .power_on = cdns_torrent_noop_phy_on, - .owner = THIS_MODULE, -}; - static int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) { @@ -2869,10 +2868,7 @@ static int cdns_torrent_phy_probe(struct platform_device *pdev) of_property_read_u32(child, "cdns,ssc-mode", &cdns_phy->phys[node].ssc_mode); - if (!cdns_phy->already_configured) - gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); - else - gphy = devm_phy_create(dev, child, &noop_ops); + gphy = devm_phy_create(dev, child, &cdns_torrent_phy_ops); if (IS_ERR(gphy)) { ret = PTR_ERR(gphy); goto put_child; From patchwork Mon Mar 4 15:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271489rwb; Mon, 4 Mar 2024 07:40:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXGIK1erskLp/l74k0ZV5Tx2jLNeq6cCybunRZdM2YNITm6fL7hBUVfz/Yl2o+UfxNeLFlSh0oE2onoMW51h/60YRW51w== X-Google-Smtp-Source: AGHT+IEWsMkVhjqzjAnXtEitd5UAhT37hVLABRcfCv04cWKc3clWLA7fFS90MdeSpUlC+pQ977un X-Received: by 2002:a0c:fb12:0:b0:690:551c:1a9 with SMTP id c18-20020a0cfb12000000b00690551c01a9mr16298832qvp.10.1709566859633; Mon, 04 Mar 2024 07:40:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566859; cv=pass; d=google.com; s=arc-20160816; b=KQDW9SR+ODp32rcsFsm+Sd8d6mV0SCQI0viop6ERIey4aiuoQB8WliuiHiWgb5/jed kqMWVSVVOWiTPz3CNm0sTuSE4Et/lIyfF+KcphENNvnS3ORRIfWLOxdKzW1vX0PfWFvi jJWL9BkkefDJzp86pXHscv3zzqTYyTbIUE0QyT5431+g8u65m43iD55EBa5rf3dzi5el 8k/2yr7uxDcXUb9kWxapuvELp6H9Rn3exGOwCnkAX9n7lksEh5MunFd79WEfGWoCKjAZ ERm9jGKBFz0i+EKDhTVUvzFmvXfULEm77AkHoAoDWuXhZJO60tccoxMmKOcusqQrKzzS PVBg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=UcbAmu4dmEBPFqimSZPh3yEPPq1ape6wFi34dJc4ne4=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=h+HTA1EW911NtgsL9QPtLz7TtkTTHBLOm++7H9pvoUewymrYzAJFyJnjr1gd7oVzKC gMC0svI8ghH3SMrwVoLH3orcd3y5ZiYwmGhBc9FcVDu6RVkwTuSEJLqNL2kT4L3cbjGA amqNmuI2yXH9IO8/TbK5VM/+iOzp/x4zdLbcUaX/q40dD79SOI3ZDOGIA234V7Oxsja+ Cj5T7gor1hmOzsf7uc/eVC9sGzEg4r5Zdx3orWAdJ3WdgbUNxfyOAYqC82vOUdff180N LjKwJy7FdfQok1BdhXzzEcwWj4Xw2aBepsrMiP8svHCyDr4re4WBsV8V8EhRVhAnt5EL xYAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OYOTK8bo; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90852-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90852-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i7-20020ad45c67000000b0068fd0486f10si10104151qvh.51.2024.03.04.07.40.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90852-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=OYOTK8bo; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90852-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90852-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2ED361C2343D for ; Mon, 4 Mar 2024 15:40:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3433258201; Mon, 4 Mar 2024 15:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OYOTK8bo" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 F1C1754916; Mon, 4 Mar 2024 15:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566597; cv=none; b=J1lXi+y0DQNDRmkNNstz+VZSxR/SEPM7WtWPE+Vi83aHetxLApjRmWatHqZLMWgwGvIjzz8l/0IqGvuQS4WcckHvwV+hiDA+SSJT3ILBLBOaOmOVGhslumfbARPbv4m47TYweu3KIMX77HT/JDZXqvSEkTc1JDx+cEWre/6cgG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566597; c=relaxed/simple; bh=QGCbotRiQdOgnWzi1oFs9U8XPApR4DcBOUsWj+1+Pgk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aqpt4/3sldsh3zhWx+tGDaqFWF7hFhBOmx8B4qS2v3LGAE8zF7z3JWqI6n7WKNxGZW3WaO5lYk6zFWciyij97mnpCMlAYmilMRzC93966O0OnuHR5kZlH1FjEmlj1ZUe2p6gGlkDsOov1b3U6ouX4af+Yysv1UI0tk8CJHK1wRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OYOTK8bo; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 865931BF216; Mon, 4 Mar 2024 15:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UcbAmu4dmEBPFqimSZPh3yEPPq1ape6wFi34dJc4ne4=; b=OYOTK8boA3wSOeBGMzlrYVBUR9aW9TAdg4WSIxbjoRSEvtuaNf3OVnimXwUEVR2m+g+60V g48l7l/BeSQJd00hnTI9Bs9ZDP/SG2wWhAoeAxaXAi59KsD12vbclhui7/fCyrRa6Y0rSa u6obxZ0hZdmtn3WwNDZf1yVpNeiVfb7cZgt3RdiDcecGrVHuOZU0sFhVqaLEhQjQh5btSb om/h4Qf7eG/OWOyb/yaJ7x9bnkMQU7gDfBtHJ0y9+t4v1vnJ+eSPUQzjF0wM7dYcotnzF+ +iawwIgWi9DzikK9K8x1kcZkn9Q1DTGLrDS0ozAV1x71MwuDcquxfbIq9Dy6lA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:56 +0100 Subject: [PATCH v4 13/18] phy: cadence-torrent: add suspend and resume support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-13-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610779455966793 X-GMAIL-MSGID: 1792610779455966793 Add suspend and resume support. The already_configured flag is cleared during the suspend stage to force the PHY initialization during the resume stage. Co-developed-by: Théo Lebrun Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/phy/cadence/phy-cadence-torrent.c | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c index 52cadca4c07b..b4245c088760 100644 --- a/drivers/phy/cadence/phy-cadence-torrent.c +++ b/drivers/phy/cadence/phy-cadence-torrent.c @@ -3005,6 +3005,58 @@ static void cdns_torrent_phy_remove(struct platform_device *pdev) cdns_torrent_clk_cleanup(cdns_phy); } +static int cdns_torrent_phy_suspend_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int i; + + reset_control_assert(cdns_phy->phy_rst); + reset_control_assert(cdns_phy->apb_rst); + for (i = 0; i < cdns_phy->nsubnodes; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + + if (cdns_phy->already_configured) + cdns_phy->already_configured = 0; + else + clk_disable_unprepare(cdns_phy->clk); + + return 0; +} + +static int cdns_torrent_phy_resume_noirq(struct device *dev) +{ + struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(dev); + int node = cdns_phy->nsubnodes; + int ret, i; + + ret = cdns_torrent_clk(cdns_phy); + if (ret) + return ret; + + /* Enable APB */ + reset_control_deassert(cdns_phy->apb_rst); + + if (cdns_phy->nsubnodes > 1) { + ret = cdns_torrent_phy_configure_multilink(cdns_phy); + if (ret) + goto put_lnk_rst; + } + + return 0; + +put_lnk_rst: + for (i = 0; i < node; i++) + reset_control_assert(cdns_phy->phys[i].lnk_rst); + reset_control_assert(cdns_phy->apb_rst); + clk_disable_unprepare(cdns_phy->clk); + + return ret; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(cdns_torrent_phy_pm_ops, + cdns_torrent_phy_suspend_noirq, + cdns_torrent_phy_resume_noirq); + /* USB and DP link configuration */ static struct cdns_reg_pairs usb_dp_link_cmn_regs[] = { {0x0002, PHY_PLL_CFG}, @@ -4576,6 +4628,7 @@ static struct platform_driver cdns_torrent_phy_driver = { .driver = { .name = "cdns-torrent-phy", .of_match_table = cdns_torrent_phy_of_match, + .pm = pm_sleep_ptr(&cdns_torrent_phy_pm_ops), } }; module_platform_driver(cdns_torrent_phy_driver); From patchwork Mon Mar 4 15:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp272590rwb; Mon, 4 Mar 2024 07:43:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLB+bJW8B/A0kelDjPudUwJMJrnQ/jvwpp5lQAXqSPJN4X8CRjgoD7nx/+pmy9q92hswKyV1d2KuETwlznJbq+nq7V6A== X-Google-Smtp-Source: AGHT+IENgAp2YYBSBf06njDsDg934BpMNiSRAhhUIzNn6uQxCyW9BbztHgLlzWeLW1yl7g3VAYar X-Received: by 2002:a05:6a00:1248:b0:6e5:2f97:bf43 with SMTP id u8-20020a056a00124800b006e52f97bf43mr8689955pfi.27.1709566986790; Mon, 04 Mar 2024 07:43:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566986; cv=pass; d=google.com; s=arc-20160816; b=UWCrt7HyXZAozmaY/sXG0FoM/kM8xqbC8N8em27e/4Mb+BZ4YffOtpKoAin95MBvb2 NZx2Kexc1S8kptIj7nTHjyDk8/JnWo5BGPXLvBniD4vpGvmEMNU3i8+vy3lDpKvhJCQO u6a1sW/G9MdTiH9g9swKkXbF/LiLHvVNYUEtq3NisTWz7I3JuWzrXdK6eO1/7Q0+FoJN 7NQt7NZ9HhhROhZfWMwHGsTZR23dEC9En3ovnloAVVgUH9DCbdf4gBKVl/DemtyjCjFj 4/cgL20l2LmMc88bNZaLluj3/U6f2B73Zi5bR4/lxm+wfYfZ3Tjk+vfWIF6sq+0WKUgk zHBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=DaC56o2wBLHPxa2Ttp6Fja2dcIvmi8wc4P6dTqN62vk=; fh=16AwIsfnaBgs0S7h9TVOhyQqQjjaKNV4ZtY0tk57H5k=; b=G6jAVGXDTF6xIOobvZD1ucztbDEj99HeGy3QVHEKRrXHts8x8XQE0EmsTkN8sUlewj 7LayF5wdrPRhKk7bmQiftftbG3slvU+b+z2izjuapWPrH400bv7mJjSFO0A0fUB6SmNF WfYVWbSr1wYbPH9p2yPS56xxeFcLCIR8Rmhl2iNCgWD1HFwSUoKIs7iKSj7sN4SOqZwi 5zvXsJi8E+9bbhAMZ8T8C/v1q6Vl2TJC0q8N5xQFLyjRUlxwnfyKYqSdnvVDCfqO6iKr YwODYaiTlzW8toRyM5lVG+3y/vYWs0lHcvp2kkY/D0GLhIma9liPycrPWrUutmUuiVCY AzFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DYGTkPWE; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u20-20020a62d454000000b006e531ba990bsi8308845pfl.326.2024.03.04.07.43.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:43:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DYGTkPWE; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90853-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 826F52808BE for ; Mon, 4 Mar 2024 15:41:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5232E59171; Mon, 4 Mar 2024 15:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DYGTkPWE" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 0320E56B98; Mon, 4 Mar 2024 15:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566599; cv=none; b=keAR3yNcssE+WO6XKCClRP2Kj+XFHTGuqmPS6ljWtWAa6zc5brmsAPuWIcU/e4Aom5ue5+OvSmU4XxZQBU7cStbGYFPprk1F23T5+/xSDa/e797UoDh8yTOyk6RCPiQ0SjslVi/GucINBsm4Z56BF6pEoWEhhrnzTOFzP6uCK3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566599; c=relaxed/simple; bh=PuFPfR2lIZ+bkqMkJWaCoXVb8zQMzKhIXQuBGxgZ6Mw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DfwmF6mb913x9uh55jn+GJiZv8Dxyd7RGsW9Iop238NKNm4z0xbp0OiHmJOrTc3Kcm2DxhxEqDUkjHJmmHdyxv42BoELvWL1BKL+XCnPW3DJn+0emUdMszrkTUMI/3yit05jgdUqYTMUhVt1CIqOKlbOJpM36C+FlYg4oesn0hA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DYGTkPWE; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 771F61BF20B; Mon, 4 Mar 2024 15:36:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566595; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DaC56o2wBLHPxa2Ttp6Fja2dcIvmi8wc4P6dTqN62vk=; b=DYGTkPWEslLKG8HWGpJ11wN+i6/cmO4SQCQb8RAV5EJtc4xXnvBDg6XQ/AXZOu2gFCUsAG 2+t6wdveq+JnF/wbiAGysqVcbo4f5C9KpKqmamF7ZOEBhmiCTDHKT7ZHqlNSyc1gzZFl8J PU2u1fQ4dS6Fy6Lt3hhCCEJcMKNNrgp1PX53fvt/ufDHll2jicK16x89I2iVdXlIF/7fXB hTMI3Ggc4WoGOgLD3mrg+4KXl7r+jExKUw99Tbha9BIGIwc40Yz2vAHgF66nE0bOeLL2mz HS8lsbqZgkSVRWLF+kzb+jeVF54C6wzLxx+XEz/VVc9KzUZqddt0Ley+aYbBDA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:57 +0100 Subject: [PATCH v4 14/18] PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-14-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Siddharth Vadapalli X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610913164267946 X-GMAIL-MSGID: 1792610913164267946 The function cdns_pcie_host_setup() mixes probe structure and link setup. The link setup must be done during the resume sequence. So extract it from cdns_pcie_host_setup() and create a dedicated function. Reviewed-by: Siddharth Vadapalli Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pcie-cadence-host.c | 39 ++++++++++++++-------- drivers/pci/controller/cadence/pcie-cadence.h | 6 ++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 5b14f7ee3c79..93d9922730af 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -497,6 +497,30 @@ static int cdns_pcie_host_init(struct device *dev, return cdns_pcie_host_init_address_translation(rc); } +int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc) +{ + struct cdns_pcie *pcie = &rc->pcie; + struct device *dev = rc->pcie.dev; + int ret; + + if (rc->quirk_detect_quiet_flag) + cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); + + cdns_pcie_host_enable_ptm_response(pcie); + + ret = cdns_pcie_start_link(pcie); + if (ret) { + dev_err(dev, "Failed to start link\n"); + return ret; + } + + ret = cdns_pcie_host_start_link(rc); + if (ret) + dev_dbg(dev, "PCIe link never came up\n"); + + return 0; +} + int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { struct device *dev = rc->pcie.dev; @@ -533,20 +557,9 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) return PTR_ERR(rc->cfg_base); rc->cfg_res = res; - if (rc->quirk_detect_quiet_flag) - cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); - - cdns_pcie_host_enable_ptm_response(pcie); - - ret = cdns_pcie_start_link(pcie); - if (ret) { - dev_err(dev, "Failed to start link\n"); - return ret; - } - - ret = cdns_pcie_host_start_link(rc); + ret = cdns_pcie_host_link_setup(rc); if (ret) - dev_dbg(dev, "PCIe link never came up\n"); + return ret; for (bar = RP_BAR0; bar <= RP_NO_BAR; bar++) rc->avail_ib_bar[bar] = true; diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 03b96798f858..9ca2ffca0bf9 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -515,10 +515,16 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) } #ifdef CONFIG_PCIE_CADENCE_HOST +int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc); int cdns_pcie_host_setup(struct cdns_pcie_rc *rc); void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where); #else +static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc) +{ + return 0; +} + static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { return 0; From patchwork Mon Mar 4 15:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp271754rwb; Mon, 4 Mar 2024 07:41:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVx72jocRw4xKYrY5k8YCwtapcNw/VsThfnMEPZiE+VczJpTc9iNNgQSlJvOGKxOFq6be9PCStFy7sL8sDSVDJKeJs47Q== X-Google-Smtp-Source: AGHT+IEQAS+1RJMCJWTZcqo9g9Yaz2+oB5+sDRXnF1zJcEH/J0w94IQEukTac3WapbbMPzMwHnZb X-Received: by 2002:a05:622a:15d6:b0:42e:f980:2f4a with SMTP id d22-20020a05622a15d600b0042ef9802f4amr1106341qty.10.1709566890133; Mon, 04 Mar 2024 07:41:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566890; cv=pass; d=google.com; s=arc-20160816; b=dwK6TSIuds1it2HAmzGni+uIF24/z3Rx3Yh+IlOdTE0V9f1JR0Embr+HsJtRwAesVa cZG764VQ/Y3nm3UOEtSW/KM5X5ujuu7gZhAw35YKOpm+A3iHQ4VZ60zX8E8jo6dHIw1t eB3xFWuNRmtUPmfVRMMf9qvANZhnju79yV4gNTZeIPeQq68CriW1pD10rQDKeITd3j28 BUC9WHT4Wdjt6QkT87gKn5mzIx/KwqHgdOkw5ij9HazLP1brkfMAvJOuAsWRXXpcCL5m 8/lWrxy57zNZJlg6KxmRLW6sKEeubJrpnOc/LZjXa0DEOzQXikMn83Fnsf9bgpR+2z+q 5UuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=y+hiKLN8/2fVVMMZXP4L41OHcU7ks/UCHNFnX3+9Yuc=; fh=16AwIsfnaBgs0S7h9TVOhyQqQjjaKNV4ZtY0tk57H5k=; b=BK+qklOd6CQNO+phLJva+pNt/IjoSHix6nh8uZNNotJJuRXE1LPzClS/azJH+yPWS4 DmLrfXO9PTLjVt5fnxpgZbW2K3NcT4O+TvxeWGx6sqedpkJlBmSSeBdFoAIsrG/liJPm IwlTQVLLN96DPjoSgDk3gUwgt8lRhSVif6RftwYOf26I/ft+5iBNRNtvZnTQgnVny0n3 ARmODqYxErZoQZiJ8CWwhTeKfqeH1pH7qlRyALzWR9f242k72/TXBFTGyZjk8ZQiEcNC SkCYzAmOTHSc2lDOPmDvztrAPNc0xZGT7scXJyrrJuV4SfmmN2AY4dQgmPOC+JKUbhfb PLoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ASbWpFj+; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90854-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90854-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t9-20020ac85889000000b0042ef14bff1dsi2534793qta.531.2024.03.04.07.41.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:41:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90854-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ASbWpFj+; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90854-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90854-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BE5281C20C40 for ; Mon, 4 Mar 2024 15:41:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D63175A10C; Mon, 4 Mar 2024 15:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ASbWpFj+" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 8969057880; Mon, 4 Mar 2024 15:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566601; cv=none; b=IfEmYEDSzUuq+biEGZL4NHM65YzU57XH3p41RhO6GJPdi7JWnJ//0gi2UwIvxS/b0t40orPT7Sp4BLPptfp8JYXCoME2czwjKqX+eLURcFhl++K7bDFUYugrFAl8l1sPAFs0WKWIjZkEe9n5b9XMUkPZSkyyAVKgq8oZIeFvbsk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566601; c=relaxed/simple; bh=IGmleIBWOi9EUoe685aNDMmUQj5xf6Jx9AU6KShFt1k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W+i0BVRKLE5f72AKdYIcBGw4HueReRh+I1A63iumP9yHm+JUDNReQvIBo8qJwKxuwJF9NR5elWufwJzc29GsAetxtSbRzrQSZyB2dTvrHKQMSWHZ3WhZlWbIN9N6sufN6wzduVGb21GfK084NwZOv1hTJSI45hyzExDOavZkG5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ASbWpFj+; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 702B01BF203; Mon, 4 Mar 2024 15:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566597; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y+hiKLN8/2fVVMMZXP4L41OHcU7ks/UCHNFnX3+9Yuc=; b=ASbWpFj+u2PW8ZQrhB+nBN1B8wyRqLNMxhD64t4BpJTyFlLS3M3TyzwlKpkLsFg9W5nLD8 61uCJVaS7gSm+rimhenARcbtUFUKzJJBsmmWCW7XMK2+3TilRUIn5mztsjAbpsgatVM8uP ZzLyTkUbf96rYbdmtwSLwly0GzhnF71YMJTNuMtQoPQS76b2F4gnaRBM7B6qnboiuQxs/h L5ZNvZ37EVviF9A47oec5lvONX+5YNq4wfmQ84Uw/JLLAwUz+MjGuawIacL5Nvl/4s1htr HORDqb0080Xr7pYKoH/L+eVwh8xLaPcask2iNeCUTDQ9CaaTWGYtnbsKIMo1+g== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:58 +0100 Subject: [PATCH v4 15/18] PCI: cadence: Set cdns_pcie_host_init() global Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-15-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard , Siddharth Vadapalli X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610811262391173 X-GMAIL-MSGID: 1792610811262391173 During the resume sequence of the host, cdns_pcie_host_init() needs to be called, so set it global. The dev function parameter is removed, as it isn't used. Reviewed-by: Siddharth Vadapalli Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pcie-cadence-host.c | 5 ++--- drivers/pci/controller/cadence/pcie-cadence.h | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 93d9922730af..8af95e9da7ce 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -485,8 +485,7 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc) return cdns_pcie_host_map_dma_ranges(rc); } -static int cdns_pcie_host_init(struct device *dev, - struct cdns_pcie_rc *rc) +int cdns_pcie_host_init(struct cdns_pcie_rc *rc) { int err; @@ -564,7 +563,7 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) for (bar = RP_BAR0; bar <= RP_NO_BAR; bar++) rc->avail_ib_bar[bar] = true; - ret = cdns_pcie_host_init(dev, rc); + ret = cdns_pcie_host_init(rc); if (ret) return ret; diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 9ca2ffca0bf9..a2e04261237d 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -516,6 +516,7 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) #ifdef CONFIG_PCIE_CADENCE_HOST int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc); +int cdns_pcie_host_init(struct cdns_pcie_rc *rc); int cdns_pcie_host_setup(struct cdns_pcie_rc *rc); void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where); @@ -525,6 +526,11 @@ static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc) return 0; } +static inline int cdns_pcie_host_init(struct cdns_pcie_rc *rc) +{ + return 0; +} + static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) { return 0; From patchwork Mon Mar 4 15:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp1527382dyc; Mon, 4 Mar 2024 08:21:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXNx3IblGBFu7Rw5eILfKaP1JT/RWeP1Ci2pPVx5it8YK8d3g8FbbTaxSidFp1+3Pt8bOG5UB0h9ymBFg9NkgdrF8GsuA== X-Google-Smtp-Source: AGHT+IHXUYX8f2Ez/5he22PYQeFFY4fg3K9zAIB3qbIvfRTO8rUHEBYCMhax4brCeo+f0sB+iTJ3 X-Received: by 2002:a17:903:18a:b0:1dc:771f:ae56 with SMTP id z10-20020a170903018a00b001dc771fae56mr11053148plg.29.1709569263795; Mon, 04 Mar 2024 08:21:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709569263; cv=pass; d=google.com; s=arc-20160816; b=kHODodTnUr60NrPwSEyS9DMzgcklf/BFA8bhU7x2M3GawKvMTu3bqQsO4bUVE91a6p G0hdphWA4JHi5hDTdotABX6yPBrfXxr5nUqPviPpSDoo21xJreWFJi2J7mfNccdQhHRc BqVG6eLxXYH/KbAT+PkmEU2MqumZPTTPeVYnKe85hXTfJdqlujVJKF8D2db5mnYc2+id SZLnAtA7quvnjGly76U4K/5l81zqQHZHBqKZ0IqOh6ETkeThJ2W/XPB+wcLkMgZfGWq0 6aNARqRAe7QuTtv9DPjOdbelzC3A1ZN2TVsQe3TllCiA/nMBb7TxrY//lPpXltSb2qOn fNZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=KHgRE7AWaSOAAlSu+b/+Fh63+xKvjYyr+YQEe5ZFNNM=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=e+U4eadfX8cHvt3l3+9abg/lPGnNACF3b2OLxACfdZnzeI5+2r0QU3xmEazu+ttJVT 6n6HSl3q1ARkftM2tAWs3i1DKfmVpD2d+/x2Sp6vjPOxvU1K/HEg5+rm85CA24E4fkMq pMoeD2TLgDYdC6p9JZDk4Gsvjee3D6fQw8nnXbkSr0GVvHrmnFCp4GyJziaEuEJGqm6/ kmh7b2Y2oeyFRutNLIEN0sl70ZYDEDzLZCeh/rrjQqDpmSGyCGpXgQ837XiTyU4VJyNf iEyHjzZt6dT7s7+zWjyAvwo28gzEv/0iTnsMwrjtMXCzrJdgNb/NStdOHcflW5T2j0e4 C3aQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aZhrnNep; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90855-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d1-20020a170903230100b001dc3dfe9f86si8565058plh.220.2024.03.04.08.21.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 08:21:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aZhrnNep; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90855-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 096EFB2BAFD for ; Mon, 4 Mar 2024 15:41:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC1CA5A110; Mon, 4 Mar 2024 15:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="aZhrnNep" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 82E1E58209; Mon, 4 Mar 2024 15:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566603; cv=none; b=HNiiBa37erejKduvjNEJzojcLxPL1tsHK3oOM+tgY3xp3hOePHutv6AgPClJM2lBveCPzBqrREaav45WEeoXluQSf427pSYk8fLXfB45zZn12m8yUiCRYsPoHCM/A2flrAKYOb9hTRQtgHL3aunoThaj4QNp7Zvx3I2GtAgfQsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566603; c=relaxed/simple; bh=Ohktw3RK4eDwPNimb3W6pUcDGyTAny2PddqKGaaMR6I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Deld+VNPgG1ii8UKBdnPXnjPP1Xsv6hAz1rhZCPOwYnP7YKv17z1QM0Fg4pprwS4QHrJXB3grehEaEaCBhQnXHVW1O5elIACRzspATcGqnrWK2y/fEd7x3ky4Ey+G+33bX3Q9SP/k5QrJqsYLI8EwjPQHRrweS+rdCSghC633l4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=aZhrnNep; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 3EC7B1BF208; Mon, 4 Mar 2024 15:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KHgRE7AWaSOAAlSu+b/+Fh63+xKvjYyr+YQEe5ZFNNM=; b=aZhrnNepGDvUIjpqZPS2Mj2T+VGrvoVHTiGmgIK6SWeYriVx6Fsc0imTLaWFmxbv+SOBbq IRz/GynvGMJd/TuUwCO06iCpLAolLJNbp5SK46bUCZ721iEOsmd7vaD0vsUfl+KSADEqby 8o5NdLzFsFT5FgdzFNNDwhiymGG5bTiNL4mcABGgAiZnJ6h9IA/9N1btGN5ksg7HVYORqX +jgBj35S7+ozRjumHtehBIXiUdREalVMwA5Ca7Cg4xS39/qRCEIoK7VbqiY8PXy0CtD2OE bOsQq8kpaOcIMtINeAqRRQ/xGg1HQ3STdf0+Ht9yFGoMZxK+yexyt6xInPikKQ== From: Thomas Richard Date: Mon, 04 Mar 2024 16:35:59 +0100 Subject: [PATCH v4 16/18] PCI: j721e: Use dev_err_probe() in the probe() function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-16-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792613300233443445 X-GMAIL-MSGID: 1792613300233443445 Use dev_err_probe() instead of dev_err() in the probe() function to simplify the code and standardize the error output. Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 85718246016b..98484f001562 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -482,20 +482,20 @@ static int j721e_pcie_probe(struct platform_device *pdev) pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev); if (ret < 0) { - dev_err(dev, "pm_runtime_get_sync failed\n"); + dev_err_probe(dev, ret, "pm_runtime_get_sync failed\n"); goto err_get_sync; } ret = j721e_pcie_ctrl_init(pcie); if (ret < 0) { - dev_err(dev, "pm_runtime_get_sync failed\n"); + dev_err_probe(dev, ret, "pm_runtime_get_sync failed\n"); goto err_get_sync; } ret = devm_request_irq(dev, irq, j721e_pcie_link_irq_handler, 0, "j721e-pcie-link-down-irq", pcie); if (ret < 0) { - dev_err(dev, "failed to request link state IRQ %d\n", irq); + dev_err_probe(dev, ret, "failed to request link state IRQ %d\n", irq); goto err_get_sync; } @@ -505,28 +505,25 @@ static int j721e_pcie_probe(struct platform_device *pdev) case PCI_MODE_RC: gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(gpiod)) { - ret = PTR_ERR(gpiod); - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get reset GPIO\n"); + ret = dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get reset GPIO\n"); goto err_get_sync; } ret = cdns_pcie_init_phy(dev, cdns_pcie); if (ret) { - dev_err(dev, "Failed to init phy\n"); + dev_err_probe(dev, ret, "Failed to init phy\n"); goto err_get_sync; } clk = devm_clk_get_optional(dev, "pcie_refclk"); if (IS_ERR(clk)) { - ret = PTR_ERR(clk); - dev_err(dev, "failed to get pcie_refclk\n"); + ret = dev_err_probe(dev, PTR_ERR(clk), "failed to get pcie_refclk\n"); goto err_pcie_setup; } ret = clk_prepare_enable(clk); if (ret) { - dev_err(dev, "failed to enable pcie_refclk\n"); + dev_err_probe(dev, ret, "failed to enable pcie_refclk\n"); goto err_pcie_setup; } pcie->refclk = clk; @@ -554,7 +551,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) case PCI_MODE_EP: ret = cdns_pcie_init_phy(dev, cdns_pcie); if (ret) { - dev_err(dev, "Failed to init phy\n"); + dev_err_probe(dev, ret, "Failed to init phy\n"); goto err_get_sync; } From patchwork Mon Mar 4 15:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp272091rwb; Mon, 4 Mar 2024 07:42:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWVriFkEgGi5bUtlaG4ZpxwLNnEuwnazfJ9N+3vrZJE3mSmZ74lJL2PYuJm6jNfEmeMQLKKyY/z+islRhh68u1MRpp/Pw== X-Google-Smtp-Source: AGHT+IEhw1yp27lV7jXf5muhfYlR33xD4xNBC7OffhGUCUgaV0pLJdyy0jUr9U+9gVrdBEztu+6v X-Received: by 2002:a05:6808:1528:b0:3c0:3e27:b122 with SMTP id u40-20020a056808152800b003c03e27b122mr11772383oiw.39.1709566927412; Mon, 04 Mar 2024 07:42:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709566927; cv=pass; d=google.com; s=arc-20160816; b=vSfKTcStql34x7gMQJSMpKb4sULhH8ZRJv4bcdFJJMTfvqS/Uez+KRVGXRbr0/QoJ+ zw9c1Vt20RTi5742Zgg8mmKClu9vS4lf698C+ZjZFen/nQsLWQMsorZb4uoFvLrZSbVu Zfdf7JD1ij8dVWN9cLIo/NGk/Nc/dmI5adp+enCCCsyJOAMK8eBj60RYv8kZRTt+avTY 96qk4Au3pCw/qYuQhYHh2ZXQYXxPJH5nytJ7jiL4BsqhqCVOqi2lAnPE1bfHfi/ombMq JAH4AKbh0kINZN/FKNnfPKdtcQ+v3w/8115uC/zWmPJDnlljeL9S5kIqjQ9HMO0TlOwM iDrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=pAhWJDZy3Qxtd03byX/QomLU+QUbXtxsEhEbMTufqk0=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=bLIX6JbCF8rQy1xkzY2Jy5+Gl5WkWvo7pFHGbEniWfu9ENP2M7pEjI+3or1fp5y/dA Ca9xwoUjuNaAXwKmhUGhe2+USu31DGNmDhBLIdzSQoXsLxEM3znYjEFQAQNDKW6rAVtu 0AhEYDQGpZDPL4jbPWwh5PYZESeeHUeWuwdH6N9Maf/REZo2ula7akSE60legxmDI2ii lUt23n3ZIFTDsZ7zBwLOZnJH+NCCWNp/1OflKtPt1pcpN91g/Hyvonuvqsf2M1pQnyxR Uj+pE5zSrA+6F0Z1LTlJl7t16rZ54pjeDpxve/6Ctttz2oeA/t3fwfeh2A0h5mIIjsCR Invg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Kc17rCqk; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e17-20020ac85dd1000000b0042ef866aeaesi927294qtx.794.2024.03.04.07.42.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:42:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Kc17rCqk; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A1791C20FC9 for ; Mon, 4 Mar 2024 15:42:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2757E5A7BE; Mon, 4 Mar 2024 15:36:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Kc17rCqk" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 3F73B5916C; Mon, 4 Mar 2024 15:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566604; cv=none; b=jfqLKHJq8viUA+/smWIgA7/h8PQ3ZmKNWwXenU6nRkPoNZGrzbSsobX8EyA+PepoaY+OKkKqWASzgsqZYtxRfjXBAkTMYJ230TQgl9Sihrg5Nn81aN8ahIOYpBquxFsIkiDKeKxK+5RHSmUwLOOJOfcxGeezqCJpV0ogoiqrg8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566604; c=relaxed/simple; bh=D/mIw5PQXaVybV8q1M5tT5irn19bOqE7/C1r84b60EQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EQJstz21pLw1Ss8sYpPBpYkQh0AR+nHvGjo6Gz3G4gMREwuKkZkOoIJkKbYrXAFgI5j31+bh1d+JBrhQck0LyjLaq862dmX5SGHEf4GeA8baKnGDCSmJ+ssQnBHy9EjiDz6dhGGm+rEmwVL/uIs6cx2LzbE0djvF7Nzj9+0iRBk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Kc17rCqk; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 155381BF207; Mon, 4 Mar 2024 15:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pAhWJDZy3Qxtd03byX/QomLU+QUbXtxsEhEbMTufqk0=; b=Kc17rCqkc6LOuhYPwzljGg/aEZQJ8pXDhF6R5AXxVwGA3rWUtr6nJ+P/hf1YcshHcsgfln r3emNG6lXMTbJ0PzSHKu5p+6lxRGBaBfH5U26dL9aGFQilO5dcI04j9QqvWFLrX6gLXu55 44G9/+PQVO9Js+sc7Ok4WYHoEFsPLM5dIM3oceE8QEYk4r1obpEnDwGTkDTW8HN9OIvNMb T2EUi1aDs0gMPskOlN08SRld8nN/yfZ6LT4POBBN2f26/mqHy+7JiM54p4LFoC+FRGzIDC +Ul80YVITQ4Tlr/nA2VCuukU/XrDcfSEDHcq2vNFaMcme9jU19vIfIJ+TQnjZA== From: Thomas Richard Date: Mon, 04 Mar 2024 16:36:00 +0100 Subject: [PATCH v4 17/18] PCI: j721e: Add reset GPIO to struct j721e_pcie Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-17-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792610850726121294 X-GMAIL-MSGID: 1792610850726121294 From: Théo Lebrun Add reset GPIO to struct j721e_pcie, so it can be used at suspend and resume stages. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 98484f001562..9af4fd64c1f9 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -52,6 +52,7 @@ struct j721e_pcie { u32 mode; u32 num_lanes; u32 max_lanes; + struct gpio_desc *reset_gpio; void __iomem *user_cfg_base; void __iomem *intd_cfg_base; u32 linkdown_irq_regfield; @@ -508,6 +509,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) ret = dev_err_probe(dev, PTR_ERR(gpiod), "Failed to get reset GPIO\n"); goto err_get_sync; } + pcie->reset_gpio = gpiod; ret = cdns_pcie_init_phy(dev, cdns_pcie); if (ret) { From patchwork Mon Mar 4 15:36:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 209613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6299:b0:17c:1df7:5ed3 with SMTP id se25csp274080rwb; Mon, 4 Mar 2024 07:45:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVocOVlqcsdS3h60bLCCc2RUc3xExqyXcRKfafmnPqGE6VkPZOa8NDoH9wCzpG2fVB+RO20GgcB9koLwWYaD+kY6ABgOg== X-Google-Smtp-Source: AGHT+IGraxrlAOSxa3WDNG2iCjlUMmS5GJUt2ZgiG8WwYVONjppdtiZQCqE9G5mLPnFVBeE9c7Th X-Received: by 2002:a05:6a00:4f8b:b0:6e6:2159:ed8e with SMTP id ld11-20020a056a004f8b00b006e62159ed8emr4660844pfb.12.1709567145795; Mon, 04 Mar 2024 07:45:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709567145; cv=pass; d=google.com; s=arc-20160816; b=OPw5pbhAjAhFOu0rzalFdhPt2KoM7vXhMy5oOy1tfdGXBfb/cfykHMzKQtBpc7lt3T MfeOOHqnlv/vu8Kk6uLAgd1WiCJBoNNciaqA65FwbbQmKncSA/99dX0FsYMKqoDVGSE+ qQEO8WtR2kv55mUiOe2aAhO0KSFy++/iBF7+HqVw7jg9IB+n0NdLB1qyYvUYmJZNrxjR SSnN+Vu+sxqigeKzIvqV7oyqToN5VRRCtVpYIKMBYLjgzL/m8UC5MjQGXC+ApwijaE8B QSa0b+ppEp+bhBo5nYOZin0B/x8UAb9DWMhHcoEFiyEPRR79boopv2nB5sNte+LlN5aV 3hQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=s6E/Ne64c6+x0FpS9CVe8d7lEAGfcFSrGEubkDw5WnM=; fh=wHZQkXie84v2FP+2z7dUEuyvptHwnAyqgx34WxJkhrY=; b=FhWkjBwyQbyNQN5r//Kcfe7NUUhCve0AG0YGg6Uai1Og0Usfs9JMyTWLJ9CjhWPmhN esF46Z1zWWwmrk7so1EO0MzMIkmdBoFsN8miwcjpoj2e1tRjPKwSMoKAhLEUCgRJyITl LCGrBKVsEpqJPAF5f0NTgcrRO3yrCN+bw4ym9NGAJWJaMy/E8ttV53XgeOlvQzgbqB5N W8JVbubDiMfSBDYNA4w1fxgvagKPuo7irDwv6tmrnyGdZ5EANyfUNg02tAXw0VKibem1 Jl8h+fEHsb02p+OZ29ESIEhLXxQuw9IrjFETK6Be67f40Jh/FtuFEYZAoenEMZq1ASoe hSPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DkCG7exs; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90857-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s16-20020a632150000000b005dc6cbf8440si8551657pgm.99.2024.03.04.07.45.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:45:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-90857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DkCG7exs; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-90857-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-90857-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3AD76282512 for ; Mon, 4 Mar 2024 15:42:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B79E5B5C1; Mon, 4 Mar 2024 15:36:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DkCG7exs" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 CE6095A10B; Mon, 4 Mar 2024 15:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566606; cv=none; b=B/g/NQKrzL0i8u001ozC83Q2CHiEl/kqtJXPRN3uQX9IRcdhktZi5OdtYoWdGPGlCdK6S4Cob9knlUxdMC6WduAzDXPZwUgsUSl7u6kvJyVO1lkC+7mEworHup1ZJ4LeEJYSebye99laMbuVB8xuRMeh22PRy+MvaIRVViJ7yPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566606; c=relaxed/simple; bh=/JaCgmvn7UffcKtiKZ8KnVu2ThvlYf/H+nfsZaXvtrs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bEus+0azwGKvDxi7ocx/giV6akC/oPRsyRmxzCD6PiDkSGTar6wTX6KA/iDJ0h52WcMD4fvk2IMDaucu57dzAsfRapmCQL7uX7DM5d+hiTL2nqo9lB5bRW5y4Yl/7+UtQ8IK03GzvrGLiISKUWDLDqRL2yMqEv7y8sZFhvLK6EA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DkCG7exs; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C85DC1BF20D; Mon, 4 Mar 2024 15:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709566602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s6E/Ne64c6+x0FpS9CVe8d7lEAGfcFSrGEubkDw5WnM=; b=DkCG7exsY9UG0LnSnUH7x6xVnM2DPQ1Lj6I2RzBY+M7bkhHNhhakHh7CoGAHXYsXcvlGbq A4ejNjPUVEZWsUjN2ioBLevD96g9DYAkOMpX7opwl8btRLw7jmFxXMP/bauJTQo844czGL OSe/8J5KC3IpIFWpHreXS9ou4YhhpN0nCNBtkCj/ruw3mJOxuLyXilxeDtASBR76Qigb6K B114owohauREEMF/fDdF5MUh0CSC+C5D2QJqkBiZCrO6hRngqjLDG85AFBezRdn59uE0IG 3Rwp0QtrYvsmiBlp+g4K7wa2jNHudKR/F5DFFBkYT9eyk43BYTXkAVvLynrQSw== From: Thomas Richard Date: Mon, 04 Mar 2024 16:36:01 +0100 Subject: [PATCH v4 18/18] PCI: j721e: Add suspend and resume support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240102-j7200-pcie-s2r-v4-18-6f1f53390c85@bootlin.com> References: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v4-0-6f1f53390c85@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792611079159398157 X-GMAIL-MSGID: 1792611079159398157 From: Théo Lebrun Add suspend and resume support. Only the rc mode is supported. During the suspend stage PERST# is asserted, then deasserted during the resume stage. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 86 ++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 9af4fd64c1f9..a1f1232e8ee5 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include @@ -22,6 +24,8 @@ #include "../../pci.h" #include "pcie-cadence.h" +#define cdns_pcie_to_rc(p) container_of(p, struct cdns_pcie_rc, pcie) + #define ENABLE_REG_SYS_2 0x108 #define STATUS_REG_SYS_2 0x508 #define STATUS_CLR_REG_SYS_2 0x708 @@ -588,6 +592,87 @@ static void j721e_pcie_remove(struct platform_device *pdev) pm_runtime_disable(dev); } +static int j721e_pcie_suspend_noirq(struct device *dev) +{ + struct j721e_pcie *pcie = dev_get_drvdata(dev); + + if (pcie->mode == PCI_MODE_RC) { + gpiod_set_value_cansleep(pcie->reset_gpio, 0); + clk_disable_unprepare(pcie->refclk); + } + + cdns_pcie_disable_phy(pcie->cdns_pcie); + + return 0; +} + +static int j721e_pcie_resume_noirq(struct device *dev) +{ + struct j721e_pcie *pcie = dev_get_drvdata(dev); + struct cdns_pcie *cdns_pcie = pcie->cdns_pcie; + int ret; + + ret = j721e_pcie_ctrl_init(pcie); + if (ret < 0) + return ret; + + j721e_pcie_config_link_irq(pcie); + + /* + * This is not called explicitly in the probe, it is called by + * cdns_pcie_init_phy(). + */ + ret = cdns_pcie_enable_phy(pcie->cdns_pcie); + if (ret < 0) + return ret; + + if (pcie->mode == PCI_MODE_RC) { + struct cdns_pcie_rc *rc = cdns_pcie_to_rc(cdns_pcie); + + ret = clk_prepare_enable(pcie->refclk); + if (ret < 0) + return ret; + + /* + * "Power Sequencing and Reset Signal Timings" table in + * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 + * indicates PERST# should be deasserted after minimum of 100us + * once REFCLK is stable. The REFCLK to the connector in RC + * mode is selected while enabling the PHY. So deassert PERST# + * after 100 us. + */ + if (pcie->reset_gpio) { + fsleep(100); + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + } + + ret = cdns_pcie_host_link_setup(rc); + if (ret < 0) { + clk_disable_unprepare(pcie->refclk); + return ret; + } + + /* + * Reset internal status of BARs to force reinitialization in + * cdns_pcie_host_init(). + */ + for (enum cdns_pcie_rp_bar bar = RP_BAR0; bar <= RP_NO_BAR; bar++) + rc->avail_ib_bar[bar] = true; + + ret = cdns_pcie_host_init(rc); + if (ret) { + clk_disable_unprepare(pcie->refclk); + return ret; + } + } + + return 0; +} + +static DEFINE_NOIRQ_DEV_PM_OPS(j721e_pcie_pm_ops, + j721e_pcie_suspend_noirq, + j721e_pcie_resume_noirq); + static struct platform_driver j721e_pcie_driver = { .probe = j721e_pcie_probe, .remove_new = j721e_pcie_remove, @@ -595,6 +680,7 @@ static struct platform_driver j721e_pcie_driver = { .name = "j721e-pcie", .of_match_table = of_j721e_pcie_match, .suppress_bind_attrs = true, + .pm = pm_sleep_ptr(&j721e_pcie_pm_ops), }, }; builtin_platform_driver(j721e_pcie_driver);