Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1214546lqo; Sat, 11 May 2024 12:29:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMfW7xIdm8cLp+l0DNCX7KCaraAo+xp2SVYwLiT/rqEAQEm+Z7HoieW72KHfc7y8if9EvjLB/PQcim50Wyp4PNKZ9v0G937i07gdW4Cg== X-Google-Smtp-Source: AGHT+IGn41TvmhW5FS+igvDIO5an3p+nVYYb2U9KWQ+w/DGnDT1lLyKerZyuUtVGXYXw6yW22hZv X-Received: by 2002:a17:902:8bc6:b0:1ee:1dbe:74f4 with SMTP id d9443c01a7336-1ef43e231ecmr56458455ad.29.1715455781396; Sat, 11 May 2024 12:29:41 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c038a17si59235345ad.369.2024.05.11.12.29.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 12:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176701-linux.lists.archive=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; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-176701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 0AAEE281811 for ; Sat, 11 May 2024 19:29:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF5E41DA53; Sat, 11 May 2024 19:29:33 +0000 (UTC) Received: from fgw20-7.mail.saunalahti.fi (fgw20-7.mail.saunalahti.fi [62.142.5.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4B011CD0C for ; Sat, 11 May 2024 19:29:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715455773; cv=none; b=rt5trtj79DCqPch/atpGJCeYS8byWWj1mNSWigM0d5K2MctPG3eAahU+4bEpN7UozCGKx697KFU4zQPBGWMG1zroT3CaGOaP3opzBCLUBTsL3pgt9VUwbDdoKK2KWGqX2ElW6htAdPY4POJm//oRz8lMtEyCmg1Ie8WDBEv2HuI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715455773; c=relaxed/simple; bh=4lsE2Se8vXaMMEIsPzHa9RIlcRpOCsASJLMGgVYbVfc=; h=From:Date:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nUbNvZ1oz+Z01r8gKEXjHYemeMxnqp/avPNDA5KuERuuAeyj459HjKkbPZ19aYqNlgQvrEq3kn32Z0mHfSJBY2umaXEfECyhVaVghg6TeKaIhvrLsnQyI40X8PMWa6d9J6eW5Usobc+3m0wWtlH7Wegquy9dzy606j0VSeCQlPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-25-208.elisa-laajakaista.fi [88.113.25.208]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id c822eb82-0fcc-11ef-abf4-005056bdd08f; Sat, 11 May 2024 22:29:28 +0300 (EEST) From: Andy Shevchenko Date: Sat, 11 May 2024 22:29:27 +0300 To: "Peng Fan (OSS)" Cc: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Linus Walleij , Dong Aisheng , Jacky Bai , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-gpio@vger.kernel.org, Peng Fan Subject: Re: [PATCH v4 3/3] pinctrl: imx: support SCMI pinctrl protocol for i.MX95 Message-ID: References: <20240505-pinctrl-scmi-oem-v3-v4-0-7c99f989e9ba@nxp.com> <20240505-pinctrl-scmi-oem-v3-v4-3-7c99f989e9ba@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240505-pinctrl-scmi-oem-v3-v4-3-7c99f989e9ba@nxp.com> Sun, May 05, 2024 at 11:47:19AM +0800, Peng Fan (OSS) kirjoitti: > From: Peng Fan > > The generic pinctrl-scmi.c driver could not be used for i.MX95 because > i.MX95 SCMI firmware not supports functions, groups or generic > 'Pin Configuration Type and Enumerations' listed in SCMI Specification. > > i.MX95 System Control Management Interface(SCMI) firmware only supports > below pin configuration types which are OEM specific types: > 192: PIN MUX > 193: PIN CONF > 194: DAISY ID > 195: DAISY VAL > > To support Linux generic pinctrl properties(pinmux, bias-pull-[up, > down], and etc), need extract the value from the property and map > them to the format that i.MX95 SCMI pinctrl protocol understands, > so add this driver. .. > +struct imx_pin_group { > + struct pingroup data; > +}; I don't see the necessity of having this wrapper structure. Can't you simply use struct pingroup directly? .. > +static int scmi_pinctrl_imx_probe(struct scmi_device *sdev) > +{ > + int ret; > + struct device *dev = &sdev->dev; > + struct scmi_pinctrl_imx *pmx; > + const struct scmi_handle *handle; > + struct scmi_protocol_handle *ph; > + struct device_node *np __free(device_node) = of_find_node_by_path("/"); > + const struct scmi_pinctrl_proto_ops *pinctrl_ops; > + if (!sdev->handle) > + return -EINVAL; When this conditional can be true? > + if (!of_match_node(scmi_pinctrl_imx_allowlist, np)) > + return -ENODEV; > + handle = sdev->handle; It's even better to assign first and then check if the above check is needed at all. > + pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL, &ph); > + if (IS_ERR(pinctrl_ops)) > + return PTR_ERR(pinctrl_ops); > + > + pmx = devm_kzalloc(dev, sizeof(*pmx), GFP_KERNEL); > + if (!pmx) > + return -ENOMEM; > + > + pmx->ph = ph; > + pmx->ops = pinctrl_ops; > + > + pmx->dev = dev; > + pmx->pctl_desc.name = DRV_NAME; > + pmx->pctl_desc.owner = THIS_MODULE; > + pmx->pctl_desc.pctlops = &pinctrl_scmi_imx_pinctrl_ops; > + pmx->pctl_desc.pmxops = &pinctrl_scmi_imx_pinmux_ops; > + pmx->pctl_desc.confops = &pinctrl_scmi_imx_pinconf_ops; > + > + ret = scmi_pinctrl_imx_get_pins(pmx, &pmx->pctl_desc); > + if (ret) > + return ret; > + > + ret = scmi_pinctrl_imx_probe_dt(sdev, pmx); > + if (ret) > + return ret; > + > + ret = devm_pinctrl_register_and_init(dev, &pmx->pctl_desc, pmx, > + &pmx->pctldev); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to register pinctrl\n"); > + > + return pinctrl_enable(pmx->pctldev); > +} -- With Best Regards, Andy Shevchenko