From patchwork Fri Jan 12 16:36:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 187790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp295036dyc; Fri, 12 Jan 2024 08:38:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjUyIgfU1sC8v3MZtjqbectWf/9QrEjycqOlB3IzqTPWnOk0X22mqqi5KVWi+GT0Ta5cIh X-Received: by 2002:a17:90a:8a11:b0:28e:1212:3dcf with SMTP id w17-20020a17090a8a1100b0028e12123dcfmr711086pjn.68.1705077500961; Fri, 12 Jan 2024 08:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705077500; cv=none; d=google.com; s=arc-20160816; b=qQ5XyGhDZuTYbiRZSTmimg8aU49hC7fN5ap4lHAcTVeUayxLzuQmZAR+Tka4U0sxP7 BWRxOyjheBU0umfDSWF3b5sJ3veq7g4OC4hOfdgk3yJ4hT/gud/NJyOnqNkNnUIz4CQm JEaPaNx0HvDk6JMhcPoKR1wDHdWjxWouPbhWD0ZcILQGlDMzq5FhlInm1ZKt9zob5OEd 6aV+ksfnZjc3UZYD0har3Czo7Q0+wpETyW6iOdRxQXfnuqLet6FeetjJPratzTZUnIlr ruCk0rlR9IuUnfgqr9ztmzvOGUI6Gsdd+jAf1cxVEvKNr6oTJvuJP1nZexyZCuNc3HmK 6YQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qJ0gjfKMOfp9CH0Fl1AfdBLtnAI1t5WhWrFWLERW/vA=; fh=+9Max/V/7cjj8RZEj+C1lXQLChlj/u+Ka2QetC5y70Q=; b=qVbC3YSu4w4lFWJBz1lDZJwDYBjKoYBmNC/Ftoa4PxIF4P1AbL8ZbDKZqOTkWlm9PJ QXurP4ti0dDbTPsooTg4gHPJZ8y/EqagaLs4YdtI/T736kgr2HP8kP7Y8A1B1F47Rytm FGGXeg+odF/EoRNrsXeiGNcXYwDtZpjBXegRE7JKKZPPL+uigPamNnNvySbE9ygOtYsk 3hQ+Gh5fGe44uBwdtd8O0xuFNt42cBXMdH6lN5Lcu9hpHFO36z6wpXohW3CIuv/EVGmp XFQyoRy5JMIRrZB2OUjS96l3AN6CcYtLeCpw4beHRJGEmeS4adi/BWtWM4JR1oV2N8iM WIVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=crFy3OhX; spf=pass (google.com: domain of linux-kernel+bounces-24866-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24866-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id la6-20020a170902fa0600b001d5a61ff46fsi1360773plb.505.2024.01.12.08.38.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:38:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24866-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=crFy3OhX; spf=pass (google.com: domain of linux-kernel+bounces-24866-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24866-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 09A85B22C7E for ; Fri, 12 Jan 2024 16:38:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94D637FBAB; Fri, 12 Jan 2024 16:36:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="crFy3OhX" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 BE14077F24 for ; Fri, 12 Jan 2024 16:36:29 +0000 (UTC) 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 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40e62e6e3b0so14029505e9.2 for ; Fri, 12 Jan 2024 08:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705077388; x=1705682188; darn=vger.kernel.org; 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=qJ0gjfKMOfp9CH0Fl1AfdBLtnAI1t5WhWrFWLERW/vA=; b=crFy3OhX9eZtbss3gYEfpxA4SPcDBc2AGE5zY0Z4ap2j4Amtc9vH+ZJ2wwyrQ+y0fc sD2hwMPhVoZpQf0207k7tJJeugRSKYcJs6IcLTaCgF44CF38rZVSjyA8RG2HR68HPpNG uR3z9RIIw9ylGg+QB5RLNh17hnTT4UP7HGINuezoII0pAwISkhf7HDFr4oTxrFHGAsYz 0E/ZONyYbgctJKUS8dmCeRi+Xl1OrutehtQf+rWfR1gQEB3CaYZGfH+1sqIxzsJgMgeb sdqKv6nLX28pmyNqhyXS7oFGwOj5cXLvDFpV0Nvz0o0tekNwqhVVDW01r7XkDYtY0nRV nHRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705077388; x=1705682188; 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=qJ0gjfKMOfp9CH0Fl1AfdBLtnAI1t5WhWrFWLERW/vA=; b=Uwcz4KIncTl6FxXLlpqn6kq6DVHYyhE5w953fvmtXhR8kwB9Jhk/ofy9+3f3AQuBjN cWUkLTMYr6lgfZ4YaouzKAkCBaTtX3+FyeA6OEvlUaeMhutZ4Lz3td4lBaZ3iTaxtmf4 GybKFEFZ51c8U3w+w5PeSGCXumq8MFcz6xDmzyDzoh1AlzfOX+oHigPPxT+YpCIxkjYG FMi2u2jL4aNXCR0xuOjgoPUEmOHVLNhm9Ni4g+0tbCu7yBTl5OAzzLUI6fjUz9CGTeYp +QECPbDSzo8GV8BXrkpDtbu6FalTQj8eOtLJ2LQQ3srlpp5JtEwGv0zjOK7CB945+SNB xJuQ== X-Gm-Message-State: AOJu0YwkX+CGMH0y9/imUWq0oHcE2uzIYIfQJoPjlHtrv967TyR4eseg cKnP0tV+ucWDPUW8zzYEn2I1YnDCONzwSA== X-Received: by 2002:a05:600c:181b:b0:40e:437c:7db2 with SMTP id n27-20020a05600c181b00b0040e437c7db2mr665698wmp.211.1705077387970; Fri, 12 Jan 2024 08:36:27 -0800 (PST) Received: from krzk-bin.. ([178.197.223.112]) by smtp.gmail.com with ESMTPSA id bd16-20020a05600c1f1000b0040e5a93ae53sm6573195wmb.22.2024.01.12.08.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:36:27 -0800 (PST) From: Krzysztof Kozlowski To: Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peter Rosin , Philipp Zabel , Jaroslav Kysela , Takashi Iwai , linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Krzysztof Kozlowski , Bartosz Golaszewski , Sean Anderson Subject: [PATCH v3 4/5] ASoC: codecs: wsa884x: Allow sharing reset GPIO Date: Fri, 12 Jan 2024 17:36:07 +0100 Message-Id: <20240112163608.528453-5-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240112163608.528453-1-krzysztof.kozlowski@linaro.org> References: <20240112163608.528453-1-krzysztof.kozlowski@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787903345791749427 X-GMAIL-MSGID: 1787903345791749427 On some boards with multiple WSA8840/WSA8845 speakers, the reset (shutdown) GPIO is shared between two speakers. Use the reset controller framework and its "reset-gpio" driver to handle this case. This allows bring-up and proper handling of all WSA884x speakers on X1E80100-CRD board. Cc: Bartosz Golaszewski Cc: Sean Anderson Signed-off-by: Krzysztof Kozlowski --- If previous patches are fine, then this commit is independent and could be taken via ASoC. --- sound/soc/codecs/wsa884x.c | 53 +++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c index f2653df84e4a..a9767ef0e39d 100644 --- a/sound/soc/codecs/wsa884x.c +++ b/sound/soc/codecs/wsa884x.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -699,6 +700,7 @@ struct wsa884x_priv { struct sdw_stream_runtime *sruntime; struct sdw_port_config port_config[WSA884X_MAX_SWR_PORTS]; struct gpio_desc *sd_n; + struct reset_control *sd_reset; bool port_prepared[WSA884X_MAX_SWR_PORTS]; bool port_enable[WSA884X_MAX_SWR_PORTS]; unsigned int variant; @@ -1799,9 +1801,22 @@ static struct snd_soc_dai_driver wsa884x_dais[] = { }, }; -static void wsa884x_gpio_powerdown(void *data) +static void wsa884x_reset_powerdown(void *data) { - gpiod_direction_output(data, 1); + struct wsa884x_priv *wsa884x = data; + + if (wsa884x->sd_reset) + reset_control_assert(wsa884x->sd_reset); + else + gpiod_direction_output(wsa884x->sd_n, 1); +} + +static void wsa884x_reset_deassert(struct wsa884x_priv *wsa884x) +{ + if (wsa884x->sd_reset) + reset_control_deassert(wsa884x->sd_reset); + else + gpiod_direction_output(wsa884x->sd_n, 0); } static void wsa884x_regulator_disable(void *data) @@ -1809,6 +1824,27 @@ static void wsa884x_regulator_disable(void *data) regulator_bulk_disable(WSA884X_SUPPLIES_NUM, data); } +static int wsa884x_get_reset(struct device *dev, struct wsa884x_priv *wsa884x) +{ + wsa884x->sd_reset = devm_reset_control_get_optional_shared(dev, NULL); + if (IS_ERR(wsa884x->sd_reset)) + return dev_err_probe(dev, PTR_ERR(wsa884x->sd_reset), + "Failed to get reset\n"); + else if (wsa884x->sd_reset) + return 0; + /* + * else: NULL, so use the backwards compatible way for powerdown-gpios, + * which does not handle sharing GPIO properly. + */ + wsa884x->sd_n = devm_gpiod_get_optional(dev, "powerdown", + GPIOD_OUT_HIGH); + if (IS_ERR(wsa884x->sd_n)) + return dev_err_probe(dev, PTR_ERR(wsa884x->sd_n), + "Shutdown Control GPIO not found\n"); + + return 0; +} + static int wsa884x_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) { @@ -1838,11 +1874,9 @@ static int wsa884x_probe(struct sdw_slave *pdev, if (ret) return ret; - wsa884x->sd_n = devm_gpiod_get_optional(dev, "powerdown", - GPIOD_OUT_HIGH); - if (IS_ERR(wsa884x->sd_n)) - return dev_err_probe(dev, PTR_ERR(wsa884x->sd_n), - "Shutdown Control GPIO not found\n"); + ret = wsa884x_get_reset(dev, wsa884x); + if (ret) + return ret; dev_set_drvdata(dev, wsa884x); wsa884x->slave = pdev; @@ -1858,9 +1892,8 @@ static int wsa884x_probe(struct sdw_slave *pdev, pdev->prop.sink_dpn_prop = wsa884x_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; - /* Bring out of reset */ - gpiod_direction_output(wsa884x->sd_n, 0); - ret = devm_add_action_or_reset(dev, wsa884x_gpio_powerdown, wsa884x->sd_n); + wsa884x_reset_deassert(wsa884x); + ret = devm_add_action_or_reset(dev, wsa884x_reset_powerdown, wsa884x); if (ret) return ret;