Message ID | 20240808102742.4095904-5-jbrunet@baylibre.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | reset: amlogic: move audio reset drivers out of CCF | expand |
On 08/08/2024 12:27, Jerome Brunet wrote: > 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> > --- > drivers/reset/reset-meson.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c > index 460ad2f8360f..8addd100e601 100644 > --- a/drivers/reset/reset-meson.c > +++ b/drivers/reset/reset-meson.c > @@ -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 { > @@ -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)); > } > @@ -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, > @@ -84,17 +88,23 @@ 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, Just a comment, I would rather leave the "default" users of this driver with the default value and use level_high_reset = true for the clock ones Neil > }; > > static const struct of_device_id meson_reset_dt_ids[] = {
On Mon 19 Aug 2024 at 17:57, Neil Armstrong <neil.armstrong@linaro.org> wrote: >> + 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, >> @@ -84,17 +88,23 @@ 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, > > Just a comment, I would rather leave the "default" users of this driver with the default value > and use level_high_reset = true for the clock ones In every other place in the kernel, we specify that kind of thing if it is acitve low. Your request make things up-side-down and harder to follow IMO. There is no 'default' user, there is the platform ones and auxiliary ones. Platform ones tend to active low reset line. It is clearly shown above and hard to miss when adding new platforms. > > Neil > >> }; >> static const struct of_device_id meson_reset_dt_ids[] = {
On 19/08/2024 18:40, Jerome Brunet wrote: > On Mon 19 Aug 2024 at 17:57, Neil Armstrong <neil.armstrong@linaro.org> wrote: > >>> + 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, >>> @@ -84,17 +88,23 @@ 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, >> >> Just a comment, I would rather leave the "default" users of this driver with the default value >> and use level_high_reset = true for the clock ones > > In every other place in the kernel, we specify that kind of thing if it > is acitve low. Your request make things up-side-down and harder to > follow IMO. > > There is no 'default' user, there is the platform ones and auxiliary ones. > Platform ones tend to active low reset line. It is clearly shown above > and hard to miss when adding new platforms. It's only a suggestion, we tend to not add `= true` to existing users and keep the new boolean properties for the new users, whatever the logic, and since the driver originally did set the reset as low lever by default, it makes sense use level_high_reset whatever other drivers does. > >> >> Neil >> >>> }; >>> static const struct of_device_id meson_reset_dt_ids[] = { >
diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 460ad2f8360f..8addd100e601 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -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 { @@ -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)); } @@ -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, @@ -84,17 +88,23 @@ 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 of_device_id meson_reset_dt_ids[] = {
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> --- drivers/reset/reset-meson.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)