]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: sparx5: change frequency calculation for SDLB's
authorDaniel Machon <daniel.machon@microchip.com>
Wed, 23 Oct 2024 22:01:22 +0000 (00:01 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 31 Oct 2024 01:08:05 +0000 (18:08 -0700)
In preparation for lan969x, rework the function that calculates the SDLB
(Service Dual Leacky Bucket) clock. This is required, as the
HSCH_SYS_CLK_PER register is Sparx5-exclusive. Instead derive the clock
from the core clock, using the sparx5_clk_period() function. The clock
stays the same before and after this patch, only now,
sparx5_sdlb_clk_hz_get() can be used for lan969x too.

Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Link: https://patch.msgid.link/20241024-sparx5-lan969x-switch-driver-2-v2-3-a0b5fae88a0f@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/sparx5/sparx5_main.h
drivers/net/ethernet/microchip/sparx5/sparx5_sdlb.c

index f117cf65cf8ca102a11279c8dedaa5e2fb00c5c5..2a3b4e855590b8acb92f0df5ef452ba9b17beb2c 100644 (file)
@@ -552,7 +552,7 @@ struct sparx5_sdlb_group *sparx5_get_sdlb_group(int idx);
 int sparx5_sdlb_pup_token_get(struct sparx5 *sparx5, u32 pup_interval,
                              u64 rate);
 
-int sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5);
+u64 sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5);
 int sparx5_sdlb_group_get_by_rate(struct sparx5 *sparx5, u32 rate, u32 burst);
 int sparx5_sdlb_group_get_by_index(struct sparx5 *sparx5, u32 idx, u32 *group);
 
index df1d15600aad05eb4a25d2d61c073b41fe5325f3..98a3f44c569c98008f67d31a7f39120342445e91 100644 (file)
@@ -25,17 +25,13 @@ struct sparx5_sdlb_group *sparx5_get_sdlb_group(int idx)
        return &sdlb_groups[idx];
 }
 
-int sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5)
+u64 sparx5_sdlb_clk_hz_get(struct sparx5 *sparx5)
 {
-       u32 clk_per_100ps;
        u64 clk_hz;
 
-       clk_per_100ps = HSCH_SYS_CLK_PER_100PS_GET(spx5_rd(sparx5,
-                                                          HSCH_SYS_CLK_PER));
-       if (!clk_per_100ps)
-               clk_per_100ps = SPX5_CLK_PER_100PS_DEFAULT;
+       clk_hz = (10 * 1000 * 1000) /
+                (sparx5_clk_period(sparx5->coreclock) / 100);
 
-       clk_hz = (10 * 1000 * 1000) / clk_per_100ps;
        return clk_hz *= 1000;
 }