From patchwork Mon Jan 29 11:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp510293dyb; Mon, 29 Jan 2024 03:53:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+ijPbLfnRQYaSMUXnw0W1JCp+ylAd2yGlcpaOxsYoqjbo4L3ZqS91NN8Ucgqxv67kbe5E X-Received: by 2002:a05:620a:2098:b0:783:8d71:e4e6 with SMTP id e24-20020a05620a209800b007838d71e4e6mr4909085qka.76.1706529199820; Mon, 29 Jan 2024 03:53:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529199; cv=pass; d=google.com; s=arc-20160816; b=znDmfRwWmCYv/SkpEX3z2IxuL0P4G7fJxWeAsTPnhuUiUp+yKtLpYDH7bs8VkhfQqB bPmx2OZUBnQM6y2PEuv3Cx7YWjPb2+DExEJk9Gn7+8ytHTgZ71NZjWnPDi7Z3V4Iqs9p b2lrkDwsCAxUmAUvlw/5RWJYsgcRg/7yRNh23ZBnGxnTEOeQp4l2ljyPFzNSFKYFhDdm Hrhha1ld/lBiwPM7hlp7gNDcYq92t4qiq2mMTXYX4VxawW4AEDa6OBOYb5e88B8pI4on dsMWKpGRYkJEZ6zH9jg95qsCE/bvhbMMdtQmAhlFxNbJuv8YcUpATH+UxlgyaiCV+Cyr FvYA== 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=7u11vGwKEs3fH7gtNpJv3ew33Q7fXCEnCXNY0GONseQ=; fh=fFm2K8VcB+7rgMRllZR/p+J69hkVshGdMfAgQKU9hhQ=; b=c1+R87aHuISbY9czsPmCBweZeTysMUxjlVovx5GbyqVQYpdcWU7Pb2LCS3fbLIXDN6 3sh3AUNMboEF7ldcwK3DdfFR+2QzTeek69au/X9ZTxDvjID7CafbwGcNy8eXtS6mCLcb c3XNMZXDEwtk6cRmQqHlfiYm4s66HtResBFnbu1RrsX9QOvvMFPxhqR6ixFk19VFzxHl niHIPuwYjR9tzuW3V6YLcBdKUXs9fePEcYxtFumALtJ+Bks9mL+H8abptihmehGc7zto peWkKTQqpSaNKfIkLeZSK869HpbC8HIqSBud7Mx8OHSDrYsY+H1HyRBlRSHvVyL1DT+/ s2iw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yh56MIvr; 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-42639-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42639-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id xr10-20020a05620a5cca00b00783ebb7fa28si4370653qkn.316.2024.01.29.03.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:53:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42639-ouuuleilei=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=yh56MIvr; 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-42639-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42639-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9AB6C1C22845 for ; Mon, 29 Jan 2024 11:53:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8E70605D8; Mon, 29 Jan 2024 11:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yh56MIvr" Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.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 4D09F5D8FE for ; Mon, 29 Jan 2024 11:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529147; cv=none; b=oNq9JrslCWUNsBBrhMP9zlAcWstrjuH4/PejigdFBuzrnEaT1HUW0o4HXN1r4EFExsCOm9uVRyhgEB6Dh2PLq4lbV4c4ukWbdUszhop7MQih1uEbmfTAA8OzgNlnWsg3xqOKW6nDMuJ9YwLReiwSkuzAZX1rCDEYIEd7SoKf1J0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529147; c=relaxed/simple; bh=pEaaZzWd53CrhjsWjih79Gm0lLf84UYwD3xSD5zEQj4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fy39xIWdtJNk/fZLxuXQZQeuM9cREmq/AxaLVUCrCEq8xCegVxex8EEGXzLyhX/msdtdDb4REiDO+Mirg+GRX3ZeXAuxTlhwdcs5UCBqgTB7YaUY2mXhu9oHeKacuYWcum+GpczlKJp0oIsvZBtA5gqeBj5WTWjQ++VHLtQEZSc= 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=yh56MIvr; arc=none smtp.client-ip=209.85.208.45 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-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-55ee686b5d5so1449486a12.0 for ; Mon, 29 Jan 2024 03:52:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529142; x=1707133942; 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=7u11vGwKEs3fH7gtNpJv3ew33Q7fXCEnCXNY0GONseQ=; b=yh56MIvrIsDDIDVRv+XbFPR1vq7DFcZr2EVOcMGSm8H5VBpT+4FLwgMKgbreCl94KO 4+kllBcnF8Tsd/Z7TOsH5z8zzbD4FWMfWiNXja/DLdcEfku4uvC0ldYaRIsBQnfo1Gy/ 5nzJdHCiRfZ8vXCkwv5QuKhz89AoZ7KLKzGn857jrjih/EOfLQ4MUeCUWhasUfvDSPvb NsdAVSnnjVHjTVwyl6Aj7h8JFbeUGv9hEBae0urfW90XUQ/Pc7ybAZ2EYeqcBh5WH0rc BUxLbc5/yWEZNypMX3EM3sF5x48DAMh74kk8wLIxuESZlSgOetYf92PXnYlJHC7sGQp4 sVmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529142; x=1707133942; 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=7u11vGwKEs3fH7gtNpJv3ew33Q7fXCEnCXNY0GONseQ=; b=iYOpEXKezwSUcnmg/KfPQFlxwnsA0oZZER17bmT94j0UZtlUa5fgcyswqja4LiibTr m7vvF1VI+yKNgxrcg/LBr8sJ6OE/BntClwpF0SeAUgygx9O13BXyQWWEZ3z8HFkfGpn6 77DKt6hK2kq7gBvUOZLKgz42h15/kbvVQMR5lIUxe8henbG0TtREaKMpRDxoFD6lf47A Eex9st56u/xDcjuKyFfM+bCHG3wiJkdR/l5lvYjpUrsfZoJ9QC75YEtt26fji2XLmsuN CKQyTU/Xh19CwhnNygZqmSBmg7f7DEjvRciuLxaXFwwA9CZBGdDV2MIrxsPV0izWkO3V dxag== X-Gm-Message-State: AOJu0YzLT9tzzki1vRUqVShGO8vwHPbj7o1h+OwapeFPBsFWzio4ZTCk /Iajo/2j9IZ7/5yXBL38al9L5YjX/gx85dRLEsXbSFG7iRxwDADQhJgveZJUACM= X-Received: by 2002:a05:6402:274b:b0:55e:f866:30dd with SMTP id z11-20020a056402274b00b0055ef86630ddmr2119525edd.12.1706529142419; Mon, 29 Jan 2024 03:52:22 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:21 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Krzysztof Kozlowski , Rob Herring Subject: [PATCH v6 1/6] of: Add of_phandle_args_equal() helper Date: Mon, 29 Jan 2024 12:52:11 +0100 Message-Id: <20240129115216.96479-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789425562442758767 X-GMAIL-MSGID: 1789425562442758767 Add a helper comparing two "struct of_phandle_args" to avoid reinventing the wheel. Reviewed-by: Philipp Zabel Acked-by: Rob Herring Signed-off-by: Krzysztof Kozlowski --- Dependency of cpufreq and reset change. --- include/linux/of.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..85bcc05b278d 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1065,6 +1065,22 @@ static inline int of_parse_phandle_with_optional_args(const struct device_node * 0, index, out_args); } +/** + * of_phandle_args_equal() - Compare two of_phandle_args + * @a1: First of_phandle_args to compare + * @a2: Second of_phandle_args to compare + * + * Return: True if a1 and a2 are the same (same node pointer, same phandle + * args), false otherwise. + */ +static inline bool of_phandle_args_equal(const struct of_phandle_args *a1, + const struct of_phandle_args *a2) +{ + return a1->np == a2->np && + a1->args_count == a2->args_count && + !memcmp(a1->args, a2->args, sizeof(a1->args[0]) * a1->args_count); +} + /** * of_property_count_u8_elems - Count the number of u8 elements in a property * From patchwork Mon Jan 29 11:52:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193419 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp512603dyb; Mon, 29 Jan 2024 03:58:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCnDHdEcYX4TUeEMFplq/Poo7+QZDVo0sgExs+bJ22tAHilSU+uJYM8N2iGyIfDk2KyTto X-Received: by 2002:a17:90b:19d5:b0:290:2af9:55eb with SMTP id nm21-20020a17090b19d500b002902af955ebmr4890914pjb.22.1706529515194; Mon, 29 Jan 2024 03:58:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529515; cv=pass; d=google.com; s=arc-20160816; b=sh99o2UddMrgv34dhyU90OrMmExu4UWGs6o5ZU4gtuZfn6qtrcWFPWay/JX/Eju88U Gddt3pFla6WhCgbQkKuETiUvaAuvJqH9MtWBfWRzno3+TC3U1sAA/CdHX6QMexhIj9Qe LrKHqb40zb8n3lVCZTJSsF+JV1WmuikWSZcGyYFead4IGbxsz47BJn82jrVGPucCqClH 08M4Utz+dwB2GVGP75JHgPH4bTLW5WZQE69XQiwrFJlBDlmkgETAZd8+tptVMHFNvSjA BnB8KvlvHZ5TQkZ/u8if2WIpoNC/W9ntNhfOI7WoCEDxTMUAen5gdVw/ppKASLS7ptK+ 2YCw== 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=nDGYECsDtIdBMjd3oPDwhe2eE52MgTh9xNyzExOhMAs=; fh=5vb8PvSf1Mhczj2Nkd/ZngQfS5knYHe/PZA3LmlvXKc=; b=Dpk1aIMwdn4iN5bd39wU/p7wSGuWoxpLdfJSifktnOBUD2m+rhlCNYiPXHDlwrz8VX w0bT8WkJZIFXn9vATHKtOV+OhL/S9LMRSCp5EIzPqeARKakJocmYKuddiGiALakbzR+Q dCmSs8RahRvHa7OqRxp3y970pA7vmjkzr38qlkT27leELqO8UCNvblpw1EWjx9YW/YKJ tO1uN65dHbjDp9nJbs70SVEv/uOIogaGNZ9KvVa13DOClFS5km3cIRjtAKuKZkV5VGj0 Ay+USYR0Sg56pjkq1h3ARQnPfB4Qw4jUkYo/tIjG1GTLxwkXT7iZUdRxE2wo38Co6EdI h4Xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q8b5OvvT; 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-42640-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42640-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. [147.75.48.161]) by mx.google.com with ESMTPS id f24-20020a17090a4a9800b00292688df83bsi7568005pjh.101.2024.01.29.03.58.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:58:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42640-ouuuleilei=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=q8b5OvvT; 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-42640-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42640-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 05321B23B04 for ; Mon, 29 Jan 2024 11:53:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D78A5605DD; Mon, 29 Jan 2024 11:52:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q8b5OvvT" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 394AD5FEEF for ; Mon, 29 Jan 2024 11:52:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529147; cv=none; b=Gx3ZRP21QBhjoKV+eMix+miGmQM/2ysjaXv0Ga1W99zr2oIQEFstY5CDCuLPoPoPZQbtNvrQsejCs5VyLpoQ13VXcEcy73hqxV3DHjru/x8Ckrl4gBXPqar4YSBglHQgdh8VS7cFuuedmGbs1dmkz03QLH1DJ0eEnzgl1sg+618= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529147; c=relaxed/simple; bh=OEn344ksEcO/KPuz03HGzt0LbiDtkFUUnDPggKZSm1Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WzcZK2QOkY88XjB2omEQyvhP1UcRmVvZP4KZsrh2iPM2QsYWO6kyrPn3JFRVHcOIrXCCSqdm/gpSnp4pRmbz1nPIEJWb/3F+LVTFrEM8Ppe+cpR5SKvumFFQmkq7wFR+Mzh/06d8h9e/tdTtGmj3IrVGrYUTL2Sx7ElxukigRCg= 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=q8b5OvvT; arc=none smtp.client-ip=209.85.208.51 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-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-55a9008c185so4469245a12.1 for ; Mon, 29 Jan 2024 03:52:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529144; x=1707133944; 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=nDGYECsDtIdBMjd3oPDwhe2eE52MgTh9xNyzExOhMAs=; b=q8b5OvvTa9f/RWb3NGXpsnBIN2ZgiYeIVf9OiHYDkvGk3hdMutIWF1EEh0rhj88h/p 2qFgExwNkb4oulqKFs6czWzjC3cXWChiC4JqaY9jVxKw357DBmGHT1P0g1AAxWqBJz++ OXxva5J+BnhHXYQ4Q93HfBXgCxWOSyp2I9XkdWG4rKz0F2PB35O9EtOcqN/AVGXGQiRx luSDgjkBSCfSE61fay6OFiwbQnqLIPzqXGwqtqpoIKW64LIIAfs0umYxmAKR5V15tB3w GRtsA6znNpxcFUjHdBoGIwkNq3Gck162ZvRj6/ykFJkIZ4K39HwMbOdA+7DLdfDjkd5c sEKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529144; x=1707133944; 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=nDGYECsDtIdBMjd3oPDwhe2eE52MgTh9xNyzExOhMAs=; b=rYUlodLlgk2v/NP+xZ/r4C/gH0tumvFgBihbTkIY0DZUfb9Q1P3nAI0hLhfKfhQTHo 7kZRptIpPkQfaNvKUwUPdjoM5OZnHF+/8jkT7Y6g0i3Z4z7c0eIdVJfw4HvQBTu66D3W knLubegX0CIqIHjGaFesCt5gMrWpBBEm1DnG44MzN3xcuEP+ceSP/a93Vt03U2U+P8V7 8ypxapPfQX9mzzvL/iYQ9zxbVtL0iCPZXmj0V7lU0yDeEvLZgxd2xFofrR9r/GWej/7g Wt1DW4UM/bx/ZlnErjYe2Ru6hySnHaEXy8Ybz46ZWgbDUm1dEO9WcBo+NAHBJtdKjSEe m7cQ== X-Gm-Message-State: AOJu0YwKXL+Np4ka7IPblZ+4muSJD5tHZKv/PSxvhYm7YEZ3vuNKe9KU q4jCyg1PJSf/D4PSvyKBMqQOYKkYNg3dKqvGGFJ/qPX+p2LT3xlQDbX+W9veED4= X-Received: by 2002:a05:6402:2711:b0:55e:b30d:d845 with SMTP id y17-20020a056402271100b0055eb30dd845mr6121423edd.17.1706529144550; Mon, 29 Jan 2024 03:52:24 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:23 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org, linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH v6 2/6] cpufreq: do not open-code of_phandle_args_equal() Date: Mon, 29 Jan 2024 12:52:12 +0100 Message-Id: <20240129115216.96479-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789425892977539839 X-GMAIL-MSGID: 1789425892977539839 Use newly added of_phandle_args_equal() helper to compare two of_phandle_args. Acked-by: Viresh Kumar Reviewed-by: Philipp Zabel Signed-off-by: Krzysztof Kozlowski --- Depends on previous OF change. --- include/linux/cpufreq.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index afda5f24d3dd..3cd06dafb04b 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -1149,8 +1149,7 @@ static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_ if (ret < 0) continue; - if (pargs->np == args.np && pargs->args_count == args.args_count && - !memcmp(pargs->args, args.args, sizeof(args.args[0]) * args.args_count)) + if (of_phandle_args_equal(pargs, &args)) cpumask_set_cpu(cpu, cpumask); of_node_put(args.np); From patchwork Mon Jan 29 11:52:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193411 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp510518dyb; Mon, 29 Jan 2024 03:53:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP6tP82Q3JUgs+Ojq6AIxTPZbVuz2j3EzgFT0m2f+ZYbexrxBxI6s1HTi5hrGphRXMxroo X-Received: by 2002:a05:6214:1c4d:b0:685:1ece:98e5 with SMTP id if13-20020a0562141c4d00b006851ece98e5mr5125067qvb.4.1706529228564; Mon, 29 Jan 2024 03:53:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529228; cv=pass; d=google.com; s=arc-20160816; b=DnTg/ppWQ/y9R71oAb93q2JmS/kxQWsplZfTqMEEBplMnm4yVTXBglm13+syd05hSD 67DNhyliA3siV2e+p3d68uCENPMLyMZ1AUNp8Lt5VYuQopcKP8o70sYZVd3Gm+PKiWao esGuW47LYZCMnQHS69sE5zbHT54NDJ1UsrfDq50hvhuxuKav7mvo+F9xnRW6ad0OEEgY nADy03kCm+B5O6KZq9p6yN9LRZXXB9QeBD6j1KqyHt6nor5Oa6/RmwW2K30WTCiKHGxe 1q6qhrrpQrgXhlxU8HuisttzUVPN37RNci3isZdyDyT+30DwOSNepJaZonQLQ0JJqIkV xj7A== 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=xRfi7bENx/I9rSbdoOaYxClTFMvpbeifXHCV8MulR38=; fh=Bo7Hfhe8vKTO1PFfP+diH6nw8xfU2ThR5fq+auBM6tw=; b=NJmnqB/w+ap7gT6HqlpiXJ0XiGL2ENJsqOCcikWTjhvz8xDYnLwxx/4iDnRuY/kOVn NjKVyM1kN4EgQae1HG0RdBlrekGHY7qqMHG+GWhSPWuIpjNIgPCmbKMmgZ+4H1Bx0JuY NxOcObN383ZHh1PnfOAp8rn7xxEDC8Kc1PaBlCKQDX0c1mRguPJukqLDlSmZOwtdnQRP hUNhbdLorxjOMuErDPLJB6TNUWksaWxo1GgdAmgqLIR5Tc+pIAuaeNjk01bUhIOwbBfs s10dCXqdqqRudrevaeu/jR5mZ00h6dLsOY87w3n8iI39rNlxWJFyP0nEFK+11Vo74CVT S0Fg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIZXnAv6; 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-42641-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42641-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dv5-20020ad44ee5000000b0068179622f16si7470936qvb.248.2024.01.29.03.53.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:53:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42641-ouuuleilei=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=SIZXnAv6; 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-42641-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42641-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4F83F1C21ECE for ; Mon, 29 Jan 2024 11:53:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBD8560B98; Mon, 29 Jan 2024 11:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SIZXnAv6" Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 E0B1A604DB for ; Mon, 29 Jan 2024 11:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529151; cv=none; b=SsI8rw5PuiBOc7syuVQye/Af6npgG488Oa2gGQ1z6uZ9RSouOjS4UegrCVVJPj2u1J99+M8tFhM09cL369UhudP108+ncHcS+O4XMnyGGkq49BB2dJO+pZg7Vq8jQh/3oZQjzVnuW2lmiuvXyCeOxLjT1Snd+FO4SK5x55O0UlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529151; c=relaxed/simple; bh=S2rlUFR7COiCXocSNwYdxys7hBLM3PNkPdINVgzUk+A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MxQKm5mbm26ObqCmyjHMQLDyDiDlSrhxsrguRIMwCiynj3tUZDOfb0nrJOeBr+RI1AxpmfIXIjHJ6uXy96phfxLOfPwVO9P0cIpW2XhvNBrhzYAjRvcVj595v7krBEG85ZJK3o+ks3D0zVTCFRoE+2laIxP4U0FDrumYyXTvkU4= 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=SIZXnAv6; arc=none smtp.client-ip=209.85.208.171 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-lj1-f171.google.com with SMTP id 38308e7fff4ca-2cf4a22e10dso28758221fa.3 for ; Mon, 29 Jan 2024 03:52:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529147; x=1707133947; 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=xRfi7bENx/I9rSbdoOaYxClTFMvpbeifXHCV8MulR38=; b=SIZXnAv6OxaK2ilNUBqeIfoDnW9RlK3G2azGdYkQaraxM9+K5sn32IfIpULHDLcMZv ajlZvwPE/rLvSamQF8eZSsHQ6CF/r56oPNZWMXuyi6/DMnOWvb8TKX87wm6HtYVuia8J rrYPrNuF2hF8cDxkNBwIBZFN8NJ1xrmxNi7G6Gc6RPPEFA8l+d5BURMTesTMzh+lx8j7 rpVQOV6MTNnk3Y0RQ+XxvtgFYqA+np6FUA8vYFWNU7Hym0ytFAU9VIV7L5nsXLBASont L0pSx4XG0FFXs+V1wFFsq9XP4bPVoKH8JAzYZ28eqh3GnHFH11i7e7WEW52xGNfxXBCY ZPxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529147; x=1707133947; 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=xRfi7bENx/I9rSbdoOaYxClTFMvpbeifXHCV8MulR38=; b=WHYRZUOsrNvHIGKytYTsi1rA3liyzvL6wkTJfU4FQMlBGIo49EICc2ARcpWQPNa2mc raRxk0EYilPkpfxwlhyj7dIv4pLUDWplVyOVrhI3xBBVo8z/QoL7KrQm1ek8iQFKgMgS WfPOU9IDkhx8hKfPqw5JX9S+EIb4O0ucfs3YbaW+NxbIiGiz/dRnUkqACTbxAboy4K8m pn0DZyTy3ejq7OQUoOq2HtnU5fQWS+9ITivAOYBSj4H8eVE+W2pfRJNiHYwrYeI39tH6 DYsS0hM1SPAx55rttU3SsLlsFOmMsFMmDxUn9hMwNk/lZlrMAJWtk8cC9m6f+t95SGX0 ssqQ== X-Gm-Message-State: AOJu0YzokXzEpQGc1n35xuXEy3vyPEdJvlgFq/NzkwHwYrqyHePfS3X+ ttubiYR0j0kIpCXGS1o32DhotZ1PZXKrADoHLkniXM8UPE406jQ2hoUWpxs2VeU= X-Received: by 2002:a2e:be11:0:b0:2d0:4c41:695 with SMTP id z17-20020a2ebe11000000b002d04c410695mr1588148ljq.37.1706529147037; Mon, 29 Jan 2024 03:52:27 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:26 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.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 , Chris Packham , Sean Anderson , Bartosz Golaszewski Subject: [PATCH v6 3/6] reset: gpio: Add GPIO-based reset controller Date: Mon, 29 Jan 2024 12:52:13 +0100 Message-Id: <20240129115216.96479-4-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789425592294839993 X-GMAIL-MSGID: 1789425592294839993 Add a simple driver to control GPIO-based resets using the reset controller API for the cases when the GPIOs are shared and reset should be coordinated. The driver is expected to be used by reset core framework for ad-hoc reset controllers. Cc: Bartosz Golaszewski Cc: Chris Packham Cc: Sean Anderson Reviewed-by: Bartosz Golaszewski Reviewed-by: Philipp Zabel Signed-off-by: Krzysztof Kozlowski --- MAINTAINERS | 5 ++ drivers/reset/Kconfig | 9 +++ drivers/reset/Makefile | 1 + drivers/reset/reset-gpio.c | 119 +++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 drivers/reset/reset-gpio.c diff --git a/MAINTAINERS b/MAINTAINERS index ddc5e1049921..91d45c6bade7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8905,6 +8905,11 @@ F: Documentation/i2c/muxes/i2c-mux-gpio.rst F: drivers/i2c/muxes/i2c-mux-gpio.c F: include/linux/platform_data/i2c-mux-gpio.h +GENERIC GPIO RESET DRIVER +M: Krzysztof Kozlowski +S: Maintained +F: drivers/reset/reset-gpio.c + GENERIC HDLC (WAN) DRIVERS M: Krzysztof Halasa S: Maintained diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index ccd59ddd7610..bb1b5a326eb7 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -66,6 +66,15 @@ config RESET_BRCMSTB_RESCAL This enables the RESCAL reset controller for SATA, PCIe0, or PCIe1 on BCM7216. +config RESET_GPIO + tristate "GPIO reset controller" + help + This enables a generic reset controller for resets attached via + GPIOs. Typically for OF platforms this driver expects "reset-gpios" + property. + + If compiled as module, it will be called reset-gpio. + config RESET_HSDK bool "Synopsys HSDK Reset Driver" depends on HAS_IOMEM diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 8270da8a4baa..fd8b49fa46fc 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o obj-$(CONFIG_RESET_BERLIN) += reset-berlin.o obj-$(CONFIG_RESET_BRCMSTB) += reset-brcmstb.o obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o +obj-$(CONFIG_RESET_GPIO) += reset-gpio.o obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o obj-$(CONFIG_RESET_IMX7) += reset-imx7.o obj-$(CONFIG_RESET_INTEL_GW) += reset-intel-gw.o diff --git a/drivers/reset/reset-gpio.c b/drivers/reset/reset-gpio.c new file mode 100644 index 000000000000..2290b25b6703 --- /dev/null +++ b/drivers/reset/reset-gpio.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include + +struct reset_gpio_priv { + struct reset_controller_dev rc; + struct gpio_desc *reset; +}; + +static inline struct reset_gpio_priv +*rc_to_reset_gpio(struct reset_controller_dev *rc) +{ + return container_of(rc, struct reset_gpio_priv, rc); +} + +static int reset_gpio_assert(struct reset_controller_dev *rc, unsigned long id) +{ + struct reset_gpio_priv *priv = rc_to_reset_gpio(rc); + + gpiod_set_value_cansleep(priv->reset, 1); + + return 0; +} + +static int reset_gpio_deassert(struct reset_controller_dev *rc, + unsigned long id) +{ + struct reset_gpio_priv *priv = rc_to_reset_gpio(rc); + + gpiod_set_value_cansleep(priv->reset, 0); + + return 0; +} + +static int reset_gpio_status(struct reset_controller_dev *rc, unsigned long id) +{ + struct reset_gpio_priv *priv = rc_to_reset_gpio(rc); + + return gpiod_get_value_cansleep(priv->reset); +} + +static const struct reset_control_ops reset_gpio_ops = { + .assert = reset_gpio_assert, + .deassert = reset_gpio_deassert, + .status = reset_gpio_status, +}; + +static int reset_gpio_of_xlate(struct reset_controller_dev *rcdev, + const struct of_phandle_args *reset_spec) +{ + return reset_spec->args[0]; +} + +static void reset_gpio_of_node_put(void *data) +{ + of_node_put(data); +} + +static int reset_gpio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct of_phandle_args *platdata = dev_get_platdata(dev); + struct reset_gpio_priv *priv; + int ret; + + if (!platdata) + return -EINVAL; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, &priv->rc); + + priv->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(priv->reset)) + return dev_err_probe(dev, PTR_ERR(priv->reset), + "Could not get reset gpios\n"); + + priv->rc.ops = &reset_gpio_ops; + priv->rc.owner = THIS_MODULE; + priv->rc.dev = dev; + priv->rc.of_args = platdata; + ret = devm_add_action_or_reset(dev, reset_gpio_of_node_put, + priv->rc.of_node); + if (ret) + return ret; + + /* Cells to match GPIO specifier, but it's not really used */ + priv->rc.of_reset_n_cells = 2; + priv->rc.of_xlate = reset_gpio_of_xlate; + priv->rc.nr_resets = 1; + + return devm_reset_controller_register(dev, &priv->rc); +} + +static const struct platform_device_id reset_gpio_ids[] = { + { .name = "reset-gpio", }, + {} +}; +MODULE_DEVICE_TABLE(platform, reset_gpio_ids); + +static struct platform_driver reset_gpio_driver = { + .probe = reset_gpio_probe, + .id_table = reset_gpio_ids, + .driver = { + .name = "reset-gpio", + }, +}; +module_platform_driver(reset_gpio_driver); + +MODULE_AUTHOR("Krzysztof Kozlowski "); +MODULE_DESCRIPTION("Generic GPIO reset driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Jan 29 11:52:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp510921dyb; Mon, 29 Jan 2024 03:54:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDfLpW4VFZ6xx0kf0YIDm3msB+jArNTgECvKHW6DpXaGPxx4PO0prc+9h5JHinpt3xFPhP X-Received: by 2002:a17:902:eb90:b0:1d8:f071:5067 with SMTP id q16-20020a170902eb9000b001d8f0715067mr765852plg.35.1706529285897; Mon, 29 Jan 2024 03:54:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529284; cv=pass; d=google.com; s=arc-20160816; b=ucjiOsjyqHIPqZNnukTPb5DnIX25sRJBKFn8BtyamYPemo0w0/A9yLv1zagoVpnkO8 RzsdSk8ukVCSSdOUBbDwfnOO0u6mtvLlhS9FfuW6XvsaLAHlwTyjQmFpwWWqOVv2Kd+1 EPMfDbLpw4DSZwtqJ/d7SBGftgMojo0yI6ny0+baLmDNF1yy/B1NY7/9Hd13w3iIYT4t X+KAcR3p45IOJ1K2RJGBEg7bGHyEbYRKlH9ERWYGcfn0rJVvc2rXiL9v/QIC+0aT4z9y HfU9RLaPOi3LgU7pem8DOI1GXrg+Xaa6YwCLYGhA6DCk8J6nAIgxKsh6x95JowRh8x6a Cofg== 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=1TBfXvR6pIfyFCcQcCo2FCNn/31lFzDY7nyc0/6S74g=; fh=EkO6hQiAy+S1HdOPEWXW3D2/O633mFAuOGuxu2HM1Qw=; b=bQJ1WKB+eJDygcmVJ9Cgv5pFYBCIc2goh//HkLF/7bQsqXCPIxhyFCBIDtnvPsHRFr 53QBsLQIv2SUC6AihpQaIjo8zZOQq/xkbaY2pafyHVN+MWiCMvJ3W1w9AsK6fiW8qMnH dlYgldlMW0NgQ/1jUU8K4fVBquKZ7t1BnsgLZjPlYUNLOugKG5BOXkPY5hLmdkZViTh3 wJDoIPB0JWQnKiuODwb1homYa847NCpRZhqtU+ZJ+JvNpqfAPgJAvpwZxdSz8QkwGu6l 2hzYLzobrJ/2+XcGGALhg/tuIiCccE42Pky/xOzBIQl0h0qtGmtb6ow7jJgoROyVGf9Z r2Xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="icU/uHwT"; 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-42642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42642-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h6-20020a170902ac8600b001d78fd4af34si2221263plr.533.2024.01.29.03.54.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="icU/uHwT"; 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-42642-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42642-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 48A42284261 for ; Mon, 29 Jan 2024 11:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDA1860DCB; Mon, 29 Jan 2024 11:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="icU/uHwT" Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 86B8B605A0 for ; Mon, 29 Jan 2024 11:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529153; cv=none; b=bPv+pYietuNfOree6nKsupzdOQCmh/zBHN0sfcutEXzjdVGRyXKCJGxTUVjgOvuIz+KNg3vBBKEAjSNnP2FZ/DOqwk5qBT4xEcmxzgAi5wys36IqcXV0sQ8/b/1YGEviFvMLXizl/IsWz6ynMvlsSuNdrX5g8Z7X4LAB0Bziy7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529153; c=relaxed/simple; bh=RDKdQXX40OiNl7/3DjOh16dFowMeZxhASXBGszdgn6Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BJchxClP3nQv3xyoBTYytTD0zT2RFrCKGpzg7uCcyZF+xfA/U8AZbMw7mZplwgfuK55PDO57nJSfAyJQ3vHyobjmQBpFU+ZERN2TjjwOLaxzQVOKZ0t0zFpAUEAtg8LIjCnKWybGB0oF3OqW+wvSnlPqBF4RgmF4mOSsNnr/kYY= 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=icU/uHwT; arc=none smtp.client-ip=209.85.208.175 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-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cf3ed3b917so27960761fa.1 for ; Mon, 29 Jan 2024 03:52:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529149; x=1707133949; 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=1TBfXvR6pIfyFCcQcCo2FCNn/31lFzDY7nyc0/6S74g=; b=icU/uHwTulyJH2PiVM/qmhPZgbJDeyZ2rY9EoYLZliZkYUyFuIrLnS6rVUlCXmhO8B QvKCRFRM11G2S5qGhySC7nMexrpYRdGoDgteTIqrKHqUTFLYuIano568nB27PugETOgJ PqbJhq53NYCqUPI0/BLClE1Y0voG6RhNhH++aCMC3y2a9aTgoRtW0oKEb0iAmyZEHlZP 0mjlgJyPaWVAzZj2YbpZ421lpiPoXf4tm1c+x5y07OED2gJcVrD5kSGL5gdPMcSWNTaP 729DvRXXmEZMpD/Bb18Skl8HHTSVPCUC4G6kFmnBuPmzyNm/atKempDUlflk0qhXXNZg tNmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529149; x=1707133949; 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=1TBfXvR6pIfyFCcQcCo2FCNn/31lFzDY7nyc0/6S74g=; b=Alhl747Nxj+9qE94jl6Vho4y4l9KIr3Xqb/gkf1pRZLAqIOCpOhy6fv46rO/tneHGX POgkyg8y+KgF0Nu7/2f9mOTRTPTTIur7bPSqe2Q7nAUSfB+smIC4mbVrhBXKD2Ek+Hsr QqKJkLlKxa9OWI+Vh14e5betIPGbfc3DiNPRzlEOcQeEb35Z9a0rEywY/2g2B8nGujqo dE5ygalFofc8v0X4FKMmhiWxD0M7mYWAQlBKy6JbVFCl1D9ZHgpfVN59f3doyMIVvLAp JDMsbt0qs/gXHmuQNWP7NP+3eEPtZFI3U3w5X1VVaSij8KPdjetFdFgfMnEnuKxHGR6t B5ig== X-Gm-Message-State: AOJu0YyzDIWy17ybZyLcJp9/e4rncydjweKYuP5KGso96hyFC8JLbgKa KalYeDJXMbzWXrC2uA5TX76KxDZuIPikJiCnSTvIFKTz5MpQt1dqnT3d3qODwko= X-Received: by 2002:a2e:a796:0:b0:2cd:ef2c:b43e with SMTP id c22-20020a2ea796000000b002cdef2cb43emr4500136ljf.2.1706529149616; Mon, 29 Jan 2024 03:52:29 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:29 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.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 , Chris Packham , Sean Anderson Subject: [PATCH v6 4/6] reset: Instantiate reset GPIO controller for shared reset-gpios Date: Mon, 29 Jan 2024 12:52:14 +0100 Message-Id: <20240129115216.96479-5-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789425651282663067 X-GMAIL-MSGID: 1789425651282663067 Devices sharing a reset GPIO could use the reset framework for coordinated handling of that shared GPIO line. We have several cases of such needs, at least for Devicetree-based platforms. If Devicetree-based device requests a reset line, while "resets" Devicetree property is missing but there is a "reset-gpios" one, instantiate a new "reset-gpio" platform device which will handle such reset line. This allows seamless handling of such shared reset-gpios without need of changing Devicetree binding [1]. To avoid creating multiple "reset-gpio" platform devices, store the Devicetree "reset-gpios" GPIO specifiers used for new devices on a linked list. Later such Devicetree GPIO specifier (phandle to GPIO controller, GPIO number and GPIO flags) is used to check if reset controller for given GPIO was already registered. If two devices have conflicting "reset-gpios" property, e.g. with different ACTIVE_xxx flags, this would allow to spawn two separate "reset-gpio" devices, where the second would fail probing on busy GPIO request. Link: https://lore.kernel.org/all/YXi5CUCEi7YmNxXM@robh.at.kernel.org/ [1] Cc: Bartosz Golaszewski Cc: Chris Packham Cc: Sean Anderson Reviewed-by: Philipp Zabel Signed-off-by: Krzysztof Kozlowski Acked-by: Linus Walleij Acked-by: Bartosz Golaszewski --- Depends on: 1. Previous OF change. 2. !GPIOLIB stub: https://lore.kernel.org/all/20240125081601.118051-3-krzysztof.kozlowski@linaro.org/ --- drivers/reset/core.c | 224 +++++++++++++++++++++++++++++-- include/linux/reset-controller.h | 4 + 2 files changed, 215 insertions(+), 13 deletions(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 4d5a78d3c085..dba74e857be6 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -5,14 +5,19 @@ * Copyright 2013 Philipp Zabel, Pengutronix */ #include +#include #include #include #include #include #include +#include +#include +#include #include #include #include +#include #include #include #include @@ -23,6 +28,11 @@ static LIST_HEAD(reset_controller_list); static DEFINE_MUTEX(reset_lookup_mutex); static LIST_HEAD(reset_lookup_list); +/* Protects reset_gpio_lookup_list */ +static DEFINE_MUTEX(reset_gpio_lookup_mutex); +static LIST_HEAD(reset_gpio_lookup_list); +static DEFINE_IDA(reset_gpio_ida); + /** * struct reset_control - a reset control * @rcdev: a pointer to the reset controller device @@ -63,6 +73,16 @@ struct reset_control_array { struct reset_control *rstc[] __counted_by(num_rstcs); }; +/** + * struct reset_gpio_lookup - lookup key for ad-hoc created reset-gpio devices + * @of_args: phandle to the reset controller with all the args like GPIO number + * @list: list entry for the reset_gpio_lookup_list + */ +struct reset_gpio_lookup { + struct of_phandle_args of_args; + struct list_head list; +}; + static const char *rcdev_name(struct reset_controller_dev *rcdev) { if (rcdev->dev) @@ -71,6 +91,9 @@ static const char *rcdev_name(struct reset_controller_dev *rcdev) if (rcdev->of_node) return rcdev->of_node->full_name; + if (rcdev->of_args) + return rcdev->of_args->np->full_name; + return NULL; } @@ -99,6 +122,9 @@ static int of_reset_simple_xlate(struct reset_controller_dev *rcdev, */ int reset_controller_register(struct reset_controller_dev *rcdev) { + if (rcdev->of_node && rcdev->of_args) + return -EINVAL; + if (!rcdev->of_xlate) { rcdev->of_reset_n_cells = 1; rcdev->of_xlate = of_reset_simple_xlate; @@ -813,12 +839,171 @@ static void __reset_control_put_internal(struct reset_control *rstc) kref_put(&rstc->refcnt, __reset_control_release); } +static int __reset_add_reset_gpio_lookup(int id, struct device_node *np, + unsigned int gpio, + unsigned int of_flags) +{ + const struct fwnode_handle *fwnode = of_fwnode_handle(np); + unsigned int lookup_flags; + const char *label_tmp; + + /* + * Later we map GPIO flags between OF and Linux, however not all + * constants from include/dt-bindings/gpio/gpio.h and + * include/linux/gpio/machine.h match each other. + */ + if (of_flags > GPIO_ACTIVE_LOW) { + pr_err("reset-gpio code does not support GPIO flags %u for GPIO %u\n", + of_flags, gpio); + return -EINVAL; + } + + struct gpio_device *gdev __free(gpio_device_put) = gpio_device_find_by_fwnode(fwnode); + if (!gdev) + return -EPROBE_DEFER; + + label_tmp = gpio_device_get_label(gdev); + if (!label_tmp) + return -EINVAL; + + char *label __free(kfree) = kstrdup(label_tmp, GFP_KERNEL); + if (!label) + return -ENOMEM; + + /* Size: one lookup entry plus sentinel */ + struct gpiod_lookup_table *lookup __free(kfree) = kzalloc(struct_size(lookup, table, 2), + GFP_KERNEL); + if (!lookup) + return -ENOMEM; + + lookup->dev_id = kasprintf(GFP_KERNEL, "reset-gpio.%d", id); + if (!lookup->dev_id) + return -ENOMEM; + + lookup_flags = GPIO_PERSISTENT; + lookup_flags |= of_flags & GPIO_ACTIVE_LOW; + lookup->table[0] = GPIO_LOOKUP(no_free_ptr(label), gpio, "reset", + lookup_flags); + + /* Not freed on success, because it is persisent subsystem data. */ + gpiod_add_lookup_table(no_free_ptr(lookup)); + + return 0; +} + +/* + * @args: phandle to the GPIO provider with all the args like GPIO number + */ +static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) +{ + struct reset_gpio_lookup *rgpio_dev; + struct platform_device *pdev; + int id, ret; + + /* + * Currently only #gpio-cells=2 is supported with the meaning of: + * args[0]: GPIO number + * args[1]: GPIO flags + * TODO: Handle other cases. + */ + if (args->args_count != 2) + return -ENOENT; + + /* + * Registering reset-gpio device might cause immediate + * bind, resulting in its probe() registering new reset controller thus + * taking reset_list_mutex lock via reset_controller_register(). + */ + lockdep_assert_not_held(&reset_list_mutex); + + mutex_lock(&reset_gpio_lookup_mutex); + + list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) { + if (args->np == rgpio_dev->of_args.np) { + if (of_phandle_args_equal(args, &rgpio_dev->of_args)) + goto out; /* Already on the list, done */ + } + } + + id = ida_alloc(&reset_gpio_ida, GFP_KERNEL); + if (id < 0) { + ret = id; + goto err_unlock; + } + + /* Not freed on success, because it is persisent subsystem data. */ + rgpio_dev = kzalloc(sizeof(*rgpio_dev), GFP_KERNEL); + if (!rgpio_dev) { + ret = -ENOMEM; + goto err_ida_free; + } + + ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0], + args->args[1]); + if (ret < 0) + goto err_kfree; + + rgpio_dev->of_args = *args; + /* + * We keep the device_node reference, but of_args.np is put at the end + * of __of_reset_control_get(), so get it one more time. + * Hold reference as long as rgpio_dev memory is valid. + */ + of_node_get(rgpio_dev->of_args.np); + pdev = platform_device_register_data(NULL, "reset-gpio", id, + &rgpio_dev->of_args, + sizeof(rgpio_dev->of_args)); + ret = PTR_ERR_OR_ZERO(pdev); + if (ret) + goto err_put; + + list_add(&rgpio_dev->list, &reset_gpio_lookup_list); + +out: + mutex_unlock(&reset_gpio_lookup_mutex); + + return 0; + +err_put: + of_node_put(rgpio_dev->of_args.np); +err_kfree: + kfree(rgpio_dev); +err_ida_free: + ida_free(&reset_gpio_ida, id); +err_unlock: + mutex_unlock(&reset_gpio_lookup_mutex); + + return ret; +} + +static struct reset_controller_dev *__reset_find_rcdev(const struct of_phandle_args *args, + bool gpio_fallback) +{ + struct reset_controller_dev *rcdev; + + lockdep_assert_held(&reset_list_mutex); + + list_for_each_entry(rcdev, &reset_controller_list, list) { + if (gpio_fallback) { + if (rcdev->of_args && of_phandle_args_equal(args, + rcdev->of_args)) + return rcdev; + } else { + if (args->np == rcdev->of_node) + return rcdev; + } + } + + return NULL; +} + struct reset_control * __of_reset_control_get(struct device_node *node, const char *id, int index, bool shared, bool optional, bool acquired) { + bool gpio_fallback = false; struct reset_control *rstc; - struct reset_controller_dev *r, *rcdev; + struct reset_controller_dev *rcdev; struct of_phandle_args args; int rstc_id; int ret; @@ -839,39 +1024,52 @@ __of_reset_control_get(struct device_node *node, const char *id, int index, index, &args); if (ret == -EINVAL) return ERR_PTR(ret); - if (ret) - return optional ? NULL : ERR_PTR(ret); + if (ret) { + if (!IS_ENABLED(CONFIG_RESET_GPIO)) + return optional ? NULL : ERR_PTR(ret); - mutex_lock(&reset_list_mutex); - rcdev = NULL; - list_for_each_entry(r, &reset_controller_list, list) { - if (args.np == r->of_node) { - rcdev = r; - break; + /* + * There can be only one reset-gpio for regular devices, so + * don't bother with the "reset-gpios" phandle index. + */ + ret = of_parse_phandle_with_args(node, "reset-gpios", "#gpio-cells", + 0, &args); + if (ret) + return optional ? NULL : ERR_PTR(ret); + + gpio_fallback = true; + + ret = __reset_add_reset_gpio_device(&args); + if (ret) { + rstc = ERR_PTR(ret); + goto out_put; } } + mutex_lock(&reset_list_mutex); + rcdev = __reset_find_rcdev(&args, gpio_fallback); if (!rcdev) { rstc = ERR_PTR(-EPROBE_DEFER); - goto out; + goto out_unlock; } if (WARN_ON(args.args_count != rcdev->of_reset_n_cells)) { rstc = ERR_PTR(-EINVAL); - goto out; + goto out_unlock; } rstc_id = rcdev->of_xlate(rcdev, &args); if (rstc_id < 0) { rstc = ERR_PTR(rstc_id); - goto out; + goto out_unlock; } /* reset_list_mutex also protects the rcdev's reset_control list */ rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); -out: +out_unlock: mutex_unlock(&reset_list_mutex); +out_put: of_node_put(args.np); return rstc; diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h index 0fa4f60e1186..357df16ede32 100644 --- a/include/linux/reset-controller.h +++ b/include/linux/reset-controller.h @@ -60,6 +60,9 @@ struct reset_control_lookup { * @reset_control_head: head of internal list of requested reset controls * @dev: corresponding driver model device struct * @of_node: corresponding device tree node as phandle target + * @of_args: for reset-gpios controllers: corresponding phandle args with + * of_node and GPIO number complementing of_node; either this or + * of_node should be present * @of_reset_n_cells: number of cells in reset line specifiers * @of_xlate: translation function to translate from specifier as found in the * device tree to id as given to the reset control ops, defaults @@ -73,6 +76,7 @@ struct reset_controller_dev { struct list_head reset_control_head; struct device *dev; struct device_node *of_node; + const struct of_phandle_args *of_args; int of_reset_n_cells; int (*of_xlate)(struct reset_controller_dev *rcdev, const struct of_phandle_args *reset_spec); From patchwork Mon Jan 29 11:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp510765dyb; Mon, 29 Jan 2024 03:54:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/Hhenon+4NK8Q96rXcyqCxIxM3SgeMzKbi6b+TWCYT4gcXVBrLyyHj0HBtt17BbqyLeKs X-Received: by 2002:a17:907:76e1:b0:a35:f93b:2dd2 with SMTP id kg1-20020a17090776e100b00a35f93b2dd2mr100510ejc.7.1706529264407; Mon, 29 Jan 2024 03:54:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529264; cv=pass; d=google.com; s=arc-20160816; b=J7Bwm07NdVKY3FZN3S23pwUXGH/6BDir2ScjcMFcABQIoi72eWPGJD1rNZQ7NhScbn ZIAZbPlGrgdaz1ZyYkVtbPi4fQMh3DDKEfxo+1YWRvU83vzfpnmK8bAK4fKl7nnVjKTm p5fcu2tvdZRH5dLsCUiyYweEkOKQqsVCI0h08ECmkV5Q3so85fknPH6GHCd4vPHcuydf vY9bm0gGNvS9Uq5DfkRrWu7624Vru9hEM7sMqiv2GHelc8C0Km40nyL9qxIMuSIrZA9C d9LVVRvICESZAV6zRgtozLwTnFQ8ItK+EyUL5GYcIUnSEuyr3vlUpEq+4fAf7TbULIoi e+0A== 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=qG0lQDgeayG/ZAaWGjl028iUARha7B2YZJgs2y6qJ/U=; fh=YsVwLZkD0YP058IApfRoPKkfxHaxg1kAWoUrjZCTAzM=; b=lnj+TZaTPK5DQntEruUCj1jWKFBJR9ufr25WsbN/A4ylo5EigLJDblK9D7n59e9Kal Gfn1/Yz52wWkwq6/sW+kDn3bl5jlTuIdBF0kVndtlbPOkPSelC/e3Q+jOu/J7ewHxiMx NZgOOEw5Y3Te4mlHg+tuEoRXC86rPMW0XVGrXxahwpfwg2P6Rml4vcLoSLYkU/YYoDJD XXHISfnMWiX9dolDvr0QtUooZhNVPKkGUZcjyac6iUhJCP67ProWAAJGUt+5JPzaOtpF pI3bxOs1t0QXxgFbft4rZTAZopBGaYcTv0ih6TZoc15xx2Nu3NMNaQfJaFr2wb9u+4ta 6/hA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=onsBLnSO; 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-42643-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42643-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dv25-20020a170906b81900b00a34c4bfff5asi3308955ejb.584.2024.01.29.03.54.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:54:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42643-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=onsBLnSO; 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-42643-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42643-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 070C01F2228E for ; Mon, 29 Jan 2024 11:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE6FF60ED8; Mon, 29 Jan 2024 11:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="onsBLnSO" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 08FFD60B8C for ; Mon, 29 Jan 2024 11:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529155; cv=none; b=nhFe2iyH6LeUY6XnKpBfDpZNXEsQGr4EwCTA2pF4GTUJ5O0dOtsjLB8oZAKmTpSPHvW6DGpi1ZRSlL755rxZjIcm1is9BvJ1d+95x4gpCGb9tbIIEUxTrDUbGuNEMpZKkm9srkUZd9hVUVXGrGMh/keN6S4I3CLCfNU0mGPJ4s8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529155; c=relaxed/simple; bh=oMxlIYU8lOKLFt0TEL5h53mUDoaj/hO9QDpO+Y17nsg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DTOW48jtTWdFyQk4dN1V3WBg8pwfpBT5+WAS93L8scoYwW3OAdQn2AfAtUf/7M6ji84dxsOuVXm97V2ke18dMMsj8j/iqfyJs5vcNPlH3k8dO2A1F091Zgd6g0UMUiqnrGPbeaLKA5+y85iJ0iMzxAL94GrSdW57JJZRJT3Xq9M= 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=onsBLnSO; arc=none smtp.client-ip=209.85.208.54 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-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-55ef011e934so1309951a12.3 for ; Mon, 29 Jan 2024 03:52:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529152; x=1707133952; 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=qG0lQDgeayG/ZAaWGjl028iUARha7B2YZJgs2y6qJ/U=; b=onsBLnSOlbDh+dU0MK93ZLMDFHtfF+N6xtyDHOtKTDkSOl5a3Oh2oy/7VL8iVjtXIf ytk+1oJdeQbQkVEM9mXmvsGKWe75Ly9Hflc/VhV7S/5n+XzZF6z5zxlEvEaIXJmTl/vO MY9I/0BkxOp8TKOBQDOMkJ5cU5FGM9UvqzUQXoAN0SIIa1ppv/XDxWTnaO7XaOFIHu9y PxqQLpr1vsAhzW89erW+hjk3usObWQypvaqdQQ1I+w7JuK+pE+a8EtDpOqWgtjm+Amko /lVQfKI/kepryyi7VCZgawaWUfQME5AY8+L3ik6Qwtr+P+jQXfrAoPcET8yZZTLbPPpK Eziw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529152; x=1707133952; 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=qG0lQDgeayG/ZAaWGjl028iUARha7B2YZJgs2y6qJ/U=; b=DBOw/Hnl+7G/11tPT6LGbjEdnBImnTI8n/7OGCvWkVtsdgwOeWYlYq/jEEtPZsAJ1k JnICZe7Jqy1wk0A0lJ02KNwNqJDJiXceZbbId0uzud27/Brz36CQv4aYsggddCbKbVre FhHQXayHV9seXCSsD4CCkuYtC9u37ZmtSD5x+tBFZQLiMOX/OzKB9T6u2hV/bJyX8875 RJqjCJR73IZu68NsHYFASJb3p4Y9FKG2HHMF0vevpLH2tDEWHS9aV6+6EidPstET0d6v VlK3N4qt0x0wUiOTJmO0CMSxqTjvRA7ZBpBqQONDRezRBrtDtqRHqtxejRltG86OLJMh 2YCg== X-Gm-Message-State: AOJu0YyLmbuDWOqe90oR7xEEvuRuhUyBhZYpwF9iDwr93py2pPPDJUP5 BMI6OZw0vsbGEQWxr5uMPxDCx21rEeSlAUXU9Q9FmWuLC4kj/5zIjBqOtBpHrkM= X-Received: by 2002:a05:6402:2709:b0:55d:3787:fa06 with SMTP id y9-20020a056402270900b0055d3787fa06mr4268042edd.26.1706529152297; Mon, 29 Jan 2024 03:52:32 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:31 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.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 , Rob Herring Subject: [PATCH v6 5/6] ASoC: dt-bindings: qcom,wsa8840: Add reset-gpios for shared line Date: Mon, 29 Jan 2024 12:52:15 +0100 Message-Id: <20240129115216.96479-6-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789425629993439961 X-GMAIL-MSGID: 1789425629993439961 On newer Qualcomm platforms, like X1E80100-CRD, the WSA884x speakers share SD_N GPIOs between two speakers, thus a coordinated assertion is needed. Linux supports handling shared GPIO lines through "reset-gpios" property, thus allow specifying either powerdown or reset GPIOs (these are the same). Cc: Bartosz Golaszewski Cc: Sean Anderson Acked-by: Rob Herring Signed-off-by: Krzysztof Kozlowski --- If previous patches are fine, then this commit is independent and could be taken via ASoC. --- .../devicetree/bindings/sound/qcom,wsa8840.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/qcom,wsa8840.yaml b/Documentation/devicetree/bindings/sound/qcom,wsa8840.yaml index d717017b0fdb..22798d22d981 100644 --- a/Documentation/devicetree/bindings/sound/qcom,wsa8840.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,wsa8840.yaml @@ -28,6 +28,10 @@ properties: description: Powerdown/Shutdown line to use (pin SD_N) maxItems: 1 + reset-gpios: + description: Powerdown/Shutdown line to use (pin SD_N) + maxItems: 1 + '#sound-dai-cells': const: 0 @@ -37,11 +41,16 @@ properties: required: - compatible - reg - - powerdown-gpios - '#sound-dai-cells' - vdd-1p8-supply - vdd-io-supply +oneOf: + - required: + - powerdown-gpios + - required: + - reset-gpios + unevaluatedProperties: false examples: From patchwork Mon Jan 29 11:52:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 193424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp513895dyb; Mon, 29 Jan 2024 04:00:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkzH+f4GS2K+S45sEEZ8uhzCqxP6bnV7ahQA6B6dmcDQsVJmFebqHl+J3OniSC125OIQhL X-Received: by 2002:a05:6a21:9213:b0:19c:9c44:f71b with SMTP id tl19-20020a056a21921300b0019c9c44f71bmr5219861pzb.50.1706529655878; Mon, 29 Jan 2024 04:00:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706529655; cv=pass; d=google.com; s=arc-20160816; b=BrHdeDDbXbwIZHB9OaxHA+WfbhcTeHkBsdz2vjpXyJXxXj4q4x5mFlGd7yA1N80/rx tOTrpQoUCG6PMX50YlDOTwFTODPYuwNYDnBMlkU+s5fZf9k1uEYLsKbCX3RAISPI9wTs v/u3ek7uvd/mpjxjV3yVpoQK2B0uL3l5zyYnlyXCgwFjKWi4TsaDehOyG79Y7ebPFLYO 5Cl0eSOev9Ov4TN1vZgSmCGlDg1u2AjV2lJ8yGimZ4Un4UxPKmLzvHd6kPXkb80kmG+n /v4ku44Nj6snMNQEkn+jqJE7rNXzVfo6RINdvH8uh6/hf+l59LS588iPEmA/4//VsQ6H /viQ== 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=lRX88GpgU1fgsZxup3Gn93xc8N0Fj24AFUmctHwLfn4=; fh=nxNo1KOdVqLeo95uy268dw3yoxkL/JJiLFxQlwOPRQs=; b=YnI+zhjg+FE2gUFjSajOnVQkz4FtFXnUhrpzpjeg1rj7w5WQNYK0W14U6xqKtykgo/ ST4uyCZjCGaox0m3WJQl7l0j/41welwnxVwXAAT/jH2HWgbPTpak4cduXlUXh2lHpLzj qCWIleKE6eqXM02QdaB2WncApBjz+cainDA5C/LpFpmDeB7TiYOXN5HNGfvUt1Fkh+Si cBQ9pG/P/JaNeC5321MRa0U5mzEFNTAB6r5KXJUmWQeuaDHfel8VWOkn5iu2gTGj56EW LnwwosNnaMnVgIRWEQZZkHTeyii2cElX4uBV49SpbhHLSbSZmGboaARRRcp7Fk20O4sz flsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L2VxAzQW; 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-42644-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42644-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. [147.75.48.161]) by mx.google.com with ESMTPS id ff22-20020a056a002f5600b006d99584c178si5417080pfb.402.2024.01.29.04.00.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 04:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42644-ouuuleilei=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=L2VxAzQW; 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-42644-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42644-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 1355BB23DA0 for ; Mon, 29 Jan 2024 11:54:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A023560EEE; Mon, 29 Jan 2024 11:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="L2VxAzQW" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 8C38860DC8 for ; Mon, 29 Jan 2024 11:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529158; cv=none; b=sig1v7Aph8J1DcNlAGfTCa/XQBbs76f7b/Q4WJsX3us/nlv9bbsrksmvJCUVpfqWrx2DZWhjMd8i6RqHJrGOgz55DGILSWYGqFd9ShKvNs22nHwSCrVB4q/gQl8tEf3hRkKGV3ueq7CZzYPOQdmzgtvNvApI6ZE4iZT0Z8ts3i8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706529158; c=relaxed/simple; bh=oh0sTMif6CnOQLiL5a5MmyT0hcKnwI/jjGqAII0YSDc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cmiWTse6EagNV/nu1T07bxPcIaRkgUdMmAvM7kGtHeh/6jvpLbSk3+jXomHOBIoi86ByTLKNJAf7pc0UBH0flGt+57Y2PqyyybpnHJ6T8T/liFfeIqkVykgOK4fFI4Ujv/4lJjk88pPnUB+ClmKAnfS0+ddh45wBT2tvE4lXuHw= 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=L2VxAzQW; arc=none smtp.client-ip=209.85.208.54 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-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-55a5e7fa471so2450474a12.1 for ; Mon, 29 Jan 2024 03:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706529155; x=1707133955; 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=lRX88GpgU1fgsZxup3Gn93xc8N0Fj24AFUmctHwLfn4=; b=L2VxAzQWX1GxMHZawNcSSglVzdU8GE/dTzhkaUYCwbLIfIFdfglH4xrCZUS2u10rn0 PZHJHmisvtHx2Q3t5CI7wtlfZuO+QnZ6uF2ZpdPLJWj9DWiiswTD/l36yGhVR8uS8cKu sNu2o27nCbjhlx07Wg5HPEtPXXS3yi70FL4WCOY1KbTkKWek1g4rqJcnoM0aYkZJCwKT A1cZ5NLK7jChQZPG0e+ew2gUAjE3gDDF9UmCXqWtnFDD/w6IRonTSQUvM4pMCYsGFZN+ 9sX6h2hphk5RQrhagev6fNM1JiVw9sxK+lxK+qstUEArGIOCuj5gYOWOPtaAN23F8+Sk /9fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706529155; x=1707133955; 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=lRX88GpgU1fgsZxup3Gn93xc8N0Fj24AFUmctHwLfn4=; b=FyiXi5Nu1Ik0lWTrxYLY14/4nfbrI2lgDYS5SQpGGJ+oCf19e0wWGN51H+FB+vqmHV snhefXXPi1B6+MtyFXPkYTaeiJnN7y0f435Y2e/deIfCsk3onwnlW5tZ0uybH1vYKvwc 8UGW3utXRCyKh1/TA4bx9LaDthPZ62Ei4oEsofY/VsycDynxwuOw0Y138DbtefnO2uhC bAw0XQTe0ULmguVGVI2QpGoLz44J6xDqvcrZ//XmN31xjyvaQ1mfXOy1PVDR/qqlokkg q5FAQSmK17tafal7OpxRYTi0QUMv9FSU28xf4FhJWb9ceJDEhuGERiMoF8/f8JrVpx8y RxTQ== X-Gm-Message-State: AOJu0YwRhSmbHY7I80WwR/tDzHcF00IHGrpTVLSjzdlcN99XgD1QAUgx Sm/4IALNy+0GWfQDH4M6bpSGt+jhagMH/cpcmnxMcxYfU357Q6tcIhkToUiri2o= X-Received: by 2002:aa7:d695:0:b0:55f:72f:5caf with SMTP id d21-20020aa7d695000000b0055f072f5cafmr1120034edr.11.1706529154944; Mon, 29 Jan 2024 03:52:34 -0800 (PST) Received: from krzk-bin.. ([178.197.222.62]) by smtp.gmail.com with ESMTPSA id ec19-20020a0564020d5300b0055f29ececeasm19907edb.57.2024.01.29.03.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 03:52:34 -0800 (PST) From: Krzysztof Kozlowski To: Srinivas Kandagatla , Banajit Goswami , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , "Rafael J. Wysocki" , Viresh Kumar , Frank Rowand , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.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 v6 6/6] ASoC: codecs: wsa884x: Allow sharing reset GPIO Date: Mon, 29 Jan 2024 12:52:16 +0100 Message-Id: <20240129115216.96479-7-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240129115216.96479-1-krzysztof.kozlowski@linaro.org> References: <20240129115216.96479-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: 1789426040755711785 X-GMAIL-MSGID: 1789426040755711785 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 Reviewed-by: Philipp Zabel 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;