Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1418570pxj; Sat, 8 May 2021 17:23:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2xe1JMaLlD0Cst+uFcIGpMDaBB6kbOEmBTLT81icaEwqT/39udnuQ2nkjR7UlxLBQXhmA X-Received: by 2002:a05:6402:1157:: with SMTP id g23mr20807251edw.303.1620519822667; Sat, 08 May 2021 17:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620519822; cv=none; d=google.com; s=arc-20160816; b=UeRWJl7gVFRbbVOpaTOcLYKn6iUds55/YyZbg2vbdBBfvTfNceRpv/ATPPeLZHMZRz he9FE3wQ7PBxobjlzPsQl8VnQfkCsiyQQuZfjYjXNS7LY5ym8Rn73PkLT3zLq5pxJPQA MAEY+BwWh9ynJfAPBMxdNgp+F4K8pOGPp4f/f9wAQNY4ymrsd3QGfSafzRvSNeS+OUev RkuSHpvYlUEdB7VG03g51xESd1Ku820a4OxmArySsd8uQ4XnKNNYa733s+lu0Yq8j89U +YW5Wpl9+f8xUz+8S5Bu20wl5bcMbTGOf1D3dIUDdCSgHWm47ROQ78hZed5haN7f3rR8 yfug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qpNO09z6ZmadBd56yRYdadNcpRqIARDEuzpJbLavNTc=; b=JuSuK/ksUukwHzzA+GE2R37I+0XJOvbRpefdKHZkXnwyhg6YwMNbjKNlOTpFKqyy3c XVWaNwoJNtFhyq6zZHHD/Gl+6L3wk3a2xIh1/07fJvfQCty4u9u0Sy+Z1O8kUWeQRvEb my5/BYlGWQ69u8qThXb0M1z7xwWX1JJCe79wEpIAdRihX03waA9ycuN3Ri/KCodVx6yp gbWtnGcTGwShIlelG18Jyq/WMk1vu6wn0/f7JJeS3N7oAyORFzV/y4Ts5Jku2PE+tPX5 eS4Kp2NWElbLxpDcmT2YXJtJKbjecom7S7pu/KvWNAIlb2e0+nemFtjhLEVuV+jYVInm N2SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KQb+U0lm; 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 rs3si9291515ejb.501.2021.05.08.17.23.07; Sat, 08 May 2021 17:23:42 -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=KQb+U0lm; 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 S229656AbhEIAUH (ORCPT + 99 others); Sat, 8 May 2021 20:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbhEIAUH (ORCPT ); Sat, 8 May 2021 20:20:07 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF72C061574 for ; Sat, 8 May 2021 17:19:05 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id o16so16324972ljp.3 for ; Sat, 08 May 2021 17:19:04 -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=qpNO09z6ZmadBd56yRYdadNcpRqIARDEuzpJbLavNTc=; b=KQb+U0lms78RQkO8DPmn5XEjIkPeRjoQxn/yKZKG9V4pHgrohQMRnr8zQgG2ML1UJa m0TahKGN90/zU7qYZZW4Tv4hQbYqP6AksgCnxZRUEIsVRSeQ4TdMVzj3ih19iB0LnOLb AF0CEnsJypdmcpye7WsI0WAgz7TKaeBxyM1Vp+WiRvYcAdCPRzW8u0ZLDGvnIKXNuRiP UreFmKe9cfRlhx9nQzWR2xTp73hKWVx+5Ueg+3J4hulBJMnXkZhEs7UrPLGt9Enczn+6 VpXy5UlTCxUe1imSGCAf2Pkbzog6qFMr6ytQtJnR8LnD26zK+jvLiiLA354IEMjiGe+Y tbaw== 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=qpNO09z6ZmadBd56yRYdadNcpRqIARDEuzpJbLavNTc=; b=RoTKvJBn9bI5UyMMhpSuzQLhOHjj7EOAbJ/VyJupiCb0WxbUu7NRMQqHbe65HTDfDD VGy8XFVCJXmIrIjVduUy+bhnwKgGh8g/uisJoii3fBL3MxHzDHiwK5wk9FRRcAQrYLSI lxfOVZ+Z1r+SK54SgYaypTV8tYWIqBfScUbZ8rFVfb/iqs1bXepOnaQ6LgERM8E2QSmx jzWsyu7zJ9XDJYIPIJbaZP+GSKOYtw2M1KyXdtet6o6wnNcHPtcrdV4QkqtOdKJK+e3+ SmhjgjZj1C0OhAJPxVvrl20h89GtNa6jKT5fTw8lo3Na2KmtH2I7Dp82UROUqnAwJZu2 q4DQ== X-Gm-Message-State: AOAM532bcAunX5PddERvuDnezhKZDOlyw3VnLGeHwVUCQ6kn5jcREY38 HV5YkG7fg2jrdIuUJcspjbnw6oFpYnYB3SbGarHHtg== X-Received: by 2002:a2e:889a:: with SMTP id k26mr13669134lji.438.1620519543447; Sat, 08 May 2021 17:19:03 -0700 (PDT) MIME-Version: 1.0 References: <20210508142000.85116-1-kettenis@openbsd.org> <20210508142000.85116-2-kettenis@openbsd.org> In-Reply-To: <20210508142000.85116-2-kettenis@openbsd.org> From: Linus Walleij Date: Sun, 9 May 2021 02:18:52 +0200 Message-ID: Subject: Re: [PATCH 1/2] dt-bindings: pinctrl: Add DT bindings for apple,pinctrl To: kettenis@openbsd.org Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Hector Martin , Rob Herring , Linux ARM , "open list:GPIO SUBSYSTEM" , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, here is a second note on pin mux layout: On Sat, May 8, 2021 at 4:20 PM Mark Kettenis wrote: > + pcie_pins: pcie-pins { > + pinmux = , > + , > + ; (...) > +#define APPLE_PINMUX(pin, func) ((pin) | ((func) << 16)) > +#define APPLE_PIN(pinmux) ((pinmux) & 0xffff) > +#define APPLE_FUNC(pinmux) ((pinmux) >> 16) Since the word altfunction is used, I suppose that this is one of those pin controllers where each pin can be muxed individually (usually with one register or one group of bits per pin). So this is one way to do it, which Another way is what Qualcomm is doing and looks for example like this: pinctrl@800000 { /* eMMMC pins, all 8 data lines connected */ dragon_sdcc1_pins: sdcc1 { mux { pins = "gpio159", "gpio160", "gpio161", "gpio162", "gpio163", "gpio164", "gpio165", "gpio166", "gpio167", "gpio168"; function = "sdc1"; }; (...) Here all pins have a name and they get assigned as a group to a function. Each pin is referenced by name. Some people don't like this because they like bitstuffing and bitfiddling and are worried that the DTB file strings will take up too much memory, and they have to include all these strings in their operating system driver. However there are clear upsides to it, when you later on come to set up the electrical pin config: cmd { pins = "gpio168"; /* SDC1 CMD */ drive-strength = <12>; bias-pull-up; }; data { /* SDC1 D0 to D7 */ pins = "gpio159", "gpio160", "gpio161", "gpio162", "gpio163", "gpio164", "gpio165", "gpio166"; drive-strength = <8>; bias-pull-none; }; As you can see this becomes quite readable. It is clear and crisp which pins are set up for pull-up and not, and what drive strength is used on each pin. But notice first and foremost this: the muxing is done in one node, and the electrical config is done in two separate nodes, breaking muxing and config into two different categories in the device tree. The problem with the magic number approach to muxing is that the magic numbers will fall through to the electrical pin config later and indeed it looks like in the STM32 device trees: sdmmc1_b4_od_pins_a: sdmmc1-b4-od-0 { pins1 { pinmux = , /* SDMMC1_D0 */ , /* SDMMC1_D1 */ , /* SDMMC1_D2 */ , /* SDMMC1_D3 */ ; /* SDMMC1_CK */ slew-rate = <3>; drive-push-pull; bias-disable; }; pins2 { pinmux = ; /* SDMMC1_CMD */ slew-rate = <3>; drive-open-drain; bias-disable; }; }; Notice here how the pins need to be separated into two subnodes in order to set different electrical configuration on them, and how muxing and configuration are mixed up. This is a side effect of using the "pinmux" attribute rather than "pins" and "function". So make sure you really like this rather than the other approach in your device trees. I will definately insist that you electrical config be done similar to how STM32 does it when you implement that later, for example any magic numbers for electrical config is not acceptable, you will have to find a way to use drive-open-drain; and such flags in the device tree. Sadly we have something like three different ways to do pin control device tree, as a result of failure to find consensus. Yours, Linus Walleij