Lines Matching +full:- +full:function

1 // SPDX-License-Identifier: GPL-2.0
7 * https://www.mipi.org/mipi-sdca-v1-0-download
21 function_find_entity(struct sdca_function_data *function, unsigned int reg) in function_find_entity() argument
25 for (i = 0; i < function->num_entities; i++) in function_find_entity()
26 if (SDW_SDCA_CTL_ENT(reg) == function->entities[i].id) in function_find_entity()
27 return &function->entities[i]; in function_find_entity()
37 for (i = 0; i < entity->num_controls; i++) { in entity_find_control()
38 if (SDW_SDCA_CTL_CSEL(reg) == entity->controls[i].sel) in entity_find_control()
39 return &entity->controls[i]; in entity_find_control()
46 function_find_control(struct sdca_function_data *function, unsigned int reg) in function_find_control() argument
50 entity = function_find_entity(function, reg); in function_find_control()
58 * sdca_regmap_readable - return if a given SDCA Control is readable
59 * @function: Pointer to the Function information.
64 bool sdca_regmap_readable(struct sdca_function_data *function, unsigned int reg) in sdca_regmap_readable() argument
71 control = function_find_control(function, reg); in sdca_regmap_readable()
75 if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list)) in sdca_regmap_readable()
78 switch (control->mode) { in sdca_regmap_readable()
88 return control->layers & ~SDCA_ACCESS_LAYER_DEVICE; in sdca_regmap_readable()
96 * sdca_regmap_writeable - return if a given SDCA Control is writeable
97 * @function: Pointer to the Function information.
102 bool sdca_regmap_writeable(struct sdca_function_data *function, unsigned int reg) in sdca_regmap_writeable() argument
109 control = function_find_control(function, reg); in sdca_regmap_writeable()
113 if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list)) in sdca_regmap_writeable()
116 switch (control->mode) { in sdca_regmap_writeable()
125 return control->layers & ~SDCA_ACCESS_LAYER_DEVICE; in sdca_regmap_writeable()
133 * sdca_regmap_volatile - return if a given SDCA Control is volatile
134 * @function: Pointer to the Function information.
139 bool sdca_regmap_volatile(struct sdca_function_data *function, unsigned int reg) in sdca_regmap_volatile() argument
146 control = function_find_control(function, reg); in sdca_regmap_volatile()
150 switch (control->mode) { in sdca_regmap_volatile()
162 * sdca_regmap_deferrable - return if a given SDCA Control is deferrable
163 * @function: Pointer to the Function information.
168 bool sdca_regmap_deferrable(struct sdca_function_data *function, unsigned int reg) in sdca_regmap_deferrable() argument
175 control = function_find_control(function, reg); in sdca_regmap_deferrable()
179 return control->deferrable; in sdca_regmap_deferrable()
184 * sdca_regmap_mbq_size - return size in bytes of a given SDCA Control
185 * @function: Pointer to the Function information.
190 int sdca_regmap_mbq_size(struct sdca_function_data *function, unsigned int reg) in sdca_regmap_mbq_size() argument
195 return -EINVAL; in sdca_regmap_mbq_size()
197 control = function_find_control(function, reg); in sdca_regmap_mbq_size()
199 return -EINVAL; in sdca_regmap_mbq_size()
201 return clamp_val(control->nbits / BITS_PER_BYTE, sizeof(u8), sizeof(u32)); in sdca_regmap_mbq_size()
206 * sdca_regmap_count_constants - count the number of DisCo constant Controls
208 * @function: Pointer to the Function information, to be parsed.
210 * This function returns the number of DisCo constant Controls present
211 * in a function. Typically this information will be used to populate
219 struct sdca_function_data *function) in sdca_regmap_count_constants() argument
224 for (i = 0; i < function->num_entities; i++) { in sdca_regmap_count_constants()
225 struct sdca_entity *entity = &function->entities[i]; in sdca_regmap_count_constants()
227 for (j = 0; j < entity->num_controls; j++) { in sdca_regmap_count_constants()
228 if (entity->controls[j].mode == SDCA_ACCESS_MODE_DC) in sdca_regmap_count_constants()
229 nconsts += hweight64(entity->controls[j].cn_list); in sdca_regmap_count_constants()
238 * sdca_regmap_populate_constants - fill an array with DisCo constant values
240 * @function: Pointer to the Function information, to be parsed.
244 * This function will populate a regmap struct reg_default array with
245 * the values of the DisCo constants for a given Function. This
253 struct sdca_function_data *function, in sdca_regmap_populate_constants() argument
258 for (i = 0, k = 0; i < function->num_entities; i++) { in sdca_regmap_populate_constants()
259 struct sdca_entity *entity = &function->entities[i]; in sdca_regmap_populate_constants()
261 for (j = 0; j < entity->num_controls; j++) { in sdca_regmap_populate_constants()
262 struct sdca_control *control = &entity->controls[j]; in sdca_regmap_populate_constants()
265 if (control->mode != SDCA_ACCESS_MODE_DC) in sdca_regmap_populate_constants()
269 for_each_set_bit(cn, (unsigned long *)&control->cn_list, in sdca_regmap_populate_constants()
270 BITS_PER_TYPE(control->cn_list)) { in sdca_regmap_populate_constants()
271 consts[k].reg = SDW_SDCA_CTL(function->desc->adr, in sdca_regmap_populate_constants()
272 entity->id, in sdca_regmap_populate_constants()
273 control->sel, cn); in sdca_regmap_populate_constants()
274 consts[k].def = control->values[l]; in sdca_regmap_populate_constants()
286 * sdca_regmap_write_defaults - write out DisCo defaults to device
288 * @regmap: Pointer to the Function register map.
289 * @function: Pointer to the Function information, to be parsed.
291 * This function will write out to the hardware all the DisCo default and
298 struct sdca_function_data *function) in sdca_regmap_write_defaults() argument
303 for (i = 0; i < function->num_entities; i++) { in sdca_regmap_write_defaults()
304 struct sdca_entity *entity = &function->entities[i]; in sdca_regmap_write_defaults()
306 for (j = 0; j < entity->num_controls; j++) { in sdca_regmap_write_defaults()
307 struct sdca_control *control = &entity->controls[j]; in sdca_regmap_write_defaults()
310 if (control->mode == SDCA_ACCESS_MODE_DC) in sdca_regmap_write_defaults()
313 if (!control->has_default && !control->has_fixed) in sdca_regmap_write_defaults()
317 for_each_set_bit(cn, (unsigned long *)&control->cn_list, in sdca_regmap_write_defaults()
318 BITS_PER_TYPE(control->cn_list)) { in sdca_regmap_write_defaults()
321 reg = SDW_SDCA_CTL(function->desc->adr, entity->id, in sdca_regmap_write_defaults()
322 control->sel, cn); in sdca_regmap_write_defaults()
324 ret = regmap_write(regmap, reg, control->values[k]); in sdca_regmap_write_defaults()