Lines Matching +full:rst +full:- +full:- +full:- +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Inspired by mach-imx/src.c
18 #include "reset-syscfg.h"
21 * struct syscfg_reset_channel - Reset channel regmap configuration
32 * struct syscfg_reset_controller - A reset controller which groups together
36 * @rst: base reset controller structure.
42 struct reset_controller_dev rst; member
48 container_of(_rst, struct syscfg_reset_controller, rst)
53 struct syscfg_reset_controller *rst = to_syscfg_reset_controller(rcdev); in syscfg_reset_program_hw() local
55 u32 ctrl_val = rst->active_low ? !assert : !!assert; in syscfg_reset_program_hw()
58 if (idx >= rcdev->nr_resets) in syscfg_reset_program_hw()
59 return -EINVAL; in syscfg_reset_program_hw()
61 ch = &rst->channels[idx]; in syscfg_reset_program_hw()
63 err = regmap_field_write(ch->reset, ctrl_val); in syscfg_reset_program_hw()
67 if (ch->ack) { in syscfg_reset_program_hw()
70 err = regmap_field_read_poll_timeout(ch->ack, ack_val, (ack_val == ctrl_val), in syscfg_reset_program_hw()
106 struct syscfg_reset_controller *rst = to_syscfg_reset_controller(rcdev); in syscfg_reset_status() local
111 if (idx >= rcdev->nr_resets) in syscfg_reset_status()
112 return -EINVAL; in syscfg_reset_status()
114 ch = &rst->channels[idx]; in syscfg_reset_status()
115 if (ch->ack) in syscfg_reset_status()
116 err = regmap_field_read(ch->ack, &ret_val); in syscfg_reset_status()
118 err = regmap_field_read(ch->reset, &ret_val); in syscfg_reset_status()
122 return rst->active_low ? !ret_val : !!ret_val; in syscfg_reset_status()
140 return -ENOMEM; in syscfg_reset_controller_register()
142 rc->channels = devm_kcalloc(dev, data->nr_channels, in syscfg_reset_controller_register()
143 sizeof(*rc->channels), GFP_KERNEL); in syscfg_reset_controller_register()
144 if (!rc->channels) in syscfg_reset_controller_register()
145 return -ENOMEM; in syscfg_reset_controller_register()
147 rc->rst.ops = &syscfg_reset_ops; in syscfg_reset_controller_register()
148 rc->rst.of_node = dev->of_node; in syscfg_reset_controller_register()
149 rc->rst.nr_resets = data->nr_channels; in syscfg_reset_controller_register()
150 rc->active_low = data->active_low; in syscfg_reset_controller_register()
152 for (i = 0; i < data->nr_channels; i++) { in syscfg_reset_controller_register()
155 const char *compatible = data->channels[i].compatible; in syscfg_reset_controller_register()
161 f = devm_regmap_field_alloc(dev, map, data->channels[i].reset); in syscfg_reset_controller_register()
165 rc->channels[i].reset = f; in syscfg_reset_controller_register()
167 if (!data->wait_for_ack) in syscfg_reset_controller_register()
170 f = devm_regmap_field_alloc(dev, map, data->channels[i].ack); in syscfg_reset_controller_register()
174 rc->channels[i].ack = f; in syscfg_reset_controller_register()
177 err = reset_controller_register(&rc->rst); in syscfg_reset_controller_register()
186 struct device *dev = pdev ? &pdev->dev : NULL; in syscfg_reset_probe()
189 if (!dev || !dev->driver) in syscfg_reset_probe()
190 return -ENODEV; in syscfg_reset_probe()
192 data = device_get_match_data(&pdev->dev); in syscfg_reset_probe()
194 return -EINVAL; in syscfg_reset_probe()