Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2411408rdd; Fri, 12 Jan 2024 08:36:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/8YfZQmhke04sDH4yo3YqCCjSkH7GhnNk7AXp2xNv59acxHaNdfNKf85XyYbYuY763RPg X-Received: by 2002:a05:651c:234:b0:2cd:7039:e281 with SMTP id z20-20020a05651c023400b002cd7039e281mr961039ljn.8.1705077397828; Fri, 12 Jan 2024 08:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705077397; cv=none; d=google.com; s=arc-20160816; b=dKoXynRObhmxEcOR0rSinZxMW7JqvyEcdyrCyheWE3GBYS4lGOMMsg+Denle4NcUrW BVKQC7Z3YjKzVp6eiJpfGcld66zViNhImTA9egmjzVq4DlBo3HRvyJ8hxnsIka+4NeYq QyYplZvRVAu713chQq3N1cPkMJXFT+LGzGEq6WN5sgk0yZh9Qn/kGFIkdCDg0PnYsmH3 LJbgY/tIUAzMT7dX2M2oxBa0F5TZcQB45/a3livPsMt76dex6+OVy/Xb3HXP97uh38Aw hSwRnzmym616f1a9GccISqeFU24vfHHbDS1FiFP0NSB5NLnK0WFyVUCQ9g4otpkYQ5U4 ZwSg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=Hn+LSFeIE6cgmvG+tEU3s1iTtjUkavz0Czg37/bP5gM=; fh=N0g6NNwEgsB2HPA8hUuIqtt2mCu+B6W+5g16SAegov0=; b=HGDvU55xBcAkcWk2TPBJKB4BmZQMp3IygCMEPLTHgnz4/6hXBlzrR9Yp8r8ZABiATv CpBQlFSLYJSiub83Fc/MQ/RmNhKxIZjskRFMg1cY8Ozc9WE2BFbRwH4Csu+3imBIX7nJ ysSvQNLmYukkeL+Z06AD2R4+Z8JT/PG/e3BvR5yo/VKfqwjuywy54Pu1SJCqkn7ptz6/ vuJsU5/RXXyhOW2PdPXsn/yO6P0lJRUN+E7eNmvuiKunL+s4BeSIv1s0B7CiuL34NoRA E02gQmhpiCTWmclE7r+EBHw7WNbr5Nxr+F6BORmPqnaVGHOAM808TacGKMR3YQ203W/t Bsqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DhHJs56x; spf=pass (google.com: domain of linux-kernel+bounces-24862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g7-20020a056402320700b00558cb8f8395si673229eda.16.2024.01.12.08.36.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:36:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DhHJs56x; spf=pass (google.com: domain of linux-kernel+bounces-24862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24862-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4FAE91F2260E for ; Fri, 12 Jan 2024 16:36:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7246777624; Fri, 12 Jan 2024 16:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DhHJs56x" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 605877762C for ; Fri, 12 Jan 2024 16:36:22 +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-f54.google.com with SMTP id 5b1f17b1804b1-40e60e135a7so16362935e9.0 for ; Fri, 12 Jan 2024 08:36:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705077380; x=1705682180; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Hn+LSFeIE6cgmvG+tEU3s1iTtjUkavz0Czg37/bP5gM=; b=DhHJs56xoMdthQqCaQz5JO0J50qLvVDNZTmB3U+ObnqvxumKs4M4fE+rgeZ52iQviY wR3q6U5ib6jxSJGix+DeSLcoKTj6g5ad1/NsRWhxpyzLN/p7UX570v/Ml9zyDArBO+ie LJ7Rm2tEeejyFfPNmyaddGvU03kpNLVXqESY2kcnn83XYRRHyOQp1ZbaGOkBxQ0LGY6J a1h6ISFaPjywPvJ3uDrO0ZG2JNeHBS4vCvDIdqivOZm1XeCLmXdoawvNY19aXcK5Ppu8 rEfv28e0jc9rRqr8ue2HYevzKi4Ci7JlSY6rIrrJxqUsvF14NGbvV6uUFPSdiYSbUmVu 4inQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705077380; x=1705682180; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Hn+LSFeIE6cgmvG+tEU3s1iTtjUkavz0Czg37/bP5gM=; b=X9Wt6ZKM/OQcGxnJ2ZZzAmmEKRtyTdytxqGuMx87F3mnmj+PtjLpiGbp6tbGVv6wUO gll5XRJDaDjfdorKmDk7M1yDJSrKVVzdcXlxjHNcHJ10FxG2vv4Ss0yc5XKyLvYy7zAT nPP4XXD1ISQ7Iyz7tZIF0NM0PTfJiMmM1V+A/Dua9MCzLbyRkq3/Nt4ZnwNmldXTyLFB CjNyXpR3xh3VL0HeuM785fAqPGAD5N+6swynXMLqjeGVTdZeb78+WW6ZEVQbPrjJjvVw aNttFI0P0fS6Nz6PO5OcaRoSTL/qDAX0TKE22UYiCkq/+iJxh7DSoxoE4HrkUUjwFXcR WaDg== X-Gm-Message-State: AOJu0YzzhG7IlYt5ur17sLoU75V+quiFgqh/m5okLozUKrmBlCzB/UX+ sIDWDm0DR3hO/2az3oNIZHbCdhYHSCiNPg== X-Received: by 2002:a05:600c:1c92:b0:40e:532c:7cb1 with SMTP id k18-20020a05600c1c9200b0040e532c7cb1mr1056935wms.125.1705077380618; Fri, 12 Jan 2024 08:36:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 08:36:20 -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 , Chris Packham , Bartosz Golaszewski , Sean Anderson Subject: [PATCH v3 0/5] reset: gpio: ASoC: shared GPIO resets Date: Fri, 12 Jan 2024 17:36:03 +0100 Message-Id: <20240112163608.528453-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi, Changes in v3 ============= 1. reset-gpio.c: - Add reset_gpio_of_xlate (Philipp). - reset_gpio_of_args_put->reset_gpio_of_node_put (Philipp). - Expect via platdata of_phandle_args. - Do not call device_set_node() to attach itself to reset consumer (the final device). This was questionable idea in the first place. Bartosz suggested to use GPIO_LOOKUP to solve this. 2. reset/core.c, implement Philipp's feedback. That was a lot: - Commit msg fixes. - Add new platform_device earlier, when reset core found "reset-gpios" but not "resets". - Do not overwrite of_phandle_args. - Expect matching .of_reset_n_cells. - Pass of_phandle_args as platdata to reset-gpio. - Rename reset_gpio_device->reset_gpio_lookup and others. Fix few comments and code cleanup pointed on review. - From Bartosz: Use GPIO_LOOKUP and a lot of cleanup.h in __reset_add_reset_gpio_lookup(). 3. Include here Chris' patch: "i2c: muxes: pca954x: Allow sharing reset GPIO". Changes in v2 ============= 1. wsa884x.c: add missing return in wsa884x_get_reset(), correct comment. 2. qcom,wsa8840.yaml: fix oneOf syntax. 3. reset-gpio.c: - Fix smatch warning on platdata evaluation. - Parse GPIO args and store them in rc.of_args. 4. reset/core.c: - Revise approach based on Bartosz comments: parse the reset-gpios phandle with arguments, do not use deprecated API and do not rely on gpio_desc pointer. - Create a list of instantiated platform devices to avoid any duplicates. - After creating reset-gpio platform device, try to get new reset controller or return EPROBE_DEFER. - Drop the "cookie" member and add new "of_args" to "struct reset_controller_dev". Description =========== We have at least few cases where hardware engineers decided to use one powerdown/shutdown/reset GPIO line for multiple devices: 1. WSA884x (this and previous patch): https://lore.kernel.org/all/b7aeda24-d638-45b7-8e30-80d287f498f8@sirena.org.uk/ 2. https://lore.kernel.org/all/20231027033104.1348921-1-chris.packham@alliedtelesis.co.nz/ 3. https://lore.kernel.org/lkml/20191030120440.3699-1-peter.ujfalusi@ti.com/ 4. https://lore.kernel.org/all/20211018234923.1769028-1-sean.anderson@seco.com/ 5. https://social.treehouse.systems/@marcan/111268780311634160 I try to solve my case, hopefuly Chris' (2), partially Sean's (4) and maybe Hectors (5), using Rob's suggestion: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ Best regards, Krzysztof Cc: Chris Packham Cc: Bartosz Golaszewski Cc: Sean Anderson Chris Packham (1): i2c: muxes: pca954x: Allow sharing reset GPIO Krzysztof Kozlowski (4): reset: gpio: Add GPIO-based reset controller reset: Instantiate reset GPIO controller for shared reset-gpios ASoC: dt-bindings: qcom,wsa8840: Add reset-gpios for shared line ASoC: codecs: wsa884x: Allow sharing reset GPIO .../bindings/sound/qcom,wsa8840.yaml | 11 +- MAINTAINERS | 5 + drivers/i2c/muxes/i2c-mux-pca954x.c | 46 +++- drivers/reset/Kconfig | 9 + drivers/reset/Makefile | 1 + drivers/reset/core.c | 227 ++++++++++++++++-- drivers/reset/reset-gpio.c | 121 ++++++++++ include/linux/reset-controller.h | 4 + sound/soc/codecs/wsa884x.c | 53 +++- 9 files changed, 444 insertions(+), 33 deletions(-) create mode 100644 drivers/reset/reset-gpio.c -- 2.34.1