* @sel: Identifier used for addressing.
* @nbits: Number of bits used in the Control.
* @values: Holds the Control value for constants and defaults.
+ * @reset: Defined reset value for the Control.
* @cn_list: A bitmask showing the valid Control Numbers within this Control,
* Control Numbers typically represent channels.
* @interrupt_position: SCDA interrupt line that will alert to changes on this
* @layers: Bitmask of access layers of the Control.
* @deferrable: Indicates if the access to the Control can be deferred.
* @has_default: Indicates the Control has a default value to be written.
+ * @has_reset: Indicates the Control has a defined reset value.
* @has_fixed: Indicates the Control only supports a single value.
*/
struct sdca_control {
int nbits;
int *values;
+ int reset;
u64 cn_list;
int interrupt_position;
bool deferrable;
bool is_volatile;
bool has_default;
+ bool has_reset;
bool has_fixed;
};
return 0;
}
+static int find_sdca_control_reset(const struct sdca_entity *entity,
+ struct sdca_control *control)
+{
+ switch (SDCA_CTL_TYPE(entity->type, control->sel)) {
+ case SDCA_CTL_TYPE_S(FU, AGC):
+ case SDCA_CTL_TYPE_S(FU, BASS_BOOST):
+ case SDCA_CTL_TYPE_S(FU, LOUDNESS):
+ case SDCA_CTL_TYPE_S(SMPU, TRIGGER_ENABLE):
+ case SDCA_CTL_TYPE_S(GE, SELECTED_MODE):
+ case SDCA_CTL_TYPE_S(TG, TONE_DIVIDER):
+ case SDCA_CTL_TYPE_S(ENTITY_0, COMMIT_GROUP_MASK):
+ control->has_reset = true;
+ control->reset = 0;
+ break;
+ case SDCA_CTL_TYPE_S(XU, BYPASS):
+ case SDCA_CTL_TYPE_S(MFPU, BYPASS):
+ case SDCA_CTL_TYPE_S(FU, MUTE):
+ case SDCA_CTL_TYPE_S(CX, CLOCK_SELECT):
+ control->has_reset = true;
+ control->reset = 1;
+ break;
+ case SDCA_CTL_TYPE_S(PDE, REQUESTED_PS):
+ control->has_reset = true;
+ control->reset = 3;
+ break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
static int find_sdca_entity_control(struct device *dev, struct sdca_entity *entity,
struct fwnode_handle *control_node,
struct sdca_control *control)
control->is_volatile = find_sdca_control_volatile(entity, control);
+ ret = find_sdca_control_reset(entity, control);
+ if (ret)
+ return ret;
+
ret = find_sdca_control_range(dev, control_node, &control->range);
if (ret) {
dev_err(dev, "%s: control %#x: range missing: %d\n",
struct sdca_entity *entity = &function->entities[i];
for (j = 0; j < entity->num_controls; j++) {
- if (entity->controls[j].mode == SDCA_ACCESS_MODE_DC)
+ if (entity->controls[j].mode == SDCA_ACCESS_MODE_DC ||
+ entity->controls[j].has_reset)
nconsts += hweight64(entity->controls[j].cn_list);
}
}
struct sdca_control *control = &entity->controls[j];
int cn;
- if (control->mode != SDCA_ACCESS_MODE_DC)
+ if (control->mode != SDCA_ACCESS_MODE_DC &&
+ !control->has_reset)
continue;
l = 0;
consts[k].reg = SDW_SDCA_CTL(function->desc->adr,
entity->id,
control->sel, cn);
- consts[k].def = control->values[l];
+ if (control->mode == SDCA_ACCESS_MODE_DC)
+ consts[k].def = control->values[l];
+ else
+ consts[k].def = control->reset;
k++;
l++;
}
i++;
} else if (!control->is_volatile) {
+ if (control->has_reset)
+ regcache_drop_region(regmap, reg, reg);
+
ret = regmap_read(regmap, reg, &val);
if (ret) {
dev_err(dev, "Failed to read initial %#x: %d\n",