Skip to contentSkip to conversation

clk: x86: Add Atom PMC platform clocks

PATCH Superseded Irina Tirdea 2 participants 6 messages Sep 9, 2016 – Oct 6, 2016

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 clk: x86: Add Atom PMC platform clocks

The BayTrail and CherryTrail platforms provide platform clocks through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[5:0]) with a frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail an a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks are available for general system use, where appropriate, and each have Control & Frequency register fields associated with them.

For example, the usage for platform clocks suggested in the datasheet is the following:
PLT_CLK[2:0] - Camera
PLT_CLK[3] - Audio Codec
PLT_CLK[4] -
PLT_CLK[5] - COMMs

---

Notes:
Submitting this patch through the clock tree as requested by Mark Brown. This patch specifically enables the audio MCLK required by Baytrail CR devices (support already merged in Mark's tree)

Changes from v2:
- move clk platform data structures to a separate include file
- store clk_hw pointer for the fixed rate clocks

Changes from v1:
- register the clk device as child of pmc device
- pass iomem pointer from pmc driver to clk driver to avoid using
pmc_atom_read()/write() and use readl/writel API instead
- use devm_clk_hw_register/clkdev_hw_create instead of
clk_register/clkdev_create

 arch/x86/Kconfig                          |   1 +
 arch/x86/include/asm/pmc_atom.h           |   3 +
 arch/x86/platform/atom/pmc_atom.c         |  78 +++++-
 drivers/clk/x86/Makefile                  |   1 +
 drivers/clk/x86/clk-byt-plt.c             | 381 ++++++++++++++++++++++++++++++
 include/linux/platform_data/clk-byt-plt.h |  31 +++
 6 files changed, 492 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/x86/clk-byt-plt.c
 create mode 100644 include/linux/platform_data/clk-byt-plt.h
arch/x86/Kconfig +1 -0
index 2a1f0ce..3e603a8 100644
@@ -2744,6 +2744,7 @@ config X86_DMA_REMAP
 config PMC_ATOM
 	def_bool y
         depends on PCI
+	select COMMON_CLK
 
 config VMD
 	depends on PCI_MSI
arch/x86/include/asm/pmc_atom.h +3 -0
index aa8744c..2d310cf 100644
@@ -50,6 +50,9 @@
 				BIT_ORED_DEDICATED_IRQ_GPSC | \
 				BIT_SHARED_IRQ_GPSS)
 
+/* Platform clock control registers */
+#define PMC_CLK_CTL_0		0x60
+
 /* The timers acumulate time spent in sleep state */
 #define	PMC_S0IR_TMR		0x80
 #define	PMC_S0I1_TMR		0x84
arch/x86/platform/atom/pmc_atom.c +75 -3

123 lines not on this page · raw message

drivers/clk/x86/Makefile +1 -0
index 0478138..cbdc8cc 100644
@@ -1,2 +1,3 @@
 clk-x86-lpss-objs		:= clk-lpt.o
 obj-$(CONFIG_X86_INTEL_LPSS)	+= clk-x86-lpss.o
+obj-$(CONFIG_PMC_ATOM)		+= clk-byt-plt.o
drivers/clk/x86/clk-byt-plt.c new file +381 -0

381 lines not on this page · raw message

include/linux/platform_data/clk-byt-plt.h new file +31 -0
new file mode 100644
index 0000000..e6bca9c
@@ -0,0 +1,31 @@
+/*
+ * Intel Atom platform clocks for BayTrail and CherryTrail SoC.
+ *
+ * Copyright (C) 2016, Intel Corporation
+ * Author: Irina Tirdea <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __CLK_BYT_PLT_H
+#define __CLK_BYT_PLT_H
+
+struct pmc_clk {
+	const char *name;
+	unsigned long freq;
+	const char *parent_name;
+};
+
+struct pmc_clk_data {
+	void __iomem *base;
+	const struct pmc_clk *clks;
+};
+
+#endif /* __CLK_BYT_PLT_H */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 37 lines · Irina Tirdea

The BayTrail and CherryTrail platforms provide platform clocks through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[5:0]) with a frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail an a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks are available for general system use, where appropriate, and each have Control & Frequency register fields associated with them.

