This source file includes following definitions.
- dal_hw_generic_construct
- dal_hw_generic_destruct
- destroy
- set_config
- construct
- dal_hw_generic_init
- dal_hw_generic_get_pin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <linux/slab.h>
27
28 #include "dm_services.h"
29
30 #include "include/gpio_interface.h"
31 #include "include/gpio_types.h"
32 #include "hw_gpio.h"
33 #include "hw_generic.h"
34
35 #include "reg_helper.h"
36 #include "generic_regs.h"
37
38 #undef FN
39 #define FN(reg_name, field_name) \
40 generic->shifts->field_name, generic->masks->field_name
41
42 #define CTX \
43 generic->base.base.ctx
44 #define REG(reg)\
45 (generic->regs->reg)
46
47 struct gpio;
48
49 static void dal_hw_generic_construct(
50 struct hw_generic *pin,
51 enum gpio_id id,
52 uint32_t en,
53 struct dc_context *ctx)
54 {
55 dal_hw_gpio_construct(&pin->base, id, en, ctx);
56 }
57
58 static void dal_hw_generic_destruct(
59 struct hw_generic *pin)
60 {
61 dal_hw_gpio_destruct(&pin->base);
62 }
63
64 static void destroy(
65 struct hw_gpio_pin **ptr)
66 {
67 struct hw_generic *generic = HW_GENERIC_FROM_BASE(*ptr);
68
69 dal_hw_generic_destruct(generic);
70
71 kfree(generic);
72
73 *ptr = NULL;
74 }
75
76 static enum gpio_result set_config(
77 struct hw_gpio_pin *ptr,
78 const struct gpio_config_data *config_data)
79 {
80 struct hw_generic *generic = HW_GENERIC_FROM_BASE(ptr);
81
82 if (!config_data)
83 return GPIO_RESULT_INVALID_DATA;
84
85 REG_UPDATE_2(mux,
86 GENERIC_EN, config_data->config.generic_mux.enable_output_from_mux,
87 GENERIC_SEL, config_data->config.generic_mux.mux_select);
88
89 return GPIO_RESULT_OK;
90 }
91
92 static const struct hw_gpio_pin_funcs funcs = {
93 .destroy = destroy,
94 .open = dal_hw_gpio_open,
95 .get_value = dal_hw_gpio_get_value,
96 .set_value = dal_hw_gpio_set_value,
97 .set_config = set_config,
98 .change_mode = dal_hw_gpio_change_mode,
99 .close = dal_hw_gpio_close,
100 };
101
102 static void construct(
103 struct hw_generic *generic,
104 enum gpio_id id,
105 uint32_t en,
106 struct dc_context *ctx)
107 {
108 dal_hw_generic_construct(generic, id, en, ctx);
109 generic->base.base.funcs = &funcs;
110 }
111
112 void dal_hw_generic_init(
113 struct hw_generic **hw_generic,
114 struct dc_context *ctx,
115 enum gpio_id id,
116 uint32_t en)
117 {
118 if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
119 ASSERT_CRITICAL(false);
120 *hw_generic = NULL;
121 }
122
123 *hw_generic = kzalloc(sizeof(struct hw_generic), GFP_KERNEL);
124 if (!*hw_generic) {
125 ASSERT_CRITICAL(false);
126 return;
127 }
128
129 construct(*hw_generic, id, en, ctx);
130 }
131
132
133 struct hw_gpio_pin *dal_hw_generic_get_pin(struct gpio *gpio)
134 {
135 struct hw_generic *hw_generic = dal_gpio_get_generic(gpio);
136
137 return &hw_generic->base.base;
138 }