hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/reset/reset-scmi.c
....@@ -2,7 +2,7 @@
22 /*
33 * ARM System Control and Management Interface (ARM SCMI) reset driver
44 *
5
- * Copyright (C) 2019 ARM Ltd.
5
+ * Copyright (C) 2019-2020 ARM Ltd.
66 */
77
88 #include <linux/module.h>
....@@ -11,18 +11,20 @@
1111 #include <linux/reset-controller.h>
1212 #include <linux/scmi_protocol.h>
1313
14
+static const struct scmi_reset_proto_ops *reset_ops;
15
+
1416 /**
1517 * struct scmi_reset_data - reset controller information structure
1618 * @rcdev: reset controller entity
17
- * @handle: ARM SCMI handle used for communication with system controller
19
+ * @ph: ARM SCMI protocol handle used for communication with system controller
1820 */
1921 struct scmi_reset_data {
2022 struct reset_controller_dev rcdev;
21
- const struct scmi_handle *handle;
23
+ const struct scmi_protocol_handle *ph;
2224 };
2325
2426 #define to_scmi_reset_data(p) container_of((p), struct scmi_reset_data, rcdev)
25
-#define to_scmi_handle(p) (to_scmi_reset_data(p)->handle)
27
+#define to_scmi_handle(p) (to_scmi_reset_data(p)->ph)
2628
2729 /**
2830 * scmi_reset_assert() - assert device reset
....@@ -37,9 +39,9 @@
3739 static int
3840 scmi_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
3941 {
40
- const struct scmi_handle *handle = to_scmi_handle(rcdev);
42
+ const struct scmi_protocol_handle *ph = to_scmi_handle(rcdev);
4143
42
- return handle->reset_ops->assert(handle, id);
44
+ return reset_ops->assert(ph, id);
4345 }
4446
4547 /**
....@@ -55,9 +57,9 @@
5557 static int
5658 scmi_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
5759 {
58
- const struct scmi_handle *handle = to_scmi_handle(rcdev);
60
+ const struct scmi_protocol_handle *ph = to_scmi_handle(rcdev);
5961
60
- return handle->reset_ops->deassert(handle, id);
62
+ return reset_ops->deassert(ph, id);
6163 }
6264
6365 /**
....@@ -73,9 +75,9 @@
7375 static int
7476 scmi_reset_reset(struct reset_controller_dev *rcdev, unsigned long id)
7577 {
76
- const struct scmi_handle *handle = to_scmi_handle(rcdev);
78
+ const struct scmi_protocol_handle *ph = to_scmi_handle(rcdev);
7779
78
- return handle->reset_ops->reset(handle, id);
80
+ return reset_ops->reset(ph, id);
7981 }
8082
8183 static const struct reset_control_ops scmi_reset_ops = {
....@@ -90,9 +92,14 @@
9092 struct device *dev = &sdev->dev;
9193 struct device_node *np = dev->of_node;
9294 const struct scmi_handle *handle = sdev->handle;
95
+ struct scmi_protocol_handle *ph;
9396
94
- if (!handle || !handle->reset_ops)
97
+ if (!handle)
9598 return -ENODEV;
99
+
100
+ reset_ops = handle->devm_get_protocol(sdev, SCMI_PROTOCOL_RESET, &ph);
101
+ if (IS_ERR(reset_ops))
102
+ return PTR_ERR(reset_ops);
96103
97104 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
98105 if (!data)
....@@ -101,8 +108,8 @@
101108 data->rcdev.ops = &scmi_reset_ops;
102109 data->rcdev.owner = THIS_MODULE;
103110 data->rcdev.of_node = np;
104
- data->rcdev.nr_resets = handle->reset_ops->num_domains_get(handle);
105
- data->handle = handle;
111
+ data->rcdev.nr_resets = reset_ops->num_domains_get(ph);
112
+ data->ph = ph;
106113
107114 return devm_reset_controller_register(dev, &data->rcdev);
108115 }