For example, the usage for platform clocks suggested in the datasheet is the following:
PLT_CLK[2:0] - Camera
PLT_CLK[3] - Audio Codec
PLT_CLK[4] -
PLT_CLK[5] - COMMs

---

Notes:
Submitting this patch through the clock tree as requested by Mark Brown. This patch specifically enables the audio MCLK required by Baytrail CR devices (support already merged in Mark's tree)

Changes from v2:
- move clk platform data structures to a separate include file
- store clk_hw pointer for the fixed rate clocks

Changes from v1:
- register the clk device as child of pmc device
- pass iomem pointer from pmc driver to clk driver to avoid using
pmc_atom_read()/write() and use readl/writel API instead
- use devm_clk_hw_register/clkdev_hw_create instead of
clk_register/clkdev_create

Quoted 3 lines
 arch/x86/Kconfig                          |   1 +
 arch/x86/include/asm/pmc_atom.h           |   3 +
 arch/x86/platform/atom/pmc_atom.c         |  78 +++++-

Will there be problems if this merges through clk tree? If so we could take the clk driver part and the platform data include part could be duplicated into both trees. Or clk tree could be pulled into x86?

The patch looks fine to me.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw
Quoted 52 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Boyd
Sent: 15 September, 2016 0:30
To: Tirdea, Irina
Cc: [email protected]; Michael Turquette; [email protected]; Mark Brown; Takashi Iwai; Bossart, Pierre-louis; Pierre- Louis Bossart
Subject: Re: [PATCH v3] clk: x86: Add Atom PMC platform clocks

Quoted 37 lines · Irina Tirdea

The BayTrail and CherryTrail platforms provide platform clocks through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[5:0]) with a frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail an a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks are available for general system use, where appropriate, and each have Control & Frequency register fields associated with them.

For example, the usage for platform clocks suggested in the datasheet is the following:
PLT_CLK[2:0] - Camera
PLT_CLK[3] - Audio Codec
PLT_CLK[4] -
PLT_CLK[5] - COMMs

---

Notes:
Submitting this patch through the clock tree as requested by Mark Brown. This patch specifically enables the audio MCLK required by Baytrail CR devices (support already merged in Mark's tree)

Changes from v2:
- move clk platform data structures to a separate include file
- store clk_hw pointer for the fixed rate clocks

Changes from v1:
- register the clk device as child of pmc device
- pass iomem pointer from pmc driver to clk driver to avoid using
pmc_atom_read()/write() and use readl/writel API instead
- use devm_clk_hw_register/clkdev_hw_create instead of
clk_register/clkdev_create

Quoted 3 lines
 arch/x86/Kconfig                          |   1 +
 arch/x86/include/asm/pmc_atom.h           |   3 +
 arch/x86/platform/atom/pmc_atom.c         |  78 +++++-
Quoted 6 lines

Will there be problems if this merges through clk tree? If so we could take the clk driver part and the platform data include part could be duplicated into both trees. Or clk tree could be pulled into x86?

The patch looks fine to me.

Oops... Seems I forgot to add the x86 architecture maintainers. Sorry about that. I will send v4 and add them.

Thanks,
Irina

#3 lore raw
In reply to Stephen Boyd
Quoted 52 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Boyd
Sent: 15 September, 2016 0:30
To: Tirdea, Irina
Cc: [email protected]; Michael Turquette; [email protected]; Mark Brown; Takashi Iwai; Bossart, Pierre-louis; Pierre- Louis Bossart
Subject: Re: [PATCH v3] clk: x86: Add Atom PMC platform clocks

Quoted 37 lines · Irina Tirdea

The BayTrail and CherryTrail platforms provide platform clocks through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[5:0]) with a frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail an a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks are available for general system use, where appropriate, and each have Control & Frequency register fields associated with them.

For example, the usage for platform clocks suggested in the datasheet is the following:
PLT_CLK[2:0] - Camera
PLT_CLK[3] - Audio Codec
PLT_CLK[4] -
PLT_CLK[5] - COMMs

---

