Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp995824rdb; Sat, 6 Jan 2024 21:33:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHscpsktTE6uRnppe8S+Ka4h2GPMRE7GmYm4Ejiv5drFzooAksiEBrsLjfyG7L2XaWSziyr X-Received: by 2002:a05:622a:54:b0:425:a84d:bccc with SMTP id y20-20020a05622a005400b00425a84dbcccmr2924770qtw.137.1704605615123; Sat, 06 Jan 2024 21:33:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704605615; cv=none; d=google.com; s=arc-20160816; b=KA4IRN23TQlTHci5HECiIGVRl8kpf19V5qqPyLXy6BpCauQ1jUZTbWVGGOQwrwGCJI TVYivh4S89Mecg47h8q+AwOUp69Por+qQsnB6PymYQwv99tGfK2BbfoUxV2ACt8iLFuU Zr2Fvsk6Cvd3IwbcVQtye4++nwjUgyEITF1nWeDFerIwlIEo8hWPaIE7JVCgcLkNl3Ji Mcx37xZUW0Whx72lN+tm7gp/REhXIq68jQiX2NGmSgkR3KQFeGpzy8afoyk0RUR2hrwo LuWZOHBklyKuYML9le/qktGERJ6Uzg0OyJu9ikIfrtcVl0dRtDjlOeEzKbsOJwhScs2Y Snjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sUxB7wKicUOyFSlq6s48xe3dcqB2CW2xhmx3XZD8AVg=; fh=iWBv4He8s+xpzrJY93iuua2RS8H3PW0G6YXgJrUCrjQ=; b=Fkltqq0DfrIpwZ51x1Crgr1Guu7jH8dNm5zqfHszDVx/6/97d2TrBRcY/fKYV3jvLn clYrKlqSjVttyA9wn+LNYzDVY6dky6bNCN1eLO+KAJaqZSK2MfewLETFNJRIOCcHwOh+ L4dsVG3g24kqcQ6/KbD6ywCp251I7LkStivag/pqhaNtnjbLtolyYh86/OxmAbrbT6/E V/EKZ7JyUCbUN8zM5INL3afh5sV86iKYaoY9oth6dxe4oW6ozv8SJDRyn4x2LKT6/Vxr RKIo2KikNDlpUuWhjDTHkDsBfqJi8NGMmgsNwJYG5tK6udaRCEdKSuhY25NN7NvsMPy8 EvTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=krsR6mz9; spf=pass (google.com: domain of linux-kernel+bounces-18783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h3-20020ac85843000000b004298fc39b6csi397984qth.159.2024.01.06.21.33.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 21:33:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18783-linux.lists.archive=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=@linaro.org header.s=google header.b=krsR6mz9; spf=pass (google.com: domain of linux-kernel+bounces-18783-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18783-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 CF0461C2137B for ; Sun, 7 Jan 2024 05:33:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E598125B3; Sun, 7 Jan 2024 05:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="krsR6mz9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEC11125AD for ; Sun, 7 Jan 2024 05:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-3606dc50447so6270805ab.2 for ; Sat, 06 Jan 2024 21:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704605604; x=1705210404; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=sUxB7wKicUOyFSlq6s48xe3dcqB2CW2xhmx3XZD8AVg=; b=krsR6mz9BLFpHNaTtL7j8CUvHjsiIAiXUC8lUkTkUYEoDPMBxbFft25F1vnlFXDODg LCGjYo9YdWTy8uWJyrz01fwNkmMQBYEExz1AZjRjHKX11YUKpu+64BQyN77DU77nennr XJ6Zv21WINYnfyQ+c3chTk6CtdgJofOiUsdBgz2WBnCVQTb4KeebtZiAr7cXn8loKPzz Zd7zw4ZTbWg6g9dv0OPnCadHNSgW9dm+GsXYHhP47u62qcAE22LzOPjQ0IqpfEQjJ2FI RPK4d55uwWXG7Y039z7srqCUv1xdUEy9HOrBZEEZHgjOKXolnuGXirnPKjvvsbiQr+yS mAbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704605604; x=1705210404; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sUxB7wKicUOyFSlq6s48xe3dcqB2CW2xhmx3XZD8AVg=; b=Emnj+c38M3lMlphiC+REPtk5fWoYE3s+m3l4t1zQXyOq76XHPANgisyzrVMQ+psr95 cbm9Qr9pGC/dd+Lr/u8j6Gd2IFCKwCIo8+DHu9MjxNWR//zg84F1hPBkvZcZE/qIUV+n 4UfEceni64sU5iNQrJ09zBpHfk9/nVorKH7+1uxqmTdpJRsxk4y2O9mxjdekBbDl89Yc 3Us4Kc1z/cuOg8dcb+5giYWp30+cfX/Obsh4LVhzX7QWk1LUWDucabOIHmkPQ5iSFXMd 5RElXfh6B/ViJYWp8K/KSOWdQxKgXSvmdn7HXLyTpBYN21V/N/lmTBRM2r75OcI6zL1E AcUg== X-Gm-Message-State: AOJu0YwDP7vDAD2vXlBSfJNO+xTn35NspwTkwfzEJl4oA388Sx15S535 2qfWCtBymhcVrGxuiIZgu6BFgHHsKTPU+ts0qdXivaFV4rVL X-Received: by 2002:a92:ca05:0:b0:360:7c05:e484 with SMTP id j5-20020a92ca05000000b003607c05e484mr3356916ils.54.1704605603671; Sat, 06 Jan 2024 21:33:23 -0800 (PST) Received: from thinkpad ([103.197.115.97]) by smtp.gmail.com with ESMTPSA id u13-20020a170902e80d00b001d072365b87sm3858364plg.106.2024.01.06.21.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 21:33:23 -0800 (PST) Date: Sun, 7 Jan 2024 11:03:13 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: krzysztof.kozlowski@linaro.org, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH v7 08/16] PCI: imx6: Simplify switch-case logic by involve init_phy callback Message-ID: <20240107053313.GH3416@thinkpad> References: <20231227182727.1747435-1-Frank.Li@nxp.com> <20231227182727.1747435-9-Frank.Li@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231227182727.1747435-9-Frank.Li@nxp.com> On Wed, Dec 27, 2023 at 01:27:19PM -0500, Frank Li wrote: Subject: PCI: imx6: Introduce init_phy() callback to simplify PHY initialization > Add drvdata::init_phy() callback function, so difference SOC choose > difference callback function to simple switch-case logic. > Same subject can be used in commit message. > Signed-off-by: Frank Li > --- > > Notes: > change from v1 to v4: > - none > > drivers/pci/controller/dwc/pci-imx6.c | 135 ++++++++++++++------------ > 1 file changed, 71 insertions(+), 64 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > index 717e8fa030deb..d66a2db53bdb7 100644 > --- a/drivers/pci/controller/dwc/pci-imx6.c > +++ b/drivers/pci/controller/dwc/pci-imx6.c > @@ -69,6 +69,9 @@ enum imx6_pcie_variants { > #define IMX6_PCIE_MAX_CLKS 6 > > #define IMX6_PCIE_MAX_INSTANCES 2 > + > +struct imx6_pcie; > + > struct imx6_pcie_drvdata { > enum imx6_pcie_variants variant; > enum dw_pcie_device_mode mode; > @@ -80,6 +83,7 @@ struct imx6_pcie_drvdata { > const u32 ltssm_mask; > const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; > const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; > + int (*init_phy)(struct imx6_pcie *pcie); > }; > > struct imx6_pcie { > @@ -323,76 +327,69 @@ static int pcie_phy_write(struct imx6_pcie *imx6_pcie, int addr, u16 data) > return 0; > } > > -static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie) > +static int imx8mq_pcie_init_phy(struct imx6_pcie *imx6_pcie) > { > - switch (imx6_pcie->drvdata->variant) { > - case IMX8MM: > - case IMX8MM_EP: > - case IMX8MP: > - case IMX8MP_EP: > - /* > - * The PHY initialization had been done in the PHY > - * driver, break here directly. > - */ > - break; > - case IMX8MQ: > - case IMX8MQ_EP: > - /* > - * TODO: Currently this code assumes external > - * oscillator is being used > - */ > + /* > + * TODO: Currently this code assumes external > + * oscillator is being used Wrap the comments to 80 column. > + */ > + regmap_update_bits(imx6_pcie->iomuxc_gpr, > + imx6_pcie_grp_offset(imx6_pcie), > + IMX8MQ_GPR_PCIE_REF_USE_PAD, > + IMX8MQ_GPR_PCIE_REF_USE_PAD); > + /* > + * Regarding the datasheet, the PCIE_VPH is suggested > + * to be 1.8V. If the PCIE_VPH is supplied by 3.3V, the > + * VREG_BYPASS should be cleared to zero. > + */ Same here. > + if (imx6_pcie->vph && regulator_get_voltage(imx6_pcie->vph) > 3000000) > regmap_update_bits(imx6_pcie->iomuxc_gpr, > imx6_pcie_grp_offset(imx6_pcie), > - IMX8MQ_GPR_PCIE_REF_USE_PAD, > - IMX8MQ_GPR_PCIE_REF_USE_PAD); > - /* > - * Regarding the datasheet, the PCIE_VPH is suggested > - * to be 1.8V. If the PCIE_VPH is supplied by 3.3V, the > - * VREG_BYPASS should be cleared to zero. > - */ > - if (imx6_pcie->vph && > - regulator_get_voltage(imx6_pcie->vph) > 3000000) > - regmap_update_bits(imx6_pcie->iomuxc_gpr, > - imx6_pcie_grp_offset(imx6_pcie), > - IMX8MQ_GPR_PCIE_VREG_BYPASS, > - 0); > - break; > - case IMX7D: > - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, > + IMX8MQ_GPR_PCIE_VREG_BYPASS, > + 0); > + > + return 0; > +} > + > +static int imx7d_pcie_init_phy(struct imx6_pcie *imx6_pcie) > +{ > + return regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, For consistency, return 0. - Mani -- மணிவண்ணன் சதாசிவம்