From patchwork Tue Aug 20 14:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 13770256 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 50B30C3DA4A for ; Tue, 20 Aug 2024 14:37:27 +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:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=OfyTQeSSkPZ+QzWWZU+FNyyT4+itZMzr8DmOygd/33U=; b=eHw6098riaiLVJy3FMqend9Dxw qePVy7qJUqqhoEJKVwEwq2KGyO/TbvQ6GKkfoh/nwtzxYmjHGoYl8+yiWGmcecq63yDZu3QqhHtR5 +aLDE1rICD6NBbm59qDk3yKsvPfBts1NPRMn03lkNr6Ggf2NSBPbKvYAr72/B1/tFaAdrhiaNsjlc xXL+CD8PUhCmOz25QzseKYDlU0/ZLIL0oW1OEhzecgZ0FnT3FXegCEtG0JOkd4ZbzjuVPSoHW4Qgs Zgz9U7B0diyfq8Z7sSp15GwYb2p1voBwMS9nHWRUSka/p0oJ15+6gaGS8fhaTskGeR4nfSfx6RAr5 VcY1aTEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPyx-00000005aFG-1wVn; Tue, 20 Aug 2024 14:37:11 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPy3-00000005Zug-0Fza for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:36:16 +0000 Received: by mail-lf1-x143.google.com with SMTP id 2adb3069b0e04-533462b9428so353372e87.3 for ; Tue, 20 Aug 2024 07:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1724164572; x=1724769372; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=OfyTQeSSkPZ+QzWWZU+FNyyT4+itZMzr8DmOygd/33U=; b=JK+jBK/agkNljFpOsQ/CevmZL4FPSPirYg8Ira1I/7X/F8Nea+Ww5HxZ+QUYZdWatw 8WsNJKX7KNfZoEFfSdDgp5D2bP8jlppN8zMlBQexpf3CKVR20sl5a3sSyLWtO5sAnKRy SsPMPu+SH4RZ1cU31Nj0P8c3ssATRi8g1m348EZkDB9W3LACZypKTtPc+DZLYver2K6D L0j1tQjyVivk4SlC6juQsnerwMVt4VEF2PoFaZy8N7xq2ubDLbvyDoOqx//N3CAhX8P0 i6o4EoBEOtIEsbD5c7E50MQr+W6RquEi4db8KUZKkH+6ItrJMjZz09jdErklvBxGGVTi HxLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724164572; x=1724769372; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OfyTQeSSkPZ+QzWWZU+FNyyT4+itZMzr8DmOygd/33U=; b=QCUgiVQWJlzX0b1IfQJyklCFXLTiBfjjMGZywOAyT3FhZ/pul9GS1/1cuglDZc+tgJ RuvSynBtNRXty9JB1ZTq+GDojdYsFwkgp0gyuXJup+ngJEWpHU1JhVcYCIcmx8zB1Ouv w9jq2CHR/NI33tFxWwxJupXJ/7pYGJs6CBMRDxlnJm62PZkADQks7to/UJcRv4/l4HI7 EVZ/MU+/PXX6EQ9tYIhzOHu4SLEgk0zq3mx8AtxOzWIEpKpWdP11FFaus8RYHqEDYJqY uqAFHlMUXCrMnon3hvV44jZDyVujN1rloaqBC51QseNGO4yKtQw3juyn7G86mcpHlDDr V1JA== X-Forwarded-Encrypted: i=1; AJvYcCXu0Khk9Tcid1cetSqOb3ii+5L86a6WFKMMVS3XvE9Ds5kxD+WGrQrahWRlsYEbBVa6LSJ/bJNEMeyhChC/12BcVe7P/lk2BkFYpuxfTDBjlQF6Wxk= X-Gm-Message-State: AOJu0YztbjBW5w7E1ZrMScz3QqaMe5F8BUEb8gdx3svY1qiJae1TxMos sh8xTm/acToSRaScSrb+9YzBrdUDdVoMzi+UOARSAIYY3bUpK8jBQmJ2yw1ysSY= X-Google-Smtp-Source: AGHT+IFLUQVFBJiZPnU1UIStc9VMSRLEpQuaGd1PxEKJ/fpKdzW6906wlGxbUZmW87C0ek7drDgHNg== X-Received: by 2002:a05:6512:3b8b:b0:52e:fa5f:b6a7 with SMTP id 2adb3069b0e04-5331c6a0569mr10710062e87.13.1724164571458; Tue, 20 Aug 2024 07:36:11 -0700 (PDT) Received: from localhost ([87.13.33.30]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a838396940fsm772692466b.189.2024.08.20.07.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 07:36:11 -0700 (PDT) From: Andrea della Porta To: Andrea della Porta , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Linus Walleij , Catalin Marinas , Will Deacon , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Nicolas Ferre , Claudiu Beznea , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Saravana Kannan , Bjorn Helgaas , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, Lee Jones , Andrew Lunn , Stefan Wahren Subject: [PATCH 00/11] Add support for RaspberryPi RP1 PCI device using a DT overlay Date: Tue, 20 Aug 2024 16:36:02 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240820_073615_136595_D8EA6564 X-CRM114-Status: GOOD ( 27.18 ) 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 RP1 is an MFD chipset that acts as a south-bridge PCIe endpoint sporting a pletora of subdevices (i.e. Ethernet, USB host controller, I2C, PWM, etc.) whose registers are all reachable starting from an offset from the BAR address. The main point here is that while the RP1 as an endpoint itself is discoverable via usual PCI enumeraiton, the devices it contains are not discoverable and must be declared e.g. via the devicetree. This patchset is an attempt to provide a minimum infrastructure to allow the RP1 chipset to be discovered and perpherals it contains to be added from a devictree overlay loaded during RP1 PCI endpoint enumeration. Followup patches should add support for the several peripherals contained in RP1. This work is based upon dowstream drivers code and the proposal from RH et al. (see [1] and [2]). A similar approach is also pursued in [3]. The patches are ordered as follows: -PATCHES 1 and 2: add binding schemas for clock and gpio peripherals found in RP1. They are needed to support the other peripherals, e.g. the ethernet mac depends on a clock generated by RP1 and the phy is reset though the on-board gpio controller. -PATCHES 3, 4 and 5: preparatory patches that fix the address mapping translation (especially wrt dma-ranges) and permit to place the dtbo binary blob to be put in non transient section. -PATCH 6 and 7: add clock and gpio device drivers. -PATCH 8: this is the main patch to support RP1 chipset and peripherals enabling through dtb overlay. It contains the dtso since its intimately coupled with the driver and will be linked in as binary blob in the driver obj, but of course it can be easily split in a separate patch if the maintainer feels it so. The real dtso is in devicetree folder while the dtso in driver folder is just a placeholder to include the real dtso. In this way it is possible to check the dtso against dt-bindings. -PATCH 9: add the relevant kernel CONFIG_ options to defconfig. -PATCHES 10 and 11: these (still unpolished) patches are not intended to be upstreamed (yet), they serve just as a test reference to be able to use the ethernet MAC contained in RP1. This patchset is also a first attempt to be more agnostic wrt hardware description standards such as OF devicetree and ACPI, where 'agnostic' means "using DT in coexistence with ACPI", as been alredy promoted by e.g. AL (see [4]). Although there's currently no evidence it will also run out of the box on purely ACPI system, it is a first step towards that direction. Please note that albeit this patchset has no prerequisites in order to be applied cleanly, it still depends on Stanimir's WIP patchset for BCM2712 PCIe controller (see [5]) in order to work at runtime. Many thanks, Andrea della Porta Link: - [1]: https://lpc.events/event/17/contributions/1421/attachments/1337/2680/LPC2023%20Non-discoverable%20devices%20in%20PCI.pdf - [2]: https://lore.kernel.org/lkml/20230419231155.GA899497-robh@kernel.org/t/ - [3]: https://lore.kernel.org/all/20240808154658.247873-1-herve.codina@bootlin.com/#t - [4]: https://lore.kernel.org/all/73e05c77-6d53-4aae-95ac-415456ff0ae4@lunn.ch/ - [5]: https://lore.kernel.org/all/20240626104544.14233-1-svarbanov@suse.de/ Andrea della Porta (11): dt-bindings: clock: Add RaspberryPi RP1 clock bindings dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings PCI: of_property: Sanitize 32 bit PCI address parsed from DT of: address: Preserve the flags portion on 1:1 dma-ranges mapping vmlinux.lds.h: Preserve DTB sections from being discarded after init clk: rp1: Add support for clocks provided by RP1 pinctrl: rp1: Implement RaspberryPi RP1 gpio support misc: rp1: RaspberryPi RP1 misc driver arm64: defconfig: Enable RP1 misc/clock/gpio drivers as built-in net: macb: Add support for RP1's MACB variant arm64: dts: rp1: Add support for MACB contained in RP1 .../clock/raspberrypi,rp1-clocks.yaml | 87 + .../pinctrl/raspberrypi,rp1-gpio.yaml | 177 ++ MAINTAINERS | 12 + arch/arm64/boot/dts/broadcom/rp1.dtso | 175 ++ arch/arm64/configs/defconfig | 3 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1655 +++++++++++++++++ drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 20 + drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.c | 333 ++++ drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/net/ethernet/cadence/macb.h | 25 + drivers/net/ethernet/cadence/macb_main.c | 152 +- drivers/of/address.c | 3 +- drivers/pci/of_property.c | 5 +- drivers/pci/quirks.c | 1 + drivers/pinctrl/Kconfig | 10 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 719 +++++++ include/asm-generic/vmlinux.lds.h | 2 +- include/dt-bindings/clock/rp1.h | 56 + include/dt-bindings/misc/rp1.h | 235 +++ include/linux/pci_ids.h | 3 + 26 files changed, 3692 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso create mode 100644 drivers/clk/clk-rp1.c create mode 100644 drivers/misc/rp1/Kconfig create mode 100644 drivers/misc/rp1/Makefile create mode 100644 drivers/misc/rp1/rp1-pci.c create mode 100644 drivers/misc/rp1/rp1-pci.dtso create mode 100644 drivers/pinctrl/pinctrl-rp1.c create mode 100644 include/dt-bindings/clock/rp1.h create mode 100644 include/dt-bindings/misc/rp1.h