Skip to content

Commit

Permalink
reset: amlogic: add driver parameters
Browse files Browse the repository at this point in the history
To allow using the same driver for the main reset controller and the
auxiliary ones embedded in the clock controllers, allow to customise
the reset offset, same as the level offset. Also add an option to make
the level reset active low or high.

Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20240910-meson-rst-aux-v5-4-60be62635d3e@baylibre.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
  • Loading branch information
Jerome Brunet authored and Philipp Zabel committed Oct 1, 2024
1 parent ee64998 commit 6b2d2e5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/reset/reset-meson.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

struct meson_reset_param {
unsigned int reg_count;
unsigned int reset_offset;
unsigned int level_offset;
bool level_low_reset;
};

struct meson_reset {
Expand Down Expand Up @@ -46,6 +48,7 @@ static int meson_reset_reset(struct reset_controller_dev *rcdev,
unsigned int offset, bit;

meson_reset_offset_and_bit(data, id, &offset, &bit);
offset += data->param->reset_offset;

return regmap_write(data->map, offset, BIT(bit));
}
Expand All @@ -59,9 +62,10 @@ static int meson_reset_level(struct reset_controller_dev *rcdev,

meson_reset_offset_and_bit(data, id, &offset, &bit);
offset += data->param->level_offset;
assert ^= data->param->level_low_reset;

return regmap_update_bits(data->map, offset,
BIT(bit), assert ? 0 : BIT(bit));
BIT(bit), assert ? BIT(bit) : 0);
}

static int meson_reset_assert(struct reset_controller_dev *rcdev,
Expand All @@ -84,22 +88,30 @@ static const struct reset_control_ops meson_reset_ops = {

static const struct meson_reset_param meson8b_param = {
.reg_count = 8,
.reset_offset = 0x0,
.level_offset = 0x7c,
.level_low_reset = true,
};

static const struct meson_reset_param meson_a1_param = {
.reg_count = 3,
.reset_offset = 0x0,
.level_offset = 0x40,
.level_low_reset = true,
};

static const struct meson_reset_param meson_s4_param = {
.reg_count = 6,
.reset_offset = 0x0,
.level_offset = 0x40,
.level_low_reset = true,
};

static const struct meson_reset_param t7_param = {
.reg_count = 7,
.reset_offset = 0x0,
.level_offset = 0x40,
.level_low_reset = true,
};

static const struct of_device_id meson_reset_dt_ids[] = {
Expand Down

0 comments on commit 6b2d2e5

Please sign in to comment.