lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250407173149.1010216-8-ivecera@redhat.com>
Date: Mon,  7 Apr 2025 19:31:47 +0200
From: Ivan Vecera <ivecera@...hat.com>
To: netdev@...r.kernel.org
Cc: Michal Schmidt <mschmidt@...hat.com>,
	Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>,
	Jiri Pirko <jiri@...nulli.us>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk+dt@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Prathosh Satish <Prathosh.Satish@...rochip.com>,
	Lee Jones <lee@...nel.org>,
	Kees Cook <kees@...nel.org>,
	Andy Shevchenko <andy@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux-hardening@...r.kernel.org
Subject: [PATCH 17/28] dpll: zl3073x: Read DPLL types from firmware

System firmware (DT, ACPI...) can provide a type for each DPLL. The types
are stored in property 'dpll-types' as string array and possible values
'pps' and 'eec' are mapped to DPLL enums DPLL_TYPE_PPS and DPLL_TYPE_EEC.

Reviewed-by: Michal Schmidt <mschmidt@...hat.com>
Signed-off-by: Ivan Vecera <ivecera@...hat.com>
---
 drivers/dpll/dpll_zl3073x.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/dpll/dpll_zl3073x.c b/drivers/dpll/dpll_zl3073x.c
index 34bd6964fe001..3ff53a333a6e9 100644
--- a/drivers/dpll/dpll_zl3073x.c
+++ b/drivers/dpll/dpll_zl3073x.c
@@ -6,6 +6,7 @@
 #include <linux/mfd/zl3073x.h>
 #include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 
 /*
  * Register Map Page 2, Status
@@ -825,6 +826,36 @@ zl3073x_dpll_unregister_pins(struct zl3073x_dpll *zldpll)
 		zl3073x_dpll_pin_unregister(&zldpll->pins[i]);
 }
 
+static enum dpll_type
+zl3073x_dpll_type_get(struct zl3073x_dpll *zldpll)
+{
+	const char *types[ZL3073X_NUM_CHANNELS];
+	enum dpll_type type;
+	int rc;
+
+	/* Set default */
+	type = DPLL_TYPE_PPS;
+
+	/* Read dpll types property from firmware */
+	rc = device_property_read_string_array(zldpll->mfd->dev, "dpll-types",
+					       types, ARRAY_SIZE(types));
+
+	/* It is not present or property does not exist, use default */
+	if (rc <= zldpll->id)
+		return type;
+
+	if (!strcmp(types[zldpll->id], "pps"))
+		type = DPLL_TYPE_PPS;
+	else if (!strcmp(types[zldpll->id], "eec"))
+		type = DPLL_TYPE_EEC;
+	else
+		dev_info(zldpll->mfd->dev,
+			 "Unknown dpll type '%s', using default\n",
+			 types[zldpll->id]);
+
+	return type;
+}
+
 static int
 zl3073x_dpll_register(struct zl3073x_dpll *zldpll)
 {
@@ -852,7 +883,8 @@ zl3073x_dpll_register(struct zl3073x_dpll *zldpll)
 	if (IS_ERR(zldpll->dpll_dev))
 		return PTR_ERR(zldpll->dpll_dev);
 
-	rc = dpll_device_register(zldpll->dpll_dev, DPLL_TYPE_PPS,
+	rc = dpll_device_register(zldpll->dpll_dev,
+				  zl3073x_dpll_type_get(zldpll),
 				  &zl3073x_dpll_device_ops, zldpll);
 	if (rc) {
 		dpll_device_put(zldpll->dpll_dev);
-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