From patchwork Wed Nov 16 05:38:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 20728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3104915wru; Tue, 15 Nov 2022 21:40:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf57/ccBcnlhWeil1gr/m/YIBkb2GnCV0JDDSybdVVOfW0TgRYwH6EMB+yxmLQ4TOxuocQbU X-Received: by 2002:a17:90b:104f:b0:215:d767:4863 with SMTP id gq15-20020a17090b104f00b00215d7674863mr1967136pjb.233.1668577215224; Tue, 15 Nov 2022 21:40:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668577215; cv=none; d=google.com; s=arc-20160816; b=SODrtg7jT6ThROe2AXC/PanMCLCTIDD5mT5Oa3BTW3VZgmyHeM5mPNPwlBKAfge1Zx Tp1MLc224Lj036ZjBUeg+Bv94sWcnCXKdRiYMrHA9K3cJkvEXudd+y490UHCOr7LDUW9 KbcXfSMj/dIVk56kwXUFsISRWPLJxafTTxDykwUCzSLD1DnG8ygJbZggdKmFo/5KoDAy Y1ToBl4GIptccwvgzkG9WYVHfWMj90yeTpoh7VMJ79nH5a/zYdmu3QmqOPm0ubu0mH7J 2vnZ3uzHI/5OpupiJVFPsC8ea1fUha3UPRmDntmx2wKFmgvaHBAPx5VZSGfhxUYA1jdk 9ocg== 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=yEUFbdVypOtyoH064OjwzyJ2ZvEG5EnyjXzOQihafjo=; b=Ls6BaPOUC/sxQ+KGFof1pjaZzHO7hdZ2Sr9sDDYnNFkwl7qVkN2tHifBcNlr7pqkL6 oMb8/q+ZrJfB4AXgqvnqMHRGJ2Wg0YZEYTdZsllx4TsOAbrdR/mrnLq3KdVWBAFsRc7t A0JlJZZBAQezIvsvXjxTZnPgqbmOcFb96Ep5o/B1AHSOppGsy+MQLyXuxgBGmZDBcLu0 Y6h6dG4qoyZjmyTBAXOn68H7t/g8joDz/yqdXajXD6IJ+SKDzJ8I868GEVwx/f8CnRPg 6Wf5G46a76zHbqON/y5CZ7xXYFQKsv0IG54ct5W7BnrDW00sQt49XFRWYsC3HrW8LuSk z/Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="b5/F1lcF"; 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 n9-20020a1709026a8900b001870c4c2722si13127054plk.299.2022.11.15.21.40.01; Tue, 15 Nov 2022 21:40:15 -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="b5/F1lcF"; 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 S231834AbiKPFim (ORCPT + 99 others); Wed, 16 Nov 2022 00:38:42 -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 S231659AbiKPFi1 (ORCPT ); Wed, 16 Nov 2022 00:38:27 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785C138C for ; Tue, 15 Nov 2022 21:38:24 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id k7so15447672pll.6 for ; Tue, 15 Nov 2022 21:38:24 -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=yEUFbdVypOtyoH064OjwzyJ2ZvEG5EnyjXzOQihafjo=; b=b5/F1lcFrypyG5b3jZd+tIci2jDxqkerWT178BAUcRicXkw95dBFxRknwrsZMS5Qud MlaVJs2wquHY4clWTApR5ZADFFvP/rBfGGjMXoynix7py8419JTe18a4QU3ldzp2e42Q snQtuSlystcc2T7vWhP4LZ5Id/pkAsturPEbM21KtqDB66Q5yrGIVhQE5h0/XF9atu2b /viTKRsIgxeAFGKq2MKvzP3a5zDdh5uIv8BnGJlIt66+NkLlvfgaDCbbJZ3LBxTIGUrx Q4M4eXC+8RU/oLEVmQgsyKM6/CmwkPOoVFpU+cxPL+MfceYAsUS/byeTNadVgiOQVpr9 1OWA== 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=yEUFbdVypOtyoH064OjwzyJ2ZvEG5EnyjXzOQihafjo=; b=QOp25vNCzHwh63B4JI0KbCn+P9Pp32+UnFaD0U56L8KLc643noldCKGQ40dYFwdRIm O22Wy8TfSNlLhIpRKHOaOOOEMLkN7Yyh3d3cmO5oHJtTtNu/89cJl5169UylfAMqhng2 eqvk5pLTGLThG9lDOobhuPYIs2Y2o83kE9Ueiv5DLXaNlpaK+Fdre46obB5Q8lQe/fSB IZmQKnNZ+/yNU0MIy7G/HVyUU+XGx+EmBXsvpML8G8V2QiRlxn5CIUbWogWN+2Yfw3b+ /UwSN2tYVNQkH/9Ns6nSwOUn3PjQQqet7ET8pv6vUqiggwT9Bq5V2G6fovhKcYfHBaQl yoGA== X-Gm-Message-State: ANoB5pnPfGZ0ogiUIOTArpZaNa/C6Vylp8zyJi1Sv2GZHTNrvjhWvniK CuS3gAwHX9EaUzmdEkZrh+q47BW8x6M= X-Received: by 2002:a17:902:e846:b0:186:94b8:5980 with SMTP id t6-20020a170902e84600b0018694b85980mr7764409plg.113.1668577103864; Tue, 15 Nov 2022 21:38:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 21:38:23 -0800 (PST) From: Dmitry Torokhov To: Mark Brown , Liam Girdwood Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 02/11] ASoC: max98373: switch to using gpiod API Date: Tue, 15 Nov 2022 21:38:08 -0800 Message-Id: <20221116053817.2929810-2-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?1749630022272864263?= X-GMAIL-MSGID: =?utf-8?q?1749630022272864263?= 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/max98373-i2c.c | 39 +++++++++++++++++++-------------- sound/soc/codecs/max98373.c | 18 --------------- sound/soc/codecs/max98373.h | 1 - 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/max98373-i2c.c b/sound/soc/codecs/max98373-i2c.c index 3e04c7f0cce4..969cdca83bc1 100644 --- a/sound/soc/codecs/max98373-i2c.c +++ b/sound/soc/codecs/max98373-i2c.c @@ -3,12 +3,12 @@ #include #include -#include +#include +#include #include #include #include #include -#include #include #include #include @@ -520,14 +520,13 @@ static int max98373_i2c_probe(struct i2c_client *i2c) int ret = 0; int reg = 0; int i; - struct max98373_priv *max98373 = NULL; + struct max98373_priv *max98373; + struct gpio_desc *reset_gpio; max98373 = devm_kzalloc(&i2c->dev, sizeof(*max98373), GFP_KERNEL); + if (!max98373) + return -ENOMEM; - if (!max98373) { - ret = -ENOMEM; - return ret; - } i2c_set_clientdata(i2c, max98373); /* update interleave mode info */ @@ -557,17 +556,23 @@ static int max98373_i2c_probe(struct i2c_client *i2c) max98373_slot_config(&i2c->dev, max98373); /* Power on device */ - if (gpio_is_valid(max98373->reset_gpio)) { - ret = devm_gpio_request(&i2c->dev, max98373->reset_gpio, - "MAX98373_RESET"); - if (ret) { - dev_err(&i2c->dev, "%s: Failed to request gpio %d\n", - __func__, max98373->reset_gpio); - return -EINVAL; - } - gpio_direction_output(max98373->reset_gpio, 0); + /* Acquire and assert reset line */ + reset_gpio = devm_gpiod_get_optional(&i2c->dev, "maxim,reset", + GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(reset_gpio); + if (ret) { + dev_err(&i2c->dev, "%s: Failed to request reset gpio: %d\n", + __func__, ret); + return ret; + } + + gpiod_set_consumer_name(reset_gpio, "MAX98373_RESET"); + + if (reset_gpio) { + /* Keep line asserted to reset device */ msleep(50); - gpio_direction_output(max98373->reset_gpio, 1); + /* Deassert reset line */ + gpiod_set_value_cansleep(reset_gpio, 0); msleep(20); } diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index f90a6a7ba83b..401546c1084e 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -12,9 +12,6 @@ #include #include #include -#include -#include -#include #include #include "max98373.h" @@ -478,21 +475,6 @@ void max98373_slot_config(struct device *dev, max98373->i_slot = value & 0xF; else max98373->i_slot = 1; - if (dev->of_node) { - max98373->reset_gpio = of_get_named_gpio(dev->of_node, - "maxim,reset-gpio", 0); - if (!gpio_is_valid(max98373->reset_gpio)) { - dev_err(dev, "Looking up %s property in node %s failed %d\n", - "maxim,reset-gpio", dev->of_node->full_name, - max98373->reset_gpio); - } else { - dev_dbg(dev, "maxim,reset-gpio=%d", - max98373->reset_gpio); - } - } else { - /* this makes reset_gpio as invalid */ - max98373->reset_gpio = -1; - } if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value)) max98373->spkfb_slot = value & 0xF; diff --git a/sound/soc/codecs/max98373.h b/sound/soc/codecs/max98373.h index e1810b3b1620..7b259789e1be 100644 --- a/sound/soc/codecs/max98373.h +++ b/sound/soc/codecs/max98373.h @@ -213,7 +213,6 @@ struct max98373_cache { struct max98373_priv { struct regmap *regmap; - int reset_gpio; unsigned int v_slot; unsigned int i_slot; unsigned int spkfb_slot;