clk: x86: Add Atom PMC platform clocks
Subsystems (2)
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
@@ -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
@@ -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
@@ -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
@@ -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
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] - COMMsSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Pierre-Louis Bossart <[email protected]>---
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
- storeclk_hwpointer for the fixed rate clocksChanges 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
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
@@ -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
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 clocksQuoted 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] - COMMsSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Pierre-Louis Bossart <[email protected]>---
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
- storeclk_hwpointer for the fixed rate clocksChanges 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_createQuoted 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
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 clocksQuoted 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@@ -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
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 clocksQuoted 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] - COMMsSigned-off-by Irina Tirdea <[email protected]>Signed-off-by Pierre-Louis Bossart <[email protected]>---
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
- storeclk_hwpointer for the fixed rate clocksChanges 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_createQuoted 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