ASoC: codecs: ak4619: Add PDN pin handling

Alexander Koch <mail@alexanderkoch.net> says:

The AK4619 datasheet describes the functionality of the power down (PDN)
pin as follows (p. 39, 'Power-up/down Sequence'):

  The AK4619 should be powered up when the PDN pin = "L". The PDN pin
  should be set "H" after all power supplies have ramped up.
  At that point, the reference voltage generator block (REFBLK) and LDO
  (AVDRV) circuit are powered up and the control registers are
  initialized. Control register settings should be no less than 10ms
  after PDN pin = "H".

The current implementation of the driver does not operate the PDN pin
in any way, it seems to rely on external control of the pin.

Improve this by adding a device tree binding to enable the driver to
set the pin 'high' during probe. Make it optional to keep the behaviour
for existing device trees unchanged.

Tested on an i.MX8MM board with the AK4619 connected to GPIO1 and SSI3.

Link: https://patch.msgid.link/20260929090821.1476257-1-mail@alexanderkoch.net
This commit is contained in:
Mark Brown 2026-09-29 12:45:37 +01:00
commit d733add0b2
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
2 changed files with 23 additions and 0 deletions

View File

@ -34,6 +34,12 @@ properties:
$ref: audio-graph-port.yaml#
unevaluatedProperties: false
powerdown-gpios:
maxItems: 1
description:
GPIO connected to the 'PDN' pin, if any. Needs to be set low to
power down the codec, hence the GPIO must be GPIO_ACTIVE_LOW.
required:
- compatible
- reg
@ -42,6 +48,8 @@ unevaluatedProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
@ -49,6 +57,8 @@ examples:
compatible = "asahi-kasei,ak4619";
reg = <0x10>;
powerdown-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
clocks = <&rcar_sound>;
clock-names = "mclk";

View File

@ -152,6 +152,7 @@
struct ak4619_priv {
struct regmap *regmap;
struct snd_pcm_hw_constraint_list constraint;
struct gpio_desc *pdn_gpio;
int deemph_en;
unsigned int playback_rate;
unsigned int sysclk;
@ -894,10 +895,20 @@ static int ak4619_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, ak4619);
ak4619->pdn_gpio = devm_gpiod_get_optional(dev, "powerdown",
GPIOD_OUT_LOW);
if (IS_ERR(ak4619->pdn_gpio))
return dev_err_probe(dev, PTR_ERR(ak4619->pdn_gpio),
"powerdown GPIO request failed\n");
if (ak4619->pdn_gpio)
msleep(10);
ak4619->regmap = devm_regmap_init_i2c(i2c, &ak4619_regmap_cfg);
if (IS_ERR(ak4619->regmap)) {
ret = PTR_ERR(ak4619->regmap);
dev_err(dev, "regmap_init() failed: %d\n", ret);
if (ak4619->pdn_gpio)
gpiod_set_value_cansleep(ak4619->pdn_gpio, 1);
return ret;
}
@ -906,6 +917,8 @@ static int ak4619_i2c_probe(struct i2c_client *i2c)
if (ret < 0) {
dev_err(dev, "Failed to register ak4619 component: %d\n",
ret);
if (ak4619->pdn_gpio)
gpiod_set_value_cansleep(ak4619->pdn_gpio, 1);
return ret;
}