Skip to content

Commit c601478

Browse files
committed
Merge tag 'clk-meson-v6.13-1' of https://github.com/BayLibre/clk-meson into clk-amlogic
Pull Amlogic clk driver updates from Jerome Brunet: - Fix hifi_pll rate calculation on Amlogic s4 and c3 - Move audio reset implementation from the Amlogic axg-audio clock controller driver to the reset directory, using the auxiliary device bus - Remove the unnecessary spinlock in the Amlogic mpll driver - Fix Amlogic meson8 clock controller DT bindings * tag 'clk-meson-v6.13-1' of https://github.com/BayLibre/clk-meson: clk: amlogic: axg-audio: use the auxiliary reset driver reset: amlogic: Fix small whitespace issue reset: amlogic: add auxiliary reset driver support reset: amlogic: split the device core and platform probe reset: amlogic: move drivers to a dedicated directory reset: amlogic: add reset status support reset: amlogic: use reset number instead of register count reset: amlogic: add driver parameters reset: amlogic: make parameters unsigned reset: amlogic: use generic data matching function reset: amlogic: convert driver to regmap dt-bindings: clock: convert amlogic,meson8b-clkc.txt to dtschema clk: meson: meson8b: remove spinlock clk: meson: mpll: Delete a useless spinlock from the MPLL clk: meson: s4: pll: fix frac maximum value for hifi_pll clk: meson: c3: pll: fix frac maximum value for hifi_pll clk: meson: Support PLL with fixed fractional denominators clk: meson: s4: pll: hifi_pll support fractional multiplier
2 parents 9852d85 + 664988e commit c601478

25 files changed

+535
-376
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/clock/amlogic,meson8-clkc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Amlogic Meson8, Meson8b and Meson8m2 Clock and Reset Controller
8+
9+
maintainers:
10+
- Neil Armstrong <[email protected]>
11+
12+
properties:
13+
compatible:
14+
oneOf:
15+
- enum:
16+
- amlogic,meson8-clkc
17+
- amlogic,meson8b-clkc
18+
- items:
19+
- const: amlogic,meson8m2-clkc
20+
- const: amlogic,meson8-clkc
21+
22+
clocks:
23+
minItems: 2
24+
maxItems: 3
25+
26+
clock-names:
27+
minItems: 2
28+
items:
29+
- const: xtal
30+
- const: ddr_pll
31+
- const: clk_32k
32+
33+
'#clock-cells':
34+
const: 1
35+
36+
'#reset-cells':
37+
const: 1
38+
39+
required:
40+
- compatible
41+
- clocks
42+
- clock-names
43+
- '#reset-cells'
44+
45+
additionalProperties: false

Documentation/devicetree/bindings/clock/amlogic,meson8b-clkc.txt

Lines changed: 0 additions & 51 deletions
This file was deleted.

drivers/clk/meson/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ config COMMON_CLK_AXG_AUDIO
106106
select COMMON_CLK_MESON_SCLK_DIV
107107
select COMMON_CLK_MESON_CLKC_UTILS
108108
select REGMAP_MMIO
109+
imply RESET_MESON_AUX
109110
help
110111
Support for the audio clock controller on AmLogic A113D devices,
111112
aka axg, Say Y if you want audio subsystem to work.

drivers/clk/meson/axg-audio.c

Lines changed: 9 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/reset-controller.h>
1616
#include <linux/slab.h>
1717

18+
#include <soc/amlogic/reset-meson-aux.h>
19+
1820
#include "meson-clkc-utils.h"
1921
#include "axg-audio.h"
2022
#include "clk-regmap.h"
@@ -1678,84 +1680,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
16781680
&sm1_earcrx_dmac_clk,
16791681
};
16801682

