Lines Matching +full:reset +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI SYSCON regmap reset driver
5 * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
15 #include <linux/reset-controller.h>
17 #include <dt-bindings/reset/ti-syscon.h>
20 * struct ti_syscon_reset_control - reset control structure
21 * @assert_offset: reset assert control register offset from syscon base
22 * @assert_bit: reset assert bit in the reset assert control register
23 * @deassert_offset: reset deassert control register offset from syscon base
24 * @deassert_bit: reset deassert bit in the reset deassert control register
25 * @status_offset: reset status register offset from syscon base
26 * @status_bit: reset status bit in the reset status register
27 * @flags: reset flag indicating how the (de)assert and status are handled
40 * struct ti_syscon_reset_data - reset controller information structure
41 * @rcdev: reset controller entity
42 * @regmap: regmap handle containing the memory-mapped reset registers
43 * @controls: array of reset controls
57 * ti_syscon_reset_assert() - assert device reset
58 * @rcdev: reset controller entity
59 * @id: ID of the reset to be asserted
61 * This function implements the reset driver op to assert a device's reset.
62 * This asserts the reset in a manner prescribed by the reset flags.
71 unsigned int mask, value; in ti_syscon_reset_assert() local
73 if (id >= data->nr_controls) in ti_syscon_reset_assert()
74 return -EINVAL; in ti_syscon_reset_assert()
76 control = &data->controls[id]; in ti_syscon_reset_assert()
78 if (control->flags & ASSERT_NONE) in ti_syscon_reset_assert()
79 return -ENOTSUPP; /* assert not supported for this reset */ in ti_syscon_reset_assert()
81 mask = BIT(control->assert_bit); in ti_syscon_reset_assert()
82 value = (control->flags & ASSERT_SET) ? mask : 0x0; in ti_syscon_reset_assert()
84 return regmap_write_bits(data->regmap, control->assert_offset, mask, value); in ti_syscon_reset_assert()
88 * ti_syscon_reset_deassert() - deassert device reset
89 * @rcdev: reset controller entity
90 * @id: ID of reset to be deasserted
92 * This function implements the reset driver op to deassert a device's reset.
93 * This deasserts the reset in a manner prescribed by the reset flags.
102 unsigned int mask, value; in ti_syscon_reset_deassert() local
104 if (id >= data->nr_controls) in ti_syscon_reset_deassert()
105 return -EINVAL; in ti_syscon_reset_deassert()
107 control = &data->controls[id]; in ti_syscon_reset_deassert()
109 if (control->flags & DEASSERT_NONE) in ti_syscon_reset_deassert()
110 return -ENOTSUPP; /* deassert not supported for this reset */ in ti_syscon_reset_deassert()
112 mask = BIT(control->deassert_bit); in ti_syscon_reset_deassert()
113 value = (control->flags & DEASSERT_SET) ? mask : 0x0; in ti_syscon_reset_deassert()
115 return regmap_write_bits(data->regmap, control->deassert_offset, mask, value); in ti_syscon_reset_deassert()
119 * ti_syscon_reset_status() - check device reset status
120 * @rcdev: reset controller entity
121 * @id: ID of the reset for which the status is being requested
123 * This function implements the reset driver op to return the status of a
124 * device's reset.
126 * Return: 0 if reset is deasserted, true if reset is asserted, else a
137 if (id >= data->nr_controls) in ti_syscon_reset_status()
138 return -EINVAL; in ti_syscon_reset_status()
140 control = &data->controls[id]; in ti_syscon_reset_status()
142 if (control->flags & STATUS_NONE) in ti_syscon_reset_status()
143 return -ENOTSUPP; /* status not supported for this reset */ in ti_syscon_reset_status()
145 ret = regmap_read(data->regmap, control->status_offset, &reset_state); in ti_syscon_reset_status()
149 return !(reset_state & BIT(control->status_bit)) == in ti_syscon_reset_status()
150 !(control->flags & STATUS_SET); in ti_syscon_reset_status()
161 struct device *dev = &pdev->dev; in ti_syscon_reset_probe()
162 struct device_node *np = dev->of_node; in ti_syscon_reset_probe()
171 return -ENOMEM; in ti_syscon_reset_probe()
173 regmap = syscon_node_to_regmap(np->parent); in ti_syscon_reset_probe()
177 list = of_get_property(np, "ti,reset-bits", &size); in ti_syscon_reset_probe()
179 dev_err(dev, "invalid DT reset description\n"); in ti_syscon_reset_probe()
180 return -EINVAL; in ti_syscon_reset_probe()
187 return -ENOMEM; in ti_syscon_reset_probe()
199 data->rcdev.ops = &ti_syscon_reset_ops; in ti_syscon_reset_probe()
200 data->rcdev.owner = THIS_MODULE; in ti_syscon_reset_probe()
201 data->rcdev.of_node = np; in ti_syscon_reset_probe()
202 data->rcdev.nr_resets = nr_controls; in ti_syscon_reset_probe()
203 data->regmap = regmap; in ti_syscon_reset_probe()
204 data->controls = controls; in ti_syscon_reset_probe()
205 data->nr_controls = nr_controls; in ti_syscon_reset_probe()
207 return devm_reset_controller_register(dev, &data->rcdev); in ti_syscon_reset_probe()
211 { .compatible = "ti,syscon-reset", },
219 .name = "ti-syscon-reset",
226 MODULE_AUTHOR("Suman Anna <s-anna@ti.com>");
227 MODULE_DESCRIPTION("TI SYSCON Regmap Reset Driver");