diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-08 17:13:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-08 17:13:04 -0400 |
commit | cf377ad7d42c566356d79049536d9cb37499cb77 (patch) | |
tree | 266371ff3a9462dcbaa9567e20c9a34722e3b32f /drivers/clk/at91 | |
parent | 212fe84a6f215c39795a76517c1c02114d428681 (diff) | |
parent | d8f0faa339b0beff6e055218e10b2982422db540 (diff) |
Merge tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC platform changes from Arnd Bergmann:
"New and updated SoC support. Among the things new for this release
are:
- at91: Added support for the new SAMA5D4 SoC, following the earlier
SAMA5D3
- bcm: Added support for BCM63XX family of DSL SoCs
- hisi: Added support for HiP04 server-class SoC
- meson: Initial support for the Amlogic Meson6 (aka 8726MX) platform
- shmobile: added support for new r8a7794 (R-Car E2) automotive SoC
Noteworthy changes to existing SoC support are:
- imx: convert i.MX1 to device tree
- omap: lots of power management work
- omap: base support to enable moving to standard UART driver
- shmobile: lots of progress for multiplatform support, still
ongoing"
* tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (171 commits)
ARM: hisi: depend on ARCH_MULTI_V7
CNS3xxx: Fix debug UART.
ARM: at91: fix nommu build regression
ARM: meson: add basic support for MesonX SoCs
ARM: meson: debug: add debug UART for earlyprintk support
irq: Export handle_fasteoi_irq
ARM: mediatek: Add earlyprintk support for mt6589
ARM: hisi: Fix platmcpm compilation when ARMv6 is selected
ARM: debug: fix alphanumerical order on debug uarts
ARM: at91: document Atmel SMART compatibles
ARM: at91: add sama5d4 support to sama5_defconfig
ARM: at91: dt: add device tree file for SAMA5D4ek board
ARM: at91: dt: add device tree file for SAMA5D4 SoC
ARM: at91: SAMA5D4 SoC detection code and low level routines
ARM: at91: introduce basic SAMA5D4 support
clk: at91: add a driver for the h32mx clock
ARM: pxa3xx: provide specific platform_devices for all ssp ports
ARM: pxa: ssp: provide platform_device_id for PXA3xx
ARM: OMAP4+: Remove static iotable mappings for SRAM
ARM: OMAP4+: Move SRAM data to DT
...
Diffstat (limited to 'drivers/clk/at91')
-rw-r--r-- | drivers/clk/at91/Makefile | 1 | ||||
-rw-r--r-- | drivers/clk/at91/clk-h32mx.c | 123 | ||||
-rw-r--r-- | drivers/clk/at91/pmc.c | 6 | ||||
-rw-r--r-- | drivers/clk/at91/pmc.h | 5 |
4 files changed, 135 insertions, 0 deletions
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile index 4998aee59267..89a48a7bd5df 100644 --- a/drivers/clk/at91/Makefile +++ b/drivers/clk/at91/Makefile | |||
@@ -9,3 +9,4 @@ obj-y += clk-system.o clk-peripheral.o clk-programmable.o | |||
9 | obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o | 9 | obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o |
10 | obj-$(CONFIG_HAVE_AT91_USB_CLK) += clk-usb.o | 10 | obj-$(CONFIG_HAVE_AT91_USB_CLK) += clk-usb.o |
11 | obj-$(CONFIG_HAVE_AT91_SMD) += clk-smd.o | 11 | obj-$(CONFIG_HAVE_AT91_SMD) += clk-smd.o |
12 | obj-$(CONFIG_HAVE_AT91_H32MX) += clk-h32mx.o | ||
diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c new file mode 100644 index 000000000000..152dcb3f7b5f --- /dev/null +++ b/drivers/clk/at91/clk-h32mx.c | |||
@@ -0,0 +1,123 @@ | |||
1 | /* | ||
2 | * clk-h32mx.c | ||
3 | * | ||
4 | * Copyright (C) 2014 Atmel | ||
5 | * | ||
6 | * Alexandre Belloni <alexandre.belloni@free-electrons.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #include <linux/clk-provider.h> | ||
16 | #include <linux/clkdev.h> | ||
17 | #include <linux/clk/at91_pmc.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/of_address.h> | ||
21 | #include <linux/of_irq.h> | ||
22 | #include <linux/io.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/irq.h> | ||
25 | #include <linux/sched.h> | ||
26 | #include <linux/wait.h> | ||
27 | |||
28 | #include "pmc.h" | ||
29 | |||
30 | #define H32MX_MAX_FREQ 90000000 | ||
31 | |||
32 | struct clk_sama5d4_h32mx { | ||
33 | struct clk_hw hw; | ||
34 | struct at91_pmc *pmc; | ||
35 | }; | ||
36 | |||
37 | #define to_clk_sama5d4_h32mx(hw) container_of(hw, struct clk_sama5d4_h32mx, hw) | ||
38 | |||
39 | static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk_hw *hw, | ||
40 | unsigned long parent_rate) | ||
41 | { | ||
42 | struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); | ||
43 | |||
44 | if (pmc_read(h32mxclk->pmc, AT91_PMC_MCKR) & AT91_PMC_H32MXDIV) | ||
45 | return parent_rate / 2; | ||
46 | |||
47 | if (parent_rate > H32MX_MAX_FREQ) | ||
48 | pr_warn("H32MX clock is too fast\n"); | ||
49 | return parent_rate; | ||
50 | } | ||
51 | |||
52 | static long clk_sama5d4_h32mx_round_rate(struct clk_hw *hw, unsigned long rate, | ||
53 | unsigned long *parent_rate) | ||
54 | { | ||
55 | unsigned long div; | ||
56 | |||
57 | if (rate > *parent_rate) | ||
58 | return *parent_rate; | ||
59 | div = *parent_rate / 2; | ||
60 | if (rate < div) | ||
61 | return div; | ||
62 | |||
63 | if (rate - div < *parent_rate - rate) | ||
64 | return div; | ||
65 | |||
66 | return *parent_rate; | ||
67 | } | ||
68 | |||
69 | static int clk_sama5d4_h32mx_set_rate(struct clk_hw *hw, unsigned long rate, | ||
70 | unsigned long parent_rate) | ||
71 | { | ||
72 | struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); | ||
73 | struct at91_pmc *pmc = h32mxclk->pmc; | ||
74 | u32 tmp; | ||
75 | |||
76 | if (parent_rate != rate && (parent_rate / 2) != rate) | ||
77 | return -EINVAL; | ||
78 | |||
79 | pmc_lock(pmc); | ||
80 | tmp = pmc_read(pmc, AT91_PMC_MCKR) & ~AT91_PMC_H32MXDIV; | ||
81 | if ((parent_rate / 2) == rate) | ||
82 | tmp |= AT91_PMC_H32MXDIV; | ||
83 | pmc_write(pmc, AT91_PMC_MCKR, tmp); | ||
84 | pmc_unlock(pmc); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static const struct clk_ops h32mx_ops = { | ||
90 | .recalc_rate = clk_sama5d4_h32mx_recalc_rate, | ||
91 | .round_rate = clk_sama5d4_h32mx_round_rate, | ||
92 | .set_rate = clk_sama5d4_h32mx_set_rate, | ||
93 | }; | ||
94 | |||
95 | void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, | ||
96 | struct at91_pmc *pmc) | ||
97 | { | ||
98 | struct clk_sama5d4_h32mx *h32mxclk; | ||
99 | struct clk_init_data init; | ||
100 | const char *parent_name; | ||
101 | struct clk *clk; | ||
102 | |||
103 | h32mxclk = kzalloc(sizeof(*h32mxclk), GFP_KERNEL); | ||
104 | if (!h32mxclk) | ||
105 | return; | ||
106 | |||
107 | parent_name = of_clk_get_parent_name(np, 0); | ||
108 | |||
109 | init.name = np->name; | ||
110 | init.ops = &h32mx_ops; | ||
111 | init.parent_names = parent_name ? &parent_name : NULL; | ||
112 | init.num_parents = parent_name ? 1 : 0; | ||
113 | init.flags = CLK_SET_RATE_GATE; | ||
114 | |||
115 | h32mxclk->hw.init = &init; | ||
116 | h32mxclk->pmc = pmc; | ||
117 | |||
118 | clk = clk_register(NULL, &h32mxclk->hw); | ||
119 | if (!clk) | ||
120 | return; | ||
121 | |||
122 | of_clk_add_provider(np, of_clk_src_simple_get, clk); | ||
123 | } | ||
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 524196bb35a5..386999b4f8eb 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c | |||
@@ -337,6 +337,12 @@ static const struct of_device_id pmc_clk_ids[] __initconst = { | |||
337 | .data = of_at91sam9x5_clk_smd_setup, | 337 | .data = of_at91sam9x5_clk_smd_setup, |
338 | }, | 338 | }, |
339 | #endif | 339 | #endif |
340 | #if defined(CONFIG_HAVE_AT91_H32MX) | ||
341 | { | ||
342 | .compatible = "atmel,sama5d4-clk-h32mx", | ||
343 | .data = of_sama5d4_clk_h32mx_setup, | ||
344 | }, | ||
345 | #endif | ||
340 | { /*sentinel*/ } | 346 | { /*sentinel*/ } |
341 | }; | 347 | }; |
342 | 348 | ||
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 6c7625976113..52d2041fa3f6 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h | |||
@@ -120,4 +120,9 @@ extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np, | |||
120 | struct at91_pmc *pmc); | 120 | struct at91_pmc *pmc); |
121 | #endif | 121 | #endif |
122 | 122 | ||
123 | #if defined(CONFIG_HAVE_AT91_SMD) | ||
124 | extern void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, | ||
125 | struct at91_pmc *pmc); | ||
126 | #endif | ||
127 | |||
123 | #endif /* __PMC_H_ */ | 128 | #endif /* __PMC_H_ */ |