From patchwork Fri Jan 9 15:43:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Soren Brinkmann X-Patchwork-Id: 5601071 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B1FB0C058D for ; Fri, 9 Jan 2015 15:45:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C14692051C for ; Fri, 9 Jan 2015 15:45:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3D4D20483 for ; Fri, 9 Jan 2015 15:45:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y9bkr-0001Sw-8a; Fri, 09 Jan 2015 15:45:41 +0000 Received: from mail-ob0-x230.google.com ([2607:f8b0:4003:c01::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y9bjl-0007vi-UV; Fri, 09 Jan 2015 15:44:34 +0000 Received: by mail-ob0-f176.google.com with SMTP id vb8so13672213obc.7; Fri, 09 Jan 2015 07:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=qnv9uRIK6fUXq9md4/Iaj2iWsJra2B4SVKk+jtaehFk=; b=eezul5Y6eRSXem25BzNokWD28qxqQIgSJiSbYbQlInrXWM+7QOPQbQ9jzVsbw7CTN/ gGj9jjlA1tnTDXBuCx2GlDyR9LHid67G85A/WrXRwkA+wnE/n2diBgF0jIvIfSc6iUB9 M1N+ntL4EFwb5odHb55OjPdf5iadZLw+3rZVCFWsqYtI7wlcOfT7YgQSKpwKmvb2DZup SKQeOiIngdHvirYE1+ty8AmZKTa7HbGO4f0wytX+8Vw20oQC0+x08qx+P3r7gzfswaWy xuKvbEUx8WCltS+F3pHYDmaqmZu7uMdv76ARQ9rTDI58pJD9mmaaU9+vYGz8r3kLTGg4 WCXA== X-Received: by 10.202.200.215 with SMTP id y206mr8934309oif.123.1420818252586; Fri, 09 Jan 2015 07:44:12 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id e143sm4533456oic.7.2015.01.09.07.44.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jan 2015 07:44:11 -0800 (PST) From: Soren Brinkmann To: Linus Walleij , Rob Herring , Pawel Moll , Mark Rutland Subject: [PATCH v4 1/7] pinctrl: pinconf-generic: Infer map type from DT property Date: Fri, 9 Jan 2015 07:43:45 -0800 Message-Id: <1420818231-13451-2-git-send-email-soren.brinkmann@xilinx.com> X-Mailer: git-send-email 2.2.1.1.gb42cc81 In-Reply-To: <1420818231-13451-1-git-send-email-soren.brinkmann@xilinx.com> References: <1420818231-13451-1-git-send-email-soren.brinkmann@xilinx.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150109_074434_077373_477F3B96 X-CRM114-Status: GOOD ( 15.04 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, Ian Campbell , Laurent Pinchart , Heiko Stuebner , linux-sh@vger.kernel.org, Bjorn Andersson , Michal Simek , linux-kernel@vger.kernel.org, Beniamino Galvani , linux-rockchip@lists.infradead.org, =?UTF-8?q?S=C3=B6ren=20Brinkmann?= , "Ivan T. Ivanov" , Kumar Gala , Grant Likely , linux-arm-kernel@lists.infradead.org, Alessandro Rubini X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the new 'groups' property, the DT parser can infer the map type from the fact whether 'pins' or 'groups' is used to specify the pin group to work on. To maintain backwards compatibitliy with current usage of the DT binding, this is only done when PIN_MAP_TYPE_INVALID is passed to the parsing function as type. Also, a new helper 'pinconf_generic_dt_node_to_map_all()' is introduced, which can be used by drivers as generic callback for dt_node_to_map() to leverage the new feature. Signed-off-by: Soren Brinkmann Tested-by: Andreas Färber --- Changes since v2: - rename dt_pin_specifier to subnode_target_type - add additional comment in header file explaining passing an invalid map type - mention map_all() helper in commit message Changes since RFC v2: - none --- drivers/pinctrl/pinconf-generic.c | 17 ++++++++++++++--- include/linux/pinctrl/pinconf-generic.h | 11 +++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c index f78b416d7984..21b3d90ebb2d 100644 --- a/drivers/pinctrl/pinconf-generic.c +++ b/drivers/pinctrl/pinconf-generic.c @@ -264,6 +264,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, unsigned reserve; struct property *prop; const char *group; + const char *subnode_target_type = "pins"; ret = of_property_read_string(np, "function", &function); if (ret < 0) { @@ -284,10 +285,20 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, reserve++; if (num_configs) reserve++; + ret = of_property_count_strings(np, "pins"); if (ret < 0) { - dev_err(dev, "could not parse property pins\n"); - goto exit; + ret = of_property_count_strings(np, "groups"); + if (ret < 0) { + dev_err(dev, "could not parse property pins/groups\n"); + goto exit; + } + if (type == PIN_MAP_TYPE_INVALID) + type = PIN_MAP_TYPE_CONFIGS_GROUP; + subnode_target_type = "groups"; + } else { + if (type == PIN_MAP_TYPE_INVALID) + type = PIN_MAP_TYPE_CONFIGS_PIN; } reserve *= ret; @@ -296,7 +307,7 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev *pctldev, if (ret < 0) goto exit; - of_property_for_each_string(np, "pins", prop, group) { + of_property_for_each_string(np, subnode_target_type, prop, group) { if (function) { ret = pinctrl_utils_add_map_mux(pctldev, map, reserved_maps, num_maps, group, diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h index d578a60eff23..83c89f5ab705 100644 --- a/include/linux/pinctrl/pinconf-generic.h +++ b/include/linux/pinctrl/pinconf-generic.h @@ -174,6 +174,17 @@ static inline int pinconf_generic_dt_node_to_map_pin( PIN_MAP_TYPE_CONFIGS_PIN); } +static inline int pinconf_generic_dt_node_to_map_all( + struct pinctrl_dev *pctldev, struct device_node *np_config, + struct pinctrl_map **map, unsigned *num_maps) +{ + /* + * passing the type as PIN_MAP_TYPE_INVALID causes the underlying parser + * to infer the map type from the DT properties used. + */ + return pinconf_generic_dt_node_to_map(pctldev, np_config, map, num_maps, + PIN_MAP_TYPE_INVALID); +} #endif #endif /* CONFIG_GENERIC_PINCONF */