1681-
struct axg_audio_reset_data {
1682-
struct reset_controller_dev rstc;
1683-
struct regmap *map;
1684-
unsigned int offset;
1685-
};
1686-
1687-
static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst,
1688-
unsigned long id,
1689-
unsigned int *reg,
1690-
unsigned int *bit)
1691-
{
1692-
unsigned int stride = regmap_get_reg_stride(rst->map);
1693-
1694-
*reg = (id / (stride * BITS_PER_BYTE)) * stride;
1695-
*reg += rst->offset;
1696-
*bit = id % (stride * BITS_PER_BYTE);
1697-
}
1698-
1699-
static int axg_audio_reset_update(struct reset_controller_dev *rcdev,
1700-
unsigned long id, bool assert)
1701-
{
1702-
struct axg_audio_reset_data *rst =
1703-
container_of(rcdev, struct axg_audio_reset_data, rstc);
1704-
unsigned int offset, bit;
1705-
1706-
axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
1707-
1708-
regmap_update_bits(rst->map, offset, BIT(bit),
1709-
assert ? BIT(bit) : 0);
1710-
1711-
return 0;
1712-
}
1713-
1714-
static int axg_audio_reset_status(struct reset_controller_dev *rcdev,
1715-
unsigned long id)
1716-
{
1717-
struct axg_audio_reset_data *rst =
1718-
container_of(rcdev, struct axg_audio_reset_data, rstc);
1719-
unsigned int val, offset, bit;
1720-
1721-
axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
1722-
1723-
regmap_read(rst->map, offset, &val);
1724-
1725-
return !!(val & BIT(bit));
1726-
}
1727-
1728-
static int axg_audio_reset_assert(struct reset_controller_dev *rcdev,
1729-
unsigned long id)
1730-
{
1731-
return axg_audio_reset_update(rcdev, id, true);
1732-
}
1733-
1734-
static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev,
1735-
unsigned long id)
1736-
{
1737-
return axg_audio_reset_update(rcdev, id, false);
1738-
}
1739-
1740-
static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev,
1741-
unsigned long id)
1742-
{
1743-
int ret;
1744-
1745-
ret = axg_audio_reset_assert(rcdev, id);
1746-
if (ret)
1747-
return ret;
1748-
1749-
return axg_audio_reset_deassert(rcdev, id);
1750-
}
1751-
1752-
static const struct reset_control_ops axg_audio_rstc_ops = {
1753-
.assert = axg_audio_reset_assert,
1754-
.deassert = axg_audio_reset_deassert,
1755-
.reset = axg_audio_reset_toggle,
1756-
.status = axg_audio_reset_status,
1757-
};
1758-
17591683
static struct regmap_config axg_audio_regmap_cfg = {
17601684
.reg_bits = 32,
17611685
.val_bits = 32,
@@ -1766,16 +1690,14 @@ struct audioclk_data {
17661690
struct clk_regmap *const *regmap_clks;
17671691
unsigned int regmap_clk_num;
17681692
struct meson_clk_hw_data hw_clks;
1769-
unsigned int reset_offset;
1770-
unsigned int reset_num;
17711693
unsigned int max_register;
1694+
const char *rst_drvname;
17721695
};
17731696

17741697
static int axg_audio_clkc_probe(struct platform_device *pdev)
17751698
{
17761699
struct device *dev = &pdev->dev;
17771700
const struct audioclk_data *data;
1778-
struct axg_audio_reset_data *rst;
17791701
struct regmap *map;
17801702
void __iomem *regs;
17811703
struct clk_hw *hw;
@@ -1834,22 +1756,11 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
18341756
if (ret)
18351757
return ret;
18361758

1837-
/* Stop here if there is no reset */
1838-
if (!data->reset_num)
1839-
return 0;
1840-
1841-
rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL);
1842-
if (!rst)
1843-
return -ENOMEM;
1844-
1845-
rst->map = map;
1846-
rst->offset = data->reset_offset;
1847-
rst->rstc.nr_resets = data->reset_num;
1848-
rst->rstc.ops = &axg_audio_rstc_ops;
1849-
rst->rstc.of_node = dev->of_node;
1850-
rst->rstc.owner = THIS_MODULE;
1759+
/* Register auxiliary reset driver when applicable */
1760+
if (data->rst_drvname)
1761+
ret = devm_meson_rst_aux_register(dev, map, data->rst_drvname);
18511762

1852-
return devm_reset_controller_register(dev, &rst->rstc);
1763+
return ret;
18531764
}
18541765

18551766
static const struct audioclk_data axg_audioclk_data = {
@@ -1869,9 +1780,8 @@ static const struct audioclk_data g12a_audioclk_data = {
18691780
.hws = g12a_audio_hw_clks,
18701781
.num = ARRAY_SIZE(g12a_audio_hw_clks),
18711782
},
1872-
.reset_offset = AUDIO_SW_RESET,
1873-
.reset_num = 26,
18741783
.max_register = AUDIO_CLK_SPDIFOUT_B_CTRL,
1784+
.rst_drvname = "rst-g12a",
18751785
};
18761786

18771787
static const struct audioclk_data sm1_audioclk_data = {
@@ -1881,9 +1791,8 @@ static const struct audioclk_data sm1_audioclk_data = {
18811791
.hws = sm1_audio_hw_clks,
18821792
.num = ARRAY_SIZE(sm1_audio_hw_clks),
18831793
},
1884-
.reset_offset = AUDIO_SM1_SW_RESET0,
1885-
.reset_num = 39,
18861794
.max_register = AUDIO_EARCRX_DMAC_CLK_CTRL,
1795+
.rst_drvname = "rst-sm1",
18871796
};
18881797

