设备树配置
ad82584f_62: ad82584f_62@62 {
compatible = “ESMT, ad82584f”;
#sound-dai-cells = <0>;
reg = <0x31>;
status = “okay”;
reset_pin = <&gpio GPIOZ_15 1>;
no_mclk;
};
static int ad82584f_parse_dt(
struct ad82584f_priv *ad82584f,
struct device_node *np)
{
int ret = 0;
int reset_pin = -1;
reset_pin = of_get_named_gpio(np, "reset_pin", 0);
if (reset_pin < 0) {
pr_err("%s fail to get reset pin from dts!\n", __func__);
printk("%s fail to get reset pin from dts!\n", __func__);
ret = -1;
} else {
pr_info("%s pdata->reset_pin = %d!\n", __func__,
ad82584f->pdata->reset_pin);
printk("%s pdata->reset_pin = %d!\n", __func__,
ad82584f->pdata->reset_pin);
}
ad82584f->pdata->reset_pin = reset_pin;
printk("%s:reset_pin %d\n",__func__,reset_pin);
ad82584f->pdata->no_mclk = of_property_read_bool(
np,
"no_mclk");
if (ad82584f->pdata->no_mclk)
pr_info("%s mclk is not connected.\n", __func__);
return ret;
}
static int ad82584f_GPIO_enable(struct snd_soc_codec *codec, bool enable)
{
struct ad82584f_priv *ad82584f = snd_soc_codec_get_drvdata(codec);
struct ad82584f_platform_data *pdata = ad82584f->pdata;
printk("%s:pt1\n",__func__);
if (pdata->reset_pin < 0)
return 0;
printk("%s:pt2\n",__func__);
if (enable == true) {
printk("%s:pt4\n",__func__);
gpio_direction_output(pdata->reset_pin, GPIOF_OUT_INIT_LOW);
usleep_range(10 * 1000, 11 * 1000);
gpio_direction_output(pdata->reset_pin, GPIOF_OUT_INIT_HIGH);
gpio_set_value(pdata->reset_pin,GPIOF_OUT_INIT_HIGH);
dev_info(codec->dev, "ad82584f start status = %d\n",
gpio_get_value(pdata->reset_pin));
usleep_range(1 * 1000, 2 * 1000);
mdelay(100);
printk("ad82584f start status = %d\n",
gpio_get_value(pdata->reset_pin));
} else {
/*gpio_direction_output(pdata->reset_pin, GPIOF_OUT_INIT_LOW);*/
gpio_set_value(pdata->reset_pin, GPIOF_OUT_INIT_LOW);
dev_info(codec->dev, "ad82584f stop status = %d\n",
gpio_get_value(pdata->reset_pin));
/*devm_gpio_free(codec->dev, pdata->reset_pin);*/
}
return 0;
}
对应log
[ 3.172947] ad82584f_i2c_probe:pt1
[ 3.172969] ad82584f_parse_dt pdata->reset_pin = 0!
[ 3.172970] ad82584f_parse_dt pdata->reset_pin = 0!
[ 3.172971] ad82584f_parse_dt:reset_pin 426
[ 3.172973] ad82584f_parse_dt mclk is not connected.
[ 3.195766] meson-mmc: amlmmc_dtb_init: register dtb chardev OK
[ 3.195766] meson-mmc: Exit aml_emmc_partition_ops OK.
[ 3.391386] ad82584f_init:pt1
[ 3.391388] ad82584f_GPIO_enable:pt1
[ 3.391389] ad82584f_GPIO_enable:pt2
[ 3.391390] ad82584f_GPIO_enable:pt4
[ 3.402422] ad82584f 3-0031: ad82584f start status = 0
[ 3.504445] ad82584f start status = 0
[ 3.504448] ad82584f 3-0031: ad82584f_init!
[ 3.964455] asoc-aml-card auge_sound: control 2:0:0:I2SIn CLK:0 is already present
[ 3.195766] meson-mmc: Exit aml_emmc_partition_ops OK.
[ 3.391386] ad82584f_init:pt1
[ 3.391388] ad82584f_GPIO_enable:pt1
[ 3.391389] ad82584f_GPIO_enable:pt2
[ 3.391390] ad82584f_GPIO_enable:pt4
[ 3.402422] ad82584f 3-0031: ad82584f start status = 0
[ 3.504445] ad82584f start status = 0
[ 3.504448] ad82584f 3-0031: ad82584f_init!
gpioz_15 设置为高后,示波器无法测试出高,及用gpio_get_value(pdata->reset_pin) 获取到的数据也是低,pdata->reset_pin = 426。