forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
....@@ -23,8 +23,11 @@
2323 *
2424 */
2525
26
+#include <linux/slab.h>
27
+
2628 #include "dm_services.h"
2729
30
+#include "include/gpio_interface.h"
2831 #include "include/gpio_types.h"
2932 #include "hw_gpio.h"
3033 #include "hw_hpd.h"
....@@ -41,14 +44,7 @@
4144 #define REG(reg)\
4245 (hpd->regs->reg)
4346
44
-static void dal_hw_hpd_construct(
45
- struct hw_hpd *pin,
46
- enum gpio_id id,
47
- uint32_t en,
48
- struct dc_context *ctx)
49
-{
50
- dal_hw_gpio_construct(&pin->base, id, en, ctx);
51
-}
47
+struct gpio;
5248
5349 static void dal_hw_hpd_destruct(
5450 struct hw_hpd *pin)
....@@ -56,19 +52,12 @@
5652 dal_hw_gpio_destruct(&pin->base);
5753 }
5854
59
-
60
-static void destruct(
61
- struct hw_hpd *hpd)
62
-{
63
- dal_hw_hpd_destruct(hpd);
64
-}
65
-
66
-static void destroy(
55
+static void dal_hw_hpd_destroy(
6756 struct hw_gpio_pin **ptr)
6857 {
6958 struct hw_hpd *hpd = HW_HPD_FROM_BASE(*ptr);
7059
71
- destruct(hpd);
60
+ dal_hw_hpd_destruct(hpd);
7261
7362 kfree(hpd);
7463
....@@ -115,7 +104,7 @@
115104 }
116105
117106 static const struct hw_gpio_pin_funcs funcs = {
118
- .destroy = destroy,
107
+ .destroy = dal_hw_hpd_destroy,
119108 .open = dal_hw_gpio_open,
120109 .get_value = get_value,
121110 .set_value = dal_hw_gpio_set_value,
....@@ -124,39 +113,39 @@
124113 .close = dal_hw_gpio_close,
125114 };
126115
127
-static void construct(
128
- struct hw_hpd *hpd,
116
+static void dal_hw_hpd_construct(
117
+ struct hw_hpd *pin,
129118 enum gpio_id id,
130119 uint32_t en,
131120 struct dc_context *ctx)
132121 {
133
- dal_hw_hpd_construct(hpd, id, en, ctx);
134
- hpd->base.base.funcs = &funcs;
122
+ dal_hw_gpio_construct(&pin->base, id, en, ctx);
123
+ pin->base.base.funcs = &funcs;
135124 }
136125
137
-struct hw_gpio_pin *dal_hw_hpd_create(
126
+void dal_hw_hpd_init(
127
+ struct hw_hpd **hw_hpd,
138128 struct dc_context *ctx,
139129 enum gpio_id id,
140130 uint32_t en)
141131 {
142
- struct hw_hpd *hpd;
143
-
144
- if (id != GPIO_ID_HPD) {
132
+ if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
145133 ASSERT_CRITICAL(false);
146
- return NULL;
134
+ *hw_hpd = NULL;
147135 }
148136
149
- if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) {
137
+ *hw_hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
138
+ if (!*hw_hpd) {
150139 ASSERT_CRITICAL(false);
151
- return NULL;
140
+ return;
152141 }
153142
154
- hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
155
- if (!hpd) {
156
- ASSERT_CRITICAL(false);
157
- return NULL;
158
- }
143
+ dal_hw_hpd_construct(*hw_hpd, id, en, ctx);
144
+}
159145
160
- construct(hpd, id, en, ctx);
161
- return &hpd->base.base;
146
+struct hw_gpio_pin *dal_hw_hpd_get_pin(struct gpio *gpio)
147
+{
148
+ struct hw_hpd *hw_hpd = dal_gpio_get_hpd(gpio);
149
+
150
+ return &hw_hpd->base.base;
162151 }