Lines Matching +full:controller +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Texas Instrument's System Control Interface (TI-SCI) reset driver
5 * Copyright (C) 2015-2017 Texas Instruments Incorporated - https://www.ti.com/
14 #include <linux/reset-controller.h>
18 * struct ti_sci_reset_control - reset control structure
19 * @dev_id: SoC-specific device identifier
21 * @lock: synchronize reset_mask read-modify-writes
30 * struct ti_sci_reset_data - reset controller information structure
31 * @rcdev: reset controller entity
32 * @dev: reset controller device pointer
33 * @sci: TI SCI handle used for communication with system controller
47 * ti_sci_reset_set() - program a device's reset
48 * @rcdev: reset controller entity
55 * The mechanism itself is a read-modify-write procedure, the current device
57 * set or un-set using the reset's mask, and the new reset value written by
65 struct ti_sci_reset_data *data = to_ti_sci_reset_data(rcdev); in ti_sci_reset_set() local
66 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_set()
67 const struct ti_sci_dev_ops *dev_ops = &sci->ops.dev_ops; in ti_sci_reset_set()
72 control = idr_find(&data->idr, id); in ti_sci_reset_set()
74 return -EINVAL; in ti_sci_reset_set()
76 mutex_lock(&control->lock); in ti_sci_reset_set()
78 ret = dev_ops->get_device_resets(sci, control->dev_id, &reset_state); in ti_sci_reset_set()
83 reset_state |= control->reset_mask; in ti_sci_reset_set()
85 reset_state &= ~control->reset_mask; in ti_sci_reset_set()
87 ret = dev_ops->set_device_resets(sci, control->dev_id, reset_state); in ti_sci_reset_set()
89 mutex_unlock(&control->lock); in ti_sci_reset_set()
95 * ti_sci_reset_assert() - assert device reset
96 * @rcdev: reset controller entity
113 * ti_sci_reset_deassert() - deassert device reset
114 * @rcdev: reset controller entity
131 * ti_sci_reset_status() - check device reset status
132 * @rcdev: reset controller entity
141 * Return: 0 if reset is deasserted, or a non-zero value if reset is asserted
146 struct ti_sci_reset_data *data = to_ti_sci_reset_data(rcdev); in ti_sci_reset_status() local
147 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_status()
148 const struct ti_sci_dev_ops *dev_ops = &sci->ops.dev_ops; in ti_sci_reset_status()
153 control = idr_find(&data->idr, id); in ti_sci_reset_status()
155 return -EINVAL; in ti_sci_reset_status()
157 ret = dev_ops->get_device_resets(sci, control->dev_id, &reset_state); in ti_sci_reset_status()
161 return reset_state & control->reset_mask; in ti_sci_reset_status()
171 * ti_sci_reset_of_xlate() - translate a set of OF arguments to a reset ID
172 * @rcdev: reset controller entity
187 struct ti_sci_reset_data *data = to_ti_sci_reset_data(rcdev); in ti_sci_reset_of_xlate() local
190 if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells)) in ti_sci_reset_of_xlate()
191 return -EINVAL; in ti_sci_reset_of_xlate()
193 control = devm_kzalloc(data->dev, sizeof(*control), GFP_KERNEL); in ti_sci_reset_of_xlate()
195 return -ENOMEM; in ti_sci_reset_of_xlate()
197 control->dev_id = reset_spec->args[0]; in ti_sci_reset_of_xlate()
198 control->reset_mask = reset_spec->args[1]; in ti_sci_reset_of_xlate()
199 mutex_init(&control->lock); in ti_sci_reset_of_xlate()
201 return idr_alloc(&data->idr, control, 0, 0, GFP_KERNEL); in ti_sci_reset_of_xlate()
205 { .compatible = "ti,sci-reset", },
212 struct ti_sci_reset_data *data; in ti_sci_reset_probe() local
214 if (!pdev->dev.of_node) in ti_sci_reset_probe()
215 return -ENODEV; in ti_sci_reset_probe()
217 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in ti_sci_reset_probe()
218 if (!data) in ti_sci_reset_probe()
219 return -ENOMEM; in ti_sci_reset_probe()
221 data->sci = devm_ti_sci_get_handle(&pdev->dev); in ti_sci_reset_probe()
222 if (IS_ERR(data->sci)) in ti_sci_reset_probe()
223 return PTR_ERR(data->sci); in ti_sci_reset_probe()
225 data->rcdev.ops = &ti_sci_reset_ops; in ti_sci_reset_probe()
226 data->rcdev.owner = THIS_MODULE; in ti_sci_reset_probe()
227 data->rcdev.of_node = pdev->dev.of_node; in ti_sci_reset_probe()
228 data->rcdev.of_reset_n_cells = 2; in ti_sci_reset_probe()
229 data->rcdev.of_xlate = ti_sci_reset_of_xlate; in ti_sci_reset_probe()
230 data->dev = &pdev->dev; in ti_sci_reset_probe()
231 idr_init(&data->idr); in ti_sci_reset_probe()
233 platform_set_drvdata(pdev, data); in ti_sci_reset_probe()
235 return reset_controller_register(&data->rcdev); in ti_sci_reset_probe()
240 struct ti_sci_reset_data *data = platform_get_drvdata(pdev); in ti_sci_reset_remove() local
242 reset_controller_unregister(&data->rcdev); in ti_sci_reset_remove()
244 idr_destroy(&data->idr); in ti_sci_reset_remove()
251 .name = "ti-sci-reset",