.. | .. |
---|
23 | 23 | * |
---|
24 | 24 | */ |
---|
25 | 25 | |
---|
| 26 | +#include <linux/slab.h> |
---|
| 27 | + |
---|
26 | 28 | #include "dm_services.h" |
---|
27 | 29 | |
---|
| 30 | +#include "include/gpio_interface.h" |
---|
28 | 31 | #include "include/gpio_types.h" |
---|
29 | 32 | #include "hw_gpio.h" |
---|
30 | 33 | #include "hw_hpd.h" |
---|
.. | .. |
---|
41 | 44 | #define REG(reg)\ |
---|
42 | 45 | (hpd->regs->reg) |
---|
43 | 46 | |
---|
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; |
---|
52 | 48 | |
---|
53 | 49 | static void dal_hw_hpd_destruct( |
---|
54 | 50 | struct hw_hpd *pin) |
---|
.. | .. |
---|
56 | 52 | dal_hw_gpio_destruct(&pin->base); |
---|
57 | 53 | } |
---|
58 | 54 | |
---|
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( |
---|
67 | 56 | struct hw_gpio_pin **ptr) |
---|
68 | 57 | { |
---|
69 | 58 | struct hw_hpd *hpd = HW_HPD_FROM_BASE(*ptr); |
---|
70 | 59 | |
---|
71 | | - destruct(hpd); |
---|
| 60 | + dal_hw_hpd_destruct(hpd); |
---|
72 | 61 | |
---|
73 | 62 | kfree(hpd); |
---|
74 | 63 | |
---|
.. | .. |
---|
115 | 104 | } |
---|
116 | 105 | |
---|
117 | 106 | static const struct hw_gpio_pin_funcs funcs = { |
---|
118 | | - .destroy = destroy, |
---|
| 107 | + .destroy = dal_hw_hpd_destroy, |
---|
119 | 108 | .open = dal_hw_gpio_open, |
---|
120 | 109 | .get_value = get_value, |
---|
121 | 110 | .set_value = dal_hw_gpio_set_value, |
---|
.. | .. |
---|
124 | 113 | .close = dal_hw_gpio_close, |
---|
125 | 114 | }; |
---|
126 | 115 | |
---|
127 | | -static void construct( |
---|
128 | | - struct hw_hpd *hpd, |
---|
| 116 | +static void dal_hw_hpd_construct( |
---|
| 117 | + struct hw_hpd *pin, |
---|
129 | 118 | enum gpio_id id, |
---|
130 | 119 | uint32_t en, |
---|
131 | 120 | struct dc_context *ctx) |
---|
132 | 121 | { |
---|
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; |
---|
135 | 124 | } |
---|
136 | 125 | |
---|
137 | | -struct hw_gpio_pin *dal_hw_hpd_create( |
---|
| 126 | +void dal_hw_hpd_init( |
---|
| 127 | + struct hw_hpd **hw_hpd, |
---|
138 | 128 | struct dc_context *ctx, |
---|
139 | 129 | enum gpio_id id, |
---|
140 | 130 | uint32_t en) |
---|
141 | 131 | { |
---|
142 | | - struct hw_hpd *hpd; |
---|
143 | | - |
---|
144 | | - if (id != GPIO_ID_HPD) { |
---|
| 132 | + if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) { |
---|
145 | 133 | ASSERT_CRITICAL(false); |
---|
146 | | - return NULL; |
---|
| 134 | + *hw_hpd = NULL; |
---|
147 | 135 | } |
---|
148 | 136 | |
---|
149 | | - if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) { |
---|
| 137 | + *hw_hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL); |
---|
| 138 | + if (!*hw_hpd) { |
---|
150 | 139 | ASSERT_CRITICAL(false); |
---|
151 | | - return NULL; |
---|
| 140 | + return; |
---|
152 | 141 | } |
---|
153 | 142 | |
---|
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 | +} |
---|
159 | 145 | |
---|
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; |
---|
162 | 151 | } |
---|