18891798
static const struct of_device_id clkc_match_table[] = {

drivers/clk/meson/axg.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
#include <dt-bindings/clock/axg-clkc.h>
2525

26-
static DEFINE_SPINLOCK(meson_clk_lock);
27-
2826
static struct clk_regmap axg_fixed_pll_dco = {
2927
.data = &(struct meson_clk_pll_data){
3028
.en = {
@@ -506,7 +504,6 @@ static struct clk_regmap axg_mpll0_div = {
506504
.shift = 0,
507505
.width = 1,
508506
},
509-
.lock = &meson_clk_lock,
510507
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
511508
},
512509
.hw.init = &(struct clk_init_data){
@@ -557,7 +554,6 @@ static struct clk_regmap axg_mpll1_div = {
557554
.shift = 1,
558555
.width = 1,
559556
},
560-
.lock = &meson_clk_lock,
561557
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
562558
},
563559
.hw.init = &(struct clk_init_data){
@@ -613,7 +609,6 @@ static struct clk_regmap axg_mpll2_div = {
613609
.shift = 2,
614610
.width = 1,
615611
},
616-
.lock = &meson_clk_lock,
617612
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
618613
},
619614
.hw.init = &(struct clk_init_data){
@@ -664,7 +659,6 @@ static struct clk_regmap axg_mpll3_div = {
664659
.shift = 3,
665660
.width = 1,
666661
},
667-
.lock = &meson_clk_lock,
668662
.flags = CLK_MESON_MPLL_ROUND_CLOSEST,
669663
},
670664
.hw.init = &(struct clk_init_data){

drivers/clk/meson/c3-pll.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ static struct clk_regmap hifi_pll_dco = {
361361
.range = &c3_gp0_pll_mult_range,
362362
.init_regs = c3_hifi_init_regs,
363363
.init_count = ARRAY_SIZE(c3_hifi_init_regs),
364+
.frac_max = 100000,
364365
},
365366
.hw.init = &(struct clk_init_data) {
366367
.name = "hifi_pll_dco",

drivers/clk/meson/clk-mpll.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,15 @@ static int mpll_set_rate(struct clk_hw *hw,
112112
struct clk_regmap *clk = to_clk_regmap(hw);
113113
struct meson_clk_mpll_data *mpll = meson_clk_mpll_data(clk);
114114
unsigned int sdm, n2;
115-
unsigned long flags = 0;
116115

117116
params_from_rate(rate, parent_rate, &sdm, &n2, mpll->flags);
118117

119-
if (mpll->lock)
120-
spin_lock_irqsave(mpll->lock, flags);
121-
else
122-
__acquire(mpll->lock);
123-
124118
/* Set the fractional part */
125119
meson_parm_write(clk->map, &mpll->sdm, sdm);
126120

127121
/* Set the integer divider part */
128122
meson_parm_write(clk->map, &mpll->n2, n2);
129123

130-
if (mpll->lock)
131-
spin_unlock_irqrestore(mpll->lock, flags);
132-
else
133-
__release(mpll->lock);
134-
135124
return 0;
136125
}
137126

drivers/clk/meson/clk-mpll.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ struct meson_clk_mpll_data {
2020
struct parm misc;
2121
const struct reg_sequence *init_regs;
2222
unsigned int init_count;
23-
spinlock_t *lock;
2423
u8 flags;
2524
};
2625

drivers/clk/meson/clk-pll.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ static unsigned long __pll_params_to_rate(unsigned long parent_rate,
5757
struct meson_clk_pll_data *pll)
5858
{
5959
u64 rate = (u64)parent_rate * m;
60+
unsigned int frac_max = pll->frac_max ? pll->frac_max :
61+
(1 << pll->frac.width);
6062

6163
if (frac && MESON_PARM_APPLICABLE(&pll->frac)) {
6264
u64 frac_rate = (u64)parent_rate * frac;
6365

64-
rate += DIV_ROUND_UP_ULL(frac_rate,
65-
(1 << pll->frac.width));
66+
rate += DIV_ROUND_UP_ULL(frac_rate, frac_max);
6667
}
6768

6869
return DIV_ROUND_UP_ULL(rate, n);
@@ -100,7 +101,8 @@ static unsigned int __pll_params_with_frac(unsigned long rate,
100101
unsigned int n,
101102
struct meson_clk_pll_data *pll)
102103
{
103-
unsigned int frac_max = (1 << pll->frac.width);
104+
unsigned int frac_max = pll->frac_max ? pll->frac_max :
105+
(1 << pll->frac.width);
104106
u64 val = (u64)rate * n;
105107

106108
/* Bail out if we are already over the requested rate */

drivers/clk/meson/clk-pll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct meson_clk_pll_data {
4343
unsigned int init_count;
4444
const struct pll_params_table *table;
4545
const struct pll_mult_range *range;
46+
unsigned int frac_max;
4647
u8 flags;
4748
};
4849

0 commit comments

Comments
 (0)