From nobody Mon Oct 6 13:17:37 2025 Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (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 D72A52236EF for ; Sun, 20 Jul 2025 19:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040324; cv=none; b=fFbVzVlHrFrFlX6R+t+Tky+sD6VXtrLLC5EYD2Grz1eps5/Q4FAGwLUgvmj/OmqZ9bFbA1J66leF5lVhaCxKBp8/1QLF6tN46OJ7xxKaJd5YVtZzSoKtPUxozQ0R63AMqTzyLpwb5f+zyHnf5JAyRj/82pED9u6KPWFZdFQOCxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040324; c=relaxed/simple; bh=NGvVaxHT6GAmFiO4/MidCvEywAVxDk7Jl939F55Z0dI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m9HjtBKWh7wSvYm9C1qhrn9hIEWEk2NuW0lYXcaP13JViivi3+8WCzpwnXr9ufvaHKZ1NKnpINfX45IPNMbxIH9rPcDkf9WvIGXRdZRJXhIotwpGyQcLMHk9gcoRGbg3AjHBy1F050PWY/g3MuJmeGzdMh/O7PMPiq89sGCk35M= 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=xURukzX9; arc=none smtp.client-ip=209.85.161.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xURukzX9" Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-615d75ee53dso115086eaf.0 for ; Sun, 20 Jul 2025 12:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040322; x=1753645122; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=X8e0Rkt8jdkgvftQKNoZRYfHGuTcfUv00gpyykQyZ5M=; b=xURukzX9xG/OwgS474fODizN51RwJT7HiKxjhoaHkXB/BmQt4vJX2WX0s7Ql2g1ALs gWqsX1pVFv11bd5CMefY9iaJt3OchcllDfqr5gHjXP1wRVhUqMhvYkqMLc8xTAKKXU6N QU25j5dQlsSnQxrFBgUusVgRrgq4krWXgE5rgSlRDJpZQ3aJEjqGNs346RrRxL/dmNXV dVyzZ6d+FYNme9iLEsrNA24WE7OdhBeJ/VEB58xD0yQCCWKmtwMBc7RbzOoyNqj17pA8 jr4O50JEBOuTGKo5t7+O4NKck+uS2rlm5lUt7i0NfFa9FY8wzcrGcSCUNvDY2zEx2/pu QYBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040322; x=1753645122; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X8e0Rkt8jdkgvftQKNoZRYfHGuTcfUv00gpyykQyZ5M=; b=XUREINU6NtmNF37IAhJlYSA/BnXvz2nwhciuqMjLHLwUJzJsDE4gL5F7mW5PDnb9Wi KKOi4e1DRGBZBx347g9pIZHcDqWsLrpjviDbgydUOy6tDnqbpuVAUwpeB8K872Phf9TH 1EHMZ/cflsiavoiNqeGJZvrwewjPQCPi/UVLs8uwPM+4aC1VDpEvQhVWEGaoh10HFr2s QPPiOB/dcs+o0kPi/XFrol+W6Qn65ImHExg7dfxiyJV+mcUTSZw9qWmB/Nlnwh4isat8 SBT4l+TtDIPrNQ9VsKPYmjM1S+ZTeyEjjn8eSFxEL/8+nYdcQrdCTtxn6kVSBM+XcfgC imLQ== X-Forwarded-Encrypted: i=1; AJvYcCWZtmJGXrhAuBL1HHJR0vBmv6ywAb4GF1tvNRPZCGcubswy79nTPXRJboeIadviSN3igMISbjLe96v+WcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwANxm2L+Tu+zrL3qXHGXVy/Yc+KktCI2qKW6O2Z/XHOGRjcJvD TcGbxsRhbEDm17ZYrQfXoyY09jBZX83Bv4a/+UffCtznTpA2x5H6TCAUJxibJt3rBF9Pg5Ffla8 cCPuBIh0= X-Gm-Gg: ASbGncvgAiBkFM/GIjRl8e0p95dWVVZHOGxjbE8CbUHPn7S2R3dw7eCGZUhvUFANsTh rT9cukgpIpmjqgkRY2hgyKZ15HOj6SLtnw8xMtBssq4WHzFoJHdG9Wtv0HXno6A66CRmWuPR6H0 dxsmLLrLEKeDjJ+afOrtif2/MtXE0qfrHlYG5feaAG7KVKGiC5pUtJfm+85q88b4ueSrHC63hEG ZThbCfLFQ+Cucc0tZsQBWvBFhJs3ZD/YA1i5EOgBbny48o9B5gcdYXgaxfCUrjox5oW/s3WfHLv tJigOArvqY+RbBEP5omH11ndvYDGjb16bhdO7hJ3QyBf1QgLFx4BfZJ+u/hAIotHtHotMowz1MM +qXdURvni8JE= X-Google-Smtp-Source: AGHT+IGeTlhYB9KS9TF9xSDd7VU5hXZEme07PjGtrxZBrvFLIeMvThRyC/+06//IuEU+tzOyCgkyAA== X-Received: by 2002:a05:6808:3c4b:b0:41c:d19f:27a7 with SMTP id 5614622812f47-41d031f1b44mr15123791b6e.8.1753040321954; Sun, 20 Jul 2025 12:38:41 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 5614622812f47-41fd10c2058sm1777647b6e.2.2025.07.20.12.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:38:40 -0700 (PDT) Date: Sun, 20 Jul 2025 14:38:35 -0500 From: Dan Carpenter To: Sudeep Holla , AKASHI Takahiro , Michal Simek Cc: Cristian Marussi , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 1/7] firmware: arm_scmi: move boiler plate code into the get info functions Message-ID: <7a47cf3d-05e1-4702-87ef-cb7f36f03149@sabinyo.mountain> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This code to check whether the selector is valid and if the item has already been recorded in the array can be moved to the scmi_pinctrl_get_function_info() type functions. That way it's in one place instead of duplicated in each of the callers. I removed the check for if "pi->nr_groups =3D=3D 0" because if that were the case then "selector >=3D pi->nr_groups" would already be true. It already was not checked for pins so this makes things a bit more uniform. I also removed the check for if (!pin) since pin is an offset into the middle of an array and can't be NULL. Signed-off-by: Dan Carpenter Reviewed-by tag from V1, so I am wondering if there is anything to --- drivers/firmware/arm_scmi/pinctrl.c | 108 +++++++++++++--------------- 1 file changed, 48 insertions(+), 60 deletions(-) diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scm= i/pinctrl.c index 3855c98caf06..d18c2d248f04 100644 --- a/drivers/firmware/arm_scmi/pinctrl.c +++ b/drivers/firmware/arm_scmi/pinctrl.c @@ -596,11 +596,19 @@ static int scmi_pinctrl_pin_free(const struct scmi_pr= otocol_handle *ph, u32 pin) } =20 static int scmi_pinctrl_get_group_info(const struct scmi_protocol_handle *= ph, - u32 selector, - struct scmi_group_info *group) + u32 selector) { + struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + struct scmi_group_info *group; int ret; =20 + if (selector >=3D pi->nr_groups) + return -EINVAL; + + group =3D &pi->groups[selector]; + if (group->present) + return 0; + ret =3D scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name, &group->nr_pins); if (ret) @@ -632,21 +640,14 @@ static int scmi_pinctrl_get_group_name(const struct s= cmi_protocol_handle *ph, u32 selector, const char **name) { struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; =20 if (!name) return -EINVAL; =20 - if (selector >=3D pi->nr_groups || pi->nr_groups =3D=3D 0) - return -EINVAL; - - if (!pi->groups[selector].present) { - int ret; - - ret =3D scmi_pinctrl_get_group_info(ph, selector, - &pi->groups[selector]); - if (ret) - return ret; - } + ret =3D scmi_pinctrl_get_group_info(ph, selector); + if (ret) + return ret; =20 *name =3D pi->groups[selector].name; =20 @@ -658,21 +659,14 @@ static int scmi_pinctrl_group_pins_get(const struct s= cmi_protocol_handle *ph, u32 *nr_pins) { struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; =20 if (!pins || !nr_pins) return -EINVAL; =20 - if (selector >=3D pi->nr_groups || pi->nr_groups =3D=3D 0) - return -EINVAL; - - if (!pi->groups[selector].present) { - int ret; - - ret =3D scmi_pinctrl_get_group_info(ph, selector, - &pi->groups[selector]); - if (ret) - return ret; - } + ret =3D scmi_pinctrl_get_group_info(ph, selector); + if (ret) + return ret; =20 *pins =3D pi->groups[selector].group_pins; *nr_pins =3D pi->groups[selector].nr_pins; @@ -681,11 +675,19 @@ static int scmi_pinctrl_group_pins_get(const struct s= cmi_protocol_handle *ph, } =20 static int scmi_pinctrl_get_function_info(const struct scmi_protocol_handl= e *ph, - u32 selector, - struct scmi_function_info *func) + u32 selector) { + struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + struct scmi_function_info *func; int ret; =20 + if (selector >=3D pi->nr_functions) + return -EINVAL; + + func =3D &pi->functions[selector]; + if (func->present) + return 0; + ret =3D scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name, &func->nr_groups); if (ret) @@ -716,21 +718,14 @@ static int scmi_pinctrl_get_function_name(const struc= t scmi_protocol_handle *ph, u32 selector, const char **name) { struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; =20 if (!name) return -EINVAL; =20 - if (selector >=3D pi->nr_functions || pi->nr_functions =3D=3D 0) - return -EINVAL; - - if (!pi->functions[selector].present) { - int ret; - - ret =3D scmi_pinctrl_get_function_info(ph, selector, - &pi->functions[selector]); - if (ret) - return ret; - } + ret =3D scmi_pinctrl_get_function_info(ph, selector); + if (ret) + return ret; =20 *name =3D pi->functions[selector].name; return 0; @@ -742,21 +737,14 @@ scmi_pinctrl_function_groups_get(const struct scmi_pr= otocol_handle *ph, const u32 **groups) { struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; =20 if (!groups || !nr_groups) return -EINVAL; =20 - if (selector >=3D pi->nr_functions || pi->nr_functions =3D=3D 0) - return -EINVAL; - - if (!pi->functions[selector].present) { - int ret; - - ret =3D scmi_pinctrl_get_function_info(ph, selector, - &pi->functions[selector]); - if (ret) - return ret; - } + ret =3D scmi_pinctrl_get_function_info(ph, selector); + if (ret) + return ret; =20 *groups =3D pi->functions[selector].groups; *nr_groups =3D pi->functions[selector].nr_groups; @@ -771,13 +759,19 @@ static int scmi_pinctrl_mux_set(const struct scmi_pro= tocol_handle *ph, } =20 static int scmi_pinctrl_get_pin_info(const struct scmi_protocol_handle *ph, - u32 selector, struct scmi_pin_info *pin) + u32 selector) { + struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + struct scmi_pin_info *pin; int ret; =20 - if (!pin) + if (selector >=3D pi->nr_pins) return -EINVAL; =20 + pin =3D &pi->pins[selector]; + if (pin->present) + return 0; + ret =3D scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL); if (ret) return ret; @@ -790,20 +784,14 @@ static int scmi_pinctrl_get_pin_name(const struct scm= i_protocol_handle *ph, u32 selector, const char **name) { struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; =20 if (!name) return -EINVAL; =20 - if (selector >=3D pi->nr_pins) - return -EINVAL; - - if (!pi->pins[selector].present) { - int ret; - - ret =3D scmi_pinctrl_get_pin_info(ph, selector, &pi->pins[selector]); - if (ret) - return ret; - } + ret =3D scmi_pinctrl_get_pin_info(ph, selector); + if (ret) + return ret; =20 *name =3D pi->pins[selector].name; =20 --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-oo1-f46.google.com (mail-oo1-f46.google.com [209.85.161.46]) (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 E920722425B for ; Sun, 20 Jul 2025 19:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040328; cv=none; b=RqWMOs3drk+7Sy8yrGD0UVxYSbcGq2dP2PuOkih7YGqrl5qWHJ4SyxBzW+hBFerHsgE5SN1nqwyxq+wb9kfcD55Rvzrmqu0madT6tc8wX9eihD+OQc52GBMAUL4i3wJSPZaLbzeN3ejrETfTW9XzYxo8OxrxxftlEVRrKXkujPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040328; c=relaxed/simple; bh=65YRWaYQ/xNnHFyu5hWqKKOZEWxUH+v3jmAFlpWeXqc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VpBoXLYIPtQE500GTXxNgOBwJv6aoCXY4SfFrrOK7RGF8mnFjgrTRAue4BpABR0C57ZqF6IrlN9tpPzNUO/esD89Us0J+ssn8oqGb5RXgOGsaZVgdaMFRaiD6DxhxLjamjclwCeTzFedn9S+nLvuSMelVc0p6IH34gqi28Li6SE= 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=GhgEKvBi; arc=none smtp.client-ip=209.85.161.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GhgEKvBi" Received: by mail-oo1-f46.google.com with SMTP id 006d021491bc7-615950642d9so2067723eaf.1 for ; Sun, 20 Jul 2025 12:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040326; x=1753645126; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Sk/Cvjmn3F+MvNcu5ECj0qva2OjAj6ueLb9Dbmgomqw=; b=GhgEKvBiSXoS2jkpXTQ01Fz4368D5gxq5tfy8+lrw6IfQp1NMC1s1EAAkto3VIZi6W r3Sz2QJ9t6jpdCQeW+Znq5BimyDQBQ3Q25xepI6GzM18upKNAyM8SFSNlZLbkWpOyydn Pe9k098ivHjFugjLSG9t5CZ0lRhWiGACLnCcfogiMoOoJtYkjGjMSaN/Pjho/UYZ6CIl jl+1MX2PPqLxpj12HyXfGdKTdlQJ4YmDncD14/NoDEMm0gdSZf3HnYXPSKyxvrfru/lJ UKMcsKKfu5Cv/RxNm8MU/CeOHiWT7FHqyiWgJpG5s5wAHuBT/lX6smAQTpQjpMAdgybg 7aYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040326; x=1753645126; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Sk/Cvjmn3F+MvNcu5ECj0qva2OjAj6ueLb9Dbmgomqw=; b=MEyz60FY2H8fnifGgV14U8BcUrkd/Uk0FtFNVlscpkzWCfC3Bc43jugaRXuV7NPBi9 BhseaJYYdnLJs9cCuKqYyQuTy9UWtv20qsNWY8MtqH677+ASJQ3IoxsJ/7AQyw+KAIaj C4u5yjI/0aeTlZcAON8XoZwXhcj0fJZTGPRZ54qpyPP6bOBoGTuQfMcRhWpkuv+IMkz/ x6+83Dqy/4pGaR/0xAVP06aFVrwiGYcngoI+RCOSlUkyB6mxWwKwPPA92w11Tf40BHnE QbDNawFiZINOW6Yg3QCnBmfvUVbQd5sVX0SDqKkFqq5UHkpsa7CHwC9vN8IXo+ITHYD4 dSCQ== X-Forwarded-Encrypted: i=1; AJvYcCVOngMzmd8jBANBCoqHltLyP15FFTnncOB0YQDhOsXHZGB2E1kq6xj+/x3imU2BUytUdiynA90+u5O4alg=@vger.kernel.org X-Gm-Message-State: AOJu0YzhcQlPgW3znyF4pZDItl2mqgrBiUWOyN5NL8iUp9G3CdaWLAio OfX74PeL0GuKsKDMuKPcx3UdET44jkWTq4JYHhde5ZI46P319Hh7M5cKKTLwOoaceCMH2K7iIZ9 6Ai2pCIY= X-Gm-Gg: ASbGncvbB4AAV4H6QITcpAqJ7+M5F5bT3yIxgkIkpJkmFwPLpYfzYI4/+PqrACwU9vm /jecxXqyfM+pzta6Hqv1xpYpcySdb2SDVaMS7eIsgdQd6vburXgKkTdDDpIcU/8BVCYRr316yzD vXHTzBU0YKMJmVlJZIiEhl6FC/B4r5pz+cYqH1Fcc0+h0p1vzquSwYIuieA9aN4Np1qm5NkQtX+ JXRG+GAFkrb+A81glAXHrspniZPIJqS78jD7bGGlJPsK9nWIOWmHA5Q1teUjjWGRER9cOaOJw1Z x602CPFAlPK5ttGbnZNjNuxzo/+dgk7b5hgcqW5dXvv3Md3ksxf06dda+EG0miHwqilwZjTMYNz LnscI/GCQ9hZwZVOrVwh1PA== X-Google-Smtp-Source: AGHT+IHv3AJy6WvLlnGO2CccdtcgTjsbozHvajCI7dbyHtAdaolcMplcFhzuNXWcUN+G/rBrd/RjDA== X-Received: by 2002:a05:6808:10d0:b0:406:2bb4:cd77 with SMTP id 5614622812f47-41d034f1585mr12534170b6e.5.1753040326039; Sun, 20 Jul 2025 12:38:46 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 5614622812f47-41fd498d8d4sm2027882b6e.24.2025.07.20.12.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:38:44 -0700 (PDT) Date: Sun, 20 Jul 2025 14:38:42 -0500 From: Dan Carpenter To: Sudeep Holla , AKASHI Takahiro , Michal Simek Cc: Cristian Marussi , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 2/7] firmware: arm_scmi: add is_gpio() function Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Parse the GPIO response in scmi_pinctrl_attributes(), set the gpio flag, and create an is_gpio() function pointer so that it can be queried. In SCMI only functions and pins have a GPIO flag so that's why groups are not handled here. Signed-off-by: Dan Carpenter Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/pinctrl.c | 34 +++++++++++++++++++++++++---- include/linux/scmi_protocol.h | 2 ++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_scmi/pinctrl.c b/drivers/firmware/arm_scm= i/pinctrl.c index d18c2d248f04..10c92007bc1b 100644 --- a/drivers/firmware/arm_scmi/pinctrl.c +++ b/drivers/firmware/arm_scmi/pinctrl.c @@ -28,6 +28,7 @@ =20 #define EXT_NAME_FLAG(x) le32_get_bits((x), BIT(31)) #define NUM_ELEMS(x) le32_get_bits((x), GENMASK(15, 0)) +#define GPIO_FUNC(x) le32_get_bits((x), BIT(17)) =20 #define REMAINING(x) le32_get_bits((x), GENMASK(31, 16)) #define RETURNED(x) le32_get_bits((x), GENMASK(11, 0)) @@ -107,6 +108,7 @@ struct scmi_group_info { struct scmi_function_info { char name[SCMI_MAX_STR_SIZE]; bool present; + bool gpio; u32 *groups; u32 nr_groups; }; @@ -114,6 +116,7 @@ struct scmi_function_info { struct scmi_pin_info { char name[SCMI_MAX_STR_SIZE]; bool present; + bool gpio; }; =20 struct scmi_pinctrl_info { @@ -189,7 +192,7 @@ static int scmi_pinctrl_validate_id(const struct scmi_p= rotocol_handle *ph, =20 static int scmi_pinctrl_attributes(const struct scmi_protocol_handle *ph, enum scmi_pinctrl_selector_type type, - u32 selector, char *name, + u32 selector, char *name, bool *gpio, u32 *n_elems) { int ret; @@ -217,6 +220,8 @@ static int scmi_pinctrl_attributes(const struct scmi_pr= otocol_handle *ph, =20 ret =3D ph->xops->do_xfer(ph, t); if (!ret) { + if (gpio) + *gpio =3D GPIO_FUNC(rx->attributes); if (n_elems) *n_elems =3D NUM_ELEMS(rx->attributes); =20 @@ -610,7 +615,7 @@ static int scmi_pinctrl_get_group_info(const struct scm= i_protocol_handle *ph, return 0; =20 ret =3D scmi_pinctrl_attributes(ph, GROUP_TYPE, selector, group->name, - &group->nr_pins); + NULL, &group->nr_pins); if (ret) return ret; =20 @@ -689,7 +694,7 @@ static int scmi_pinctrl_get_function_info(const struct = scmi_protocol_handle *ph, return 0; =20 ret =3D scmi_pinctrl_attributes(ph, FUNCTION_TYPE, selector, func->name, - &func->nr_groups); + &func->gpio, &func->nr_groups); if (ret) return ret; =20 @@ -772,7 +777,8 @@ static int scmi_pinctrl_get_pin_info(const struct scmi_= protocol_handle *ph, if (pin->present) return 0; =20 - ret =3D scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, NULL); + ret =3D scmi_pinctrl_attributes(ph, PIN_TYPE, selector, pin->name, + &pin->gpio, NULL); if (ret) return ret; =20 @@ -815,9 +821,29 @@ static int scmi_pinctrl_name_get(const struct scmi_pro= tocol_handle *ph, } } =20 +static int scmi_pinctrl_is_gpio(const struct scmi_protocol_handle *ph, + u32 selector, + enum scmi_pinctrl_selector_type type) +{ + struct scmi_pinctrl_info *pi =3D ph->get_priv(ph); + int ret; + + ret =3D scmi_pinctrl_get_pin_info(ph, selector); + if (ret) + return ret; + + if (type =3D=3D PIN_TYPE) + return pi->pins[selector].gpio; + if (type =3D=3D FUNCTION_TYPE) + return pi->functions[selector].gpio; + + return -EINVAL; +} + static const struct scmi_pinctrl_proto_ops pinctrl_proto_ops =3D { .count_get =3D scmi_pinctrl_count_get, .name_get =3D scmi_pinctrl_name_get, + .is_gpio =3D scmi_pinctrl_is_gpio, .group_pins_get =3D scmi_pinctrl_group_pins_get, .function_groups_get =3D scmi_pinctrl_function_groups_get, .mux_set =3D scmi_pinctrl_mux_set, diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 688466a0e816..b4ad32067fc4 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -792,6 +792,8 @@ struct scmi_pinctrl_proto_ops { int (*name_get)(const struct scmi_protocol_handle *ph, u32 selector, enum scmi_pinctrl_selector_type type, const char **name); + int (*is_gpio)(const struct scmi_protocol_handle *ph, u32 selector, + enum scmi_pinctrl_selector_type type); int (*group_pins_get)(const struct scmi_protocol_handle *ph, u32 selector, const unsigned int **pins, unsigned int *nr_pins); --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 043942264B0 for ; Sun, 20 Jul 2025 19:38:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040336; cv=none; b=rmWKPHE/sRKU5a2LxHKSS1KUXZNmRtWiRoSt2LGLvy1GuHoAEqxzOfPiAaHQuSxI8Ck/V3j6a9i0PFzvNvCvbz52cTklu3JZYvyJRPE5QTrJPCZoZxD3PPdWBK9hAOE32Xr0Gw6KE7QcblUlGWtlPr0jtnRiYt9ZRsima3S6HSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040336; c=relaxed/simple; bh=mYX7pyCKmgBI3xkaCZ3OcyOD6ECMbja6Ks4OfZzYD0U=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CXviSwP7a69Iu2sia91BzYcX7s8TBy5NHex/j1yzcsrraHqhawi9DqlengBCtYFoZQC1k0NXhrTCLuuKscsDuy8K50ZjTqWa1ibrESsGcI+fZaBbF4tQ/yXAYBIxEYiIL2w/9n6a5ipHUfVieVnBqDDnxBeNB2hKb1Hc5LwCaX4= 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=E1q5u3x4; arc=none smtp.client-ip=209.85.160.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E1q5u3x4" Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-30297d04cdbso628585fac.1 for ; Sun, 20 Jul 2025 12:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040332; x=1753645132; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=mJ8CW0vLOfnenhTuOWc+TeZEp3L4Zf69FjBvFuh8CCU=; b=E1q5u3x4B/jU8dBh3OI7i5oFnomFS/yqXGh7i7eibqWMDCDVF+YHgXvPPkmK0g131u KZltk0AjUoyYqdF+ly+ZJFucbWBIK0sB6mMrCFyRhjne1rjfBcMIsYjd3a9ThdE2WX4D XbpPChMrsUZl5NZDdySchkilblrGn9LM49JrFEQDPCs1U3JW4FEIry34/pDOcNf4KLEZ L8+Be9LuHlLt2LyeYc6sbzd6UREd7qT4PEysPrQgnvnpz6F3Xpdv9FgSX9SShVdRQOad vPyo2eM7lp5G43DgTC3m7Hew5KvdgmVK+POkBGBDk74wrj5imbvO+nx5mtu+BowgQBKk w5cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040332; x=1753645132; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mJ8CW0vLOfnenhTuOWc+TeZEp3L4Zf69FjBvFuh8CCU=; b=m5ercNqVh1ClRh45A8qAorT6izruzZwLqbI+VwXs6FiURRMRFk/YTHUmsrkd9Br7Ai HCjHY5TpjTRBkLbz15xAFgKfsn4hR8Wqm5gbw3qtjw3oCG6aXRC1vPV42gt5KnJw0FYx ClYlYZYpMuUumGL2golWOTgqz6oHE/FFoRhRxEktqbQC0TvItKLdgUunEabtF6CJvus1 a0tY3REAty7dIvC6gAI9EvXE7MFl0q6oC1B0kEVPvWkSZ+geykv/Q4K7Nap0Q9CuO8hf U07ho9Zl9B9J8TVYue2cBbfU3e/MrXtoWY9QKc68dyBpW6bL0GMbZ+P7EwzwyRNl7EVx K4Sw== X-Forwarded-Encrypted: i=1; AJvYcCX0koSnWYWpzEBiefLHiYRAHdzXMNb6D52TzCMSOlLoICwVcrZo2lNzzrRyr7GHeYdLZ6wW7aDv9buqMoY=@vger.kernel.org X-Gm-Message-State: AOJu0YzksXyX1r8EXUgs6LSl3fNt2li25UIRniLUPZl7lWecfYYwAgEe OUZVv3KTnRcDjnujZwS9I06Um97Gy1lfMetakvSoBkM9ydRI3PT9C+6pWz2XgxBKrBw= X-Gm-Gg: ASbGncvnPAhMHpfv1liAxYn+J0guelAK+HSjGWTclkDaiTt2as5zXbQsOsSNlJYT9q9 2de/2Qm8PK423LOUjRVVMt4QOnmjLC/Q1Rnzsho6YMsN4gZzGsHaB3uhopZQuVmRPDyoM6yqlBV gxdV80TT4jLZsfpNQVo87AEeSF0Jma4NrA8kS/AFPQsCKqtOOPcKZWNk2D0F+pmgJiFu+PMNcEL 6cOhP8EgVFnKPG7iWUKl6TFKyL/QVItQPApRLmhL4ZwPgvkMpJzYy6f3YdABhHD3CWz1f3WhT1X KV8EpynFOaI8FjvsrMi4gM5QDrk0m8yNVIYOEuN8+zGe/7g1G6Z+c190C8skFj8NIrBU57+yR2N 9CliMwgk6zfviaw== X-Google-Smtp-Source: AGHT+IFbjLhU8/44DbMUEvvTUW/4Nyns5hHtifrjZpoaHHE4Bl1HkYPNemmL3YlLCmSkuw2CsDAi/w== X-Received: by 2002:a05:6870:4149:b0:2ef:ac47:798a with SMTP id 586e51a60fabf-2ffb2246fc7mr13966393fac.9.1753040332019; Sun, 20 Jul 2025 12:38:52 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 586e51a60fabf-30104256720sm2795172fac.33.2025.07.20.12.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:38:50 -0700 (PDT) From: AKASHI Takahiro X-Google-Original-From: AKASHI Takahiro Date: Sun, 20 Jul 2025 14:38:48 -0500 To: AKASHI Takahiro , Michal Simek , Linus Walleij Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 3/7] pinctrl: introduce pinctrl_gpio_get_config() Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is a counterpart of pinctrl_gpio_set_config(), which will initially be used to implement gpio_get interface in SCMI pinctrl based GPIO driver. Signed-off-by: AKASHI Takahiro Signed-off-by: Dan Carpenter --- drivers/pinctrl/core.c | 35 ++++++++++++++++++++++++++++++++ include/linux/pinctrl/consumer.h | 9 ++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 73b78d6eac67..bbcc6881b119 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -30,6 +30,7 @@ #include #include #include +#include #include =20 #include "core.h" @@ -937,6 +938,40 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsi= gned int offset, } EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config); =20 +/** + * pinctrl_gpio_get_config() - Get the config for a given GPIO pin + * @gc: GPIO chip structure from the GPIO subsystem + * @offset: hardware offset of the GPIO relative to the controller + * @config: the configuration to query. On success it holds the result + */ +int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, uns= igned long *config) +{ + struct pinctrl_gpio_range *range; + const struct pinconf_ops *ops; + struct pinctrl_dev *pctldev; + int ret, pin; + + ret =3D pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range); + if (ret) + return ret; + + ops =3D pctldev->desc->confops; + if (!ops || !ops->pin_config_get) + return -EINVAL; + + mutex_lock(&pctldev->mutex); + pin =3D gpio_to_pin(range, gc, offset); + ret =3D ops->pin_config_get(pctldev, pin, config); + mutex_unlock(&pctldev->mutex); + + if (ret) + return ret; + + *config =3D pinconf_to_config_argument(*config); + return 0; +} +EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config); + static struct pinctrl_state *find_state(struct pinctrl *p, const char *name) { diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consu= mer.h index 73de70362b98..e5815b3382dc 100644 --- a/include/linux/pinctrl/consumer.h +++ b/include/linux/pinctrl/consumer.h @@ -35,6 +35,8 @@ int pinctrl_gpio_direction_output(struct gpio_chip *gc, unsigned int offset); int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset, unsigned long config); +int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, + unsigned long *config); =20 struct pinctrl * __must_check pinctrl_get(struct device *dev); void pinctrl_put(struct pinctrl *p); @@ -96,6 +98,13 @@ pinctrl_gpio_direction_output(struct gpio_chip *gc, unsi= gned int offset) return 0; } =20 +static inline int +pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, + unsigned long *config) +{ + return 0; +} + static inline int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset, unsigned long config) --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.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 E64EA221F0F for ; Sun, 20 Jul 2025 19:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040344; cv=none; b=hk8yvr9aWd5yriv63ptA8U3TXs30xZJTpPHzvHbgga7z3cjwd/GIlYcm2JBglzDdDvqGDKfIAMSXWUEUYwb+Gkgdtfm1nFyvkBQjfBy21sTJOlZDH8OgWOvTzQ0NrRAJlo4r5RjbtK2ZF7epKScXAp83n2qgzFtDitV33+nCEyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040344; c=relaxed/simple; bh=9auUBQhB8O3iigsJ/KehzMZyztYeJf1B88SFG08/JSg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=u71TOVZ8KyZUNWYYqcjLMnLWJJKk+ccwgHgYuT3H/pihG4acLU7AnVRvHovOzkw5hb8VB/m8sE+gjvxTvc6gVFqWKAdfqw5qKWZz+BDfyNfpSVc/4/Cjf/nhZl9AZDoDx3Ne90velXvp3EWizBSwxFfasw9TkIUAoPz3oL2WBR0= 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=rq+X066Y; arc=none smtp.client-ip=209.85.160.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rq+X066Y" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-2edec6c5511so1740894fac.2 for ; Sun, 20 Jul 2025 12:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040342; x=1753645142; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6uCGwy/uGkpfb0pvgcXUB8vgobgSJDaGpbJSvSenFqI=; b=rq+X066YPJYvj7caU6QoRh+ck4ryX4OBTUpKgnOv18omKOBrBoveEWtqW7OR1YHFjX yMNzJibFgVDjbmQCRT4RpaN+uH2+2qU/EpXLAg+NxdfFJeEAfnrRl7SaUgcsM6cV7+tv rwEZu/Vw5JWZt51u6lmnjOQjNydOHkHF1B2a9TJWP2OOWY6oioQQGvuryAN88KmeByKS 6Ufu+JCjyuU5ajWVOVH+O5420L4Yd43zAdiqfpXObIPC9SSEkzcLzxVmXDweqwiyIfmz ABGZKDG69/eahe5HyIGgOwVX0I64tg9sH9a7olXVf1vtHVxlnD4jcaOrDmtUl4IecLVo HjeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040342; x=1753645142; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6uCGwy/uGkpfb0pvgcXUB8vgobgSJDaGpbJSvSenFqI=; b=K643QKx00ARxaoBz9oulwE7NNC631x2OrRbQKixLM0VXM2b661bFASJIJboqdcGxTJ mCQOxuJc99Seb3/+LPAvPnPG1uPnp24uj9IPYTxkzEogxmLhvJTYhKFQtpkscvsxj5se 1FttzY1/b859fMYJb6DCaAyZdHxtHChR+YvgLTkJn5y+3TUdqHgsdeZ2gokEFPRH3WTk 64ClqB3z/5CWfWiwbdiBy5B2oXJI2vuaIntHL4/Ur9AmFJs03ivaPbP7mCB3l3ecyjJb WLVB+qTe03UQjHcHGNmur6IjwP/kD9o4tdviNScAoXHAOiazYfWkviUx3h79tEn4ciUb ZrGw== X-Forwarded-Encrypted: i=1; AJvYcCWf9/pDQPjzph+XS2mFV8g5Fxdb0xKX6Em3qcI1HG93s9Y+9bhdYSOhFF37sSOqe8tKdVg2VskkPuElDOE=@vger.kernel.org X-Gm-Message-State: AOJu0Ywec46px2PMqmXIxlvRlINIprt/KNC1TiDaKSMdW0QjdvztpeEw QoskPymvP9qTuOC1os4+UJpB5GrVxpSa9T8YFe8kwL0xn89Srh7ASN0POFdNsEFO/u5nGsIQBwZ hAxjTYEw= X-Gm-Gg: ASbGncsUJaCKcPBhv3vPjyE253rxLOyr0WUWUUXkjbVVUlO+HcYjDXP06FioQZxU0gN VQqe9rh3ihlyGU0gdHZSqMDSpL+ZwTTYIzo6m0uOA8mEUlDpquhJWWYJWVwLeqzx/PoipvIL0NF KrTo5nhM1hp0KQaLU7lhiVVNmtjChrUAAkPixqe22252zrY104POcKfHfQFg5n9otApNBGzvAig gGhYzdmPxJMFVuF0ZUILEvXlkw143BZblLx6qtCG9njFm/EIsrcCOHxFl4T1mIFckJAbo59l7dz 82hh1eZZ/OgTsOmT09mv7/eGeZFXr5Oz2FEHSSY7TAuxI5NoNw2bXZup0VQ3qvd5/aaG1dgbpTU vQz9TF61UESw= X-Google-Smtp-Source: AGHT+IH8XmyhhsiwXlgfzLZBUO70j3GY7Ll+3IavnthbKLQPwxSitZFNpac9MaQeewUcKGCyD5gWsw== X-Received: by 2002:a05:6871:7383:b0:2d5:ba2d:80da with SMTP id 586e51a60fabf-2ffaf5c8720mr13188863fac.36.1753040342019; Sun, 20 Jul 2025 12:39:02 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 586e51a60fabf-30103d1d804sm2810796fac.29.2025.07.20.12.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:39:01 -0700 (PDT) Date: Sun, 20 Jul 2025 14:38:59 -0500 From: Dan Carpenter To: Sudeep Holla , AKASHI Takahiro , Michal Simek Cc: Cristian Marussi , Linus Walleij , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 4/7] pinctrl-scmi: add PIN_CONFIG_INPUT_VALUE Message-ID: <6f732f53-7e00-4f0d-82a3-480bc81497bd@sabinyo.mountain> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In SCMI the value of the pin is just another configuration option. Add this as an option in the pin_config_param enum and creating a mapping to SCMI_PIN_INPUT_VALUE in pinctrl_scmi_map_pinconf_type() Since this is an RFC patch, I'm going to comment that I think the SCMI pinctrl driver misuses the PIN_CONFIG_OUTPUT enum. It should be for enabling and disabling output on pins which can serve as both input and output. Enabling it is supposed to write a 1 and disabling it is supposed to write a 0 but we use that side effect to write 1s and 0s. I did't change this because it would break userspace but I'd like to add a PIN_CONFIG_OUTPUT_VALUE enum as well and use that in the GPIO driver. But in this patchset I just use PIN_CONFIG_OUTPUT. Signed-off-by: Dan Carpenter --- drivers/pinctrl/pinctrl-scmi.c | 3 +++ include/linux/pinctrl/pinconf-generic.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c index 383681041e4c..d1f2f971cd96 100644 --- a/drivers/pinctrl/pinctrl-scmi.c +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -250,6 +250,9 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_confi= g_param param, case PIN_CONFIG_INPUT_SCHMITT_ENABLE: *type =3D SCMI_PIN_INPUT_MODE; break; + case PIN_CONFIG_INPUT_VALUE: + *type =3D SCMI_PIN_INPUT_VALUE; + break; case PIN_CONFIG_MODE_LOW_POWER: *type =3D SCMI_PIN_LOW_POWER_MODE; break; diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctr= l/pinconf-generic.h index 1bcf071b860e..b37838171581 100644 --- a/include/linux/pinctrl/pinconf-generic.h +++ b/include/linux/pinctrl/pinconf-generic.h @@ -83,6 +83,8 @@ struct pinctrl_map; * schmitt-trigger mode is disabled. * @PIN_CONFIG_INPUT_SCHMITT_UV: this will configure an input pin to run in * schmitt-trigger mode. The argument is in uV. + * @PIN_CONFIG_INPUT_VALUE: This is used in SCMI to read the value from the + * pin. * @PIN_CONFIG_MODE_LOW_POWER: this will configure the pin for low power * operation, if several modes of operation are supported these can be * passed in the argument on a custom form, else just use argument 1 @@ -135,6 +137,7 @@ enum pin_config_param { PIN_CONFIG_INPUT_SCHMITT, PIN_CONFIG_INPUT_SCHMITT_ENABLE, PIN_CONFIG_INPUT_SCHMITT_UV, + PIN_CONFIG_INPUT_VALUE, PIN_CONFIG_MODE_LOW_POWER, PIN_CONFIG_MODE_PWM, PIN_CONFIG_OUTPUT, --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 B2216225A37 for ; Sun, 20 Jul 2025 19:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040354; cv=none; b=o8pAxR2vW+TsfqQuVBwAZZ0fivDups45VQWpYRpk1uBFXSfQhW5nqsoklY355KGJ2d7UATl2Qs3/VkDabII1vNIPxRDqPmdiPgUj3hNV9lWPpFrRurs6b7gLDj/eUfi2hFvwEf68FgPPBVSpiZdzjXquutOWSyvrh1jy9+br5bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040354; c=relaxed/simple; bh=4NAzFP3h5a6Z6vaqs42FUh+f1ajE8aZtOY0xrnx7jQA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jKCFQ1kaYKOg8WgrbvF5xy3/3RrKMQn/QguWDYXBB/GtflS83aC5xlVImjCyKGz9YMyqg5SEVCf90Du8ENOORUcwL2K32UaqAuxFlQSFjNEkytrTStR8v3X2dzDM8f0RPHT0bk2Pc8BTkwD1uYbMfOiNitdE/YiQ6R58PGNE9I8= 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=ScqJlMR6; arc=none smtp.client-ip=209.85.210.50 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ScqJlMR6" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-73e8cc38e80so1150404a34.1 for ; Sun, 20 Jul 2025 12:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040352; x=1753645152; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RgyhAHdNttgB7UCXQ5eGMG7hG2NbXpPfSEfjq5gWiJg=; b=ScqJlMR6Q+5uJtK8YRnjvjLE4jn0wnIFDBGsaI6fuydxaNfyBUAA8FU2g611dQSbiI EzuWThQZlfvX+e6zB9CcQixx7g9WyW0kLsqHbQm86q5mjq8M5zvyn1c7zEPrl9p/vzvu LnqC6zmr+2tQSjq06mBE06p3WWF0Se+Ix1bqV1a8d2fKV4XOV8jgixScmaUVbFB/GvW9 XB3q38fK3OjB92PCd/wm6bAyhnYMU6Nksdj/EsujrdMkONgsx2Cvqr1A+W+SZEywbFy+ rUCrNKyRSGTEwNy5mMG3DIuU6KCPCHs0GFCKJ1DSIDvHg8gYEJHs5O1ZhxCg8BRUSjD6 p8cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040352; x=1753645152; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RgyhAHdNttgB7UCXQ5eGMG7hG2NbXpPfSEfjq5gWiJg=; b=lBoJpxCcvqZpK07fMd6wyM6SD0l9CitZr78V/K4JX9ia2RSTvGP1qlx/LT8liYmumh TwdL5hqeQD0+nSvi/hOBoTqqIHUHuksOeAV8p6yH8lnLAgtZZISNUXQfcezZxp/AxadF nnJgF+fcxFBZtOpPbFie025hgPDNtUJIXSas1MYiy/fpcFEtfFVap9IrhKpOYvxyyumM DjvX/2zo+V3576hOFarfArKi1uHrF33uhTs6422r9EAhA3gwb3qU+vgc9s87nRnKgBiv kv3EdYRms53yRt2atp5cM+V55n35s1EuctF4Ct45NNFaU2MBksTgsRtWbsYZPA2c5dnn LHAQ== X-Forwarded-Encrypted: i=1; AJvYcCUzo/3S05BpziWh4qD6Ehfw3lXGdiiZs7Iu+iHDWbpyfb/esWFENfSVDaJhGLSu348J06DG/kwExOFm5JU=@vger.kernel.org X-Gm-Message-State: AOJu0YwbQOSJOChuoXITY1Bg9Wb3o6uHQnGWAsZc5fpvjlMCDjkfp27s ZxPOHCbdy50ems1z389MFl7FYEQm0qwSC3VwQYSWLSom2pdNk6L+d93Zn6TemM03ovU= X-Gm-Gg: ASbGnctf9wJU05+j6CexYWLwB/JeOidP6ZXaiej9+lSGhkO8jnvtECnfdeDXK2Xv54x WZuFohrda/9U/thbsgc1k4sj2T2g9k8ZHaLOxkYa1RcpJSRaoie4V2ktu6Tp/6nNdUU8QZMXggs wo2D72sHPtO4BSwz2ol4wNQMhjtHnvE8tql5cNGs8sVs8DjXhzNvzsPRjvcAGFDmjhnXkyVnk2Z uvywuOpVmZdV77wl5CzTEifgx7/T/78gNh3m3RMS7gmHbJeK0MAKTsJ05rjQrTJHiJx3A22xngm 8HjW8rWBUKrBYptGjsKAs+dYn4AbkaasXKzPs7MqAuDyj39KWZs3Y7epCko4c/GA1VqZ1ubtER7 fz5d8ej87b9I= X-Google-Smtp-Source: AGHT+IHy8h8fAxy3bWPzzT5SaTNbVxExyHntma33sNuNiRQHREjvH7p9NCon9z5dH6T2S3oJqW8IpQ== X-Received: by 2002:a05:6830:6b4a:b0:73a:d3f6:8b22 with SMTP id 46e09a7af769-73e81090c46mr6599365a34.11.1753040351644; Sun, 20 Jul 2025 12:39:11 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 46e09a7af769-73e8354c8f1sm2296368a34.4.2025.07.20.12.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:39:11 -0700 (PDT) Date: Sun, 20 Jul 2025 14:39:09 -0500 From: Dan Carpenter To: AKASHI Takahiro , Michal Simek , Sudeep Holla Cc: Cristian Marussi , Linus Walleij , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 5/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The argument for PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS is supposed to be expressed in terms of ohms. But the pinctrl-scmi driver was implementing it the same as PIN_CONFIG_OUTPUT and writing either a zero or one to the pin. The SCMI protocol doesn't have an support configuration type so just delete this code instead of fixing it. Signed-off-by: Dan Carpenter --- drivers/pinctrl/pinctrl-scmi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c index d1f2f971cd96..fba0a3a2fc10 100644 --- a/drivers/pinctrl/pinctrl-scmi.c +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -262,9 +262,6 @@ static int pinctrl_scmi_map_pinconf_type(enum pin_confi= g_param param, case PIN_CONFIG_OUTPUT_ENABLE: *type =3D SCMI_PIN_OUTPUT_MODE; break; - case PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS: - *type =3D SCMI_PIN_OUTPUT_VALUE; - break; case PIN_CONFIG_POWER_SOURCE: *type =3D SCMI_PIN_POWER_SOURCE; break; --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 B2BD62253EC for ; Sun, 20 Jul 2025 19:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040351; cv=none; b=bm5uKb5ShJTjqgsfWhQANulnZA7IIRcryKgexZ/sIT6QzOA90m+Ra6kJhTGr+A7yBbU2dOjRtDoDzm9SsH3YMWzJGthzc/V/JRH0mdvDVjsxE8ab5rT5RkIZjcXJSmrpY7DUFS3LqkxBFpORI27wbbdMy2g/NceaZm/c/cjcbAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040351; c=relaxed/simple; bh=iDtvHuWeWWAvaDrc1D90AZ0sVF5gJEyOSaBvzWOZYBo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TDd+lvSdCNv01E/feUhNTywA8RCO+f4KllgeAyQb8U8k6duUcAVFWNvAtkK4XcwEdZXw4iKvzLaTkv/y/j3qPjNTGAYu3o3c3jXYyhsWfvtgbTpOG4Krpz2Wrgfu1CVcemfXVPiwZBHh8CtvdtnmWjRPmd3wvllTubSopf8Gc5w= 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=ct66e4xf; arc=none smtp.client-ip=209.85.210.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ct66e4xf" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-73e82d2ea1dso1498982a34.2 for ; Sun, 20 Jul 2025 12:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040348; x=1753645148; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TzWMDQiQhqKDucj4xDCvdrZWSeCpiJ1tZaaA5u2Est8=; b=ct66e4xfWyBumlCu9mdkTKmo7lpkX7txgrmlVNZocTJPFVh1tbH2hrQ3S/PXrb7DwT QGyA0vqLPgWwF4RnWlo3sqZQy5/bVeuuOKFFiMc/atQk3ceL8V3fvuBkMhJVTPZAhRCe AGt6WU6GLn8m2MjevlH931ZIwKjIVEF7bsXFkxR4i/NjAcCXSqHVBDZiQ/LbDR3Vh6PR 8Bt+9Ip0ENszW2iSzjkr7ssszsixlbxdSOu8TZpWTAbbD9o32EGg5wVdF0N3zBzLJCHT DAMTTkHaiKUNHnOZocAULkPweHjDu0oy717DVCPYceU6FViqGgffPzWwKzyNMtf3f+3q 95aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040348; x=1753645148; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TzWMDQiQhqKDucj4xDCvdrZWSeCpiJ1tZaaA5u2Est8=; b=oTHQG/bhkxH54UH7S5PmOEyx8ciZo3n/6KuSBJndul9Co1rbN79SeR4Vq1VvOrDAzK 1nfhOJjdRJl9OmXHERffVcwz3dZzKbgfWHTtmFS965lkGOxRTclVkgzjgeBtoNCt0t2O PeH0f9RYSIB6Ev8dsEdv2ukvZpgpBrH3T+rWQ+Ri7Km2D6D0CVPYK0LaQ7z5pEF3LqCh eRvaIKcHf3lxYXkGgMKVuPOT9bxbhXrU7fr7F5IYWuBCfSl5bQhxMtOmAImLKYdHUNqx fdSiZoG8DNEYBY/O9O5PJA7fBGkv0X67f3JrbuAZK3ZUTZuO7U75/3qoJ9Xhd8Nu999a X9EA== X-Forwarded-Encrypted: i=1; AJvYcCX/YJtrbtUWsRl9gnvyiqFYqMsDHIicmY9fuKSb8FMCcwZi9nUcLMm2ZaadQIJbqnEI/ewzLCB64AENw8k=@vger.kernel.org X-Gm-Message-State: AOJu0Yz90sMfhu6HRGuVmB34nqodggO0Vaa73OLbxSl3Zwyez7j2wzAH msdoA5YOm1ZS75XjcamXdpe/Li7ExbAcqcPaF1k8k0ExIB0jKIgDkP+v+BVEwcLd8+Q= X-Gm-Gg: ASbGncsBcICIvxE7C0640VAyQc2Ht2mItX9e3DwI7FKKLolWLh7dq7Ak+YSEsGoenfd U35mz3xybuLAe15ERmfSmcVqYWT2tjI76z11+yFiZQ0Bhp2KM3xLVpdJPABRWK5hWaIn/Ifb4l0 sLKm3bcOtcQICOZ8J2dQOlO5E+GpBMn0Sx/wmDvEl5gfd6hFJ5h2HKFefYAoT8dxOLjX6qtpDuy jz+tuJKVXWnoG3Ke+xaPhwX/mZ8EqJo1K5Ag4H10EN0lG/g1ta7F+XcCJJOp9V759INGYGYlvGT wpYvQL3upnPTFtM595Wlm12UQa0BdlJ6PrgKWq+DjhXTmwQ/ofKtDBXKJMxl8Zu6NlJ2n5mHWDT xOR/zu3bSEfA= X-Google-Smtp-Source: AGHT+IHG0eQajqarHbENrvaixxkoziriMrVyGz1oaBStUnyceEv9srArOzG9hJaXtUODGRIJ4Pm6Aw== X-Received: by 2002:a05:6808:3a15:b0:40a:533c:c9cb with SMTP id 5614622812f47-41d05654bcdmr12175951b6e.38.1753040347679; Sun, 20 Jul 2025 12:39:07 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 5614622812f47-41fd498c1cbsm1799638b6e.27.2025.07.20.12.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:39:06 -0700 (PDT) Date: Sun, 20 Jul 2025 14:39:04 -0500 From: Dan Carpenter To: AKASHI Takahiro , Michal Simek , Linus Walleij Cc: Sudeep Holla , Cristian Marussi , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC v2 6/7] pinctrl-scmi: Add GPIO support Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds GPIO support to the SCMI pin controller driver. It's an RFC patch because I'm not really sure how these are used and so I don't know how they should be configured via devicetree. I've labeled the places where I think devicetree configuration would go with a FIXME. This driver was based on work from Takahiro AKASHI. Signed-off-by: Dan Carpenter --- drivers/pinctrl/core.c | 8 +- drivers/pinctrl/pinctrl-scmi.c | 206 ++++++++++++++++++++++++++++++++- 2 files changed, 207 insertions(+), 7 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index bbcc6881b119..91882c68bcd5 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -947,7 +947,6 @@ EXPORT_SYMBOL_GPL(pinctrl_gpio_set_config); int pinctrl_gpio_get_config(struct gpio_chip *gc, unsigned int offset, uns= igned long *config) { struct pinctrl_gpio_range *range; - const struct pinconf_ops *ops; struct pinctrl_dev *pctldev; int ret, pin; =20 @@ -955,19 +954,16 @@ int pinctrl_gpio_get_config(struct gpio_chip *gc, uns= igned int offset, unsigned if (ret) return ret; =20 - ops =3D pctldev->desc->confops; - if (!ops || !ops->pin_config_get) - return -EINVAL; - mutex_lock(&pctldev->mutex); pin =3D gpio_to_pin(range, gc, offset); - ret =3D ops->pin_config_get(pctldev, pin, config); + ret =3D pin_config_get_for_pin(pctldev, pin, config); mutex_unlock(&pctldev->mutex); =20 if (ret) return ret; =20 *config =3D pinconf_to_config_argument(*config); + return 0; } EXPORT_SYMBOL_GPL(pinctrl_gpio_get_config); diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c index fba0a3a2fc10..9a947ced0df7 100644 --- a/drivers/pinctrl/pinctrl-scmi.c +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -6,6 +6,7 @@ * Copyright 2024 NXP */ =20 +#include #include #include #include @@ -16,6 +17,9 @@ #include #include =20 +#include + +#include #include #include #include @@ -42,6 +46,7 @@ struct scmi_pinctrl { unsigned int nr_functions; struct pinctrl_pin_desc *pins; unsigned int nr_pins; + struct gpio_chip *gc; }; =20 static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev) @@ -505,6 +510,197 @@ static int pinctrl_scmi_get_pins(struct scmi_pinctrl = *pmx, return 0; } =20 +static int pinctrl_gpio_get_direction(struct gpio_chip *gc, unsigned int o= ffset) +{ + unsigned long config; + bool in, out; + int ret; + + config =3D PIN_CONFIG_INPUT_ENABLE; + ret =3D pinctrl_gpio_get_config(gc, offset, &config); + if (ret) + return ret; + in =3D config; + + config =3D PIN_CONFIG_OUTPUT_ENABLE; + ret =3D pinctrl_gpio_get_config(gc, offset, &config); + if (ret) + return ret; + out =3D config; + + /* Consistency check - in theory both can be enabled! */ + if (in && !out) + return GPIO_LINE_DIRECTION_IN; + if (!in && out) + return GPIO_LINE_DIRECTION_OUT; + + return -EINVAL; +} + +static int pinctrl_gpio_direction_output_wrapper(struct gpio_chip *gc, + unsigned int offset, int val) +{ + return pinctrl_gpio_direction_output(gc, offset); +} + +static int pinctrl_gpio_get(struct gpio_chip *gc, unsigned int offset) +{ + unsigned long config; + int ret; + + config =3D PIN_CONFIG_INPUT_VALUE; + ret =3D pinctrl_gpio_get_config(gc, offset, &config); + if (ret) + return ret; + + return config; +} + +static void pinctrl_gpio_set(struct gpio_chip *gc, unsigned int offset, in= t val) +{ + unsigned long config; + + config =3D PIN_CONF_PACKED(PIN_CONFIG_OUTPUT, val); + pinctrl_gpio_set_config(gc, offset, config); +} + +static int pinctrl_gc_to_func(struct gpio_chip *gc) +{ + struct scmi_pinctrl *pmx =3D gpiochip_get_data(gc); + + return (gc - pmx->gc); +} + +static int gpio_add_pin_ranges(struct gpio_chip *gc) +{ + struct scmi_pinctrl *pmx =3D gpiochip_get_data(gc); + const char * const *p_groups; + unsigned int n_groups; + int func =3D pinctrl_gc_to_func(gc); + const unsigned int *pins; + unsigned int n_pins; + int offset =3D 0; + int group; + int ret; + + ret =3D pmx->pctl_desc.pmxops->get_function_groups(pmx->pctldev, func, &p= _groups, &n_groups); + if (ret) + return ret; + + // FIXME: fix the correct group from the device tree + for (group =3D 0; group < n_groups; group++) { + ret =3D pinctrl_get_group_pins(pmx->pctldev, p_groups[group], &pins, &n_= pins); + if (ret) + return ret; + + ret =3D gpiochip_add_pingroup_range(gc, pmx->pctldev, offset, p_groups[g= roup]); + if (ret) + return ret; + + offset +=3D n_pins; + } + + return 0; +} + +static int get_nr_pins_in_function(struct scmi_pinctrl *pmx, int func) +{ + const char * const *pin_groups; + unsigned int n_groups; + const unsigned int *pins; + unsigned int n_pins; + int total =3D 0; + int i, ret; + + // FIXME: get the correct number of gc.ngpio + // Find the right group from the device tree + ret =3D pmx->pctl_desc.pmxops->get_function_groups(pmx->pctldev, func, &p= in_groups, &n_groups); + if (ret) + return ret; + + for (i =3D 0; i < n_groups; i++) { + ret =3D pinctrl_get_group_pins(pmx->pctldev, pin_groups[i], &pins, &n_pi= ns); + if (ret) + return ret; + total +=3D n_pins; + } + + return total; +} + +static int register_scmi_pinctrl_gpio_handler(struct device *dev, struct s= cmi_pinctrl *pmx) +{ + struct fwnode_handle *gpio =3D NULL; + int ret, i; + + gpio =3D fwnode_get_named_child_node(dev->fwnode, "gpio"); + if (!gpio) + return 0; + + pmx->gc =3D devm_kcalloc(dev, pmx->nr_functions, sizeof(*pmx->gc), GFP_KE= RNEL); + if (!pmx->gc) + return -ENOMEM; + + for (i =3D 0; i < pmx->nr_functions; i++) { + const char *fn_name; + + ret =3D pinctrl_ops->is_gpio(pmx->ph, i, FUNCTION_TYPE); + if (ret < 0) + return ret; + if (ret =3D=3D false) + continue; + + ret =3D pinctrl_ops->name_get(pmx->ph, i, FUNCTION_TYPE, &fn_name); + if (ret) + return ret; + + pmx->gc[i].label =3D devm_kasprintf(dev, GFP_KERNEL, "%s", fn_name); + if (!pmx->gc[i].label) + return -ENOMEM; + + pmx->gc[i].owner =3D THIS_MODULE; + pmx->gc[i].get =3D pinctrl_gpio_get; + pmx->gc[i].set =3D pinctrl_gpio_set; + pmx->gc[i].get_direction =3D pinctrl_gpio_get_direction; + pmx->gc[i].direction_input =3D pinctrl_gpio_direction_input; + pmx->gc[i].direction_output =3D pinctrl_gpio_direction_output_wrapper; + pmx->gc[i].add_pin_ranges =3D gpio_add_pin_ranges; + + // FIXME: verify that this is correct + pmx->gc[i].can_sleep =3D true; + + ret =3D get_nr_pins_in_function(pmx, i); + if (ret < 0) + return ret; + pmx->gc[i].ngpio =3D ret; + + pmx->gc[i].parent =3D dev; + pmx->gc[i].base =3D -1; + } + + return 0; +} + +static int scmi_gpiochip_add_data(struct device *dev, struct scmi_pinctrl = *pmx) +{ + int ret; + int i; + + for (i =3D 0; i < pmx->nr_functions; i++) { + ret =3D pinctrl_ops->is_gpio(pmx->ph, i, FUNCTION_TYPE); + if (ret < 0) + return ret; + if (ret =3D=3D false) + continue; + + ret =3D devm_gpiochip_add_data(dev, &pmx->gc[i], pmx); + if (ret) + return ret; + } + + return 0; +} + static const char * const scmi_pinctrl_blocklist[] =3D { "fsl,imx95", "fsl,imx94", @@ -559,7 +755,15 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev) if (!pmx->functions) return -ENOMEM; =20 - return pinctrl_enable(pmx->pctldev); + ret =3D register_scmi_pinctrl_gpio_handler(dev, pmx); + if (ret) + return ret; + + ret =3D pinctrl_enable(pmx->pctldev); + if (ret) + return ret; + + return scmi_gpiochip_add_data(dev, pmx); } =20 static const struct scmi_device_id scmi_id_table[] =3D { --=20 2.47.2 From nobody Mon Oct 6 13:17:37 2025 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 74428230BC6 for ; Sun, 20 Jul 2025 19:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040360; cv=none; b=P24P95FLJ9PaoPylVqjm5JZwlJ+UgEtdJ+ooB3Yl5KA7UBE05Gc1NEa52wqsXT8ud7gXOFk95d1y3WtjzSWgxejgtb2pEh98FrAxas6br4Oo+m5HC3wn7hfH7osuBwVBKn+XBKALOvVvTbKt+JTelCouJ2ftZHJes+awWT4pYcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753040360; c=relaxed/simple; bh=pZLfQFK+iDMmtewhGnGO/1SaOgqUaWhiuxkwGFO9BrM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Xx3Rjd0nGymk5e8KJ4dLEy5uqOaEmTKbaC/KIcWnpyhFEr81WdiBp2F+jNYZnm2fwngnVHgB7w/YlqD93yyFMJRHmaAsmfh9I2l2gHnsgzbwznmSvJptESgVpZxDr+4HGVCrUzwicqPhvCddYx556FGwOKDBjyOQCNMOpbvWCkY= 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=E8F7ju5j; arc=none smtp.client-ip=209.85.167.177 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E8F7ju5j" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-40a55314d06so1096419b6e.1 for ; Sun, 20 Jul 2025 12:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753040356; x=1753645156; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7qmI92MLlIBwFrbUrwXTt/2+OJ1ahYjNp50nlsYvpao=; b=E8F7ju5jPsBgq+NLTWbjJBo1YcC8lwER0ZNuqFA7XBH7HBtRqeKDMvy2nIxcc3WlTe g6EF1SYLVCtE70FFkGebGztWpHWKFZJ6oSbNUpRP2/xPUeJmWtTujlZY5s+GhYKudEP6 w3vpbjeWj0Ux4XnSPk4BJKCJgyDGmc88y81dusWy3qAUxsUuZ8qTRkuDetO4Xt2XJkCc 9BXOInxidoNOY1X5kCR1jjlv/CycQ2XChWUZso+KIYG9QxhuUKG2rxR1bAki7++SvwSi Ygf+eg03dS8NMerFdzgFYSNoyXYU4g0iWmNdPAnh4Akkez2j9EtQfH8jFWp9fdm20oVJ z/Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753040356; x=1753645156; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7qmI92MLlIBwFrbUrwXTt/2+OJ1ahYjNp50nlsYvpao=; b=qHN56T4Zai6dTXIHcsewtb59N+RxPeqzetKWWPk+h0ULU1LEX4n9IAEErHwVPhsOfR XMVZ88RqhH7oP88HcdjIDyQnx2/JnPab0ZVBhjrs5LCOTFDuTXBlC0/WsEV63Kmt15zZ zWgx+AUhCIWC6DlPSgms2yOtkFxbv9bogscVN0DAz9jTl0ZfSt5s97yHzbKVWtCNAJg5 bHu8nAm+rDMy14nv+6ucZ1aNWU+j+3PNv/94Nwl9jsXZFIEHrDD/Ej2rLGI7D/Sb6iow Y/3XJV5aSXlFPoVZ5zv4ao5Jd8ORqb6JAGzrQJbU/n90QT5D9FcPSP37HA0TPtpEKa02 YnNw== X-Forwarded-Encrypted: i=1; AJvYcCXqa5ERGzQv8IFesnnK4C45B01D07c+6r6rXlGSDNUWQM4+UaMQCTiUVvwpAbuHt6xNDi57NNGUayS0Was=@vger.kernel.org X-Gm-Message-State: AOJu0YwGoUO8EZCTmn8KKDmIMCOkYycftiMJHz1B9GyWpvJd/VLf7z8v STstQY9ZzPjEi50nP8CpSGMb7Q3ZydBsmsxwDZDO1qNBeuocGaSnjSIzNMH0tDDqjfM= X-Gm-Gg: ASbGncsSsTgVihFcByy+RoH3PMwT8W1F3JRRRjBtcNieFw5gfXqxq7i2D1tgc6lyfRn 9CBxcuJ3UqGWChHnbHqRAKikmwYDDiu2h6UhE3oojpoVIZEnYucK6iV/yxK8llbJUpqYhmcDe1g li6LucEE+IACxqdCsZlgQgEVZjjFLy0yCIl8X+51sUoc3iKD/ocq0lI++Y8aid3GfKy2j1GCZ5m Gmw3TCKoFGpMKkiN9ObyvExhp41DjE1WhvZGIkLIkIaP9W7AE4C8lxm7ErIiGoPjNrTntsxm7WC kRZUgYU9wmHczfSTNd3VoB4nJOGSsEdjHOfr7+WmGdHLI4sXOgRhnfjrgly+IYSmkqSJREWPJgv p6S30joZeyOI= X-Google-Smtp-Source: AGHT+IHdyoPC+reGPO2928s8eY4VkIUqzrYH+Trvh6vGBElbMDvsyr9bGCnwye0zSGLIyzetZNTdGw== X-Received: by 2002:a05:6808:10c5:b0:3f8:3eeb:1192 with SMTP id 5614622812f47-41f98e4cbc4mr6102894b6e.27.1753040356463; Sun, 20 Jul 2025 12:39:16 -0700 (PDT) Received: from localhost ([2603:8080:b800:f700::1fec]) by smtp.gmail.com with UTF8SMTPSA id 5614622812f47-41fd19b3e74sm2025039b6e.15.2025.07.20.12.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jul 2025 12:39:15 -0700 (PDT) Date: Sun, 20 Jul 2025 14:39:13 -0500 From: Dan Carpenter To: AKASHI Takahiro , Michal Simek , Sudeep Holla Cc: Cristian Marussi , Linus Walleij , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 7/7] pinctrl-scmi: remove unused struct member Message-ID: <27a80ed0-65a3-4a41-994e-9c2d3bb76b54@sabinyo.mountain> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The ->nr_pins is not used so delete that. Signed-off-by: Dan Carpenter Reviewed-by: Cristian Marussi --- drivers/pinctrl/pinctrl-scmi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c index 9a947ced0df7..372fa67589fb 100644 --- a/drivers/pinctrl/pinctrl-scmi.c +++ b/drivers/pinctrl/pinctrl-scmi.c @@ -45,7 +45,6 @@ struct scmi_pinctrl { struct pinfunction *functions; unsigned int nr_functions; struct pinctrl_pin_desc *pins; - unsigned int nr_pins; struct gpio_chip *gc; }; =20 --=20 2.47.2