Skip to content

Commit 65ab884

Browse files
ajitkupandeybebarino
authored andcommitted
x86: clk: clk-fch: Add support for newer family of AMD's SOC
FCH controller clock configuration slightly differs across AMD's SOC architectures. Newer family of SOC only support a 48MHz fix clock while stoney SOC family has a clk_mux to choose 48MHz and 25 MHz clk. At present fixed clk support is only enabled for RV architecture using "is-rv" device property initialized from boot loader. This limit 48MHz fixed clock gate support to RV platform unless we add similar device property in boot loader for other architectures. Add pci_device_id table with Stoney platform id and replace "is-rv" device property check with pci id match to add clk mux support with 25MHz and 48MHz clk support based on clk mux selection. This enable 48Mhz fixed fch clock support by default on all newer SOC's except stoney. Also replace RV with FIXED as a generic naming conventions across all platforms and changed module description. Signed-off-by: Ajit Kumar Pandey <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent ff5f87c commit 65ab884

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

drivers/clk/x86/clk-fch.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
/*
3-
* clock framework for AMD Stoney based clocks
3+
* clock framework for AMD FCH controller block
44
*
55
* Copyright 2018 Advanced Micro Devices, Inc.
66
*/
77

88
#include <linux/clk.h>
99
#include <linux/clkdev.h>
1010
#include <linux/clk-provider.h>
11+
#include <linux/pci.h>
1112
#include <linux/platform_data/clk-fch.h>
1213
#include <linux/platform_device.h>
1314

@@ -26,22 +27,37 @@
2627
#define ST_CLK_GATE 3
2728
#define ST_MAX_CLKS 4
2829

29-
#define RV_CLK_48M 0
30-
#define RV_CLK_GATE 1
31-
#define RV_MAX_CLKS 2
30+
#define CLK_48M_FIXED 0
31+
#define CLK_GATE_FIXED 1
32+
#define CLK_MAX_FIXED 2
33+
34+
/* List of supported CPU ids for clk mux with 25Mhz clk support */
35+
#define AMD_CPU_ID_ST 0x1576
3236

3337
static const char * const clk_oscout1_parents[] = { "clk48MHz", "clk25MHz" };
3438
static struct clk_hw *hws[ST_MAX_CLKS];
3539

40+
static const struct pci_device_id fch_pci_ids[] = {
41+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_ST) },
42+
{ }
43+
};
44+
3645
static int fch_clk_probe(struct platform_device *pdev)
3746
{
3847
struct fch_clk_data *fch_data;
48+
struct pci_dev *rdev;
3949

4050
fch_data = dev_get_platdata(&pdev->dev);
4151
if (!fch_data || !fch_data->base)
4252
return -EINVAL;
4353

44-
if (!fch_data->is_rv) {
54+
rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
55+
if (!rdev) {
56+
dev_err(&pdev->dev, "FCH device not found\n");
57+
return -ENODEV;
58+
}
59+
60+
if (pci_match_id(fch_pci_ids, rdev)) {
4561
hws[ST_CLK_48M] = clk_hw_register_fixed_rate(NULL, "clk48MHz",
4662
NULL, 0, 48000000);
4763
hws[ST_CLK_25M] = clk_hw_register_fixed_rate(NULL, "clk25MHz",
@@ -61,32 +77,36 @@ static int fch_clk_probe(struct platform_device *pdev)
6177
devm_clk_hw_register_clkdev(&pdev->dev, hws[ST_CLK_GATE],
6278
"oscout1", NULL);
6379
} else {
64-
hws[RV_CLK_48M] = clk_hw_register_fixed_rate(NULL, "clk48MHz",
80+
hws[CLK_48M_FIXED] = clk_hw_register_fixed_rate(NULL, "clk48MHz",
6581
NULL, 0, 48000000);
6682

67-
hws[RV_CLK_GATE] = clk_hw_register_gate(NULL, "oscout1",
83+
hws[CLK_GATE_FIXED] = clk_hw_register_gate(NULL, "oscout1",
6884
"clk48MHz", 0, fch_data->base + MISCCLKCNTL1,
6985
OSCCLKENB, CLK_GATE_SET_TO_DISABLE, NULL);
7086

71-
devm_clk_hw_register_clkdev(&pdev->dev, hws[RV_CLK_GATE],
87+
devm_clk_hw_register_clkdev(&pdev->dev, hws[CLK_GATE_FIXED],
7288
"oscout1", NULL);
7389
}
7490

91+
pci_dev_put(rdev);
7592
return 0;
7693
}
7794

7895
static int fch_clk_remove(struct platform_device *pdev)
7996
{
8097
int i, clks;
81-
struct fch_clk_data *fch_data;
98+
struct pci_dev *rdev;
8299

83-
fch_data = dev_get_platdata(&pdev->dev);
100+
rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
101+
if (!rdev)
102+
return -ENODEV;
84103

85-
clks = fch_data->is_rv ? RV_MAX_CLKS : ST_MAX_CLKS;
104+
clks = pci_match_id(fch_pci_ids, rdev) ? CLK_MAX_FIXED : ST_MAX_CLKS;
86105

87106
for (i = 0; i < clks; i++)
88107
clk_hw_unregister(hws[i]);
89108

109+
pci_dev_put(rdev);
90110
return 0;
91111
}
92112

0 commit comments

Comments
 (0)