From patchwork Wed Nov 16 05:38:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3104780wru; Tue, 15 Nov 2022 21:39:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ZMdIRL0OhnrffKY2sxOPx0UvPsFY0oEnBpc5NaiHugX7+clyVCYGgmWadj5UEghexaKD9 X-Received: by 2002:a62:e412:0:b0:56d:a1fc:7000 with SMTP id r18-20020a62e412000000b0056da1fc7000mr21322016pfh.35.1668577184884; Tue, 15 Nov 2022 21:39:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668577184; cv=none; d=google.com; s=arc-20160816; b=fikOxDQc/7O/e0mjNkmwV0P1YA9zDjnCqK9n7VUhoUoft0AzWgNLqGyJZCyjTo1yOS qUevx8d58SUM3gTLKedWb7aUeZVYzhC5XTMEHviWfmdb6Oy6uOPBcpM1Qw8+BQrdY5iw WlKLJz0AJllGUN0PIk6OVbDOlnCsIdZ1UMxJh74aFYiYfUPe07ORBuvvik2EQph/V0x3 VaEbwCNxz6zoKAxfiEsxLMogG1r0MCBRsYQbTTyCDdZ1zbHHKhvGgQbslUcQUhElDl1C CzVyZj9r3ZZut62ZQHyWLJkjLgAUe4uMrS7Lmhnqig6Roz1612RNIgbJHbQOzllxWsq2 tgQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r01ypcYo+LtD9fhypz7U4KPnsRobXTNuGoo4vyNF/vc=; b=xdaQ7B13p0/j65OCa+aznBSmPd8Cw8C9jsJR6ByZjDbkDgys9iD6OjGpxJWvnvEVaF W3am3+sve03HCL+/uCRze2uwbi58zrVXPMXitjD78hqeh777gQVIS6N75DNVYy2hVM/a C5YgetPPyVWO1veMRu1sHetGCZNfdcwu4UCsGMTwNAmYhopAdWR58qN8MBGsHeQULDjx Sq5RCZQSDmXQhIVWM6tYCTX6kcfesFCbywUrD5WIaeObVm/gzYSWH2DhFjvmk7gC1nKi J1o5KWjn8bXjZUJiPBLxbsOvpO+igiwiGntV1oJblscgVne8p9jhCKtlj6x3k6Uer+LK rcig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Hdfcb6sJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r191-20020a632bc8000000b00476ceab2adcsi3093233pgr.448.2022.11.15.21.39.31; Tue, 15 Nov 2022 21:39:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Hdfcb6sJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbiKPFiu (ORCPT + 99 others); Wed, 16 Nov 2022 00:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbiKPFid (ORCPT ); Wed, 16 Nov 2022 00:38:33 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 393FA100B for ; Tue, 15 Nov 2022 21:38:30 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id c2so15427937plz.11 for ; Tue, 15 Nov 2022 21:38:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r01ypcYo+LtD9fhypz7U4KPnsRobXTNuGoo4vyNF/vc=; b=Hdfcb6sJtZK0d4iSfc/c+K5+0PYEPfETP19Nve63ggNiKTbV6nRrj4Vb4GfGLphU77 JL9fPjFGZN+xuLVLnY9F8MtLwtXD10i7AxQh0kdt+xCvJCzv0IxzCLnwB3CiEO0++qQ8 cvbX71x5YS4YX4MOl3W89daY6QxvCAdYtGF2kIJTH8YFYBTDBvWd+yEE59Z1oqf5Mgsu MswmnkG/O1rW5lzeLp9bQUxKADGJ05ftzgyMVFqGQ75+4mK2VU9l4bxqOZ08fz/LaIAO rXeBGl4jU92zG9ChdWwmYbEGZZtcxAdlkg4m7CV+U61qWVVU26rLYvH2PbRXwv+fCFMV dacQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r01ypcYo+LtD9fhypz7U4KPnsRobXTNuGoo4vyNF/vc=; b=V4NOJNrxECk87eZ9Wm9hdgy2+dGEke6DaxeVSbI2WgHVhsuwQAdQztj2iEytnlQH2W 4WKoscdGxkAA6HXfEnF8UftEdw//9Y2dWZsyxorGdTfGpWbFKk0ShRrWHaFziRU4MW5V K3GNH3WxkLjAE+I5jeLaD6tescLjxZJ7kTLngI99CnAb9ZvfZWUxEt3mbDMSIZ1xjb6L va3pFBaHKoOFEt1+XxzaL8lbPU186v2CwpbU2d/4nXslQXW81YtX/q9AKH0wc5btfBIL QP/1ezxkDGBXzQcyRxhYxGi7/FYfMEWpq0EiTlvrPa1B4K+Ulr2e7HBEGqBBfisVZVE8 OvUw== X-Gm-Message-State: ANoB5pmAx+xKG8o0XGDRrGAJlOAaXp0/5yh9cHR8N/S6qL/ygRuWsz6t z5pYGqFDP9oxQPgZIV6jZA0= X-Received: by 2002:a17:903:2789:b0:186:9b19:1dbb with SMTP id jw9-20020a170903278900b001869b191dbbmr7643358plb.59.1668577109573; Tue, 15 Nov 2022 21:38:29 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:2d36:e9a0:170b:669f]) by smtp.gmail.com with ESMTPSA id ik13-20020a170902ab0d00b0017834a6966csm10881038plb.176.2022.11.15.21.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 21:38:28 -0800 (PST) From: Dmitry Torokhov To: Mark Brown , Liam Girdwood Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 05/11] ASoC: tpa6130a2: switch to using gpiod API Date: Tue, 15 Nov 2022 21:38:11 -0800 Message-Id: <20221116053817.2929810-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221116053817.2929810-1-dmitry.torokhov@gmail.com> References: <20221116053817.2929810-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749629990175240909?= X-GMAIL-MSGID: =?utf-8?q?1749629990175240909?= Switch the driver from legacy gpio API that is deprecated to the newer gpiod API that respects line polarities described in ACPI/DT. Signed-off-by: Dmitry Torokhov --- sound/soc/codecs/tpa6130a2.c | 42 +++++++++++++++--------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 5f00bfc32917..696a27b472aa 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -9,15 +9,15 @@ #include #include +#include #include #include -#include +#include #include #include #include #include #include -#include #include #include "tpa6130a2.h" @@ -32,7 +32,7 @@ struct tpa6130a2_data { struct device *dev; struct regmap *regmap; struct regulator *supply; - int power_gpio; + struct gpio_desc *power_gpio; enum tpa_model id; }; @@ -48,8 +48,8 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable) return ret; } /* Power on */ - if (data->power_gpio >= 0) - gpio_set_value(data->power_gpio, 1); + if (data->power_gpio) + gpiod_set_value(data->power_gpio, 1); /* Sync registers */ regcache_cache_only(data->regmap, false); @@ -58,8 +58,8 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable) dev_err(data->dev, "Failed to sync registers: %d\n", ret); regcache_cache_only(data->regmap, true); - if (data->power_gpio >= 0) - gpio_set_value(data->power_gpio, 0); + if (data->power_gpio) + gpiod_set_value(data->power_gpio, 0); ret2 = regulator_disable(data->supply); if (ret2 != 0) dev_err(data->dev, @@ -75,8 +75,8 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable) regcache_cache_only(data->regmap, true); /* Power off */ - if (data->power_gpio >= 0) - gpio_set_value(data->power_gpio, 0); + if (data->power_gpio) + gpiod_set_value(data->power_gpio, 0); ret = regulator_disable(data->supply); if (ret != 0) { @@ -224,37 +224,29 @@ static int tpa6130a2_probe(struct i2c_client *client) unsigned int version; int ret; - if (!dev->of_node) - return -ENODEV; - data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; + i2c_set_clientdata(client, data); data->dev = dev; data->regmap = devm_regmap_init_i2c(client, &tpa6130a2_regmap_config); if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); - data->power_gpio = of_get_named_gpio(dev->of_node, "power-gpio", 0); + data->power_gpio = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); + ret = PTR_ERR_OR_ZERO(data->power_gpio); + if (ret) { + dev_err(dev, "Failed to request power GPIO: %d\n", ret); + return ret; + } - i2c_set_clientdata(client, data); + gpiod_set_consumer_name(data->power_gpio, "tpa6130a2 enable"); id = i2c_match_id(tpa6130a2_id, client); data->id = id->driver_data; - if (data->power_gpio >= 0) { - ret = devm_gpio_request(dev, data->power_gpio, - "tpa6130a2 enable"); - if (ret < 0) { - dev_err(dev, "Failed to request power GPIO (%d)\n", - data->power_gpio); - return ret; - } - gpio_direction_output(data->power_gpio, 0); - } - switch (data->id) { default: dev_warn(dev, "Unknown TPA model (%d). Assuming 6130A2\n",