Skip to content

Commit 5ae1a43

Browse files
jbrun3tbebarino
authored andcommitted
clk: amlogic: axg-audio: revert reset implementation
The audio subsystem of axg based platform is not probing anymore. This is due to the introduction of RESET_MESON_AUX and the config not being enabled with the default arm64 defconfig. This brought another discussion around proper decoupling between the clock and reset part. While this discussion gets sorted out, revert back to the initial implementation. This reverts * commit 681ed49 ("clk: amlogic: axg-audio: fix Kconfig dependency on RESET_MESON_AUX") * commit 664988e ("clk: amlogic: axg-audio: use the auxiliary reset driver") Both are reverted with single change to avoid creating more compilation problems. Fixes: 681ed49 ("clk: amlogic: axg-audio: fix Kconfig dependency on RESET_MESON_AUX") Cc: Arnd Bergmann <arnd@arndb.de> Reported-by: Mark Brown <broonie@kernel.org> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://lore.kernel.org/r/20241128-clk-audio-fix-rst-missing-v2-1-cf437d1a73da@baylibre.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 06fec99 commit 5ae1a43

File tree

2 files changed

+101
-10
lines changed

2 files changed

+101
-10
lines changed

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[] = {

0 commit comments

Comments
 (0)