Skip to content

Commit a4dcb2f

Browse files
committed
Merge branches 'clk-zynq', 'clk-xilinx' and 'clk-stm' into clk-next
- Update Zynqmp driver for Versal NET platforms - Add clk driver for Versal clocking wizard IP * clk-zynq: drivers: clk: zynqmp: update divider round rate logic drivers: clk: zynqmp: calculate closest mux rate * clk-xilinx: clocking-wizard: Add support for versal clocking wizard dt-bindings: clock: xilinx: add versal compatible * clk-stm: dt-bindings: stm32: add clocks and reset binding for stm32mp25 platform clk: stm32mp1: use stm32mp13 reset driver clk: stm32mp1: move stm32mp1 clock driver into stm32 directory
4 parents 23bd8c4 + 1fe15be + 3a96393 + b5be49d commit a4dcb2f

File tree

17 files changed

+1350
-292
lines changed

17 files changed

+1350
-292
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/st,stm32mp25-rcc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: STM32MP25 Reset Clock Controller
8+
9+
maintainers:
10+
- Gabriel Fernandez <[email protected]>
11+
12+
description: |
13+
The RCC hardware block is both a reset and a clock controller.
14+
RCC makes also power management (resume/supend).
15+
16+
See also::
17+
include/dt-bindings/clock/st,stm32mp25-rcc.h
18+
include/dt-bindings/reset/st,stm32mp25-rcc.h
19+
20+
properties:
21+
compatible:
22+
enum:
23+
- st,stm32mp25-rcc
24+
25+
reg:
26+
maxItems: 1
27+
28+
'#clock-cells':
29+
const: 1
30+
31+
'#reset-cells':
32+
const: 1
33+
34+
clocks:
35+
items:
36+
- description: CK_SCMI_HSE High Speed External oscillator (8 to 48 MHz)
37+
- description: CK_SCMI_HSI High Speed Internal oscillator (~ 64 MHz)
38+
- description: CK_SCMI_MSI Low Power Internal oscillator (~ 4 MHz or ~ 16 MHz)
39+
- description: CK_SCMI_LSE Low Speed External oscillator (32 KHz)
40+
- description: CK_SCMI_LSI Low Speed Internal oscillator (~ 32 KHz)
41+
42+
clock-names:
43+
items:
44+
- const: hse
45+
- const: hsi
46+
- const: msi
47+
- const: lse
48+
- const: lsi
49+
50+
required:
51+
- compatible
52+
- reg
53+
- '#clock-cells'
54+
- '#reset-cells'
55+
- clocks
56+
- clock-names
57+
58+
additionalProperties: false
59+
60+
examples:
61+
- |
62+
#include <dt-bindings/clock/st,stm32mp25-rcc.h>
63+
64+
rcc: clock-controller@44200000 {
65+
compatible = "st,stm32mp25-rcc";
66+
reg = <0x44200000 0x10000>;
67+
#clock-cells = <1>;
68+
#reset-cells = <1>;
69+
clock-names = "hse", "hsi", "msi", "lse", "lsi";
70+
clocks = <&scmi_clk CK_SCMI_HSE>,
71+
<&scmi_clk CK_SCMI_HSI>,
72+
<&scmi_clk CK_SCMI_MSI>,
73+
<&scmi_clk CK_SCMI_LSE>,
74+
<&scmi_clk CK_SCMI_LSI>;
75+
};
76+
...

Documentation/devicetree/bindings/clock/xlnx,clocking-wizard.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
- xlnx,clocking-wizard
2121
- xlnx,clocking-wizard-v5.2
2222
- xlnx,clocking-wizard-v6.0
23+
- xlnx,versal-clk-wizard
2324

2425

2526
reg:

drivers/clk/Kconfig

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,6 @@ config COMMON_CLK_VC7
414414
Renesas Versaclock7 is a family of configurable clock generator
415415
and jitter attenuator ICs with fractional and integer dividers.
416416

