return 0;
}
----static int axg_register_clk_hw_input(struct device *dev,
---- const char *name)
++++struct axg_audio_reset_data {
++++ struct reset_controller_dev rstc;
++++ struct regmap *map;
++++ unsigned int offset;
++++};
++++
++++static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst,
++++ unsigned long id,
++++ unsigned int *reg,
++++ unsigned int *bit)
+ {
--- char *clk_name;
--- struct clk_hw *hw;
--- int err = 0;
++++ unsigned int stride = regmap_get_reg_stride(rst->map);
+
--- clk_name = kasprintf(GFP_KERNEL, "aud_%s", name);
--- if (!clk_name)
--- return -ENOMEM;
++++ *reg = (id / (stride * BITS_PER_BYTE)) * stride;
++++ *reg += rst->offset;
++++ *bit = id % (stride * BITS_PER_BYTE);
++++}
+
--- hw = meson_clk_hw_register_input(dev, name, clk_name, 0);
--- if (IS_ERR(hw)) {
--- /* It is ok if an input clock is missing */
--- if (PTR_ERR(hw) == -ENOENT) {
--- dev_dbg(dev, "%s not provided", name);
--- } else {
--- err = PTR_ERR(hw);
--- if (err != -EPROBE_DEFER)
--- dev_err(dev, "failed to get %s clock", name);
--- }
--- }
++++static int axg_audio_reset_update(struct reset_controller_dev *rcdev,
++++ unsigned long id, bool assert)
+++{
- char *clk_name;
- struct clk_hw *hw;
- int err = 0;
++++ struct axg_audio_reset_data *rst =
++++ container_of(rcdev, struct axg_audio_reset_data, rstc);
++++ unsigned int offset, bit;
+++
- clk_name = kasprintf(GFP_KERNEL, "aud_%s", name);
- if (!clk_name)
- return -ENOMEM;
++++ axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
- hw = meson_clk_hw_register_input(dev, name, clk_name, 0);
- if (IS_ERR(hw)) {
- /* It is ok if an input clock is missing */
- if (PTR_ERR(hw) == -ENOENT) {
- dev_dbg(dev, "%s not provided", name);
- } else {
- err = PTR_ERR(hw);
- if (err != -EPROBE_DEFER)
- dev_err(dev, "failed to get %s clock", name);
- }
- }
--- kfree(clk_name);
--- return err;
++++ regmap_update_bits(rst->map, offset, BIT(bit),
++++ assert ? BIT(bit) : 0);
+++
- kfree(clk_name);
- return err;
++++ return 0;
}
----static int axg_register_clk_hw_inputs(struct device *dev,
---- const char *basename,
---- unsigned int count)
++++static int axg_audio_reset_status(struct reset_controller_dev *rcdev,
++++ unsigned long id)
{
---- char *name;
---- int i, ret;
++++ struct axg_audio_reset_data *rst =
++++ container_of(rcdev, struct axg_audio_reset_data, rstc);
++++ unsigned int val, offset, bit;
---- for (i = 0; i < count; i++) {
---- name = kasprintf(GFP_KERNEL, "%s%d", basename, i);
---- if (!name)
---- return -ENOMEM;
++++ axg_audio_reset_reg_and_bit(rst, id, &offset, &bit);
---- ret = axg_register_clk_hw_input(dev, name);
---- kfree(name);
---- if (ret)
---- return ret;
---- }
++++ regmap_read(rst->map, offset, &val);
---- return 0;
++++ return !!(val & BIT(bit));
+++}
+++
++++static int axg_audio_reset_assert(struct reset_controller_dev *rcdev,
++++ unsigned long id)
++++{
++++ return axg_audio_reset_update(rcdev, id, true);
+ }
+
++++static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev,
++++ unsigned long id)
++++{
++++ return axg_audio_reset_update(rcdev, id, false);
++++}
++++
++++static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev,
++++ unsigned long id)
++++{
++++ int ret;
++++
++++ ret = axg_audio_reset_assert(rcdev, id);
++++ if (ret)
++++ return ret;
++++
++++ return axg_audio_reset_deassert(rcdev, id);
++++}
++++
++++static const struct reset_control_ops axg_audio_rstc_ops = {
++++ .assert = axg_audio_reset_assert,
++++ .deassert = axg_audio_reset_deassert,
++++ .reset = axg_audio_reset_toggle,
++++ .status = axg_audio_reset_status,
++++};
++++
static const struct regmap_config axg_audio_regmap_cfg = {
.reg_bits = 32,
.val_bits = 32,