Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'reset-for-v5.11' of git://git.pengutronix.de/pza/linux into arm/drivers

Reset controller updates for v5.11

This tag adds support for sharing pulsed resets under certain
conditions. For example, when multiple drivers go through a
suspend-resume cycle, a reset line they share can be triggered
again during resume.
Further, the reset-meson driver now can be built as a module, the
reset-socfpga driver properly releases its memory region in the
probe error path, and reset-ti-syscon driver uses regmap_write_bits()
instead of regmap_update_bits() to support devices without status
readback.

* tag 'reset-for-v5.11' of git://git.pengutronix.de/pza/linux:
reset-controller: ti: force the write operation when assert or deassert
reset: socfpga: add error handling and release mem-region
reset: meson: make it possible to build as a module
reset: make shared pulsed reset controls re-triggerable

Link: https://lore.kernel.org/r/d586ada0073f2ac50a02274f42bf07bfb0603835.camel@pengutronix.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+94 -6
+2 -1
drivers/reset/Kconfig
··· 95 95 This enables the reset controller driver for NXP LPC18xx/43xx SoCs. 96 96 97 97 config RESET_MESON 98 - bool "Meson Reset Driver" if COMPILE_TEST 98 + tristate "Meson Reset Driver" 99 + depends on ARCH_MESON || COMPILE_TEST 99 100 default ARCH_MESON 100 101 help 101 102 This enables the reset driver for Amlogic Meson SoCs.
+73
drivers/reset/core.c
··· 208 208 return 0; 209 209 } 210 210 211 + static int reset_control_array_rearm(struct reset_control_array *resets) 212 + { 213 + struct reset_control *rstc; 214 + int i; 215 + 216 + for (i = 0; i < resets->num_rstcs; i++) { 217 + rstc = resets->rstc[i]; 218 + 219 + if (!rstc) 220 + continue; 221 + 222 + if (WARN_ON(IS_ERR(rstc))) 223 + return -EINVAL; 224 + 225 + if (rstc->shared) { 226 + if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) 227 + return -EINVAL; 228 + } else { 229 + if (!rstc->acquired) 230 + return -EPERM; 231 + } 232 + } 233 + 234 + for (i = 0; i < resets->num_rstcs; i++) { 235 + rstc = resets->rstc[i]; 236 + 237 + if (rstc && rstc->shared) 238 + WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); 239 + } 240 + 241 + return 0; 242 + } 243 + 211 244 static int reset_control_array_assert(struct reset_control_array *resets) 212 245 { 213 246 int ret, i; ··· 357 324 return ret; 358 325 } 359 326 EXPORT_SYMBOL_GPL(reset_control_reset); 327 + 328 + /** 329 + * reset_control_rearm - allow shared reset line to be re-triggered" 330 + * @rstc: reset controller 331 + * 332 + * On a shared reset line the actual reset pulse is only triggered once for the 333 + * lifetime of the reset_control instance, except if this call is used. 334 + * 335 + * Calls to this function must be balanced with calls to reset_control_reset, 336 + * a warning is thrown in case triggered_count ever dips below 0. 337 + * 338 + * Consumers must not use reset_control_(de)assert on shared reset lines when 339 + * reset_control_reset or reset_control_rearm have been used. 340 + * 341 + * If rstc is NULL the function will just return 0. 342 + */ 343 + int reset_control_rearm(struct reset_control *rstc) 344 + { 345 + if (!rstc) 346 + return 0; 347 + 348 + if (WARN_ON(IS_ERR(rstc))) 349 + return -EINVAL; 350 + 351 + if (reset_control_is_array(rstc)) 352 + return reset_control_array_rearm(rstc_to_array(rstc)); 353 + 354 + if (rstc->shared) { 355 + if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) 356 + return -EINVAL; 357 + 358 + WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); 359 + } else { 360 + if (!rstc->acquired) 361 + return -EPERM; 362 + } 363 + 364 + return 0; 365 + } 366 + EXPORT_SYMBOL_GPL(reset_control_rearm); 360 367 361 368 /** 362 369 * reset_control_assert - asserts the reset line
+7 -1
drivers/reset/reset-meson.c
··· 9 9 #include <linux/init.h> 10 10 #include <linux/io.h> 11 11 #include <linux/of.h> 12 + #include <linux/module.h> 12 13 #include <linux/platform_device.h> 13 14 #include <linux/reset-controller.h> 14 15 #include <linux/slab.h> ··· 105 104 { .compatible = "amlogic,meson-a1-reset", .data = &meson_a1_param}, 106 105 { /* sentinel */ }, 107 106 }; 107 + MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); 108 108 109 109 static int meson_reset_probe(struct platform_device *pdev) 110 110 { ··· 144 142 .of_match_table = meson_reset_dt_ids, 145 143 }, 146 144 }; 147 - builtin_platform_driver(meson_reset_driver); 145 + module_platform_driver(meson_reset_driver); 146 + 147 + MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); 148 + MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>"); 149 + MODULE_LICENSE("Dual BSD/GPL");
+9 -2
drivers/reset/reset-socfpga.c
··· 44 44 data->membase = ioremap(res.start, size); 45 45 if (!data->membase) { 46 46 ret = -ENOMEM; 47 - goto err_alloc; 47 + goto release_region; 48 48 } 49 49 50 50 if (of_property_read_u32(np, "altr,modrst-offset", &reg_offset)) ··· 59 59 data->rcdev.of_node = np; 60 60 data->status_active_low = true; 61 61 62 - return reset_controller_register(&data->rcdev); 62 + ret = reset_controller_register(&data->rcdev); 63 + if (ret) 64 + pr_err("unable to register device\n"); 65 + 66 + return ret; 67 + 68 + release_region: 69 + release_mem_region(res.start, size); 63 70 64 71 err_alloc: 65 72 kfree(data);
+2 -2
drivers/reset/reset-ti-syscon.c
··· 89 89 mask = BIT(control->assert_bit); 90 90 value = (control->flags & ASSERT_SET) ? mask : 0x0; 91 91 92 - return regmap_update_bits(data->regmap, control->assert_offset, mask, value); 92 + return regmap_write_bits(data->regmap, control->assert_offset, mask, value); 93 93 } 94 94 95 95 /** ··· 120 120 mask = BIT(control->deassert_bit); 121 121 value = (control->flags & DEASSERT_SET) ? mask : 0x0; 122 122 123 - return regmap_update_bits(data->regmap, control->deassert_offset, mask, value); 123 + return regmap_write_bits(data->regmap, control->deassert_offset, mask, value); 124 124 } 125 125 126 126 /**
+1
include/linux/reset.h
··· 13 13 #ifdef CONFIG_RESET_CONTROLLER 14 14 15 15 int reset_control_reset(struct reset_control *rstc); 16 + int reset_control_rearm(struct reset_control *rstc); 16 17 int reset_control_assert(struct reset_control *rstc); 17 18 int reset_control_deassert(struct reset_control *rstc); 18 19 int reset_control_status(struct reset_control *rstc);