417-
config COMMON_CLK_STM32MP135
418-
def_bool COMMON_CLK && MACH_STM32MP13
419-
help
420-
Support for stm32mp135 SoC family clocks
421-
422-
config COMMON_CLK_STM32MP157
423-
def_bool COMMON_CLK && MACH_STM32MP157
424-
help
425-
Support for stm32mp157 SoC family clocks
426-
427417
config COMMON_CLK_STM32F
428418
def_bool COMMON_CLK && (MACH_STM32F429 || MACH_STM32F469 || MACH_STM32F746)
429419
help
@@ -504,6 +494,7 @@ source "drivers/clk/starfive/Kconfig"
504494
source "drivers/clk/sunxi/Kconfig"
505495
source "drivers/clk/sunxi-ng/Kconfig"
506496
source "drivers/clk/tegra/Kconfig"
497+
source "drivers/clk/stm32/Kconfig"
507498
source "drivers/clk/ti/Kconfig"
508499
source "drivers/clk/uniphier/Kconfig"
509500
source "drivers/clk/visconti/Kconfig"

drivers/clk/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ obj-$(CONFIG_COMMON_CLK_SI570) += clk-si570.o
7070
obj-$(CONFIG_COMMON_CLK_SP7021) += clk-sp7021.o
7171
obj-$(CONFIG_COMMON_CLK_STM32F) += clk-stm32f4.o
7272
obj-$(CONFIG_COMMON_CLK_STM32H7) += clk-stm32h7.o
73-
obj-$(CONFIG_COMMON_CLK_STM32MP157) += clk-stm32mp1.o
7473
obj-$(CONFIG_COMMON_CLK_TPS68470) += clk-tps68470.o
7574
obj-$(CONFIG_CLK_TWL6040) += clk-twl6040.o
7675
obj-$(CONFIG_CLK_TWL) += clk-twl.o

drivers/clk/stm32/Kconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
# common clock support for STMicroelectronics SoC family.
3+
4+
menuconfig COMMON_CLK_STM32MP
5+
bool "Clock support for common STM32MP clocks"
6+
depends on ARCH_STM32 || COMPILE_TEST
7+
default y
8+
select RESET_CONTROLLER
9+
help
10+
Support for STM32MP SoC family clocks.
11+
12+
if COMMON_CLK_STM32MP
13+
14+
config COMMON_CLK_STM32MP135
15+
bool "Clock driver for stm32mp13x clocks"
16+
depends on ARM || COMPILE_TEST
17+
default y
18+
help
19+
Support for stm32mp13x SoC family clocks.
20+
21+
config COMMON_CLK_STM32MP157
22+
bool "Clock driver for stm32mp15x clocks"
23+
depends on ARM || COMPILE_TEST
24+
default y
25+
help
26+
Support for stm32mp15x SoC family clocks.
27+
28+
endif
29+

drivers/clk/stm32/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
obj-$(CONFIG_COMMON_CLK_STM32MP135) += clk-stm32mp13.o clk-stm32-core.o reset-stm32.o
2+
obj-$(CONFIG_COMMON_CLK_STM32MP157) += clk-stm32mp1.o reset-stm32.o

