Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp501154rdb; Tue, 23 Jan 2024 06:16:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3adbQDWRMb73TIaC5UZ7AfZ9dBaQdD20Ucz32ioTjhH+nO8lT9cAfsuuuZIXT7ukqnzgs X-Received: by 2002:a05:6214:518b:b0:67f:78e9:4698 with SMTP id kl11-20020a056214518b00b0067f78e94698mr856529qvb.64.1706019407099; Tue, 23 Jan 2024 06:16:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706019407; cv=pass; d=google.com; s=arc-20160816; b=m9BxRfL4RrusL/3Z2hPH+yUkKrefljOJzm+DDBv8UKVvgbbt9/UaF8eM0pO1raiRpg zB4OHMpYzGljjn8Wbt0euazKN9gh65I+42ex4ZIkacJFL89EpMv6f3BlhoT1ZV6GRcms 2yc1M/Gk34IjhoWzAniCGF0nh48ehL6tyVJCmQHd682HTb0hWV+dNkw6vXhNOT8Op0VI P45DoTSiZ9kyesDWK38KaL6+Iuj1buvRYYt5xpCpNfcB8qOAZb1J0g974FmDWGkemKtX AUo7Ub0tMpRfxexqzOyBJ2HTrMCTOBZGwBxbXenCicraSwwa+y+FcRuwpLtEpDkhVC5h M+XQ== ARC-Message-Signature: i=2; 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=DXEXD9YlrkAaVO96VfCDJLQlDA1hpIkrGXqNCPOjb+c=; b=vHNL7nHZ+u/aUlLHeikkSHauuwZis++opW52OSw7Ufx5sdfBk1vZ+sezuXBZeT/6aW 7P8MRTBUbK3CamhvMUF9glnbVtEp09GkyY+tSkAXhDXzkt1tRzd4iumn0D1K3XT8f4KE zqOru4ey5IFALHUrVgTUM3rxD9vcCdD9cntwAPt6NrmCuG029e+2bngoAcOYrzb51U7S I2fbbYoUY6oDBqGjqW9J9vAe0aNtN50VI4yp7HqE4xY7NHbcFM/MA4BR84Z7EGczDE/P L3CMp9289/8f4ZupjAJ44hgju7ngX2L2C8dWIoD/PpQ26tEO80ntqHIa3Mau+CYcMP9H SdFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VUV7wcHc; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-35435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d27-20020a0cb2db000000b00685a29c879bsi7496256qvf.525.2024.01.23.06.16.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 06:16:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VUV7wcHc; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-35435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35435-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 431EE1C27BF0 for ; Tue, 23 Jan 2024 14:15:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17F6A605B2; Tue, 23 Jan 2024 14:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VUV7wcHc" Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 98006604B4 for ; Tue, 23 Jan 2024 14:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706019233; cv=none; b=Rf4GGhgIsWcszoQC3aFiCcQW7WnThArwyoIBqP/WQwUHRylKNk0ci4o4KanByl4q1Dj96mt/UJKKM0zatETNN55X2Jq0oxJiM+J7tuJOLNeJrUL/e1k0on4Oi/jS0iBLd1RQSBlKBFlaM+kThchA9lmH72FI293jYHmDL7IRKbg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706019233; c=relaxed/simple; bh=zd6Bmh48g7rsM+87XsXBkxNU+Zs2Yu+NMiweLujpj9I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zq2lsKfLzjTaHOxc/XJQP5T3rVkSbPIoK5Gm0ZdTcHezi6KZCVz3lmMUkzZUTz6L/ffe0o/8YAbG5i3Tlkf4Lm1QzeeFT/978szc2xjmuCQ038uAI3S469Rj1DzmM2lqxt1wRY+wIAdn/v1Q+Asse9d6aMgzF82TElb8VdyJbtY= 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=VUV7wcHc; arc=none smtp.client-ip=209.85.221.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 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-33922b66bd7so2985993f8f.2 for ; Tue, 23 Jan 2024 06:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706019229; x=1706624029; 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=VUV7wcHcc6udQnCmXkUlYNNaIXwzT45/R90OgLr6ZF9YVFWehNeLZksZ1rhDq8kso/ FtjfgzuXFdenYS9N9QONRHYyDNfqal2VXNCxhB2jM9o0kzTNFeXcnW3A/pOy9q3ZbFlY ar7UHsOxXnVOh7eyWgvj6u6Rda4l4SPQ0lawXvvnPRiZdwYX8mEqWwWbkb+klYWcQE20 cg6Huqz2d9Pd5OsWOReudJDQQ05PFk1SzbRO243TBdyiqIlNJcrKNPgtuqYA+FXsOFTA 1637JUEZlON5rtdXKTdPX8QtuqkxIJFnP7legeuUooXNIiHY8BkaAkTs4r40N9m/HpW0 TCAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706019229; x=1706624029; 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=IzK/Em8rSDK7IcMiQhjF/Z5Mt0dzIU8BxnQZjYcpDLqn0Z13NW/GElt1HdJTd7Rfmp sdZghZXzvTxoq59fntc+/1jz6wj40F8jx+7Di6LiDvRkmHlXls+DZ4PV6DJkUXT/9Hm7 KINTXo9nn8dr7njiGU7jMoLqqkFPOgigA+gfdmX+TWnP/OMJeOAD2RKLfMGTXLTHswTR zhNfBIYhcATdE7sX0Y7YtaRNe+CUIPAm8LTTSjqdK3vjOI3pmg6unBRXvaqo/MyHJjkY WXnbBe3XKkJ2vfeQJaq7jAamB/YYWUcVTde/LsVkOuJ1qh9Nmw+W+kj/6IHdhzdGOiSy rQCg== X-Gm-Message-State: AOJu0YzyxzqfuUltarSuvbfxCGa1bhd1r4elLUloBUGjF9TcpKtuittN RCCRIWRnfalz2zcDNJf0NCqgpK1ig7Id9sY0wkYXsX5nscwf9OswdQHBleog4U8= X-Received: by 2002:a5d:5086:0:b0:337:c5fb:c84f with SMTP id a6-20020a5d5086000000b00337c5fbc84fmr3473681wrt.33.1706019229029; Tue, 23 Jan 2024 06:13:49 -0800 (PST) Received: from krzk-bin.. ([178.197.215.66]) by smtp.gmail.com with ESMTPSA id r8-20020adfe688000000b00337d97338b0sm12132298wrm.76.2024.01.23.06.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 06:13:48 -0800 (PST) From: Krzysztof Kozlowski To: Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Banajit Goswami , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , 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-pm@vger.kernel.org Cc: Krzysztof Kozlowski , Bartosz Golaszewski , Sean Anderson Subject: [PATCH v4 6/6] ASoC: codecs: wsa884x: Allow sharing reset GPIO Date: Tue, 23 Jan 2024 15:13:11 +0100 Message-Id: <20240123141311.220505-7-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240123141311.220505-1-krzysztof.kozlowski@linaro.org> References: <20240123141311.220505-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