From patchwork Wed Jan 31 02:36:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 126304 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp291716ljc; Tue, 30 Jan 2018 18:36:38 -0800 (PST) X-Google-Smtp-Source: AH8x224OO8JTz63fkbt59PvxptlJPKVxe9jhMKAzCo5ClL6zKUhWic/bYN0Lcn5EF+GZ41YBXdB3 X-Received: by 10.99.191.78 with SMTP id i14mr26405880pgo.246.1517366198468; Tue, 30 Jan 2018 18:36:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517366198; cv=none; d=google.com; s=arc-20160816; b=i0k+r8RWfQjmcT3OfnuOuFmCloUiItvz0eWE9UyAZ1R4BXizM0VGujvzeMicVaaagO ZVdA+cmgk9wWfcQQ37GYkNIrLPJm0x1olgnAWvgk1hi7UszLCLvKafGI6siLTZCucE4L RC5GdVA1VbUuq0v0eetKCuaYoM9b4ErKRW4j6XUz8kOPLaCgXcEC65CoTP/ureYWfIwa HQF+MtfoFxIxm1u1K+YKqINTyOpvWwwo7QcfzzAbYpP8P8grjYT6rv7wS+E8AbES6DJC vCvaJB0imkUhR0PPThE5e6Ku8BXxXnNUnI1FSdhXpH2iL3j8atwb4MNvyC1pYlt2L/1w 3q7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=+YGe5AfQMSsdI2+cZp6bKM76ra175J+uy5clIruW6EY=; b=yDii9ZdBC+YWs/rYc1/vgEVcLly9vX2XXZIpwXwQ8t20vTXRQHzVbFhtfnxdQ+vatk s4wXfHU0mGVooDQkpB58kcqBktCtPLGnccF/Wp7B/ZBHGMzkqFfB99yeXbkO24yeS6Ti zAAwJCAFlxwIiEeUIfN0eIgspnThH1/o7NaE/2c32XobxrEbKqxJtOFV4Tb/C7aLs5Gf th0LBl/M4KLhsWLxp2TvV1xgjzyHy29dVlSzc6Kph3R55RMy+FbGW6zhxICZm4pYOxBn qQH2cjDBwGWvHhFOSrgeKLvE6S/YFXPzulPRjRYJSxpykJEKF3DMzjFCjKTxmZwttXaP iPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QAjVXHfd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si797542pfk.153.2018.01.30.18.36.37; Tue, 30 Jan 2018 18:36:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QAjVXHfd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753474AbeAaCgg (ORCPT + 28 others); Tue, 30 Jan 2018 21:36:36 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:46463 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753437AbeAaCgb (ORCPT ); Tue, 30 Jan 2018 21:36:31 -0500 Received: by mail-pf0-f193.google.com with SMTP id y5so11088526pff.13 for ; Tue, 30 Jan 2018 18:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+YGe5AfQMSsdI2+cZp6bKM76ra175J+uy5clIruW6EY=; b=QAjVXHfdZgv4bFCOMV6Bw9cY5kHLbx20wKLfHLq7lKyGrd5VBpKyRyaQI+wXq5DRgW voBDUeEM3k9eDQgycyl973iaIljRFep+Qa4YeZmVOzj+8fiXTmaql9CScNNqH6I3bJdK cFox6D2FVrlFGB1XiKDRxU/6oHwYhen4ELRI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+YGe5AfQMSsdI2+cZp6bKM76ra175J+uy5clIruW6EY=; b=uAf0sNhn6hzWLZnFVv+SfE4KGaaDwqm1beG/LhWWcGVgcjGrIcr6nOHGaTm5/ZgzCI EfXm4/mTzjhRawYoEC1jyQToLoMyNbBtc581fkJj3IQpFYu5trntNEPrk3oGhhQUOpqc wEV3/QEM/UIFfxYefDWdT8Jdi9ckU2jE+5ddJeMWV4EKasXxjItMuSq7J3VyAl5sZjpl WXHF4mBqHUOM498E315cZLEiZ97wsCPwMyGAai/j0ZgJ3eoh+Ssh2AQFcayeIDHVF+QZ fr8n+12ntnqyzI/TrKU5M1xuHqDcG+F2No4yYhrSOiTrnc1wJm51s4J9BCSx8fddnorC a+Ig== X-Gm-Message-State: AKwxytfKesLraiqHVo2FeHCWDKlAicwiUcWyefkakSg50geWY44Mndtz kn8syevifMBb6KDEOYICWkvNmA== X-Received: by 2002:a17:902:8f90:: with SMTP id z16-v6mr27613005plo.370.1517366190205; Tue, 30 Jan 2018 18:36:30 -0800 (PST) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id z2sm24126828pgz.22.2018.01.30.18.36.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jan 2018 18:36:29 -0800 (PST) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Russell King - ARM Linux , devicetree-spec@vger.kernel.org, Pantelis Antoniou , Linus Walleij , Mark Brown Subject: [PATCH v5 2/4] of: Support parsing phandle argument lists through a nexus node Date: Tue, 30 Jan 2018 18:36:16 -0800 Message-Id: <20180131023618.14292-3-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.14.GIT In-Reply-To: <20180131023618.14292-1-stephen.boyd@linaro.org> References: <20180131023618.14292-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Platforms like 96boards have a standardized connector/expansion slot that exposes signals like GPIOs to expansion boards in an SoC agnostic way. We'd like the DT overlays for the expansion boards to be written once without knowledge of the SoC on the other side of the connector. This avoids the unscalable combinatorial explosion of a different DT overlay for each expansion board and SoC pair. We need a way to describe the GPIOs routed through the connector in an SoC agnostic way. Let's introduce nexus property parsing into the OF core to do this. This is largely based on the interrupt nexus support we already have. This allows us to remap a phandle list in a consumer node (e.g. reset-gpios) through a connector in a generic way (e.g. via gpio-map). Do this in a generic routine so that we can remap any sort of variable length phandle list. Taking GPIOs as an example, the connector would be a GPIO nexus, supporting the remapping of a GPIO specifier space to multiple GPIO providers on the SoC. DT would look as shown below, where 'soc_gpio1' and 'soc_gpio2' are inside the SoC, 'connector' is an expansion port where boards can be plugged in, and 'expansion_device' is a device on the expansion board. soc { soc_gpio1: gpio-controller1 { #gpio-cells = <2>; }; soc_gpio2: gpio-controller2 { #gpio-cells = <2>; }; }; connector: connector { #gpio-cells = <2>; gpio-map = <0 0 &soc_gpio1 1 0>, <1 0 &soc_gpio2 4 0>, <2 0 &soc_gpio1 3 0>, <3 0 &soc_gpio2 2 0>; gpio-map-mask = <0xf 0x0>; gpio-map-pass-thru = <0x0 0x1> }; expansion_device { reset-gpios = <&connector 2 GPIO_ACTIVE_LOW>; }; The GPIO core would use of_parse_phandle_with_args_map() instead of of_parse_phandle_with_args() and arrive at the same type of result, a phandle and argument list. The difference is that the phandle and arguments will be remapped through the nexus node to the underlying SoC GPIO controller node. In the example above, we would remap 'reset-gpios' from <&connector 2 GPIO_ACTIVE_LOW> to <&soc_gpio1 3 GPIO_ACTIVE_LOW>. Cc: Pantelis Antoniou Cc: Linus Walleij Cc: Mark Brown Signed-off-by: Stephen Boyd --- drivers/of/base.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 12 ++++ 2 files changed, 196 insertions(+) -- 2.14.GIT diff --git a/drivers/of/base.c b/drivers/of/base.c index 26618ba8f92a..aab0fc9a70d7 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1261,6 +1261,190 @@ int of_parse_phandle_with_args(const struct device_node *np, const char *list_na } EXPORT_SYMBOL(of_parse_phandle_with_args); +/** + * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @stem_name: stem of property names that specify phandles' arguments count + * @index: index of a phandle to parse out + * @out_args: optional pointer to output arguments structure (will be filled) + * + * This function is useful to parse lists of phandles and their arguments. + * Returns 0 on success and fills out_args, on error returns appropriate errno + * value. The difference between this function and of_parse_phandle_with_args() + * is that this API remaps a phandle if the node the phandle points to has + * a <@stem_name>-map property. + * + * Caller is responsible to call of_node_put() on the returned out_args->np + * pointer. + * + * Example: + * + * phandle1: node1 { + * #list-cells = <2>; + * } + * + * phandle2: node2 { + * #list-cells = <1>; + * } + * + * phandle3: node3 { + * #list-cells = <1>; + * list-map = <0 &phandle2 3>, + * <1 &phandle2 2>, + * <2 &phandle1 5 1>; + * list-map-mask = <0x3>; + * }; + * + * node4 { + * list = <&phandle1 1 2 &phandle3 0>; + * } + * + * To get a device_node of the `node2' node you may call this: + * of_parse_phandle_with_args(node4, "list", "list", 1, &args); + */ +int of_parse_phandle_with_args_map(const struct device_node *np, + const char *list_name, + const char *stem_name, + int index, struct of_phandle_args *out_args) +{ + char *cells_name, *map_name = NULL, *mask_name = NULL; + char *pass_name = NULL; + struct device_node *cur, *new = NULL; + const __be32 *map, *mask, *pass; + static const __be32 dummy_mask[] = { [0 ... MAX_PHANDLE_ARGS] = ~0 }; + static const __be32 dummy_pass[] = { [0 ... MAX_PHANDLE_ARGS] = 0 }; + __be32 initial_match_array[MAX_PHANDLE_ARGS]; + const __be32 *match_array = initial_match_array; + int i, ret, map_len, match; + u32 list_size, new_size; + + if (index < 0) + return -EINVAL; + + cells_name = kasprintf(GFP_KERNEL, "#%s-cells", stem_name); + if (!cells_name) + return -ENOMEM; + + ret = -ENOMEM; + map_name = kasprintf(GFP_KERNEL, "%s-map", stem_name); + if (!map_name) + goto free; + + mask_name = kasprintf(GFP_KERNEL, "%s-map-mask", stem_name); + if (!mask_name) + goto free; + + pass_name = kasprintf(GFP_KERNEL, "%s-map-pass-thru", stem_name); + if (!pass_name) + goto free; + + ret = __of_parse_phandle_with_args(np, list_name, cells_name, 0, index, + out_args); + if (ret) + goto free; + + /* Get the #-cells property */ + cur = out_args->np; + ret = of_property_read_u32(cur, cells_name, &list_size); + if (ret < 0) + goto put; + + /* Precalculate the match array - this simplifies match loop */ + for (i = 0; i < list_size; i++) + initial_match_array[i] = cpu_to_be32(out_args->args[i]); + + ret = -EINVAL; + while (cur) { + /* Get the -map property */ + map = of_get_property(cur, map_name, &map_len); + if (!map) { + ret = 0; + goto free; + } + map_len /= sizeof(u32); + + /* Get the -map-mask property (optional) */ + mask = of_get_property(cur, mask_name, NULL); + if (!mask) + mask = dummy_mask; + /* Iterate through -map property */ + match = 0; + while (map_len > (list_size + 1) && !match) { + /* Compare specifiers */ + match = 1; + for (i = 0; i < list_size; i++, map_len--) + match &= !((match_array[i] ^ *map++) & mask[i]); + + of_node_put(new); + new = of_find_node_by_phandle(be32_to_cpup(map)); + map++; + map_len--; + + /* Check if not found */ + if (!new) + goto put; + + if (!of_device_is_available(new)) + match = 0; + + ret = of_property_read_u32(new, cells_name, &new_size); + if (ret) + goto put; + + /* Check for malformed properties */ + if (WARN_ON(new_size > MAX_PHANDLE_ARGS)) + goto put; + if (map_len < new_size) + goto put; + + /* Move forward by new node's #-cells amount */ + map += new_size; + map_len -= new_size; + } + if (!match) + goto put; + + /* Get the -map-pass-thru property (optional) */ + pass = of_get_property(cur, pass_name, NULL); + if (!pass) + pass = dummy_pass; + + /* + * Successfully parsed a -map translation; copy new + * specifier into the out_args structure, keeping the + * bits specified in -map-pass-thru. + */ + match_array = map - new_size; + for (i = 0; i < new_size; i++) { + __be32 val = *(map - new_size + i); + + if (i < list_size) { + val &= ~pass[i]; + val |= cpu_to_be32(out_args->args[i]) & pass[i]; + } + + out_args->args[i] = be32_to_cpu(val); + } + out_args->args_count = list_size = new_size; + /* Iterate again with new provider */ + out_args->np = new; + of_node_put(cur); + cur = new; + } +put: + of_node_put(cur); + of_node_put(new); +free: + kfree(mask_name); + kfree(map_name); + kfree(cells_name); + kfree(pass_name); + + return ret; +} +EXPORT_SYMBOL(of_parse_phandle_with_args_map); + /** * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list * @np: pointer to a device tree node containing a list diff --git a/include/linux/of.h b/include/linux/of.h index d3dea1d1e3a9..1bdf10118134 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -367,6 +367,9 @@ extern struct device_node *of_parse_phandle(const struct device_node *np, extern int of_parse_phandle_with_args(const struct device_node *np, const char *list_name, const char *cells_name, int index, struct of_phandle_args *out_args); +extern int of_parse_phandle_with_args_map(const struct device_node *np, + const char *list_name, const char *stem_name, int index, + struct of_phandle_args *out_args); extern int of_parse_phandle_with_fixed_args(const struct device_node *np, const char *list_name, int cells_count, int index, struct of_phandle_args *out_args); @@ -817,6 +820,15 @@ static inline int of_parse_phandle_with_args(const struct device_node *np, return -ENOSYS; } +static inline int of_parse_phandle_with_args_map(const struct device_node *np, + const char *list_name, + const char *stem_name, + int index, + struct of_phandle_args *out_args) +{ + return -ENOSYS; +} + static inline int of_parse_phandle_with_fixed_args(const struct device_node *np, const char *list_name, int cells_count, int index, struct of_phandle_args *out_args) From patchwork Wed Jan 31 02:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 126305 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp291789ljc; Tue, 30 Jan 2018 18:36:46 -0800 (PST) X-Google-Smtp-Source: AH8x224vToMesEPmlGB4FNLN0RAmoNku+N3CV6IaKcENtU19zORokLl7Wzox3r76UIGKG/yr4zYe X-Received: by 2002:a17:902:b43:: with SMTP id 61-v6mr27447106plq.127.1517366206110; Tue, 30 Jan 2018 18:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517366206; cv=none; d=google.com; s=arc-20160816; b=e0TLUhD43ZlNNoJWsTo0zYfhd6i6WZqa+q6cG1+xg0kjR1ExYgAaPBsO0zRba7VLWO iuvzAfPD4U8BbsXM5N9jSutUnQViU3baSFJTnZdf7qYKhfFMmpsljNEYY64T2q/1GcLC GE1VtdmbuAdm2h52AmzT1WPSXHROWguHVaMpoeHl5wRahnKC5RUzRZZJdAh53MYl/iVc hiGUtpZ0duHHKe4cIhZmeMMrp5jCr9v47uZlmvL1HI4rhMyix165UUJlVARLdIqtlghl VJJyWECRr5XcaMfKmHTyz4MKyuOpvy9RARwzYTtF7mo+aCow7w3O8Z+Fdz68jL010i6U YgWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=xo1pIR1xvBvDy/Pi7Idp95Txk3h0Vvmdq3pnieCBYpI=; b=ZBQdVNNxCrGuhN/ehndPiVoGeNZT90XDi5j5+WsJ2rhj36qqyxWUG3NCgp0F0xR77I lZaDEa0z2j2SkJJagaDrGIUz2QEp6kOkNS/zVj+LXQQfy31cgJgwSJSYkXf974e72e72 oPxCljOR6qWlgyfpFGKEwunAHzwSqwY4cN2ASbelbYYnGftQndjDZmMyvmgdfQMYDCI3 aUBYomz05EmTwJMp5HhVvUsCfhxnYkXBLtQuiFNPRdEu8sfqcHQX/sBJTQwW5bzny8E9 9yITzrhaX4WbkNhLdZwFo77Tj5uyPCkoPEYUt1EEs/o99yHeMUYb6Aujm6bi8jcH/yek DrOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKFCnZal; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si2360775pln.340.2018.01.30.18.36.45; Tue, 30 Jan 2018 18:36:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKFCnZal; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932091AbeAaCgo (ORCPT + 28 others); Tue, 30 Jan 2018 21:36:44 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:44583 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbeAaCgf (ORCPT ); Tue, 30 Jan 2018 21:36:35 -0500 Received: by mail-pf0-f194.google.com with SMTP id 17so9652708pfw.11 for ; Tue, 30 Jan 2018 18:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xo1pIR1xvBvDy/Pi7Idp95Txk3h0Vvmdq3pnieCBYpI=; b=bKFCnZal/oAqamBCP0C2MwVt66KKRCliQ9Iv0/elfCkdMPue+xMBjNOrOctj4RDwni 9zwr5qmtooLQIJgNi7ejdkcDLijAB1VCe0X0SfHXJHk/6FeexYsWvh01cTxASFv6mwTy LL6tP1RCw9+KO+9KKKGdXJQ2FOe28QNft4oQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xo1pIR1xvBvDy/Pi7Idp95Txk3h0Vvmdq3pnieCBYpI=; b=bFVyeSz+2q5kVaEARKrSXoGeqqWqV5Eli0e3YccNEJ3+KcSB+sMfSJaxTaCPt4vu5D 4V/G5tDSxzc/Adj/LpqgbTVDz/HDZCYVWzD+a1YT8KRhc6O1whWiQfceK9smkDlonVAE 064m533YeCHZqhO5GN4Tou0Gtbq2rL1et4AL2Ebv96n4PeKsR5QuyVjLzbjVPYo1Dsiq HL/JJ8XmQI+F5CeK59HoiRSHv0DpHqMoocYcsX+OaWQ6arxPTla+bThoGNXUQyFY+caM F2rozoUcKNB/kmN5xIh+WKzc32+GlCTUsUc83/4RiF1+k7KQY7eDUc8/gKHoZT05VN87 mG1g== X-Gm-Message-State: AKwxytdRmVFr9pRAGjaO4wQCiYJiPsRaZOx+c/3dXm2dV/lVhqEkE/Fi vUcAklcoJNwcMQmIFve4GEvUhQ== X-Received: by 2002:a17:902:42a5:: with SMTP id h34-v6mr26274614pld.265.1517366194486; Tue, 30 Jan 2018 18:36:34 -0800 (PST) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id z2sm24126828pgz.22.2018.01.30.18.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jan 2018 18:36:34 -0800 (PST) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Russell King - ARM Linux , devicetree-spec@vger.kernel.org, Pantelis Antoniou , Mark Brown Subject: [PATCH v5 4/4] gpio: Support gpio nexus dt bindings Date: Tue, 30 Jan 2018 18:36:18 -0800 Message-Id: <20180131023618.14292-5-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.14.GIT In-Reply-To: <20180131023618.14292-1-stephen.boyd@linaro.org> References: <20180131023618.14292-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Platforms like 96boards have a standardized connector/expansion slot that exposes signals like GPIOs to expansion boards in an SoC agnostic way. We'd like the DT overlays for the expansion boards to be written once without knowledge of the SoC on the other side of the connector. This avoids the unscalable combinatorial explosion of a different DT overlay for each expansion board and SoC pair. Now that we have nexus support in the OF core let's change the function call here that parses the phandle lists of gpios to use the nexus variant. This allows us to remap phandles and their arguments through any number of nexus nodes and end up with the actual gpio provider being used. Cc: Pantelis Antoniou Acked-by: Linus Walleij Cc: Mark Brown Signed-off-by: Stephen Boyd --- drivers/gpio/gpiolib-of.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.GIT diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 72a0695d2ac3..09217a87e7ff 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -75,8 +75,8 @@ struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np, struct gpio_desc *desc; int ret; - ret = of_parse_phandle_with_args(np, propname, "#gpio-cells", index, - &gpiospec); + ret = of_parse_phandle_with_args_map(np, propname, "gpio", index, + &gpiospec); if (ret) { pr_debug("%s: can't parse '%s' property of node '%pOF[%d]'\n", __func__, propname, np, index);