Notes:
Submitting this patch through the clock tree as requested by Mark Brown. This patch specifically enables the audio MCLK required by Baytrail CR devices (support already merged in Mark's tree)

Changes from v2:
- move clk platform data structures to a separate include file
- store clk_hw pointer for the fixed rate clocks

Changes from v1:
- register the clk device as child of pmc device
- pass iomem pointer from pmc driver to clk driver to avoid using
pmc_atom_read()/write() and use readl/writel API instead
- use devm_clk_hw_register/clkdev_hw_create instead of
clk_register/clkdev_create

Quoted 3 lines
 arch/x86/Kconfig                          |   1 +
 arch/x86/include/asm/pmc_atom.h           |   3 +
 arch/x86/platform/atom/pmc_atom.c         |  78 +++++-
Quoted 6 lines

Will there be problems if this merges through clk tree? If so we could take the clk driver part and the platform data include part could be duplicated into both trees. Or clk tree could be pulled into x86?

The patch looks fine to me.

Adding the x86 list and maintainers to this thread, as they should be able to answer this question. I already sent a new version of this patch, this time also including the x86 platform list and maintainers [1].

Thanks,
Irina

[1] http://www.spinics.net/lists/linux-clk/msg12169.html

#4 lore raw
In reply to Irina Tirdea
Quoted 5 lines · Irina Tirdea
(quoted diff) +5 -0
+
+static const char **plt_clk_register_parents(struct platform_device *pdev,
+					     struct clk_plt_data *data,
+					     const struct pmc_clk *clks)
+{

Review

Quoted 10 lines
(quoted diff) +10 -0
+	const char **parent_names;
+	int i, err;
+
+	data->nparents = 0;
+	while (clks[data->nparents].name)
+		data->nparents++;
+
+	data->parents = devm_kzalloc(&pdev->dev,
+				     sizeof(*data->parents) * data->nparents,
+				     GFP_KERNEL);

This could be devm_kcalloc()

---8<----

drivers/clk/x86/clk-byt-plt.c +2 -3
index 9dbf4b04ae47..7bd6c0dded00 100644
@@ -259,9 +259,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev,
 	while (clks[data->nparents].name)
 		data->nparents++;
 
-	data->parents = devm_kzalloc(&pdev->dev,
-				     sizeof(*data->parents) * data->nparents,
-				     GFP_KERNEL);
+	data->parents = devm_kcalloc(&pdev->dev, data->nparents,
+				     sizeof(*data->parents), GFP_KERNEL);
 	if (!data->parents) {
 		err = -ENOMEM;
 		goto err_out;
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw
Quoted 20 lines

-----Original Message-----
From: Stephen Boyd [mailto:[email protected]]
Sent: 15 September, 2016 0:33
To: Tirdea, Irina
Cc: [email protected]; Michael Turquette; [email protected]; Mark Brown; Takashi Iwai; Bossart, Pierre-louis; Pierre- Louis Bossart
Subject: Re: [PATCH v3] clk: x86: Add Atom PMC platform clocks

Quoted 9 lines · Irina Tirdea
(quoted diff) +9 -0
+
+static const char **plt_clk_register_parents(struct platform_device *pdev,
+					     struct clk_plt_data *data,
+					     const struct pmc_clk *clks)
+{
+	const char **parent_names;
+	int i, err;
+
+	data->nparents = 0;
Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	while (clks[data->nparents].name)
+		data->nparents++;
+
+	data->parents = devm_kzalloc(&pdev->dev,
+				     sizeof(*data->parents) * data->nparents,
+				     GFP_KERNEL);

This could be devm_kcalloc()

OK, will send v4 with this change.

Quoted 21 lines

---8<----

drivers/clk/x86/clk-byt-plt.c +2 -4
index 9dbf4b04ae47..7bd6c0dded00 100644
@@ -259,9 +259,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev,
 	while (clks[data->nparents].name)
 		data->nparents++;
 
-	data->parents = devm_kzalloc(&pdev->dev,
-				     sizeof(*data->parents) * data->nparents,
-				     GFP_KERNEL);
+	data->parents = devm_kcalloc(&pdev->dev, data->nparents,
+				     sizeof(*data->parents), GFP_KERNEL);
 	if (!data->parents) {
 		err = -ENOMEM;
 		goto err_out;
 
--

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project