Lines Matching +full:j +full:- +full:to +full:- +full:k
1 // SPDX-License-Identifier: GPL-2.0
7 * https://www.mipi.org/mipi-sdca-v1-0-download
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()
58 * sdca_regmap_readable - return if a given SDCA Control is readable
59 * @function: Pointer to the Function information.
60 * @reg: Register address/Control to be processed.
75 if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list)) in sdca_regmap_readable()
78 switch (control->mode) { in sdca_regmap_readable()
87 /* No access to registers marked solely for device use */ 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.
98 * @reg: Register address/Control to be processed.
113 if (!(BIT(SDW_SDCA_CTL_CNUM(reg)) & control->cn_list)) in sdca_regmap_writeable()
116 switch (control->mode) { in sdca_regmap_writeable()
124 /* No access to registers marked solely for device use */ 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.
135 * @reg: Register address/Control to be processed.
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.
164 * @reg: Register address/Control to be processed.
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.
186 * @reg: Register address/Control to be processed.
195 return -EINVAL; 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
207 * @dev: Pointer to the device.
208 * @function: Pointer to the Function information, to be parsed.
211 * in a function. Typically this information will be used to populate
212 * the regmap defaults array, allowing drivers to access the values of
222 int i, j; in sdca_regmap_count_constants() local
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
239 * @dev: Pointer to the device.
240 * @function: Pointer to the Function information, to be parsed.
241 * @consts: Pointer to the array which should be filled with the DisCo
246 * allows to access the values of DisCo constants the same as any
256 int i, j, k, l; in sdca_regmap_populate_constants() local
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()
275 k++; in sdca_regmap_populate_constants()
281 return k; in sdca_regmap_populate_constants()
286 * sdca_regmap_write_defaults - write out DisCo defaults to device
287 * @dev: Pointer to the 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
292 * fixed value controls. This will cause them to be populated into the cache,
300 int i, j, k; in sdca_regmap_write_defaults() local
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()
316 k = 0; 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()
328 k++; in sdca_regmap_write_defaults()