linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk
@ 2021-10-11  4:45 Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 2/5] drivers: acpi: acpi_apd: Remove unused device property "is-rv" Ajit Kumar Pandey
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ajit Kumar Pandey @ 2021-10-11  4:45 UTC (permalink / raw)
  To: sboyd, linux-clk
  Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Alexander.Deucher, Ajit Kumar Pandey, Michael Turquette,
	Stephen Boyd, open list

At present 48MHz 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 Kernel config option to enable 48MHz fixed clk gate registration
with clock framework. This enahanced flexibility to enable 48MHz fch
clock support on any platforms by simply enabling kernel config. Also
replace RV with FIXED as generic naming convention across platforms.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
---
 drivers/clk/x86/Kconfig   |  5 +++++
 drivers/clk/x86/clk-fch.c | 19 +++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/clk/x86/Kconfig b/drivers/clk/x86/Kconfig
index 69642e15fcc1..c10081774cd6 100644
--- a/drivers/clk/x86/Kconfig
+++ b/drivers/clk/x86/Kconfig
@@ -6,3 +6,8 @@ config CLK_LGM_CGU
 	help
 	  Clock Generation Unit(CGU) driver for Intel Lightning Mountain(LGM)
 	  network processor SoC.
+
+config CLK_FIXED_FCH
+	bool "AMD FCH controller fixed 48MHz CLK support"
+	help
+	  Enable this option for 48MHz fixed mclk support on AMD platforms.
diff --git a/drivers/clk/x86/clk-fch.c b/drivers/clk/x86/clk-fch.c
index 8f7c5142b0f0..a95c3ffa79da 100644
--- a/drivers/clk/x86/clk-fch.c
+++ b/drivers/clk/x86/clk-fch.c
@@ -26,9 +26,9 @@
 #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
 
 static const char * const clk_oscout1_parents[] = { "clk48MHz", "clk25MHz" };
 static struct clk_hw *hws[ST_MAX_CLKS];
@@ -41,7 +41,7 @@ static int fch_clk_probe(struct platform_device *pdev)
 	if (!fch_data || !fch_data->base)
 		return -EINVAL;
 
-	if (!fch_data->is_rv) {
+	if (!IS_ENABLED(CONFIG_CLK_FIXED_FCH)) {
 		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 +61,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);
 	}
 
@@ -82,7 +82,10 @@ static int fch_clk_remove(struct platform_device *pdev)
 
 	fch_data = dev_get_platdata(&pdev->dev);
 
-	clks = fch_data->is_rv ? RV_MAX_CLKS : ST_MAX_CLKS;
+	clks = ST_MAX_CLKS;
+
+	if (IS_ENABLED(CONFIG_CLK_FIXED_FCH))
+		clks = CLK_MAX_FIXED;
 
 	for (i = 0; i < clks; i++)
 		clk_hw_unregister(hws[i]);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] drivers: acpi: acpi_apd: Remove unused device property "is-rv"
  2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
@ 2021-10-11  4:45 ` Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 3/5] ACPI: APD: Add a fmw property clk-name Ajit Kumar Pandey
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ajit Kumar Pandey @ 2021-10-11  4:45 UTC (permalink / raw)
  To: sboyd, linux-clk
  Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Alexander.Deucher, Ajit Kumar Pandey, Rafael J. Wysocki,
	Len Brown, open list:ACPI, open list

Initially "is-rv" device property is added for 48MHz fixed clock
support on Raven or RV architecture. It's unused now as we moved
to clock config based selection to extend such support on others
architecture. This change removed unused code from acpi driver.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
---
 drivers/acpi/acpi_apd.c               | 3 ---
 include/linux/platform_data/clk-fch.h | 1 -
 2 files changed, 4 deletions(-)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 6e02448d15d9..6913e9712852 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -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));
diff --git a/include/linux/platform_data/clk-fch.h b/include/linux/platform_data/clk-fch.h
index b9f682459f08..850ca776156d 100644
--- a/include/linux/platform_data/clk-fch.h
+++ b/include/linux/platform_data/clk-fch.h
@@ -12,7 +12,6 @@
 
 struct fch_clk_data {
 	void __iomem *base;
-	u32 is_rv;
 };
 
 #endif /* __CLK_FCH_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] ACPI: APD: Add a fmw property clk-name
  2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 2/5] drivers: acpi: acpi_apd: Remove unused device property "is-rv" Ajit Kumar Pandey
@ 2021-10-11  4:45 ` Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 4/5] clk: x86: Use dynamic con_id string during clk registration Ajit Kumar Pandey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ajit Kumar Pandey @ 2021-10-11  4:45 UTC (permalink / raw)
  To: sboyd, linux-clk
  Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Alexander.Deucher, Ajit Kumar Pandey, Rafael J. Wysocki,
	Len Brown, open list:ACPI, open list

