x86: clk: clk-fch: Enhanced 48Mhz fixed clk support
Subsystems (2)
v3 cover x86: clk: clk-fch: Enhanced 48Mhz fixed clk support
changes since v2:
- Replace config based clock selection with pci root id check
Ajit Kumar Pandey (7):
x86: clk: Add check for PCI root port for fch fixed clk support
drivers: acpi: acpi_apd: Remove unused device property "is-rv"
ACPI: APD: Add a fmw property clk-name
clk: x86: Use dynamic con_id string during clk registration
clk: x86: Fix clk_gate_flags for RV_CLK_GATE
drivers: x86: clk-fch: Add 48MHz fixed clk support on Renoir platform
drivers: x86: clk-fch: Add 48MHz fixed clk support on Stoneyridge
drivers/acpi/acpi_apd.c | 11 +++++-- drivers/clk/x86/clk-fch.c | 45 +++++++++++++++++++++------ include/linux/platform_data/clk-fch.h | 2 +- 3 files changed, 45 insertions(+), 13 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/7 x86: clk: Add check for PCI root port for fch fixed clk support
FCH controller clock configuration slightly differs across AMD's SOC architectures. Newer family of SOC only support a 48MHz fixed clock while older family has a clk_mux to choose 48MHz and 25MHz. 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 architecture.
Add pci_device_id table with Raven platform id and replace "is-rv" device property check with pci id match to support 48MHz fixed clk support. This enhanced flexibility to enable fixed 48MHz fch clock framework on other architectures by simply adding new entries into pci_device_id table. Also replace RV with FIXED as generic naming convention across all platforms.
--- drivers/clk/x86/clk-fch.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
drivers/clk/x86/clk-fch.c +29 -8
@@ -8,6 +8,7 @@#include <linux/clk.h> #include <linux/clkdev.h> #include <linux/clk-provider.h> +#include <linux/pci.h> #include <linux/platform_data/clk-fch.h> #include <linux/platform_device.h>
@@ -26,22 +27,37 @@#define ST_CLK_GATE 3#define ST_MAX_CLKS 4 -#define RV_CLK_48M 0 -#define RV_CLK_GATE 1 -#define RV_MAX_CLKS 2 +#define CLK_48M_FIXED 0 +#define CLK_GATE_FIXED 1 +#define CLK_MAX_FIXED 2 + +/* List of supported CPU ids for fixed clk */ +#define AMD_CPU_ID_RV 0x15D0static const char *const clk_oscout1_parents[] = {"clk48MHz" ,"clk25MHz" };static struct clk_hw *hws[ST_MAX_CLKS ]; +static const struct pci_device_id fch_pci_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_RV ) }, + { } +}; +static int fch_clk_probe (struct platform_device *pdev) {struct fch_clk_data *fch_data; +struct pci_dev *fch_dev; fch_data =dev_get_platdata (&pdev->dev);if (!fch_data || !fch_data->base)return -EINVAL ; -if (!fch_data->is_rv) { + fch_dev =pci_get_domain_bus_and_slot (0 ,0 ,PCI_DEVFN (0 ,0 )); +if (!fch_dev) { +dev_err (&pdev->dev,"FCH device not found\n" ); +return -ENODEV ; + } + +if (!pci_match_id (fch_pci_ids, fch_dev)) { hws[ST_CLK_48M ] =clk_hw_register_fixed_rate (NULL ,"clk48MHz" ,NULL ,0 ,48000000 ); hws[ST_CLK_25M] = clk_hw_register_fixed_rate(NULL, "clk25MHz",
@@ -61,14 +77,14 @@ static int fch_clk_probe(struct platform_device *pdev)devm_clk_hw_register_clkdev (&pdev->dev, hws[ST_CLK_GATE ],"oscout1" ,NULL ); }else { - hws[RV_CLK_48M ] =clk_hw_register_fixed_rate (NULL ,"clk48MHz" , + hws[CLK_48M_FIXED ] =clk_hw_register_fixed_rate (NULL ,"clk48MHz" ,NULL ,0 ,48000000 ); - hws[RV_CLK_GATE ] =clk_hw_register_gate (NULL ,"oscout1" , + hws[CLK_GATE_FIXED ] =clk_hw_register_gate (NULL ,"oscout1" ,"clk48MHz" ,0 , fch_data->base +MISCCLKCNTL1 ,OSCCLKENB ,CLK_GATE_SET_TO_DISABLE ,NULL ); -devm_clk_hw_register_clkdev (&pdev->dev, hws[RV_CLK_GATE ], +devm_clk_hw_register_clkdev (&pdev->dev, hws[CLK_GATE_FIXED ],"oscout1" ,NULL ); }
@@ -79,10 +95,15 @@ static int fch_clk_remove(struct platform_device *pdev) {int i, clks;struct fch_clk_data *fch_data; +struct pci_dev *fch_dev; fch_data =dev_get_platdata (&pdev->dev); - clks = fch_data->is_rv ?RV_MAX_CLKS :ST_MAX_CLKS ; + fch_dev =pci_get_domain_bus_and_slot (0 ,0 ,PCI_DEVFN (0 ,0 )); +if (!fch_dev) +return -ENODEV ; + + clks =pci_match_id (fch_pci_ids, fch_dev) ?CLK_MAX_FIXED :ST_MAX_CLKS ;for (i =0 ; i < clks; i++)clk_hw_unregister (hws[i]);
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH v3 1/7] x86: clk: Add check for PCI root port for fch fixed clk support
Thank you for the patch! Perhaps something to improve:
Hi Ajit,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on clk/clk-next]
[also build test WARNING on rafael-pm/linux-next linus/master v5.16-rc2 next-20211125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Ajit-Kumar-Pandey/x86-clk-clk-fch-Enhanced-48Mhz-fixed-clk-support/20211125-142523 base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20211125/202111252001.0psIb0sd-lkp(a)intel.com/config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/ad72f6072b56c2ad466eef386eca2d1a8ba48e2d git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Ajit-Kumar-Pandey/x86-clk-clk-fch-Enhanced-48Mhz-fixed-clk-support/20211125-142523 git checkout ad72f6072b56c2ad466eef386eca2d1a8ba48e2d # save the config file to linux build tree make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/clk/x86/clk-fch.c: In function 'fch_clk_remove':
>> drivers/clk/x86/clk-fch.c:97:23: warning: variable 'fch_data' set but not used [-Wunused-but-set-variable]
97 | struct fch_clk_data *fch_data;
| ^~~~~~~~vim +/fch_data +97 drivers/clk/x86/clk-fch.c
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 93
d9b77361c1a5155 drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 94 static int fch_clk_remove(struct platform_device *pdev)
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 95 {
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 96 int i, clks;
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 @97 struct fch_clk_data *fch_data;
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 98 struct pci_dev *fch_dev;
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 99
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 100 fch_data = dev_get_platdata(&pdev->dev);
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 101
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 102 fch_dev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 103 if (!fch_dev)
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 104 return -ENODEV;
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 105
ad72f6072b56c2a drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-11-25 106 clks = pci_match_id(fch_pci_ids, fch_dev) ? CLK_MAX_FIXED : ST_MAX_CLKS;
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 107
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 108 for (i = 0; i < clks; i++)
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 109 clk_hw_unregister(hws[i]);
19fe87fd854a92c drivers/clk/x86/clk-fch.c Akshu Agrawal 2020-07-31 110
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 111 return 0;
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 112 }
421bf6a1f061a6e drivers/clk/x86/clk-st.c Akshu Agrawal 2018-05-09 113 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
PATCH v3 2/7 drivers: acpi: acpi_apd: Remove unused device property "is-rv"
In reply to Ajit Kumar PandeyInitially "is-rv" device property is added for 48MHz fixed clock support on Raven or RV architecture. It's unused now as we moved to pci device_id based selection to extend such support on other architectures. This change removed unused code from acpi driver.
--- drivers/acpi/acpi_apd.c | 3 --- include/linux/platform_data/clk-fch.h | 1 - 2 files changed, 4 deletions(-)
drivers/acpi/acpi_apd.c +0 -3
@@ -87,9 +87,6 @@ static int fch_misc_setup(struct apd_private_data *pdata)if (ret <0 )return -ENOENT ; -if (!acpi_dev_get_property (adev,"is-rv" ,ACPI_TYPE_INTEGER , &obj)) - clk_data->is_rv = obj->integer.value; -list_for_each_entry (rentry, &resource_list, node) { clk_data->base =devm_ioremap (&adev->dev, rentry->res->start,resource_size (rentry->res));
include/linux/platform_data/clk-fch.h +0 -1
@@ -12,7 +12,6 @@struct fch_clk_data {void __iomem *base; -u32 is_rv; };#endif /* __CLK_FCH_H */
Signature · 1 line
2.25.1
PATCH v3 3/7 ACPI: APD: Add a fmw property clk-name
In reply to Ajit Kumar PandeyAdd a new device property to fetch clk-name from firmware.
--- drivers/acpi/acpi_apd.c | 10 ++++++++++ include/linux/platform_data/clk-fch.h | 1 + 2 files changed, 11 insertions(+)
drivers/acpi/acpi_apd.c +10 -0
@@ -87,6 +87,16 @@ static int fch_misc_setup(struct apd_private_data *pdata)if (ret <0 )return -ENOENT ; +if (!acpi_dev_get_property (adev,"clk-name" ,ACPI_TYPE_STRING , &obj)) { + clk_data->name =devm_kzalloc (&adev->dev, obj->string.length, +GFP_KERNEL ); + +strcpy (clk_data->name, obj->string.pointer); + }else { +/* Set default name to mclk if entry missing in firmware */ + clk_data->name ="mclk" ; + } +list_for_each_entry (rentry, &resource_list, node) { clk_data->base =devm_ioremap (&adev->dev, rentry->res->start,resource_size (rentry->res));
include/linux/platform_data/clk-fch.h +1 -0
@@ -12,6 +12,7 @@struct fch_clk_data {void __iomem *base; +char *name; };#endif /* __CLK_FCH_H */
Signature · 1 line
2.25.1
PATCH v3 4/7 clk: x86: Use dynamic con_id string during clk registration
In reply to Ajit Kumar PandeyReplace hard coded con_id string with fch_data->name. We have clk consumers looking up with different clock names, hence use dynamic con_id string during clk lookup registration. fch_data->name will be initialized in acpi driver based on fmw property value.
--- drivers/clk/x86/clk-fch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/x86/clk-fch.c +1 -1
@@ -85,7 +85,7 @@ static int fch_clk_probe(struct platform_device *pdev) OSCCLKENB, CLK_GATE_SET_TO_DISABLE, NULL);devm_clk_hw_register_clkdev (&pdev->dev, hws[CLK_GATE_FIXED ], -"oscout1" ,NULL ); + fch_data->name,NULL ); }return 0 ;
Signature · 1 line
2.25.1
PATCH v3 5/7 clk: x86: Fix clk_gate_flags for RV_CLK_GATE
In reply to Ajit Kumar PandeyIn newer SoC we have to clear bit for disabling 48MHz oscillator clock gate. Remove CLK_GATE_SET_TO_DISABLE flag for proper enable and disable of 48MHz clock.
--- drivers/clk/x86/clk-fch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/x86/clk-fch.c +1 -1
@@ -82,7 +82,7 @@ static int fch_clk_probe(struct platform_device *pdev) hws[CLK_GATE_FIXED ] =clk_hw_register_gate (NULL ,"oscout1" ,"clk48MHz" ,0 , fch_data->base +MISCCLKCNTL1 , -OSCCLKENB ,CLK_GATE_SET_TO_DISABLE ,NULL ); +OSCCLKENB ,0 ,NULL );devm_clk_hw_register_clkdev (&pdev->dev, hws[CLK_GATE_FIXED ], fch_data->name,NULL );
Signature · 1 line
2.25.1
PATCH v3 6/7 drivers: x86: clk-fch: Add 48MHz fixed clk support on Renoir platform
In reply to Ajit Kumar PandeyAdd renoir SOC pci root port id into pci_device_id table to enable 48 MHz fixed fch clock support on renoir platforms.
--- drivers/clk/x86/clk-fch.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/x86/clk-fch.c +2 -0
@@ -33,12 +33,14 @@/* List of supported CPU ids for fixed clk */ #define AMD_CPU_ID_RV 0x15D0 +#define AMD_CPU_ID_RN 0x1630static const char *const clk_oscout1_parents[] = {"clk48MHz" ,"clk25MHz" };static struct clk_hw *hws[ST_MAX_CLKS ];static const struct pci_device_id fch_pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_RV ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_RN ) }, { } };
Signature · 1 line
2.25.1
PATCH v3 7/7 drivers: x86: clk-fch: Add 48MHz fixed clk support on Stoneyridge
In reply to Ajit Kumar PandeyAdd stoney ridge SOC pci root port id into pci_device_id table to enable 48 MHz fixed fch clock support on Stoneyridge platforms.
--- drivers/clk/x86/clk-fch.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/x86/clk-fch.c +2 -0
@@ -34,6 +34,7 @@/* List of supported CPU ids for fixed clk */ #define AMD_CPU_ID_RV 0x15D0#define AMD_CPU_ID_RN 0x1630 +#define AMD_CPU_ID_ST 0x1576static const char *const clk_oscout1_parents[] = {"clk48MHz" ,"clk25MHz" };static struct clk_hw *hws[ST_MAX_CLKS ];
@@ -41,6 +42,7 @@ static struct clk_hw *hws[ST_MAX_CLKS];static const struct pci_device_id fch_pci_ids[] = { {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_RV ) }, {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_RN ) }, + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,AMD_CPU_ID_ST ) }, { } };
Signature · 1 line
2.25.1