* [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes
@ 2025-05-05 16:41 Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 1/7] clk: clk-axi-clkgen: fix fpfd_max frequency for zynq Nuno Sá via B4 Relay
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette,
Xu Yilun
This series starts with a small fix and then a bunch of small
improvements. The main change though is to allow detecting of
struct axi_clkgen_limits during probe().
---
Changes in v4:
- Patch 3:
* New patch to move the adi-axi-common header.
- Link to v3: https://lore.kernel.org/r/20250421-dev-axi-clkgen-limits-v3-0-4203b4fed2c9@analog.com
Changes in v3:
- Patch 6:
* Revert change and parenthesis back on 'if (((params->edge == 0) ^
(frac_divider == 1))'. While checkpatch complains, it's more
readable like this and in some configs we might even get -Wparentheses.
- Link to v2: https://lore.kernel.org/r/20250313-dev-axi-clkgen-limits-v2-0-173ae2ad6311@analog.com
Changes in v2:
- Patch 3
* Rename adi_axi_fgpa_technology -> adi_axi_fpga_technology.
- Link to v1: https://lore.kernel.org/r/20250219-dev-axi-clkgen-limits-v1-0-26f7ef14cd9c@analog.com
---
Nuno Sá (7):
clk: clk-axi-clkgen: fix fpfd_max frequency for zynq
clk: clk-axi-clkgen: make sure to include mod_devicetable.h
include: linux: move adi-axi-common.h out of fpga
include: fpga: adi-axi-common: add new helper macros
clk: clk-axi-clkgen: detect axi_clkgen_limits at runtime
clk: clk-axi-clkgen move to min/max()
clk: clk-axi-clkgen: fix coding style issues
drivers/clk/clk-axi-clkgen.c | 147 +++++++++++++++++++++++++-----------
drivers/dma/dma-axi-dmac.c | 2 +-
drivers/hwmon/axi-fan-control.c | 2 +-
drivers/iio/adc/adi-axi-adc.c | 3 +-
drivers/iio/dac/adi-axi-dac.c | 2 +-
drivers/pwm/pwm-axi-pwmgen.c | 2 +-
drivers/spi/spi-axi-spi-engine.c | 2 +-
include/linux/adi-axi-common.h | 58 ++++++++++++++
include/linux/fpga/adi-axi-common.h | 23 ------
9 files changed, 169 insertions(+), 72 deletions(-)
---
base-commit: 82f69876ef45ad66c0b114b786c7c6ac0f6a4580
change-id: 20250218-dev-axi-clkgen-limits-63fb0c5ec38b
--
Thanks!
- Nuno Sá
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v4 1/7] clk: clk-axi-clkgen: fix fpfd_max frequency for zynq
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 2/7] clk: clk-axi-clkgen: make sure to include mod_devicetable.h Nuno Sá via B4 Relay
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
The fpfd_max frequency should be set to 450 MHz instead of 300 MHz.
Well, it actually depends on the platform speed grade but we are being
conservative for ultrascale so let's be consistent. In a following
change we will set these limits at runtime.
Fixes: 0e646c52cf0e ("clk: Add axi-clkgen driver")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 934e53a96dddac8ed61dd109cfc188f3a2a0539a..00bf799964c61a3efc042b0f3a9ec3bc8625c9da 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -118,7 +118,7 @@ static const struct axi_clkgen_limits axi_clkgen_zynqmp_default_limits = {
static const struct axi_clkgen_limits axi_clkgen_zynq_default_limits = {
.fpfd_min = 10000,
- .fpfd_max = 300000,
+ .fpfd_max = 450000,
.fvco_min = 600000,
.fvco_max = 1200000,
};
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 2/7] clk: clk-axi-clkgen: make sure to include mod_devicetable.h
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 1/7] clk: clk-axi-clkgen: fix fpfd_max frequency for zynq Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga Nuno Sá via B4 Relay
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
The mod_devicetable header is the one to be used for struct
of_device_id.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 00bf799964c61a3efc042b0f3a9ec3bc8625c9da..2a95f9b220234a1245024a821c50e1eb9c104ac9 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -13,6 +13,7 @@
#include <linux/io.h>
#include <linux/of.h>
#include <linux/module.h>
+#include <linux/mod_devicetable.h>
#include <linux/err.h>
#define AXI_CLKGEN_V2_REG_RESET 0x40
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 1/7] clk: clk-axi-clkgen: fix fpfd_max frequency for zynq Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 2/7] clk: clk-axi-clkgen: make sure to include mod_devicetable.h Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 18:30 ` Jonathan Cameron
2025-05-05 16:41 ` [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros Nuno Sá via B4 Relay
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette,
Xu Yilun
From: Nuno Sá <nuno.sa@analog.com>
The adi-axi-common.h header has some common defines used in various ADI
IPs. However they are not specific for any fpga manager so it's
questionable for the header to live under include/linux/fpga. Hence
let's just move one directory up and update all users.
Suggested-by: Xu Yilun <yilun.xu@linux.intel.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 2 ++
drivers/dma/dma-axi-dmac.c | 2 +-
drivers/hwmon/axi-fan-control.c | 2 +-
drivers/iio/adc/adi-axi-adc.c | 3 +--
drivers/iio/dac/adi-axi-dac.c | 2 +-
drivers/pwm/pwm-axi-pwmgen.c | 2 +-
drivers/spi/spi-axi-spi-engine.c | 2 +-
include/linux/{fpga => }/adi-axi-common.h | 0
8 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 2a95f9b220234a1245024a821c50e1eb9c104ac9..31915f8f5565f2ef5d17c0b4a0c91a648005b3e6 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -16,6 +16,8 @@
#include <linux/mod_devicetable.h>
#include <linux/err.h>
+#include <linux/adi-axi-common.h>
+
#define AXI_CLKGEN_V2_REG_RESET 0x40
#define AXI_CLKGEN_V2_REG_CLKSEL 0x44
#define AXI_CLKGEN_V2_REG_DRP_CNTRL 0x70
diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index 36943b0c6d603cbe38606b0d7bde02535f529a9a..5b06b0dc67ee12017c165bf815fb7c0e1bf5abd8 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -6,6 +6,7 @@
* Author: Lars-Peter Clausen <lars@metafoo.de>
*/
+#include <linux/adi-axi-common.h>
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/device.h>
@@ -22,7 +23,6 @@
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
-#include <linux/fpga/adi-axi-common.h>
#include <dt-bindings/dma/axi-dmac.h>
diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c
index 35c862eb158b0909dac64c2e9f51f0f9f0e8bf72..b7bb325c3ad966ed2a93be4dfbf4e20661568509 100644
--- a/drivers/hwmon/axi-fan-control.c
+++ b/drivers/hwmon/axi-fan-control.c
@@ -4,9 +4,9 @@
*
* Copyright 2019 Analog Devices Inc.
*/
+#include <linux/adi-axi-common.h>
#include <linux/bits.h>
#include <linux/clk.h>
-#include <linux/fpga/adi-axi-common.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/interrupt.h>
diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index c7357601f0f869e57636f00bb1e26c059c3ab15c..87fa18f1ec96782556bdfad08bedb5e7549fb93d 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -6,6 +6,7 @@
* Copyright 2012-2020 Analog Devices Inc.
*/
+#include <linux/adi-axi-common.h>
#include <linux/bitfield.h>
#include <linux/cleanup.h>
#include <linux/clk.h>
@@ -20,8 +21,6 @@
#include <linux/regmap.h>
#include <linux/slab.h>
-#include <linux/fpga/adi-axi-common.h>
-
#include <linux/iio/backend.h>
#include <linux/iio/buffer-dmaengine.h>
#include <linux/iio/buffer.h>
diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index b143f7ed6847277aeb49094627d90e5d95eed71c..581a2fe55a7fb35f1a03f96f3a0e95421d1583e7 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -5,6 +5,7 @@
*
* Copyright 2016-2024 Analog Devices Inc.
*/
+#include <linux/adi-axi-common.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/cleanup.h>
@@ -23,7 +24,6 @@
#include <linux/regmap.h>
#include <linux/units.h>
-#include <linux/fpga/adi-axi-common.h>
#include <linux/iio/backend.h>
#include <linux/iio/buffer-dmaengine.h>
#include <linux/iio/buffer.h>
diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c
index 4259a0db9ff45808eecae28680473292d165d1f6..e720191e74558d15f1b04fa18cf2984299f88809 100644
--- a/drivers/pwm/pwm-axi-pwmgen.c
+++ b/drivers/pwm/pwm-axi-pwmgen.c
@@ -18,10 +18,10 @@
* - Supports normal polarity. Does not support changing polarity.
* - On disable, the PWM output becomes low (inactive).
*/
+#include <linux/adi-axi-common.h>
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/err.h>
-#include <linux/fpga/adi-axi-common.h>
#include <linux/io.h>
#include <linux/minmax.h>
#include <linux/module.h>
diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
index 7c252126b33ea83fe6a6e80c6cb87499243069f5..d498132f1ff6adf20639bf4a21f1687903934bec 100644
--- a/drivers/spi/spi-axi-spi-engine.c
+++ b/drivers/spi/spi-axi-spi-engine.c
@@ -5,9 +5,9 @@
* Author: Lars-Peter Clausen <lars@metafoo.de>
*/
+#include <linux/adi-axi-common.h>
#include <linux/clk.h>
#include <linux/completion.h>
-#include <linux/fpga/adi-axi-common.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/of.h>
diff --git a/include/linux/fpga/adi-axi-common.h b/include/linux/adi-axi-common.h
similarity index 100%
rename from include/linux/fpga/adi-axi-common.h
rename to include/linux/adi-axi-common.h
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
` (2 preceding siblings ...)
2025-05-05 16:41 ` [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 17:21 ` David Lechner
2025-05-05 16:41 ` [PATCH v4 5/7] clk: clk-axi-clkgen: detect axi_clkgen_limits at runtime Nuno Sá via B4 Relay
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
Add new helper macros and enums to help identifying the platform and some
characteristics of it at runtime.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
include/linux/adi-axi-common.h | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/include/linux/adi-axi-common.h b/include/linux/adi-axi-common.h
index 141ac3f251e6f256526812b9d55cd440a2a46e76..a832ef9b37473ca339a2a2ff8a4a5716d428fd29 100644
--- a/include/linux/adi-axi-common.h
+++ b/include/linux/adi-axi-common.h
@@ -12,6 +12,8 @@
#define ADI_AXI_COMMON_H_
#define ADI_AXI_REG_VERSION 0x0000
+#define ADI_AXI_REG_FPGA_INFO 0x001C
+#define ADI_AXI_REG_FPGA_VOLTAGE 0x0140
#define ADI_AXI_PCORE_VER(major, minor, patch) \
(((major) << 16) | ((minor) << 8) | (patch))
@@ -20,4 +22,37 @@
#define ADI_AXI_PCORE_VER_MINOR(version) (((version) >> 8) & 0xff)
#define ADI_AXI_PCORE_VER_PATCH(version) ((version) & 0xff)
+#define ADI_AXI_INFO_FPGA_TECH(info) (((info) >> 24) & 0xff)
+#define ADI_AXI_INFO_FPGA_FAMILY(info) (((info) >> 16) & 0xff)
+#define ADI_AXI_INFO_FPGA_SPEED_GRADE(info) (((info) >> 8) & 0xff)
+#define ADI_AXI_INFO_FPGA_VOLTAGE(val) ((val) & 0xffff)
+
+enum adi_axi_fpga_technology {
+ ADI_AXI_FPGA_TECH_UNKNOWN = 0,
+ ADI_AXI_FPGA_TECH_SERIES7,
+ ADI_AXI_FPGA_TECH_ULTRASCALE,
+ ADI_AXI_FPGA_TECH_ULTRASCALE_PLUS,
+};
+
+enum adi_axi_fpga_family {
+ ADI_AXI_FPGA_FAMILY_UNKNOWN = 0,
+ ADI_AXI_FPGA_FAMILY_ARTIX,
+ ADI_AXI_FPGA_FAMILY_KINTEX,
+ ADI_AXI_FPGA_FAMILY_VIRTEX,
+ ADI_AXI_FPGA_FAMILY_ZYNQ,
+};
+
+enum adi_axi_fpga_speed_grade {
+ ADI_AXI_FPGA_SPEED_UNKNOWN = 0,
+ ADI_AXI_FPGA_SPEED_1 = 10,
+ ADI_AXI_FPGA_SPEED_1L = 11,
+ ADI_AXI_FPGA_SPEED_1H = 12,
+ ADI_AXI_FPGA_SPEED_1HV = 13,
+ ADI_AXI_FPGA_SPEED_1LV = 14,
+ ADI_AXI_FPGA_SPEED_2 = 20,
+ ADI_AXI_FPGA_SPEED_2L = 21,
+ ADI_AXI_FPGA_SPEED_2LV = 22,
+ ADI_AXI_FPGA_SPEED_3 = 30,
+};
+
#endif /* ADI_AXI_COMMON_H_ */
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 5/7] clk: clk-axi-clkgen: detect axi_clkgen_limits at runtime
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
` (3 preceding siblings ...)
2025-05-05 16:41 ` [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 6/7] clk: clk-axi-clkgen move to min/max() Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues Nuno Sá via B4 Relay
6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
This patch adds support for setting the limits in struct
axi_clkgen_limits in accordance with fpga speed grade, voltage,
technology and family. This new information is extracted from
two new registers implemented in the ip core that are only available
for core versions higher or equal to 4.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 60 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index 31915f8f5565f2ef5d17c0b4a0c91a648005b3e6..a4cc6e1f0742fb22904c9a4c266198f62ede9c65 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -499,6 +499,54 @@ static u8 axi_clkgen_get_parent(struct clk_hw *clk_hw)
return parent;
}
+static int axi_clkgen_setup_limits(struct axi_clkgen *axi_clkgen,
+ struct device *dev)
+{
+ unsigned int tech, family, speed_grade, reg_value;
+
+ axi_clkgen_read(axi_clkgen, ADI_AXI_REG_FPGA_INFO, ®_value);
+ tech = ADI_AXI_INFO_FPGA_TECH(reg_value);
+ family = ADI_AXI_INFO_FPGA_FAMILY(reg_value);
+ speed_grade = ADI_AXI_INFO_FPGA_SPEED_GRADE(reg_value);
+
+ axi_clkgen->limits.fpfd_min = 10000;
+ axi_clkgen->limits.fvco_min = 600000;
+
+ switch (speed_grade) {
+ case ADI_AXI_FPGA_SPEED_1 ... ADI_AXI_FPGA_SPEED_1LV:
+ axi_clkgen->limits.fvco_max = 1200000;
+ axi_clkgen->limits.fpfd_max = 450000;
+ break;
+ case ADI_AXI_FPGA_SPEED_2 ... ADI_AXI_FPGA_SPEED_2LV:
+ axi_clkgen->limits.fvco_max = 1440000;
+ axi_clkgen->limits.fpfd_max = 500000;
+ if (family == ADI_AXI_FPGA_FAMILY_KINTEX || family == ADI_AXI_FPGA_FAMILY_ARTIX) {
+ axi_clkgen_read(axi_clkgen, ADI_AXI_REG_FPGA_VOLTAGE,
+ ®_value);
+ if (ADI_AXI_INFO_FPGA_VOLTAGE(reg_value) < 950) {
+ axi_clkgen->limits.fvco_max = 1200000;
+ axi_clkgen->limits.fpfd_max = 450000;
+ }
+ }
+ break;
+ case ADI_AXI_FPGA_SPEED_3:
+ axi_clkgen->limits.fvco_max = 1600000;
+ axi_clkgen->limits.fpfd_max = 550000;
+ break;
+ default:
+ return dev_err_probe(dev, -ENODEV, "Unknown speed grade %d\n",
+ speed_grade);
+ };
+
+ /* Overwrite vco limits for ultrascale+ */
+ if (tech == ADI_AXI_FPGA_TECH_ULTRASCALE_PLUS) {
+ axi_clkgen->limits.fvco_max = 1600000;
+ axi_clkgen->limits.fvco_min = 800000;
+ }
+
+ return 0;
+}
+
static const struct clk_ops axi_clkgen_ops = {
.recalc_rate = axi_clkgen_recalc_rate,
.determine_rate = axi_clkgen_determine_rate,
@@ -513,6 +561,7 @@ static int axi_clkgen_probe(struct platform_device *pdev)
{
const struct axi_clkgen_limits *dflt_limits;
struct axi_clkgen *axi_clkgen;
+ unsigned int pcore_version;
struct clk_init_data init;
const char *parent_names[2];
const char *clk_name;
@@ -558,7 +607,16 @@ static int axi_clkgen_probe(struct platform_device *pdev)
return -EINVAL;
}
- memcpy(&axi_clkgen->limits, dflt_limits, sizeof(axi_clkgen->limits));
+ axi_clkgen_read(axi_clkgen, ADI_AXI_REG_VERSION, &pcore_version);
+
+ if (ADI_AXI_PCORE_VER_MAJOR(pcore_version) > 0x04) {
+ ret = axi_clkgen_setup_limits(axi_clkgen, &pdev->dev);
+ if (ret)
+ return ret;
+ } else {
+ memcpy(&axi_clkgen->limits, dflt_limits,
+ sizeof(axi_clkgen->limits));
+ }
clk_name = pdev->dev.of_node->name;
of_property_read_string(pdev->dev.of_node, "clock-output-names",
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 6/7] clk: clk-axi-clkgen move to min/max()
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
` (4 preceding siblings ...)
2025-05-05 16:41 ` [PATCH v4 5/7] clk: clk-axi-clkgen: detect axi_clkgen_limits at runtime Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues Nuno Sá via B4 Relay
6 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
Instead of using the type versions of min/max(), use the plain ones as
now they are perfectly capable of handling different types like
unsigned and non negative integers that are compiletime constant.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index a4cc6e1f0742fb22904c9a4c266198f62ede9c65..d8634d1cb401fff2186702354ecda7b4fcda006f 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -144,15 +144,15 @@ static void axi_clkgen_calc_params(const struct axi_clkgen_limits *limits,
*best_m = 0;
*best_dout = 0;
- d_min = max_t(unsigned long, DIV_ROUND_UP(fin, limits->fpfd_max), 1);
- d_max = min_t(unsigned long, fin / limits->fpfd_min, 80);
+ d_min = max(DIV_ROUND_UP(fin, limits->fpfd_max), 1);
+ d_max = min(fin / limits->fpfd_min, 80);
again:
fvco_min_fract = limits->fvco_min << fract_shift;
fvco_max_fract = limits->fvco_max << fract_shift;
- m_min = max_t(unsigned long, DIV_ROUND_UP(fvco_min_fract, fin) * d_min, 1);
- m_max = min_t(unsigned long, fvco_max_fract * d_max / fin, 64 << fract_shift);
+ m_min = max(DIV_ROUND_UP(fvco_min_fract, fin) * d_min, 1);
+ m_max = min(fvco_max_fract * d_max / fin, 64 << fract_shift);
for (m = m_min; m <= m_max; m++) {
_d_min = max(d_min, DIV_ROUND_UP(fin * m, fvco_max_fract));
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
` (5 preceding siblings ...)
2025-05-05 16:41 ` [PATCH v4 6/7] clk: clk-axi-clkgen move to min/max() Nuno Sá via B4 Relay
@ 2025-05-05 16:41 ` Nuno Sá via B4 Relay
2025-05-05 17:21 ` David Lechner
6 siblings, 1 reply; 14+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-05-05 16:41 UTC (permalink / raw)
To: linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette
From: Nuno Sá <nuno.sa@analog.com>
This is just cosmetics and so no functional changes intended.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/clk/clk-axi-clkgen.c | 74 +++++++++++++++++++++++---------------------
1 file changed, 38 insertions(+), 36 deletions(-)
diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
index d8634d1cb401fff2186702354ecda7b4fcda006f..63b7b7e48f8fa00842ce4cf2112ce7a89fa25dae 100644
--- a/drivers/clk/clk-axi-clkgen.c
+++ b/drivers/clk/clk-axi-clkgen.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/err.h>
+#include <linux/types.h>
#include <linux/adi-axi-common.h>
@@ -93,7 +94,7 @@ static uint32_t axi_clkgen_lookup_filter(unsigned int m)
}
}
-static const uint32_t axi_clkgen_lock_table[] = {
+static const u32 axi_clkgen_lock_table[] = {
0x060603e8, 0x060603e8, 0x080803e8, 0x0b0b03e8,
0x0e0e03e8, 0x111103e8, 0x131303e8, 0x161603e8,
0x191903e8, 0x1c1c03e8, 0x1f1f0384, 0x1f1f0339,
@@ -105,7 +106,7 @@ static const uint32_t axi_clkgen_lock_table[] = {
0x1f1f012c, 0x1f1f0113, 0x1f1f0113, 0x1f1f0113,
};
-static uint32_t axi_clkgen_lookup_lock(unsigned int m)
+static u32 axi_clkgen_lookup_lock(unsigned int m)
{
if (m < ARRAY_SIZE(axi_clkgen_lock_table))
return axi_clkgen_lock_table[m];
@@ -127,8 +128,9 @@ static const struct axi_clkgen_limits axi_clkgen_zynq_default_limits = {
};
static void axi_clkgen_calc_params(const struct axi_clkgen_limits *limits,
- unsigned long fin, unsigned long fout,
- unsigned int *best_d, unsigned int *best_m, unsigned int *best_dout)
+ unsigned long fin, unsigned long fout,
+ unsigned int *best_d, unsigned int *best_m,
+ unsigned int *best_dout)
{
unsigned long d, d_min, d_max, _d_min, _d_max;
unsigned long m, m_min, m_max;
@@ -195,9 +197,9 @@ struct axi_clkgen_div_params {
};
static void axi_clkgen_calc_clk_params(unsigned int divider,
- unsigned int frac_divider, struct axi_clkgen_div_params *params)
+ unsigned int frac_divider,
+ struct axi_clkgen_div_params *params)
{
-
memset(params, 0x0, sizeof(*params));
if (divider == 1) {
@@ -225,7 +227,7 @@ static void axi_clkgen_calc_clk_params(unsigned int divider,
if (params->edge == 0 || frac_divider == 1)
params->low--;
if (((params->edge == 0) ^ (frac_divider == 1)) ||
- (divider == 2 && frac_divider == 1))
+ (divider == 2 && frac_divider == 1))
params->frac_wf_f = 1;
params->frac_phase = params->edge * 4 + frac_divider / 2;
@@ -233,13 +235,13 @@ static void axi_clkgen_calc_clk_params(unsigned int divider,
}
static void axi_clkgen_write(struct axi_clkgen *axi_clkgen,
- unsigned int reg, unsigned int val)
+ unsigned int reg, unsigned int val)
{
writel(val, axi_clkgen->base + reg);
}
static void axi_clkgen_read(struct axi_clkgen *axi_clkgen,
- unsigned int reg, unsigned int *val)
+ unsigned int reg, unsigned int *val)
{
*val = readl(axi_clkgen->base + reg);
}
@@ -260,7 +262,7 @@ static int axi_clkgen_wait_non_busy(struct axi_clkgen *axi_clkgen)
}
static int axi_clkgen_mmcm_read(struct axi_clkgen *axi_clkgen,
- unsigned int reg, unsigned int *val)
+ unsigned int reg, unsigned int *val)
{
unsigned int reg_val;
int ret;
@@ -284,7 +286,8 @@ static int axi_clkgen_mmcm_read(struct axi_clkgen *axi_clkgen,
}
static int axi_clkgen_mmcm_write(struct axi_clkgen *axi_clkgen,
- unsigned int reg, unsigned int val, unsigned int mask)
+ unsigned int reg, unsigned int val,
+ unsigned int mask)
{
unsigned int reg_val = 0;
int ret;
@@ -305,8 +308,7 @@ static int axi_clkgen_mmcm_write(struct axi_clkgen *axi_clkgen,
return 0;
}
-static void axi_clkgen_mmcm_enable(struct axi_clkgen *axi_clkgen,
- bool enable)
+static void axi_clkgen_mmcm_enable(struct axi_clkgen *axi_clkgen, bool enable)
{
unsigned int val = AXI_CLKGEN_V2_RESET_ENABLE;
@@ -322,31 +324,31 @@ static struct axi_clkgen *clk_hw_to_axi_clkgen(struct clk_hw *clk_hw)
}
static void axi_clkgen_set_div(struct axi_clkgen *axi_clkgen,
- unsigned int reg1, unsigned int reg2, unsigned int reg3,
- struct axi_clkgen_div_params *params)
+ unsigned int reg1, unsigned int reg2,
+ unsigned int reg3,
+ struct axi_clkgen_div_params *params)
{
axi_clkgen_mmcm_write(axi_clkgen, reg1,
- (params->high << 6) | params->low, 0xefff);
+ (params->high << 6) | params->low, 0xefff);
axi_clkgen_mmcm_write(axi_clkgen, reg2,
- (params->frac << 12) | (params->frac_en << 11) |
- (params->frac_wf_r << 10) | (params->edge << 7) |
- (params->nocount << 6), 0x7fff);
+ (params->frac << 12) | (params->frac_en << 11) |
+ (params->frac_wf_r << 10) | (params->edge << 7) |
+ (params->nocount << 6), 0x7fff);
if (reg3 != 0) {
axi_clkgen_mmcm_write(axi_clkgen, reg3,
- (params->frac_phase << 11) | (params->frac_wf_f << 10), 0x3c00);
+ (params->frac_phase << 11) | (params->frac_wf_f << 10),
+ 0x3c00);
}
}
-static int axi_clkgen_set_rate(struct clk_hw *clk_hw,
- unsigned long rate, unsigned long parent_rate)
+static int axi_clkgen_set_rate(struct clk_hw *clk_hw, unsigned long rate,
+ unsigned long parent_rate)
{
struct axi_clkgen *axi_clkgen = clk_hw_to_axi_clkgen(clk_hw);
const struct axi_clkgen_limits *limits = &axi_clkgen->limits;
unsigned int d, m, dout;
struct axi_clkgen_div_params params;
- uint32_t power = 0;
- uint32_t filter;
- uint32_t lock;
+ u32 power = 0, filter, lock;
if (parent_rate == 0 || rate == 0)
return -EINVAL;
@@ -366,22 +368,22 @@ static int axi_clkgen_set_rate(struct clk_hw *clk_hw,
axi_clkgen_calc_clk_params(dout >> 3, dout & 0x7, ¶ms);
axi_clkgen_set_div(axi_clkgen, MMCM_REG_CLKOUT0_1, MMCM_REG_CLKOUT0_2,
- MMCM_REG_CLKOUT5_2, ¶ms);
+ MMCM_REG_CLKOUT5_2, ¶ms);
axi_clkgen_calc_clk_params(d, 0, ¶ms);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_CLK_DIV,
- (params.edge << 13) | (params.nocount << 12) |
- (params.high << 6) | params.low, 0x3fff);
+ (params.edge << 13) | (params.nocount << 12) |
+ (params.high << 6) | params.low, 0x3fff);
axi_clkgen_calc_clk_params(m >> 3, m & 0x7, ¶ms);
axi_clkgen_set_div(axi_clkgen, MMCM_REG_CLK_FB1, MMCM_REG_CLK_FB2,
- MMCM_REG_CLKOUT6_2, ¶ms);
+ MMCM_REG_CLKOUT6_2, ¶ms);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_LOCK1, lock & 0x3ff, 0x3ff);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_LOCK2,
- (((lock >> 16) & 0x1f) << 10) | 0x1, 0x7fff);
+ (((lock >> 16) & 0x1f) << 10) | 0x1, 0x7fff);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_LOCK3,
- (((lock >> 24) & 0x1f) << 10) | 0x3e9, 0x7fff);
+ (((lock >> 24) & 0x1f) << 10) | 0x3e9, 0x7fff);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_FILTER1, filter >> 16, 0x9900);
axi_clkgen_mmcm_write(axi_clkgen, MMCM_REG_FILTER2, filter, 0x9900);
@@ -410,7 +412,7 @@ static int axi_clkgen_determine_rate(struct clk_hw *hw,
}
static unsigned int axi_clkgen_get_div(struct axi_clkgen *axi_clkgen,
- unsigned int reg1, unsigned int reg2)
+ unsigned int reg1, unsigned int reg2)
{
unsigned int val1, val2;
unsigned int div;
@@ -437,7 +439,7 @@ static unsigned int axi_clkgen_get_div(struct axi_clkgen *axi_clkgen,
}
static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
- unsigned long parent_rate)
+ unsigned long parent_rate)
{
struct axi_clkgen *axi_clkgen = clk_hw_to_axi_clkgen(clk_hw);
unsigned int d, m, dout;
@@ -445,9 +447,9 @@ static unsigned long axi_clkgen_recalc_rate(struct clk_hw *clk_hw,
unsigned int val;
dout = axi_clkgen_get_div(axi_clkgen, MMCM_REG_CLKOUT0_1,
- MMCM_REG_CLKOUT0_2);
+ MMCM_REG_CLKOUT0_2);
m = axi_clkgen_get_div(axi_clkgen, MMCM_REG_CLK_FB1,
- MMCM_REG_CLK_FB2);
+ MMCM_REG_CLK_FB2);
axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_DIV, &val);
if (val & MMCM_CLK_DIV_NOCOUNT)
@@ -620,7 +622,7 @@ static int axi_clkgen_probe(struct platform_device *pdev)
clk_name = pdev->dev.of_node->name;
of_property_read_string(pdev->dev.of_node, "clock-output-names",
- &clk_name);
+ &clk_name);
init.name = clk_name;
init.ops = &axi_clkgen_ops;
--
2.49.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros
2025-05-05 16:41 ` [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros Nuno Sá via B4 Relay
@ 2025-05-05 17:21 ` David Lechner
2025-05-07 6:11 ` Nuno Sá
0 siblings, 1 reply; 14+ messages in thread
From: David Lechner @ 2025-05-05 17:21 UTC (permalink / raw)
To: nuno.sa, linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, Mark Brown, Mike Turquette
On 5/5/25 11:41 AM, Nuno Sá via B4 Relay wrote:
> From: Nuno Sá <nuno.sa@analog.com>
>
> Add new helper macros and enums to help identifying the platform and some
> characteristics of it at runtime.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> include/linux/adi-axi-common.h | 35 +++++++++++++++++++++++++++++++++++
Since this file was moved in the previous patch, should we drop "fpga:" from the
subject of this patch?
> 1 file changed, 35 insertions(+)
>
> diff --git a/include/linux/adi-axi-common.h b/include/linux/adi-axi-common.h
> index 141ac3f251e6f256526812b9d55cd440a2a46e76..a832ef9b37473ca339a2a2ff8a4a5716d428fd29 100644
> --- a/include/linux/adi-axi-common.h
> +++ b/include/linux/adi-axi-common.h
> @@ -12,6 +12,8 @@
> #define ADI_AXI_COMMON_H_
>
> #define ADI_AXI_REG_VERSION 0x0000
> +#define ADI_AXI_REG_FPGA_INFO 0x001C
> +#define ADI_AXI_REG_FPGA_VOLTAGE 0x0140
Doesn't the voltage register only apply to AXI CLKGEN and therefore would
belong in the clock driver rather than here? 0x1C seems to be the last of the
defined "common to all IP cores" address before we possibly get into
core-specific register definitions starting at 0x40.
I guess there are 1 or 2 other cores that define it at the same place, but it
still seems not-global.
>
> #define ADI_AXI_PCORE_VER(major, minor, patch) \
> (((major) << 16) | ((minor) << 8) | (patch))
> @@ -20,4 +22,37 @@
> #define ADI_AXI_PCORE_VER_MINOR(version) (((version) >> 8) & 0xff)
> #define ADI_AXI_PCORE_VER_PATCH(version) ((version) & 0xff)
>
> +#define ADI_AXI_INFO_FPGA_TECH(info) (((info) >> 24) & 0xff)
> +#define ADI_AXI_INFO_FPGA_FAMILY(info) (((info) >> 16) & 0xff)
> +#define ADI_AXI_INFO_FPGA_SPEED_GRADE(info) (((info) >> 8) & 0xff)
I guess we don't care about the DEV_PACKAGE field?
> +#define ADI_AXI_INFO_FPGA_VOLTAGE(val) ((val) & 0xffff)
This VOLTAGE also goes applies to the first comment.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues
2025-05-05 16:41 ` [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues Nuno Sá via B4 Relay
@ 2025-05-05 17:21 ` David Lechner
2025-05-07 6:08 ` Nuno Sá
0 siblings, 1 reply; 14+ messages in thread
From: David Lechner @ 2025-05-05 17:21 UTC (permalink / raw)
To: nuno.sa, linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, Mark Brown, Mike Turquette
On 5/5/25 11:41 AM, Nuno Sá via B4 Relay wrote:
> From: Nuno Sá <nuno.sa@analog.com>
>
> This is just cosmetics and so no functional changes intended.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> drivers/clk/clk-axi-clkgen.c | 74 +++++++++++++++++++++++---------------------
> 1 file changed, 38 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
> index d8634d1cb401fff2186702354ecda7b4fcda006f..63b7b7e48f8fa00842ce4cf2112ce7a89fa25dae 100644
> --- a/drivers/clk/clk-axi-clkgen.c
> +++ b/drivers/clk/clk-axi-clkgen.c
> @@ -15,6 +15,7 @@
> #include <linux/module.h>
> #include <linux/mod_devicetable.h>
> #include <linux/err.h>
> +#include <linux/types.h>
>
Might as well sort the rest alphabetically while we are cleaning things up.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga
2025-05-05 16:41 ` [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga Nuno Sá via B4 Relay
@ 2025-05-05 18:30 ` Jonathan Cameron
2025-05-07 2:35 ` Xu Yilun
0 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2025-05-05 18:30 UTC (permalink / raw)
To: Nuno Sá via B4 Relay
Cc: nuno.sa, linux-clk, linux-fpga, dmaengine, linux-hwmon, linux-iio,
linux-pwm, linux-spi, Stephen Boyd, Michael Turquette,
Moritz Fischer, Wu Hao, Xu Yilun, Tom Rix, Vinod Koul,
Jean Delvare, Guenter Roeck, Michael Hennerich, Trevor Gamblin,
Uwe Kleine-König, David Lechner, Mark Brown, Mike Turquette,
Xu Yilun
On Mon, 05 May 2025 17:41:34 +0100
Nuno Sá via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
> From: Nuno Sá <nuno.sa@analog.com>
>
> The adi-axi-common.h header has some common defines used in various ADI
> IPs. However they are not specific for any fpga manager so it's
> questionable for the header to live under include/linux/fpga. Hence
> let's just move one directory up and update all users.
>
> Suggested-by: Xu Yilun <yilun.xu@linux.intel.com>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for IIO
> ---
> drivers/clk/clk-axi-clkgen.c | 2 ++
> drivers/dma/dma-axi-dmac.c | 2 +-
> drivers/hwmon/axi-fan-control.c | 2 +-
> drivers/iio/adc/adi-axi-adc.c | 3 +--
> drivers/iio/dac/adi-axi-dac.c | 2 +-
> drivers/pwm/pwm-axi-pwmgen.c | 2 +-
> drivers/spi/spi-axi-spi-engine.c | 2 +-
> include/linux/{fpga => }/adi-axi-common.h | 0
> 8 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
> index 2a95f9b220234a1245024a821c50e1eb9c104ac9..31915f8f5565f2ef5d17c0b4a0c91a648005b3e6 100644
> --- a/drivers/clk/clk-axi-clkgen.c
> +++ b/drivers/clk/clk-axi-clkgen.c
> @@ -16,6 +16,8 @@
> #include <linux/mod_devicetable.h>
> #include <linux/err.h>
>
> +#include <linux/adi-axi-common.h>
> +
> #define AXI_CLKGEN_V2_REG_RESET 0x40
> #define AXI_CLKGEN_V2_REG_CLKSEL 0x44
> #define AXI_CLKGEN_V2_REG_DRP_CNTRL 0x70
> diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> index 36943b0c6d603cbe38606b0d7bde02535f529a9a..5b06b0dc67ee12017c165bf815fb7c0e1bf5abd8 100644
> --- a/drivers/dma/dma-axi-dmac.c
> +++ b/drivers/dma/dma-axi-dmac.c
> @@ -6,6 +6,7 @@
> * Author: Lars-Peter Clausen <lars@metafoo.de>
> */
>
> +#include <linux/adi-axi-common.h>
> #include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/device.h>
> @@ -22,7 +23,6 @@
> #include <linux/platform_device.h>
> #include <linux/regmap.h>
> #include <linux/slab.h>
> -#include <linux/fpga/adi-axi-common.h>
>
> #include <dt-bindings/dma/axi-dmac.h>
>
> diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c
> index 35c862eb158b0909dac64c2e9f51f0f9f0e8bf72..b7bb325c3ad966ed2a93be4dfbf4e20661568509 100644
> --- a/drivers/hwmon/axi-fan-control.c
> +++ b/drivers/hwmon/axi-fan-control.c
> @@ -4,9 +4,9 @@
> *
> * Copyright 2019 Analog Devices Inc.
> */
> +#include <linux/adi-axi-common.h>
> #include <linux/bits.h>
> #include <linux/clk.h>
> -#include <linux/fpga/adi-axi-common.h>
> #include <linux/hwmon.h>
> #include <linux/hwmon-sysfs.h>
> #include <linux/interrupt.h>
> diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
> index c7357601f0f869e57636f00bb1e26c059c3ab15c..87fa18f1ec96782556bdfad08bedb5e7549fb93d 100644
> --- a/drivers/iio/adc/adi-axi-adc.c
> +++ b/drivers/iio/adc/adi-axi-adc.c
> @@ -6,6 +6,7 @@
> * Copyright 2012-2020 Analog Devices Inc.
> */
>
> +#include <linux/adi-axi-common.h>
> #include <linux/bitfield.h>
> #include <linux/cleanup.h>
> #include <linux/clk.h>
> @@ -20,8 +21,6 @@
> #include <linux/regmap.h>
> #include <linux/slab.h>
>
> -#include <linux/fpga/adi-axi-common.h>
> -
> #include <linux/iio/backend.h>
> #include <linux/iio/buffer-dmaengine.h>
> #include <linux/iio/buffer.h>
> diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> index b143f7ed6847277aeb49094627d90e5d95eed71c..581a2fe55a7fb35f1a03f96f3a0e95421d1583e7 100644
> --- a/drivers/iio/dac/adi-axi-dac.c
> +++ b/drivers/iio/dac/adi-axi-dac.c
> @@ -5,6 +5,7 @@
> *
> * Copyright 2016-2024 Analog Devices Inc.
> */
> +#include <linux/adi-axi-common.h>
> #include <linux/bitfield.h>
> #include <linux/bits.h>
> #include <linux/cleanup.h>
> @@ -23,7 +24,6 @@
> #include <linux/regmap.h>
> #include <linux/units.h>
>
> -#include <linux/fpga/adi-axi-common.h>
> #include <linux/iio/backend.h>
> #include <linux/iio/buffer-dmaengine.h>
> #include <linux/iio/buffer.h>
> diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c
> index 4259a0db9ff45808eecae28680473292d165d1f6..e720191e74558d15f1b04fa18cf2984299f88809 100644
> --- a/drivers/pwm/pwm-axi-pwmgen.c
> +++ b/drivers/pwm/pwm-axi-pwmgen.c
> @@ -18,10 +18,10 @@
> * - Supports normal polarity. Does not support changing polarity.
> * - On disable, the PWM output becomes low (inactive).
> */
> +#include <linux/adi-axi-common.h>
> #include <linux/bits.h>
> #include <linux/clk.h>
> #include <linux/err.h>
> -#include <linux/fpga/adi-axi-common.h>
> #include <linux/io.h>
> #include <linux/minmax.h>
> #include <linux/module.h>
> diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
> index 7c252126b33ea83fe6a6e80c6cb87499243069f5..d498132f1ff6adf20639bf4a21f1687903934bec 100644
> --- a/drivers/spi/spi-axi-spi-engine.c
> +++ b/drivers/spi/spi-axi-spi-engine.c
> @@ -5,9 +5,9 @@
> * Author: Lars-Peter Clausen <lars@metafoo.de>
> */
>
> +#include <linux/adi-axi-common.h>
> #include <linux/clk.h>
> #include <linux/completion.h>
> -#include <linux/fpga/adi-axi-common.h>
> #include <linux/interrupt.h>
> #include <linux/io.h>
> #include <linux/of.h>
> diff --git a/include/linux/fpga/adi-axi-common.h b/include/linux/adi-axi-common.h
> similarity index 100%
> rename from include/linux/fpga/adi-axi-common.h
> rename to include/linux/adi-axi-common.h
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga
2025-05-05 18:30 ` Jonathan Cameron
@ 2025-05-07 2:35 ` Xu Yilun
0 siblings, 0 replies; 14+ messages in thread
From: Xu Yilun @ 2025-05-07 2:35 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Nuno Sá via B4 Relay, nuno.sa, linux-clk, linux-fpga,
dmaengine, linux-hwmon, linux-iio, linux-pwm, linux-spi,
Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Trevor Gamblin, Uwe Kleine-König,
David Lechner, Mark Brown, Mike Turquette
On Mon, May 05, 2025 at 07:30:01PM +0100, Jonathan Cameron wrote:
> On Mon, 05 May 2025 17:41:34 +0100
> Nuno Sá via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
>
> > From: Nuno Sá <nuno.sa@analog.com>
> >
> > The adi-axi-common.h header has some common defines used in various ADI
> > IPs. However they are not specific for any fpga manager so it's
> > questionable for the header to live under include/linux/fpga. Hence
> > let's just move one directory up and update all users.
> >
> > Suggested-by: Xu Yilun <yilun.xu@linux.intel.com>
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
>
> Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for IIO
Acked-by: Xu Yilun <yilun.xu@intel.com>
>
> > ---
> > drivers/clk/clk-axi-clkgen.c | 2 ++
> > drivers/dma/dma-axi-dmac.c | 2 +-
> > drivers/hwmon/axi-fan-control.c | 2 +-
> > drivers/iio/adc/adi-axi-adc.c | 3 +--
> > drivers/iio/dac/adi-axi-dac.c | 2 +-
> > drivers/pwm/pwm-axi-pwmgen.c | 2 +-
> > drivers/spi/spi-axi-spi-engine.c | 2 +-
> > include/linux/{fpga => }/adi-axi-common.h | 0
> > 8 files changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
> > index 2a95f9b220234a1245024a821c50e1eb9c104ac9..31915f8f5565f2ef5d17c0b4a0c91a648005b3e6 100644
> > --- a/drivers/clk/clk-axi-clkgen.c
> > +++ b/drivers/clk/clk-axi-clkgen.c
> > @@ -16,6 +16,8 @@
> > #include <linux/mod_devicetable.h>
> > #include <linux/err.h>
> >
> > +#include <linux/adi-axi-common.h>
> > +
> > #define AXI_CLKGEN_V2_REG_RESET 0x40
> > #define AXI_CLKGEN_V2_REG_CLKSEL 0x44
> > #define AXI_CLKGEN_V2_REG_DRP_CNTRL 0x70
> > diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
> > index 36943b0c6d603cbe38606b0d7bde02535f529a9a..5b06b0dc67ee12017c165bf815fb7c0e1bf5abd8 100644
> > --- a/drivers/dma/dma-axi-dmac.c
> > +++ b/drivers/dma/dma-axi-dmac.c
> > @@ -6,6 +6,7 @@
> > * Author: Lars-Peter Clausen <lars@metafoo.de>
> > */
> >
> > +#include <linux/adi-axi-common.h>
> > #include <linux/bitfield.h>
> > #include <linux/clk.h>
> > #include <linux/device.h>
> > @@ -22,7 +23,6 @@
> > #include <linux/platform_device.h>
> > #include <linux/regmap.h>
> > #include <linux/slab.h>
> > -#include <linux/fpga/adi-axi-common.h>
> >
> > #include <dt-bindings/dma/axi-dmac.h>
> >
> > diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c
> > index 35c862eb158b0909dac64c2e9f51f0f9f0e8bf72..b7bb325c3ad966ed2a93be4dfbf4e20661568509 100644
> > --- a/drivers/hwmon/axi-fan-control.c
> > +++ b/drivers/hwmon/axi-fan-control.c
> > @@ -4,9 +4,9 @@
> > *
> > * Copyright 2019 Analog Devices Inc.
> > */
> > +#include <linux/adi-axi-common.h>
> > #include <linux/bits.h>
> > #include <linux/clk.h>
> > -#include <linux/fpga/adi-axi-common.h>
> > #include <linux/hwmon.h>
> > #include <linux/hwmon-sysfs.h>
> > #include <linux/interrupt.h>
> > diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
> > index c7357601f0f869e57636f00bb1e26c059c3ab15c..87fa18f1ec96782556bdfad08bedb5e7549fb93d 100644
> > --- a/drivers/iio/adc/adi-axi-adc.c
> > +++ b/drivers/iio/adc/adi-axi-adc.c
> > @@ -6,6 +6,7 @@
> > * Copyright 2012-2020 Analog Devices Inc.
> > */
> >
> > +#include <linux/adi-axi-common.h>
> > #include <linux/bitfield.h>
> > #include <linux/cleanup.h>
> > #include <linux/clk.h>
> > @@ -20,8 +21,6 @@
> > #include <linux/regmap.h>
> > #include <linux/slab.h>
> >
> > -#include <linux/fpga/adi-axi-common.h>
> > -
> > #include <linux/iio/backend.h>
> > #include <linux/iio/buffer-dmaengine.h>
> > #include <linux/iio/buffer.h>
> > diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> > index b143f7ed6847277aeb49094627d90e5d95eed71c..581a2fe55a7fb35f1a03f96f3a0e95421d1583e7 100644
> > --- a/drivers/iio/dac/adi-axi-dac.c
> > +++ b/drivers/iio/dac/adi-axi-dac.c
> > @@ -5,6 +5,7 @@
> > *
> > * Copyright 2016-2024 Analog Devices Inc.
> > */
> > +#include <linux/adi-axi-common.h>
> > #include <linux/bitfield.h>
> > #include <linux/bits.h>
> > #include <linux/cleanup.h>
> > @@ -23,7 +24,6 @@
> > #include <linux/regmap.h>
> > #include <linux/units.h>
> >
> > -#include <linux/fpga/adi-axi-common.h>
> > #include <linux/iio/backend.h>
> > #include <linux/iio/buffer-dmaengine.h>
> > #include <linux/iio/buffer.h>
> > diff --git a/drivers/pwm/pwm-axi-pwmgen.c b/drivers/pwm/pwm-axi-pwmgen.c
> > index 4259a0db9ff45808eecae28680473292d165d1f6..e720191e74558d15f1b04fa18cf2984299f88809 100644
> > --- a/drivers/pwm/pwm-axi-pwmgen.c
> > +++ b/drivers/pwm/pwm-axi-pwmgen.c
> > @@ -18,10 +18,10 @@
> > * - Supports normal polarity. Does not support changing polarity.
> > * - On disable, the PWM output becomes low (inactive).
> > */
> > +#include <linux/adi-axi-common.h>
> > #include <linux/bits.h>
> > #include <linux/clk.h>
> > #include <linux/err.h>
> > -#include <linux/fpga/adi-axi-common.h>
> > #include <linux/io.h>
> > #include <linux/minmax.h>
> > #include <linux/module.h>
> > diff --git a/drivers/spi/spi-axi-spi-engine.c b/drivers/spi/spi-axi-spi-engine.c
> > index 7c252126b33ea83fe6a6e80c6cb87499243069f5..d498132f1ff6adf20639bf4a21f1687903934bec 100644
> > --- a/drivers/spi/spi-axi-spi-engine.c
> > +++ b/drivers/spi/spi-axi-spi-engine.c
> > @@ -5,9 +5,9 @@
> > * Author: Lars-Peter Clausen <lars@metafoo.de>
> > */
> >
> > +#include <linux/adi-axi-common.h>
> > #include <linux/clk.h>
> > #include <linux/completion.h>
> > -#include <linux/fpga/adi-axi-common.h>
> > #include <linux/interrupt.h>
> > #include <linux/io.h>
> > #include <linux/of.h>
> > diff --git a/include/linux/fpga/adi-axi-common.h b/include/linux/adi-axi-common.h
> > similarity index 100%
> > rename from include/linux/fpga/adi-axi-common.h
> > rename to include/linux/adi-axi-common.h
> >
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues
2025-05-05 17:21 ` David Lechner
@ 2025-05-07 6:08 ` Nuno Sá
0 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá @ 2025-05-07 6:08 UTC (permalink / raw)
To: David Lechner, nuno.sa, linux-clk, linux-fpga, dmaengine,
linux-hwmon, linux-iio, linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, Mark Brown, Mike Turquette
On Mon, 2025-05-05 at 12:21 -0500, David Lechner wrote:
> On 5/5/25 11:41 AM, Nuno Sá via B4 Relay wrote:
> > From: Nuno Sá <nuno.sa@analog.com>
> >
> > This is just cosmetics and so no functional changes intended.
> >
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> > drivers/clk/clk-axi-clkgen.c | 74 +++++++++++++++++++++++---------------------
> > 1 file changed, 38 insertions(+), 36 deletions(-)
> >
> > diff --git a/drivers/clk/clk-axi-clkgen.c b/drivers/clk/clk-axi-clkgen.c
> > index
> > d8634d1cb401fff2186702354ecda7b4fcda006f..63b7b7e48f8fa00842ce4cf2112ce7a89fa25da
> > e 100644
> > --- a/drivers/clk/clk-axi-clkgen.c
> > +++ b/drivers/clk/clk-axi-clkgen.c
> > @@ -15,6 +15,7 @@
> > #include <linux/module.h>
> > #include <linux/mod_devicetable.h>
> > #include <linux/err.h>
> > +#include <linux/types.h>
> >
> Might as well sort the rest alphabetically while we are cleaning things up.
>
Alright, it looks like a v5 might be needed. I can do that
- Nuno Sá
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros
2025-05-05 17:21 ` David Lechner
@ 2025-05-07 6:11 ` Nuno Sá
0 siblings, 0 replies; 14+ messages in thread
From: Nuno Sá @ 2025-05-07 6:11 UTC (permalink / raw)
To: David Lechner, nuno.sa, linux-clk, linux-fpga, dmaengine,
linux-hwmon, linux-iio, linux-pwm, linux-spi
Cc: Stephen Boyd, Michael Turquette, Moritz Fischer, Wu Hao, Xu Yilun,
Tom Rix, Vinod Koul, Jean Delvare, Guenter Roeck,
Michael Hennerich, Jonathan Cameron, Trevor Gamblin,
Uwe Kleine-König, Mark Brown, Mike Turquette
On Mon, 2025-05-05 at 12:21 -0500, David Lechner wrote:
> On 5/5/25 11:41 AM, Nuno Sá via B4 Relay wrote:
> > From: Nuno Sá <nuno.sa@analog.com>
> >
> > Add new helper macros and enums to help identifying the platform and some
> > characteristics of it at runtime.
> >
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> > include/linux/adi-axi-common.h | 35 +++++++++++++++++++++++++++++++++++
>
> Since this file was moved in the previous patch, should we drop "fpga:" from the
> subject of this patch?
sure
>
> > 1 file changed, 35 insertions(+)
> >
> > diff --git a/include/linux/adi-axi-common.h b/include/linux/adi-axi-common.h
> > index
> > 141ac3f251e6f256526812b9d55cd440a2a46e76..a832ef9b37473ca339a2a2ff8a4a5716d428fd2
> > 9 100644
> > --- a/include/linux/adi-axi-common.h
> > +++ b/include/linux/adi-axi-common.h
> > @@ -12,6 +12,8 @@
> > #define ADI_AXI_COMMON_H_
> >
> > #define ADI_AXI_REG_VERSION 0x0000
> > +#define ADI_AXI_REG_FPGA_INFO 0x001C
> > +#define ADI_AXI_REG_FPGA_VOLTAGE 0x0140
>
> Doesn't the voltage register only apply to AXI CLKGEN and therefore would
> belong in the clock driver rather than here? 0x1C seems to be the last of the
> defined "common to all IP cores" address before we possibly get into
> core-specific register definitions starting at 0x40.
>
> I guess there are 1 or 2 other cores that define it at the same place, but it
> still seems not-global.
Hmm, to be honest I did not checked. This patch was out of tree and I blindly pushed
it (as its straightforward). Will drop the above.
>
> >
> > #define ADI_AXI_PCORE_VER(major, minor, patch) \
> > (((major) << 16) | ((minor) << 8) | (patch))
> > @@ -20,4 +22,37 @@
> > #define ADI_AXI_PCORE_VER_MINOR(version) (((version) >> 8) & 0xff)
> > #define ADI_AXI_PCORE_VER_PATCH(version) ((version) & 0xff)
> >
> > +#define ADI_AXI_INFO_FPGA_TECH(info) (((info) >> 24) & 0xff)
> > +#define ADI_AXI_INFO_FPGA_FAMILY(info) (((info) >> 16) & 0xff)
> > +#define ADI_AXI_INFO_FPGA_SPEED_GRADE(info) (((info) >> 8) & 0xff)
>
> I guess we don't care about the DEV_PACKAGE field?
ack
>
> > +#define ADI_AXI_INFO_FPGA_VOLTAGE(val) ((val) & 0xffff)
>
> This VOLTAGE also goes applies to the first comment.
>
ack
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-05-07 7:11 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-05 16:41 [PATCH v4 0/7] clk: clk-axi-clkgen: improvements and some fixes Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 1/7] clk: clk-axi-clkgen: fix fpfd_max frequency for zynq Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 2/7] clk: clk-axi-clkgen: make sure to include mod_devicetable.h Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 3/7] include: linux: move adi-axi-common.h out of fpga Nuno Sá via B4 Relay
2025-05-05 18:30 ` Jonathan Cameron
2025-05-07 2:35 ` Xu Yilun
2025-05-05 16:41 ` [PATCH v4 4/7] include: fpga: adi-axi-common: add new helper macros Nuno Sá via B4 Relay
2025-05-05 17:21 ` David Lechner
2025-05-07 6:11 ` Nuno Sá
2025-05-05 16:41 ` [PATCH v4 5/7] clk: clk-axi-clkgen: detect axi_clkgen_limits at runtime Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 6/7] clk: clk-axi-clkgen move to min/max() Nuno Sá via B4 Relay
2025-05-05 16:41 ` [PATCH v4 7/7] clk: clk-axi-clkgen: fix coding style issues Nuno Sá via B4 Relay
2025-05-05 17:21 ` David Lechner
2025-05-07 6:08 ` Nuno Sá
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).