| .. | .. |
|---|
| 23 | 23 | * |
|---|
| 24 | 24 | */ |
|---|
| 25 | 25 | |
|---|
| 26 | +#include <linux/delay.h> |
|---|
| 27 | +#include <linux/slab.h> |
|---|
| 28 | + |
|---|
| 26 | 29 | #include "dm_services.h" |
|---|
| 27 | 30 | |
|---|
| 31 | +#include "include/gpio_interface.h" |
|---|
| 28 | 32 | #include "include/gpio_types.h" |
|---|
| 29 | 33 | #include "hw_gpio.h" |
|---|
| 30 | 34 | #include "hw_ddc.h" |
|---|
| .. | .. |
|---|
| 42 | 46 | #define REG(reg)\ |
|---|
| 43 | 47 | (ddc->regs->reg) |
|---|
| 44 | 48 | |
|---|
| 45 | | -static void destruct( |
|---|
| 49 | +struct gpio; |
|---|
| 50 | + |
|---|
| 51 | +static void dal_hw_ddc_destruct( |
|---|
| 46 | 52 | struct hw_ddc *pin) |
|---|
| 47 | 53 | { |
|---|
| 48 | 54 | dal_hw_gpio_destruct(&pin->base); |
|---|
| 49 | 55 | } |
|---|
| 50 | 56 | |
|---|
| 51 | | -static void destroy( |
|---|
| 57 | +static void dal_hw_ddc_destroy( |
|---|
| 52 | 58 | struct hw_gpio_pin **ptr) |
|---|
| 53 | 59 | { |
|---|
| 54 | 60 | struct hw_ddc *pin = HW_DDC_FROM_BASE(*ptr); |
|---|
| 55 | 61 | |
|---|
| 56 | | - destruct(pin); |
|---|
| 62 | + dal_hw_ddc_destruct(pin); |
|---|
| 57 | 63 | |
|---|
| 58 | 64 | kfree(pin); |
|---|
| 59 | 65 | |
|---|
| .. | .. |
|---|
| 144 | 150 | AUX_PAD1_MODE, 0); |
|---|
| 145 | 151 | } |
|---|
| 146 | 152 | |
|---|
| 153 | + if (ddc->regs->dc_gpio_aux_ctrl_5 != 0) { |
|---|
| 154 | + REG_UPDATE(dc_gpio_aux_ctrl_5, DDC_PAD_I2CMODE, 1); |
|---|
| 155 | + } |
|---|
| 156 | + //set DC_IO_aux_rxsel = 2'b01 |
|---|
| 157 | + if (ddc->regs->phy_aux_cntl != 0) { |
|---|
| 158 | + REG_UPDATE(phy_aux_cntl, AUX_PAD_RXSEL, 1); |
|---|
| 159 | + } |
|---|
| 147 | 160 | return GPIO_RESULT_OK; |
|---|
| 148 | 161 | case GPIO_DDC_CONFIG_TYPE_MODE_AUX: |
|---|
| 149 | 162 | /* set the AUX pad mode */ |
|---|
| 150 | 163 | if (!aux_pad_mode) { |
|---|
| 151 | 164 | REG_SET(gpio.MASK_reg, regval, |
|---|
| 152 | 165 | AUX_PAD1_MODE, 1); |
|---|
| 166 | + } |
|---|
| 167 | + if (ddc->regs->dc_gpio_aux_ctrl_5 != 0) { |
|---|
| 168 | + REG_UPDATE(dc_gpio_aux_ctrl_5, |
|---|
| 169 | + DDC_PAD_I2CMODE, 0); |
|---|
| 153 | 170 | } |
|---|
| 154 | 171 | |
|---|
| 155 | 172 | return GPIO_RESULT_OK; |
|---|
| .. | .. |
|---|
| 190 | 207 | } |
|---|
| 191 | 208 | |
|---|
| 192 | 209 | static const struct hw_gpio_pin_funcs funcs = { |
|---|
| 193 | | - .destroy = destroy, |
|---|
| 210 | + .destroy = dal_hw_ddc_destroy, |
|---|
| 194 | 211 | .open = dal_hw_gpio_open, |
|---|
| 195 | 212 | .get_value = dal_hw_gpio_get_value, |
|---|
| 196 | 213 | .set_value = dal_hw_gpio_set_value, |
|---|
| .. | .. |
|---|
| 199 | 216 | .close = dal_hw_gpio_close, |
|---|
| 200 | 217 | }; |
|---|
| 201 | 218 | |
|---|
| 202 | | -static void construct( |
|---|
| 219 | +static void dal_hw_ddc_construct( |
|---|
| 203 | 220 | struct hw_ddc *ddc, |
|---|
| 204 | 221 | enum gpio_id id, |
|---|
| 205 | 222 | uint32_t en, |
|---|
| .. | .. |
|---|
| 209 | 226 | ddc->base.base.funcs = &funcs; |
|---|
| 210 | 227 | } |
|---|
| 211 | 228 | |
|---|
| 212 | | -struct hw_gpio_pin *dal_hw_ddc_create( |
|---|
| 229 | +void dal_hw_ddc_init( |
|---|
| 230 | + struct hw_ddc **hw_ddc, |
|---|
| 213 | 231 | struct dc_context *ctx, |
|---|
| 214 | 232 | enum gpio_id id, |
|---|
| 215 | 233 | uint32_t en) |
|---|
| 216 | 234 | { |
|---|
| 217 | | - struct hw_ddc *pin; |
|---|
| 218 | | - |
|---|
| 219 | 235 | if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) { |
|---|
| 220 | 236 | ASSERT_CRITICAL(false); |
|---|
| 221 | | - return NULL; |
|---|
| 237 | + *hw_ddc = NULL; |
|---|
| 222 | 238 | } |
|---|
| 223 | 239 | |
|---|
| 224 | | - pin = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL); |
|---|
| 225 | | - if (!pin) { |
|---|
| 240 | + *hw_ddc = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL); |
|---|
| 241 | + if (!*hw_ddc) { |
|---|
| 226 | 242 | ASSERT_CRITICAL(false); |
|---|
| 227 | | - return NULL; |
|---|
| 243 | + return; |
|---|
| 228 | 244 | } |
|---|
| 229 | 245 | |
|---|
| 230 | | - construct(pin, id, en, ctx); |
|---|
| 231 | | - return &pin->base.base; |
|---|
| 246 | + dal_hw_ddc_construct(*hw_ddc, id, en, ctx); |
|---|
| 247 | +} |
|---|
| 248 | + |
|---|
| 249 | +struct hw_gpio_pin *dal_hw_ddc_get_pin(struct gpio *gpio) |
|---|
| 250 | +{ |
|---|
| 251 | + struct hw_ddc *hw_ddc = dal_gpio_get_ddc(gpio); |
|---|
| 252 | + |
|---|
| 253 | + return &hw_ddc->base.base; |
|---|
| 232 | 254 | } |
|---|