Commit 7adadfb0 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Mark Brown

ASoC: twl4030: Drop legacy, non DT boot support

Legacy or non DT boot is no longer possible on systems where the
tw4030/5030 is used.

Drop the support for handling legacy pdata and replace it with a local
board_params struct to allow further cleanups on the mfd side.
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20220616153521.29701-1-peter.ujfalusi@gmail.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2964e31c
...@@ -34,6 +34,14 @@ ...@@ -34,6 +34,14 @@
#define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1)
struct twl4030_board_params {
unsigned int digimic_delay; /* in ms */
unsigned int ramp_delay_value;
unsigned int offset_cncl_path;
unsigned int hs_extmute:1;
int hs_extmute_gpio;
};
/* codec private data */ /* codec private data */
struct twl4030_priv { struct twl4030_priv {
unsigned int codec_powered; unsigned int codec_powered;
...@@ -58,7 +66,7 @@ struct twl4030_priv { ...@@ -58,7 +66,7 @@ struct twl4030_priv {
u8 carkitl_enabled, carkitr_enabled; u8 carkitl_enabled, carkitr_enabled;
u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1]; u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
struct twl4030_codec_data *pdata; struct twl4030_board_params *board_params;
}; };
static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030) static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030)
...@@ -193,73 +201,71 @@ static void twl4030_codec_enable(struct snd_soc_component *component, int enable ...@@ -193,73 +201,71 @@ static void twl4030_codec_enable(struct snd_soc_component *component, int enable
udelay(10); udelay(10);
} }
static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata, static void
struct device_node *node) twl4030_get_board_param_values(struct twl4030_board_params *board_params,
struct device_node *node)
{ {
int value; int value;
of_property_read_u32(node, "ti,digimic_delay", of_property_read_u32(node, "ti,digimic_delay", &board_params->digimic_delay);
&pdata->digimic_delay); of_property_read_u32(node, "ti,ramp_delay_value", &board_params->ramp_delay_value);
of_property_read_u32(node, "ti,ramp_delay_value", of_property_read_u32(node, "ti,offset_cncl_path", &board_params->offset_cncl_path);
&pdata->ramp_delay_value);
of_property_read_u32(node, "ti,offset_cncl_path",
&pdata->offset_cncl_path);
if (!of_property_read_u32(node, "ti,hs_extmute", &value)) if (!of_property_read_u32(node, "ti,hs_extmute", &value))
pdata->hs_extmute = value; board_params->hs_extmute = value;
pdata->hs_extmute_gpio = of_get_named_gpio(node, board_params->hs_extmute_gpio = of_get_named_gpio(node, "ti,hs_extmute_gpio", 0);
"ti,hs_extmute_gpio", 0); if (gpio_is_valid(board_params->hs_extmute_gpio))
if (gpio_is_valid(pdata->hs_extmute_gpio)) board_params->hs_extmute = 1;
pdata->hs_extmute = 1;
} }
static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_component *component) static struct twl4030_board_params*
twl4030_get_board_params(struct snd_soc_component *component)
{ {
struct twl4030_codec_data *pdata = dev_get_platdata(component->dev); struct twl4030_board_params *board_params = NULL;
struct device_node *twl4030_codec_node = NULL; struct device_node *twl4030_codec_node = NULL;
twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node,
"codec"); "codec");
if (!pdata && twl4030_codec_node) { if (twl4030_codec_node) {
pdata = devm_kzalloc(component->dev, board_params = devm_kzalloc(component->dev,
sizeof(struct twl4030_codec_data), sizeof(struct twl4030_board_params),
GFP_KERNEL); GFP_KERNEL);
if (!pdata) { if (!board_params) {
of_node_put(twl4030_codec_node); of_node_put(twl4030_codec_node);
return NULL; return NULL;
} }
twl4030_setup_pdata_of(pdata, twl4030_codec_node); twl4030_get_board_param_values(board_params, twl4030_codec_node);
of_node_put(twl4030_codec_node); of_node_put(twl4030_codec_node);
} }
return pdata; return board_params;
} }
static void twl4030_init_chip(struct snd_soc_component *component) static void twl4030_init_chip(struct snd_soc_component *component)
{ {
struct twl4030_codec_data *pdata; struct twl4030_board_params *board_params;
struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component);
u8 reg, byte; u8 reg, byte;
int i = 0; int i = 0;
pdata = twl4030_get_pdata(component); board_params = twl4030_get_board_params(component);
if (pdata && pdata->hs_extmute) { if (board_params && board_params->hs_extmute) {
if (gpio_is_valid(pdata->hs_extmute_gpio)) { if (gpio_is_valid(board_params->hs_extmute_gpio)) {
int ret; int ret;
if (!pdata->hs_extmute_gpio) if (!board_params->hs_extmute_gpio)
dev_warn(component->dev, dev_warn(component->dev,
"Extmute GPIO is 0 is this correct?\n"); "Extmute GPIO is 0 is this correct?\n");
ret = gpio_request_one(pdata->hs_extmute_gpio, ret = gpio_request_one(board_params->hs_extmute_gpio,
GPIOF_OUT_INIT_LOW, GPIOF_OUT_INIT_LOW,
"hs_extmute"); "hs_extmute");
if (ret) { if (ret) {
dev_err(component->dev, dev_err(component->dev,
"Failed to get hs_extmute GPIO\n"); "Failed to get hs_extmute GPIO\n");
pdata->hs_extmute_gpio = -1; board_params->hs_extmute_gpio = -1;
} }
} else { } else {
u8 pin_mux; u8 pin_mux;
...@@ -290,14 +296,14 @@ static void twl4030_init_chip(struct snd_soc_component *component) ...@@ -290,14 +296,14 @@ static void twl4030_init_chip(struct snd_soc_component *component)
twl4030_write(component, TWL4030_REG_ARXR2_APGA_CTL, 0x32); twl4030_write(component, TWL4030_REG_ARXR2_APGA_CTL, 0x32);
/* Machine dependent setup */ /* Machine dependent setup */
if (!pdata) if (!board_params)
return; return;
twl4030->pdata = pdata; twl4030->board_params = board_params;
reg = twl4030_read(component, TWL4030_REG_HS_POPN_SET); reg = twl4030_read(component, TWL4030_REG_HS_POPN_SET);
reg &= ~TWL4030_RAMP_DELAY; reg &= ~TWL4030_RAMP_DELAY;
reg |= (pdata->ramp_delay_value << 2); reg |= (board_params->ramp_delay_value << 2);
twl4030_write(component, TWL4030_REG_HS_POPN_SET, reg); twl4030_write(component, TWL4030_REG_HS_POPN_SET, reg);
/* initiate offset cancellation */ /* initiate offset cancellation */
...@@ -305,7 +311,7 @@ static void twl4030_init_chip(struct snd_soc_component *component) ...@@ -305,7 +311,7 @@ static void twl4030_init_chip(struct snd_soc_component *component)
reg = twl4030_read(component, TWL4030_REG_ANAMICL); reg = twl4030_read(component, TWL4030_REG_ANAMICL);
reg &= ~TWL4030_OFFSET_CNCL_SEL; reg &= ~TWL4030_OFFSET_CNCL_SEL;
reg |= pdata->offset_cncl_path; reg |= board_params->offset_cncl_path;
twl4030_write(component, TWL4030_REG_ANAMICL, twl4030_write(component, TWL4030_REG_ANAMICL,
reg | TWL4030_CNCL_OFFSET_START); reg | TWL4030_CNCL_OFFSET_START);
...@@ -692,7 +698,7 @@ static void headset_ramp(struct snd_soc_component *component, int ramp) ...@@ -692,7 +698,7 @@ static void headset_ramp(struct snd_soc_component *component, int ramp)
{ {
unsigned char hs_gain, hs_pop; unsigned char hs_gain, hs_pop;
struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component);
struct twl4030_codec_data *pdata = twl4030->pdata; struct twl4030_board_params *board_params = twl4030->board_params;
/* Base values for ramp delay calculation: 2^19 - 2^26 */ /* Base values for ramp delay calculation: 2^19 - 2^26 */
unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304,
8388608, 16777216, 33554432, 67108864}; 8388608, 16777216, 33554432, 67108864};
...@@ -705,9 +711,9 @@ static void headset_ramp(struct snd_soc_component *component, int ramp) ...@@ -705,9 +711,9 @@ static void headset_ramp(struct snd_soc_component *component, int ramp)
/* Enable external mute control, this dramatically reduces /* Enable external mute control, this dramatically reduces
* the pop-noise */ * the pop-noise */
if (pdata && pdata->hs_extmute) { if (board_params && board_params->hs_extmute) {
if (gpio_is_valid(pdata->hs_extmute_gpio)) { if (gpio_is_valid(board_params->hs_extmute_gpio)) {
gpio_set_value(pdata->hs_extmute_gpio, 1); gpio_set_value(board_params->hs_extmute_gpio, 1);
} else { } else {
hs_pop |= TWL4030_EXTMUTE; hs_pop |= TWL4030_EXTMUTE;
twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop);
...@@ -741,9 +747,9 @@ static void headset_ramp(struct snd_soc_component *component, int ramp) ...@@ -741,9 +747,9 @@ static void headset_ramp(struct snd_soc_component *component, int ramp)
} }
/* Disable external mute */ /* Disable external mute */
if (pdata && pdata->hs_extmute) { if (board_params && board_params->hs_extmute) {
if (gpio_is_valid(pdata->hs_extmute_gpio)) { if (gpio_is_valid(board_params->hs_extmute_gpio)) {
gpio_set_value(pdata->hs_extmute_gpio, 0); gpio_set_value(board_params->hs_extmute_gpio, 0);
} else { } else {
hs_pop &= ~TWL4030_EXTMUTE; hs_pop &= ~TWL4030_EXTMUTE;
twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop);
...@@ -806,10 +812,10 @@ static int digimic_event(struct snd_soc_dapm_widget *w, ...@@ -806,10 +812,10 @@ static int digimic_event(struct snd_soc_dapm_widget *w,
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component);
struct twl4030_codec_data *pdata = twl4030->pdata; struct twl4030_board_params *board_params = twl4030->board_params;
if (pdata && pdata->digimic_delay) if (board_params && board_params->digimic_delay)
twl4030_wait_ms(pdata->digimic_delay); twl4030_wait_ms(board_params->digimic_delay);
return 0; return 0;
} }
...@@ -2168,10 +2174,11 @@ static int twl4030_soc_probe(struct snd_soc_component *component) ...@@ -2168,10 +2174,11 @@ static int twl4030_soc_probe(struct snd_soc_component *component)
static void twl4030_soc_remove(struct snd_soc_component *component) static void twl4030_soc_remove(struct snd_soc_component *component)
{ {
struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component);
struct twl4030_codec_data *pdata = twl4030->pdata; struct twl4030_board_params *board_params = twl4030->board_params;
if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) if (board_params && board_params->hs_extmute &&
gpio_free(pdata->hs_extmute_gpio); gpio_is_valid(board_params->hs_extmute_gpio))
gpio_free(board_params->hs_extmute_gpio);
} }
static const struct snd_soc_component_driver soc_component_dev_twl4030 = { static const struct snd_soc_component_driver soc_component_dev_twl4030 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment