From patchwork Mon Jul 1 07:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13717598 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFE9853365 for ; Mon, 1 Jul 2024 07:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719817360; cv=none; b=QV42FLhaEMi94n2OuI97KILlhwPrse79Qr8MRXeEKmRV17Vt40N6BvSwKbwkradVj0qfk4vyT/kgJuZdOYDjq6jmuG6BqUjIUpl1x65i9j08VdBC//keH0a9MUXzjedDikZ+glF5LweSm69GY38/XTlmrdPxVQZRsHQgbAuJhC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719817360; c=relaxed/simple; bh=HoYOZ5VZZSoT1oPQmsk8ALI7brrvFdAyk8iW+8VaR4M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UC+zoQ4HskFdsAVaVPE1P0dFQVdQ/H2oNNl4+rftUzX5VSBTKhI4cAlw0jnMtLr0eELYQrpVilVoHisLM3gRFCGR1RVSwi1gZpkBCiF6FAMFtbFuXhrYSmEpwZVwJ50fmwPsRoFL1JFkm0LZJiqq5S7PdqWrbYLjWkd7e+xZ2GM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=kvd6i+a/; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kvd6i+a/" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-57d06101d76so2839157a12.3 for ; Mon, 01 Jul 2024 00:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719817357; x=1720422157; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=G0uxixe8SRdEtYS3hYnA/51z5ZCVTziscEpNL0ARHP8=; b=kvd6i+a/8KSSu0NKX5Qvd7b+ppJhT5FrDmuIKUHmKBGHhieikiXrm2al7Lj4b8vDBj nohdvVhGFBVNSw2U1q1V4QR/BDqKj9ll26StvJWYV/CQQI9i3m6YXG0/Y7oyQxz2f7to DBcscjENTIycKvdzyMd9k9l660kaaF0MaeCXsg27wcUf9Jrsqz19ubGKmj+v/foojqLN lxCJ8LNsIJX0KOQQMMjmRcl50YfWQlCWaeVuwMpc5Z3xKs0v5mbyy31oi1HFhs5OKPOW W8qhZnY8wGHL4yoY9mKwq5F5fHJierlkrCYrzZFie+JS62MzwwzX1bbi40e0a3RiUVJg 4wag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719817357; x=1720422157; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G0uxixe8SRdEtYS3hYnA/51z5ZCVTziscEpNL0ARHP8=; b=XC5yDCdLTFlJfsDx7Vy75zAzz4qrmoUzgbGr4MEHenBHFUqNmS+mPrRreUu6q6jH7k p/ESu+h7YUbuSPQ+6mf+Vl9+zu7XJsze/P8m1LYeLOYmNI3oM14cef2bNiOkpqMAnp9d jMbcgH6iXqlAltjlRXqCSgGNX6N/8cslLUsHztTV7k4dQqTn/XWsjtsIlgb+8UMcwu83 W2pqqr7n1wMlo+QBqUR+51GgejG7GoKoR9uMkv9zTx4i3S8scDmXC1RkW/bcvlfwvXvQ jqgpITZJX9lwhn9FwHB/5GI1sz1zzC07/EnqCAuYChpiVWrZ/TGd51eXbHxsPrNoMdKb 7A5Q== X-Gm-Message-State: AOJu0YzA5zJsh1HBQnBoh7YYvu1EqxgIrrAsnt2qwBG7zDWMD2xgDuC5 8JAXImalecNVcQD0o5RK7AeTLbSw+HNvq6Sc9Cc6Z6zaJwfTu/p0jPv6APE5IUFVazoppa+h42v i X-Google-Smtp-Source: AGHT+IFpmkqFIW4SYt5Bywcq02sj5OIw8F3oMcyUDj7GJ0VoQuAFnMl+7gJ97FBtnoFNiB+QfU/AHA== X-Received: by 2002:a05:6402:2547:b0:57d:f9f:133b with SMTP id 4fb4d7f45d1cf-5879f0c4da6mr3053720a12.2.1719817357206; Mon, 01 Jul 2024 00:02:37 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861324f036sm4034383a12.34.2024.07.01.00.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 00:02:36 -0700 (PDT) From: Linus Walleij Date: Mon, 01 Jul 2024 09:02:12 +0200 Subject: [PATCH 1/4] ASoC: tas5086: Convert to GPIO descriptors Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240701-asoc-tas-gpios-v1-1-d69ec5d79939@linaro.org> References: <20240701-asoc-tas-gpios-v1-0-d69ec5d79939@linaro.org> In-Reply-To: <20240701-asoc-tas-gpios-v1-0-d69ec5d79939@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shenghao Ding , Kevin Lu , Baojun Xu Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Shenghao Ding <13916275206@139.com>, alsa-devel@alsa-project.org, Linus Walleij X-Mailer: b4 0.14.0 Switch the driver to use GPIO descriptors. Notice that we let the gpiolib handle line inversion for the active low reset line (nreset !reset). There are no upstream device trees using the tas5086 compatible string, if there were, we would need to ascertain that they all set the GPIO_ACTIVE_LOW flag on their GPIO lines. Signed-off-by: Linus Walleij --- sound/soc/codecs/tas5086.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index 6d45df3b9ba4..4bc1fdd232bb 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -24,14 +24,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #include #include #include @@ -246,7 +245,7 @@ struct tas5086_private { /* Current sample rate for de-emphasis control */ int rate; /* GPIO driving Reset pin, if any */ - int gpio_nreset; + struct gpio_desc *reset; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; }; @@ -462,11 +461,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) static void tas5086_reset(struct tas5086_private *priv) { - if (gpio_is_valid(priv->gpio_nreset)) { + if (priv->reset) { /* Reset codec - minimum assertion time is 400ns */ - gpio_direction_output(priv->gpio_nreset, 0); + gpiod_direction_output(priv->reset, 1); udelay(1); - gpio_set_value(priv->gpio_nreset, 1); + gpiod_set_value(priv->reset, 0); /* Codec needs ~15ms to wake up */ msleep(15); @@ -867,9 +866,9 @@ static void tas5086_remove(struct snd_soc_component *component) { struct tas5086_private *priv = snd_soc_component_get_drvdata(component); - if (gpio_is_valid(priv->gpio_nreset)) + if (priv->reset) /* Set codec to the reset state */ - gpio_set_value(priv->gpio_nreset, 0); + gpiod_set_value(priv->reset, 1); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); }; @@ -914,7 +913,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c) { struct tas5086_private *priv; struct device *dev = &i2c->dev; - int gpio_nreset = -EINVAL; int i, ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -940,12 +938,11 @@ static int tas5086_i2c_probe(struct i2c_client *i2c) i2c_set_clientdata(i2c, priv); - gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0); - if (gpio_is_valid(gpio_nreset)) - if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) - gpio_nreset = -EINVAL; - - priv->gpio_nreset = gpio_nreset; + /* Request line asserted */ + priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(priv->reset)) + return PTR_ERR(priv->reset); + gpiod_set_consumer_name(priv->reset, "TAS5086 Reset"); ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) {