Lines Matching +full:sci +full:- +full:dev +full:- +full:id

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
32 * @dev: reset controller device pointer
33 * @sci: TI SCI handle used for communication with system controller
38 struct device *dev; member
39 const struct ti_sci_handle *sci; member
47 * ti_sci_reset_set() - program a device's reset
49 * @id: ID of the reset to toggle
53 * reset using the TI SCI protocol. The device's reset is asserted if the
55 * The mechanism itself is a read-modify-write procedure, the current device
56 * reset register is read using a TI SCI device operation, the new value is
57 * set or un-set using the reset's mask, and the new reset value written by
58 * using another TI SCI device operation.
63 unsigned long id, bool assert) in ti_sci_reset_set() argument
66 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_set() local
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
97 * @id: ID of the reset to be asserted
100 * using the TI SCI protocol. This invokes the function ti_sci_reset_set()
107 unsigned long id) in ti_sci_reset_assert() argument
109 return ti_sci_reset_set(rcdev, id, true); in ti_sci_reset_assert()
113 * ti_sci_reset_deassert() - deassert device reset
115 * @id: ID of the reset to be deasserted
118 * using the TI SCI protocol. This invokes the function ti_sci_reset_set()
125 unsigned long id) in ti_sci_reset_deassert() argument
127 return ti_sci_reset_set(rcdev, id, false); in ti_sci_reset_deassert()
131 * ti_sci_reset_status() - check device reset status
133 * @id: ID of reset to be checked
136 * device's reset using the TI SCI protocol. The reset register value is read
137 * by invoking the TI SCI device operation .get_device_resets(), and the
141 * Return: 0 if reset is deasserted, or a non-zero value if reset is asserted
144 unsigned long id) in ti_sci_reset_status() argument
147 const struct ti_sci_handle *sci = data->sci; in ti_sci_reset_status() local
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
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", },
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()
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()
235 return reset_controller_register(&data->rcdev); in ti_sci_reset_probe()
242 reset_controller_unregister(&data->rcdev); in ti_sci_reset_remove()
244 idr_destroy(&data->idr); in ti_sci_reset_remove()
253 .name = "ti-sci-reset",
260 MODULE_DESCRIPTION("TI System Control Interface (TI SCI) Reset driver");