Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp369523lqh; Sat, 4 May 2024 04:59:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+zKEcuf4GNbDYWTmFh/avTd7LNeBhJmd+UYXa9rnzC/qbLJMMmV1ie4daSdj4pTj3gak1/pp5cxFIIcGmIT9t9joCQPRTPyMABtV4pQ== X-Google-Smtp-Source: AGHT+IEzp1jDrgZPgMTy/z2dVNtzMUVCDTnISatSrNWrXC/LS1v7LcT6SPMfP+yElBKgj3TmEED7 X-Received: by 2002:ac2:4898:0:b0:51b:64c3:8cfa with SMTP id x24-20020ac24898000000b0051b64c38cfamr3357077lfc.13.1714823952484; Sat, 04 May 2024 04:59:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714823952; cv=pass; d=google.com; s=arc-20160816; b=HValP71zTjWvYTSxkMuzL/Kv9niUBIAlpeU89O55Ub/YHoMTnWRgQVYDObHEAZ43II H/dZ2esdtZXqyi7/Up1zq9RVBLY3AquQ69N5spOqYdkDv02rUtGBlroDlGFwBiEt0Fv+ AOHcQ38NQv1VS9OWxDi6aCwf1Zs8C6NZ/FLodCSiRLK3geaEKFATUGB6EomfuAa6Ew+q kXddN87bswCreF46tYbR8352xD+z+Q4ET1VWz7k8poqy2U6EWfcfRrB5TL4qGXXKen74 fPKJDmYopSKRMlK01VHsr/sJwWBXL3S5qx7dEFAXvzN0etFHqQqM4DFVh/hPkyPM+6KU G3lw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mIu7meJtJeQ/YTrZe7AJY7UV77t3Y7lgAw0tIWxJzQ4=; fh=i6/CoQlMbC857LhNo+E/yUkUrAQq899jPmD5AJ1Q30o=; b=QM8uluckj5Q2Xr1R+TMAFJbrjWOZG98uhHftkcC6bWVmQxbgcKCJmLUpfpJiu0Ur2o VxdA1/x/8xbHTB2YjUNh5R7YVZQ3A+DT5oEjOUiEj0qJkOZ2sbHadO4vHtFOnIxb7/zb uaOrYXi9FrRHFgZnvwF56rOsocHD625GvbKbb1y6eJ61gqO690lBbqra9JuPW6QI0Ura aZF1ntEBYBHJ1svWkPJ2UBMjYkPIxNFdz3PODkSc7QRDc0qr8/ANm36BQyjymWUDrC/5 0C/N/LliU6GHxsyGTXPy89huQ810lyXj6X119+d9FDT2gcYgpI3C8g0qi3yjpLTBqZLu Wlzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IR3uaWJw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168628-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l25-20020a1709060e1900b00a59a02f6244si995513eji.299.2024.05.04.04.59.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 May 2024 04:59:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168628-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IR3uaWJw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-168628-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id F2A191F21F91 for ; Sat, 4 May 2024 11:59:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6604E208A4; Sat, 4 May 2024 11:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IR3uaWJw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.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 8F6C71CFAF for ; Sat, 4 May 2024 11:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823944; cv=none; b=W3so5Q9S7ztXhJ+wqpcp7JNxFQNsn4NIcYu0rNls62H3U9LkS0I80VpDDmAxSSyFlWAHKgFU8WE1rBlY3ikhhEeZZzpYozX8TgCdDW72Z2FjnUFt9U+AKjsZXkZ6mSuxamgOITvUKXR6G+IwXJ16Be2E+ffq+rQsAsixWGUpEXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714823944; c=relaxed/simple; bh=tHkDDYIJU8PS+ZwgvuIlZuzFtSgUX3xgqS/6qnXnSp0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gNDlGB/XrXh0hMNlZeIy7EDHbx9evaiDyerd3nk/hQINK5cBbyuxwduUXKt/yZuAopp8bSgWN32ciY8oXy17cw3WMgM173o3zt7fUn1xCXUKhqeDfLYCLRo+/w137AMAcjKKVuP0MTTJVbgy673rBXw3DgJ0/GfJrL8Fw5TW5OI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IR3uaWJw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7278FC072AA; Sat, 4 May 2024 11:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714823944; bh=tHkDDYIJU8PS+ZwgvuIlZuzFtSgUX3xgqS/6qnXnSp0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IR3uaWJwhf7qbZM6CQd1Id1zrPd6408b1hvcGk/k2JrQCIXAhZiI4R3sOu4icY4m9 bYtizQ42wkei0Kte3UNKXV1pfAxdykrxIO6C6EnLpVruCLvVAcRxkMYXwDN4JE+BuI Lw6B86Wn2rt7bz+B2ZrzqLtCa21XLXUU37QPxIE4C9rYwv7iBG8uOoQruiFsOs1CuR OPWfoZHIc63ZSl7rAyQuD8/HZY6uGTaGsYzSOCOxfLQJkzGd6miViOMGlcICGI1dBq +bAIVE8r9qyte6nWLXdufrOw8ZNStRIGoLtXoMzSd/8pZCadggqdGjeoQ57TPfYu4N 3F6tXbHAOU11g== Date: Sat, 4 May 2024 17:28:58 +0530 From: Vinod Koul To: Sean Anderson Cc: Laurent Pinchart , linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Simek , linux-arm-kernel@lists.infradead.org, Kishon Vijay Abraham I Subject: Re: [PATCH 3/3] phy: zynqmp: Add debugfs support Message-ID: References: <20240422185803.3575319-1-sean.anderson@linux.dev> <20240422185803.3575319-4-sean.anderson@linux.dev> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240422185803.3575319-4-sean.anderson@linux.dev> On 22-04-24, 14:58, Sean Anderson wrote: > Add support for printing some basic status information to debugfs. This > is helpful when debugging phy consumers to make sure they are configuring > the phy appropriately. > > Signed-off-by: Sean Anderson > --- > > drivers/phy/xilinx/phy-zynqmp.c | 54 +++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/drivers/phy/xilinx/phy-zynqmp.c b/drivers/phy/xilinx/phy-zynqmp.c > index 08c88dcd7799..e2e86943e9f3 100644 > --- a/drivers/phy/xilinx/phy-zynqmp.c > +++ b/drivers/phy/xilinx/phy-zynqmp.c > @@ -13,6 +13,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -122,6 +123,15 @@ > #define ICM_PROTOCOL_DP 0x4 > #define ICM_PROTOCOL_SGMII 0x5 > > +static const char *const xpsgtr_icm_str[] = { > + [ICM_PROTOCOL_PD] = "powered down", > + [ICM_PROTOCOL_PCIE] = "PCIe", > + [ICM_PROTOCOL_SATA] = "SATA", > + [ICM_PROTOCOL_USB] = "USB", > + [ICM_PROTOCOL_DP] = "DisplayPort", > + [ICM_PROTOCOL_SGMII] = "SGMII", > +}; > + > /* Test Mode common reset control parameters */ > #define TM_CMN_RST 0x10018 > #define TM_CMN_RST_EN 0x1 > @@ -768,6 +778,48 @@ static struct phy *xpsgtr_xlate(struct device *dev, > return ERR_PTR(-EINVAL); > } > > +/* > + * DebugFS > + */ > + > +static int xpsgtr_status_read(struct seq_file *seq, void *data) > +{ > + struct xpsgtr_phy *gtr_phy = seq->private; > + struct clk *clk; > + u32 pll_status; > + > + mutex_lock(>r_phy->phy->mutex); > + pll_status = xpsgtr_read_phy(gtr_phy, L0_PLL_STATUS_READ_1); > + clk = gtr_phy->dev->clk[gtr_phy->refclk]; > + > + seq_printf(seq, "Lane: %u\n", gtr_phy->lane); > + seq_printf(seq, "Protocol: %s\n", > + xpsgtr_icm_str[gtr_phy->protocol]); > + seq_printf(seq, "Instance: %u\n", gtr_phy->instance); > + seq_printf(seq, "Reference clock: %u (%pC)\n", gtr_phy->refclk, clk); > + seq_printf(seq, "Reference rate: %lu\n", clk_get_rate(clk)); > + seq_printf(seq, "PLL locked: %s\n", > + pll_status & PLL_STATUS_LOCKED ? "yes" : "no"); > + > + mutex_unlock(>r_phy->phy->mutex); > + return 0; > +} > + > +static int xpsgtr_status_open(struct inode *inode, struct file *f) > +{ > + struct xpsgtr_phy *gtr_phy = inode->i_private; > + > + return single_open(f, xpsgtr_status_read, gtr_phy); > +} > + > +static const struct file_operations xpsgtr_status_ops = { > + .owner = THIS_MODULE, > + .open = xpsgtr_status_open, > + .release = single_release, > + .read = seq_read, > + .llseek = seq_lseek > +}; There are debugfs simple helpers which should help you avoid all this open coding and just have the read call > + > /* > * Power Management > */ > @@ -917,6 +969,8 @@ static int xpsgtr_probe(struct platform_device *pdev) > > gtr_phy->phy = phy; > phy_set_drvdata(phy, gtr_phy); > + debugfs_create_file("status", 0444, phy->debugfs, gtr_phy, > + &xpsgtr_status_ops); generic status does not make sense, how about device-name-status -- ~Vinod