sta2x11 common clock framework implementation
Subsystems (3)
cover sta2x11 common clock framework implementation
Hi,
this patchset is the first implementation of the common clock framework for the STA2X11 (aka connext) chip.
Actually 1/3 and 2/3 are not strictly relevant to the clock framework, but they're needed to get the rest of the code to compile and have already been submitted some months ago (see https://lkml.org/lkml/2012/9/20/363)
and acked by Alessandro Rubini (see https://lkml.org/lkml/2012/9/20/452).
3/3 has been submitted RFC on Jun 20th 2012
(see https://lkml.org/lkml/2012/6/20/779).
Mike Turquette reviewed it (see https://lkml.org/lkml/2012/8/23/624) and his comments have been taken into account for this submission.
Please note that this patchset applies to next-20130307, should build cleanly and do no harm at runtime, but it is not functional because it needs the pci-to-amba bridge patch by Alessandro Rubini, which has already been submitted several times but has not made it in the linux-next tree yet (see thread https://lkml.org/lkml/2013/2/20/561 for more details).
Some clocks still have to be added and some others need to be implemented with different types (see the TODOs in the code), but the current implementation is actually enough to get a Connext based board up and running (with its UARTs working at least), of course provided that the pci to amba bridge is there. Multiple instances of the Connext chip should also be supported, even if no test has been done up to now.
Thanks and regards
Davide
Davide Ciminaghi (3):
x86, pci sta2x11-fixup: add clk related field to struct
sta2x11_instance
x86, pci sta2x11-fixup: add function to access sta2x11 instance id drivers/clk: sta2x11 common clock framework implementation
arch/x86/Kconfig | 1 + arch/x86/include/asm/sta2x11.h | 16 + arch/x86/pci/sta2x11-fixup.c | 20 + drivers/clk/Makefile | 1 + drivers/clk/sta2x11/Makefile | 1 + drivers/clk/sta2x11/clk-audio-pll.c | 150 +++++++ drivers/clk/sta2x11/clk-soc-pll.c | 96 +++++ drivers/clk/sta2x11/clk.c | 782 +++++++++++++++++++++++++++++++++++ drivers/clk/sta2x11/clk.h | 73 ++++ 9 files changed, 1140 insertions(+) create mode 100644 drivers/clk/sta2x11/Makefile create mode 100644 drivers/clk/sta2x11/clk-audio-pll.c create mode 100644 drivers/clk/sta2x11/clk-soc-pll.c create mode 100644 drivers/clk/sta2x11/clk.c create mode 100644 drivers/clk/sta2x11/clk.h
Signature · 1 line
1.7.10.4
PATCH 1/3 x86, pci sta2x11-fixup: add clk related field to struct sta2x11_instance
Use struct sta2x11_instance for storing a pointer to an array of struct clk pointers representing the set of clocks belonging to a single connext chip.
Since sta2x11_instance is an opaque type, we also add functions to access the new field.
--- arch/x86/include/asm/sta2x11.h | 16 ++++++++++++++++ arch/x86/pci/sta2x11-fixup.c | 14 ++++++++++++++ 2 files changed, 30 insertions(+)
arch/x86/include/asm/sta2x11.h +16 -0
@@ -5,8 +5,24 @@#define __ASM_STA2X11_H#include <linux/pci.h> +#include <linux/clk.h> /* This needs to be called from the MFD to configure its sub-devices */ struct sta2x11_instance *sta2x11_get_instance (struct pci_dev *pdev); +/* +* Return instance id +*/ +int sta2x11_get_instance_id (struct sta2x11_instance *instance); + +/* +* Add clks array to instance. This is called by clock common API +*/ +void sta2x11_instance_add_clks (struct sta2x11_instance *,struct clk **); + +/* +* Returns clks array of instance. This is called by clock common API +*/ +struct clk **sta2x11_instance_get_clks (struct sta2x11_instance *); +#endif /* __ASM_STA2X11_H */
arch/x86/pci/sta2x11-fixup.c +14 -0
@@ -27,6 +27,8 @@#include <linux/export.h> #include <linux/list.h> +#include <asm/sta2x11.h> +#define STA2X11_SWIOTLB_SIZE (4*1024*1024)extern int swiotlb_late_init_with_default_size (size_t default_size);
@@ -52,6 +54,7 @@ struct sta2x11_instance {struct list_head list;int bus0;struct sta2x11_mapping map[STA2X11_NR_EP ]; +struct clk **clks; };static LIST_HEAD (sta2x11_instance_list);
@@ -78,6 +81,17 @@ static void sta2x11_new_instance(struct pci_dev *pdev) }DECLARE_PCI_FIXUP_ENABLE (PCI_VENDOR_ID_STMICRO ,0xcc17 , sta2x11_new_instance); +void sta2x11_instance_add_clks (struct sta2x11_instance *instance, +struct clk **clks) +{ + instance->clks = clks; +} + +struct clk **sta2x11_instance_get_clks (struct sta2x11_instance *instance) +{ +return instance->clks; +} +/* * Utility functions used in this file from below */
Signature · 1 line
1.7.10.4
PATCH 2/3 x86, pci sta2x11-fixup: add function to access sta2x11 instance id
In reply to Davide CiminaghiThe sta2x11 instance id will be included in clock names to make them unique in case of multiple sta2x11's living on the same machine.
--- arch/x86/pci/sta2x11-fixup.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/pci/sta2x11-fixup.c +6 -0
@@ -138,6 +138,12 @@ struct sta2x11_instance *sta2x11_get_instance(struct pci_dev *pdev) }EXPORT_SYMBOL (sta2x11_get_instance); +int sta2x11_get_instance_id (struct sta2x11_instance *instance) +{ +return instance->bus0; +} +EXPORT_SYMBOL (sta2x11_get_instance_id); +/** * p2a - Translate physical address to STA2x11 AMBA address,
Signature · 1 line
1.7.10.4
Re: [PATCH 2/3] x86, pci sta2x11-fixup: add function to access sta2x11 instance id
Quoted 5 lines · Davide Ciminaghi
The sta2x11 instance id will be included in clock names to make them unique in case of multiple sta2x11's living on the same machine.
Signed-off-by Davide Ciminaghi <[email protected]>
I might be missing something, but this seems counterintuitive. Shouldn't the clock names really be constant and independent of the instance?
The instance should be identified already by the dev_name, right?
Arnd
Re: [PATCH 2/3] x86, pci sta2x11-fixup: add function to access sta2x11 instance id
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Davide Ciminaghi
The sta2x11 instance id will be included in clock names to make them unique in case of multiple sta2x11's living on the same machine.
Quoted 7 lines
Quoted 1 line
Signed-off-by Davide Ciminaghi <[email protected]>I might be missing something, but this seems counterintuitive. Shouldn't the clock names really be constant and independent of the instance?
The instance should be identified already by the
dev_name, right?
Hi,
sorry for the delay.
Well, I actually wrote this some months ago, so I might also be missing something (yes, I know I shouldn't :-).
If I understand well, I should call clk_register_* with dev pointing to the struct device corresponding to the sta2x11 instance to which the clock belongs and a constant name (while currently I set dev to NULL and use a different name for each instance of the same clock, by postfixing the name with an instance id).
You're probably right, even if looking at the code in drivers/clk/clk.c, there's something I'm not sure about (and I cannot do any tests right now):
_clk_register() takes hw->init->name as clock name, where hw->init->name should come from the second arg of clk_register_*, if I'm not wrong. Then __clk_init does:
if (__clk_lookup(clk->name)) {
pr_debug("%s: clk %s already initialized\n", __func__, clk->name);
ret = -EEXIST;
goto out;
}Is it actually possible registering multiple clocks with the same name ? Sorry maybe I missed your point ...
Thanks and regards
Davide
PATCH 3/3 drivers/clk: sta2x11 common clock framework implementation
In reply to Davide Ciminaghi--- arch/x86/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sta2x11/Makefile | 1 + drivers/clk/sta2x11/clk-audio-pll.c | 150 +++++++ drivers/clk/sta2x11/clk-soc-pll.c | 96 +++++ drivers/clk/sta2x11/clk.c | 782 +++++++++++++++++++++++++++++++++++ drivers/clk/sta2x11/clk.h | 73 ++++ 7 files changed, 1104 insertions(+) create mode 100644 drivers/clk/sta2x11/Makefile create mode 100644 drivers/clk/sta2x11/clk-audio-pll.c create mode 100644 drivers/clk/sta2x11/clk-soc-pll.c create mode 100644 drivers/clk/sta2x11/clk.c create mode 100644 drivers/clk/sta2x11/clk.h
arch/x86/Kconfig +1 -0
@@ -547,6 +547,7 @@ config STA2X11 depends on X86_32_NON_STANDARD && PCI select X86_DEV_DMA_OPS select X86_DMA_REMAP + select COMMON_CLK select SWIOTLB select MFD_STA2X11 select ARCH_REQUIRE_GPIOLIB
drivers/clk/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_STA2X11) += sta2x11/ # Chip specific obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
drivers/clk/sta2x11/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_STA2X11) += clk.o clk-soc-pll.o clk-audio-pll.o
drivers/clk/sta2x11/clk-audio-pll.c new file +150 -0
150 lines not on this page · raw message
drivers/clk/sta2x11/clk-soc-pll.c new file +96 -0
96 lines not on this page · raw message
drivers/clk/sta2x11/clk.c new file +782 -0
782 lines not on this page · raw message
drivers/clk/sta2x11/clk.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
1.7.10.4