Skip to content

Commit f51df26

Browse files
committed
Merge tag 'reset-for-v6.14-2' of git://git.pengutronix.de/pza/linux into soc/drivers
Reset controller updates for v6.14 (v2) * Add support for A1 SoC in amlogic reset driver. * Drop aux registration helper from amlogic reset driver. * tag 'reset-for-v6.14-2' of git://git.pengutronix.de/pza/linux: reset: amlogic: aux: drop aux registration helper reset: amlogic: aux: get regmap through parent device reset: amlogic: add support for A1 SoC in auxiliary reset driver dt-bindings: reset: add bindings for A1 SoC audio reset controller clk: amlogic: axg-audio: revert reset implementation Revert "clk: Fix invalid execution of clk_set_rate" Link: https://lore.kernel.org/r/20250115170247.1303656-1-p.zabel@pengutronix.de Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 677184d + 72bb827 commit f51df26

File tree

6 files changed

+159
-110
lines changed

6 files changed

+159
-110
lines changed

drivers/clk/clk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ static int clk_core_set_rate_nolock(struct clk_core *core,
25302530
rate = clk_core_req_round_rate_nolock(core, req_rate);
25312531

25322532
/* bail early if nothing to do */
2533-
if (rate == clk_core_get_rate_recalc(core))
2533+
if (rate == clk_core_get_rate_nolock(core))
25342534
return 0;
25352535

25362536
/* fail on a direct rate set of a protected provider */

drivers/clk/meson/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +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-
depends on RESET_MESON_AUX
109+
select RESET_CONTROLLER
110110
help
111111
Support for the audio clock controller on AmLogic A113D devices,
112112
aka axg, Say Y if you want audio subsystem to work.

drivers/clk/meson/axg-audio.c

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

18-
#include <soc/amlogic/reset-meson-aux.h>
19-
2018
#include "meson-clkc-utils.h"
2119
#include "axg-audio.h"
2220
#include "clk-regmap.h"
@@ -1680,6 +1678,84 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
16801678
&sm1_earcrx_dmac_clk,
16811679
};
16821680

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+
16831759
static struct regmap_config axg_audio_regmap_cfg = {
16841760
.reg_bits = 32,
16851761
.val_bits = 32,
@@ -1690,14 +1766,16 @@ struct audioclk_data {
16901766
struct clk_regmap *const *regmap_clks;
16911767
unsigned int regmap_clk_num;
16921768
struct meson_clk_hw_data hw_clks;
1769+
unsigned int reset_offset;
1770+
unsigned int reset_num;
16931771
unsigned int max_register;
1694-
const char *rst_drvname;
16951772
};
16961773

16971774
static int axg_audio_clkc_probe(struct platform_device *pdev)
16981775
{
16991776
struct device *dev = &pdev->dev;
17001777
const struct audioclk_data *data;
1778+
struct axg_audio_reset_data *rst;
17011779
struct regmap *map;
17021780
void __iomem *regs;
17031781
struct clk_hw *hw;
@@ -1756,11 +1834,22 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
17561834
if (ret)
17571835
return ret;
17581836

1759-
/* Register auxiliary reset driver when applicable */
1760-
if (data->rst_drvname)
1761-
ret = devm_meson_rst_aux_register(dev, map, data->rst_drvname);
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;
17621851

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

17661855
static const struct audioclk_data axg_audioclk_data = {
@@ -1780,8 +1869,9 @@ static const struct audioclk_data g12a_audioclk_data = {
17801869
.hws = g12a_audio_hw_clks,
17811870
.num = ARRAY_SIZE(g12a_audio_hw_clks),
17821871
},
1872+
.reset_offset = AUDIO_SW_RESET,
1873+
.reset_num = 26,
17831874
.max_register = AUDIO_CLK_SPDIFOUT_B_CTRL,
1784-
.rst_drvname = "rst-g12a",
17851875
};
17861876

17871877
static const struct audioclk_data sm1_audioclk_data = {
@@ -1791,8 +1881,9 @@ static const struct audioclk_data sm1_audioclk_data = {
17911881
.hws = sm1_audio_hw_clks,
17921882
.num = ARRAY_SIZE(sm1_audio_hw_clks),
17931883
},
1884+
.reset_offset = AUDIO_SM1_SW_RESET0,
1885+
.reset_num = 39,
17941886
.max_register = AUDIO_EARCRX_DMAC_CLK_CTRL,
1795-
.rst_drvname = "rst-sm1",
17961887
};
17971888

17981889
static const struct of_device_id clkc_match_table[] = {

drivers/reset/amlogic/reset-meson-aux.c

Lines changed: 21 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111
#include <linux/auxiliary_bus.h>
1212
#include <linux/regmap.h>
1313
#include <linux/reset-controller.h>
14-
#include <linux/slab.h>
1514

1615
#include "reset-meson.h"
17-
#include <soc/amlogic/reset-meson-aux.h>
1816

19-
static DEFINE_IDA(meson_rst_aux_ida);
20-
21-
struct meson_reset_adev {
22-
struct auxiliary_device adev;
23-
struct regmap *map;
17+
static const struct meson_reset_param meson_a1_audio_param = {
18+
.reset_ops = &meson_reset_toggle_ops,
19+
.reset_num = 32,
20+
.level_offset = 0x28,
2421
};
2522

26-
#define to_meson_reset_adev(_adev) \
27-
container_of((_adev), struct meson_reset_adev, adev)
23+
static const struct meson_reset_param meson_a1_audio_vad_param = {
24+
.reset_ops = &meson_reset_toggle_ops,
25+
.reset_num = 6,
26+
.level_offset = 0x8,
27+
};
2828

2929
static const struct meson_reset_param meson_g12a_audio_param = {
3030
.reset_ops = &meson_reset_toggle_ops,
@@ -40,6 +40,12 @@ static const struct meson_reset_param meson_sm1_audio_param = {
4040

4141
static const struct auxiliary_device_id meson_reset_aux_ids[] = {
4242
{
43+
.name = "a1-audio-clkc.rst-a1",
44+
.driver_data = (kernel_ulong_t)&meson_a1_audio_param,
45+
}, {
46+
.name = "a1-audio-clkc.rst-a1-vad",
47+
.driver_data = (kernel_ulong_t)&meson_a1_audio_vad_param,
48+
}, {
4349
.name = "axg-audio-clkc.rst-g12a",
4450
.driver_data = (kernel_ulong_t)&meson_g12a_audio_param,
4551
}, {
@@ -54,10 +60,13 @@ static int meson_reset_aux_probe(struct auxiliary_device *adev,
5460
{
5561
const struct meson_reset_param *param =
5662
(const struct meson_reset_param *)(id->driver_data);
57-
struct meson_reset_adev *raux =
58-
to_meson_reset_adev(adev);
63+
struct regmap *map;
64+
65+
map = dev_get_regmap(adev->dev.parent, NULL);
66+
if (!map)
67+
return -EINVAL;
5968

60-
return meson_reset_controller_register(&adev->dev, raux->map, param);
69+
return meson_reset_controller_register(&adev->dev, map, param);
6170
}
6271

6372
static struct auxiliary_driver meson_reset_aux_driver = {
@@ -66,70 +75,6 @@ static struct auxiliary_driver meson_reset_aux_driver = {
6675
};
6776
module_auxiliary_driver(meson_reset_aux_driver);
6877

69-
static void meson_rst_aux_release(struct device *dev)
70-
{
71-
struct auxiliary_device *adev = to_auxiliary_dev(dev);
72-
struct meson_reset_adev *raux =
73-
to_meson_reset_adev(adev);
74-
75-
ida_free(&meson_rst_aux_ida, adev->id);
76-
kfree(raux);
77-
}
78-
79-
static void meson_rst_aux_unregister_adev(void *_adev)
80-
{
81-
struct auxiliary_device *adev = _adev;
82-
83-
auxiliary_device_delete(adev);
84-
auxiliary_device_uninit(adev);
85-
}
86-
87-
int devm_meson_rst_aux_register(struct device *dev,
88-
struct regmap *map,
89-
const char *adev_name)
90-
{
91-
struct meson_reset_adev *raux;
92-
struct auxiliary_device *adev;
93-
int ret;
94-
95-
raux = kzalloc(sizeof(*raux), GFP_KERNEL);
96-
if (!raux)
97-
return -ENOMEM;
98-
99-
ret = ida_alloc(&meson_rst_aux_ida, GFP_KERNEL);
100-
if (ret < 0)
101-
goto raux_free;
102-
103-
raux->map = map;
104-
105-
adev = &raux->adev;
106-
adev->id = ret;
107-
adev->name = adev_name;
108-
adev->dev.parent = dev;
109-
adev->dev.release = meson_rst_aux_release;
110-
device_set_of_node_from_dev(&adev->dev, dev);
111-
112-
ret = auxiliary_device_init(adev);
113-
if (ret)
114-
goto ida_free;
115-
116-
ret = __auxiliary_device_add(adev, dev->driver->name);
117-
if (ret) {
118-
auxiliary_device_uninit(adev);
119-
return ret;
120-
}
121-
122-
return devm_add_action_or_reset(dev, meson_rst_aux_unregister_adev,
123-
adev);
124-
125-
ida_free:
126-
ida_free(&meson_rst_aux_ida, adev->id);
127-
raux_free:
128-
kfree(raux);
129-
return ret;
130-
}
131-
EXPORT_SYMBOL_GPL(devm_meson_rst_aux_register);
132-
13378
MODULE_DESCRIPTION("Amlogic Meson Reset Auxiliary driver");
13479
MODULE_AUTHOR("Jerome Brunet <jbrunet@baylibre.com>");
13580
MODULE_LICENSE("Dual BSD/GPL");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2+
/*
3+
* Copyright (c) 2024, SaluteDevices. All Rights Reserved.
4+
*
5+
* Author: Jan Dakinevich <jan.dakinevich@salutedevices.com>
6+
*/
7+
8+
#ifndef _DT_BINDINGS_AMLOGIC_MESON_A1_AUDIO_RESET_H
9+
#define _DT_BINDINGS_AMLOGIC_MESON_A1_AUDIO_RESET_H
10+
11+
#define AUD_RESET_DDRARB 0
12+
#define AUD_RESET_TDMIN_A 1
13+
#define AUD_RESET_TDMIN_B 2
14+
#define AUD_RESET_TDMIN_LB 3
15+
#define AUD_RESET_LOOPBACK 4
16+
#define AUD_RESET_TDMOUT_A 5
17+
#define AUD_RESET_TDMOUT_B 6
18+
#define AUD_RESET_FRDDR_A 7
19+
#define AUD_RESET_FRDDR_B 8
20+
#define AUD_RESET_TODDR_A 9
21+
#define AUD_RESET_TODDR_B 10
22+
#define AUD_RESET_SPDIFIN 11
23+
#define AUD_RESET_RESAMPLE 12
24+
#define AUD_RESET_EQDRC 13
25+
#define AUD_RESET_LOCKER 14
26+
#define AUD_RESET_TOACODEC 30
27+
#define AUD_RESET_CLKTREE 31
28+
29+
#define AUD_VAD_RESET_DDRARB 0
30+
#define AUD_VAD_RESET_PDM 1
31+
#define AUD_VAD_RESET_TDMIN_VAD 2
32+
#define AUD_VAD_RESET_TODDR_VAD 3
33+
#define AUD_VAD_RESET_TOVAD 4
34+
#define AUD_VAD_RESET_CLKTREE 5
35+
36+
#endif /* _DT_BINDINGS_AMLOGIC_MESON_A1_AUDIO_RESET_H */

include/soc/amlogic/reset-meson-aux.h

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

0 commit comments

Comments
 (0)