Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp202313ybs; Tue, 26 May 2020 07:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD4LvGCpSMnWPXoi4vLMDYYNB/q+aSGR6TYOh7bzBig2AhZpaMB2i6r3fVj4gLohDb6D4E X-Received: by 2002:a17:906:410a:: with SMTP id j10mr1281143ejk.378.1590502355504; Tue, 26 May 2020 07:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590502355; cv=none; d=google.com; s=arc-20160816; b=B4onh7v77R7oNuhApvJYzbD/fpPWzJm79yIpFJCUfs0x3PizSUc2uRylxSGZ5kzmZm Otu8wqc1ziguINY1FvLZgOvQdSdbGSleBxUeyyTq4893Kqu8j99+pqcd85d+HogYMx+h xgOSDPHQAII0FCm7xNGez0K+u9MX9aVpQbz7USqt/0Kcbm9FpYFuJOya5omK1bY4cwYy NjR69kGOXYERJHgT/JVNnxaU9cLtBunS9H+V9/ixjZvl5ouhfTgMgkmWaNnDZv5NGXiL 3kBYXkzK6lOj7Id3Q71BUjBAGgUZp24aEUwQGjZudqKPq7vOSziuCw9sjQq4/LfzxzW0 eUpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=tjIxLurGAZl3ClrqkcDTUozxTD1nDew3Brnlr2xXLqY=; b=S8UInN+WynJKxMZjANX+ePrn6AnN+pMwnjHqra4aHTuzRMbhmOYXAvYdi95HkJ3fdQ Ut/bZmxNMXXy7OK+muy3X40f6Jl0GY4vPRw0BeqFHYV6YW33wE4+aYNHELoqpmzIR2vA cUmDtEFJw2p65V4dtHkZIHVr0jUaitKVRGhJ9bLApPDj+bTows7Y6/BmZrhDqCkT9KDK N2gpsDI/a5RnpJGajsxgneGhvhzbAsaumBi9p4FScyfjqI6dXqZgb2vSH+52ST7e94EV uvq7nXjvHftbmkE5P0msw2WbootAqs5Qs6kSlltCJVxB81jJAHO9v30JapYIEqTLo8Jb +pvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JCqyYSiM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id op26si10307099ejb.568.2020.05.26.07.12.11; Tue, 26 May 2020 07:12:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JCqyYSiM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731766AbgEZJU7 (ORCPT + 99 others); Tue, 26 May 2020 05:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731662AbgEZJU6 (ORCPT ); Tue, 26 May 2020 05:20:58 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484D6C03E97E for ; Tue, 26 May 2020 02:20:57 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id c11so21443772ljn.2 for ; Tue, 26 May 2020 02:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tjIxLurGAZl3ClrqkcDTUozxTD1nDew3Brnlr2xXLqY=; b=JCqyYSiMdYS1eYDRtnDeEiedABn2SLAJ9eHMlUwpGPm+5yJt1v4LCf6UvpJc84XRbE 1cfRRQoLViCSj/Ef6G2XQ1MnDs8XRyleZi6kQTJgM4lW4Eyurn8txIZenaHRroS5F4Ii zqWLfi1rIGTUwxWPo6NxZWKxgXdkIdm6Z/9uTNfehAxFi1FZ5QXiVI/oLvhWfxfBZP04 64YHr1ZbYww9BFPrJ+2zK2C1+oW+dLlk/sZkNNq4aRcvkJ5DbIEeA679CTRIvnoSxtQM qA8qkXqWSIUdnpytsjCspoXtwgmZPFRfsVg7QYO2gGDE+hSnc8P9Dw8ZhWPx2fnwvwsb qrxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tjIxLurGAZl3ClrqkcDTUozxTD1nDew3Brnlr2xXLqY=; b=OhSB2WrDzQKo5REKJ5pgfPIJQoZ8KceGGFUxIzA2EDg+LLQprQ6UN5grvx1hmGycw2 yk2xfRv7HxD825l4wj81b3HYa88Yp2gETZfedKiPS22KaESyxnpM/dFaFE2K7G9XhTwk iZxoHbNQtsOybjOY4rKThrfnWLihc0hTDhOocPuVhbBk/QwYWcTuRKnpnbv3OXt8rQ77 XniQL3+ojlO0NgLqlh7JPjA62A3jT7LYI7PdiXooElf6C2qInQDQZsHA9x7I/OsNSUYd rmo+Y1Rvyi/6abyIEw1jUZEkXPi5wtB/qiE0vJctD5K3TJXMN3meQWLf9I9M4QfrHiuo FyfA== X-Gm-Message-State: AOAM530kFfYwry4qLsX4c9f8i/dTy8rGx0Qv+IR2wQQaBU8Z2N9nnzq4 nLhhnim+DpFd/A8kw7FveuYN22Vtzjye4K7NIerVbA== X-Received: by 2002:a2e:711c:: with SMTP id m28mr162302ljc.104.1590484855739; Tue, 26 May 2020 02:20:55 -0700 (PDT) MIME-Version: 1.0 References: <20200513141134.25819-1-lars.povlsen@microchip.com> <20200513141134.25819-2-lars.povlsen@microchip.com> <87pnb1nf2j.fsf@soft-dev15.microsemi.net> <87r1v8oz9f.fsf@soft-dev15.microsemi.net> In-Reply-To: <87r1v8oz9f.fsf@soft-dev15.microsemi.net> From: Linus Walleij Date: Tue, 26 May 2020 11:20:44 +0200 Message-ID: Subject: Re: [PATCH 1/3] dt-bindings: pinctrl: Add bindings for mscc,ocelot-sgpio To: Lars Povlsen Cc: SoC Team , Rob Herring , Microchip Linux Driver Support , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "open list:GPIO SUBSYSTEM" , Linux ARM , "linux-kernel@vger.kernel.org" , Alexandre Belloni Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 25, 2020 at 4:38 PM Lars Povlsen wrote: > Yes, the problem is they're not in sequence. F.ex. you could have ports > 0,1 enabled, skip 2,3,4 and have 5,6,7 enabled. Just use disabled nodes. That would look like this in my idea of a device tree: pinctrl@nnn { gpio0: gpio@0 { compatible = "foo"; status = "ok"; .... }; gpio1: gpio@1 { compatible = "foo"; status = "ok"; .... }; gpio2: gpio@2 { compatible = "foo"; status = "disabled"; .... }; gpio3: gpio@3 { compatible = "foo"; status = "disabled"; .... }; gpio4: gpio@4 { compatible = "foo"; status = "disabled"; .... }; gpio5: gpio@5 { compatible = "foo"; status = "ok"; .... }; gpio6: gpio@6 { compatible = "foo"; status = "ok"; .... }; gpio7: gpio@7 { compatible = "foo"; status = "ok"; .... }; }; It is common to use the status to enable/disable nodes like this. In the Linux kernel is is possible to iterate over these subnodes and check which ones are enabled and disabled while keeping the index by using something like: i = 0; struct device_node *np, *child; for_each_child_of_node(np, child) { if (of_device_is_available(child)) { pr_info("populating device %d\n", i); } i++; } Certainly you can use i in the above loop to populate your registers etc from an indexed array. This way the consumers can pick their GPIO from the right port and everything just using e.g. my-gpios = <&gpio6 4 GPIO_OUT_LOW>; Yours, Linus Walleij