Lines Matching +full:reset +full:- +full:controller
2 * Texas Instrument's System Control Interface (TI-SCI) reset driver
4 * Copyright (C) 2015-2017 Texas Instruments Incorporated - https://www.ti.com/
22 #include <linux/reset-controller.h>
26 * struct ti_sci_reset_control - reset control structure
27 * @dev_id: SoC-specific device identifier
28 * @reset_mask: reset mask to use for toggling reset
29 * @lock: synchronize reset_mask read-modify-writes
38 * struct ti_sci_reset_data - reset controller information structure
39 * @rcdev: reset controller entity
40 * @dev: reset controller device pointer
41 * @sci: TI SCI handle used for communication with system controller
42 * @idr: idr structure for mapping ids to reset control structures
55 * ti_sci_reset_set() - program a device's reset
56 * @rcdev: reset controller entity
57 * @id: ID of the reset to toggle
61 * reset using the TI SCI protocol. The device's reset is asserted if the
63 * The mechanism itself is a read-modify-write procedure, the current device
64 * reset register is read using a TI SCI device operation, the new value is
65 * set or un-set using the reset's mask, and the new reset value written by
74 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_set()
75 const struct ti_sci_dev_ops *dev_ops = &sci->ops.dev_ops; in ti_sci_reset_set()
80 control = idr_find(&data->idr, id); in ti_sci_reset_set()
82 return -EINVAL; in ti_sci_reset_set()
84 mutex_lock(&control->lock); in ti_sci_reset_set()
86 ret = dev_ops->get_device_resets(sci, control->dev_id, &reset_state); in ti_sci_reset_set()
91 reset_state |= control->reset_mask; in ti_sci_reset_set()
93 reset_state &= ~control->reset_mask; in ti_sci_reset_set()
95 ret = dev_ops->set_device_resets(sci, control->dev_id, reset_state); in ti_sci_reset_set()
97 mutex_unlock(&control->lock); in ti_sci_reset_set()
103 * ti_sci_reset_assert() - assert device reset
104 * @rcdev: reset controller entity
105 * @id: ID of the reset to be asserted
107 * This function implements the reset driver op to assert a device's reset
110 * argument set to true for asserting the reset.
121 * ti_sci_reset_deassert() - deassert device reset
122 * @rcdev: reset controller entity
123 * @id: ID of the reset to be deasserted
125 * This function implements the reset driver op to deassert a device's reset
128 * argument set to false for deasserting the reset.
139 * ti_sci_reset_status() - check device reset status
140 * @rcdev: reset controller entity
141 * @id: ID of reset to be checked
143 * This function implements the reset driver op to return the status of a
144 * device's reset using the TI SCI protocol. The reset register value is read
146 * status of the specific reset is extracted and returned using this reset's
147 * reset mask.
149 * Return: 0 if reset is deasserted, or a non-zero value if reset is asserted
155 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_status()
156 const struct ti_sci_dev_ops *dev_ops = &sci->ops.dev_ops; in ti_sci_reset_status()
161 control = idr_find(&data->idr, id); in ti_sci_reset_status()
163 return -EINVAL; in ti_sci_reset_status()
165 ret = dev_ops->get_device_resets(sci, control->dev_id, &reset_state); in ti_sci_reset_status()
169 return reset_state & control->reset_mask; in ti_sci_reset_status()
179 * ti_sci_reset_of_xlate() - translate a set of OF arguments to a reset ID
180 * @rcdev: reset controller entity
181 * @reset_spec: OF reset argument specifier
183 * This function performs the translation of the reset argument specifier
184 * values defined in a reset consumer device node. The function allocates a
185 * reset control structure for that device reset, and will be used by the
186 * driver for performing any reset functions on that reset. An idr structure
187 * is allocated and used to map to the reset control structure. This idr
188 * is used by the driver to do reset lookups.
198 if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells)) in ti_sci_reset_of_xlate()
199 return -EINVAL; in ti_sci_reset_of_xlate()
201 control = devm_kzalloc(data->dev, sizeof(*control), GFP_KERNEL); in ti_sci_reset_of_xlate()
203 return -ENOMEM; in ti_sci_reset_of_xlate()
205 control->dev_id = reset_spec->args[0]; in ti_sci_reset_of_xlate()
206 control->reset_mask = reset_spec->args[1]; in ti_sci_reset_of_xlate()
207 mutex_init(&control->lock); in ti_sci_reset_of_xlate()
209 return idr_alloc(&data->idr, control, 0, 0, GFP_KERNEL); in ti_sci_reset_of_xlate()
213 { .compatible = "ti,sci-reset", },
222 if (!pdev->dev.of_node) in ti_sci_reset_probe()
223 return -ENODEV; in ti_sci_reset_probe()
225 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in ti_sci_reset_probe()
227 return -ENOMEM; in ti_sci_reset_probe()
229 data->sci = devm_ti_sci_get_handle(&pdev->dev); in ti_sci_reset_probe()
230 if (IS_ERR(data->sci)) in ti_sci_reset_probe()
231 return PTR_ERR(data->sci); in ti_sci_reset_probe()
233 data->rcdev.ops = &ti_sci_reset_ops; in ti_sci_reset_probe()
234 data->rcdev.owner = THIS_MODULE; in ti_sci_reset_probe()
235 data->rcdev.of_node = pdev->dev.of_node; in ti_sci_reset_probe()
236 data->rcdev.of_reset_n_cells = 2; in ti_sci_reset_probe()
237 data->rcdev.of_xlate = ti_sci_reset_of_xlate; in ti_sci_reset_probe()
238 data->dev = &pdev->dev; in ti_sci_reset_probe()
239 idr_init(&data->idr); in ti_sci_reset_probe()
243 return reset_controller_register(&data->rcdev); in ti_sci_reset_probe()
250 reset_controller_unregister(&data->rcdev); in ti_sci_reset_remove()
252 idr_destroy(&data->idr); in ti_sci_reset_remove()
261 .name = "ti-sci-reset",
268 MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reset driver");