drivers/clk/stm32/clk-stm32-core.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static int stm32_rcc_clock_init(struct device *dev,
7070
int stm32_rcc_init(struct device *dev, const struct of_device_id *match_data,
7171
void __iomem *base)
7272
{
73+
const struct stm32_rcc_match_data *rcc_match_data;
7374
const struct of_device_id *match;
7475
int err;
7576

@@ -79,8 +80,10 @@ int stm32_rcc_init(struct device *dev, const struct of_device_id *match_data,
7980
return -ENODEV;
8081
}
8182

83+
rcc_match_data = match->data;
84+
8285
/* RCC Reset Configuration */
83-
err = stm32_rcc_reset_init(dev, match, base);
86+
err = stm32_rcc_reset_init(dev, rcc_match_data->reset_data, base);
8487
if (err) {
8588
pr_err("stm32 reset failed to initialize\n");
8689
return err;

drivers/clk/stm32/clk-stm32-core.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ struct stm32_rcc_match_data {
7070
const struct clock_config *tab_clocks;
7171
unsigned int maxbinding;
7272
struct clk_stm32_clock_data *clock_data;
73-
u32 clear_offset;
73+
struct clk_stm32_reset_data *reset_data;
7474
int (*check_security)(void __iomem *base,
7575
const struct clock_config *cfg);
7676
int (*multi_mux)(void __iomem *base, const struct clock_config *cfg);
7777
};
7878

79-
int stm32_rcc_reset_init(struct device *dev, const struct of_device_id *match,
80-
void __iomem *base);
81-
8279
int stm32_rcc_init(struct device *dev, const struct of_device_id *match_data,
8380
void __iomem *base);
8481

drivers/clk/clk-stm32mp1.c renamed to drivers/clk/stm32/clk-stm32mp1.c

Lines changed: 16 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
#include <dt-bindings/clock/stm32mp1-clks.h>
2222

23+
#include "reset-stm32.h"
24+
25+
#define STM32MP1_RESET_ID_MASK GENMASK(15, 0)
26+
2327
static DEFINE_SPINLOCK(rlock);
2428

2529
#define RCC_OCENSETR 0x0C
@@ -2137,22 +2141,27 @@ struct stm32_rcc_match_data {
21372141
const struct clock_config *cfg;
21382142
unsigned int num;
21392143
unsigned int maxbinding;
2140-
u32 clear_offset;
2144+
struct clk_stm32_reset_data *reset_data;
21412145
bool (*check_security)(const struct clock_config *cfg);
21422146
};
21432147

2148+
static struct clk_stm32_reset_data stm32mp1_reset_data = {
2149+
.nr_lines = STM32MP1_RESET_ID_MASK,
2150+
.clear_offset = RCC_CLR,
2151+
};
2152+
21442153
static struct stm32_rcc_match_data stm32mp1_data = {
21452154
.cfg = stm32mp1_clock_cfg,
21462155
.num = ARRAY_SIZE(stm32mp1_clock_cfg),
21472156
.maxbinding = STM32MP1_LAST_CLK,
2148-
.clear_offset = RCC_CLR,
2157+
.reset_data = &stm32mp1_reset_data,
21492158
};
21502159

21512160
static struct stm32_rcc_match_data stm32mp1_data_secure = {
21522161
.cfg = stm32mp1_clock_cfg,
21532162
.num = ARRAY_SIZE(stm32mp1_clock_cfg),
21542163
.maxbinding = STM32MP1_LAST_CLK,
2155-
.clear_offset = RCC_CLR,
2164+
.reset_data = &stm32mp1_reset_data,
21562165
.check_security = &stm32_check_security
21572166
};
21582167

@@ -2193,113 +2202,6 @@ static int stm32_register_hw_clk(struct device *dev,
21932202
return 0;
21942203
}
21952204

2196-
#define STM32_RESET_ID_MASK GENMASK(15, 0)
2197-
2198-
struct stm32_reset_data {
2199-
/* reset lock */
2200-
spinlock_t lock;
2201-
struct reset_controller_dev rcdev;
2202-
void __iomem *membase;
2203-
u32 clear_offset;
2204-
};
2205-
2206-
static inline struct stm32_reset_data *
2207-
to_stm32_reset_data(struct reset_controller_dev *rcdev)
2208-
{
2209-
return container_of(rcdev, struct stm32_reset_data, rcdev);
2210-
}
2211-
2212-
static int stm32_reset_update(struct reset_controller_dev *rcdev,
2213-
unsigned long id, bool assert)
2214-
{
2215-
struct stm32_reset_data *data = to_stm32_reset_data(rcdev);
2216-
int reg_width = sizeof(u32);
2217-
int bank = id / (reg_width * BITS_PER_BYTE);
2218-
int offset = id % (reg_width * BITS_PER_BYTE);
2219-
2220-
if (data->clear_offset) {
2221-
void __iomem *addr;
2222-
2223-
addr = data->membase + (bank * reg_width);
2224-
if (!assert)
2225-
addr += data->clear_offset;
2226-
2227-
writel(BIT(offset), addr);
2228-
2229-
} else {
2230-
unsigned long flags;
2231-
u32 reg;
2232-
2233-
spin_lock_irqsave(&data->lock, flags);
2234-
2235-
reg = readl(data->membase + (bank * reg_width));
2236-
2237-
if (assert)
2238-
reg |= BIT(offset);
2239-
else
2240-
reg &= ~BIT(offset);
2241-
2242-
writel(reg, data->membase + (bank * reg_width));
2243-
2244-
spin_unlock_irqrestore(&data->lock, flags);
2245-
}
2246-
2247-
return 0;
2248-
}
2249-
2250-
static int stm32_reset_assert(struct reset_controller_dev *rcdev,
2251-
unsigned long id)
2252-
{
2253-
return stm32_reset_update(rcdev, id, true);
2254-
}
2255-
2256-
static int stm32_reset_deassert(struct reset_controller_dev *rcdev,
2257-
unsigned long id)
2258-
{
2259-
return stm32_reset_update(rcdev, id, false);
2260-
}
2261-
2262-
static int stm32_reset_status(struct reset_controller_dev *rcdev,
2263-
unsigned long id)
2264-
{
2265-
struct stm32_reset_data *data = to_stm32_reset_data(rcdev);
2266-
int reg_width = sizeof(u32);
2267-
int bank = id / (reg_width * BITS_PER_BYTE);
2268-
int offset = id % (reg_width * BITS_PER_BYTE);
2269-
u32 reg;
2270-
2271-
reg = readl(data->membase + (bank * reg_width));
2272-
2273-
return !!(reg & BIT(offset));
2274-
}
2275-
2276-
static const struct reset_control_ops stm32_reset_ops = {
2277-
.assert = stm32_reset_assert,
2278-
.deassert = stm32_reset_deassert,
2279-
.status = stm32_reset_status,
2280-
};
2281-
2282-
static int stm32_rcc_reset_init(struct device *dev, void __iomem *base,
2283-
const struct of_device_id *match)
2284-
{
2285-
const struct stm32_rcc_match_data *data = match->data;
2286-
struct stm32_reset_data *reset_data = NULL;
2287-
2288-
reset_data = kzalloc(sizeof(*reset_data), GFP_KERNEL);
2289-
if (!reset_data)
2290-
return -ENOMEM;
2291-
2292-
spin_lock_init(&reset_data->lock);
2293-
reset_data->membase = base;
2294-
reset_data->rcdev.owner = THIS_MODULE;
2295-
reset_data->rcdev.ops = &stm32_reset_ops;
2296-
reset_data->rcdev.of_node = dev_of_node(dev);
2297-
reset_data->rcdev.nr_resets = STM32_RESET_ID_MASK;
2298-
reset_data->clear_offset = data->clear_offset;
2299-
2300-
return reset_controller_register(&reset_data->rcdev);
2301-
}
2302-
23032205
static int stm32_rcc_clock_init(struct device *dev, void __iomem *base,
23042206
const struct of_device_id *match)
23052207
{
@@ -2342,6 +2244,7 @@ static int stm32_rcc_clock_init(struct device *dev, void __iomem *base,
23422244
static int stm32_rcc_init(struct device *dev, void __iomem *base,
23432245
const struct of_device_id *match_data)
23442246
{
2247+
const struct stm32_rcc_match_data *rcc_match_data;
23452248
const struct of_device_id *match;
23462249
int err;
23472250

@@ -2351,8 +2254,10 @@ static int stm32_rcc_init(struct device *dev, void __iomem *base,
23512254
return -ENODEV;
23522255
}
23532256

2257+
rcc_match_data = match->data;
2258+
23542259
/* RCC Reset Configuration */
2355-
err = stm32_rcc_reset_init(dev, base, match);
2260+
err = stm32_rcc_reset_init(dev, rcc_match_data->reset_data, base);
23562261
if (err) {
23572262
pr_err("stm32mp1 reset failed to initialize\n");
23582263
return err;

drivers/clk/stm32/clk-stm32mp13.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#include <linux/platform_device.h>
1111
#include <dt-bindings/clock/stm32mp13-clks.h>
1212
#include "clk-stm32-core.h"
13+
#include "reset-stm32.h"
1314
#include "stm32mp13_rcc.h"
1415

16+
#define STM32MP1_RESET_ID_MASK GENMASK(15, 0)
1517
#define RCC_CLR_OFFSET 0x4
1618

1719
/* STM32 Gates definition */
@@ -1511,13 +1513,18 @@ static struct clk_stm32_clock_data stm32mp13_clock_data = {
15111513
.is_multi_mux = stm32mp13_is_multi_mux,
15121514
};
15131515

1516+
static struct clk_stm32_reset_data stm32mp13_reset_data = {
1517+
.nr_lines = STM32MP1_RESET_ID_MASK,
1518+
.clear_offset = RCC_CLR_OFFSET,
1519+
};
1520+
15141521
static const struct stm32_rcc_match_data stm32mp13_data = {
15151522
.tab_clocks = stm32mp13_clock_cfg,
15161523
.num_clocks = ARRAY_SIZE(stm32mp13_clock_cfg),
15171524
.clock_data = &stm32mp13_clock_data,
15181525
.check_security = &stm32mp13_clock_is_provided_by_secure,
15191526
.maxbinding = STM32MP1_LAST_CLK,
1520-
.clear_offset = RCC_CLR_OFFSET,
1527+
.reset_data = &stm32mp13_reset_data,
15211528
};
15221529

15231530
static const struct of_device_id stm32mp13_match_data[] = {

0 commit comments

Comments
 (0)