Add a new device property to fetch clk-name from firmware.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
---
 drivers/acpi/acpi_apd.c               | 10 ++++++++++
 include/linux/platform_data/clk-fch.h |  1 +
 2 files changed, 11 insertions(+)

diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 6913e9712852..2b958b426b03 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -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));
diff --git a/include/linux/platform_data/clk-fch.h b/include/linux/platform_data/clk-fch.h
index 850ca776156d..11a2a23fd9b2 100644
--- a/include/linux/platform_data/clk-fch.h
+++ b/include/linux/platform_data/clk-fch.h
@@ -12,6 +12,7 @@
 
 struct fch_clk_data {
 	void __iomem *base;
+	char *name;
 };
 
 #endif /* __CLK_FCH_H */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] clk: x86: Use dynamic con_id string during clk registration
  2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 2/5] drivers: acpi: acpi_apd: Remove unused device property "is-rv" Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 3/5] ACPI: APD: Add a fmw property clk-name Ajit Kumar Pandey
@ 2021-10-11  4:45 ` Ajit Kumar Pandey
  2021-10-11  4:45 ` [PATCH 5/5] clk: x86: Fix clk_gate_flags for RV_CLK_GATE Ajit Kumar Pandey
  2021-10-11 19:21 ` [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk kernel test robot
  4 siblings, 0 replies; 6+ messages in thread
From: Ajit Kumar Pandey @ 2021-10-11  4:45 UTC (permalink / raw)
  To: sboyd, linux-clk
  Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Alexander.Deucher, Ajit Kumar Pandey, Michael Turquette,
	Stephen Boyd, open list

Replace 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.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
---
 drivers/clk/x86/clk-fch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/x86/clk-fch.c b/drivers/clk/x86/clk-fch.c
index a95c3ffa79da..9fcf452e28d6 100644
--- a/drivers/clk/x86/clk-fch.c
+++ b/drivers/clk/x86/clk-fch.c
@@ -69,7 +69,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;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] clk: x86: Fix clk_gate_flags for RV_CLK_GATE
  2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
                   ` (2 preceding siblings ...)
  2021-10-11  4:45 ` [PATCH 4/5] clk: x86: Use dynamic con_id string during clk registration Ajit Kumar Pandey
@ 2021-10-11  4:45 ` Ajit Kumar Pandey
  2021-10-11 19:21 ` [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk kernel test robot
  4 siblings, 0 replies; 6+ messages in thread
From: Ajit Kumar Pandey @ 2021-10-11  4:45 UTC (permalink / raw)
  To: sboyd, linux-clk
  Cc: Vijendar.Mukunda, Basavaraj.Hiregoudar, Sunil-kumar.Dommati,
	Alexander.Deucher, Ajit Kumar Pandey, Michael Turquette,
	Stephen Boyd, open list

In AMD's 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.

Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
---
 drivers/clk/x86/clk-fch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/x86/clk-fch.c b/drivers/clk/x86/clk-fch.c
index 9fcf452e28d6..7279f592012e 100644
--- a/drivers/clk/x86/clk-fch.c
+++ b/drivers/clk/x86/clk-fch.c
@@ -66,7 +66,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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk
  2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
                   ` (3 preceding siblings ...)
  2021-10-11  4:45 ` [PATCH 5/5] clk: x86: Fix clk_gate_flags for RV_CLK_GATE Ajit Kumar Pandey
@ 2021-10-11 19:21 ` kernel test robot
  4 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2021-10-11 19:21 UTC (permalink / raw)
  To: Ajit Kumar Pandey, sboyd, linux-clk
  Cc: kbuild-all, Vijendar.Mukunda, Basavaraj.Hiregoudar,
	Sunil-kumar.Dommati, Alexander.Deucher, Ajit Kumar Pandey,
	Michael Turquette, Stephen Boyd, open list

