misc: cs40l2x: Add GPIO1 device tree entries

Added device tree entries for default GPIO1 rising-edge index,
falling-edge index, and falling-edge timeout to be written to
the corresponding DSP firmware controls during initialization.

Change-Id: Ib8f0b662fdf8367e31608cdc121fdcade0fdd1be
Signed-off-by: Jeff LaBundy <jeff.labundy@cirrus.com>
Signed-off-by: Ravi Vembu <raviv@motorola.com>
This commit is contained in:
Jeff LaBundy 2018-05-31 17:38:04 -05:00 • committed by a7301c
commit 3ca806f96d
3 changed files with 70 additions and 0 deletions

View file

@ -1887,6 +1887,58 @@ static void cs40l2x_dsp_start(struct cs40l2x_private *cs40l2x)
}
}
if (cs40l2x->pdata.gpio1_rise_index > 0
&& cs40l2x->pdata.gpio1_rise_index
< cs40l2x->num_waves) {
ret = regmap_write(regmap,
cs40l2x_dsp_reg(cs40l2x, "INDEXBUTTONPRESS",
CS40L2X_XM_UNPACKED_TYPE),
cs40l2x->pdata.gpio1_rise_index);
if (ret) {
dev_err(dev,
"Failed to write default gpio1_rise_index\n");
return;
}
} else if (cs40l2x->pdata.gpio1_rise_index >= cs40l2x->num_waves) {
dev_warn(dev, "Ignored default gpio1_rise_index\n");
}
if (cs40l2x->pdata.gpio1_fall_index > 0
&& cs40l2x->pdata.gpio1_fall_index
< cs40l2x->num_waves) {
ret = regmap_write(regmap,
cs40l2x_dsp_reg(cs40l2x, "INDEXBUTTONRELEASE",
CS40L2X_XM_UNPACKED_TYPE),
cs40l2x->pdata.gpio1_fall_index);
if (ret) {
dev_err(dev,
"Failed to write default gpio1_fall_index\n");
return;
}
} else if (cs40l2x->pdata.gpio1_fall_index >= cs40l2x->num_waves) {
dev_warn(dev, "Ignored default gpio1_fall_index\n");
}
if (cs40l2x->pdata.gpio1_fall_timeout > 0
&& (cs40l2x->pdata.gpio1_fall_timeout
& CS40L2X_PDATA_MASK)
<= CS40L2X_PR_TIMEOUT_MAX) {
ret = regmap_write(regmap,
cs40l2x_dsp_reg(cs40l2x,
"PRESS_RELEASE_TIMEOUT",
CS40L2X_XM_UNPACKED_TYPE),
cs40l2x->pdata.gpio1_fall_timeout
& CS40L2X_PDATA_MASK);
if (ret) {
dev_err(dev,
"Failed to write default gpio1_fall_timeout\n");
return;
}
} else if ((cs40l2x->pdata.gpio1_fall_timeout
& CS40L2X_PDATA_MASK) > CS40L2X_PR_TIMEOUT_MAX) {
dev_warn(dev, "Ignored default gpio1_fall_timeout\n");
}
dev_info(dev, "Normal-mode haptics successfully started\n");
cs40l2x_vibe_init(cs40l2x);
@ -2604,6 +2656,18 @@ static int cs40l2x_handle_of_data(struct i2c_client *i2c_client,
if (!ret)
pdata->redc_max = out_val;
ret = of_property_read_u32(np, "cirrus,gpio1-rise-index", &out_val);
if (!ret)
pdata->gpio1_rise_index = out_val;
ret = of_property_read_u32(np, "cirrus,gpio1-fall-index", &out_val);
if (!ret)
pdata->gpio1_fall_index = out_val;
ret = of_property_read_u32(np, "cirrus,gpio1-fall-timeout", &out_val);
if (!ret)
pdata->gpio1_fall_timeout = out_val | CS40L2X_PDATA_PRESENT;
return 0;
}

View file

@ -743,6 +743,9 @@
#define CS40L2X_WT_NAME "cs40l20.bin"
#define CS40L2X_PDATA_PRESENT 0x80000000
#define CS40L2X_PDATA_MASK ~CS40L2X_PDATA_PRESENT
bool cs40l2x_readable_reg(struct device *dev, unsigned int reg);
bool cs40l2x_precious_reg(struct device *dev, unsigned int reg);

View file

@ -23,6 +23,9 @@ struct cs40l2x_platform_data {
unsigned int redc_default;
unsigned int redc_min;
unsigned int redc_max;
unsigned int gpio1_rise_index;
unsigned int gpio1_fall_index;
unsigned int gpio1_fall_timeout;
};
#endif /* __CS40L2X_H */