Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2412121rdd; Fri, 12 Jan 2024 08:37:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMU/VQi32adHnBGW2nuLr5o324F6VP34tv5SEkJBFQBMc+fUtFCAQ+U6afYAvnauAiZtco X-Received: by 2002:a05:6358:5d8b:b0:175:7892:5d31 with SMTP id s11-20020a0563585d8b00b0017578925d31mr1793372rwm.30.1705077476006; Fri, 12 Jan 2024 08:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705077475; cv=none; d=google.com; s=arc-20160816; b=xS2xbqsexCSAETLHOp0+B2TkxHvMdSSC0mlWqTLJls5OnWCZ3ke05qx7NCV7WfZJRy jAzXO/kOjD0flivuzoP6jvSN2so7JpMyHFRKzNMwiIukY5Erk2r7pvJP57bVvYRlcFM2 ihbo18GwI+CF6nTYvhkRLdUeCDluGRbkSk1hb0xjbpz7PpB9WGH+UOxucE+kn2EXWiBh IxiWVifwP9wbj/9Jl+rAMMro2mf4eVbkuceXN2m1EluxiEEg9PePk1XVCMLR+pCzM73x EaL09mPVGif5GfGVIzIzwNU9rJHrWB6aQeiisV1Wm09FofqjFAmV+AByINpGWfee8QeU Y41w== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24866-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p16-20020a637410000000b005b86142ee56si3260498pgc.277.2024.01.12.08.37.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:37:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24866-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24866-linux.lists.archive=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 60300B2282F for ; Fri, 12 Jan 2024 16:37:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7385E7690B; Fri, 12 Jan 2024 16:36:32 +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 Content-Transfer-Encoding: 8bit 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; -- 2.34.1