[-- Attachment #1: Type: text/plain, Size: 3498 bytes --]

Hi Ajit,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on clk/clk-next]
[also build test ERROR on rafael-pm/linux-next linus/master v5.15-rc5 next-20211011]
[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-Add-config-option-to-enable-48MHz-fixed-fch-clk/20211011-124732
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: i386-allyesconfig (attached as .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/f33c19d1cd863fd12fff7433a6bb22a2b0e22dfe
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ajit-Kumar-Pandey/x86-clk-Add-config-option-to-enable-48MHz-fixed-fch-clk/20211011-124732
        git checkout f33c19d1cd863fd12fff7433a6bb22a2b0e22dfe
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/clk/x86/clk-fch.c: In function 'fch_clk_remove':
>> drivers/clk/x86/clk-fch.c:81:23: error: variable 'fch_data' set but not used [-Werror=unused-but-set-variable]
      81 |  struct fch_clk_data *fch_data;
         |                       ^~~~~~~~
   cc1: all warnings being treated as errors


vim +/fch_data +81 drivers/clk/x86/clk-fch.c

421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  77  
d9b77361c1a515 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  78  static int fch_clk_remove(struct platform_device *pdev)
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  79  {
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  80  	int i, clks;
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31 @81  	struct fch_clk_data *fch_data;
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  82  
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  83  	fch_data = dev_get_platdata(&pdev->dev);
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  84  
f33c19d1cd863f drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-10-11  85  	clks = ST_MAX_CLKS;
f33c19d1cd863f drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-10-11  86  
f33c19d1cd863f drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-10-11  87  	if (IS_ENABLED(CONFIG_CLK_FIXED_FCH))
f33c19d1cd863f drivers/clk/x86/clk-fch.c Ajit Kumar Pandey 2021-10-11  88  		clks = CLK_MAX_FIXED;
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  89  
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  90  	for (i = 0; i < clks; i++)
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  91  		clk_hw_unregister(hws[i]);
19fe87fd854a92 drivers/clk/x86/clk-fch.c Akshu Agrawal     2020-07-31  92  
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  93  	return 0;
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  94  }
421bf6a1f061a6 drivers/clk/x86/clk-st.c  Akshu Agrawal     2018-05-09  95  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66028 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-11 19:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11  4:45 [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk Ajit Kumar Pandey
2021-10-11  4:45 ` [PATCH 2/5] drivers: acpi: acpi_apd: Remove unused device property "is-rv" Ajit Kumar Pandey
2021-10-11  4:45 ` [PATCH 3/5] ACPI: APD: Add a fmw property clk-name Ajit Kumar Pandey
2021-10-11  4:45 ` [PATCH 4/5] clk: x86: Use dynamic con_id string during clk registration Ajit Kumar Pandey
2021-10-11  4:45 ` [PATCH 5/5] clk: x86: Fix clk_gate_flags for RV_CLK_GATE Ajit Kumar Pandey
2021-10-11 19:21 ` [PATCH 1/5] x86: clk: Add config option to enable 48MHz fixed fch clk kernel test robot

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).