From patchwork Thu Jun 27 16:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 684EBC3064D for ; Thu, 27 Jun 2024 16:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yhIZRHpA4qOumuO4k7pvHL8zVi+S/SE7cZamMyu7G80=; b=f9hkXdYTWqwF5W9CEpfHWybJ0F NFg3qA2NClU4jC1f1IRUMhG6YLvmyBwlkdPiN1Ep49Icy2bccEIOv+QMgAE9JJ1DgBmq1hmN+V43h i6fT2311AAWICXqTmfkPVkGtNKTlo77KvTD/irSdg98hva4xi90jQ2zKFqTqV4066EiNQrWEMaUyY 46JXmXRDogbwYNFae9nfVGverNxzjuFYRXssA7XoQMNK98X0sZlxOFfgu/JIxrM/E9R844Npm+8Rx O5+dffTcw3smtrMQcpWr/OAtZ/YIF13C1Yml9dPuFY+Jr7mveEOtmIUJewcAuKwbdY6TmmfrSspRP +01edlaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrza-0000000B2gt-48Hx; Thu, 27 Jun 2024 16:29:02 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzS-0000000B2db-0fNg for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:28:55 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7068ca5a807so238697b3a.3 for ; Thu, 27 Jun 2024 09:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505733; x=1720110533; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yhIZRHpA4qOumuO4k7pvHL8zVi+S/SE7cZamMyu7G80=; b=Wh7Y7KxgIe0W9TSMW4PrumkNK4s7s9WClcXseYsZmKgbP0ResuPckyzRlLFuczAcaq B4T69WAlamkMHiEsTVhFpUG0zjH/Mhv5k4oF9/tUiH3SjLfxh0SgzA39blhVdez2fVWv BnCHUAaUnOdaBo0EugkDw08WjgA0ARiKvm0VSh39GFvrZFcFdO5+ul7YYLCrsrfBLVa6 HnmBAUpGAW/E/iARQnfhhaCwfPn75oxOEhLnBuUsKAvBgszVWahTzv9hY23ZEsRO7Uhv LMCGbz7jYCbJnr7WD49jfoEO2TwrNphtanoDKJLKmLVDFiJh0d3SULm/o41h4TDP1gtY sZqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505733; x=1720110533; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yhIZRHpA4qOumuO4k7pvHL8zVi+S/SE7cZamMyu7G80=; b=ruQa5eXMR3i25NVyxpM1X2L6fE96L30FtK7YmIX+DqA95I55tGUXD4wqNxdYeQ/P+a htzPVLHgLTwa7/ifwvJvAhrgdWIz7wq/hEcT4lsi6wcRWNKCkHoF3Ml35eo+y3gFoZV5 CyeAXmoVW0aQXjb6CHu7ZnUfCXMJWKxY5Nko65U1HrLkC/Ps0S85p3Msk5G31yvTAkDS FEaCDU/gniAJ9qMrBfA6vUCkAPboOJMMnms/GmgrbsyVWkNc4Pf4nPY1JOo8yztRVGki qiCgWukX+yvbGvQAwciVQ0TdELcGd8IFLt1jyxVurNgdqP9xslm+1EJACQlgLpHmhoDV 9Spg== X-Forwarded-Encrypted: i=1; AJvYcCXfhRic7UZyPa7mj7OdwRemuyOf1HqeYdOzFohqxgGGsRBW7tOt1MyaIpCJWPW+3ps4lP2/FffKYKxYQl7T1KExvgW+c2vXtAXN3R7rx8YEQXHQW/k= X-Gm-Message-State: AOJu0Ywc5XTioMXDj9i5SxK492dmmVA2PBK8MYdZWZdynbA+FkDOV1ap INqdazfGKx844ID6CcvMZY2WJVjLgbiv0BnZXDirIaKxmjjjk73H3A06jmJvcBIHiOpbRsylarw V3Orw X-Google-Smtp-Source: AGHT+IGu7nfAht951dRK0GykxN4pyx/LO6pNHCPGWyCGEdRxWhNATyHi0HUE8qiqBodGwFGg0p2swQ== X-Received: by 2002:a05:6a00:408b:b0:706:5c2c:e202 with SMTP id d2e1a72fcca58-70667bd82ccmr16038261b3a.0.1719505733221; Thu, 27 Jun 2024 09:28:53 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.28.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:28:53 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:11 +0530 Subject: [PATCH v5 1/7] dt-bindings: connector: Add mikrobus-connector MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-1-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6830; i=ayush@beagleboard.org; h=from:subject:message-id; bh=9/rpedcTTyGMwyn6LHb+RIA+j2zaGfGSP/fqzhrUXJo=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM3CjLemMfmgtRjyAG+QFAnKzW5YgCMcFF4n thEWPBvvdCJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TNwAKCRAFzvXHieVa dMDYD/4qz46wFWZWzewi7xIKhBYFSdUuNPu3Z/RnnoAeeEPwArGJMiHZAgbjUWU+Ss7Cizf8eyR Ghzs5yQcnk7cZ0bYK1EBrmvgQW2mAAvni1UHQrUo+4QmgKdt5r8h8F1btWDqxXDBBnAWsSFK9dp eYEe631gu90oesxwkH8j2bqEYw5p1AIAzjbsB6D+d35TOuaQsTasS/CNRmD978KM9+2usW9bu34 82hFjsGAaRdvWAZqKoD5lgFjyajIZXUOxdCguTssgsnTqUU8KtKNJew+0h3iKaOqtKS30fXPdSg cGLrTs2vWrnZh5TCoCv5XjOp//vicjb3aoyQlKMIIweGS+AjgieyrMyRkPakGchUStJmsAxGkDs eo2RBvog3OT9WtWy41N5rMiYIfrW3YA+fBsQylUGKM9/AGDMHwJG+aB08E8yHoqHoPcseHbspUy CmjNihxQt3+nGfq6KC36pCJ7EnInom62np4vafwCvqRvW6aIupMw46jBu+YMKHXD3Xf2kXwoto/ qGfPDTQeco5wFTt1AtEJb/cfESmGI7XLJtLFFahpRq62X+KScegeTDRCQi9nsI8XLB9HYFUAsVf yMbONuFSltU+KjMk/PzoMcJ4iVt+AZswu6UPVplECqGyrbA4352882O7JqRQrWoB2pDzKL3OIBN 4TT4yCa5LCVqZ7A== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092854_241722_08AFEFDA X-CRM114-Status: GOOD ( 18.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add DT bindings for mikroBUS interface. MikroBUS is an open standard developed by MikroElektronika for connecting add-on boards to microcontrollers or microprocessors. mikroBUS is a connector and does not have a controller. Instead the software is responsible for identification of board and setting up uart, spi, i2c, pwm and other buses. Additionally, some new mikroBUS boards contain 1-wire EEPROM that contains a manifest to describe the addon board to provide plug and play capabilities. A mikroBUS addon board is free to leave some of the pins unused which are marked as NC or Not Connected. Some of the pins might need to be configured as GPIOs deviating from their reserved purposes Eg: SHT15 Click where the SCL and SDA Pins need to be configured as GPIOs for the driver (drivers/hwmon/sht15.c) to work. For some add-on boards the driver may not take care of some additional signals like reset/wake-up/other. Eg: ENC28J60 click where the reset line (RST pin on the mikrobus port) needs to be pulled high. Some SPI addon boards use other pins like RST, AN etc as chipselect (eg. SPI Extend Click). Thus, `spi-cs` and `spi-cs-names` property is added to allow mikroBUS addon board to specify chipselect by name. Here's the list of pins in mikroBUS connector: AN - Analog RST - Reset CS - SPI Chip Select SCK - SPI Clock MISO - SPI Master Input Slave Output MOSI - SPI Master Output Slave Input +3.3V - VCC-3.3V power GND - Reference Ground PWM - PWM output INT - Hardware Interrupt RX - UART Receive TX - UART Transmit SCL - I2C Clock SDA - I2C Data +5V - VCC-5V power GND - Reference Ground Link: https://www.mikroe.com/mikrobus Link: https://download.mikroe.com/documents/standards/mikrobus/mikrobus-standard-specification-v200.pdf mikroBUS specification Link: https://www.mikroe.com/sht1x-click SHT15 Click Link: https://www.mikroe.com/eth-click ENC28J60 Click Link: https://www.mikroe.com/spi-extend-click SPI Extend Click Co-developed-by: Vaishnav M A Signed-off-by: Vaishnav M A Signed-off-by: Ayush Singh --- .../bindings/connector/mikrobus-connector.yaml | 107 +++++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 113 insertions(+) diff --git a/Documentation/devicetree/bindings/connector/mikrobus-connector.yaml b/Documentation/devicetree/bindings/connector/mikrobus-connector.yaml new file mode 100644 index 000000000000..033479f8604f --- /dev/null +++ b/Documentation/devicetree/bindings/connector/mikrobus-connector.yaml @@ -0,0 +1,107 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/connector/mikrobus-connector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: mikroBUS add-on board connector + +maintainers: + - Ayush Singh + +properties: + compatible: + const: mikrobus-connector + + pinctrl-0: true + pinctrl-1: true + pinctrl-2: true + pinctrl-3: true + pinctrl-4: true + pinctrl-5: true + pinctrl-6: true + pinctrl-7: true + pinctrl-8: true + + pinctrl-names: + minItems: 1 + maxItems: 9 + items: + enum: [default, pwm_default, pwm_gpio, uart_default, uart_gpio, i2c_default, i2c_gpio, spi_default, + spi_gpio] + + spi-controller: + description: spi-controller of mikroBUS SPI pins along with cs pins. + $ref: /schemas/types.yaml#/definitions/phandle + + spi-cs: + description: spi chip-select corresponding to the chip-selects on the mikrobus socket. + $ref: /schemas/types.yaml#/definitions/uint32-array + + spi-cs-names: + minItems: 1 + maxItems: 12 + items: + enum: [default, pwm, int, rx, tx, scl, sda, an, rst, sck, cipo, copi] + + i2c-controller: + description: i2c controller attached to the mikrobus socket. + $ref: /schemas/types.yaml#/definitions/phandle + + uart-controller: + description: uart controller attached to the mikrobus socket + $ref: /schemas/types.yaml#/definitions/phandle + + pwms: + description: the pwm-controller corresponding to the mikroBUS PWM pin. + maxItems: 1 + + mikrobus-gpios: + minItems: 1 + maxItems: 12 + + mikrobus-gpio-names: + minItems: 1 + maxItems: 12 + items: + enum: [pwm, int, rx, tx, scl, sda, an, rst, cs, sck, cipo, copi] + + board: + description: board attached to mikrobus connector + $ref: /schemas/types.yaml#/definitions/phandle-array + +required: + - compatible + - pinctrl-0 + +additionalProperties: false + +examples: + - | + #include + mikrobus { + compatible = "mikrobus-connector"; + pinctrl-names = "default", "pwm_default", "pwm_gpio","uart_default", "uart_gpio", "i2c_default", + "i2c_gpio", "spi_default", "spi_gpio"; + pinctrl-0 = <&P2_03_gpio_input_pin &P1_04_gpio_pin &P1_02_gpio_pin>; + pinctrl-1 = <&P2_01_pwm_pin>; + pinctrl-2 = <&P2_01_gpio_pin>; + pinctrl-3 = <&P2_05_uart_pin &P2_07_uart_pin>; + pinctrl-4 = <&P2_05_gpio_pin &P2_07_gpio_pin>; + pinctrl-5 = <&P2_09_i2c_pin &P2_11_i2c_pin>; + pinctrl-6 = <&P2_09_gpio_pin &P2_11_gpio_pin>; + pinctrl-7 = <&P1_12_spi_pin &P1_10_spi_pin &P1_08_spi_sclk_pin &P1_06_spi_cs_pin>; + pinctrl-8 = <&P1_12_gpio_pin &P1_10_gpio_pin &P1_08_gpio_pin &P1_06_gpio_pin>; + pwms = <&ehrpwm1 0 500000 0>; + i2c-controller = <&i2c1>; + uart-controller = <&uart1>; + spi-controller = <&spi1>; + spi-cs = <0 1>; + spi-cs-names = "default", "rst"; + mikrobus-gpios = <&gpio1 18 GPIO_ACTIVE_HIGH>, <&gpio0 23 GPIO_ACTIVE_HIGH>, + <&gpio0 30 GPIO_ACTIVE_HIGH>, <&gpio0 31 GPIO_ACTIVE_HIGH>, + <&gpio0 15 GPIO_ACTIVE_HIGH>, <&gpio0 14 GPIO_ACTIVE_HIGH>, + <&gpio0 4 GPIO_ACTIVE_HIGH>, <&gpio0 3 GPIO_ACTIVE_HIGH>, + <&gpio0 2 GPIO_ACTIVE_HIGH>, <&gpio0 5 GPIO_ACTIVE_HIGH>, + <&gpio2 25 GPIO_ACTIVE_HIGH>, <&gpio2 3 GPIO_ACTIVE_HIGH>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 807feae089c4..8e4115e93aeb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15108,6 +15108,12 @@ M: Oliver Neukum S: Maintained F: drivers/usb/image/microtek.* +MIKROBUS +M: Ayush Singh +M: Vaishnav M A +S: Maintained +F: Documentation/devicetree/bindings/connector/mikrobus-connector.yaml + MIKROTIK CRS3XX 98DX3236 BOARD SUPPORT M: Luka Kovacic M: Luka Perkov From patchwork Thu Jun 27 16:26:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A684BC3064D for ; Thu, 27 Jun 2024 16:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+ccOqRF95rvK7M/qswICcqSLYl9oR0H6qjszvfV+fi4=; b=WqDTHg+7MW0u7X4lv9w91YQskG qVpa0QaGENn6UanbRo8kk+HYIkKRZ9QBDkkay/GjMjcJ4mhGFaeiLWRXRi4/6N2NMBppP7Ro3l+qN nruV0sJ9YpfhoLm5Qf3ykcQ+C/0ekmKTwIKS40NkcOJuPmN583KZfFstKVVvL/e+45ATGAsIcvb4A Fhi8Ofm3383fIgvwLMRPACguDW1O9oLp0/rOu++I0TQk6LF4WnrUks0cF4kg2tYFZGAzXRNI315j8 wZKgIvhCHHqUIAOY8ugtu5aNkOTfbkBZ7xKsjdAVXIbPoXOO+mna19thk2J2Av7pWj1nVpbUa55Ti XUXZbVgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzj-0000000B2lq-18ad; Thu, 27 Jun 2024 16:29:11 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzY-0000000B2fF-31h6 for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:02 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7068ca5a807so238700b3a.3 for ; Thu, 27 Jun 2024 09:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505740; x=1720110540; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+ccOqRF95rvK7M/qswICcqSLYl9oR0H6qjszvfV+fi4=; b=l54hAR8x6iWzvDB8vuXz6XESLtC+zi5SGuOx7VzxzKNrAYy9gDqrWdcHaQWx8SNfJn enNd7XZgDvua3JeXH6OcVN7mYEWhwMsWoxXoUWI8LtWfb4YLxeWyiOxqizhwhNXmoJuW IKIBfKfTK5zRbcfhLtprLrCnxBjvqIZg27rGVS23Hr65x3BbLXgHcMJoIAlncoqIrjo3 W0Hd8Q9ji7BWGtKM9qCCKqtLW5yrOxeXNUycjptYzLCQPLIYHrIOi4cCNWNtgBhA45Kc czDgUuqNeO1wkAGcAoBHvYPbJBKUztLvnCgMfrsuTY44b493/6SeMVlemy4G+zYuW4Pq OBCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505740; x=1720110540; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ccOqRF95rvK7M/qswICcqSLYl9oR0H6qjszvfV+fi4=; b=BRUWK4tCUh+9BN0PL1u6395qhNiqGYVALGTDV16Fj9oBMuTgbPxZqJjRVSMLJDFc8y jWoqt28Cw7D9i/9H2nlhGDKzs6t48gj3DeHGdWH8IjNqWsvZgbKnK1hwGZ7x0c3zrWQp phav1Oa9eTdN1c0HEsl0FX7y/T2Q1hec0aU+1NV8yf/7TKA2u6DK7Y2FztJy5ja+qb+5 fI2q00FH5f5QHA8uaikRPNS+jWV7ZgCLL/c4a0X3m8LaOXIkUJZ/gMuNIYJ0YE6Ycr/E IdDnxqVzgNIDB1HtZI9gZMp1rfWZ1TCWIYQbHVg/mllTf3lJOJ88voECIrZrtB2Eol4Z 7vIw== X-Forwarded-Encrypted: i=1; AJvYcCXc4giPxiyP3UBu4moIgPs4NgbefZC1ps0QeTGyW2zkMzPwhksK1+v8sqRIC4KhELKXoFZkUg/ma6xiIyTFVAacocpyQtcjCCuD7+hmKxajiKxF2V0= X-Gm-Message-State: AOJu0YyupQsWeow2vZ6mhRr9tNxQLfmLqt2E0Ckt6Uh0/OH7cWZf9aTP akt48OVgWOXptFGyHefhi7nPpb41DPzvZZza7v23JG28cHDfeWkRnShE9HyuLA== X-Google-Smtp-Source: AGHT+IFk7HX+UKAgfs/mOuNh+uAKaBrAUQCaRjadcUs82yFBm92OurvtId01tZ+4k4Mj1CxjuWO1vw== X-Received: by 2002:a05:6a00:6085:b0:705:d60f:e64e with SMTP id d2e1a72fcca58-70667e2b1cfmr16013801b3a.1.1719505739742; Thu, 27 Jun 2024 09:28:59 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:28:59 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:12 +0530 Subject: [PATCH v5 2/7] dt-bindings: mikrobus: Add mikrobus board base MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-2-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1971; i=ayush@beagleboard.org; h=from:subject:message-id; bh=Qx+Gj82f7/BC0AtS5BoDh2/utfcW2CADbnoJO4Ly0ms=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM386HpYhQNB0PpqxdYqTINwd7DNpxa1qpT3 BXwROSootiJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TNwAKCRAFzvXHieVa dI77EAContjZVyred1K/HQTl7UUY2WxuOSylfSAEp/dre8J2S0HEpt2NJE9MFdKzEVzBvp+0euk VpHNC/jIngtHlWsnOs+Hgy4VahO/Ohkxix1aM4YJhm6rXAi4I1E8mw3tVtro2+AAdqwh4ZzQ91Q J/bofN5cTWytbgd9BawV7HIE1aoi1q2jK7oE/uKCrLCi75zfUWRDwPcPj0T9DLrt36lnRRFwF39 BefYCRZcgN60wjf/QDdDG4r5mueY3yUZiRe8VV7reVnA+mjft7r+HTOd/FDHokZSIJK8NGm0AlX elUbHGmlgGHCnUAY3zraeyy21giGTjAUL1S+F3yuYBGW06FK4Sh5xRXkcvve/MgjDADLqEaN1IB uL62G8on4ywN8I3bZznwBDTocmUots1B/MCFu6uftT2wgIFWjv66SkSHx1GNFDnD9Lx0f7JeovI nmTOrQ0aUtRBP6THY+5D4tMGbo0P9L/UPbP+nMtc2Bf9hzW10m03fbv0TNO8kPtAY/nfPOCg4vn L4aZ8c2zeLASNtG4osr4DTBRcJUHdpsSPA+oj+9qC+2MmDpBtP+V8neKEMIsNNqA/Ubbwgq/cf4 4knrbpAh8IekyYZBmneWz4gxXGIrPu4UwaOjXPVklytAKWvlOtfJ/tllwAtaITp0qyMM/9TSU/i bQczVjt5RwcnSEA== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092900_827601_CD735410 X-CRM114-Status: GOOD ( 13.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Base dt bindings for mikrobus addon boards. Contains properties that are part of all types of boards (SPI, I2C, etc). Each pin in mikroBUS connector can either be used for it's original purpose (UART, I2C, SPI, etc) or as a normal GPIO. Introducing `pinctrl-apply` allows selecting the pin configuration by name. Note: Some mikrobus-connectors might not support all valid pinctrl. Signed-off-by: Ayush Singh --- .../devicetree/bindings/mikrobus/mikrobus-board.yaml | 20 ++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml b/Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml new file mode 100644 index 000000000000..42e2219c596f --- /dev/null +++ b/Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mikrobus/mikrobus-board.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: mikroBUS add-on board properties + +maintainers: + - Ayush Singh + +properties: + pinctrl-apply: + minItems: 1 + maxItems: 9 + items: + enum: [default, pwm_default, pwm_gpio, uart_default, uart_gpio, i2c_default, i2c_gpio, spi_default, + spi_gpio] + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 8e4115e93aeb..14eba18832d5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15113,6 +15113,7 @@ M: Ayush Singh M: Vaishnav M A S: Maintained F: Documentation/devicetree/bindings/connector/mikrobus-connector.yaml +F: Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml MIKROTIK CRS3XX 98DX3236 BOARD SUPPORT M: Luka Kovacic From patchwork Thu Jun 27 16:26:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7C1FC2BD09 for ; Thu, 27 Jun 2024 16:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZygMn7uvC7jOC5Dk/T17fUNW5zArlioCIEC7mvrSJII=; b=t92xcdR9NPfRhHove32bY7nOw0 c8mVot8JOhYaGf8c8UF++R7a8/yFo6+oA+yJLg96Ty47guNSiq8hs7n8j+RlWxSW0cEgdr9YxSC8l YzdylvFX7Hz/kAMJV+jDbQadsdEq4XU8G0QsqjVaFNjWZDe0Frhy/+dWL2srAqPG7OJb0hOSwTP+L knMu1kEXL6Q0tmvt6lJGl8lzMIzzZ4XPYvBct/SEhnk3RoDon+JafxNXKaiQfA0JH1CUxgMSaA7pj hCz427XOjv6oddHH6e2JeRDfTCZHnZuwmhyhIxL8zSwKQ2jeAYo4Z33D1096Q5ptSVNitgPL5c2wx qonmbOBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzr-0000000B2rd-1T3u; Thu, 27 Jun 2024 16:29:19 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzf-0000000B2jr-0Auz for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:08 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70661ab747bso179309b3a.2 for ; Thu, 27 Jun 2024 09:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505746; x=1720110546; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZygMn7uvC7jOC5Dk/T17fUNW5zArlioCIEC7mvrSJII=; b=pWdLopEAjTEF52HD5rz0zfcsX42yfoTcyBaGKOieA3BhcHOlwIYjQOfB9XVUM2gvH0 JqdN/cD9uc927wjNH3mbRgctQz5xfvxDimch2iozQb4iabyQRIYp7uOwnG0MrdXmb0j0 j2DWnMzsl3wo6WUeIKnjH9uxqZb1U/xd5hoJPvFTANcWvqDleqAAM65125PFRu/ouRnp N9SVBtqK9GUHhZ0cHfE1PfEdg4jedqs4n7/9GX+OwNrjOVvPcldpZF0AXx27GU+sXzvd DRkaVZpxmQNpugKASKqK2t2pfHVTlfiE5DPZh2J/ji2XCig5qSWHmmB6fDwVKioJvGhn 5HLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505746; x=1720110546; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZygMn7uvC7jOC5Dk/T17fUNW5zArlioCIEC7mvrSJII=; b=M8GKnmwWjt6ZjO/SvpDOsbd/OF45n/0dR8ERDsiOaN8U76RCYBnXaAv9kif3qlVvQT uVOYDvtUg9D2ymm0U8jaKMZoY7nMnvtAhoZfo8BJRYbTkg8nCO473ajw9H2ABshSC91r AWDvNwTPoqTEgN9sdUqt0B7vHHI83qNRfaL2ByzmzcCmywGq+pQY02F//J1fHABvjNJB GP57Zw+JvTxPBgVJDkNkI2Wwif40UQPLqw5eM1etBm5P1f4Y2lu4j1tap6Tl5OsvZblI QXbt1QvbibjhN159+lLItSRXRz6lBVsQElHgqzroIrUIhlfEwRPIJ0GK/wrrLXyKAKz4 OjNg== X-Forwarded-Encrypted: i=1; AJvYcCUfOhNxXYH/s0KyVz7SIOqlQ6BtJ9pvfeylHQ3JRLzQceUiD8hs+tkwHR8ytNa91rknVlTCsv6wrNHRA03rQGAM1yC0wYlke8jI5qM5oTxYROTEhbo= X-Gm-Message-State: AOJu0YzulpfMEUYzTmci9U6Mj+8rlDcJESREGq7lLKE7HT746kawdpOo goPNfQ8y8DJhlHwsryM3/j0VT4l0268k8QjkjCCIfejMv/4YScNMLZTdzWQ/2A== X-Google-Smtp-Source: AGHT+IHqbrEn/MzWqlaJoSGgZcxw7gHGkyhYPxfsB/waXYDQqYHNQq7LUMFy4l2KHYm4bXB3Fy1SLQ== X-Received: by 2002:a05:6a21:789a:b0:1be:d529:68b2 with SMTP id adf61e73a8af0-1bed529702amr1901349637.1.1719505745910; Thu, 27 Jun 2024 09:29:05 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:29:05 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:13 +0530 Subject: [PATCH v5 3/7] dt-bindings: mikrobus: Add mikrobus-spi binding MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-3-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2720; i=ayush@beagleboard.org; h=from:subject:message-id; bh=+2qvP/Xn1mfOZRYqvXqWL+bWU40Wws67RBaWRqRKWkU=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM3lAJFqmuXf/9R/f6QUc8jAUwTWHL8sDm0n zaRT+IOnhOJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TNwAKCRAFzvXHieVa dJtBEACq2bspM0xQ/MgwNhecatTUWuwJLDXryVNpVzGUeFH+1x/wPJJ7+RwikDxrwJ2rqzJgON6 MCCuZRlaDcV3VHyX9qXnrbIdrNj8Es55Ba33exrTiAdo2cIkqAaedFjk5+h27QQfvj5bP4n318v Rfg9I/VZ9Xe72YNbgGRIe/eZpODaJbXpMR/OUxREq46ezOEA0/rFbmYAyU5fFuGX+vBumR5YNXu 4k/jCNRXAHt2lH2D3s0RHsRwFSypPQQvLAVpRPJ34G+VBGtKAsShNsEpPA/9PcitKjIaK29eSaa baiWHbwt6iwiH5S15Q3JonCGg+smHQeziw/KqEjYWiV7B75fSCVrAxiO1uyYqtBuGmSugXHglIq LCKjcOhF688TYgxJCiW2O2yACllsekClGYyKv1L0zSkevJGxxDXwG8gf4bxEO4KArlAqkbcNmIo 9onNy87vJVOZ3sGg1FLP1X4OM8u8o+Bm8KBiMhV/PsMn3Cgw3nSY0ExnwRatjG17j5eCdqZC174 fF5Q5OCpVZJjXKnlofn0CB2FQkkDdLAEdNFWMx1UeVPexUfJX8vZo9O1LlZxj2Il5WDiQ4k15Q4 GDouJAvzTP3PucDdWiobFtWFvkEnW5jDy8NuBXZuoaOqUkUFCyfTSr8vjU/F86NmFsoBPpcobta 6HgDaZthkCq2Ieg== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092907_167918_C16218D4 X-CRM114-Status: GOOD ( 16.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add bindings for MikroBUS boards using SPI interface. Almost all of the properties that are valid for SPI devices can be used except reg. Since the goal is to allow use of the same MikroBUS board across different connectors, config needs to be independent of the actual SPI controller in mikroBUS port(s), it is not possible to define the chipselect by number in advance. Thus, `spi-cs-apply` property is used to specify the chipselect(s) by name. Another important fact is that while there is a CS pin in the mikroBUS connector, some boards (eg SPI Extend Click) use additional pins as chipselect. Thus we need a way to specify the CS pin(s) in terms of mikcrobus-connector which can then handle bindings the actual CS pin(s). Link: https://www.mikroe.com/spi-extend-click SPI Extend Click Signed-off-by: Ayush Singh --- .../devicetree/bindings/mikrobus/mikrobus-spi.yaml | 37 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 38 insertions(+) diff --git a/Documentation/devicetree/bindings/mikrobus/mikrobus-spi.yaml b/Documentation/devicetree/bindings/mikrobus/mikrobus-spi.yaml new file mode 100644 index 000000000000..35ca2cce3b03 --- /dev/null +++ b/Documentation/devicetree/bindings/mikrobus/mikrobus-spi.yaml @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mikrobus/mikrobus-spi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: mikroBUS add-on board using SPI + +maintainers: + - Ayush Singh + +allOf: + - $ref: /schemas/mikrobus/mikrobus-board.yaml# + +properties: + compatible: + const: mikrobus-spi + + spi-cs-apply: + minItems: 1 + maxItems: 12 + items: + enum: [default, pwm, int, rx, tx, scl, sda, an, rst, sck, cipo, copi] + +required: + - compatible + +additionalProperties: false + +examples: + - | + thermo-click { + compatible = "maxim,max31855k", "mikrobus,spi"; + spi-max-frequency = <1000000>; + pinctrl-apply = "default", "spi_default"; + spi-cs-apply = "default"; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 14eba18832d5..88f2b3adc824 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15114,6 +15114,7 @@ M: Vaishnav M A S: Maintained F: Documentation/devicetree/bindings/connector/mikrobus-connector.yaml F: Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml +F: Documentation/devicetree/bindings/mikrobus/mikrobus-spi.yaml MIKROTIK CRS3XX 98DX3236 BOARD SUPPORT M: Luka Kovacic From patchwork Thu Jun 27 16:26:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAB90C2BD09 for ; Thu, 27 Jun 2024 16:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dJ1Q8KLXbBvPejPRGDLYr/bC1HXbn69hKei2CLRD37M=; b=Sg0+GXdX/u6ph7B7WECmBFQ2Gj vDmH/Ifrp2C+Nkqd9p5IirW7Sstk0++kMA56z7gJf0CLt6i1VCZPPLrlcYRFjU7B9u/se76O7Uw4g fS9YZHICz5S2FSRhjf90gWLpJAXAUhYVZZUIknqm1GzmZsD/Sxx8p0DNlTn24zogYaaTWHaqsZiRh T/tfQc7fFrPJhfM13906gwUCMGC7fQ5mzm6IBwrn4CqthM7dBNoW5aWf8hgU7sigjUB5O3unrj1WG kwlakxbvmTLvyKz1Dd3UnOBhrmqY1pyVS+XxbdRlpXwNr6FZSs7wOqE0uH+wUur6wd6UgdC+VFQuD /vVQIprg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMs01-0000000B2xt-0Ypq; Thu, 27 Jun 2024 16:29:29 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzl-0000000B2mo-12nG for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:15 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7068fe9f98aso411444b3a.0 for ; Thu, 27 Jun 2024 09:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505752; x=1720110552; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=dJ1Q8KLXbBvPejPRGDLYr/bC1HXbn69hKei2CLRD37M=; b=rq+2PaJM4O8tJ3+NWJNTVw0xyaQHRVegU8eDy9n3lbtZPURyc2A/q/ZMVhgjcjV9nh 7xzvb3wQ+D+Lmln+6Tfqcm6MHAPYh1tWau2V/LLbELGDXpIxaCwrR2U1vevR3K7QOIBs OWW7M4beMEA1al67Od8J9njv50dbZPznzhoLK+xYzQiNI7LwqNL/M3e/tbGnbQ5YClFp DmZb+p+3fXTk2mWsf631Sf2UU35nmxDMuYhTdHlokuub51q6tOtNnp/6FHtq14TA4fVn 9qx/vKwALxU8oaUR1dzvooHOz9K3kNdBhKthRI+ucSr41FB6r6DoywOgYi885hxD4ycm WuWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505752; x=1720110552; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dJ1Q8KLXbBvPejPRGDLYr/bC1HXbn69hKei2CLRD37M=; b=UaKnDyDvdoFeWc4rn9djx/I3/nhcIhQXRs3wKDILop6VjL0t8C4uwGAbS54HBxwH/o fMHry0p9GN2lVmeYf79+1qF1iOLK1Nmr5/KDavqhZQbtbD76Wn52DYnVdM90JGH2DZ+R EsdG+Bh7zhObtFOurZkIr38zOH+olrL0bwtpJBnOMU02AmsDfd+0OcpwaIhOtrRnL2i5 VSYN7FEFRYVx//Vq8zuYRRNp+PwXFUgp0iWDMxZ+ATaWJGccaJ3Ohw3x7We51frB4f72 ygNv2HMcqVJ6HYeu3IU5jhuKaXXeo/sH4EXDjhoLPdGRkOPAAkjAELOAcbBiSd/nZWGQ dz5g== X-Forwarded-Encrypted: i=1; AJvYcCWr1/WofkXos+kUiX+lg864CWlh7ObYUZOX6cllROol+Wf3EnMxbxUCnC2eTOm4IcPNjeLeEtHei7sImVUyh/FStt8+q1pKZ8MN7f1qYr8xugzIius= X-Gm-Message-State: AOJu0Yy1HPJzklTSi15ISxfs2z+gas449/YIGtHKdnMgUaGIAbCnz9Qa 4eTswXbFloZbAIkD8tMegoVOAUcb1glgO90LIdmIi8mu/B9fzxN+2aoyX3ttJg== X-Google-Smtp-Source: AGHT+IH3omPFHGGPxV7skDlndGJ9S2ClJpc2MTVM8kooRW3+wAtdW3I1lvFLR5DYyPEFczJdm/1zgg== X-Received: by 2002:a05:6a00:8c0d:b0:704:21c2:ae92 with SMTP id d2e1a72fcca58-706649a6b01mr16098893b3a.2.1719505752619; Thu, 27 Jun 2024 09:29:12 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:29:12 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:14 +0530 Subject: [PATCH v5 4/7] spi: Make of_find_spi_controller_by_node() available MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-4-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh , Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7524; i=ayush@beagleboard.org; h=from:subject:message-id; bh=Q5G1t+bBT76IayXqh+ct3R0Xwy8Q7gI2MQZpDn6U4Tw=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM39ts1Hz8di1m0tcwk+aba8fgbKzU2sWFfL dDxLIgR2WOJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TNwAKCRAFzvXHieVa dM2AD/93OV2TFiw4AdubUbDptdezyFQRUOt4vbb1yBRSJbVpqw0STGvI8pwCR6VRNxbd8NrQtX8 kuxOz63jbSsu6ob+kNVJjeH6wHJB4nelVuf7T3JhjBMv0qTdAc/75f2pklRQx6gJVYTNNmCgfHU 9Oid495FxS1D8AHZCTp7Ungr+CwIdqTTUyTsUaav9tvrSSoVFqgGDso3URiVi86Xyraa6+aGjbW pI2d03Iua9sZOaQ2fmjsoi0mh7+zJzfhDlYLHmRIR+pqPR07zgv4MXoKwPtG+I3mEdLOcBKi7wg ZO9d3j0hZFcSqOIpey4mmMrtfT1DpckFEb0smR3mb3p6cmSkgZ53z4ALiIxW+g9NtQhtlBRQT11 RpAaRWVoRq4jrrqLxrG5/QtA7+begIYPCKmueTZgN6blJ//gU93cOctHEU+MmtptAmPjhNtB9oT HCVLZ7vvlZcckDE8i/YP/VKepTVKrkgNxOw21DMYkZo+Pa7uWUjHH6CTtgmNFa0XmeRCEIUqM1v BDFmWAhz7lTAxCm2ZMuc/+NxaJCg4/3uhrd5zScJKtS8intFDwaAMKK3NbZKGxX0gZK3G91PHvV AB4xqkIebulFZvYJg9kevmPttx3R7mLHeVOMyWednW8m+kQhTGKx6Q5qPqa6RbkQ3o4LS27e5mk YOdbHuiZ3uUdyiw== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092913_439776_D3D25F1A X-CRM114-Status: GOOD ( 19.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ayush Singh DONOTMERGE Externalize and export the symbol of_find_spi_controller_by_node() from the SPI core akin to how of_find_i2c_adapter_by_node() is already available. Also, move it under a CONFIG_OF. Signed-off-by: Ayush Singh --- drivers/spi/spi.c | 206 ++++++++++++++++++++++++------------------------ include/linux/spi/spi.h | 4 + 2 files changed, 108 insertions(+), 102 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 54cbe652a4df..565b2e2dd5b9 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2340,6 +2340,93 @@ void spi_flush_queue(struct spi_controller *ctlr) /*-------------------------------------------------------------------------*/ +static void spi_controller_release(struct device *dev) +{ + struct spi_controller *ctlr; + + ctlr = container_of(dev, struct spi_controller, dev); + kfree(ctlr); +} + +static struct class spi_master_class = { + .name = "spi_master", + .dev_release = spi_controller_release, + .dev_groups = spi_master_groups, +}; + +static ssize_t slave_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct spi_controller *ctlr = container_of(dev, struct spi_controller, + dev); + struct device *child; + + child = device_find_any_child(&ctlr->dev); + return sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias : NULL); +} + +static ssize_t slave_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct spi_controller *ctlr = container_of(dev, struct spi_controller, + dev); + struct spi_device *spi; + struct device *child; + char name[32]; + int rc; + + rc = sscanf(buf, "%31s", name); + if (rc != 1 || !name[0]) + return -EINVAL; + + child = device_find_any_child(&ctlr->dev); + if (child) { + /* Remove registered slave */ + device_unregister(child); + put_device(child); + } + + if (strcmp(name, "(null)")) { + /* Register new slave */ + spi = spi_alloc_device(ctlr); + if (!spi) + return -ENOMEM; + + strscpy(spi->modalias, name, sizeof(spi->modalias)); + + rc = spi_add_device(spi); + if (rc) { + spi_dev_put(spi); + return rc; + } + } + + return count; +} + +static DEVICE_ATTR_RW(slave); + +static struct attribute *spi_slave_attrs[] = { + &dev_attr_slave.attr, + NULL, +}; + +static const struct attribute_group spi_slave_group = { + .attrs = spi_slave_attrs, +}; + +static const struct attribute_group *spi_slave_groups[] = { + &spi_controller_statistics_group, + &spi_slave_group, + NULL, +}; + +static struct class spi_slave_class = { + .name = "spi_slave", + .dev_release = spi_controller_release, + .dev_groups = spi_slave_groups, +}; + #if defined(CONFIG_OF) static void of_spi_parse_dt_cs_delay(struct device_node *nc, struct spi_delay *delay, const char *prop) @@ -2549,6 +2636,23 @@ static void of_register_spi_devices(struct spi_controller *ctlr) } } } + +/* The spi controllers are not using spi_bus, so we find it with another way */ +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) +{ + struct device *dev; + + dev = class_find_device_by_of_node(&spi_master_class, node); + if (!dev && IS_ENABLED(CONFIG_SPI_SLAVE)) + dev = class_find_device_by_of_node(&spi_slave_class, node); + if (!dev) + return NULL; + + /* Reference got in class_find_device */ + return container_of(dev, struct spi_controller, dev); +} +EXPORT_SYMBOL_GPL(of_find_spi_controller_by_node); + #else static void of_register_spi_devices(struct spi_controller *ctlr) { } #endif @@ -2917,20 +3021,6 @@ static void acpi_register_spi_devices(struct spi_controller *ctlr) static inline void acpi_register_spi_devices(struct spi_controller *ctlr) {} #endif /* CONFIG_ACPI */ -static void spi_controller_release(struct device *dev) -{ - struct spi_controller *ctlr; - - ctlr = container_of(dev, struct spi_controller, dev); - kfree(ctlr); -} - -static struct class spi_master_class = { - .name = "spi_master", - .dev_release = spi_controller_release, - .dev_groups = spi_master_groups, -}; - #ifdef CONFIG_SPI_SLAVE /** * spi_slave_abort - abort the ongoing transfer request on an SPI slave @@ -2958,79 +3048,6 @@ int spi_target_abort(struct spi_device *spi) return -ENOTSUPP; } EXPORT_SYMBOL_GPL(spi_target_abort); - -static ssize_t slave_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct spi_controller *ctlr = container_of(dev, struct spi_controller, - dev); - struct device *child; - - child = device_find_any_child(&ctlr->dev); - return sysfs_emit(buf, "%s\n", child ? to_spi_device(child)->modalias : NULL); -} - -static ssize_t slave_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct spi_controller *ctlr = container_of(dev, struct spi_controller, - dev); - struct spi_device *spi; - struct device *child; - char name[32]; - int rc; - - rc = sscanf(buf, "%31s", name); - if (rc != 1 || !name[0]) - return -EINVAL; - - child = device_find_any_child(&ctlr->dev); - if (child) { - /* Remove registered slave */ - device_unregister(child); - put_device(child); - } - - if (strcmp(name, "(null)")) { - /* Register new slave */ - spi = spi_alloc_device(ctlr); - if (!spi) - return -ENOMEM; - - strscpy(spi->modalias, name, sizeof(spi->modalias)); - - rc = spi_add_device(spi); - if (rc) { - spi_dev_put(spi); - return rc; - } - } - - return count; -} - -static DEVICE_ATTR_RW(slave); - -static struct attribute *spi_slave_attrs[] = { - &dev_attr_slave.attr, - NULL, -}; - -static const struct attribute_group spi_slave_group = { - .attrs = spi_slave_attrs, -}; - -static const struct attribute_group *spi_slave_groups[] = { - &spi_controller_statistics_group, - &spi_slave_group, - NULL, -}; - -static struct class spi_slave_class = { - .name = "spi_slave", - .dev_release = spi_controller_release, - .dev_groups = spi_slave_groups, -}; #else extern struct class spi_slave_class; /* dummy */ #endif @@ -4720,21 +4737,6 @@ static struct spi_device *of_find_spi_device_by_node(struct device_node *node) return dev ? to_spi_device(dev) : NULL; } -/* The spi controllers are not using spi_bus, so we find it with another way */ -static struct spi_controller *of_find_spi_controller_by_node(struct device_node *node) -{ - struct device *dev; - - dev = class_find_device_by_of_node(&spi_master_class, node); - if (!dev && IS_ENABLED(CONFIG_SPI_SLAVE)) - dev = class_find_device_by_of_node(&spi_slave_class, node); - if (!dev) - return NULL; - - /* Reference got in class_find_device */ - return container_of(dev, struct spi_controller, dev); -} - static int of_spi_notify(struct notifier_block *nb, unsigned long action, void *arg) { diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 85785bcd20c1..58e692226475 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1684,4 +1684,8 @@ spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer) return list_is_last(&xfer->transfer_list, &ctlr->cur_msg->transfers); } +#if IS_ENABLED(CONFIG_OF) +struct spi_controller *of_find_spi_controller_by_node(struct device_node *node); +#endif + #endif /* __LINUX_SPI_H */ From patchwork Thu Jun 27 16:26:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBA8EC2BD09 for ; Thu, 27 Jun 2024 16:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=oeUpsO3LRVz0DWVCIRPfUEx9NS9Phcthbxa0dOGg864=; b=OYmgLy72iGB95hjDiCNkVoGQHu cgkw3TRYaMuHMbzwexwLdoWJ7yyak9DL76xd2utCqGa8a0X27YGDlwiwmDj9phZAr7Vax4j1ZZmO8 J1eDbjua/lOqzyRG787o3n9AvuU1XSdGZnbJnZPWkYSgKI3J7bZ3m7WjJcDtYy7tZATNdnIFqy7H2 dZW3Fy7JP8Nw6Pufjs4maGURtBei8nfWJ50PaNjXuEdUAtYCQNp+dWowpl02fuCLphH4prQcWzj/N px0xxglWwMfSs63EowQtY9AtFqvfd5WCJtjBHvPd6za0OmKd9N4rtZ9bcCftxFkUfMT7EASmMhrzG g2WJpT9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMs08-0000000B33m-2phM; Thu, 27 Jun 2024 16:29:36 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzr-0000000B2rc-3G4V for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:21 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fa94d0ba3dso1868475ad.2 for ; Thu, 27 Jun 2024 09:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505759; x=1720110559; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oeUpsO3LRVz0DWVCIRPfUEx9NS9Phcthbxa0dOGg864=; b=el9JaM82Q0xteTnGuem26o2YHDdVc7fwaVLx+2T3o4OPIGoPure9zuROsR/gd4tMqR rPap6M4MFpdAU0m+s+BPbGtx7KzwkmH21hYk27XKdTFx0SBYTVYRZWAkeNosMIZba6jH v4chLHn2Cx441AZutiT/t7oXA2Ls8A7yEhuKhNPum1bbyT0QDv9OQJElxHexTVoucHYV NCxkarifCZqGV8/Fu0yRW8UPsfWW1w/X6y6XTw9IAd5btcHls/1ZqgAajCO+PRmVqTHl B/p6Atx/Py/KBaWBG3baWCzGJLUDEOg0kYENqy3Xg8Mt2Q9LSEsLSy3clMF1SrI0a8Ko c1Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505759; x=1720110559; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oeUpsO3LRVz0DWVCIRPfUEx9NS9Phcthbxa0dOGg864=; b=CoVjNwp9fnLcZ3zTSugvWHkZMs48g1f2HIYVP2ajUmpwK5vjSF5iovlDS1dko93+G8 A9jXpWbfqsoFnUIkhU4qGerRfYQdRyPPB6vHOz7WkCR4BwawoM9WNACa5Ke+x7P6STtj NpKWqYxirBclvoac6OSryrO2ZEBoWG69i1B5qHXvEvP+0dB7jC2LwmZixj8JjGRC3PMM +5+okqrX035n1l70Sm92fVa6VGx6+7yLTEoTK8+HDROH7Ek0BHDTWUfQcfSGwqhw9OvH wrzBueyZvl//SSgC1GUEUXaVhP5Jg/OYvcSlj/fK+jJo7CHj9XP5jXK2SJZLzyDP/IOS XaOQ== X-Forwarded-Encrypted: i=1; AJvYcCUDTArdMEmGoB5CYXH8MtVLGa8+8z0uX6qikQwzvOSdrrQlFaLFZMXLet9An2odmlI+2xtP87AMYA4RVhqPAa7ng3o1P6OG0UIWjvnKVYp3C8lGJX0= X-Gm-Message-State: AOJu0YwtbygoU1lxFEnDZI3hgfWklgkklW3UpX7uELAl6NykFglKIsRc MUeQir/xj7UTp9z0bMHp0a51tKGNUbNgHfXDhMLkj1osfwd9OhGmq3lCZMbtWw== X-Google-Smtp-Source: AGHT+IHbEm1F9egL6S/rR3CsIzTMisY42T+/Lsbxvt3sKTUuzPOqGuGmmOan06Ef0cGA9WzFMszx3A== X-Received: by 2002:a05:6a21:191:b0:1be:d897:797a with SMTP id adf61e73a8af0-1bed89779f9mr1604844637.5.1719505758883; Thu, 27 Jun 2024 09:29:18 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:29:18 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:15 +0530 Subject: [PATCH v5 5/7] spi: Make of_register_spi_device() available MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-5-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1593; i=ayush@beagleboard.org; h=from:subject:message-id; bh=XvGqbx6PQp8f844mWBPvMecz3kVkfoFZ3ReBD72GOko=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM4NxJtL4N2ETEWuF7h6QH3spah6hXCZAD9+ AKPJ1wVgCCJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TOAAKCRAFzvXHieVa dDEYD/9ORM2M+wPDI/+3JsWhR/TBeOz4zPH5zk5O2EQnjY22bvBJ1Xwpw8SPL+I2ggu1Qlge4k8 1oIIdZeuEHPkabwou1iWkmeax6k50uNYHdN+LFRDTzjmx+S8KWq+scXijT9sWhuUypOLxJRssub HKJHtp+f3bK0JyfmcDtnyMz+ZSYR+wnleKZRw1VoBT3ULh5H5wVNHXIZU/syWxRCmuz+JAA1VBZ 1pR6bfrIRktWYtLhbiuT1wEzvuHkmgoWzsbJPItMO0Kkc3ZqR5Oydprn4bN9dtf4Nz6BsbdoIX3 vzaGWhkoC9JWF79uqboWBWt72HwgPTUsv91q5wf3puNBUxpAPmVR4qUCui+nywtXqrue/S23q1S DAMYKP9Myd7PdDvRx9aLzL6F4DRY+doeb8eyrVbGqqCFb0Iv2eY5ymN9OT/6ZayLyn0t8hCCHmZ a7Iej00On+qGkW9l69u5EbuTDTRiKsTKVen1/6OO8MT4PTTiuhwxF0Ypqedp0fkOZH3TQ1UODeS YC4KgterW4VKPHkDYBP2sk/hJ5NUAxWKQnVmwNCBlA54t9rpoujo1u0Iswdklq/ilUY45yO08QG IO69LYpPkgEOtvhwIthAPvB/7mvOwITrNM1cZOZJ1QBeX1CoUXUDW4cadI5QbZ+gTriOkXNFSsJ 9og9h5aChNFWZvg== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092919_936892_A418C367 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DONOTMERGE Export of_register_spi_device() from SPI Core to allow registering SPI devices from device tree when the device node is not a child node of spi controller. Signed-off-by: Ayush Singh --- drivers/spi/spi.c | 3 ++- include/linux/spi/spi.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 565b2e2dd5b9..8cd4d61958a2 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2566,7 +2566,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi, return 0; } -static struct spi_device * +struct spi_device * of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc) { struct spi_device *spi; @@ -2612,6 +2612,7 @@ of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc) spi_dev_put(spi); return ERR_PTR(rc); } +EXPORT_SYMBOL_GPL(of_register_spi_device); /** * of_register_spi_devices() - Register child devices onto the SPI bus diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 58e692226475..861b1cb4cca6 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1686,6 +1686,9 @@ spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer) #if IS_ENABLED(CONFIG_OF) struct spi_controller *of_find_spi_controller_by_node(struct device_node *node); + +struct spi_device * +of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc); #endif #endif /* __LINUX_SPI_H */ From patchwork Thu Jun 27 16:26:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714802 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85844C2BD09 for ; Thu, 27 Jun 2024 16:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+bfrOPZFpalSMaAS4PqOt0l9wak2sxgz4QQtL4YtP3I=; b=V7JxtwzVmB3nJtdEQEgVp03yOw Eqx3GGpsz9UT+QRlNsqmZ2TSPAviMg2W6JIlXwHwvgGmRGjlQz6M69O+6KUjUjzlcOWkAl+R0rvu1 g/hDKvg6utAuvB/+lbPlkzrW1kdFhgWZ92+5TVAHj6tzMthR7e2Pi2M+AzoqFKYsE+3SZf7Nhe2R/ fxbW2daX2g6JoIonZTKDYiLEQUO9Lg5qwsKpW3v8i+HE6zJ68Ic5yxWPJfF/vKLuga4Cc1yJ9/a0Y CJK7rZMN2OpOgUYjojhdJldp5h+/Uv5kFCLKFvgAEqhIYOiF5vio7cwPEMT+mWrznTJqr/yc9Y5VE 1XOpFXVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMs0G-0000000B38B-1LWa; Thu, 27 Jun 2024 16:29:44 +0000 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMrzy-0000000B2wb-3yKE for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:28 +0000 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3748ec0cae2so4016555ab.3 for ; Thu, 27 Jun 2024 09:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505766; x=1720110566; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+bfrOPZFpalSMaAS4PqOt0l9wak2sxgz4QQtL4YtP3I=; b=qEkM8KFAYuVRD5uFDWGM5SRKN9eeMJx1ix05Y3TcHNXrO/wDxD/nk9gRD+3+xIVlCQ ZFMBi6FVLNqaMrHM5xT+yUJ91g9HIgMvUey3HGzpJE6dOoP9WhaJtUBIQQKOUXRh8Hv2 jmQPIMkUgu4K1Vaz3BSn6ut4ufAhPwRg1XfzsK0/SyppVxjrboRzUJO0bVZ2EgDUUb+t KIDz0lJhk9sMcrcirbA1FrrGeh6pxqbdOBx7u+cBtV/84LG6L5SMFqtxZqA9m46/+l6n 17RtcU3YukLwbIkQK0bz4wuNa2LYfrXhp/P8EhIr07rzsWN4rC2tg8Spaa7w7azp0Q3U JvPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505766; x=1720110566; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+bfrOPZFpalSMaAS4PqOt0l9wak2sxgz4QQtL4YtP3I=; b=Asc27fKDZDJ6cgzBa8RjgFh1lxG69jXsT4xtwiVIGV9PwgC8wdKf4kc+WP5Lo0iCsM +cXQkgxdg52OASZ57xha6FpSSP4dKIL56BuEDtp99R/SuDPGh0a68AvvTApt730AnhKN 17VJlps/X0m3tyPASj4b9/Cqa5rhjPIz/TbQ4xxOGo6MdnFBkAWmL6ogt1BzD54XluNx 68m0TVsDt4HCS7DGLP4lr3MBuCxUZvMvPFWneMLi682Xs//7kr2CkxCCdf48wlI7jCgA QHgzSbJrxEvBajyTota3I61MfNpcs3xKoZXjsb2ScO7bPG5sOVNro+ioDtbczbNsUHXd DZDg== X-Forwarded-Encrypted: i=1; AJvYcCWg5f/B5mUmNiJY4nsaDydU0Inbg+r6bXt4GI4jP3jKiJdHUlHOEh38ZEDA2wShM+ckrhiGITgnI87knTAKW6CF9qqWeAuheZoA54HlCp/zdf6ppRM= X-Gm-Message-State: AOJu0Yz14idZkli7+cLDVF0Otghx3E1sILDMrNrkgd7wTPjf/hkQb/t8 ZP+ade2GidoHGq1sWUlz8q35ddRAzMgmhyzByhguRKwlHtVeNDXyUC6D1ZRuN4VM0klRaeqjhv9 9Mg== X-Google-Smtp-Source: AGHT+IFGYU63T/oSxgM+A/eQpByDC/Ouyy7zftKpv3HGC+fCi8ImTDpADN0e5OgU0x+zSxAjYtwXCA== X-Received: by 2002:a05:6e02:1303:b0:376:38c5:5cf2 with SMTP id e9e14a558f8ab-37638c55fcfmr140649355ab.1.1719505765939; Thu, 27 Jun 2024 09:29:25 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:29:25 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:16 +0530 Subject: [PATCH v5 6/7] mikrobus: Add mikroBUS driver MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-6-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=11731; i=ayush@beagleboard.org; h=from:subject:message-id; bh=WoVhoW5NvKUcUTYxClHtsBC4qaRwvpudUw/hgpnVaAc=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM4R0dGTAnMs7uGqJCgVYKtNuon/Ak3JVoC9 m7HsTKtHP6JAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TOAAKCRAFzvXHieVa dDM2EADlgFfHuVhxzRAUFXYWHUVshXFxWppVaI2v5v3WGzmcm7zvWzdbsomUorOAM4w2QFCwsDN PJZej/v53j1864dRgzEt//OCLG0Aml64rVd+A18JSeWFilp2+8IqsCWCC49xieiGaKAjnR9/FXi GAk11s6XWPPCFd1vEnja3OE1Kp6TZcNaIf9jsYW6LKRYYDEh89rEqiLAWf0agyxJQMO+1OavFx+ 6Hdtkf/HlsY+H73meaETjIVWM1AXvt988Yu0kvkhida8VG4/+kVWKijsCtx+cdXkWOTD1BsGftQ euSOSzywcmO2/KIiLCmKxBxbHjB1dbmh4af3EJsLGPfn+TYpVjzl8cD0XKPs1lihcKpBDZ37uQC 2CIdQtSUaEAhEyT1+/HGqKcy+dh+yOaUSS4ZhBLQqzJ57Xay5MdPdJaXqoTwgW25EC+zhNvHZHH 8nmOg2DG2sX/x4efwlJREEYyn3xyI/qJwrtAcGnq+pUcH3p2uMkw8HZZ7lbSk6VSPdkV70BARQB HDZJn9s81iYNlOXQ9jIs0G6/PdCGpDKccBo+YhRrTQs3TxT40N42FRHWkGVw4+AmwQyMx5hzg7c P+KRXpRdpDc7U2qHN//R/Fhmgo1UKO0Mys4bonya867dRAYlX/GsHCjVMOzi6a6d7nhxWhgrEaH 4XGDW5tOTotTdbg== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092927_039577_763051FB X-CRM114-Status: GOOD ( 31.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Adds support for SPI mikroBUS addon boards with configuration based on device tree. The goal is to get a minimal version in mainline to sort out the device tree structure that should be used. A mikroBUS board can use any combination of the following based protocols: I2C, SPI, UART, PWM, Analog, GPIO with possibility of all pins being used as GPIO instead of their original purpose. This requires the driver to be flexible and identify the type of board based on the compatible string. Signed-off-by: Ayush Singh --- MAINTAINERS | 1 + drivers/misc/Kconfig | 16 +++ drivers/misc/Makefile | 1 + drivers/misc/mikrobus.c | 361 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 88f2b3adc824..01a0ac261e6c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15115,6 +15115,7 @@ S: Maintained F: Documentation/devicetree/bindings/connector/mikrobus-connector.yaml F: Documentation/devicetree/bindings/mikrobus/mikrobus-board.yaml F: Documentation/devicetree/bindings/mikrobus/mikrobus-spi.yaml +F: drivers/misc/mikrobus.c MIKROTIK CRS3XX 98DX3236 BOARD SUPPORT M: Luka Kovacic diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index faf983680040..320f408cc612 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -585,6 +585,22 @@ config NSM To compile this driver as a module, choose M here. The module will be called nsm. +menuconfig MIKROBUS + tristate "Module for instantiating devices on mikroBUS ports" + depends on GPIOLIB + help + This option enables the mikroBUS driver. mikroBUS is an add-on + board socket standard that offers maximum expandability with + the smallest number of pins. The mikroBUS driver instantiates + devices on a mikroBUS port described mikroBUS manifest which is + passed using a sysfs interface. + + + Say Y here to enable support for this driver. + + To compile this code as a module, chose M here: the module + will be called mikrobus.ko + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 153a3f4837e8..f10f1414270b 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -69,3 +69,4 @@ obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_NSM) += nsm.o +obj-$(CONFIG_MIKROBUS) += mikrobus.o diff --git a/drivers/misc/mikrobus.c b/drivers/misc/mikrobus.c new file mode 100644 index 000000000000..bf160a0e8903 --- /dev/null +++ b/drivers/misc/mikrobus.c @@ -0,0 +1,361 @@ +// SPDX-License-Identifier: GPL-2.0: +/* + * Copyright 2024 Ayush Singh + */ + +#define pr_fmt(fmt) "mikrobus:%s: " fmt, __func__ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct mikrobus_spi_cs_item { + const char *cs_name; + u32 cs; +}; + +/** + * struct mikrobus_port - MikroBUS Driver + * + * @dev: underlying platform_device + * @board_ocs: board device tree changeset + * @pinctrl: mikroBUS pinctrl + * @mikrobus_spi_cs: list of supported chipselect address and name + * @mikrobus_spi_cs_count: length of mikrobus_spi_cs + * @spi_ctrl: spi controller of mikroBUS connector + * @spi_dev: spi mikroBUS board + */ +struct mikrobus_port { + struct platform_device *dev; + struct of_changeset board_ocs; + struct pinctrl *pctrl; + + struct mikrobus_spi_cs_item *spi_cs; + int spi_cs_count; + struct spi_controller *spi_ctrl; + struct spi_device *spi_dev; +}; + +/* + * mikrobus_pinctrl_select: Select pinctrl state for mikrobus pin + * + * @port: mikrobus port + * @pinctrl_selected: pinctrl state to be selected + */ +static int mikrobus_pinctrl_select(struct device *dev, + const char *pinctrl_selected) +{ + int ret; + struct pinctrl_state *state; + struct mikrobus_port *mb = dev_get_drvdata(dev); + + state = pinctrl_lookup_state(mb->pctrl, pinctrl_selected); + if (IS_ERR(state)) + return dev_err_probe(dev, PTR_ERR(state), + "failed to find state %s", + pinctrl_selected); + + ret = pinctrl_select_state(mb->pctrl, state); + if (ret) + return dev_err_probe(dev, ret, "failed to select state %s", + pinctrl_selected); + + dev_dbg_ratelimited(dev, "setting pinctrl %s", pinctrl_selected); + + return 0; +} + +/* + * mikrobus_lookup_cs - lookup mikroBUS SPI chipselect by name + * + * @mb: mikroBUS port + * @cs_name: chipselect name + */ +static int mikrobus_lookup_cs(const struct mikrobus_port *mb, + const char *cs_name) +{ + for (int i = 0; i < mb->spi_cs_count; ++i) { + if (strcmp(cs_name, mb->spi_cs[i].cs_name) == 0) + return mb->spi_cs[i].cs; + } + + return -1; +} + +static int mikrobus_spi_set_cs(struct device *dev, struct device_node *np) +{ + struct mikrobus_port *mb = dev_get_drvdata(dev); + const char *temp_str; + int reg_len; + int ret, i; + u32 *reg = NULL; + + reg_len = of_property_count_strings(np, "spi-cs"); + /* Use default cs if spi-cs property not present */ + if (reg_len <= 0) { + reg_len = 1; + reg = devm_kmalloc_array(dev, reg_len, sizeof(*reg), + GFP_KERNEL); + if (!reg) + return -ENOMEM; + + ret = mikrobus_lookup_cs(mb, "default"); + if (ret < 0) + goto free_reg; + + reg[0] = ret; + } else { + reg = devm_kmalloc_array(dev, reg_len, sizeof(*reg), + GFP_KERNEL); + if (!reg) + return -ENOMEM; + + for (i = 0; i < reg_len; ++i) { + ret = of_property_read_string_index(np, "spi-cs", i, + &temp_str); + if (ret < 0) + goto free_reg; + + ret = mikrobus_lookup_cs(mb, temp_str); + if (ret < 0) + goto free_reg; + + reg[i] = ret; + } + } + + ret = of_changeset_add_prop_u32_array(&mb->board_ocs, np, "reg", reg, + reg_len); + if (ret < 0) + goto free_reg; + + ret = of_changeset_apply(&mb->board_ocs); + if (ret < 0) + goto free_reg; + + devm_kfree(dev, reg); + return 0; + +free_reg: + devm_kfree(dev, reg); + return ret; +} + +static int of_register_mikrobus_device(struct mikrobus_port *mb, + struct device_node *np) +{ + const char *temp_str; + int i, pinctrl_count, ret; + struct spi_device *spi_dev; + struct device *dev = &mb->dev->dev; + + pinctrl_count = of_property_count_strings(np, "pinctrl-apply"); + if (pinctrl_count < 0) + return dev_err_probe(dev, pinctrl_count, + "Missing required property pinctrl-apply"); + + for (i = 0; i < pinctrl_count; ++i) { + ret = of_property_read_string_index(np, "pinctrl-apply", i, + &temp_str); + if (ret < 0) + return ret; + + ret = mikrobus_pinctrl_select(dev, temp_str); + if (ret < 0) + return dev_err_probe(dev, ret, "Failed to set pinctrl"); + } + + if (mb->spi_ctrl && !mb->spi_dev && + of_device_is_compatible(np, "mikrobus-spi")) { + ret = mikrobus_spi_set_cs(dev, np); + if (ret < 0) + return dev_err_probe(dev, ret, + "Failed to set SPI chipselect"); + + spi_dev = of_register_spi_device(mb->spi_ctrl, np); + if (IS_ERR(spi_dev)) + return dev_err_probe(dev, PTR_ERR(spi_dev), + "Failed to register SPI device"); + mb->spi_dev = spi_dev; + } + + return 0; +} + +static int of_register_mikrobus_board(struct mikrobus_port *mb) +{ + struct device *dev = &mb->dev->dev; + int board_len, i, ret; + struct device_node *np; + + board_len = of_count_phandle_with_args(dev->of_node, "board", NULL); + for (i = 0; i < board_len; ++i) { + np = of_parse_phandle(dev->of_node, "board", i); + if (!np) { + ret = dev_err_probe(dev, -ENODEV, "Board not found"); + goto free_np; + } + + ret = of_register_mikrobus_device(mb, np); + if (ret < 0) + goto free_np; + + of_node_put(np); + } + + return 0; +free_np: + of_node_put(np); + return ret; +} + +static int mikrobus_port_probe(struct platform_device *pdev) +{ + int ret, i; + struct mikrobus_port *mb; + struct device_node *np; + struct device *dev = &pdev->dev; + + mb = devm_kmalloc(dev, sizeof(*mb), GFP_KERNEL); + if (!mb) + return -ENOMEM; + + dev_set_drvdata(dev, mb); + + of_changeset_init(&mb->board_ocs); + mb->dev = pdev; + mb->pctrl = NULL; + mb->spi_ctrl = NULL; + mb->spi_dev = NULL; + mb->spi_cs = NULL; + mb->spi_cs_count = 0; + + mb->pctrl = devm_pinctrl_get(dev); + if (IS_ERR(mb->pctrl)) + return dev_err_probe(dev, PTR_ERR(mb->pctrl), + "failed to get pinctrl [%ld]", + PTR_ERR(mb->pctrl)); + + np = of_parse_phandle(dev->of_node, "spi-controller", 0); + if (np) { + mb->spi_ctrl = of_find_spi_controller_by_node(np); + if (mb->spi_ctrl) { + ret = of_property_count_u32_elems(dev->of_node, + "spi-cs"); + if (ret < 0) { + dev_err(dev, "Missing property spi-cs"); + goto free_np; + } + + mb->spi_cs_count = ret; + + ret = of_property_count_strings(dev->of_node, + "spi-cs-names"); + if (ret < 0) { + dev_err(dev, "Missing property spi-cs-names"); + goto free_np; + } + + if (mb->spi_cs_count != ret) { + ret = dev_err_probe( + dev, -EINVAL, + "spi-cs and spi-cs-names out of sync"); + goto free_np; + } + + mb->spi_cs = devm_kmalloc_array(dev, mb->spi_cs_count, + sizeof(*mb->spi_cs), + GFP_KERNEL); + if (!mb->spi_cs) { + ret = -ENOMEM; + goto free_np; + } + + for (i = 0; i < mb->spi_cs_count; ++i) { + of_property_read_u32_index(dev->of_node, + "spi-cs", i, + &mb->spi_cs->cs); + of_property_read_string_index( + dev->of_node, "spi-cs-names", i, + &mb->spi_cs->cs_name); + } + } + } + of_node_put(np); + + ret = of_register_mikrobus_board(mb); + if (ret < 0) + return dev_err_probe(dev, -EINVAL, + "Failed to register mikrobus board"); + + return 0; + +free_np: + of_node_put(np); + return ret; +} + +static void mikrobus_port_remove(struct platform_device *pdev) +{ + struct mikrobus_port *mb = dev_get_drvdata(&pdev->dev); + + spi_unregister_device(mb->spi_dev); + + of_changeset_revert(&mb->board_ocs); +} + +static const struct of_device_id mikrobus_port_of_match[] = { + { .compatible = "mikrobus-connector" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mikrobus_port_of_match); + +static struct platform_driver mikrobus_port_driver = { + .probe = mikrobus_port_probe, + .remove = mikrobus_port_remove, + .driver = { + .name = "mikrobus", + .of_match_table = mikrobus_port_of_match, + }, +}; + +static const struct bus_type mikrobus_bus_type = { + .name = "mikrobus", +}; + +static int mikrobus_init(void) +{ + int ret; + + ret = bus_register(&mikrobus_bus_type); + if (ret) { + pr_err("bus_register failed (%d)", ret); + return ret; + } + + ret = platform_driver_register(&mikrobus_port_driver); + if (ret) + pr_err("driver register failed [%d]", ret); + + return 0; +} + +module_init(mikrobus_init); + +static void mikrobus_exit(void) +{ + platform_driver_unregister(&mikrobus_port_driver); + bus_unregister(&mikrobus_bus_type); +} + +module_exit(mikrobus_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Ayush Singh "); +MODULE_DESCRIPTION("mikroBUS driver for linux"); +MODULE_VERSION("0.1"); From patchwork Thu Jun 27 16:26:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ayush Singh X-Patchwork-Id: 13714803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A70ACC2BD09 for ; Thu, 27 Jun 2024 16:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Vf+oty1NdLS1qae2Gc3SWM3tL3BZVhVoAyzz4KnihM4=; b=tFEpvmTKe0mZ9zuen8P13q7rTH Ym9exFcqccuzApQAE5Dl40jZzj10ozrrAr2QX2kqp34efiPLmA2gp7QxSYUlgVXhwPvBSdwGIcZjJ qHxmeQyYNWrPWSPSPdirR+QB6q1T5zB45LefzavLGDYrQlMLbRrUJnVrvajsMP4TjnG3es/+xeFbX 9DnI6zmbghDXCya7mrgsyp2NlYgRK4F40zaNnfXWQkfpXbm5WMAoykn96KptrpAlHQIHeNH2uziL3 StiWzMhPY6NLFLL3omHk64TMHo4e4MtFHQIZOnmHHmBOKXRuy5StmrP3OJ8rALr3lWQrkDAANp8HC AJtpRcfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMs0N-0000000B3Ck-3Rn2; Thu, 27 Jun 2024 16:29:51 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMs05-0000000B30e-0D8d for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 16:29:35 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7065f3de571so259977b3a.0 for ; Thu, 27 Jun 2024 09:29:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20230601.gappssmtp.com; s=20230601; t=1719505772; x=1720110572; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Vf+oty1NdLS1qae2Gc3SWM3tL3BZVhVoAyzz4KnihM4=; b=1ElmUyNpoRlpnSCsujmlFb3otdCDCKxn6gy0wdd2jZ4vmv1635fljzRqmnCKYYqX5H FBVWlxE+2YlfkpObIX9A9Xr+wUqcgsr6WWlTQCE76Ln9q5+PR1RaJZyIkHYSqVpMJ9Yg Yol0cBkbl75eCN8c1J5eYaUSVxc9VqFVzRcY7X61CnqEgUw2xYbCFWuCEHXh/dvmheR4 yzSES4wBLIvqi81o6cYxS1a1fN45bUAMMG9C9vrWhcJT/nSMZw3cO6PSu3bHNLRZqxD6 9lcECENq1UDAxg+7ueJoiET/L6c6QOrqNSg8N1/akL4yV3kH310BAM6Ok0ylsOO4lDxh mjRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505772; x=1720110572; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vf+oty1NdLS1qae2Gc3SWM3tL3BZVhVoAyzz4KnihM4=; b=vhjEybAXM3IERaE+dndptg+X8ztxXP0PnSxc0WAaK7S3sekKA9HZdlAjF9czjbqEcQ 5SWJh6EiWUzO8YikMUT/NUfRTdN6fzVL+X/qEzCpJLuuIe4RXK6FIM8R2Xt3SVRz9Bag Vzxjiogfu3I+k5cWAJBjisz8+ZFBlnedu0f9msDnYptq7v7ZIgGskONdQ0NwNdrm7DF+ 1CNRZRRXaleWTZXdkiekX33Jl2MelNiplFAPwEYZejhfJJ6GutwRvXKK5TcNgFcWtKLD mIYSz2YSOPPNNyA1S0i0/l6WovU749EitGrXmPGmq8XdO5eM0ECCUf/6gw4UFBxIGRAL s9dg== X-Forwarded-Encrypted: i=1; AJvYcCV7ff6BawlwqMfbt/ADot4DFuFQgDWq5uBeyLRNr3HpX+FLR1+oKreiNALQ5Rsz2JzHT9df0OlLBWg0pFO9Tp833V/rfPmw/y8wnBaiO5HBkk2Tw9M= X-Gm-Message-State: AOJu0YywLOIa/522KOq74fMJpyNzLJiI4nxq00ddWt8iFiV71gwhgrCJ pNhiWgFv/fG7Ymi6YIohzXVo9BXeVc85iwTzKFL5tmhZfk+F6cJasPPPEFPOhA== X-Google-Smtp-Source: AGHT+IEM53rJZfG+wXWNukg7BNDZblkSojZV/fyTaxHEkXKgKetvOptN3XWLNYHdMUoSnCpCZfNjsw== X-Received: by 2002:a05:6a00:3e24:b0:706:7d86:487f with SMTP id d2e1a72fcca58-7067d864f28mr12998499b3a.1.1719505772201; Thu, 27 Jun 2024 09:29:32 -0700 (PDT) Received: from [127.0.0.1] ([2401:4900:1f3e:18b0:e4e6:ed1:4c03:dcec]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58dbdsm1560739b3a.198.2024.06.27.09.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 09:29:31 -0700 (PDT) From: Ayush Singh Date: Thu, 27 Jun 2024 21:56:17 +0530 Subject: [PATCH v5 7/7] dts: ti: k3-am625-beagleplay: Add mikroBUS MIME-Version: 1.0 Message-Id: <20240627-mikrobus-scratch-spi-v5-7-9e6c148bf5f0@beagleboard.org> References: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> In-Reply-To: <20240627-mikrobus-scratch-spi-v5-0-9e6c148bf5f0@beagleboard.org> To: Mark Brown , Vaishnav M A , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Michael Walle , Andrew Lunn , jkridner@beagleboard.org, robertcnelson@beagleboard.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ayush Singh X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5723; i=ayush@beagleboard.org; h=from:subject:message-id; bh=0t/wFPVC4l/yw5eF3OeLLEEWm+E+fxx+yaa8gVfDqK0=; b=owEBbQKS/ZANAwAIAQXO9ceJ5Vp0AcsmYgBmfZM459JpVph8a7o9EFioAHe3jzmpm5BUTLvDx XeluaGM06CJAjMEAAEIAB0WIQTfzBMe8k8tZW+lBNYFzvXHieVadAUCZn2TOAAKCRAFzvXHieVa dHpEEADUBssv55R+SULKv6RULv+gOVxAXjyNVscI7LK8hDDfBEOV5xQlG5hFW92XtL9Bfrb5lgl ZQaS2VYyLcEzhTxJDPL6b0oKD3/xdOJ/y8vYBptr3YzlyS+Cg8S9h1HFL3W1wQSG4LT5HhegLHT 710faT8vf3t9XYdJqWNJyoCtBOgeMHMRRl+3ttbE9nfGpSIMvRurgAB0No8tO9pkgEZwAv72f9g /4LZO8Dor8YNa/U0HTaTrgrBAppF+TQg7jRTRE41/Og4KalwNzJKU1IuoFqlSYQzI+97d7P+R75 JRRt6H9U08UAvbJJ7JENif3m0nvLjPAGmUMsFVnEdult61dDpBoXzY3ZOUdYf1X+/BmXPFc6sUP bU4CRyOYFXPIlr5eRK5cybJv1neaVxdUlrqjh460vj3KS8f64760NPhd0lOCy4xQ/UBcw7ie6Gd /ZA8IWz091iwfRve1IneXpEjtnMM4/nQq+dZs32pQb/IgtTShP3jZXr+ldxFA5azE40lLVjH6yg mBopgaiLW0aFD3Cw20n0TnihXe9fsOkddjiJAXMFLESb7i3O41GnNAjh9hLS4E+hWTmK4Z569Ap q/YPzQtimt+rqtnByhlWUYaf6yJpLPYuL3vSjjlAngvbQgCI3Ir+L1uWyerY7T8CqDQVCPzObJ2 PqOaFYgnkKeIUoA== X-Developer-Key: i=ayush@beagleboard.org; a=openpgp; fpr=DFCC131EF24F2D656FA504D605CEF5C789E55A74 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_092933_153400_72F92E11 X-CRM114-Status: GOOD ( 14.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DONOTMERGE Add mikroBUS connector and some mikroBUS boards support for Beagleplay. The mikroBUS boards node should probably be moved to a more appropriate location but I am not quite sure where it should go since it is not dependent on specific arch. Signed-off-by: Ayush Singh --- arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts | 94 +++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts b/arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts index 70de288d728e..3f3cd70345c4 100644 --- a/arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts +++ b/arch/arm64/boot/dts/ti/k3-am625-beagleplay.dts @@ -38,6 +38,7 @@ aliases { serial2 = &main_uart0; usb0 = &usb0; usb1 = &usb1; + mikrobus0 = &mikrobus0; }; chosen { @@ -227,6 +228,56 @@ simple-audio-card,codec { }; }; + mikrobus0: mikrobus-connector { + compatible = "mikrobus-connector"; + pinctrl-names = "default", "pwm_default", "pwm_gpio", + "uart_default", "uart_gpio", "i2c_default", + "i2c_gpio", "spi_default", "spi_gpio"; + pinctrl-0 = <&mikrobus_gpio_pins_default>; + pinctrl-1 = <&mikrobus_pwm_pins_default>; + pinctrl-2 = <&mikrobus_pwm_pins_gpio>; + pinctrl-3 = <&mikrobus_uart_pins_default>; + pinctrl-4 = <&mikrobus_uart_pins_gpio>; + pinctrl-5 = <&mikrobus_i2c_pins_default>; + pinctrl-6 = <&mikrobus_i2c_pins_gpio>; + pinctrl-7 = <&mikrobus_spi_pins_default>; + pinctrl-8 = <&mikrobus_spi_pins_gpio>; + + mikrobus-gpio-names = "pwm", "int", "rx", "tx", "scl", "sda", + "mosi", "miso", "sck", "cs", "rst", "an"; + mikrobus-gpios = <&main_gpio1 11 GPIO_ACTIVE_HIGH>, + <&main_gpio1 9 GPIO_ACTIVE_HIGH>, + <&main_gpio1 24 GPIO_ACTIVE_HIGH>, + <&main_gpio1 25 GPIO_ACTIVE_HIGH>, + <&main_gpio1 22 GPIO_ACTIVE_HIGH>, + <&main_gpio1 23 GPIO_ACTIVE_HIGH>, + <&main_gpio1 7 GPIO_ACTIVE_HIGH>, + <&main_gpio1 8 GPIO_ACTIVE_HIGH>, + <&main_gpio1 14 GPIO_ACTIVE_HIGH>, + <&main_gpio1 13 GPIO_ACTIVE_HIGH>, + <&main_gpio1 12 GPIO_ACTIVE_HIGH>, + <&main_gpio1 10 GPIO_ACTIVE_HIGH>; + + spi-controller = <&main_spi2>; + spi-cs = <0>; + spi-cs-names = "default"; + + board = <&lsm6dsl_click>; + }; + + mikrobus_boards { + thermo_click: thermo-click { + compatible = "maxim,max31855k", "mikrobus-spi"; + spi-max-frequency = <1000000>; + pinctrl-apply = "spi_default"; + }; + + lsm6dsl_click: lsm6dsl-click { + compatible = "st,lsm6ds3", "mikrobus-spi"; + spi-max-frequency = <1000000>; + pinctrl-apply = "spi_default"; + }; + }; }; &main_pmx0 { @@ -387,6 +438,18 @@ AM62X_IOPAD(0x01f0, PIN_OUTPUT, 5) /* (A18) EXT_REFCLK1.CLKOUT0 */ >; }; + mikrobus_pwm_pins_default: mikrobus-pwm-default-pins { + pinctrl-single,pins = < + AM62X_IOPAD(0x01a4, PIN_INPUT, 2) /* (B20) MCASP0_ACLKX.ECAP2_IN_APWM_OUT */ + >; + }; + + mikrobus_pwm_pins_gpio: mikrobus-pwm-gpio-pins { + pinctrl-single,pins = < + AM62X_IOPAD(0x01a4, PIN_INPUT, 7) /* (B20) MCASP0_ACLKX.GPIO1_11 */ + >; + }; + mikrobus_i2c_pins_default: mikrobus-i2c-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x01d0, PIN_INPUT_PULLUP, 2) /* (A15) UART0_CTSn.I2C3_SCL */ @@ -394,6 +457,13 @@ AM62X_IOPAD(0x01d4, PIN_INPUT_PULLUP, 2) /* (B15) UART0_RTSn.I2C3_SDA */ >; }; + mikrobus_i2c_pins_gpio: mikrobus-i2c-gpio-pins { + pinctrl-single,pins = < + AM62X_IOPAD(0x01d0, PIN_INPUT, 7) /* (A15) UART0_CTSn.GPIO1_22 */ + AM62X_IOPAD(0x01d4, PIN_INPUT, 7) /* (B15) UART0_RTSn.GPIO1_23 */ + >; + }; + mikrobus_uart_pins_default: mikrobus-uart-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x01d8, PIN_INPUT, 1) /* (C15) MCAN0_TX.UART5_RXD */ @@ -401,6 +471,13 @@ AM62X_IOPAD(0x01dc, PIN_OUTPUT, 1) /* (E15) MCAN0_RX.UART5_TXD */ >; }; + mikrobus_uart_pins_gpio: mikrobus-uart-gpio-pins { + pinctrl-single,pins = < + AM62X_IOPAD(0x01d8, PIN_INPUT, 7) /* (C15) MCAN0_TX.GPIO1_24 */ + AM62X_IOPAD(0x01dc, PIN_INPUT, 7) /* (E15) MCAN0_RX.GPIO1_25 */ + >; + }; + mikrobus_spi_pins_default: mikrobus-spi-default-pins { pinctrl-single,pins = < AM62X_IOPAD(0x01b0, PIN_INPUT, 1) /* (A20) MCASP0_ACLKR.SPI2_CLK */ @@ -410,6 +487,15 @@ AM62X_IOPAD(0x0198, PIN_INPUT, 1) /* (A19) MCASP0_AXR2.SPI2_D1 */ >; }; + mikrobus_spi_pins_gpio: mikrobus-spi-gpio-pins { + pinctrl-single,pins = < + AM62X_IOPAD(0x0194, PIN_INPUT, 7) /* (B19) MCASP0_AXR3.GPIO1_7 */ + AM62X_IOPAD(0x0198, PIN_INPUT, 7) /* (A19) MCASP0_AXR2.GPIO1_8 */ + AM62X_IOPAD(0x01ac, PIN_INPUT, 7) /* (E19) MCASP0_AFSR.GPIO1_13 */ + AM62X_IOPAD(0x01b0, PIN_INPUT, 7) /* (A20) MCASP0_ACLKR.GPIO1_14 */ + >; + }; + mikrobus_gpio_pins_default: mikrobus-gpio-default-pins { bootph-all; pinctrl-single,pins = < @@ -630,8 +716,6 @@ &main_gpio0 { &main_gpio1 { bootph-all; - pinctrl-names = "default"; - pinctrl-0 = <&mikrobus_gpio_pins_default>; gpio-line-names = "", "", "", "", "", /* 0-4 */ "SPE_RSTN", "SPE_INTN", "MIKROBUS_GPIO1_7", /* 5-7 */ "MIKROBUS_GPIO1_8", "MIKROBUS_GPIO1_9", /* 8-9 */ @@ -804,15 +888,11 @@ it66121_out: endpoint { }; &main_i2c3 { - pinctrl-names = "default"; - pinctrl-0 = <&mikrobus_i2c_pins_default>; clock-frequency = <400000>; status = "okay"; }; &main_spi2 { - pinctrl-names = "default"; - pinctrl-0 = <&mikrobus_spi_pins_default>; status = "okay"; }; @@ -876,8 +956,6 @@ &main_uart1 { }; &main_uart5 { - pinctrl-names = "default"; - pinctrl-0 = <&mikrobus_uart_pins_default>; status = "okay"; };