From nobody Wed Nov 27 22:33:16 2024 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BCA51D2708 for ; Mon, 7 Oct 2024 12:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304790; cv=none; b=Edl211EWoyQHzk7mVKKeUgB+5gJQqm33hj9HeajEXYHzVDb9cKwQaumXvUqvj0/E80V8Y9fJjhDdW1jz8afd7Gosu1gNprdE6C1Lir8hyeV25MVG391ZZvQ8sBnYi2NGt+4SbbNF153KowDzMyktaWOFC8znke3E5bW1md+x0po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304790; c=relaxed/simple; bh=7UhSvQBmVVVFTx8acFF6PuDjpxUKtYsn2w3BfhfFDuI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K4ec9fRbdXWzrjDTnis1Fu/mDckpLwFrVfcEwHoHU2B6my3C7N7Y6d9N0v59smuk+qg2vM2wecHBD8FPyqynn6ppK3kja9waueEv3hCsQRm2m/hLQALIM38kkpdR/pPM/vasjQ+0tODo03ZEiMYDy2eoYuKy7Jpt4pqEMTVV5FQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=JuR2da2I; arc=none smtp.client-ip=209.85.208.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="JuR2da2I" Received: by mail-lj1-f195.google.com with SMTP id 38308e7fff4ca-2fac47f0b1aso50601961fa.1 for ; Mon, 07 Oct 2024 05:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304787; x=1728909587; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FgrKN4eApCbFOs4N+EhAzDBdIZKuI46lB8d+c3tNOMA=; b=JuR2da2IUc7N0l5uBplNuBqaCp2RLdfIVzFNljP9fvbPtMuVG3mndVn6+/it92EA/S 3qN2Ein0mO4eIwPX7SD7Q9Xc8u1zMdFCw96MQt3Milw3kFafEfA8slgYDJy9hsTSyEkI +QGDilkxNXj+TUa0wfdZN0mU/bMewoWcHVjFIpVpWypDfePZegQqVA34Q5Z4lHfUOMAM OzLRywRp9gjjJ7k9I4erkJ2GW2djxypD/PWD4vIYCOTHiGmzc0sPZTPW1VNMLILFt+N8 uPeExEf1bI8ZDOYv8gAXF+meYBzzmQah+oUJl0Hsk7EpboV6lBinSdTSyMInZcQ5C26g WYWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304787; x=1728909587; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FgrKN4eApCbFOs4N+EhAzDBdIZKuI46lB8d+c3tNOMA=; b=b+N6qS2rCPFjzDdm9q6TRuoNEs1NfMyBYdzOT0+wRNjadfv4UvufO2tRuc3tyvlqUC zyumHsh3fjy8RbXGj07ClZo5+AkBkPq6ebuMCLd2M9y4eZNc45B8GuD6braO/oYsvoL3 Lv1pNnhtyVF7kqkePLevi2+2TfaLL+lWCcFsTBx85XmyBU49BNCUCUrfIXSKV3X8f0/7 nNG8Ko6dapLpiHFBsJIOPXr8+BH5JFG1v+tnrJL8gX+6ySQDLE4w2LMBzrf705PQ2jK9 5b1w6o6mkCzyhQPiN9uFGWyzd+Oolyc6R9oAzWnI16TD2VCUGzzRPjBHJFkQ1TkKnNvL kYdw== X-Forwarded-Encrypted: i=1; AJvYcCUrGcdn01bIaoiO+lyPUVTKRbUBncp6Dk1wgHpGqJPu07Nc/CDqJWboc0QNORRjXehSWxxhv5iYt3ob8hU=@vger.kernel.org X-Gm-Message-State: AOJu0YwJkZGhzMmYp246wWsUJJoJq7I/kfixj+aI09/GxwL7S/DYhDb5 jg3N7eOSeHg+cfJd+5JELUiFCD4BZg3QRNOC9C6poccgoaONwVM8OfY9KgCP5EI= X-Google-Smtp-Source: AGHT+IHDEGgQN5ZAuRiG2HqradKHEOIaOuc7C2a238QEWkbXsHMPYlNkPtg/LPod7W5QLOgBwmJ3dg== X-Received: by 2002:a05:6512:3085:b0:539:8a9a:4e56 with SMTP id 2adb3069b0e04-539ab8c6fb8mr5863094e87.53.1728304786571; Mon, 07 Oct 2024 05:39:46 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994e6e571asm189783166b.85.2024.10.07.05.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:46 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 01/14] dt-bindings: clock: Add RaspberryPi RP1 clock bindings Date: Mon, 7 Oct 2024 14:39:44 +0200 Message-ID: <74199551e7a9e43a9aa2e1ed1a678493e7a8fb2c.1728300189.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add device tree bindings for the clock generator found in RP1 multi function device, and relative entries in MAINTAINERS file. Signed-off-by: Andrea della Porta --- .../clock/raspberrypi,rp1-clocks.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ .../clock/raspberrypi,rp1-clocks.h | 61 ++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/raspberrypi,rp1= -clocks.yaml create mode 100644 include/dt-bindings/clock/raspberrypi,rp1-clocks.h diff --git a/Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks= .yaml b/Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml new file mode 100644 index 000000000000..5e2e98051bf3 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/raspberrypi,rp1-clocks.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 clock generator + +maintainers: + - Andrea della Porta + +description: | + The RP1 contains a clock generator designed as three PLLs (CORE, AUDIO, + VIDEO), and each PLL output can be programmed though dividers to generate + the clocks to drive the sub-peripherals embedded inside the chipset. + + Link to datasheet: + https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf + +properties: + compatible: + const: raspberrypi,rp1-clocks + + reg: + maxItems: 1 + + '#clock-cells': + description: + The index in the assigned-clocks is mapped to the output clock as per + definitions in dt-bindings/clock/raspberrypi,rp1-clocks.h. + const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: rp1-xosc + +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include + + rp1 { + #address-cells =3D <2>; + #size-cells =3D <2>; + + rp1_clocks: clocks@c040018000 { + compatible =3D "raspberrypi,rp1-clocks"; + reg =3D <0xc0 0x40018000 0x0 0x10038>; + #clock-cells =3D <1>; + clocks =3D <&clk_rp1_xosc>; + clock-names =3D "rp1-xosc"; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index c27f3190737f..75a66e3e34c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19380,6 +19380,12 @@ F: Documentation/devicetree/bindings/media/raspber= rypi,pispbe.yaml F: drivers/media/platform/raspberrypi/pisp_be/ F: include/uapi/linux/media/raspberrypi/ =20 +RASPBERRY PI RP1 PCI DRIVER +M: Andrea della Porta +S: Maintained +F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: include/dt-bindings/clock/rp1.h + RC-CORE / LIRC FRAMEWORK M: Sean Young L: linux-media@vger.kernel.org diff --git a/include/dt-bindings/clock/raspberrypi,rp1-clocks.h b/include/d= t-bindings/clock/raspberrypi,rp1-clocks.h new file mode 100644 index 000000000000..b7c1eaa74eae --- /dev/null +++ b/include/dt-bindings/clock/raspberrypi,rp1-clocks.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * Copyright (C) 2021 Raspberry Pi Ltd. + */ + +#ifndef __DT_BINDINGS_CLOCK_RASPBERRYPI_RP1 +#define __DT_BINDINGS_CLOCK_RASPBERRYPI_RP1 + +#define RP1_PLL_SYS_CORE 0 +#define RP1_PLL_AUDIO_CORE 1 +#define RP1_PLL_VIDEO_CORE 2 + +#define RP1_PLL_SYS 3 +#define RP1_PLL_AUDIO 4 +#define RP1_PLL_VIDEO 5 + +#define RP1_PLL_SYS_PRI_PH 6 +#define RP1_PLL_SYS_SEC_PH 7 +#define RP1_PLL_AUDIO_PRI_PH 8 + +#define RP1_PLL_SYS_SEC 9 +#define RP1_PLL_AUDIO_SEC 10 +#define RP1_PLL_VIDEO_SEC 11 + +#define RP1_CLK_SYS 12 +#define RP1_CLK_SLOW_SYS 13 +#define RP1_CLK_DMA 14 +#define RP1_CLK_UART 15 +#define RP1_CLK_ETH 16 +#define RP1_CLK_PWM0 17 +#define RP1_CLK_PWM1 18 +#define RP1_CLK_AUDIO_IN 19 +#define RP1_CLK_AUDIO_OUT 20 +#define RP1_CLK_I2S 21 +#define RP1_CLK_MIPI0_CFG 22 +#define RP1_CLK_MIPI1_CFG 23 +#define RP1_CLK_PCIE_AUX 24 +#define RP1_CLK_USBH0_MICROFRAME 25 +#define RP1_CLK_USBH1_MICROFRAME 26 +#define RP1_CLK_USBH0_SUSPEND 27 +#define RP1_CLK_USBH1_SUSPEND 28 +#define RP1_CLK_ETH_TSU 29 +#define RP1_CLK_ADC 30 +#define RP1_CLK_SDIO_TIMER 31 +#define RP1_CLK_SDIO_ALT_SRC 32 +#define RP1_CLK_GP0 33 +#define RP1_CLK_GP1 34 +#define RP1_CLK_GP2 35 +#define RP1_CLK_GP3 36 +#define RP1_CLK_GP4 37 +#define RP1_CLK_GP5 38 +#define RP1_CLK_VEC 39 +#define RP1_CLK_DPI 40 +#define RP1_CLK_MIPI0_DPI 41 +#define RP1_CLK_MIPI1_DPI 42 + +/* Extra PLL output channels - RP1B0 only */ +#define RP1_PLL_VIDEO_PRI_PH 43 +#define RP1_PLL_AUDIO_TERN 44 + +#endif --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B6F11D27B7 for ; Mon, 7 Oct 2024 12:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304792; cv=none; b=iIxf77SumYojGR/4bRH5s7tZ5L1v5S6US7BJ4dO4qCAZtW9Ur1uPU/XWut6dJqoHHHtcClyUixKwX8ouASLfavc0f/Lezmekp3lQqk68Syi6R5ZpXbZEHkWWryPKFrSxqu5FLg+jkBUU1CS/QME4oOzgqcPFqtjTvXP/jnlNIjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304792; c=relaxed/simple; bh=wOd0gYffD7Ea7XGJvlfViJgSA9wreC2I5ALhOoujWJc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mwQLnmLvr9TorHfhUt1pLx2/1KmkDd7DcdYHztEBBzQP95w7hvLEUNu5JASijAmBUIPs4UsqpIKsmmOIC78ELXA05ygIgStoIKRcZeBhAnIkVbHJ6gyoMpmxfTboRuLJE8F69HGu9NdK85+ypJuFB5OUOxyqnBFiWuVaMkNfT1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=N3wj3Vze; arc=none smtp.client-ip=209.85.218.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="N3wj3Vze" Received: by mail-ej1-f68.google.com with SMTP id a640c23a62f3a-a995f56ea2dso68740166b.1 for ; Mon, 07 Oct 2024 05:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304788; x=1728909588; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=hff3hwplvjS7DHpYfcjvqwcC7w2WA0fQ36PlDSvv8i4=; b=N3wj3Vzet14P/QBOc1ahCd4/b5hQj2e3+E9Dg5cQRqsW3dpIcAm6CkUvl41unLQK0E 24hNJnAEy4bWpiUVVRXnUsr5WxcfhT8tRBO7/AymhxA7oDP+MfaTl6ML8DYH7Mw3n61a VE5ulik0jemr5cLTj1IZnyhIiIAXtq2lCY6fioaGyWGQ+RQX9icmmwf2RSzuTqbg2zDM dwFK/m4Yi2Wt2GIDqwnJJeHrm0bZ1JwI9HhAiWGsreVQKKg2i+7s6U01neVPckZzazxN J7wJQtlMQRQHilHvpWd1GutRtD9Kqm6gSpSzmsGWD8/la3yTE4R1AGfL2VsJH+gUmcH6 JATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304788; x=1728909588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hff3hwplvjS7DHpYfcjvqwcC7w2WA0fQ36PlDSvv8i4=; b=YonPwTMmQpZRb/E5cjzdafRrWiWH2tyPidmLXHyJjVQvYZz/2ML6IVqupmG7/HPJZ7 Z4FMQwQiAnlrciLEIeCTRs5ef7oPV9qJTYPzqrMvgXC1qNa1hpeVsSX0VgAjRAl/kJXE b01/fPbfVfauaKHQknWsjnhlw00dxs1Ml6ZwxlzpFmyoArEnzrM4QB2uXEEkI1rDkucn mS3/VOuV4R1+R2NwKCA3nCmcDkHozZRLMN1dx+NGHNiTsW8ICM73RhmlLqUhe93luEPJ vbqyU5rnrenz97VQcoXZtWLRkTHcb5PqtvS0cpXdSb17ouLGf3aPYEbPJmn7t2BcRhcQ E5yw== X-Forwarded-Encrypted: i=1; AJvYcCWlBakgJyqTEZSYPu8GpABOzRXXAGOkR4f19nR2UOGpRBz7kcHudU9GP/TJhNF4BIHZrx2PCWnS4da9CYQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwVfrMBtPmBh4x0lH5N5FQdIMVre2Z/mHsqRDOAVfdhxgbkukLg kCfP7w7FcNvx+ihyNj91QrIUyoYnlWDhR3cup+wu60gZ0Oet4AReVD8b1xBysNE= X-Google-Smtp-Source: AGHT+IG39yyCQQwIdr0FHbii9W3N4TgGlPJNvmDYGj8uTq9UAYZemTRIY+ZDrTbe3KLyHK0TjFyzoA== X-Received: by 2002:a17:906:d553:b0:a8d:1545:f48a with SMTP id a640c23a62f3a-a991c0531eamr1096917866b.61.1728304787631; Mon, 07 Oct 2024 05:39:47 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e784a4bsm373450466b.114.2024.10.07.05.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:47 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 02/14] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings Date: Mon, 7 Oct 2024 14:39:45 +0200 Message-ID: <0589448fa41bf7f3e951a75b70226a9873db554f.1728300189.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add device tree bindings for the gpio/pin/mux controller that is part of the RP1 multi function device, and relative entries in MAINTAINERS file. Signed-off-by: Andrea della Porta --- .../pinctrl/raspberrypi,rp1-gpio.yaml | 169 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 171 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/raspberrypi,r= p1-gpio.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio= .yaml b/Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml new file mode 100644 index 000000000000..46e071ec6251 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml @@ -0,0 +1,169 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/raspberrypi,rp1-gpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 GPIO/Pinconf/Pinmux Controller submodule + +maintainers: + - Andrea della Porta + +description: + The RP1 chipset is a Multi Function Device containing, among other sub-p= eripherals, + a gpio/pinconf/mux controller whose 54 pins are grouped into 3 banks. It= works also + as an interrupt controller for those gpios. + + Each pin configuration node lists the pin(s) to which it applies, and on= e or + more of the mux function to select on those pin(s), and their configurat= ion. + The pin configuration and multiplexing supports the generic bindings. + For details on each properties (including the meaning of "pin configurat= ion node"), + you can refer to ./pinctrl-bindings.txt. + +properties: + compatible: + const: raspberrypi,rp1-gpio + + reg: + maxItems: 3 + description: One reg specifier for each one of the 3 pin banks. + + '#gpio-cells': + description: The first cell is the pin number and the second cell is u= sed + to specify the flags (see include/dt-bindings/gpio/gpio.h). + const: 2 + + gpio-controller: true + + gpio-ranges: + maxItems: 1 + + gpio-line-names: + maxItems: 54 + + interrupts: + maxItems: 3 + description: One interrupt specifier for each one of the 3 pin banks. + + '#interrupt-cells': + description: + Specifies the Bank number [0, 1, 2] and Flags as defined in + include/dt-bindings/interrupt-controller/irq.h. + const: 2 + + interrupt-controller: true + +additionalProperties: + anyOf: + - type: object + additionalProperties: false + allOf: + - $ref: pincfg-node.yaml# + - $ref: pinmux-node.yaml# + + description: + Pin controller client devices use pin configuration subnodes (chil= dren + and grandchildren) for desired pin configuration. + Client device subnodes use below standard properties. + + properties: + pins: + description: + A string (or list of strings) adhering to the pattern "gpio[0-= 5][0-9]" + function: true + bias-disable: true + bias-pull-down: true + bias-pull-up: true + slew-rate: + description: 0 is slow slew rate, 1 is fast slew rate + enum: [ 0, 1 ] + drive-strength: + enum: [ 2, 4, 8, 12 ] + + - type: object + additionalProperties: + $ref: "#/additionalProperties/anyOf/0" + +allOf: + - $ref: pinctrl.yaml# + +required: + - reg + - compatible + - "#gpio-cells" + - gpio-controller + - interrupts + - "#interrupt-cells" + - interrupt-controller + +examples: + - | + #include + + rp1 { + #address-cells =3D <2>; + #size-cells =3D <2>; + + rp1_gpio: pinctrl@c0400d0000 { + reg =3D <0xc0 0x400d0000 0x0 0xc000>, + <0xc0 0x400e0000 0x0 0xc000>, + <0xc0 0x400f0000 0x0 0xc000>; + compatible =3D "raspberrypi,rp1-gpio"; + gpio-controller; + #gpio-cells =3D <2>; + interrupt-controller; + #interrupt-cells =3D <2>; + interrupts =3D <0 IRQ_TYPE_LEVEL_HIGH>, + <1 IRQ_TYPE_LEVEL_HIGH>, + <2 IRQ_TYPE_LEVEL_HIGH>; + gpio-line-names =3D + "ID_SDA", // GPIO0 + "ID_SCL", // GPIO1 + "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", + "GPIO7", "GPIO8", "GPIO9", "GPIO10", "GPIO11", + "GPIO12", "GPIO13", "GPIO14", "GPIO15", "GPIO16", + "GPIO17", "GPIO18", "GPIO19", "GPIO20", "GPIO21", + "GPIO22", "GPIO23", "GPIO24", "GPIO25", "GPIO26", + "GPIO27", + "PCIE_RP1_WAKE", // GPIO28 + "FAN_TACH", // GPIO29 + "HOST_SDA", // GPIO30 + "HOST_SCL", // GPIO31 + "ETH_RST_N", // GPIO32 + "", // GPIO33 + "CD0_IO0_MICCLK", // GPIO34 + "CD0_IO0_MICDAT0", // GPIO35 + "RP1_PCIE_CLKREQ_N", // GPIO36 + "", // GPIO37 + "CD0_SDA", // GPIO38 + "CD0_SCL", // GPIO39 + "CD1_SDA", // GPIO40 + "CD1_SCL", // GPIO41 + "USB_VBUS_EN", // GPIO42 + "USB_OC_N", // GPIO43 + "RP1_STAT_LED", // GPIO44 + "FAN_PWM", // GPIO45 + "CD1_IO0_MICCLK", // GPIO46 + "2712_WAKE", // GPIO47 + "CD1_IO1_MICDAT1", // GPIO48 + "EN_MAX_USB_CUR", // GPIO49 + "", // GPIO50 + "", // GPIO51 + "", // GPIO52 + ""; // GPIO53 + + rp1_uart0_14_15: rp1_uart0_14_15 { + pin_txd { + function =3D "uart0"; + pins =3D "gpio14"; + bias-disable; + }; + + pin_rxd { + function =3D "uart0"; + pins =3D "gpio15"; + bias-pull-up; + }; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 75a66e3e34c9..c55d12550246 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19384,7 +19384,9 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h +F: include/dt-bindings/misc/rp1.h =20 RC-CORE / LIRC FRAMEWORK M: Sean Young --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 916321D2226 for ; Mon, 7 Oct 2024 12:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304793; cv=none; b=L1TYufif4U/56haJQL7ePGAL3BZTfMGKNeVJCh2G0WL04MOaacwomi1a7cTtWNpMA8VdV79wJjualeb6KUVfqA7RAwIxMPGuHmzSmbn4zQk73aBuEpHLqWaGYVWfuHGzN9l7Llgn8dhU7xxkpbtbFke2zEVOh8SHX/bRqj719+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304793; c=relaxed/simple; bh=Vng6Rnm8WZ0QEcMErGHsHitJT99zYtF15IooAdGsAnE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n+oTv/KNMnq9NIut26pcOBBEuRYbFxYdCFm4zBwkriDYld1Ht8dSh+NL8m49jNjL33+Xj9dTaVtli4H8jTW2QoQ+bcYysCjRhCGR5+QieRWwHZdgjtL2zA7iWxeUXapzkByfwtrrZi1qEVfriuBMRegL66nPvzUI6y9VcHQ0Kfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=TDhxZrji; arc=none smtp.client-ip=209.85.208.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="TDhxZrji" Received: by mail-ed1-f67.google.com with SMTP id 4fb4d7f45d1cf-5c88c9e45c2so9401750a12.0 for ; Mon, 07 Oct 2024 05:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304789; x=1728909589; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fuhcTT207BoYyeeg1rSml1YhvWxOKliW74hU35I85Z4=; b=TDhxZrji15G+EdBBfGzo2BYYL7rRz9aTIdYe5bC37tEFJ/RdBJ/oRvuy+/AjPX6cj4 SlCtGZG3GnuY5QD6iLtYpNXrKqVd/APYsclClVtagHLyhRnI576uuLbDTwVqsGipjzLU iBFopuDRYi94rmow8weIyh97LMTXdbpmEbPWDLVfryRAUxCu7TGWan0ILUaOsCvHXCxo YQQvHuKE0+fYPqbjnT8jOgB0GCPRaWERxnypbQUMnlJCJqaxwRlagN40zzA2uODCRBpO HCSPnzc2aLJQqP4zyqdr718G3pmEOLpNpSg3qcEiCQbmnS6XBTKR+aoUtQE9812CCOph yf6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304789; x=1728909589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fuhcTT207BoYyeeg1rSml1YhvWxOKliW74hU35I85Z4=; b=WI8OVjOjxUVHUSxvEcZyyIKdVf3kKJadFYAzFlzt8mU2XKqYUgiweKomKG269sN3bL kXPtqiMfYm8OTY4XLuc3pkiDvOWDFO0/i3AngS3we4Gy1Ob53q4Wllc2npJyu/fqxGPi tIINfce/pHCU6VP2OisfzrkRS6AO1uXYC19bdV8eYmImh9NGbFTKVF0A1Y2V+A1Utcnv rdTAhrZTSrLVXOZ5XZPj47O0tPpszxLF2WI6K7yF/OARXBZZoCP0WrlOoaf1VmtQct4e JR/1ts1PMXG1czGE4wan0Kq8+N89vZir9Y3UHJ1de6w8z/SnETjrPUH5tkzwIgMbFD1W NtPg== X-Forwarded-Encrypted: i=1; AJvYcCURsCkxxcaua4ySOs5gvUARUtv3uqs7jkS/F0QWOPLho8F1zT4uxUfyXjmylSfYIgWMKE2EYbOdLkuZRrI=@vger.kernel.org X-Gm-Message-State: AOJu0YxwBlJ4YEUJxcmDIDct4SaSfaYHab1B+rk2q8iqXP+VOjU/TLK3 y0i+vHEOR8k/sG/rczY95txn83zqoyi57vaP08PMSQHz2ui12OxSecfkMDIifLk= X-Google-Smtp-Source: AGHT+IH4uJtWnmjaVwPOlrjtEv7DLcKyM5zoEla9wX4MrKe8D3yYuCSnyyFIX1r9/Ssik+roi9jduA== X-Received: by 2002:a05:6402:43c4:b0:5c4:1c89:6e36 with SMTP id 4fb4d7f45d1cf-5c8c0a8ae6amr16557075a12.19.1728304788892; Mon, 07 Oct 2024 05:39:48 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05bd4e7sm3146971a12.47.2024.10.07.05.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:48 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 03/14] dt-bindings: pci: Add common schema for devices accessible through PCI BARs Date: Mon, 7 Oct 2024 14:39:46 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Common YAML schema for devices that exports internal peripherals through PCI BARs. The BARs are exposed as simple-buses through which the peripherals can be accessed. This is not intended to be used as a standalone binding, but should be included by device specific bindings. Signed-off-by: Andrea della Porta --- .../devicetree/bindings/pci/pci-ep-bus.yaml | 69 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/pci-ep-bus.yaml diff --git a/Documentation/devicetree/bindings/pci/pci-ep-bus.yaml b/Docume= ntation/devicetree/bindings/pci/pci-ep-bus.yaml new file mode 100644 index 000000000000..9d7a784b866a --- /dev/null +++ b/Documentation/devicetree/bindings/pci/pci-ep-bus.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/pci-ep-bus.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common properties for PCI MFD endpoints with peripherals addressabl= e from BARs. + +maintainers: + - Andrea della Porta + +description: + Define a generic node representing a PCI endpoint which contains several= sub- + peripherals. The peripherals can be accessed through one or more BARs. + This common schema is intended to be referenced from device tree binding= s, and + does not represent a device tree binding by itself. + +properties: + "#address-cells": + const: 3 + + "#size-cells": + const: 2 + + ranges: + minItems: 1 + maxItems: 6 + items: + maxItems: 8 + additionalItems: true + items: + - maximum: 5 # The BAR number + - const: 0 + - const: 0 + +patternProperties: + "^pci-ep-bus@[0-5]$": + $ref: '#/$defs/pci-ep-bus' + description: + One node for each BAR used by peripherals contained in the PCI endpo= int. + Each node represent a bus on which peripherals are connected. + This allows for some segmentation, e.g. one peripheral is accessible + through BAR0 and another through BAR1, and you don't want the two + peripherals to be able to act on the other BAR. Alternatively, when + different peripherals need to share BARs, you can define only one no= de + and use 'ranges' property to map all the used BARs. + +required: + - ranges + - '#address-cells' + - '#size-cells' + +$defs: + pci-ep-bus: + type: object + additionalProperties: true + properties: + compatible: + const: simple-bus + dma-ranges: true + ranges: true + "#address-cells": true + "#size-cells": true + required: + - compatible + - ranges + - '#address-cells' + - '#size-cells' +... diff --git a/MAINTAINERS b/MAINTAINERS index c55d12550246..ccf123b805c8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19384,6 +19384,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 850111D2F64 for ; Mon, 7 Oct 2024 12:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304793; cv=none; b=VGAZ1DAuKA6UtN1/dGlfVoj+J42lFXCf9u0QykgnruJDS1DRmkJwu8ITKfww1rTY6fbTOpbnos4eEYtez7K77ik7Je1S6elId1Fd94aboXf8xFbkQTVBMxmVKeEEbD5N90qZZ4be3iBavkvbOTkwFuUWSOoil+nJQ9t3/wqwaWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304793; c=relaxed/simple; bh=ltCfjL/BttTDZuaWgfdIsVdh9gcTTSxn5v05bkxiJI8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EKxJBI6XwfMGCYUbPfsm6TfjYvfH+gPTOcIJZcIDZEieRmULLhlE1UL1QRRBFaUb36PttffypPNMbbgPbG7kY7qy0n4XH661xwB+fIvRKZ/T46+TrN5BFj2gvvePx89gL56WdzrJgcas1vIRXsjXwsAoYzaMRP8JyZY5ksD5aC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Mi0rwbNZ; arc=none smtp.client-ip=209.85.208.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Mi0rwbNZ" Received: by mail-ed1-f65.google.com with SMTP id 4fb4d7f45d1cf-5c8784e3bc8so6079466a12.1 for ; Mon, 07 Oct 2024 05:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304790; x=1728909590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eU3ji42pHlrfWJq1prcISuPTGN0LAJnGrZqn8om944U=; b=Mi0rwbNZKOFsChgSbgQbV50TVrReDZrVpfPS5+o8Fhz5kNKoenzZO4V/LSz3TzwUzQ bfsV5FmoT055ZR4wvXQsE/2DDld9/x99ToXAdpLJNqo8TAPJcn7R2X1esoFMT7rB/Wyj Y1BQERe7y/aSnARiZ4ldXTXd7W3QBgTGMoGMSPXKe7r8PLCMlcDgOS3PVMfcMxd+DR/S 447GQ7ddwlU7K3YbSkZQC+mpQKNxovXnNFWLSLA6OcRJ6cZdRtHR0qF/MjhbsuOZOQbF WVnlw2s0+aggwKV5lX8CrarIWpiJxMbhr0StEysvpG8HiTsLBmz/sHoMGPYsOmrc+o7J SySQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304790; x=1728909590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eU3ji42pHlrfWJq1prcISuPTGN0LAJnGrZqn8om944U=; b=GDAH5vJi3nZlb6t6U0tmfm+zauufxiq8X0afNLdvXJhWE96bhnBSmTBwpr+v05e0MH 5zrqFYfICQEtnQsZrH3lrpD59KbZH5i4nvZ03n1bGUQQHU7JjWTVUaUNVkTnZMo8F1OV uYymi4sL9A039Fsn0lwcQGGXBnMRSL4Vqct8zx1jYb3C1U3/Kp11wX5pwgEkM/sa5igW K6CPHLIlhzNlDoyN1PpeFHzwp8TQQHRHI6PObdW2p0i40Lhj9+cuhsEtEuCnMESCPD2h KbB1hvpLGHaEthex9V9kxQW0q8ur0jGF7L57l0X9pLVOwfYYNAt1LOwtK+MmMK4ozObW AInQ== X-Forwarded-Encrypted: i=1; AJvYcCX/352GGG3kct2vudATo+HMJIMgTZ1FRUrk/JpELYrcBrptHsqUj50tD2Pws+fxxNNrhO9i/FL8mzRG6xg=@vger.kernel.org X-Gm-Message-State: AOJu0YwJGSWCO+LvlHLWsoq63iqN8VhMRADZ/8ERv3x+28wvnehkC9NR oY1IbpuWOD6BMWzhoylXYUC5mu41N5nZW/etCqIG+jMJGr8I5unutNTTyNuvYdE= X-Google-Smtp-Source: AGHT+IGYdZc/ujfTjPKKP+5yoVqaatgPK8/RvNoAMYBcHf4RI2gthY/T+ULNWJG+Qr9qq+CZHwh19w== X-Received: by 2002:a05:6402:4404:b0:5c8:9548:f283 with SMTP id 4fb4d7f45d1cf-5c8d2e4571fmr10385444a12.20.1728304789894; Mon, 07 Oct 2024 05:39:49 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e0598947sm3101345a12.11.2024.10.07.05.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:49 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 04/14] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1 Date: Mon, 7 Oct 2024 14:39:47 +0200 Message-ID: <3141e3e7898c1538ea658487923d3446b3d7fd0c.1728300189.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RP1 is a MFD that exposes its peripherals through PCI BARs. This schema is intended as minimal support for the clock generator and gpio controller peripherals which are accessible through BAR1. Signed-off-by: Andrea della Porta --- .../devicetree/bindings/misc/pci1de4,1.yaml | 110 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 111 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/pci1de4,1.yaml diff --git a/Documentation/devicetree/bindings/misc/pci1de4,1.yaml b/Docume= ntation/devicetree/bindings/misc/pci1de4,1.yaml new file mode 100644 index 000000000000..3f099b16e672 --- /dev/null +++ b/Documentation/devicetree/bindings/misc/pci1de4,1.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/pci1de4,1.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RaspberryPi RP1 MFD PCI device + +maintainers: + - Andrea della Porta + +description: + The RaspberryPi RP1 is a PCI multi function device containing + peripherals ranging from Ethernet to USB controller, I2C, SPI + and others. + The peripherals are accessed by addressing the PCI BAR1 region. + +allOf: + - $ref: /schemas/pci/pci-ep-bus.yaml + +properties: + compatible: + additionalItems: true + maxItems: 3 + items: + - const: pci1de4,1 + +patternProperties: + "^pci-ep-bus@[0-2]$": + $ref: '#/$defs/bar-bus' + description: + The bus on which the peripherals are attached, which is addressable + through the BAR. + +unevaluatedProperties: false + +$defs: + bar-bus: + $ref: /schemas/pci/pci-ep-bus.yaml#/$defs/pci-ep-bus + unevaluatedProperties: false + + properties: + "#interrupt-cells": + const: 2 + description: + Specifies respectively the interrupt number and flags as defined + in include/dt-bindings/interrupt-controller/irq.h. + + interrupt-controller: true + + interrupt-parent: + description: + Must be the phandle of this 'pci-ep-bus' node. It will trigger + PCI interrupts on behalf of peripheral generated interrupts. + + patternProperties: + "^clocks(@[0-9a-f]+)?$": + type: object + $ref: /schemas/clock/raspberrypi,rp1-clocks.yaml + + "^ethernet(@[0-9a-f]+)?$": + type: object + $ref: /schemas/net/cdns,macb.yaml + + "^pinctrl(@[0-9a-f]+)?$": + type: object + $ref: /schemas/pinctrl/raspberrypi,rp1-gpio.yaml + + required: + - interrupt-parent + - interrupt-controller + +examples: + - | + pci { + #address-cells =3D <3>; + #size-cells =3D <2>; + + rp1@0,0 { + compatible =3D "pci1de4,1"; + ranges =3D <0x01 0x00 0x00000000 + 0x82010000 0x00 0x00 + 0x00 0x400000>; + #address-cells =3D <3>; + #size-cells =3D <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible =3D "simple-bus"; + ranges =3D <0xc0 0x40000000 + 0x01 0x00 0x00000000 + 0x00 0x00400000>; + dma-ranges =3D <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells =3D <2>; + #size-cells =3D <2>; + interrupt-controller; + interrupt-parent =3D <&pci_ep_bus>; + #interrupt-cells =3D <2>; + + rp1_clocks: clocks@c040018000 { + compatible =3D "raspberrypi,rp1-clocks"; + reg =3D <0xc0 0x40018000 0x0 0x10038>; + #clock-cells =3D <1>; + clocks =3D <&clk_rp1_xosc>; + clock-names =3D "rp1-xosc"; + }; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index ccf123b805c8..2aea5a6166bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19384,6 +19384,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta S: Maintained F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml +F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: include/dt-bindings/clock/rp1.h --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 854DB1D319F for ; Mon, 7 Oct 2024 12:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304795; cv=none; b=u2790bdVoGXSftjzX9U4nx0ORz2AbvxJd/YEe1Ceqi8DKFJGnhK+39qWxhiC63q+daRnXiFNOEN3swIHqUkiUWDsuu1mjFBaMEQcad+3dYRUuyglwgWiACptK3bGM1DLWIEODGm7MS7LXGlSxCdaF6QFjMKDHPSPC4z3MOXNuLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304795; c=relaxed/simple; bh=wzpt7n4M0YQABunSYCuMvT4laNaolsnpT6JGQVQisq8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aHk6wc1VPUDPfaqVEKjKOM1pdm0yop+ACn1QOHDPbZaAJoa3TnPn2Dl6+F743OzkBoZeAWN3VwUlP4AqATWeXOA+O0RFZa7VL4QedVXqtRUsf5UJ8QvIY2+SaKcRCnFVsgcNJXJChSn7jMqzIq0cITgRbWf+Z3NGw5PfhRr5rn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=OiwRIYel; arc=none smtp.client-ip=209.85.218.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="OiwRIYel" Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-a86e9db75b9so672177266b.1 for ; Mon, 07 Oct 2024 05:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304791; x=1728909591; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JVy087ignhx8Qr39VRDg6uatjxWZzzMpiZVqjT/QJ18=; b=OiwRIYelx6+by84RJeb33NnCp/tMnvOo0TsScuzfiTUUHgWBnTlhKXsI0uSAXpJqlc 4SWs6eX2IUPf0mtYb9i+qnxSvV3Jric6eU8vEIJ5AJROLEjJDJsPQ4nRercNpfpEBGpw EVF0CwO+JgMnXsqTdI4yfJBxvsh1DHLYpfY/qo0hxiIsUUazhSgXK/4oukjJDVpjPw9u cjOF5Xk9N/mzMbBGsPl/fFg+PsWX0wvWsUOSpJtV1xcIDU5K7boQfSH1+sPY3a56wjAU qV+CKFI43791/VU48grJwB2u4mBYNdxkQtfM28cSWA9oBsIkf2QcCe5wdiNURODHUMm8 GAWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304791; x=1728909591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JVy087ignhx8Qr39VRDg6uatjxWZzzMpiZVqjT/QJ18=; b=LY6/vvWkLydGG7OYgj+RTYJCgrLyuigS5O6xuqVmXjxhkT9eJyUywqS4xLoNZ5lz1+ HQ3sG/oslI38ydCwSsFonYkOYdOLWK+3cZ8Rue1mHzYNs9LQ478FLnQMDbqkoicCQMY5 Ax85cw4AjuNzO2fahp6iXMpIryaT2RYDIV8Bi2P9egkE7ZgkTd/zyG6RkBWPiklZzQ0x j7qpju0tV4SDYr4LTYcNuy0s2KV6/+G07dxbM+QZPPf3t+cnwbB6u98py1k5nsGofQJZ TLDdNtstrB96dKs5jsZt2jR/3og0jDsEPsn9Rr4fPJBNwxKH6B1opHXI4DK6K6KbV4nM gsaA== X-Forwarded-Encrypted: i=1; AJvYcCVr5vtnsQZb107J1Mbjqn9L9PYdax/mbSIlS4ATVYBfHMRgPykttOvXqcY+W4uX95uj0bMmC89wEdc2zws=@vger.kernel.org X-Gm-Message-State: AOJu0YyN65/SitsNHiRtXJlfk9DkrhiQ7L0I1O7ej3ZODLz+gE5ivjhV e3L1PDIrX4sN1lAYq9Y0kgOsCCeaslXSb4EXjeGIdfrEtFlJ7oNZ70+qHqu5zSk= X-Google-Smtp-Source: AGHT+IEy5GKg/nXhQMQUn4foWYz0mYMSu2W3P06/cB1glnoAkN+XlhE1TotI+oUpl1LOtWN5zL42ZQ== X-Received: by 2002:a17:907:60cc:b0:a99:5b7f:9e3b with SMTP id a640c23a62f3a-a995b7f9e4dmr208232466b.33.1728304790890; Mon, 07 Oct 2024 05:39:50 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994787fa61sm239841166b.169.2024.10.07.05.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:50 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 05/14] PCI: of_property: Sanitize 32 bit PCI address parsed from DT Date: Mon, 7 Oct 2024 14:39:48 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The of_pci_set_address() function parses devicetree PCI range specifier assuming the address is 'sanitized' at the origin, i.e. without checking whether the incoming address is 32 or 64 bit has specified in the flags. In this way an address with no OF_PCI_ADDR_SPACE_MEM64 set in the flags could leak through and the upper 32 bits of the address will be set too, and this violates the PCI specs stating that in 32 bit address the upper bits should be zero. This could cause mapping translation mismatch on PCI devices (e.g. RP1) that are expected to be addressed with a 64 bit address while advertising a 32 bit address in the PCI config region. Add a check in of_pci_set_address() to set upper 32 bits to zero in case the address has no 64 bit flag set. Signed-off-by: Andrea della Porta --- This patch has not been changed from the first version, discussion is still ongoing here: https://lore.kernel.org/all/ZwJyk9XouLfd24VG@apocalypse/#t drivers/pci/of_property.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 5a0b98e69795..77865facdb4a 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -60,7 +60,10 @@ static void of_pci_set_address(struct pci_dev *pdev, u32= *prop, u64 addr, prop[0] |=3D flags | reg_num; if (!reloc) { prop[0] |=3D OF_PCI_ADDR_FIELD_NONRELOC; - prop[1] =3D upper_32_bits(addr); + if (FIELD_GET(OF_PCI_ADDR_FIELD_SS, flags) =3D=3D OF_PCI_ADDR_SPACE_MEM6= 4) + prop[1] =3D upper_32_bits(addr); + else + prop[1] =3D 0; prop[2] =3D lower_32_bits(addr); } } --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D38AF1D358B for ; Mon, 7 Oct 2024 12:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304796; cv=none; b=QJgDyLjdiKNkBzYdMOhPUZpFhsYwyTWODYK4Qnrr3F5ekwUPr7jHsE/HWWsAdBst07yE/tq2oGfIfXaXYkZ7bQFFB9ZTMk9ZgUs+CmkH5fxJdLGN0yB0D8D1ZsFN9N4iSnmQuQycsgexDIFVwCpS7VxaRgGRcrsd8T+yiT7QyhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304796; c=relaxed/simple; bh=oF/rpJB8SDnKjbKxg5VT3ASBLt57E9z1LMpaipmd2+E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qt5yYOG+oanrc8nA1MGMN3iznnDLdTCSnvVuJUoPCevjoap8e+avDif1cyiaYtJJ29y4sIfm0zgB+5AMHDWAPSM4DYk+LU3oCuTrw44QsMMGiYbZF3K+xJk/DrZ8JeHaKG8VIYi8GvbOhXnlpTzXWy0Hngx0xeBmdhiN+9Bligk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=SfPm4Kkj; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="SfPm4Kkj" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a8d446adf6eso740299566b.2 for ; Mon, 07 Oct 2024 05:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304792; x=1728909592; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=SfPm4KkjXBG71GoPcKYuiGfZ4HG8hkHOY1l1nKA9ljIHhdd1wvJCF8nPziQaV5VPjr hjGhvaRoKmRSkW74bPwBJ6fvthxFD9TTUNbWdIaFgX2Z9/4fcYmYbv/7xh6jrU9YGc6X LG4kAGyk/fOAD5ddg0JXMnlSar/IGfm9WHvpuyA5qao1B+e5fsqD1mamCGMxmz/P6Wm4 50QTh8g0A9xNrEr4ZFeasR+JiecBGGJqYqi1KFR5hsTpp7YeMPn3S4ASyeHs13i8Pg/n cTm1ByNO0cwySxBnp1z/1gxZBCF5jDdBtzQkeIkz7w2rnq/yrhgmRkbMaVGVA1BmebBp 5mxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304792; x=1728909592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmMJCoFVCCoMSDMdNDybyaBIx5hGSa7lQNj9sEKg2KA=; b=Wvt27qDlGU/R44qYSO04ZnEHOd9cBBzBPg0igYsmHaDTTb7E3RUXvJjmA1GzM6P4RC wqo3qWYXuGyyMdBzrVWGnqL19sZm3pdqkBhf1mSzS6msMRrfRb2BY+hJTR0/Q8tSm/X6 Cl4L7iZtadVhWkAMzNdaEMsadwRJWsazhH7SRsmlIadlx1dvVUYZu5LB2C6DY1ECyt/z LldE3G60/AI6IpMDJo874Zs4SA2ruom6rNauEvetJ3Hzdbg9496YhKQUXmChrOtPZF5d o7KxYeIT/d4SgyJQFZRmTq7iibfQz3J+ycXjuF/m0nVeEU35+eQhuihxZ9MBQ0rOZ/Y+ bwLg== X-Forwarded-Encrypted: i=1; AJvYcCX71mgO4t0OzIF4h0pSA7lvSlPuwwg+lb6dMPfzjcX31lzTS7EF/F36yKynky5DiEOQd8W0Wx1cKOkydXw=@vger.kernel.org X-Gm-Message-State: AOJu0YwQvkl7JmY5zkeV86L3AFO2wFiYxPCD4g50Ii9es7XSPAcjE3ms ekhBMzPiBfQnhP8S4E1wXDW/KajukNhkAh7rRd0UapcUINBsxTzXpAs1CO0wK2M= X-Google-Smtp-Source: AGHT+IHTBvg5M5ry0Kp6n2llss528AG1tMlkKm6Eq4xV0RUgVViw5ZHoodaCTq7bcUKV0kUcKhVe+w== X-Received: by 2002:a17:907:7da7:b0:a99:4a8f:c83f with SMTP id a640c23a62f3a-a994a8fca5amr566416566b.5.1728304792074; Mon, 07 Oct 2024 05:39:52 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e664fb9sm377591066b.88.2024.10.07.05.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:51 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 06/14] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Date: Mon, 7 Oct 2024 14:39:49 +0200 Message-ID: <3bda3b90df5a36cc902213383287e79b34195485.1728300189.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A missing or empty dma-ranges in a DT node implies a 1:1 mapping for dma translations. In this specific case, the current behaviour is to zero out the entire specifier so that the translation could be carried on as an offset from zero. This includes address specifier that has flags (e.g. PCI ranges). Once the flags portion has been zeroed, the translation chain is broken since the mapping functions will check the upcoming address specifier against mismatching flags, always failing the 1:1 mapping and its entire purpose of always succeeding. Set to zero only the address portion while passing the flags through. Signed-off-by: Andrea della Porta --- This patch still lacks an entry in the DT unittest. drivers/of/address.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 286f0c161e33..72b6accff21c 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -455,7 +455,8 @@ static int of_translate_one(struct device_node *parent,= struct of_bus *bus, } if (ranges =3D=3D NULL || rlen =3D=3D 0) { offset =3D of_read_number(addr, na); - memset(addr, 0, pna * 4); + /* copy the address while preserving the flags */ + memset(addr + pbus->flag_cells, 0, (pna - pbus->flag_cells) * 4); pr_debug("empty ranges; 1:1 translation\n"); goto finish; } --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDF801D414C for ; Mon, 7 Oct 2024 12:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304798; cv=none; b=jbddBh1hIqYJ/oxIkN7dt0hQz3+CvyORtZI+P4eRdBIIP/pljqaVr5eBSmDdFTKW4jbVcvYoTy5RpUPaP/QynPAoAGY9sTlzE8NZEM87KxJ7zSKDHBTg2KnWrPH7ptNgcoAmnqw5vhsV9ZEF8sxleI9FDbwv+KVedv5LXzXu1nU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304798; c=relaxed/simple; bh=keW+vT550WqqZOgWV5RvIAX0hhvZXHvpuvbMkV4b5MQ=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DMGLDyKk/sCrIKWLmxriQ4FJj8NT/TQM6m+eWaECVuURs1lls5tlmIHGB+kRLvg63gkebW9/Agbc9EdBDx3C5fQEAN4MOLJ0OrnrewhTBKLJU8xGYFuhdj2ivm4B1sFC3N2q9uaxo0TEzoOhiOSQYxLj24ava7iDY/s/glKnThA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=YmAYEbNf; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="YmAYEbNf" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a99422929b2so225209766b.0 for ; Mon, 07 Oct 2024 05:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304793; x=1728909593; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=E3hAOrRw5xQdhMiyBTBpAF1zCHGDS1up/fzBs4ITHy4=; b=YmAYEbNfRsa+9ZquXK4zGHRxscymbJd6awqpfXIKu810sjLWv2SabVfJYFOGpGEvJl rNU8t9KyUdHDirnctl9N6k00X02lFRGVGWQkD4X0AJ7C8pKudEIgtLkp47MVh2QmooKG MBqNJ24SCrOSN0OFz0eY+ybE5RgGT22INAIfyl+ISh3M+xhLJqs7cKlDebQLnq8HjY7y 5Zefsro0WqT/OGHildlBvW9RfHajWqbpsUg7vDyhHIIAYB9hgcbbJ7mKx97yrXm+Xjl6 rHKMGN0LyD8fbOxeuZcOF63Ev/oybP4BzG1GoIYL6wmgE1A5LXAp+vM9VDZwJDCtsx/Y Q2wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304793; x=1728909593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E3hAOrRw5xQdhMiyBTBpAF1zCHGDS1up/fzBs4ITHy4=; b=UfntpGk8RKDtfXahm6EVooEixfJq3J1ONDxu0FYNRjx2HWJ5GogRLPVYziWjMrgy3h dZMH4o3uTA6ddPzngo0hCFe7WMiPlCQqxVU4w27+SCHJI48GON1kSrjgD4yJT81dXdRZ TH8rM5pmAhviqxRDumpz2jau2R7pWc2qZrYj0T+9rXmLZ4MeRsMNs83lxH1ZegtNDWsJ qXZyajNni+XegoXXmKvCWEUmTbnpL2hVbJX3f19uVgITBpV9GOfMlJ09Xtjn5QUH8nQi hR60LclD4bJQAjF8gGH0SMJUff+kmvTBVaRMN+O1ymS0JjbpT6gKOGUiJJgKyNlG4e23 HIJQ== X-Forwarded-Encrypted: i=1; AJvYcCWEWNwgY1wQjtzZceEUZ0Xg8ucoEksc/Tx3p1TzQbuugHJCi8NGPBmgfFXB+JkHkLxfkNiIWMXU4fPPcTw=@vger.kernel.org X-Gm-Message-State: AOJu0YxJicYNC+Vlvx2KUshl0UkxebEWOlBnyEYuNQQ+jilLyanBQS7e KpJizttZPE+dXkHbPT05E7yh+aEBFPlujCZ3pV1uCw6cgC9FAeyxXM6Den4NRv4= X-Google-Smtp-Source: AGHT+IFAuS51Efpu99SVNutmZJk8el6z6Su02r4hqkQ+BkrfYww1vueUey7cM49AcZEtj5NuSSmKaA== X-Received: by 2002:a17:907:972a:b0:a8d:555f:eeda with SMTP id a640c23a62f3a-a991bce5aecmr1345288866b.8.1728304793310; Mon, 07 Oct 2024 05:39:53 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994e6e571asm189794266b.85.2024.10.07.05.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:53 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 07/14] gpiolib: Export symbol gpiochip_set_names() Date: Mon, 7 Oct 2024 14:39:50 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Being able to assign gpio line names dynamically is a feature that could be used by drivers that do not have the exact naming (e.g. through the DTB/DTBO) at probing time. An example of this is the RP1 driver that populates the DT at late time through a DT overlay. In this case a custom overlay can be loaded from userspace with the gpio line names. Export gpiochip_set_names() to allow refreshing the gpio line names from the driver module. Signed-off-by: Andrea della Porta --- drivers/gpio/gpiolib.c | 3 ++- include/linux/gpio/driver.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c6afbf434366..a2aa3560094a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -522,7 +522,7 @@ static void gpiochip_set_desc_names(struct gpio_chip *g= c) * names belong to the underlying firmware node and should not be released * by the caller. */ -static int gpiochip_set_names(struct gpio_chip *chip) +int gpiochip_set_names(struct gpio_chip *chip) { struct gpio_device *gdev =3D chip->gpiodev; struct device *dev =3D &gdev->dev; @@ -589,6 +589,7 @@ static int gpiochip_set_names(struct gpio_chip *chip) =20 return 0; } +EXPORT_SYMBOL(gpiochip_set_names); =20 static unsigned long *gpiochip_allocate_mask(struct gpio_chip *gc) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 2dd7cb9cc270..6e4cd7b7e47e 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -679,6 +679,9 @@ bool gpiochip_line_is_open_source(struct gpio_chip *gc,= unsigned int offset); bool gpiochip_line_is_persistent(struct gpio_chip *gc, unsigned int offset= ); bool gpiochip_line_is_valid(const struct gpio_chip *gc, unsigned int offse= t); =20 +/* Assign gpio line names from device property */ +int gpiochip_set_names(struct gpio_chip *chip); + /* get driver data */ void *gpiochip_get_data(struct gpio_chip *gc); =20 --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C82A1D45E5 for ; Mon, 7 Oct 2024 12:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304801; cv=none; b=OxoMIP8paZu+5AX+I0Bjvyf5cCe2ydPNMl/JHyQnTrhAWbaD6Ks6ELmT5PjIeTn+SIO8aV2uUuU9hkMGP92x682UqW8+ODlr2VjjLQA4DtNMGpILIsOUklNcVOiYcGjibd91Q0TRnBIcKVa1ZaTeC2D8aII2CsBTxl5QaRw2ki0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304801; c=relaxed/simple; bh=EU7VxUFgTc1NKrucGmiHa4GEg065pGLHoPYlSdRdS/o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+L12QnE/iiBOKW0dl3rnNGVL5Aj4sHqKjerjBoofdBRuf1HFLpfH4Dl6GcaK+4wFsbRaW9Y7PlicWbhTFbMlGcP4+A7Xav5TrzfX4ryHNTlHTHdeDAdRwwTyDeCKrmR+sqZezJ0Xjzn5FIEC5RCtX46uZ34Txn4xtTb4sK2IkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=XeJP404j; arc=none smtp.client-ip=209.85.208.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="XeJP404j" Received: by mail-ed1-f67.google.com with SMTP id 4fb4d7f45d1cf-5c42e7adbddso5966607a12.2 for ; Mon, 07 Oct 2024 05:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304795; x=1728909595; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LP+jcJyNTYlTW59stbD95i+ZI2uUnNB70V+379xHCiU=; b=XeJP404j7F5/JHvEadQ31XrF+4pJpWGe1+idUsbg80QjB/aJrQjsvLt7XxLByE3sjw 7bI0iRipyb3sauhC/yJJ148ckIjztww6IwL3QElOgqfqYTpzniic/o0XgBItGjbLmc3v fh221U1BJXlNhKl6J+rfxxy/pVOoKj6Idv7JkYOwmlZLt8KdBYF3T6LEXcDh2oMGybOh LptSO1auggZD2fXGEibutsINksiD0ANLuhJdqRDZi6qKEJVfeyXNWsuZijgFKa6ptWP8 OWRg2gX2UtQvX6OCqWhUYrkpy4WHFK26YzuqbHVd8Lpg2lN97n6dJgAv2WMWnCNzSM23 1BzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304795; x=1728909595; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LP+jcJyNTYlTW59stbD95i+ZI2uUnNB70V+379xHCiU=; b=pydqjiwEZKXtszDV2wFjfv9wf3lElFIb6wgvZdxfE+70dR4ZndDYaBMZ2ozbxYtpfY v3t7zivM8KYmnbVeByMKEtPfos6ird54L5KuvrOwznHtVvSZuBlzGj2Pn4CyLzKWIhG1 o9rjQR9FeuhDW6TXoT5XMH9zUHr5GG0pMNQB+9hQHpBgPaJyILudgpRdwv+c9M4tWewI 4xv6QJJ5LNUb1PoHMIWJVcTXEQPq2CaWcuIurVLHRYpSm9oS74ic33qiwijOkmDTORMy bgu0tNrYXh1uDxlfVjhoxwEm5OdBcb4fR2Rk/KY/SlCZInpiQVYvA0z2bcz0Poe+qITd 6DBA== X-Forwarded-Encrypted: i=1; AJvYcCWDcad0CuCBNmfDcP0RZ59NX+P8hEfBYk2Jf+0FC4Jmyd9C0WhENSqwgYxKnjc/4MDo+kJKcoo7Fhm742w=@vger.kernel.org X-Gm-Message-State: AOJu0YxfZjm6Otdilq11y0hgGdj5w1TuIV9rewWcujNUrjVGyaZuCQ28 lLh5scpkC5vJuoUKEyjP2N8imTmbqzrQIVrq6kdEhIVPOdXKOK5njXs6mMegHqs= X-Google-Smtp-Source: AGHT+IEFJomjeB234ZfocSW28Z4TtFBQS95U+4Veu+L1rVWtkeJIRIug2ptaCKE3IMFL7W2pXsc8BQ== X-Received: by 2002:a05:6402:448b:b0:5be:caf6:9dc7 with SMTP id 4fb4d7f45d1cf-5c8d2ebcc2dmr10999603a12.25.1728304794743; Mon, 07 Oct 2024 05:39:54 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05bc56asm3132474a12.45.2024.10.07.05.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:54 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 08/14] clk: rp1: Add support for clocks provided by RP1 Date: Mon, 7 Oct 2024 14:39:51 +0200 Message-ID: <022cf4920f8147cc720eaf02fd52c0fa56f565c5.1728300189.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RaspberryPi RP1 is an MFD providing, among other peripherals, several clock generators and PLLs that drives the sub-peripherals. Add the driver to support the clock providers. Signed-off-by: Andrea della Porta --- MAINTAINERS | 1 + drivers/clk/Kconfig | 9 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1658 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1669 insertions(+) create mode 100644 drivers/clk/clk-rp1.c diff --git a/MAINTAINERS b/MAINTAINERS index 2aea5a6166bd..dc064cd4b6b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19387,6 +19387,7 @@ F: Documentation/devicetree/bindings/clock/raspberr= ypi,rp1-clocks.yaml F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml +F: drivers/clk/clk-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h =20 diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 299bc678ed1b..537019987f0c 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -88,6 +88,15 @@ config COMMON_CLK_RK808 These multi-function devices have two fixed-rate oscillators, clocked a= t 32KHz each. Clkout1 is always on, Clkout2 can off by control register. =20 +config COMMON_CLK_RP1 + tristate "Raspberry Pi RP1-based clock support" + depends on PCI || COMPILE_TEST + depends on COMMON_CLK + help + Enable common clock framework support for Raspberry Pi RP1. + This multi-function device has 3 main PLLs and several clock + generators to drive the internal sub-peripherals. + config COMMON_CLK_HI655X tristate "Clock driver for Hi655x" if EXPERT depends on (MFD_HI655X_PMIC || COMPILE_TEST) diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index fb8878a5d7d9..2ab97f36c800 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_CLK_LS1028A_PLLDIG) +=3D clk-plldig.o obj-$(CONFIG_COMMON_CLK_PWM) +=3D clk-pwm.o obj-$(CONFIG_CLK_QORIQ) +=3D clk-qoriq.o obj-$(CONFIG_COMMON_CLK_RK808) +=3D clk-rk808.o +obj-$(CONFIG_COMMON_CLK_RP1) +=3D clk-rp1.o obj-$(CONFIG_COMMON_CLK_HI655X) +=3D clk-hi655x.o obj-$(CONFIG_COMMON_CLK_S2MPS11) +=3D clk-s2mps11.o obj-$(CONFIG_COMMON_CLK_SCMI) +=3D clk-scmi.o diff --git a/drivers/clk/clk-rp1.c b/drivers/clk/clk-rp1.c new file mode 100644 index 000000000000..9016666fb27d --- /dev/null +++ b/drivers/clk/clk-rp1.c @@ -0,0 +1,1658 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Raspberry Pi Ltd. + * + * Clock driver for RP1 PCIe multifunction chip. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define PLL_SYS_OFFSET 0x08000 +#define PLL_SYS_CS (PLL_SYS_OFFSET + 0x00) +#define PLL_SYS_PWR (PLL_SYS_OFFSET + 0x04) +#define PLL_SYS_FBDIV_INT (PLL_SYS_OFFSET + 0x08) +#define PLL_SYS_FBDIV_FRAC (PLL_SYS_OFFSET + 0x0c) +#define PLL_SYS_PRIM (PLL_SYS_OFFSET + 0x10) +#define PLL_SYS_SEC (PLL_SYS_OFFSET + 0x14) + +#define PLL_AUDIO_OFFSET 0x0c000 +#define PLL_AUDIO_CS (PLL_AUDIO_OFFSET + 0x00) +#define PLL_AUDIO_PWR (PLL_AUDIO_OFFSET + 0x04) +#define PLL_AUDIO_FBDIV_INT (PLL_AUDIO_OFFSET + 0x08) +#define PLL_AUDIO_FBDIV_FRAC (PLL_AUDIO_OFFSET + 0x0c) +#define PLL_AUDIO_PRIM (PLL_AUDIO_OFFSET + 0x10) +#define PLL_AUDIO_SEC (PLL_AUDIO_OFFSET + 0x14) +#define PLL_AUDIO_TERN (PLL_AUDIO_OFFSET + 0x18) + +#define PLL_VIDEO_OFFSET 0x10000 +#define PLL_VIDEO_CS (PLL_VIDEO_OFFSET + 0x00) +#define PLL_VIDEO_PWR (PLL_VIDEO_OFFSET + 0x04) +#define PLL_VIDEO_FBDIV_INT (PLL_VIDEO_OFFSET + 0x08) +#define PLL_VIDEO_FBDIV_FRAC (PLL_VIDEO_OFFSET + 0x0c) +#define PLL_VIDEO_PRIM (PLL_VIDEO_OFFSET + 0x10) +#define PLL_VIDEO_SEC (PLL_VIDEO_OFFSET + 0x14) + +#define GPCLK_OE_CTRL 0x00000 + +#define CLK_SYS_OFFSET 0x00014 +#define CLK_SYS_CTRL (CLK_SYS_OFFSET + 0x00) +#define CLK_SYS_DIV_INT (CLK_SYS_OFFSET + 0x04) +#define CLK_SYS_SEL (CLK_SYS_OFFSET + 0x0c) + +#define CLK_SLOW_OFFSET 0x00024 +#define CLK_SLOW_SYS_CTRL (CLK_SLOW_OFFSET + 0x00) +#define CLK_SLOW_SYS_DIV_INT (CLK_SLOW_OFFSET + 0x04) +#define CLK_SLOW_SYS_SEL (CLK_SLOW_OFFSET + 0x0c) + +#define CLK_DMA_OFFSET 0x00044 +#define CLK_DMA_CTRL (CLK_DMA_OFFSET + 0x00) +#define CLK_DMA_DIV_INT (CLK_DMA_OFFSET + 0x04) +#define CLK_DMA_SEL (CLK_DMA_OFFSET + 0x0c) + +#define CLK_UART_OFFSET 0x00054 +#define CLK_UART_CTRL (CLK_UART_OFFSET + 0x00) +#define CLK_UART_DIV_INT (CLK_UART_OFFSET + 0x04) +#define CLK_UART_SEL (CLK_UART_OFFSET + 0x0c) + +#define CLK_ETH_OFFSET 0x00064 +#define CLK_ETH_CTRL (CLK_ETH_OFFSET + 0x00) +#define CLK_ETH_DIV_INT (CLK_ETH_OFFSET + 0x04) +#define CLK_ETH_SEL (CLK_ETH_OFFSET + 0x0c) + +#define CLK_PWM0_OFFSET 0x00074 +#define CLK_PWM0_CTRL (CLK_PWM0_OFFSET + 0x00) +#define CLK_PWM0_DIV_INT (CLK_PWM0_OFFSET + 0x04) +#define CLK_PWM0_DIV_FRAC (CLK_PWM0_OFFSET + 0x08) +#define CLK_PWM0_SEL (CLK_PWM0_OFFSET + 0x0c) + +#define CLK_PWM1_OFFSET 0x00084 +#define CLK_PWM1_CTRL (CLK_PWM1_OFFSET + 0x00) +#define CLK_PWM1_DIV_INT (CLK_PWM1_OFFSET + 0x04) +#define CLK_PWM1_DIV_FRAC (CLK_PWM1_OFFSET + 0x08) +#define CLK_PWM1_SEL (CLK_PWM1_OFFSET + 0x0c) + +#define CLK_AUDIO_IN_OFFSET 0x00094 +#define CLK_AUDIO_IN_CTRL (CLK_AUDIO_IN_OFFSET + 0x00) +#define CLK_AUDIO_IN_DIV_INT (CLK_AUDIO_IN_OFFSET + 0x04) +#define CLK_AUDIO_IN_SEL (CLK_AUDIO_IN_OFFSET + 0x0c) + +#define CLK_AUDIO_OUT_OFFSET 0x000a4 +#define CLK_AUDIO_OUT_CTRL (CLK_AUDIO_OUT_OFFSET + 0x00) +#define CLK_AUDIO_OUT_DIV_INT (CLK_AUDIO_OUT_OFFSET + 0x04) +#define CLK_AUDIO_OUT_SEL (CLK_AUDIO_OUT_OFFSET + 0x0c) + +#define CLK_I2S_OFFSET 0x000b4 +#define CLK_I2S_CTRL (CLK_I2S_OFFSET + 0x00) +#define CLK_I2S_DIV_INT (CLK_I2S_OFFSET + 0x04) +#define CLK_I2S_SEL (CLK_I2S_OFFSET + 0x0c) + +#define CLK_MIPI0_CFG_OFFSET 0x000c4 +#define CLK_MIPI0_CFG_CTRL (CLK_MIPI0_CFG_OFFSET + 0x00) +#define CLK_MIPI0_CFG_DIV_INT (CLK_MIPI0_CFG_OFFSET + 0x04) +#define CLK_MIPI0_CFG_SEL (CLK_MIPI0_CFG_OFFSET + 0x0c) + +#define CLK_MIPI1_CFG_OFFSET 0x000d4 +#define CLK_MIPI1_CFG_CTRL (CLK_MIPI1_CFG_OFFSET + 0x00) +#define CLK_MIPI1_CFG_DIV_INT (CLK_MIPI1_CFG_OFFSET + 0x04) +#define CLK_MIPI1_CFG_SEL (CLK_MIPI1_CFG_OFFSET + 0x0c) + +#define CLK_PCIE_AUX_OFFSET 0x000e4 +#define CLK_PCIE_AUX_CTRL (CLK_PCIE_AUX_OFFSET + 0x00) +#define CLK_PCIE_AUX_DIV_INT (CLK_PCIE_AUX_OFFSET + 0x04) +#define CLK_PCIE_AUX_SEL (CLK_PCIE_AUX_OFFSET + 0x0c) + +#define CLK_USBH0_MICROFRAME_OFFSET 0x000f4 +#define CLK_USBH0_MICROFRAME_CTRL (CLK_USBH0_MICROFRAME_OFFSET + 0x00) +#define CLK_USBH0_MICROFRAME_DIV_INT (CLK_USBH0_MICROFRAME_OFFSET + 0x04) +#define CLK_USBH0_MICROFRAME_SEL (CLK_USBH0_MICROFRAME_OFFSET + 0x0c) + +#define CLK_USBH1_MICROFRAME_OFFSET 0x00104 +#define CLK_USBH1_MICROFRAME_CTRL (CLK_USBH1_MICROFRAME_OFFSET + 0x00) +#define CLK_USBH1_MICROFRAME_DIV_INT (CLK_USBH1_MICROFRAME_OFFSET + 0x04) +#define CLK_USBH1_MICROFRAME_SEL (CLK_USBH1_MICROFRAME_OFFSET + 0x0c) + +#define CLK_USBH0_SUSPEND_OFFSET 0x00114 +#define CLK_USBH0_SUSPEND_CTRL (CLK_USBH0_SUSPEND_OFFSET + 0x00) +#define CLK_USBH0_SUSPEND_DIV_INT (CLK_USBH0_SUSPEND_OFFSET + 0x04) +#define CLK_USBH0_SUSPEND_SEL (CLK_USBH0_SUSPEND_OFFSET + 0x0c) + +#define CLK_USBH1_SUSPEND_OFFSET 0x00124 +#define CLK_USBH1_SUSPEND_CTRL (CLK_USBH1_SUSPEND_OFFSET + 0x00) +#define CLK_USBH1_SUSPEND_DIV_INT (CLK_USBH1_SUSPEND_OFFSET + 0x04) +#define CLK_USBH1_SUSPEND_SEL (CLK_USBH1_SUSPEND_OFFSET + 0x0c) + +#define CLK_ETH_TSU_OFFSET 0x00134 +#define CLK_ETH_TSU_CTRL (CLK_ETH_TSU_OFFSET + 0x00) +#define CLK_ETH_TSU_DIV_INT (CLK_ETH_TSU_OFFSET + 0x04) +#define CLK_ETH_TSU_SEL (CLK_ETH_TSU_OFFSET + 0x0c) + +#define CLK_ADC_OFFSET 0x00144 +#define CLK_ADC_CTRL (CLK_ADC_OFFSET + 0x00) +#define CLK_ADC_DIV_INT (CLK_ADC_OFFSET + 0x04) +#define CLK_ADC_SEL (CLK_ADC_OFFSET + 0x0c) + +#define CLK_SDIO_TIMER_OFFSET 0x00154 +#define CLK_SDIO_TIMER_CTRL (CLK_SDIO_TIMER_OFFSET + 0x00) +#define CLK_SDIO_TIMER_DIV_INT (CLK_SDIO_TIMER_OFFSET + 0x04) +#define CLK_SDIO_TIMER_SEL (CLK_SDIO_TIMER_OFFSET + 0x0c) + +#define CLK_SDIO_ALT_SRC_OFFSET 0x00164 +#define CLK_SDIO_ALT_SRC_CTRL (CLK_SDIO_ALT_SRC_OFFSET + 0x00) +#define CLK_SDIO_ALT_SRC_DIV_INT (CLK_SDIO_ALT_SRC_OFFSET + 0x04) +#define CLK_SDIO_ALT_SRC_SEL (CLK_SDIO_ALT_SRC_OFFSET + 0x0c) + +#define CLK_GP0_OFFSET 0x00174 +#define CLK_GP0_CTRL (CLK_GP0_OFFSET + 0x00) +#define CLK_GP0_DIV_INT (CLK_GP0_OFFSET + 0x04) +#define CLK_GP0_DIV_FRAC (CLK_GP0_OFFSET + 0x08) +#define CLK_GP0_SEL (CLK_GP0_OFFSET + 0x0c) + +#define CLK_GP1_OFFSET 0x00184 +#define CLK_GP1_CTRL (CLK_GP1_OFFSET + 0x00) +#define CLK_GP1_DIV_INT (CLK_GP1_OFFSET + 0x04) +#define CLK_GP1_DIV_FRAC (CLK_GP1_OFFSET + 0x08) +#define CLK_GP1_SEL (CLK_GP1_OFFSET + 0x0c) + +#define CLK_GP2_OFFSET 0x00194 +#define CLK_GP2_CTRL (CLK_GP2_OFFSET + 0x00) +#define CLK_GP2_DIV_INT (CLK_GP2_OFFSET + 0x04) +#define CLK_GP2_DIV_FRAC (CLK_GP2_OFFSET + 0x08) +#define CLK_GP2_SEL (CLK_GP2_OFFSET + 0x0c) + +#define CLK_GP3_OFFSET 0x001a4 +#define CLK_GP3_CTRL (CLK_GP3_OFFSET + 0x00) +#define CLK_GP3_DIV_INT (CLK_GP3_OFFSET + 0x04) +#define CLK_GP3_DIV_FRAC (CLK_GP3_OFFSET + 0x08) +#define CLK_GP3_SEL (CLK_GP3_OFFSET + 0x0c) + +#define CLK_GP4_OFFSET 0x001b4 +#define CLK_GP4_CTRL (CLK_GP4_OFFSET + 0x00) +#define CLK_GP4_DIV_INT (CLK_GP4_OFFSET + 0x04) +#define CLK_GP4_DIV_FRAC (CLK_GP4_OFFSET + 0x08) +#define CLK_GP4_SEL (CLK_GP4_OFFSET + 0x0c) + +#define CLK_GP5_OFFSET 0x001c4 +#define CLK_GP5_CTRL (CLK_GP5_OFFSET + 0x00) +#define CLK_GP5_DIV_INT (CLK_GP5_OFFSET + 0x04) +#define CLK_GP5_DIV_FRAC (CLK_GP5_OFFSET + 0x08) +#define CLK_GP5_SEL (CLK_GP5_OFFSET + 0x0c) + +#define CLK_SYS_RESUS_CTRL 0x0020c + +#define CLK_SLOW_SYS_RESUS_CTRL 0x00214 + +#define FC0_OFFSET 0x0021c +#define FC0_REF_KHZ (FC0_OFFSET + 0x00) +#define FC0_MIN_KHZ (FC0_OFFSET + 0x04) +#define FC0_MAX_KHZ (FC0_OFFSET + 0x08) +#define FC0_DELAY (FC0_OFFSET + 0x0c) +#define FC0_INTERVAL (FC0_OFFSET + 0x10) +#define FC0_SRC (FC0_OFFSET + 0x14) +#define FC0_STATUS (FC0_OFFSET + 0x18) +#define FC0_RESULT (FC0_OFFSET + 0x1c) +#define FC_SIZE 0x20 +#define FC_COUNT 8 +#define FC_NUM(idx, off) ((idx) * 32 + (off)) + +#define AUX_SEL 1 + +#define VIDEO_CLOCKS_OFFSET 0x4000 +#define VIDEO_CLK_VEC_CTRL (VIDEO_CLOCKS_OFFSET + 0x0000) +#define VIDEO_CLK_VEC_DIV_INT (VIDEO_CLOCKS_OFFSET + 0x0004) +#define VIDEO_CLK_VEC_SEL (VIDEO_CLOCKS_OFFSET + 0x000c) +#define VIDEO_CLK_DPI_CTRL (VIDEO_CLOCKS_OFFSET + 0x0010) +#define VIDEO_CLK_DPI_DIV_INT (VIDEO_CLOCKS_OFFSET + 0x0014) +#define VIDEO_CLK_DPI_SEL (VIDEO_CLOCKS_OFFSET + 0x001c) +#define VIDEO_CLK_MIPI0_DPI_CTRL (VIDEO_CLOCKS_OFFSET + 0x0020) +#define VIDEO_CLK_MIPI0_DPI_DIV_INT (VIDEO_CLOCKS_OFFSET + 0x0024) +#define VIDEO_CLK_MIPI0_DPI_DIV_FRAC (VIDEO_CLOCKS_OFFSET + 0x0028) +#define VIDEO_CLK_MIPI0_DPI_SEL (VIDEO_CLOCKS_OFFSET + 0x002c) +#define VIDEO_CLK_MIPI1_DPI_CTRL (VIDEO_CLOCKS_OFFSET + 0x0030) +#define VIDEO_CLK_MIPI1_DPI_DIV_INT (VIDEO_CLOCKS_OFFSET + 0x0034) +#define VIDEO_CLK_MIPI1_DPI_DIV_FRAC (VIDEO_CLOCKS_OFFSET + 0x0038) +#define VIDEO_CLK_MIPI1_DPI_SEL (VIDEO_CLOCKS_OFFSET + 0x003c) + +#define DIV_INT_8BIT_MAX GENMASK(7, 0) /* max divide for most clocks */ +#define DIV_INT_16BIT_MAX GENMASK(15, 0) /* max divide for GPx, PWM */ +#define DIV_INT_24BIT_MAX GENMASK(23, 0) /* max divide for C= LK_SYS */ + +#define FC0_STATUS_DONE BIT(4) +#define FC0_STATUS_RUNNING BIT(8) +#define FC0_RESULT_FRAC_SHIFT 5 + +#define PLL_PRIM_DIV1_SHIFT 16 +#define PLL_PRIM_DIV1_WIDTH 3 +#define PLL_PRIM_DIV1_MASK GENMASK(PLL_PRIM_DIV1_SHIFT + \ + PLL_PRIM_DIV1_WIDTH - 1, \ + PLL_PRIM_DIV1_SHIFT) +#define PLL_PRIM_DIV2_SHIFT 12 +#define PLL_PRIM_DIV2_WIDTH 3 +#define PLL_PRIM_DIV2_MASK GENMASK(PLL_PRIM_DIV2_SHIFT + \ + PLL_PRIM_DIV2_WIDTH - 1, \ + PLL_PRIM_DIV2_SHIFT) + +#define PLL_SEC_DIV_SHIFT 8 +#define PLL_SEC_DIV_WIDTH 5 +#define PLL_SEC_DIV_MASK GENMASK(PLL_SEC_DIV_SHIFT + \ + PLL_SEC_DIV_WIDTH - 1, \ + PLL_SEC_DIV_SHIFT) + +#define PLL_CS_LOCK BIT(31) +#define PLL_CS_REFDIV_SHIFT 0 + +#define PLL_PWR_PD BIT(0) +#define PLL_PWR_DACPD BIT(1) +#define PLL_PWR_DSMPD BIT(2) +#define PLL_PWR_POSTDIVPD BIT(3) +#define PLL_PWR_4PHASEPD BIT(4) +#define PLL_PWR_VCOPD BIT(5) +#define PLL_PWR_MASK GENMASK(5, 0) + +#define PLL_SEC_RST BIT(16) +#define PLL_SEC_IMPL BIT(31) + +/* PLL phase output for both PRI and SEC */ +#define PLL_PH_EN BIT(4) +#define PLL_PH_PHASE_SHIFT 0 + +#define RP1_PLL_PHASE_0 0 +#define RP1_PLL_PHASE_90 1 +#define RP1_PLL_PHASE_180 2 +#define RP1_PLL_PHASE_270 3 + +/* Clock fields for all clocks */ +#define CLK_CTRL_ENABLE BIT(11) +#define CLK_CTRL_AUXSRC_SHIFT 5 +#define CLK_CTRL_AUXSRC_WIDTH 5 +#define CLK_CTRL_AUXSRC_MASK GENMASK(CLK_CTRL_AUXSRC_SHIFT + \ + CLK_CTRL_AUXSRC_WIDTH - 1, \ + CLK_CTRL_AUXSRC_SHIFT) +#define CLK_CTRL_SRC_SHIFT 0 +#define CLK_DIV_FRAC_BITS 16 + +#define KHz 1000 +#define MHz (KHz * KHz) +#define LOCK_TIMEOUT_NS 100000000 +#define FC_TIMEOUT_NS 100000000 + +#define MAX_CLK_PARENTS 16 + +/* + * Secondary PLL channel output divider table. + * Divider values range from 8 to 19. + * Invalid values default to 19 + */ +static const struct clk_div_table pll_sec_div_table[] =3D { + { 0x00, 19 }, + { 0x01, 19 }, + { 0x02, 19 }, + { 0x03, 19 }, + { 0x04, 19 }, + { 0x05, 19 }, + { 0x06, 19 }, + { 0x07, 19 }, + { 0x08, 8 }, + { 0x09, 9 }, + { 0x0a, 10 }, + { 0x0b, 11 }, + { 0x0c, 12 }, + { 0x0d, 13 }, + { 0x0e, 14 }, + { 0x0f, 15 }, + { 0x10, 16 }, + { 0x11, 17 }, + { 0x12, 18 }, + { 0x13, 19 }, + { 0x14, 19 }, + { 0x15, 19 }, + { 0x16, 19 }, + { 0x17, 19 }, + { 0x18, 19 }, + { 0x19, 19 }, + { 0x1a, 19 }, + { 0x1b, 19 }, + { 0x1c, 19 }, + { 0x1d, 19 }, + { 0x1e, 19 }, + { 0x1f, 19 }, + { 0 } +}; + +struct rp1_clockman { + struct device *dev; + void __iomem *regs; + spinlock_t regs_lock; /* spinlock for all clocks */ + struct clk_hw *hw_xosc; /* reference clock */ + + /* Must be last */ + struct clk_hw_onecell_data onecell; +}; + +struct rp1_pll_core_data { + const char *name; + u32 cs_reg; + u32 pwr_reg; + u32 fbdiv_int_reg; + u32 fbdiv_frac_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_pll_data { + const char *name; + const char *source_pll; + u32 ctrl_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_pll_ph_data { + const char *name; + const char *source_pll; + unsigned int phase; + unsigned int fixed_divider; + u32 ph_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_pll_divider_data { + const char *name; + const char *source_pll; + u32 sec_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_clock_data { + const char *name; + const char *const parents[MAX_CLK_PARENTS]; + int num_std_parents; + int num_aux_parents; + unsigned long flags; + u32 oe_mask; + u32 clk_src_mask; + u32 ctrl_reg; + u32 div_int_reg; + u32 div_frac_reg; + u32 sel_reg; + u32 div_int_max; + unsigned long max_freq; + u32 fc0_src; +}; + +struct rp1_pll_core { + struct clk_hw hw; + struct rp1_clockman *clockman; + unsigned long cached_rate; + const struct rp1_pll_core_data *data; +}; + +struct rp1_pll { + struct clk_hw hw; + struct rp1_clockman *clockman; + struct clk_divider div; + unsigned long cached_rate; + const struct rp1_pll_data *data; +}; + +struct rp1_pll_ph { + struct clk_hw hw; + struct rp1_clockman *clockman; + const struct rp1_pll_ph_data *data; +}; + +struct rp1_clock { + struct clk_hw hw; + struct rp1_clockman *clockman; + unsigned long cached_rate; + const struct rp1_clock_data *data; +}; + +struct rp1_clk_change { + struct clk_hw *hw; + unsigned long new_rate; +}; + +struct rp1_clk_desc { + struct clk_hw *(*clk_register)(struct rp1_clockman *clockman, + const void *data); + const void *data; +}; + +static void rp1_debugfs_regset(struct rp1_clockman *clockman, u32 base, + const struct debugfs_reg32 *regs, + size_t nregs, struct dentry *dentry) +{ + struct debugfs_regset32 *regset; + + regset =3D devm_kzalloc(clockman->dev, sizeof(*regset), GFP_KERNEL); + if (!regset) + return; + + regset->regs =3D regs; + regset->nregs =3D nregs; + regset->base =3D clockman->regs + base; + + debugfs_create_regset32("regdump", 0444, dentry, regset); +} + +static inline u32 set_register_field(u32 reg, u32 val, u32 mask, u32 shift) +{ + reg &=3D ~mask; + reg |=3D (val << shift) & mask; + return reg; +} + +static inline +void clockman_write(struct rp1_clockman *clockman, u32 reg, u32 val) +{ + writel(val, clockman->regs + reg); +} + +static inline u32 clockman_read(struct rp1_clockman *clockman, u32 reg) +{ + return readl(clockman->regs + reg); +} + +static int rp1_pll_core_is_on(struct clk_hw *hw) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + u32 pwr =3D clockman_read(clockman, data->pwr_reg); + + return (pwr & PLL_PWR_PD) || (pwr & PLL_PWR_POSTDIVPD); +} + +static int rp1_pll_core_on(struct clk_hw *hw) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + u32 fbdiv_frac; + ktime_t timeout; + + spin_lock(&clockman->regs_lock); + + if (!(clockman_read(clockman, data->cs_reg) & PLL_CS_LOCK)) { + /* Reset to a known state. */ + clockman_write(clockman, data->pwr_reg, PLL_PWR_MASK); + clockman_write(clockman, data->fbdiv_int_reg, 20); + clockman_write(clockman, data->fbdiv_frac_reg, 0); + clockman_write(clockman, data->cs_reg, 1 << PLL_CS_REFDIV_SHIFT); + } + + /* Come out of reset. */ + fbdiv_frac =3D clockman_read(clockman, data->fbdiv_frac_reg); + clockman_write(clockman, data->pwr_reg, fbdiv_frac ? 0 : PLL_PWR_DSMPD); + spin_unlock(&clockman->regs_lock); + + /* Wait for the PLL to lock. */ + timeout =3D ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS); + while (!(clockman_read(clockman, data->cs_reg) & PLL_CS_LOCK)) { + if (ktime_after(ktime_get(), timeout)) { + dev_err(clockman->dev, "%s: can't lock PLL\n", + clk_hw_get_name(hw)); + return -ETIMEDOUT; + } + cpu_relax(); + } + + return 0; +} + +static void rp1_pll_core_off(struct clk_hw *hw) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->pwr_reg, 0); + spin_unlock(&clockman->regs_lock); +} + +static inline unsigned long get_pll_core_divider(struct clk_hw *hw, + unsigned long rate, + unsigned long parent_rate, + u32 *div_int, u32 *div_frac) +{ + unsigned long calc_rate; + u32 fbdiv_int, fbdiv_frac; + u64 div_fp64; /* 32.32 fixed point fraction. */ + + /* Factor of reference clock to VCO frequency. */ + div_fp64 =3D (u64)(rate) << 32; + div_fp64 =3D DIV_ROUND_CLOSEST_ULL(div_fp64, parent_rate); + + /* Round the fractional component at 24 bits. */ + div_fp64 +=3D 1 << (32 - 24 - 1); + + fbdiv_int =3D div_fp64 >> 32; + fbdiv_frac =3D (div_fp64 >> (32 - 24)) & 0xffffff; + + calc_rate =3D + ((u64)parent_rate * (((u64)fbdiv_int << 24) + fbdiv_frac) + (1 << 23)) >= > 24; + + *div_int =3D fbdiv_int; + *div_frac =3D fbdiv_frac; + + return calc_rate; +} + +static int rp1_pll_core_set_rate(struct clk_hw *hw, + unsigned long rate, unsigned long parent_rate) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + unsigned long calc_rate; + u32 fbdiv_int, fbdiv_frac; + + /* Disable dividers to start with. */ + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->fbdiv_int_reg, 0); + clockman_write(clockman, data->fbdiv_frac_reg, 0); + spin_unlock(&clockman->regs_lock); + + calc_rate =3D get_pll_core_divider(hw, rate, parent_rate, + &fbdiv_int, &fbdiv_frac); + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->pwr_reg, fbdiv_frac ? 0 : PLL_PWR_DSMPD); + clockman_write(clockman, data->fbdiv_int_reg, fbdiv_int); + clockman_write(clockman, data->fbdiv_frac_reg, fbdiv_frac); + spin_unlock(&clockman->regs_lock); + + /* Check that reference frequency is no greater than VCO / 16. */ + if (WARN_ON_ONCE(parent_rate > (rate / 16))) + return -ERANGE; + + pll_core->cached_rate =3D calc_rate; + + spin_lock(&clockman->regs_lock); + /* Don't need to divide ref unless parent_rate > (output freq / 16) */ + clockman_write(clockman, data->cs_reg, + clockman_read(clockman, data->cs_reg) | + (1 << PLL_CS_REFDIV_SHIFT)); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static unsigned long rp1_pll_core_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + u32 fbdiv_int, fbdiv_frac; + unsigned long calc_rate; + + fbdiv_int =3D clockman_read(clockman, data->fbdiv_int_reg); + fbdiv_frac =3D clockman_read(clockman, data->fbdiv_frac_reg); + calc_rate =3D + ((u64)parent_rate * (((u64)fbdiv_int << 24) + fbdiv_frac) + (1 << 23)) >= > 24; + + return calc_rate; +} + +static long rp1_pll_core_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + u32 fbdiv_int, fbdiv_frac; + long calc_rate; + + calc_rate =3D get_pll_core_divider(hw, rate, *parent_rate, + &fbdiv_int, &fbdiv_frac); + return calc_rate; +} + +static void rp1_pll_core_debug_init(struct clk_hw *hw, struct dentry *dent= ry) +{ + struct rp1_pll_core *pll_core =3D container_of(hw, struct rp1_pll_core, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + struct debugfs_reg32 *regs; + + regs =3D devm_kcalloc(clockman->dev, 4, sizeof(*regs), GFP_KERNEL); + if (!regs) + return; + + regs[0].name =3D "cs"; + regs[0].offset =3D data->cs_reg; + regs[1].name =3D "pwr"; + regs[1].offset =3D data->pwr_reg; + regs[2].name =3D "fbdiv_int"; + regs[2].offset =3D data->fbdiv_int_reg; + regs[3].name =3D "fbdiv_frac"; + regs[3].offset =3D data->fbdiv_frac_reg; + + rp1_debugfs_regset(clockman, 0, regs, 4, dentry); +} + +static void get_pll_prim_dividers(unsigned long rate, unsigned long parent= _rate, + u32 *divider1, u32 *divider2) +{ + unsigned int div1, div2; + unsigned int best_div1 =3D 7, best_div2 =3D 7; + unsigned long best_rate_diff =3D + abs_diff(DIV_ROUND_CLOSEST(parent_rate, best_div1 * best_div2), rate); + unsigned long rate_diff, calc_rate; + + for (div1 =3D 1; div1 <=3D 7; div1++) { + for (div2 =3D 1; div2 <=3D div1; div2++) { + calc_rate =3D DIV_ROUND_CLOSEST(parent_rate, div1 * div2); + rate_diff =3D abs_diff(calc_rate, rate); + + if (calc_rate =3D=3D rate) { + best_div1 =3D div1; + best_div2 =3D div2; + goto done; + } else if (rate_diff < best_rate_diff) { + best_div1 =3D div1; + best_div2 =3D div2; + best_rate_diff =3D rate_diff; + } + } + } + +done: + *divider1 =3D best_div1; + *divider2 =3D best_div2; +} + +static int rp1_pll_set_rate(struct clk_hw *hw, + unsigned long rate, unsigned long parent_rate) +{ + struct rp1_pll *pll =3D container_of(hw, struct rp1_pll, hw); + struct rp1_clockman *clockman =3D pll->clockman; + const struct rp1_pll_data *data =3D pll->data; + u32 prim, prim_div1, prim_div2; + + get_pll_prim_dividers(rate, parent_rate, &prim_div1, &prim_div2); + + spin_lock(&clockman->regs_lock); + prim =3D clockman_read(clockman, data->ctrl_reg); + prim =3D set_register_field(prim, prim_div1, PLL_PRIM_DIV1_MASK, + PLL_PRIM_DIV1_SHIFT); + prim =3D set_register_field(prim, prim_div2, PLL_PRIM_DIV2_MASK, + PLL_PRIM_DIV2_SHIFT); + clockman_write(clockman, data->ctrl_reg, prim); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static unsigned long rp1_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rp1_pll *pll =3D container_of(hw, struct rp1_pll, hw); + struct rp1_clockman *clockman =3D pll->clockman; + const struct rp1_pll_data *data =3D pll->data; + u32 prim, prim_div1, prim_div2; + + prim =3D clockman_read(clockman, data->ctrl_reg); + prim_div1 =3D (prim & PLL_PRIM_DIV1_MASK) >> PLL_PRIM_DIV1_SHIFT; + prim_div2 =3D (prim & PLL_PRIM_DIV2_MASK) >> PLL_PRIM_DIV2_SHIFT; + + if (!prim_div1 || !prim_div2) { + dev_err(clockman->dev, "%s: (%s) zero divider value\n", + __func__, data->name); + return 0; + } + + return DIV_ROUND_CLOSEST(parent_rate, prim_div1 * prim_div2); +} + +static long rp1_pll_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + u32 div1, div2; + + get_pll_prim_dividers(rate, *parent_rate, &div1, &div2); + + return DIV_ROUND_CLOSEST(*parent_rate, div1 * div2); +} + +static void rp1_pll_debug_init(struct clk_hw *hw, + struct dentry *dentry) +{ + struct rp1_pll *pll =3D container_of(hw, struct rp1_pll, hw); + struct rp1_clockman *clockman =3D pll->clockman; + const struct rp1_pll_data *data =3D pll->data; + struct debugfs_reg32 *regs; + + regs =3D devm_kcalloc(clockman->dev, 1, sizeof(*regs), GFP_KERNEL); + if (!regs) + return; + + regs[0].name =3D "prim"; + regs[0].offset =3D data->ctrl_reg; + + rp1_debugfs_regset(clockman, 0, regs, 1, dentry); +} + +static int rp1_pll_ph_is_on(struct clk_hw *hw) +{ + struct rp1_pll_ph *pll =3D container_of(hw, struct rp1_pll_ph, hw); + struct rp1_clockman *clockman =3D pll->clockman; + const struct rp1_pll_ph_data *data =3D pll->data; + + return !!(clockman_read(clockman, data->ph_reg) & PLL_PH_EN); +} + +static int rp1_pll_ph_on(struct clk_hw *hw) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + struct rp1_clockman *clockman =3D pll_ph->clockman; + const struct rp1_pll_ph_data *data =3D pll_ph->data; + u32 ph_reg; + + /* todo: ensure pri/sec is enabled! */ + spin_lock(&clockman->regs_lock); + ph_reg =3D clockman_read(clockman, data->ph_reg); + ph_reg |=3D data->phase << PLL_PH_PHASE_SHIFT; + ph_reg |=3D PLL_PH_EN; + clockman_write(clockman, data->ph_reg, ph_reg); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static void rp1_pll_ph_off(struct clk_hw *hw) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + struct rp1_clockman *clockman =3D pll_ph->clockman; + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->ph_reg, + clockman_read(clockman, data->ph_reg) & ~PLL_PH_EN); + spin_unlock(&clockman->regs_lock); +} + +static int rp1_pll_ph_set_rate(struct clk_hw *hw, + unsigned long rate, unsigned long parent_rate) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + /* Nothing really to do here! */ + WARN_ON(data->fixed_divider !=3D 1 && data->fixed_divider !=3D 2); + WARN_ON(rate !=3D parent_rate / data->fixed_divider); + + return 0; +} + +static unsigned long rp1_pll_ph_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + return parent_rate / data->fixed_divider; +} + +static long rp1_pll_ph_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + return *parent_rate / data->fixed_divider; +} + +static void rp1_pll_ph_debug_init(struct clk_hw *hw, + struct dentry *dentry) +{ + struct rp1_pll_ph *pll_ph =3D container_of(hw, struct rp1_pll_ph, hw); + const struct rp1_pll_ph_data *data =3D pll_ph->data; + struct rp1_clockman *clockman =3D pll_ph->clockman; + struct debugfs_reg32 *regs; + + regs =3D devm_kcalloc(clockman->dev, 1, sizeof(*regs), GFP_KERNEL); + if (!regs) + return; + + regs[0].name =3D "ph_reg"; + regs[0].offset =3D data->ph_reg; + + rp1_debugfs_regset(clockman, 0, regs, 1, dentry); +} + +static int rp1_pll_divider_is_on(struct clk_hw *hw) +{ + struct rp1_pll *divider =3D container_of(hw, struct rp1_pll, div.hw); + struct rp1_clockman *clockman =3D divider->clockman; + const struct rp1_pll_data *data =3D divider->data; + + return !(clockman_read(clockman, data->ctrl_reg) & PLL_SEC_RST); +} + +static int rp1_pll_divider_on(struct clk_hw *hw) +{ + struct rp1_pll *divider =3D container_of(hw, struct rp1_pll, div.hw); + struct rp1_clockman *clockman =3D divider->clockman; + const struct rp1_pll_data *data =3D divider->data; + + spin_lock(&clockman->regs_lock); + /* Check the implementation bit is set! */ + WARN_ON(!(clockman_read(clockman, data->ctrl_reg) & PLL_SEC_IMPL)); + clockman_write(clockman, data->ctrl_reg, + clockman_read(clockman, data->ctrl_reg) & ~PLL_SEC_RST); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static void rp1_pll_divider_off(struct clk_hw *hw) +{ + struct rp1_pll *divider =3D container_of(hw, struct rp1_pll, div.hw); + struct rp1_clockman *clockman =3D divider->clockman; + const struct rp1_pll_data *data =3D divider->data; + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->ctrl_reg, PLL_SEC_RST); + spin_unlock(&clockman->regs_lock); +} + +static int rp1_pll_divider_set_rate(struct clk_hw *hw, + unsigned long rate, + unsigned long parent_rate) +{ + struct rp1_pll *divider =3D container_of(hw, struct rp1_pll, div.hw); + struct rp1_clockman *clockman =3D divider->clockman; + const struct rp1_pll_data *data =3D divider->data; + u32 div, sec; + + div =3D DIV_ROUND_UP_ULL(parent_rate, rate); + div =3D clamp(div, 8u, 19u); + + spin_lock(&clockman->regs_lock); + sec =3D clockman_read(clockman, data->ctrl_reg); + sec =3D set_register_field(sec, div, PLL_SEC_DIV_MASK, PLL_SEC_DIV_SHIFT); + + /* Must keep the divider in reset to change the value. */ + sec |=3D PLL_SEC_RST; + clockman_write(clockman, data->ctrl_reg, sec); + + // todo: must sleep 10 pll vco cycles + sec &=3D ~PLL_SEC_RST; + clockman_write(clockman, data->ctrl_reg, sec); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static unsigned long rp1_pll_divider_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + return clk_divider_ops.recalc_rate(hw, parent_rate); +} + +static long rp1_pll_divider_round_rate(struct clk_hw *hw, + unsigned long rate, + unsigned long *parent_rate) +{ + return clk_divider_ops.round_rate(hw, rate, parent_rate); +} + +static void rp1_pll_divider_debug_init(struct clk_hw *hw, struct dentry *d= entry) +{ + struct rp1_pll *divider =3D container_of(hw, struct rp1_pll, div.hw); + struct rp1_clockman *clockman =3D divider->clockman; + const struct rp1_pll_data *data =3D divider->data; + struct debugfs_reg32 *regs; + + regs =3D devm_kcalloc(clockman->dev, 1, sizeof(*regs), GFP_KERNEL); + if (!regs) + return; + + regs[0].name =3D "sec"; + regs[0].offset =3D data->ctrl_reg; + + rp1_debugfs_regset(clockman, 0, regs, 1, dentry); +} + +static int rp1_clock_is_on(struct clk_hw *hw) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + + return !!(clockman_read(clockman, data->ctrl_reg) & CLK_CTRL_ENABLE); +} + +static unsigned long rp1_clock_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + u64 calc_rate; + u64 div; + + u32 frac; + + div =3D clockman_read(clockman, data->div_int_reg); + frac =3D (data->div_frac_reg !=3D 0) ? + clockman_read(clockman, data->div_frac_reg) : 0; + + /* If the integer portion of the divider is 0, treat it as 2^16 */ + if (!div) + div =3D 1 << 16; + + div =3D (div << CLK_DIV_FRAC_BITS) | (frac >> (32 - CLK_DIV_FRAC_BITS)); + + calc_rate =3D (u64)parent_rate << CLK_DIV_FRAC_BITS; + calc_rate =3D div64_u64(calc_rate, div); + + return calc_rate; +} + +static int rp1_clock_on(struct clk_hw *hw) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->ctrl_reg, + clockman_read(clockman, data->ctrl_reg) | CLK_CTRL_ENABLE); + /* If this is a GPCLK, turn on the output-enable */ + if (data->oe_mask) + clockman_write(clockman, GPCLK_OE_CTRL, + clockman_read(clockman, GPCLK_OE_CTRL) | data->oe_mask); + spin_unlock(&clockman->regs_lock); + + return 0; +} + +static void rp1_clock_off(struct clk_hw *hw) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + + spin_lock(&clockman->regs_lock); + clockman_write(clockman, data->ctrl_reg, + clockman_read(clockman, data->ctrl_reg) & ~CLK_CTRL_ENABLE); + /* If this is a GPCLK, turn off the output-enable */ + if (data->oe_mask) + clockman_write(clockman, GPCLK_OE_CTRL, + clockman_read(clockman, GPCLK_OE_CTRL) & ~data->oe_mask); + spin_unlock(&clockman->regs_lock); +} + +static u32 rp1_clock_choose_div(unsigned long rate, unsigned long parent_r= ate, + const struct rp1_clock_data *data) +{ + u64 div; + + /* + * Due to earlier rounding, calculated parent_rate may differ from + * expected value. Don't fail on a small discrepancy near unity divide. + */ + if (!rate || rate > parent_rate + (parent_rate >> CLK_DIV_FRAC_BITS)) + return 0; + + /* + * Always express div in fixed-point format for fractional division; + * If no fractional divider is present, the fraction part will be zero. + */ + if (data->div_frac_reg) { + div =3D (u64)parent_rate << CLK_DIV_FRAC_BITS; + div =3D DIV_ROUND_CLOSEST_ULL(div, rate); + } else { + div =3D DIV_ROUND_CLOSEST_ULL(parent_rate, rate); + div <<=3D CLK_DIV_FRAC_BITS; + } + + div =3D clamp(div, + 1ull << CLK_DIV_FRAC_BITS, + (u64)data->div_int_max << CLK_DIV_FRAC_BITS); + + return div; +} + +static u8 rp1_clock_get_parent(struct clk_hw *hw) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + u32 sel, ctrl; + u8 parent; + + /* Sel is one-hot, so find the first bit set */ + sel =3D clockman_read(clockman, data->sel_reg); + parent =3D ffs(sel) - 1; + + /* sel =3D=3D 0 implies the parent clock is not enabled yet. */ + if (!sel) { + /* Read the clock src from the CTRL register instead */ + ctrl =3D clockman_read(clockman, data->ctrl_reg); + parent =3D (ctrl & data->clk_src_mask) >> CLK_CTRL_SRC_SHIFT; + } + + if (parent >=3D data->num_std_parents) + parent =3D AUX_SEL; + + if (parent =3D=3D AUX_SEL) { + /* + * Clock parent is an auxiliary source, so get the parent from + * the AUXSRC register field. + */ + ctrl =3D clockman_read(clockman, data->ctrl_reg); + parent =3D (ctrl & CLK_CTRL_AUXSRC_MASK) >> CLK_CTRL_AUXSRC_SHIFT; + parent +=3D data->num_std_parents; + } + + return parent; +} + +static int rp1_clock_set_parent(struct clk_hw *hw, u8 index) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + u32 ctrl, sel; + + spin_lock(&clockman->regs_lock); + ctrl =3D clockman_read(clockman, data->ctrl_reg); + + if (index >=3D data->num_std_parents) { + /* This is an aux source request */ + if (index >=3D data->num_std_parents + data->num_aux_parents) { + spin_unlock(&clockman->regs_lock); + return -EINVAL; + } + + /* Select parent from aux list */ + ctrl =3D set_register_field(ctrl, index - data->num_std_parents, + CLK_CTRL_AUXSRC_MASK, + CLK_CTRL_AUXSRC_SHIFT); + /* Set src to aux list */ + ctrl =3D set_register_field(ctrl, AUX_SEL, data->clk_src_mask, + CLK_CTRL_SRC_SHIFT); + } else { + ctrl =3D set_register_field(ctrl, index, data->clk_src_mask, + CLK_CTRL_SRC_SHIFT); + } + + clockman_write(clockman, data->ctrl_reg, ctrl); + spin_unlock(&clockman->regs_lock); + + sel =3D rp1_clock_get_parent(hw); + WARN(sel !=3D index, "(%s): Parent index req %u returned back %u\n", + data->name, index, sel); + + return 0; +} + +static int rp1_clock_set_rate_and_parent(struct clk_hw *hw, + unsigned long rate, + unsigned long parent_rate, + u8 parent) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + u32 div =3D rp1_clock_choose_div(rate, parent_rate, data); + + WARN(rate > 4000000000ll, "rate is -ve (%d)\n", (int)rate); + + if (WARN(!div, + "clk divider calculated as 0! (%s, rate %ld, parent rate %ld)\n", + data->name, rate, parent_rate)) + div =3D 1 << CLK_DIV_FRAC_BITS; + + spin_lock(&clockman->regs_lock); + + clockman_write(clockman, data->div_int_reg, div >> CLK_DIV_FRAC_BITS); + if (data->div_frac_reg) + clockman_write(clockman, data->div_frac_reg, div << (32 - CLK_DIV_FRAC_B= ITS)); + + spin_unlock(&clockman->regs_lock); + + if (parent !=3D 0xff) + rp1_clock_set_parent(hw, parent); + + return 0; +} + +static int rp1_clock_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long parent_rate) +{ + return rp1_clock_set_rate_and_parent(hw, rate, parent_rate, 0xff); +} + +static void rp1_clock_choose_div_and_prate(struct clk_hw *hw, + int parent_idx, + unsigned long rate, + unsigned long *prate, + unsigned long *calc_rate) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + const struct rp1_clock_data *data =3D clock->data; + struct clk_hw *parent; + u32 div; + u64 tmp; + + parent =3D clk_hw_get_parent_by_index(hw, parent_idx); + + *prate =3D clk_hw_get_rate(parent); + div =3D rp1_clock_choose_div(rate, *prate, data); + + if (!div) { + *calc_rate =3D 0; + return; + } + + /* Recalculate to account for rounding errors */ + tmp =3D (u64)*prate << CLK_DIV_FRAC_BITS; + tmp =3D div_u64(tmp, div); + + /* + * Prevent overclocks - if all parent choices result in + * a downstream clock in excess of the maximum, then the + * call to set the clock will fail. + */ + if (tmp > clock->data->max_freq) + *calc_rate =3D 0; + else + *calc_rate =3D tmp; +} + +static int rp1_clock_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + struct clk_hw *parent, *best_parent =3D NULL; + unsigned long best_rate =3D 0; + unsigned long best_prate =3D 0; + unsigned long best_rate_diff =3D ULONG_MAX; + unsigned long prate, calc_rate; + size_t i; + + /* + * If the NO_REPARENT flag is set, try to use existing parent. + */ + if ((clk_hw_get_flags(hw) & CLK_SET_RATE_NO_REPARENT)) { + i =3D rp1_clock_get_parent(hw); + parent =3D clk_hw_get_parent_by_index(hw, i); + if (parent) { + rp1_clock_choose_div_and_prate(hw, i, req->rate, &prate, + &calc_rate); + if (calc_rate > 0) { + req->best_parent_hw =3D parent; + req->best_parent_rate =3D prate; + req->rate =3D calc_rate; + return 0; + } + } + } + + /* + * Select parent clock that results in the closest rate (lower or + * higher) + */ + for (i =3D 0; i < clk_hw_get_num_parents(hw); i++) { + parent =3D clk_hw_get_parent_by_index(hw, i); + if (!parent) + continue; + + rp1_clock_choose_div_and_prate(hw, i, req->rate, &prate, + &calc_rate); + + if (abs_diff(calc_rate, req->rate) < best_rate_diff) { + best_parent =3D parent; + best_prate =3D prate; + best_rate =3D calc_rate; + best_rate_diff =3D abs_diff(calc_rate, req->rate); + + if (best_rate_diff =3D=3D 0) + break; + } + } + + if (best_rate =3D=3D 0) + return -EINVAL; + + req->best_parent_hw =3D best_parent; + req->best_parent_rate =3D best_prate; + req->rate =3D best_rate; + + return 0; +} + +static void rp1_clk_debug_init(struct clk_hw *hw, struct dentry *dentry) +{ + struct rp1_clock *clock =3D container_of(hw, struct rp1_clock, hw); + struct rp1_clockman *clockman =3D clock->clockman; + const struct rp1_clock_data *data =3D clock->data; + struct debugfs_reg32 *regs; + int i; + + regs =3D devm_kcalloc(clockman->dev, 4, sizeof(*regs), GFP_KERNEL); + if (!regs) + return; + + i =3D 0; + regs[i].name =3D "ctrl"; + regs[i++].offset =3D data->ctrl_reg; + regs[i].name =3D "div_int"; + regs[i++].offset =3D data->div_int_reg; + regs[i].name =3D "div_frac"; + regs[i++].offset =3D data->div_frac_reg; + regs[i].name =3D "sel"; + regs[i++].offset =3D data->sel_reg; + + rp1_debugfs_regset(clockman, 0, regs, i, dentry); +} + +static const struct clk_ops rp1_pll_core_ops =3D { + .is_prepared =3D rp1_pll_core_is_on, + .prepare =3D rp1_pll_core_on, + .unprepare =3D rp1_pll_core_off, + .set_rate =3D rp1_pll_core_set_rate, + .recalc_rate =3D rp1_pll_core_recalc_rate, + .round_rate =3D rp1_pll_core_round_rate, + .debug_init =3D rp1_pll_core_debug_init, +}; + +static const struct clk_ops rp1_pll_ops =3D { + .set_rate =3D rp1_pll_set_rate, + .recalc_rate =3D rp1_pll_recalc_rate, + .round_rate =3D rp1_pll_round_rate, + .debug_init =3D rp1_pll_debug_init, +}; + +static const struct clk_ops rp1_pll_ph_ops =3D { + .is_prepared =3D rp1_pll_ph_is_on, + .prepare =3D rp1_pll_ph_on, + .unprepare =3D rp1_pll_ph_off, + .set_rate =3D rp1_pll_ph_set_rate, + .recalc_rate =3D rp1_pll_ph_recalc_rate, + .round_rate =3D rp1_pll_ph_round_rate, + .debug_init =3D rp1_pll_ph_debug_init, +}; + +static const struct clk_ops rp1_pll_divider_ops =3D { + .is_prepared =3D rp1_pll_divider_is_on, + .prepare =3D rp1_pll_divider_on, + .unprepare =3D rp1_pll_divider_off, + .set_rate =3D rp1_pll_divider_set_rate, + .recalc_rate =3D rp1_pll_divider_recalc_rate, + .round_rate =3D rp1_pll_divider_round_rate, + .debug_init =3D rp1_pll_divider_debug_init, +}; + +static const struct clk_ops rp1_clk_ops =3D { + .is_prepared =3D rp1_clock_is_on, + .prepare =3D rp1_clock_on, + .unprepare =3D rp1_clock_off, + .recalc_rate =3D rp1_clock_recalc_rate, + .get_parent =3D rp1_clock_get_parent, + .set_parent =3D rp1_clock_set_parent, + .set_rate_and_parent =3D rp1_clock_set_rate_and_parent, + .set_rate =3D rp1_clock_set_rate, + .determine_rate =3D rp1_clock_determine_rate, + .debug_init =3D rp1_clk_debug_init, +}; + +static struct clk_hw *rp1_register_pll_core(struct rp1_clockman *clockman, + const void *data) +{ + const char *ref_clk_name =3D clk_hw_get_name(clockman->hw_xosc); + const struct rp1_pll_core_data *pll_core_data =3D data; + struct rp1_pll_core *pll_core; + struct clk_init_data init; + int ret; + + memset(&init, 0, sizeof(init)); + + /* All of the PLL cores derive from the external oscillator. */ + init.parent_names =3D &ref_clk_name; + init.num_parents =3D 1; + init.name =3D pll_core_data->name; + init.ops =3D &rp1_pll_core_ops; + init.flags =3D pll_core_data->flags | CLK_IGNORE_UNUSED | CLK_IS_CRITICAL; + + pll_core =3D devm_kzalloc(clockman->dev, sizeof(*pll_core), GFP_KERNEL); + if (!pll_core) + return NULL; + + pll_core->clockman =3D clockman; + pll_core->data =3D pll_core_data; + pll_core->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &pll_core->hw); + if (ret) + return ERR_PTR(ret); + + return &pll_core->hw; +} + +static struct clk_hw *rp1_register_pll(struct rp1_clockman *clockman, + const void *data) +{ + const struct rp1_pll_data *pll_data =3D data; + struct rp1_pll *pll; + struct clk_init_data init; + int ret; + + memset(&init, 0, sizeof(init)); + + init.parent_names =3D &pll_data->source_pll; + init.num_parents =3D 1; + init.name =3D pll_data->name; + init.ops =3D &rp1_pll_ops; + init.flags =3D pll_data->flags | CLK_IGNORE_UNUSED | CLK_IS_CRITICAL; + + pll =3D devm_kzalloc(clockman->dev, sizeof(*pll), GFP_KERNEL); + if (!pll) + return NULL; + + pll->clockman =3D clockman; + pll->data =3D pll_data; + pll->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &pll->hw); + if (ret) + return ERR_PTR(ret); + + return &pll->hw; +} + +static struct clk_hw *rp1_register_pll_ph(struct rp1_clockman *clockman, + const void *data) +{ + const struct rp1_pll_ph_data *ph_data =3D data; + struct rp1_pll_ph *ph; + struct clk_init_data init; + int ret; + + memset(&init, 0, sizeof(init)); + + init.parent_names =3D &ph_data->source_pll; + init.num_parents =3D 1; + init.name =3D ph_data->name; + init.ops =3D &rp1_pll_ph_ops; + init.flags =3D ph_data->flags | CLK_IGNORE_UNUSED; + + ph =3D devm_kzalloc(clockman->dev, sizeof(*ph), GFP_KERNEL); + if (!ph) + return NULL; + + ph->clockman =3D clockman; + ph->data =3D ph_data; + ph->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &ph->hw); + if (ret) + return ERR_PTR(ret); + + return &ph->hw; +} + +static struct clk_hw *rp1_register_pll_divider(struct rp1_clockman *clockm= an, + const void *data) +{ + const struct rp1_pll_data *divider_data =3D data; + struct rp1_pll *divider; + struct clk_init_data init; + int ret; + + memset(&init, 0, sizeof(init)); + + init.parent_names =3D ÷r_data->source_pll; + init.num_parents =3D 1; + init.name =3D divider_data->name; + init.ops =3D &rp1_pll_divider_ops; + init.flags =3D divider_data->flags | CLK_IGNORE_UNUSED | CLK_IS_CRITICAL; + + divider =3D devm_kzalloc(clockman->dev, sizeof(*divider), GFP_KERNEL); + if (!divider) + return NULL; + + divider->div.reg =3D clockman->regs + divider_data->ctrl_reg; + divider->div.shift =3D PLL_SEC_DIV_SHIFT; + divider->div.width =3D PLL_SEC_DIV_WIDTH; + divider->div.flags =3D CLK_DIVIDER_ROUND_CLOSEST; + divider->div.flags |=3D CLK_IS_CRITICAL; + divider->div.lock =3D &clockman->regs_lock; + divider->div.hw.init =3D &init; + divider->div.table =3D pll_sec_div_table; + + divider->clockman =3D clockman; + divider->data =3D divider_data; + + ret =3D devm_clk_hw_register(clockman->dev, ÷r->div.hw); + if (ret) + return ERR_PTR(ret); + + return ÷r->div.hw; +} + +static struct clk_hw *rp1_register_clock(struct rp1_clockman *clockman, + const void *data) +{ + const struct rp1_clock_data *clock_data =3D data; + struct rp1_clock *clock; + struct clk_init_data init; + int ret; + + if (WARN_ON_ONCE(MAX_CLK_PARENTS < + clock_data->num_std_parents + clock_data->num_aux_parents)) + return NULL; + + /* There must be a gap for the AUX selector */ + if (WARN_ON_ONCE(clock_data->num_std_parents > AUX_SEL && + strcmp("-", clock_data->parents[AUX_SEL]))) + return NULL; + + memset(&init, 0, sizeof(init)); + init.parent_names =3D clock_data->parents; + init.num_parents =3D clock_data->num_std_parents + + clock_data->num_aux_parents; + init.name =3D clock_data->name; + init.flags =3D clock_data->flags | CLK_IGNORE_UNUSED; + init.ops =3D &rp1_clk_ops; + + clock =3D devm_kzalloc(clockman->dev, sizeof(*clock), GFP_KERNEL); + if (!clock) + return NULL; + + clock->clockman =3D clockman; + clock->data =3D clock_data; + clock->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &clock->hw); + if (ret) + return ERR_PTR(ret); + + return &clock->hw; +} + +/* Assignment helper macros for different clock types. */ +#define _REGISTER(f, ...) { .clk_register =3D f, .data =3D __VA_ARGS__ } + +#define REGISTER_PLL_CORE(...) _REGISTER(&rp1_register_pll_core, \ + &(struct rp1_pll_core_data) \ + {__VA_ARGS__}) + +#define REGISTER_PLL(...) _REGISTER(&rp1_register_pll, \ + &(struct rp1_pll_data) \ + {__VA_ARGS__}) + +#define REGISTER_PLL_PH(...) _REGISTER(&rp1_register_pll_ph, \ + &(struct rp1_pll_ph_data) \ + {__VA_ARGS__}) + +#define REGISTER_PLL_DIV(...) _REGISTER(&rp1_register_pll_divider, \ + &(struct rp1_pll_data) \ + {__VA_ARGS__}) + +#define REGISTER_CLK(...) _REGISTER(&rp1_register_clock, \ + &(struct rp1_clock_data) \ + {__VA_ARGS__}) + +static const struct rp1_clk_desc clk_desc_array[] =3D { + [RP1_PLL_SYS_CORE] =3D REGISTER_PLL_CORE(.name =3D "pll_sys_core", + .cs_reg =3D PLL_SYS_CS, + .pwr_reg =3D PLL_SYS_PWR, + .fbdiv_int_reg =3D PLL_SYS_FBDIV_INT, + .fbdiv_frac_reg =3D PLL_SYS_FBDIV_FRAC, + ), + + [RP1_PLL_AUDIO_CORE] =3D REGISTER_PLL_CORE(.name =3D "pll_audio_core", + .cs_reg =3D PLL_AUDIO_CS, + .pwr_reg =3D PLL_AUDIO_PWR, + .fbdiv_int_reg =3D PLL_AUDIO_FBDIV_INT, + .fbdiv_frac_reg =3D PLL_AUDIO_FBDIV_FRAC, + ), + + [RP1_PLL_VIDEO_CORE] =3D REGISTER_PLL_CORE(.name =3D "pll_video_core", + .cs_reg =3D PLL_VIDEO_CS, + .pwr_reg =3D PLL_VIDEO_PWR, + .fbdiv_int_reg =3D PLL_VIDEO_FBDIV_INT, + .fbdiv_frac_reg =3D PLL_VIDEO_FBDIV_FRAC, + ), + + [RP1_PLL_SYS] =3D REGISTER_PLL(.name =3D "pll_sys", + .source_pll =3D "pll_sys_core", + .ctrl_reg =3D PLL_SYS_PRIM, + .fc0_src =3D FC_NUM(0, 2), + ), + + [RP1_CLK_ETH_TSU] =3D REGISTER_CLK(.name =3D "clk_eth_tsu", + .parents =3D {"rp1-xosc"}, + .num_std_parents =3D 0, + .num_aux_parents =3D 1, + .ctrl_reg =3D CLK_ETH_TSU_CTRL, + .div_int_reg =3D CLK_ETH_TSU_DIV_INT, + .sel_reg =3D CLK_ETH_TSU_SEL, + .div_int_max =3D DIV_INT_8BIT_MAX, + .max_freq =3D 50 * MHz, + .fc0_src =3D FC_NUM(5, 7), + ), + + [RP1_CLK_SYS] =3D REGISTER_CLK(.name =3D "clk_sys", + .parents =3D {"rp1-xosc", "-", "pll_sys"}, + .num_std_parents =3D 3, + .num_aux_parents =3D 0, + .ctrl_reg =3D CLK_SYS_CTRL, + .div_int_reg =3D CLK_SYS_DIV_INT, + .sel_reg =3D CLK_SYS_SEL, + .div_int_max =3D DIV_INT_24BIT_MAX, + .max_freq =3D 200 * MHz, + .fc0_src =3D FC_NUM(0, 4), + .clk_src_mask =3D 0x3, + ), + + [RP1_PLL_SYS_PRI_PH] =3D REGISTER_PLL_PH(.name =3D "pll_sys_pri_ph", + .source_pll =3D "pll_sys", + .ph_reg =3D PLL_SYS_PRIM, + .fixed_divider =3D 2, + .phase =3D RP1_PLL_PHASE_0, + .fc0_src =3D FC_NUM(1, 2), + ), + + [RP1_PLL_SYS_SEC] =3D REGISTER_PLL_DIV(.name =3D "pll_sys_sec", + .source_pll =3D "pll_sys_core", + .ctrl_reg =3D PLL_SYS_SEC, + .fc0_src =3D FC_NUM(2, 2), + ), +}; + +static int rp1_clk_probe(struct platform_device *pdev) +{ + const size_t asize =3D ARRAY_SIZE(clk_desc_array); + const struct rp1_clk_desc *desc; + struct device *dev =3D &pdev->dev; + struct rp1_clockman *clockman; + struct clk *clk_xosc; + struct clk_hw **hws; + unsigned int i; + + clockman =3D devm_kzalloc(dev, struct_size(clockman, onecell.hws, asize), + GFP_KERNEL); + if (!clockman) + return -ENOMEM; + + spin_lock_init(&clockman->regs_lock); + clockman->dev =3D dev; + + clockman->regs =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(clockman->regs)) + return PTR_ERR(clockman->regs); + + clk_xosc =3D devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk_xosc)) + return PTR_ERR(clk_xosc); + + clockman->hw_xosc =3D __clk_get_hw(clk_xosc); + clockman->onecell.num =3D asize; + hws =3D clockman->onecell.hws; + + for (i =3D 0; i < asize; i++) { + desc =3D &clk_desc_array[i]; + if (desc->clk_register && desc->data) { + hws[i] =3D desc->clk_register(clockman, desc->data); + if (IS_ERR_OR_NULL(hws[i])) + dev_err(dev, "Unable to register clock: %s\n", + clk_hw_get_name(hws[i])); + } + } + + platform_set_drvdata(pdev, clockman); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, + &clockman->onecell); +} + +static const struct of_device_id rp1_clk_of_match[] =3D { + { .compatible =3D "raspberrypi,rp1-clocks" }, + {} +}; +MODULE_DEVICE_TABLE(of, rp1_clk_of_match); + +static struct platform_driver rp1_clk_driver =3D { + .driver =3D { + .name =3D "rp1-clk", + .of_match_table =3D rp1_clk_of_match, + }, + .probe =3D rp1_clk_probe, +}; + +static int __init rp1_clk_driver_init(void) +{ + return platform_driver_register(&rp1_clk_driver); +} +postcore_initcall(rp1_clk_driver_init); + +static void __exit rp1_clk_driver_exit(void) +{ + platform_driver_unregister(&rp1_clk_driver); +} +module_exit(rp1_clk_driver_exit); + +MODULE_AUTHOR("Naushir Patuck "); +MODULE_AUTHOR("Andrea della Porta "); +MODULE_DESCRIPTION("RP1 clock driver"); +MODULE_LICENSE("GPL"); --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 691931D54D8 for ; Mon, 7 Oct 2024 12:39:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304802; cv=none; b=rxN8PSzdvDNUYnP4yIdtfzVvIGJqPH6BQiK7M68u2I71VTI0VnVZ0Vgm6RIWrDkuoC2WjC07Q0d/44bqvUhOf69BoubrW3w374bMOkOco0R6ZVg2VTyCk13KFbrdlnzPaY50+J5UA1bekYNhIvwCm7ZSqFUVZlgoHD65nziTiUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304802; c=relaxed/simple; bh=K/9jiEXGaWJCBwHLugVjUvqUlgDHp2vMvULfP8cYdUE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HQ9PItSEpMWEwyT5cjAdg+azS/Xs9pAAvnTcudDfl6O0piJgT1nfIa3YVIjoVY7FasrNfVhevoGsjJafgdvvmc41EMvAhcaxDZnUvt7kZ7YAQsGO9t0yuiiVsMavKnce3x5TLUIfFhMQ8CKYk/yY3sOwOvYtCte574wm9TfeADA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=dkLn2ti0; arc=none smtp.client-ip=209.85.208.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="dkLn2ti0" Received: by mail-lj1-f196.google.com with SMTP id 38308e7fff4ca-2fac49b17ebso32681091fa.0 for ; Mon, 07 Oct 2024 05:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304796; x=1728909596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jLTVNTpWvNJNTEgav04tM9YHWKFoerW7GzoKep+fC2c=; b=dkLn2ti0wVV0wfBmRsYSyDOVyYZUz00/SQJDua+45Clz1mmRl3gERTL6pTdiZ5WOKj CXPszIKafXVfrkwTUN9I4JzIfsyTbFse6o7BLhTdUjrp50JSoTWNfvSlLV9ASaxEy2mz XsFY8KZwLsqRnmTLV5yuDPesfZK5MzEYONTUNqUF5cwzaGC4OuCO6tCFsnxEqzLpN2UT RlsuOetl1lIslAjXFjSLKP2fbjyymTLpONstMwogKAwCxODNQfk2SA3LMkABhOTp98yT Lsr0rq/X+YqOtw7+NjoMSZoGKjrW7EW/uyOOZe40EaNe2gFoAwz8OkCds4YQYxbHp9hP q59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304796; x=1728909596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jLTVNTpWvNJNTEgav04tM9YHWKFoerW7GzoKep+fC2c=; b=fxbzVU90RMfSW0o0hdocF/G+7eAzTmeodH6QCx279efNFUrRPB2sLelbarsG50vibz 9ZyZI6g35uiKRPJZSWf4B7px6MHlPPCT8wLyBP0uP5PZAANLQQdZnP81rmWMuZ3ZWmiw eaig8Z/lHf+zuoj8HUF6q0e95Pp49T0Ky7Zqqu5f4TGXnUz3p0z/PrUCuQPl8joYwslP TQSukPFypQ6IIqZGBZjf8u3FIErj/mhPZwVtUfu5lgt09tgjkFhx9pfKZdF50qGzxN0e Zm2m6Zz/pJgp/6B3H/53fm+BWSR+JEm2oZzPtnP7YKbfNxPBuLbrHxwFAfbeHxAZY2/O NPAA== X-Forwarded-Encrypted: i=1; AJvYcCUk4mxR1jbhMYl8eWFErCON2n7iZn+EEhr0I4d8XJWjp8+bZb4t3XtVMJeulhuNXPvPV2MSzbSqERFgqYQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2oJLkO6Zk9Qg299prtDXil4fM9u3D+Ikt7mtk0T/U3w8TFsLO gd7cG5YqFbc9pYHWCjJmGUgM/KFM9GkpIBheKlkxrv4gw6RC0hZRNf4vrLEwRIc= X-Google-Smtp-Source: AGHT+IE221xonLAH9xvAoowC3AixczbMz8OftHXPf4W3a988UdsERFQQeLrjc1SdmmsoaIWCGIRgyA== X-Received: by 2002:a2e:a586:0:b0:2f3:b71a:1e91 with SMTP id 38308e7fff4ca-2faf3c1ce4fmr58068821fa.17.1728304796301; Mon, 07 Oct 2024 05:39:56 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8e05eb7b7sm3172901a12.68.2024.10.07.05.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:55 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 09/14] pinctrl: rp1: Implement RaspberryPi RP1 gpio support Date: Mon, 7 Oct 2024 14:39:52 +0200 Message-ID: <199a4994312b120c73c95fa368954ad5a2a8aee6.1728300190.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RP1 is an MFD supporting a gpio controller and /pinmux/pinctrl. Add minimum support for the gpio only portion. The driver is in pinctrl folder since upcoming patches will add the pinmux/pinctrl support where the gpio part can be seen as an addition. Signed-off-by: Andrea della Porta --- Please note that checkpatch warning on this patch are unavoidable. MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 860 ++++++++++++++++++++++++++++++++++ 4 files changed, 873 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-rp1.c diff --git a/MAINTAINERS b/MAINTAINERS index dc064cd4b6b5..06277969a522 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19388,6 +19388,7 @@ F: Documentation/devicetree/bindings/misc/pci1de4,1= .yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: drivers/clk/clk-rp1.c +F: drivers/pinctrl/pinctrl-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h =20 diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 354536de564b..f49b8b7f6afa 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -587,6 +587,17 @@ config PINCTRL_MLXBF3 each pin. This driver can also be built as a module called pinctrl-mlxbf3. =20 +config PINCTRL_RP1 + bool "Pinctrl driver for RP1" + select PINMUX + select PINCONF + select GENERIC_PINCONF + select GPIOLIB + select GPIOLIB_IRQCHIP + help + Enable the gpio and pinctrl/mux driver for RaspberryPi RP1 + multi function device. + source "drivers/pinctrl/actions/Kconfig" source "drivers/pinctrl/aspeed/Kconfig" source "drivers/pinctrl/bcm/Kconfig" diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index 97823f52b972..2d714047a1ce 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -47,6 +47,7 @@ obj-$(CONFIG_PINCTRL_PIC32) +=3D pinctrl-pic32.o obj-$(CONFIG_PINCTRL_PISTACHIO) +=3D pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_RK805) +=3D pinctrl-rk805.o obj-$(CONFIG_PINCTRL_ROCKCHIP) +=3D pinctrl-rockchip.o +obj-$(CONFIG_PINCTRL_RP1) +=3D pinctrl-rp1.o obj-$(CONFIG_PINCTRL_SCMI) +=3D pinctrl-scmi.o obj-$(CONFIG_PINCTRL_SINGLE) +=3D pinctrl-single.o obj-$(CONFIG_PINCTRL_ST) +=3D pinctrl-st.o diff --git a/drivers/pinctrl/pinctrl-rp1.c b/drivers/pinctrl/pinctrl-rp1.c new file mode 100644 index 000000000000..617804871e03 --- /dev/null +++ b/drivers/pinctrl/pinctrl-rp1.c @@ -0,0 +1,860 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Driver for Raspberry Pi RP1 GPIO unit + * + * Copyright (C) 2023 Raspberry Pi Ltd. + * + * This driver is inspired by: + * pinctrl-bcm2835.c, please see original file for copyright information + */ + +#include +#include +#include +#include +#include + +#define MODULE_NAME "pinctrl-rp1" +#define RP1_NUM_GPIOS 54 +#define RP1_NUM_BANKS 3 + +#define RP1_INT_EDGE_FALLING BIT(0) +#define RP1_INT_EDGE_RISING BIT(1) +#define RP1_INT_LEVEL_LOW BIT(2) +#define RP1_INT_LEVEL_HIGH BIT(3) +#define RP1_INT_MASK GENMASK(3, 0) +#define RP1_INT_EDGE_BOTH (RP1_INT_EDGE_FALLING | \ + RP1_INT_EDGE_RISING) + +#define RP1_FSEL_COUNT 9 + +#define RP1_FSEL_ALT0 0x00 +#define RP1_FSEL_GPIO 0x05 +#define RP1_FSEL_NONE 0x09 +#define RP1_FSEL_NONE_HW 0x1f + +#define RP1_PAD_DRIVE_2MA 0x0 +#define RP1_PAD_DRIVE_4MA 0x1 +#define RP1_PAD_DRIVE_8MA 0x2 +#define RP1_PAD_DRIVE_12MA 0x3 + +enum { + RP1_PUD_OFF =3D 0, + RP1_PUD_DOWN =3D 1, + RP1_PUD_UP =3D 2, +}; + +enum { + RP1_DIR_OUTPUT =3D 0, + RP1_DIR_INPUT =3D 1, +}; + +enum { + RP1_OUTOVER_PERI =3D 0, + RP1_OUTOVER_INVPERI =3D 1, + RP1_OUTOVER_LOW =3D 2, + RP1_OUTOVER_HIGH =3D 3, +}; + +enum { + RP1_OEOVER_PERI =3D 0, + RP1_OEOVER_INVPERI =3D 1, + RP1_OEOVER_DISABLE =3D 2, + RP1_OEOVER_ENABLE =3D 3, +}; + +enum { + RP1_INOVER_PERI =3D 0, + RP1_INOVER_INVPERI =3D 1, + RP1_INOVER_LOW =3D 2, + RP1_INOVER_HIGH =3D 3, +}; + +enum { + RP1_GPIO_CTRL_IRQRESET_SET =3D 0, + RP1_GPIO_CTRL_INT_CLR =3D 1, + RP1_GPIO_CTRL_INT_SET =3D 2, + RP1_GPIO_CTRL_OEOVER =3D 3, + RP1_GPIO_CTRL_FUNCSEL =3D 4, + RP1_GPIO_CTRL_OUTOVER =3D 5, + RP1_GPIO_CTRL =3D 6, +}; + +enum { + RP1_INTE_SET =3D 0, + RP1_INTE_CLR =3D 1, +}; + +enum { + RP1_RIO_OUT_SET =3D 0, + RP1_RIO_OUT_CLR =3D 1, + RP1_RIO_OE =3D 2, + RP1_RIO_OE_SET =3D 3, + RP1_RIO_OE_CLR =3D 4, + RP1_RIO_IN =3D 5, +}; + +enum { + RP1_PAD_SLEWFAST =3D 0, + RP1_PAD_SCHMITT =3D 1, + RP1_PAD_PULL =3D 2, + RP1_PAD_DRIVE =3D 3, + RP1_PAD_IN_ENABLE =3D 4, + RP1_PAD_OUT_DISABLE =3D 5, +}; + +static const struct reg_field rp1_gpio_fields[] =3D { + [RP1_GPIO_CTRL_IRQRESET_SET] =3D REG_FIELD(0x2004, 28, 28), + [RP1_GPIO_CTRL_INT_CLR] =3D REG_FIELD(0x3004, 20, 23), + [RP1_GPIO_CTRL_INT_SET] =3D REG_FIELD(0x2004, 20, 23), + [RP1_GPIO_CTRL_OEOVER] =3D REG_FIELD(0x0004, 14, 15), + [RP1_GPIO_CTRL_FUNCSEL] =3D REG_FIELD(0x0004, 0, 4), + [RP1_GPIO_CTRL_OUTOVER] =3D REG_FIELD(0x0004, 12, 13), + [RP1_GPIO_CTRL] =3D REG_FIELD(0x0004, 0, 31), +}; + +static const struct reg_field rp1_inte_fields[] =3D { + [RP1_INTE_SET] =3D REG_FIELD(0x2000, 0, 0), + [RP1_INTE_CLR] =3D REG_FIELD(0x3000, 0, 0), +}; + +static const struct reg_field rp1_rio_fields[] =3D { + [RP1_RIO_OUT_SET] =3D REG_FIELD(0x2000, 0, 0), + [RP1_RIO_OUT_CLR] =3D REG_FIELD(0x3000, 0, 0), + [RP1_RIO_OE] =3D REG_FIELD(0x0004, 0, 0), + [RP1_RIO_OE_SET] =3D REG_FIELD(0x2004, 0, 0), + [RP1_RIO_OE_CLR] =3D REG_FIELD(0x3004, 0, 0), + [RP1_RIO_IN] =3D REG_FIELD(0x0008, 0, 0), +}; + +static const struct reg_field rp1_pad_fields[] =3D { + [RP1_PAD_SLEWFAST] =3D REG_FIELD(0, 0, 0), + [RP1_PAD_SCHMITT] =3D REG_FIELD(0, 1, 1), + [RP1_PAD_PULL] =3D REG_FIELD(0, 2, 3), + [RP1_PAD_DRIVE] =3D REG_FIELD(0, 4, 5), + [RP1_PAD_IN_ENABLE] =3D REG_FIELD(0, 6, 6), + [RP1_PAD_OUT_DISABLE] =3D REG_FIELD(0, 7, 7), +}; + +struct rp1_iobank_desc { + int min_gpio; + int num_gpios; + int gpio_offset; + int inte_offset; + int ints_offset; + int rio_offset; + int pads_offset; +}; + +struct rp1_pin_info { + u8 num; + u8 bank; + u8 offset; + u8 fsel; + u8 irq_type; + + struct regmap_field *gpio[ARRAY_SIZE(rp1_gpio_fields)]; + struct regmap_field *rio[ARRAY_SIZE(rp1_rio_fields)]; + struct regmap_field *inte[ARRAY_SIZE(rp1_inte_fields)]; + struct regmap_field *pad[ARRAY_SIZE(rp1_pad_fields)]; +}; + +struct rp1_pinctrl { + struct device *dev; + void __iomem *gpio_base; + void __iomem *rio_base; + void __iomem *pads_base; + int irq[RP1_NUM_BANKS]; + struct rp1_pin_info pins[RP1_NUM_GPIOS]; + + struct pinctrl_dev *pctl_dev; + struct gpio_chip gpio_chip; + struct pinctrl_gpio_range gpio_range; + + raw_spinlock_t irq_lock[RP1_NUM_BANKS]; + + struct configfs_subsystem subsys; +}; + +static const struct rp1_iobank_desc rp1_iobanks[RP1_NUM_BANKS] =3D { + /* gpio inte ints rio pads */ + { 0, 28, 0x0000, 0x011c, 0x0124, 0x0000, 0x0004 }, + { 28, 6, 0x4000, 0x411c, 0x4124, 0x4000, 0x4004 }, + { 34, 20, 0x8000, 0x811c, 0x8124, 0x8000, 0x8004 }, +}; + +static int rp1_pinconf_set(struct rp1_pin_info *pin, + unsigned int offset, unsigned long *configs, + unsigned int num_configs); + +static struct rp1_pin_info *rp1_get_pin(struct gpio_chip *chip, + unsigned int offset) +{ + struct rp1_pinctrl *pc =3D gpiochip_get_data(chip); + + if (pc && offset < RP1_NUM_GPIOS) + return &pc->pins[offset]; + return NULL; +} + +static void rp1_input_enable(struct rp1_pin_info *pin, int value) +{ + regmap_field_write(pin->pad[RP1_PAD_IN_ENABLE], !!value); +} + +static void rp1_output_enable(struct rp1_pin_info *pin, int value) +{ + regmap_field_write(pin->pad[RP1_PAD_OUT_DISABLE], !value); +} + +static u32 rp1_get_fsel(struct rp1_pin_info *pin) +{ + u32 oeover, fsel; + + regmap_field_read(pin->gpio[RP1_GPIO_CTRL_OEOVER], &oeover); + regmap_field_read(pin->gpio[RP1_GPIO_CTRL_FUNCSEL], &fsel); + + if (oeover !=3D RP1_OEOVER_PERI || fsel >=3D RP1_FSEL_COUNT) + fsel =3D RP1_FSEL_NONE; + + return fsel; +} + +static void rp1_set_fsel(struct rp1_pin_info *pin, u32 fsel) +{ + if (fsel >=3D RP1_FSEL_COUNT) + fsel =3D RP1_FSEL_NONE_HW; + + rp1_input_enable(pin, 1); + rp1_output_enable(pin, 1); + + if (fsel =3D=3D RP1_FSEL_NONE) { + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_OEOVER], RP1_OEOVER_DISABLE); + } else { + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_OUTOVER], RP1_OUTOVER_PERI); + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_OEOVER], RP1_OEOVER_PERI); + } + + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_FUNCSEL], fsel); +} + +static int rp1_get_dir(struct rp1_pin_info *pin) +{ + unsigned int val; + + regmap_field_read(pin->rio[RP1_RIO_OE], &val); + + return !val ? RP1_DIR_INPUT : RP1_DIR_OUTPUT; +} + +static void rp1_set_dir(struct rp1_pin_info *pin, bool is_input) +{ + int reg =3D is_input ? RP1_RIO_OE_CLR : RP1_RIO_OE_SET; + + regmap_field_write(pin->rio[reg], 1); +} + +static int rp1_get_value(struct rp1_pin_info *pin) +{ + unsigned int val; + + regmap_field_read(pin->rio[RP1_RIO_IN], &val); + + return !!val; +} + +static void rp1_set_value(struct rp1_pin_info *pin, int value) +{ + /* Assume the pin is already an output */ + int reg =3D value ? RP1_RIO_OUT_SET : RP1_RIO_OUT_CLR; + + regmap_field_write(pin->rio[reg], 1); +} + +static int rp1_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + int ret; + + if (!pin) + return -EINVAL; + + ret =3D rp1_get_value(pin); + + return ret; +} + +static void rp1_gpio_set(struct gpio_chip *chip, unsigned int offset, int = value) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + + if (pin) + rp1_set_value(pin, value); +} + +static int rp1_gpio_get_direction(struct gpio_chip *chip, unsigned int off= set) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + u32 fsel; + + if (!pin) + return -EINVAL; + + fsel =3D rp1_get_fsel(pin); + if (fsel !=3D RP1_FSEL_GPIO) + return -EINVAL; + + return (rp1_get_dir(pin) =3D=3D RP1_DIR_OUTPUT) ? + GPIO_LINE_DIRECTION_OUT : + GPIO_LINE_DIRECTION_IN; +} + +static int rp1_gpio_direction_input(struct gpio_chip *chip, unsigned int o= ffset) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + + if (!pin) + return -EINVAL; + rp1_set_dir(pin, RP1_DIR_INPUT); + rp1_set_fsel(pin, RP1_FSEL_GPIO); + + return 0; +} + +static int rp1_gpio_direction_output(struct gpio_chip *chip, unsigned int = offset, + int value) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + + if (!pin) + return -EINVAL; + rp1_set_value(pin, value); + rp1_set_dir(pin, RP1_DIR_OUTPUT); + rp1_set_fsel(pin, RP1_FSEL_GPIO); + + return 0; +} + +static int rp1_gpio_set_config(struct gpio_chip *chip, unsigned int offset, + unsigned long config) +{ + struct rp1_pin_info *pin =3D rp1_get_pin(chip, offset); + unsigned long configs[] =3D { config }; + + return rp1_pinconf_set(pin, offset, configs, + ARRAY_SIZE(configs)); +} + +static const struct gpio_chip rp1_gpio_chip =3D { + .label =3D MODULE_NAME, + .owner =3D THIS_MODULE, + .request =3D gpiochip_generic_request, + .free =3D gpiochip_generic_free, + .direction_input =3D rp1_gpio_direction_input, + .direction_output =3D rp1_gpio_direction_output, + .get_direction =3D rp1_gpio_get_direction, + .get =3D rp1_gpio_get, + .set =3D rp1_gpio_set, + .base =3D -1, + .set_config =3D rp1_gpio_set_config, + .ngpio =3D RP1_NUM_GPIOS, + .can_sleep =3D false, +}; + +static void rp1_gpio_irq_handler(struct irq_desc *desc) +{ + struct gpio_chip *chip =3D irq_desc_get_handler_data(desc); + struct irq_chip *host_chip =3D irq_desc_get_chip(desc); + struct rp1_pinctrl *pc =3D gpiochip_get_data(chip); + const struct rp1_iobank_desc *bank; + int irq =3D irq_desc_get_irq(desc); + unsigned long ints; + int bit_pos; + + if (pc->irq[0] =3D=3D irq) + bank =3D &rp1_iobanks[0]; + else if (pc->irq[1] =3D=3D irq) + bank =3D &rp1_iobanks[1]; + else + bank =3D &rp1_iobanks[2]; + + chained_irq_enter(host_chip, desc); + + ints =3D readl(pc->gpio_base + bank->ints_offset); + for_each_set_bit(bit_pos, &ints, 32) { + struct rp1_pin_info *pin =3D rp1_get_pin(chip, bit_pos); + + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_IRQRESET_SET], 1); + generic_handle_irq(irq_linear_revmap(pc->gpio_chip.irq.domain, + bank->gpio_offset + bit_pos)); + } + + chained_irq_exit(host_chip, desc); +} + +static void rp1_gpio_irq_config(struct rp1_pin_info *pin, bool enable) +{ + int reg =3D enable ? RP1_INTE_SET : RP1_INTE_CLR; + + regmap_field_write(pin->inte[reg], 1); + if (!enable) + /* Clear any latched events */ + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_IRQRESET_SET], 1); +} + +static void rp1_gpio_irq_enable(struct irq_data *data) +{ + struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); + unsigned int gpio =3D irqd_to_hwirq(data); + struct rp1_pin_info *pin =3D rp1_get_pin(chip, gpio); + + rp1_gpio_irq_config(pin, true); +} + +static void rp1_gpio_irq_disable(struct irq_data *data) +{ + struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); + unsigned int gpio =3D irqd_to_hwirq(data); + struct rp1_pin_info *pin =3D rp1_get_pin(chip, gpio); + + rp1_gpio_irq_config(pin, false); +} + +static int rp1_irq_set_type(struct rp1_pin_info *pin, unsigned int type) +{ + u32 irq_flags; + + switch (type) { + case IRQ_TYPE_NONE: + irq_flags =3D 0; + break; + case IRQ_TYPE_EDGE_RISING: + irq_flags =3D RP1_INT_EDGE_RISING; + break; + case IRQ_TYPE_EDGE_FALLING: + irq_flags =3D RP1_INT_EDGE_FALLING; + break; + case IRQ_TYPE_EDGE_BOTH: + irq_flags =3D RP1_INT_EDGE_RISING | RP1_INT_EDGE_FALLING; + break; + case IRQ_TYPE_LEVEL_HIGH: + irq_flags =3D RP1_INT_LEVEL_HIGH; + break; + case IRQ_TYPE_LEVEL_LOW: + irq_flags =3D RP1_INT_LEVEL_LOW; + break; + + default: + return -EINVAL; + } + + /* Clear them all */ + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_INT_CLR], RP1_INT_MASK); + + /* Set those that are needed */ + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_INT_SET], irq_flags); + pin->irq_type =3D type; + + return 0; +} + +static int rp1_gpio_irq_set_type(struct irq_data *data, unsigned int type) +{ + struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); + unsigned int gpio =3D irqd_to_hwirq(data); + struct rp1_pin_info *pin =3D rp1_get_pin(chip, gpio); + struct rp1_pinctrl *pc =3D gpiochip_get_data(chip); + int bank =3D pin->bank; + unsigned long flags; + int ret; + + raw_spin_lock_irqsave(&pc->irq_lock[bank], flags); + + ret =3D rp1_irq_set_type(pin, type); + if (!ret) { + if (type & IRQ_TYPE_EDGE_BOTH) + irq_set_handler_locked(data, handle_edge_irq); + else + irq_set_handler_locked(data, handle_level_irq); + } + + raw_spin_unlock_irqrestore(&pc->irq_lock[bank], flags); + + return ret; +} + +static void rp1_gpio_irq_ack(struct irq_data *data) +{ + struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); + unsigned int gpio =3D irqd_to_hwirq(data); + struct rp1_pin_info *pin =3D rp1_get_pin(chip, gpio); + + /* Clear any latched events */ + regmap_field_write(pin->gpio[RP1_GPIO_CTRL_IRQRESET_SET], 1); +} + +static struct irq_chip rp1_gpio_irq_chip =3D { + .name =3D MODULE_NAME, + .irq_enable =3D rp1_gpio_irq_enable, + .irq_disable =3D rp1_gpio_irq_disable, + .irq_set_type =3D rp1_gpio_irq_set_type, + .irq_ack =3D rp1_gpio_irq_ack, + .irq_mask =3D rp1_gpio_irq_disable, + .irq_unmask =3D rp1_gpio_irq_enable, + .flags =3D IRQCHIP_IMMUTABLE, +}; + +static void rp1_pull_config_set(struct rp1_pin_info *pin, unsigned int arg) +{ + regmap_field_write(pin->pad[RP1_PAD_PULL], arg & 0x3); +} + +static int rp1_pinconf_set(struct rp1_pin_info *pin, unsigned int offset, + unsigned long *configs, unsigned int num_configs) +{ + u32 param, arg; + int i; + + if (!pin) + return -EINVAL; + + for (i =3D 0; i < num_configs; i++) { + param =3D pinconf_to_config_param(configs[i]); + arg =3D pinconf_to_config_argument(configs[i]); + + switch (param) { + case PIN_CONFIG_BIAS_DISABLE: + rp1_pull_config_set(pin, RP1_PUD_OFF); + break; + + case PIN_CONFIG_BIAS_PULL_DOWN: + rp1_pull_config_set(pin, RP1_PUD_DOWN); + break; + + case PIN_CONFIG_BIAS_PULL_UP: + rp1_pull_config_set(pin, RP1_PUD_UP); + break; + + case PIN_CONFIG_INPUT_ENABLE: + rp1_input_enable(pin, arg); + break; + + case PIN_CONFIG_OUTPUT_ENABLE: + rp1_output_enable(pin, arg); + break; + + case PIN_CONFIG_OUTPUT: + rp1_set_value(pin, arg); + rp1_set_dir(pin, RP1_DIR_OUTPUT); + rp1_set_fsel(pin, RP1_FSEL_GPIO); + break; + + case PIN_CONFIG_INPUT_SCHMITT_ENABLE: + regmap_field_write(pin->pad[RP1_PAD_SCHMITT], !!arg); + break; + + case PIN_CONFIG_SLEW_RATE: + regmap_field_write(pin->pad[RP1_PAD_SLEWFAST], !!arg); + break; + + case PIN_CONFIG_DRIVE_STRENGTH: + switch (arg) { + case 2: + arg =3D RP1_PAD_DRIVE_2MA; + break; + case 4: + arg =3D RP1_PAD_DRIVE_4MA; + break; + case 8: + arg =3D RP1_PAD_DRIVE_8MA; + break; + case 12: + arg =3D RP1_PAD_DRIVE_12MA; + break; + default: + return -ENOTSUPP; + } + regmap_field_write(pin->pad[RP1_PAD_DRIVE], arg); + break; + + default: + return -ENOTSUPP; + + } /* switch param type */ + } /* for each config */ + + return 0; +} + +static const struct of_device_id rp1_pinctrl_match[] =3D { + { .compatible =3D "raspberrypi,rp1-gpio" }, + {}, +}; + +static ssize_t rp1_gpio_set_names_write(struct config_item *item, + const void *buf, size_t count) +{ + struct rp1_pinctrl *rp1 =3D container_of(to_configfs_subsystem(to_config_= group(item)), + struct rp1_pinctrl, subsys); + struct gpio_chip *chip =3D &rp1->gpio_chip; + struct device *dev =3D rp1->dev; + int ret, ovcs_id; + + ret =3D of_overlay_fdt_apply(buf, count, &ovcs_id, NULL); + + if (ret) { + dev_err(dev, "Cannot apply rp1_gpio overlay\n"); + return ret; + } + + ret =3D gpiochip_set_names(chip); + + if (ret) { + dev_err(dev, "Cannot set gpio line names\n"); + return ret; + } + + return count; +} + +CONFIGFS_BIN_ATTR_WO(rp1_, gpio_set_names, NULL, 2048); + +static struct configfs_bin_attribute *rp1_cfg_attrs[] =3D { + &rp1_attr_gpio_set_names, + NULL, +}; + +static const struct config_item_type rp1_cfg_type =3D { + .ct_bin_attrs =3D rp1_cfg_attrs, + .ct_owner =3D THIS_MODULE, +}; + +static struct rp1_pinctrl rp1_pinctrl_data =3D { + .subsys =3D { + .su_group =3D { + .cg_item =3D { + .ci_namebuf =3D "rp1-cfg", + .ci_type =3D &rp1_cfg_type, + }, + }, + }, +}; + +static const struct regmap_config rp1_pinctrl_regmap_cfg =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, + .fast_io =3D true, + .name =3D "rp1-pinctrl", +}; + +static int rp1_gen_regfield(struct device *dev, + const struct reg_field *array, + size_t array_size, + int reg_off, + int pin_off, + bool additive_offset, + struct regmap *regmap, + struct regmap_field *out[]) +{ + struct reg_field regfield; + int k; + + for (k =3D 0; k < array_size; k++) { + regfield =3D array[k]; + regfield.reg =3D (additive_offset ? regfield.reg : 0) + reg_off; + if (pin_off >=3D 0) { + regfield.lsb =3D pin_off; + regfield.msb =3D regfield.lsb; + } + out[k] =3D devm_regmap_field_alloc(dev, regmap, regfield); + + if (IS_ERR(out[k])) + return PTR_ERR(out[k]); + } + + return 0; +} + +static int rp1_pinctrl_probe(struct platform_device *pdev) +{ + struct regmap *gpio_regmap, *rio_regmap, *pads_regmap; + struct rp1_pinctrl *pc =3D &rp1_pinctrl_data; + struct device *dev =3D &pdev->dev; + struct device_node *np =3D dev->of_node; + struct gpio_irq_chip *girq; + int err, i; + + pc->dev =3D dev; + pc->gpio_chip =3D rp1_gpio_chip; + pc->gpio_chip.parent =3D dev; + + pc->gpio_base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(pc->gpio_base)) { + dev_err(dev, "could not get GPIO IO memory\n"); + return PTR_ERR(pc->gpio_base); + } + + pc->rio_base =3D devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(pc->rio_base)) { + dev_err(dev, "could not get RIO IO memory\n"); + return PTR_ERR(pc->rio_base); + } + + pc->pads_base =3D devm_platform_ioremap_resource(pdev, 2); + if (IS_ERR(pc->pads_base)) { + dev_err(dev, "could not get PADS IO memory\n"); + return PTR_ERR(pc->pads_base); + } + + gpio_regmap =3D devm_regmap_init_mmio(dev, pc->gpio_base, + &rp1_pinctrl_regmap_cfg); + if (IS_ERR(gpio_regmap)) { + dev_err(dev, "could not init GPIO regmap\n"); + return PTR_ERR(gpio_regmap); + } + + rio_regmap =3D devm_regmap_init_mmio(dev, pc->rio_base, + &rp1_pinctrl_regmap_cfg); + if (IS_ERR(rio_regmap)) { + dev_err(dev, "could not init RIO regmap\n"); + return PTR_ERR(rio_regmap); + } + + pads_regmap =3D devm_regmap_init_mmio(dev, pc->pads_base, + &rp1_pinctrl_regmap_cfg); + if (IS_ERR(pads_regmap)) { + dev_err(dev, "could not init PADS regmap\n"); + return PTR_ERR(pads_regmap); + } + + for (i =3D 0; i < RP1_NUM_BANKS; i++) { + const struct rp1_iobank_desc *bank =3D &rp1_iobanks[i]; + int j; + + for (j =3D 0; j < bank->num_gpios; j++) { + struct rp1_pin_info *pin =3D + &pc->pins[bank->min_gpio + j]; + int reg_off; + + pin->num =3D bank->min_gpio + j; + pin->bank =3D i; + pin->offset =3D j; + + reg_off =3D bank->gpio_offset + pin->offset + * sizeof(u32) * 2; + err =3D rp1_gen_regfield(dev, + rp1_gpio_fields, + ARRAY_SIZE(rp1_gpio_fields), + reg_off, + -1, + true, + gpio_regmap, + pin->gpio); + + if (err) { + dev_err(dev, "Unable to allocate regmap for gpio\n"); + return err; + } + + reg_off =3D bank->inte_offset; + err =3D rp1_gen_regfield(dev, + rp1_inte_fields, + ARRAY_SIZE(rp1_inte_fields), + reg_off, + pin->offset, + true, + gpio_regmap, + pin->inte); + + if (err) { + dev_err(dev, "Unable to allocate regmap for inte\n"); + return err; + } + + reg_off =3D bank->rio_offset; + err =3D rp1_gen_regfield(dev, + rp1_rio_fields, + ARRAY_SIZE(rp1_rio_fields), + reg_off, + pin->offset, + true, + rio_regmap, + pin->rio); + + if (err) { + dev_err(dev, "Unable to allocate regmap for rio\n"); + return err; + } + + reg_off =3D bank->pads_offset + pin->offset * sizeof(u32); + err =3D rp1_gen_regfield(dev, + rp1_pad_fields, + ARRAY_SIZE(rp1_pad_fields), + reg_off, + -1, + false, + pads_regmap, + pin->pad); + + if (err) { + dev_err(dev, "Unable to allocate regmap for pad\n"); + return err; + } + } + + raw_spin_lock_init(&pc->irq_lock[i]); + } + + girq =3D &pc->gpio_chip.irq; + girq->chip =3D &rp1_gpio_irq_chip; + girq->parent_handler =3D rp1_gpio_irq_handler; + girq->num_parents =3D RP1_NUM_BANKS; + girq->parents =3D pc->irq; + girq->default_type =3D IRQ_TYPE_NONE; + girq->handler =3D handle_level_irq; + + /* + * Use the same handler for all groups: this is necessary + * since we use one gpiochip to cover all lines - the + * irq handler then needs to figure out which group and + * bank that was firing the IRQ and look up the per-group + * and bank data. + */ + for (i =3D 0; i < RP1_NUM_BANKS; i++) { + pc->irq[i] =3D irq_of_parse_and_map(np, i); + if (!pc->irq[i]) { + girq->num_parents =3D i; + break; + } + } + + platform_set_drvdata(pdev, pc); + + err =3D devm_gpiochip_add_data(dev, &pc->gpio_chip, pc); + if (err) { + dev_err(dev, "could not add GPIO chip\n"); + return err; + } + + config_group_init(&pc->subsys.su_group); + mutex_init(&pc->subsys.su_mutex); + err =3D configfs_register_subsystem(&pc->subsys); + if (err) { + dev_err(dev, "Error %d while registering subsystem %s\n", + err, pc->subsys.su_group.cg_item.ci_namebuf); + return err; + } + + return 0; +} + +static struct platform_driver rp1_pinctrl_driver =3D { + .probe =3D rp1_pinctrl_probe, + .driver =3D { + .name =3D MODULE_NAME, + .of_match_table =3D rp1_pinctrl_match, + .suppress_bind_attrs =3D true, + }, +}; +builtin_platform_driver(rp1_pinctrl_driver); --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68D821D5ACE for ; Mon, 7 Oct 2024 12:39:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304804; cv=none; b=uL1XEUVFdMkCurlYR3Nn6TtZN+5gOZRzDA9tS5wSW6ZEZdogWBQ0Kk/GIrz9I2NZTAgTiwJ6b6dO01v/55Q+BiE5MehTvd+TKXkcgsMeKvEI7ceWBsGZlMrRZqWklKuFZxUvnVPUzTspwGBBsVmr6N3GXHxOP7kwW+0/TlBNt4M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304804; c=relaxed/simple; bh=MG2zG1bQpYhX9tF6Jz6wNxWrPu+3Z4sbMxD50E4qKOs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TdlOwOKuhOk42VVUqHvr1MncQM+H1d3PA8HvTqtDK5DhW17C0TR2JOcgBHrcO9L+KnT/bONw3z+lHmbtHapIBAAw/chVz/pVBl4KvoGAiB1t+oZNRFIRi1Ak6YV11p2GSeh3iMgzvdaUQnROk4mftVn2lYMczFZO0JSniaUpCSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=JD4qR1in; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="JD4qR1in" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-539973829e7so4279071e87.0 for ; Mon, 07 Oct 2024 05:39:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304797; x=1728909597; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BDBbUzAbVmbfauTgZMPEls+orUZqC1xI/z6QelfsXFI=; b=JD4qR1inRSdtNB0+ZrzVy1BGbR8QneP09WeESPh0ZVVwOQF/jlWJO8bilWi2yMpEuT RPhMJ4CJbFsn3Wz8brZ2Q1e/RC40iIJ1/JaiOI9zwbqGiCsaRPJA+TxW2uJup0K0BQa3 e7x9VqWBhCDUV2uneUNZ035VSyMtYLQ02ICduwCzny4zaAZvJoqwykPXFus47rkHeEv1 GtzZcP4Cind0ZhOp1NQh/OMDHT67Qw/b9yZuufiMhCR3vu0BagE3gErEWw59cnTmbhgs n1rThDrsa2uziJsSi6K3r0MwKojJGxXhZyeZjY70lJwZ+0oCXHo56cuU3OC6CTX70BKz rGIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304797; x=1728909597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BDBbUzAbVmbfauTgZMPEls+orUZqC1xI/z6QelfsXFI=; b=JWTr9QfX3H6Uxep/85oedAJMrm5QYOmEQbqSyusSMAIn6V2TCxORI8k4BoFzazjAFE xku7lSgsHjqZUt5V2g5yNM8XzqRop5B+tegmT8uYAsWVWOKafy2RkNZCWTUYlEJVfCBd p6o4gf4IwcSgXBTgwEh83mh5gjoQNiBW//Jo55clqAUkrb8m3gEt3ONypsFGVWJ1SfA2 aEyIzfxjKgJ2YEHHwKwuq5DvjRFz2jz5H470QWjJ6DBgtcC3QjgtPCVVqeoK1HCKlRSp J0b1MWsCH4KHE3t3PvMdDXdXzACVEzFBWNzyaNfBmUHZrF8vbLh9D5X/AImlP2iFKClX T+6A== X-Forwarded-Encrypted: i=1; AJvYcCV85syFHo9EEIkWNCaMIP4uWPE4M1ESliH1bfliO2fTKCw++AHnL2Jl2u0oRox2ceHsTS4IFXZ8v3JpZrY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywx0J8119upZvoemdixTfa5j6BLZm3iaW2yZqdp3Jln6XFuna5N s6SqSuuQMpGlR5+usiAOzwxqpNtEmsOjW+THB/Dg8LKUQ8EEPpaYP42SWmxlLyA= X-Google-Smtp-Source: AGHT+IHsa3cuseb+TMLjf68nJZfaXpa4Y/U/qsSRZ8J4Yx8YStwpVyo0ZpW4Nb8/l9tXLVtsADvnlA== X-Received: by 2002:a05:6512:159d:b0:536:53a9:96d5 with SMTP id 2adb3069b0e04-539ab866484mr5107703e87.17.1728304797453; Mon, 07 Oct 2024 05:39:57 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a995350d522sm145624166b.32.2024.10.07.05.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:57 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 10/14] arm64: dts: rp1: Add support for RaspberryPi's RP1 device Date: Mon, 7 Oct 2024 14:39:53 +0200 Message-ID: <3f6f38c06b065f5f6034ad4ed3a24902ee59f378.1728300190.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RaspberryPi RP1 is a multi function PCI endpoint device that exposes several subperipherals via PCI BAR. Add a dtb overlay that will be compiled into a binary blob and linked in the RP1 driver. This overlay offers just minimal support to represent the RP1 device itself, the sub-peripherals will be added by future patches. Signed-off-by: Andrea della Porta --- NOTE: this patch should be taken by the same maintainer that will take "[PATCH v2 11/14] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling. MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 62 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 arch/arm64/boot/dts/broadcom/rp1.dtso diff --git a/MAINTAINERS b/MAINTAINERS index 06277969a522..510a071ede78 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19383,6 +19383,7 @@ F: include/uapi/linux/media/raspberrypi/ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta S: Maintained +F: arch/arm64/boot/dts/broadcom/rp1.dtso F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml diff --git a/arch/arm64/boot/dts/broadcom/rp1.dtso b/arch/arm64/boot/dts/br= oadcom/rp1.dtso new file mode 100644 index 000000000000..846a0c99a098 --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/rp1.dtso @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +#include +#include +#include + +/dts-v1/; +/plugin/; + +/ { + fragment@0 { + target-path=3D""; + __overlay__ { + compatible =3D "pci1de4,1"; + #address-cells =3D <3>; + #size-cells =3D <2>; + + pci_ep_bus: pci-ep-bus@1 { + compatible =3D "simple-bus"; + ranges =3D <0xc0 0x40000000 + 0x01 0x00 0x00000000 + 0x00 0x00400000>; + dma-ranges =3D <0x10 0x00000000 + 0x43000000 0x10 0x00000000 + 0x10 0x00000000>; + #address-cells =3D <2>; + #size-cells =3D <2>; + interrupt-controller; + interrupt-parent =3D <&pci_ep_bus>; + #interrupt-cells =3D <2>; + + rp1_clocks: clocks@c040018000 { + compatible =3D "raspberrypi,rp1-clocks"; + reg =3D <0xc0 0x40018000 0x0 0x10038>; + #clock-cells =3D <1>; + clocks =3D <&clk_rp1_xosc>; + clock-names =3D "rp1-xosc"; + assigned-clocks =3D <&rp1_clocks RP1_PLL_SYS_CORE>, + <&rp1_clocks RP1_PLL_SYS>, + <&rp1_clocks RP1_CLK_SYS>; + assigned-clock-rates =3D <1000000000>, // RP1_PLL_SYS_CORE + <200000000>, // RP1_PLL_SYS + <200000000>; // RP1_CLK_SYS + }; + + rp1_gpio: pinctrl@c0400d0000 { + compatible =3D "raspberrypi,rp1-gpio"; + reg =3D <0xc0 0x400d0000 0x0 0xc000>, + <0xc0 0x400e0000 0x0 0xc000>, + <0xc0 0x400f0000 0x0 0xc000>; + gpio-controller; + #gpio-cells =3D <2>; + interrupt-controller; + #interrupt-cells =3D <2>; + interrupts =3D <0 IRQ_TYPE_LEVEL_HIGH>, + <1 IRQ_TYPE_LEVEL_HIGH>, + <2 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + }; + }; +}; --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 340DC1D5CC4 for ; Mon, 7 Oct 2024 12:40:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304805; cv=none; b=orYGwvuNIs8SafUAZpHWJpvZqqFTpESItL7uCK3R2Sq/hbp2OYHeprNZVuiPWVN3FOrOm4HL5jsWSUxSeCWxHDRJsB/A3XCwN7bFU8BqhBx08yCxfk60k18C2Q21YIUJgT3cKVBzSRzCRUPrCm0LJyXxcvF3YKV52zBp76TL1k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304805; c=relaxed/simple; bh=5dKe1JeaiCvhxkni9zGFDyGoGw2brksugTzocspONvw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ayKkzxVI82wv7q3Yjvw+1YSHM9mWejLxlrqUXrMd5RlRG0j31R3y8LveIfdcjTLW+Vr6eAa3Qh6FPmmeRkIh6ZB6MZP4tEfxYSPYTwRaNh3O8uVGPGDv0ZchYp1Ulm3mNXFdzhlXQCTu2exVOngg+dwQzE5f4hzf8k470tpUTII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=RJDwBTQL; arc=none smtp.client-ip=209.85.218.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="RJDwBTQL" Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-a994c322aefso212821466b.1 for ; Mon, 07 Oct 2024 05:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304799; x=1728909599; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/WE8EgqCUcz2nd/trQoIV+RWWKUmguo+K051NrWMZvA=; b=RJDwBTQLxdA0H61c9DciyXBWx2pUOfuU9Q7GJAJSs2CitfLVZIqAv+Du1ibjVzHmwY 8T4ktcKKkAwr9pnIwa7X97nCthpCb8P1NF7GHyzGtNJ/lldw8uqakJsQgGu/4dggGgzQ wgZN4iWxEseXcLFflenc+kp1aYYNmzU9/qozx67JGitqsQXQ3G8SJiBmklgfU9iVyW/+ jYugohPYPZNXpXOvDPheiR0HtXnTIp3JroAXfyeMzpeknFqy+ieNPK2aWbnxK2Dgt4pl FGNldkoborsT2nPcq78SN1py8VxZFzLDWv0pXzWOSS9nSylUtIhQrSiXHQhKCXiURgN1 j4jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304799; x=1728909599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/WE8EgqCUcz2nd/trQoIV+RWWKUmguo+K051NrWMZvA=; b=LvD3cvpI/8pLpBPc0sH99lXcp2tWqJRddw53qzWTUJVE/cEUk0ax/Ml1Rv/ZNxAfwm 2BQVTIiXDtXyuwn/vbMWA2zwD5wlQd2/wyrk0jMd7Xyx+9+neEPNlnSBRcmf58v5AKhy hcJqdl4qGRfQztkYnULvbZD/7oUnLd9CtbC4R0IJlt2yD79rCxBYjWnTwk+4wIqYzcvQ NvZ1gTqBrDY+MTM4rlrKYp375FeYNGgFukwU0Dbtv6BCegU3NM0qqkbbGY5jJ/uMRqF/ Dhisp5Z7Jpnw5XoBbj6DOawaGWXsQsZY6r6RKM6Bk16svFi8+DmTIibGclOa7ddW/d2I 71JQ== X-Forwarded-Encrypted: i=1; AJvYcCVAT+WXFwrEkpzuIMmruJPqHVdWoc5KZxTWLDPuMvvM/YnBOBfSiIXR3kirHHZL9R0kz53YW64Lpivzyu8=@vger.kernel.org X-Gm-Message-State: AOJu0YzIhX6wT8MqT/aeVBSKVzZIdUbvBm2Kj7rlE+PxWZCr4l3N3GiN QHFCtjjcAWptUQfU9OhCbXw0oQr+JZqWd3ZgQOyuJMrpGkL+7z7XSMl3gUT8muM= X-Google-Smtp-Source: AGHT+IGrvep1BYn/i5lEdgf79ESSRZcIrRig0Qglonn/ZyU2zg4t1zMTcFFrRbSOkZ9r4nHssIiP2w== X-Received: by 2002:a17:907:6d28:b0:a99:6265:ed35 with SMTP id a640c23a62f3a-a996265f231mr58540566b.10.1728304798537; Mon, 07 Oct 2024 05:39:58 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99409f1db6sm294344366b.97.2024.10.07.05.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:58 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 11/14] misc: rp1: RaspberryPi RP1 misc driver Date: Mon, 7 Oct 2024 14:39:54 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RaspberryPi RP1 is a PCI multi function device containing peripherals ranging from Ethernet to USB controller, I2C, SPI and others. Implement a bare minimum driver to operate the RP1, leveraging actual OF based driver implementations for the on-board peripherals by loading a devicetree overlay during driver probe. The peripherals are accessed by mapping MMIO registers starting from PCI BAR1 region. With the overlay approach we can achieve more generic and agnostic approach to managing this chipset, being that it is a PCI endpoint and could possibly be reused in other hw implementations. The presented approach is also used by Bootlin's Microchip LAN966x patchset (see link) as well, for a similar chipset. Since the gpio line names should be provided by the user, there is an interface through configfs that allows the userspace to load a DT overlay that will provide gpio-line-names property. The interface can be invoked like this: cat rpi-rp1-gpios-5-b.dtbo > /sys/kernel/config/rp1-cfg/gpio_set_names and is designed to be similar to what users are already used to from distro with downstream kernel. For reasons why this driver is contained in drivers/misc, please check the links. This driver is heavily based on downstream code from RaspberryPi Foundation, and the original author is Phil Elwell. Link: https://datasheets.raspberrypi.com/rp1/rp1-peripherals.pdf Link: https://lore.kernel.org/all/20240612140208.GC1504919@google.com/ Link: https://lore.kernel.org/all/83f7fa09-d0e6-4f36-a27d-cee08979be2a@app.= fastmail.com/ Link: https://lore.kernel.org/all/2024081356-mutable-everyday-6f9d@gregkh/ Link: https://lore.kernel.org/all/20240808154658.247873-1-herve.codina@boot= lin.com/ Signed-off-by: Andrea della Porta --- MAINTAINERS | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/rp1/Kconfig | 24 +++ drivers/misc/rp1/Makefile | 5 + drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/misc/rp1/rp1_pci.c | 365 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 423 insertions(+) create mode 100644 drivers/misc/rp1/Kconfig create mode 100644 drivers/misc/rp1/Makefile create mode 100644 drivers/misc/rp1/rp1-pci.dtso create mode 100644 drivers/misc/rp1/rp1_pci.c create mode 100644 drivers/misc/rp1/rp1_pci.h diff --git a/MAINTAINERS b/MAINTAINERS index 510a071ede78..032678fb2470 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19389,6 +19389,7 @@ F: Documentation/devicetree/bindings/misc/pci1de4,1= .yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml F: Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml F: drivers/clk/clk-rp1.c +F: drivers/misc/rp1/ F: drivers/pinctrl/pinctrl-rp1.c F: include/dt-bindings/clock/rp1.h F: include/dt-bindings/misc/rp1.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 3fe7e2a9bd29..ac85cb154100 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -628,4 +628,5 @@ source "drivers/misc/uacce/Kconfig" source "drivers/misc/pvpanic/Kconfig" source "drivers/misc/mchp_pci1xxxx/Kconfig" source "drivers/misc/keba/Kconfig" +source "drivers/misc/rp1/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index a9f94525e181..ae86d69997b4 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -72,3 +72,4 @@ obj-$(CONFIG_TPS6594_PFSM) +=3D tps6594-pfsm.o obj-$(CONFIG_NSM) +=3D nsm.o obj-$(CONFIG_MARVELL_CN10K_DPI) +=3D mrvl_cn10k_dpi.o obj-y +=3D keba/ +obj-$(CONFIG_MISC_RP1) +=3D rp1/ diff --git a/drivers/misc/rp1/Kconfig b/drivers/misc/rp1/Kconfig new file mode 100644 index 000000000000..29b1fc2fc4af --- /dev/null +++ b/drivers/misc/rp1/Kconfig @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# RaspberryPi RP1 misc device +# + +config MISC_RP1 + tristate "RaspberryPi RP1 PCIe support" + depends on PCI && PCI_QUIRKS + select OF + select OF_IRQ + select OF_OVERLAY + select IRQ_DOMAIN + select PCI_DYNAMIC_OF_NODES + help + Support the RP1 peripheral chip found on Raspberry Pi 5 board. + + This device supports several sub-devices including e.g. Ethernet + controller, USB controller, I2C, SPI and UART. + + The driver is responsible for enabling the DT node once the PCIe + endpoint has been configured, and handling interrupts. + + This driver uses an overlay to load other drivers to support for + RP1 internal sub-devices. diff --git a/drivers/misc/rp1/Makefile b/drivers/misc/rp1/Makefile new file mode 100644 index 000000000000..70384f5a7d7d --- /dev/null +++ b/drivers/misc/rp1/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_MISC_RP1) +=3D rp1-pci.o +rp1-pci-objs :=3D rp1_pci.o rp1-pci.dtbo.o + +DTC_FLAGS_rp1-pci +=3D -@ diff --git a/drivers/misc/rp1/rp1-pci.dtso b/drivers/misc/rp1/rp1-pci.dtso new file mode 100644 index 000000000000..0bf2f4bb18e6 --- /dev/null +++ b/drivers/misc/rp1/rp1-pci.dtso @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/* the dts overlay is included from the dts directory so + * it can be possible to check it with CHECK_DTBS while + * also compile it from the driver source directory. + */ + +#include "arm64/broadcom/rp1.dtso" diff --git a/drivers/misc/rp1/rp1_pci.c b/drivers/misc/rp1/rp1_pci.c new file mode 100644 index 000000000000..a1f7bf1804c0 --- /dev/null +++ b/drivers/misc/rp1/rp1_pci.c @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018-24 Raspberry Pi Ltd. + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rp1_pci.h" + +#define RP1_DRIVER_NAME "rp1" + +#define RP1_HW_IRQ_MASK GENMASK(5, 0) + +#define REG_SET 0x800 +#define REG_CLR 0xc00 + +/* MSI-X CFG registers start at 0x8 */ +#define MSIX_CFG(x) (0x8 + (4 * (x))) + +#define MSIX_CFG_IACK_EN BIT(3) +#define MSIX_CFG_IACK BIT(2) +#define MSIX_CFG_ENABLE BIT(0) + +/* Address map */ +#define RP1_PCIE_APBS_BASE 0x108000 + +/* Interrupts */ +#define RP1_INT_IO_BANK0 0 +#define RP1_INT_IO_BANK1 1 +#define RP1_INT_IO_BANK2 2 +#define RP1_INT_AUDIO_IN 3 +#define RP1_INT_AUDIO_OUT 4 +#define RP1_INT_PWM0 5 +#define RP1_INT_ETH 6 +#define RP1_INT_I2C0 7 +#define RP1_INT_I2C1 8 +#define RP1_INT_I2C2 9 +#define RP1_INT_I2C3 10 +#define RP1_INT_I2C4 11 +#define RP1_INT_I2C5 12 +#define RP1_INT_I2C6 13 +#define RP1_INT_I2S0 14 +#define RP1_INT_I2S1 15 +#define RP1_INT_I2S2 16 +#define RP1_INT_SDIO0 17 +#define RP1_INT_SDIO1 18 +#define RP1_INT_SPI0 19 +#define RP1_INT_SPI1 20 +#define RP1_INT_SPI2 21 +#define RP1_INT_SPI3 22 +#define RP1_INT_SPI4 23 +#define RP1_INT_SPI5 24 +#define RP1_INT_UART0 25 +#define RP1_INT_TIMER_0 26 +#define RP1_INT_TIMER_1 27 +#define RP1_INT_TIMER_2 28 +#define RP1_INT_TIMER_3 29 +#define RP1_INT_USBHOST0 30 +#define RP1_INT_USBHOST0_0 31 +#define RP1_INT_USBHOST0_1 32 +#define RP1_INT_USBHOST0_2 33 +#define RP1_INT_USBHOST0_3 34 +#define RP1_INT_USBHOST1 35 +#define RP1_INT_USBHOST1_0 36 +#define RP1_INT_USBHOST1_1 37 +#define RP1_INT_USBHOST1_2 38 +#define RP1_INT_USBHOST1_3 39 +#define RP1_INT_DMA 40 +#define RP1_INT_PWM1 41 +#define RP1_INT_UART1 42 +#define RP1_INT_UART2 43 +#define RP1_INT_UART3 44 +#define RP1_INT_UART4 45 +#define RP1_INT_UART5 46 +#define RP1_INT_MIPI0 47 +#define RP1_INT_MIPI1 48 +#define RP1_INT_VIDEO_OUT 49 +#define RP1_INT_PIO_0 50 +#define RP1_INT_PIO_1 51 +#define RP1_INT_ADC_FIFO 52 +#define RP1_INT_PCIE_OUT 53 +#define RP1_INT_SPI6 54 +#define RP1_INT_SPI7 55 +#define RP1_INT_SPI8 56 +#define RP1_INT_SYSCFG 58 +#define RP1_INT_CLOCKS_DEFAULT 59 +#define RP1_INT_VBUSCTRL 60 +#define RP1_INT_PROC_MISC 57 +#define RP1_INT_END 61 + +struct rp1_dev { + struct pci_dev *pdev; + struct device *dev; + struct clk *sys_clk; + struct irq_domain *domain; + struct irq_data *pcie_irqds[64]; + void __iomem *bar1; + int ovcs_id; + bool level_triggered_irq[RP1_INT_END]; +}; + +static void dump_bar(struct pci_dev *pdev, unsigned int bar) +{ + dev_info(&pdev->dev, + "bar%d %pR\n", + bar, + pci_resource_n(pdev, bar)); +} + +static void msix_cfg_set(struct rp1_dev *rp1, unsigned int hwirq, u32 valu= e) +{ + iowrite32(value, rp1->bar1 + RP1_PCIE_APBS_BASE + REG_SET + MSIX_CFG(hwir= q)); +} + +static void msix_cfg_clr(struct rp1_dev *rp1, unsigned int hwirq, u32 valu= e) +{ + iowrite32(value, rp1->bar1 + RP1_PCIE_APBS_BASE + REG_CLR + MSIX_CFG(hwir= q)); +} + +static void rp1_mask_irq(struct irq_data *irqd) +{ + struct rp1_dev *rp1 =3D irqd->domain->host_data; + struct irq_data *pcie_irqd =3D rp1->pcie_irqds[irqd->hwirq]; + + pci_msi_mask_irq(pcie_irqd); +} + +static void rp1_unmask_irq(struct irq_data *irqd) +{ + struct rp1_dev *rp1 =3D irqd->domain->host_data; + struct irq_data *pcie_irqd =3D rp1->pcie_irqds[irqd->hwirq]; + + pci_msi_unmask_irq(pcie_irqd); +} + +static int rp1_irq_set_type(struct irq_data *irqd, unsigned int type) +{ + struct rp1_dev *rp1 =3D irqd->domain->host_data; + unsigned int hwirq =3D (unsigned int)irqd->hwirq; + + switch (type) { + case IRQ_TYPE_LEVEL_HIGH: + dev_dbg(rp1->dev, "MSIX IACK EN for irq %d\n", hwirq); + msix_cfg_set(rp1, hwirq, MSIX_CFG_IACK_EN); + rp1->level_triggered_irq[hwirq] =3D true; + break; + case IRQ_TYPE_EDGE_RISING: + msix_cfg_clr(rp1, hwirq, MSIX_CFG_IACK_EN); + rp1->level_triggered_irq[hwirq] =3D false; + break; + default: + return -EINVAL; + } + + return 0; +} + +static struct irq_chip rp1_irq_chip =3D { + .name =3D "rp1_irq_chip", + .irq_mask =3D rp1_mask_irq, + .irq_unmask =3D rp1_unmask_irq, + .irq_set_type =3D rp1_irq_set_type, +}; + +static void rp1_chained_handle_irq(struct irq_desc *desc) +{ + unsigned int hwirq =3D desc->irq_data.hwirq & RP1_HW_IRQ_MASK; + struct rp1_dev *rp1 =3D irq_desc_get_handler_data(desc); + struct irq_chip *chip =3D irq_desc_get_chip(desc); + int virq; + + chained_irq_enter(chip, desc); + + virq =3D irq_find_mapping(rp1->domain, hwirq); + generic_handle_irq(virq); + if (rp1->level_triggered_irq[hwirq]) + msix_cfg_set(rp1, hwirq, MSIX_CFG_IACK); + + chained_irq_exit(chip, desc); +} + +static int rp1_irq_xlate(struct irq_domain *d, struct device_node *node, + const u32 *intspec, unsigned int intsize, + unsigned long *out_hwirq, unsigned int *out_type) +{ + struct rp1_dev *rp1 =3D d->host_data; + struct irq_data *pcie_irqd; + unsigned long hwirq; + int pcie_irq; + int ret; + + ret =3D irq_domain_xlate_twocell(d, node, intspec, intsize, + &hwirq, out_type); + if (ret) + return ret; + + pcie_irq =3D pci_irq_vector(rp1->pdev, hwirq); + pcie_irqd =3D irq_get_irq_data(pcie_irq); + rp1->pcie_irqds[hwirq] =3D pcie_irqd; + *out_hwirq =3D hwirq; + + return 0; +} + +static int rp1_irq_activate(struct irq_domain *d, struct irq_data *irqd, + bool reserve) +{ + struct rp1_dev *rp1 =3D d->host_data; + + msix_cfg_set(rp1, (unsigned int)irqd->hwirq, MSIX_CFG_ENABLE); + + return 0; +} + +static void rp1_irq_deactivate(struct irq_domain *d, struct irq_data *irqd) +{ + struct rp1_dev *rp1 =3D d->host_data; + + msix_cfg_clr(rp1, (unsigned int)irqd->hwirq, MSIX_CFG_ENABLE); +} + +static const struct irq_domain_ops rp1_domain_ops =3D { + .xlate =3D rp1_irq_xlate, + .activate =3D rp1_irq_activate, + .deactivate =3D rp1_irq_deactivate, +}; + +static int rp1_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + struct device *dev =3D &pdev->dev; + struct device_node *rp1_node; + struct reset_control *reset; + struct rp1_dev *rp1; + int err =3D 0; + int i; + + rp1_node =3D dev_of_node(dev); + if (!rp1_node) { + dev_err(dev, "Missing of_node for device\n"); + return -EINVAL; + } + + rp1 =3D devm_kzalloc(&pdev->dev, sizeof(*rp1), GFP_KERNEL); + if (!rp1) + return -ENOMEM; + + rp1->pdev =3D pdev; + rp1->dev =3D &pdev->dev; + + reset =3D devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + if (IS_ERR(reset)) + return PTR_ERR(reset); + reset_control_reset(reset); + + dump_bar(pdev, 0); + dump_bar(pdev, 1); + + if (pci_resource_len(pdev, 1) <=3D 0x10000) { + dev_err(&pdev->dev, + "Not initialised - is the firmware running?\n"); + return -EINVAL; + } + + err =3D pcim_enable_device(pdev); + if (err < 0) { + dev_err(&pdev->dev, "Enabling PCI device has failed: %d", + err); + return err; + } + + rp1->bar1 =3D pcim_iomap(pdev, 1, 0); + if (!rp1->bar1) { + dev_err(&pdev->dev, "Cannot map PCI BAR\n"); + return -EIO; + } + + u32 dtbo_size =3D __dtbo_rp1_pci_end - __dtbo_rp1_pci_begin; + void *dtbo_start =3D __dtbo_rp1_pci_begin; + + err =3D of_overlay_fdt_apply(dtbo_start, dtbo_size, &rp1->ovcs_id, rp1_no= de); + if (err) + return err; + + pci_set_master(pdev); + + err =3D pci_alloc_irq_vectors(pdev, RP1_INT_END, RP1_INT_END, + PCI_IRQ_MSIX); + if (err !=3D RP1_INT_END) { + dev_err(&pdev->dev, "pci_alloc_irq_vectors failed - %d\n", err); + goto err_unload_overlay; + } + + pci_set_drvdata(pdev, rp1); + rp1->domain =3D irq_domain_add_linear(of_find_node_by_name(NULL, "pci-ep-= bus"), RP1_INT_END, + &rp1_domain_ops, rp1); + + for (i =3D 0; i < RP1_INT_END; i++) { + int irq =3D irq_create_mapping(rp1->domain, i); + + if (irq < 0) { + dev_err(&pdev->dev, "failed to create irq mapping\n"); + err =3D irq; + goto err_unload_overlay; + } + irq_set_chip_and_handler(irq, &rp1_irq_chip, handle_level_irq); + irq_set_probe(irq); + irq_set_chained_handler_and_data(pci_irq_vector(pdev, i), + rp1_chained_handle_irq, rp1); + } + + err =3D of_platform_default_populate(rp1_node, NULL, dev); + if (err) + goto err_unload_overlay; + + return 0; + +err_unload_overlay: + of_overlay_remove(&rp1->ovcs_id); + + return err; +} + +static void rp1_remove(struct pci_dev *pdev) +{ + struct rp1_dev *rp1 =3D pci_get_drvdata(pdev); + struct device *dev =3D &pdev->dev; + + of_platform_depopulate(dev); + of_overlay_remove(&rp1->ovcs_id); + + clk_unregister(rp1->sys_clk); +} + +static const struct pci_device_id dev_id_table[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_RPI, PCI_DEVICE_ID_RPI_RP1_C0), }, + { 0, } +}; + +static struct pci_driver rp1_driver =3D { + .name =3D RP1_DRIVER_NAME, + .id_table =3D dev_id_table, + .probe =3D rp1_probe, + .remove =3D rp1_remove, +}; + +module_pci_driver(rp1_driver); + +MODULE_AUTHOR("Phil Elwell "); +MODULE_AUTHOR("Andrea della Porta "); +MODULE_DESCRIPTION("RP1 wrapper"); +MODULE_LICENSE("GPL"); diff --git a/drivers/misc/rp1/rp1_pci.h b/drivers/misc/rp1/rp1_pci.h new file mode 100644 index 000000000000..7982f13bad9b --- /dev/null +++ b/drivers/misc/rp1/rp1_pci.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Copyright (c) 2018-24 Raspberry Pi Ltd. + * All rights reserved. + */ + +#ifndef _RP1_EXTERN_H_ +#define _RP1_EXTERN_H_ + +extern char __dtbo_rp1_pci_begin[]; +extern char __dtbo_rp1_pci_end[]; + +#endif diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dccb60c1d9cc..41e77d94ff73 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -6266,6 +6266,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0xa76e,= dpc_log_size); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5020, of_pci_make_dev_node= ); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_XILINX, 0x5021, of_pci_make_dev_node= ); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REDHAT, 0x0005, of_pci_make_dev_node= ); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_RPI, PCI_DEVICE_ID_RPI_RP1_C0, of_pc= i_make_dev_node); =20 /* * Devices known to require a longer delay before first config space access diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4cf6aaed5f35..c7e6cd10ac52 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -2611,6 +2611,9 @@ #define PCI_VENDOR_ID_TEKRAM 0x1de1 #define PCI_DEVICE_ID_TEKRAM_DC290 0xdc29 =20 +#define PCI_VENDOR_ID_RPI 0x1de4 +#define PCI_DEVICE_ID_RPI_RP1_C0 0x0001 + #define PCI_VENDOR_ID_ALIBABA 0x1ded =20 #define PCI_VENDOR_ID_CXL 0x1e98 --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FDAF1D5CF1 for ; Mon, 7 Oct 2024 12:40:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304805; cv=none; b=bcHQe5kL5gvmyFBsodLyYrXuJrkd7s+KmYdy7tueCQSq5HXBG6SUDx7KgV3HyPXuW8V4aR+oplYm5aJxwci91LGjelax5xR6+99BlCLoqw9OIvo5lcVe5LTgaWfxxpBFSQmQ0cVwTTpyCz8PRSoVJE0doYKPmnh0nMGwWg2mRYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304805; c=relaxed/simple; bh=rKJ6g2zPe+AmVP+2VuYqwsDW7Vw/1jwj4Zek+anRIcU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EmVo1PfufDk0KNBKUxTgBAAZ+MTCsmmzUHhBPP/BgnqazwzZeHgw2vXxhce+4LHcrTXtgE3TN8yEWG57Tb/fwnxI8kDQmVxQLtSbk4Q2Dd4x76vXbTUWCr3adtDY8r0bbPZduqBv+Y1ibr3vakEref7OKd+aXqxBLgCZGba1aIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Y+a5w9LC; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Y+a5w9LC" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2fad6de2590so62796721fa.0 for ; Mon, 07 Oct 2024 05:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304800; x=1728909600; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ExSdnw6SFXuTqFss0pRdd0b0/LidGX7ZLflADrh46f0=; b=Y+a5w9LCEkrPe/97xbWkIUVEbCJsXgQq1AclnQtmslKDC3U6uIPf+5mlE4yDFV+vNT tkmxVQLX4PyRWDO2CdVQgHbYoJ41yLwqsPq1OBtgbE4FhjS1E/0n1Zc5ZW97XEd1B2sy nFvCgIkMBdj7EhPL/a3aK7CgGef+x2sihCM4pWGQNpJa4x1fGXipZ+IX7rmjjq/HAILd SB0Q5+TgIfWoPkLuy5xdLM0jEIAe4n9sQy9utcc0UosmZ9381X2O3HT77CfkxJmwSOxD sI5yPgeAWwimWvXCo54Rd87D2w+8eaIgXUFmnBpzM6ndnXbQpCxAlwsqQ4g89VmFrj0i Setg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304800; x=1728909600; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ExSdnw6SFXuTqFss0pRdd0b0/LidGX7ZLflADrh46f0=; b=LHJ3ALFhogj8RiVe9SKdAZYV+fZ4EwJtiWZdmfnFheE6Bo+cXb6Gh5nunwsulSP2ZE 2FgnSNamIUnuLpS2bdkRndVWH9R4u5r0QwP+TBp+8UvjyqYdnaEZf/9R2nMs98rJevKW tQSUB63ZaWD35r5uY8vfroH6jqM8HU6jEUOFS094R/GuG01hieMJ3b/bxAuXgNUSEh6E yHccYyfVvkDLMJEPplfwMOu2mMCvAlxBkE4/GyF2KTTc216SdSMjk8j69kzA4iFk/Y9m QB0fecfacBOEnwglxf79vye/mrTwgHM7JZ2GfNpOzONQOC51JudgkBi3YO0/cCYmzgaS wKow== X-Forwarded-Encrypted: i=1; AJvYcCUHCQ4IA/Ad5lJLGlFq0gaQWVPKYoLA6A8+7/t7XMQNr4nNlJERmZq8c1TYuE1AFCCpEAzGuzAqKAKMBcw=@vger.kernel.org X-Gm-Message-State: AOJu0YwmApEmWVRuCUL0w1uUw6y4HJOLF0ostnzp4YR0OzbmMRaN5Nyv uamREpc5aMIU10/CSxjgoSxgKOvuwIQ+lMI3YCNYMdbDImckZyTmZSF+9YTVpAc= X-Google-Smtp-Source: AGHT+IEF9XJ972EaXIB1RBwBhfHiOI0VXfiBlhriuohHhb22fhgxmRK3EvHrGiaJhb632gUnFrOgqw== X-Received: by 2002:a2e:a595:0:b0:2fa:cfba:fb7f with SMTP id 38308e7fff4ca-2faf3d797c0mr68500231fa.40.1728304799933; Mon, 07 Oct 2024 05:39:59 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a993a3a1badsm327549766b.161.2024.10.07.05.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:39:59 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 12/14] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5 Date: Mon, 7 Oct 2024 14:39:55 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RP1 found on Raspberry Pi 5 board needs an external crystal at 50MHz. Add clk_rp1_xosc node to provide that. Signed-off-by: Andrea della Porta --- arch/arm64/boot/dts/broadcom/bcm2712.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi b/arch/arm64/boot/dt= s/broadcom/bcm2712.dtsi index 6e5a984c1d4e..efdf9abf04c4 100644 --- a/arch/arm64/boot/dts/broadcom/bcm2712.dtsi +++ b/arch/arm64/boot/dts/broadcom/bcm2712.dtsi @@ -38,6 +38,13 @@ clk_emmc2: clk-emmc2 { clock-frequency =3D <200000000>; clock-output-names =3D "emmc2-clock"; }; + + clk_rp1_xosc: clock-rp1-xosc { + compatible =3D "fixed-clock"; + #clock-cells =3D <0>; + clock-output-names =3D "rp1-xosc"; + clock-frequency =3D <50000000>; + }; }; =20 cpus: cpus { --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABF461D6199 for ; Mon, 7 Oct 2024 12:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304806; cv=none; b=sE5NfJBn2S7yuOzYuknipTUaVSHaKmM64vQBjZs5waWF5ZgFR076l0TQFWGTBNDcYYbOVDfgLhx7ekXuAV/sSsVIYTsTP32TWuJH8xyalbXvOMmHWmi54IebeNv2aeSeGAPOPLZNhJi8AAWozNYPp9gcSMGkEiUwX6H/8kxdaRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304806; c=relaxed/simple; bh=ZEPzPLsXrcChWumoZ7SBiHMsSOTvRa3Wuhep1haX83c=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P7lU3ZI01kDSUomSpUpmQV9JFaPckmRLlaP9QaLrV8bpheYD6h1gNWffyJHugbNkWEeKC1NAB/CdZnJ3DpI2SzlIbLn0zsHUFIc5yuHQXNhXeEcYpB3yNwEm4Ni0xz3SfItcECtBhvfSZKN7SNfqc2zYjlAl4UHv3mqeGfCCZIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=eXWgJ8Wu; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="eXWgJ8Wu" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a9953bdc341so121723266b.2 for ; Mon, 07 Oct 2024 05:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304801; x=1728909601; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=c7GLnpdk3kpJmE9r4o2PWhEgiezo/nwd6A/PFeKxkMs=; b=eXWgJ8Wu4/VpFTXBJ1CM9XxLbRpV1g7E3GjjpLf1vNQX6h1z+scbMxa4e3SaI2Lg8I Qi6xRh+LkS7KFLwDkK9zmsMtiXoHOQVgksIVcyqy6CTAxorHksjD7euzhk5QKIPSJbQ3 jCSDy/RcRl4wQoQiu3X+FNyXBKIIy/aaEjZpF00z0Tka9AXCAQwTsLJru9PTNyIxta08 0/Xo/IHJvZ0Gf4UEsoaKRfLuS+EPyF9+5eix51dSJxwtGJwZHIdINNHScQF3gWqgkyWK H46AQdeyLjgyp/JSOaR3Z42aZTPadmQVMLdp6GDJxD2QoQR1QAWkCpqr9Nystpnl6bGG K0rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304801; x=1728909601; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c7GLnpdk3kpJmE9r4o2PWhEgiezo/nwd6A/PFeKxkMs=; b=JZepJuYqhnr/o5UdFOegzlWgiqvIB5EjDGzAuBYncAgVGiVynItXe5voZusuZQ6HXi ofdaJqm8WfgiXM8kXbmwGawIqXYhd0hl2cNTx+t18Xf2CLa0g7QgH38r/tk5UcKKG3FW JbMbp7VqZqqp/YKah8YCIpPGWdtAWOYQSyUBztMy537RTDMquOlRGDfq2LanaAPoDEJK dA0H+QC1QxJgrb091uU8GI6RZipJNaOiSdi7xpu5qOoXeScPqtuSx+UpReuxtfwstTWf ERC0FxlhdkqkPtO/J7/PLLtx+tRVUnnfoZElgG7lxG5hB4RLSeKY7Youex5q++Rzsx1O QqBw== X-Forwarded-Encrypted: i=1; AJvYcCXz/Mi49T7pdZhdDmVe5XTI4wCgoqS32lvsjTWqaY5RzZNPeWAtqSt+168QrNK3Q7HtRIzVnMXn5xptboE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxlf96y6qf10llMGfgCI/3sw+ubbtPvJfm97nVU57g7OLUKOGVk Kp7a0pG8XuqOJLF7TYw+zh8y1NdHgT8HNKcDZ2yV8eO3/1x8jQx+mtX9PNmxbPg= X-Google-Smtp-Source: AGHT+IFy0cMxJsF82yiNQcbJa9lSxuSDCs6OgxcKY5EqxFvjMZSr8FG4F668oRvYtnMpyYp5B4Dw5w== X-Received: by 2002:a17:907:6d17:b0:a8d:2d2e:90e6 with SMTP id a640c23a62f3a-a991c00fb55mr1305844266b.60.1728304800909; Mon, 07 Oct 2024 05:40:00 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9933db9c5bsm360605066b.162.2024.10.07.05.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:40:00 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 13/14] arm64: dts: Add DTS overlay for RP1 gpio line names Date: Mon, 7 Oct 2024 14:39:56 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This DT overlay contains the gpio-line-names property for RaspberryPi 5. It's intended to be loaded from userspace leveraging the RP1 driver interface through configfs, as follows: cat rpi-rp1-gpios-5-b.dtbo > /sys/kernel/config/rp1-cfg/gpio_set_names Signed-off-by: Andrea della Porta --- MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/Makefile | 3 +- .../boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso | 62 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso diff --git a/MAINTAINERS b/MAINTAINERS index 032678fb2470..2b61d9a84dae 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19384,6 +19384,7 @@ RASPBERRY PI RP1 PCI DRIVER M: Andrea della Porta S: Maintained F: arch/arm64/boot/dts/broadcom/rp1.dtso +F: arch/arm64/boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso F: Documentation/devicetree/bindings/clock/raspberrypi,rp1-clocks.yaml F: Documentation/devicetree/bindings/misc/pci1de4,1.yaml F: Documentation/devicetree/bindings/pci/pci-ep-bus.yaml diff --git a/arch/arm64/boot/dts/broadcom/Makefile b/arch/arm64/boot/dts/br= oadcom/Makefile index 92565e9781ad..d384937b0536 100644 --- a/arch/arm64/boot/dts/broadcom/Makefile +++ b/arch/arm64/boot/dts/broadcom/Makefile @@ -11,7 +11,8 @@ dtb-$(CONFIG_ARCH_BCM2835) +=3D bcm2711-rpi-400.dtb \ bcm2837-rpi-3-b.dtb \ bcm2837-rpi-3-b-plus.dtb \ bcm2837-rpi-cm3-io3.dtb \ - bcm2837-rpi-zero-2-w.dtb + bcm2837-rpi-zero-2-w.dtb \ + rpi-rp1-gpios-5-b.dtbo =20 subdir-y +=3D bcmbca subdir-y +=3D northstar2 diff --git a/arch/arm64/boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso b/arch/arm= 64/boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso new file mode 100644 index 000000000000..76a243a71644 --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/rpi-rp1-gpios-5-b.dtso @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +/dts-v1/; +/plugin/; + +&rp1_gpio { + gpio-line-names =3D + "ID_SDA", // GPIO0 + "ID_SCL", // GPIO1 + "GPIO2", // GPIO2 + "GPIO3", // GPIO3 + "GPIO4", // GPIO4 + "GPIO5", // GPIO5 + "GPIO6", // GPIO6 + "GPIO7", // GPIO7 + "GPIO8", // GPIO8 + "GPIO9", // GPIO9 + "GPIO10", // GPIO10 + "GPIO11", // GPIO11 + "GPIO12", // GPIO12 + "GPIO13", // GPIO13 + "GPIO14", // GPIO14 + "GPIO15", // GPIO15 + "GPIO16", // GPIO16 + "GPIO17", // GPIO17 + "GPIO18", // GPIO18 + "GPIO19", // GPIO19 + "GPIO20", // GPIO20 + "GPIO21", // GPIO21 + "GPIO22", // GPIO22 + "GPIO23", // GPIO23 + "GPIO24", // GPIO24 + "GPIO25", // GPIO25 + "GPIO26", // GPIO26 + "GPIO27", // GPIO27 + "PCIE_RP1_WAKE", // GPIO28 + "FAN_TACH", // GPIO29 + "HOST_SDA", // GPIO30 + "HOST_SCL", // GPIO31 + "ETH_RST_N", // GPIO32 + "", // GPIO33 + "CD0_IO0_MICCLK", // GPIO34 + "CD0_IO0_MICDAT0", // GPIO35 + "RP1_PCIE_CLKREQ_N", // GPIO36 + "", // GPIO37 + "CD0_SDA", // GPIO38 + "CD0_SCL", // GPIO39 + "CD1_SDA", // GPIO40 + "CD1_SCL", // GPIO41 + "USB_VBUS_EN", // GPIO42 + "USB_OC_N", // GPIO43 + "RP1_STAT_LED", // GPIO44 + "FAN_PWM", // GPIO45 + "CD1_IO0_MICCLK", // GPIO46 + "2712_WAKE", // GPIO47 + "CD1_IO1_MICDAT1", // GPIO48 + "EN_MAX_USB_CUR", // GPIO49 + "", // GPIO50 + "", // GPIO51 + "", // GPIO52 + ""; // GPIO53 +}; --=20 2.35.3 From nobody Wed Nov 27 22:33:16 2024 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D0011D61A2 for ; Mon, 7 Oct 2024 12:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304807; cv=none; b=ezZPhOas/AT8hLvn8mA8PH8PljrPOVg8+Z7JZbXB4d8sUgjs4OpEBbGPXrF4skFjsO6ojYOzUH8SlstfmfyVCzE6xaJS7vBW/VmzXAP7Uitc9CYpZPgzuINtEyzhE+GX0hpus4jM7yUVXp7Pc1Ypt3F4yd4+r32Zpfx52fSzh0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728304807; c=relaxed/simple; bh=mkLhLwSMHZ/hO35qXKlv3paIFazWoum0UehyHiC/QB0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XFf5Ztro6vGWsozTEpR736Mqj5ovC5rHkVIRlFHQVuYPkqePxO9nN0xBTU3CZNW5cdNZmW0objHYgkJTtvn4KqNqy7QG+JK1WyoJ9x+rvA14ZafqWFg5HVXUkXTtSMm+fUGdSWpPxLDlaGk/EP1nJdtSRkfzQjmY8DXy5Wk2+Ks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=CAIDhfiE; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="CAIDhfiE" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2fad100dd9fso58711491fa.3 for ; Mon, 07 Oct 2024 05:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728304802; x=1728909602; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=XxqlkITvdCM/QWIQix/9plieOyS0wK2Vm/r1GXcM7hA=; b=CAIDhfiESYPEcNE8YFhNUYXgmKxi424zPamebyO+pTgCeXatPoVk43dc/Gd5QS5TCF dWHxozIT6V5wSqiNQlibR9fbPy/c5BLJxdPSzayiPf1cKicZz3amHh1d7cPc2tiY90iW WfeA1n22uctbNobcD1eknSfG+TQy1wh55g87R+PhATbfT9unM7tggRJwFBGFk2OYtrnj TMw+0dMsynOB1jXg8PUP8gqg5jwVjRRvFdM1Z44sV+Bc4lvPxDNVJSe6oy2/ArJCR7Kh Y8acBAsNX82Q90sIFAQQDh+OKp8r6LT9PfsLOn6AAEEUbjE5coHSaFhHIG9KO3Vha5fz gjFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728304802; x=1728909602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxqlkITvdCM/QWIQix/9plieOyS0wK2Vm/r1GXcM7hA=; b=UAF+trorI//Flcm6KNuc+6vBVuYFzCJFwgVO5rgbSoTtrQc9ekUREgiG2cp6ux+crS gF6dzglt4MoZ/U1dPmLva6aNFta1VYNf4utEvhOvpZIzujtrsqYadeF9QE8hKTP6+fnB YvxOBsynFZIPvtSSH33mAVWYyKjRqlacw5n1KUOoao+1fMK7isGN/wUKbd6wLdzrW5I5 YdXO2Df4qQv4jyYgnquPnRCDI720VqXBb6ZIm1TtukwVParvgPlGgMt7ZYm6aOAk/9c5 Sl8XGcu5q/FURYh0GO5yAsqvrihi4TK0R35Pv3YoXmC+t0VDdrVCaF4QssrgYRtNlj6b XcEQ== X-Forwarded-Encrypted: i=1; AJvYcCXuKdhyupAynVO+h3ZaCJ/5gpWF030xQCrEXe5OidZesh1hO4W/EenL+pNhbDAkaXvVP/coWP4wxxSIeOQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyWwTaTmC4dpVQulEYscRmqXe9oLtnYSOEGz624PuQ74AqxdybV Y9o1vuFR/BnKZ8X6AF45ms3liYmDSjJ0hA0hfwZTdpgKP+t99OoqpVM5yhynVhk= X-Google-Smtp-Source: AGHT+IHR1ktp254iz8KIigduOBzppWGhiMiVs/yxKW6oEsL/Vly2uGjKRU1R2KrvUoC9JvDdD8m3iA== X-Received: by 2002:a2e:a9a1:0:b0:2f6:6198:1cfa with SMTP id 38308e7fff4ca-2faf3d79a3bmr70522671fa.41.1728304802350; Mon, 07 Oct 2024 05:40:02 -0700 (PDT) Received: from localhost (host-87-21-212-62.retail.telecomitalia.it. [87.21.212.62]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a992e7e2252sm371446466b.206.2024.10.07.05.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2024 05:40:01 -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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Bjorn Helgaas , Linus Walleij , Catalin Marinas , Will Deacon , Bartosz Golaszewski , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Saravana Kannan , 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-pci@vger.kernel.org, linux-gpio@vger.kernel.org, Masahiro Yamada , Stefan Wahren , Herve Codina , Luca Ceresoli , Thomas Petazzoni , Andrew Lunn Subject: [PATCH v2 14/14] arm64: defconfig: Enable RP1 misc/clock/gpio drivers Date: Mon, 7 Oct 2024 14:39:57 +0200 Message-ID: <6964b1728d155b85c9c97fe26726e8ee2c04abf8.1728300190.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Select the RP1 drivers needed to operate the PCI endpoint containing several peripherals such as Ethernet and USB Controller. This chip is present on RaspberryPi 5. Signed-off-by: Andrea della Porta --- arch/arm64/configs/defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 5fdbfea7a5b2..5fcd9ae0d373 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -609,6 +609,7 @@ CONFIG_PINCTRL_QCM2290=3Dy CONFIG_PINCTRL_QCS404=3Dy CONFIG_PINCTRL_QDF2XXX=3Dy CONFIG_PINCTRL_QDU1000=3Dy +CONFIG_PINCTRL_RP1=3Dy CONFIG_PINCTRL_SA8775P=3Dy CONFIG_PINCTRL_SC7180=3Dy CONFIG_PINCTRL_SC7280=3Dy @@ -689,6 +690,7 @@ CONFIG_SENSORS_RASPBERRYPI_HWMON=3Dm CONFIG_SENSORS_SL28CPLD=3Dm CONFIG_SENSORS_INA2XX=3Dm CONFIG_SENSORS_INA3221=3Dm +CONFIG_MISC_RP1=3Dm CONFIG_THERMAL_GOV_POWER_ALLOCATOR=3Dy CONFIG_CPU_THERMAL=3Dy CONFIG_DEVFREQ_THERMAL=3Dy @@ -1270,6 +1272,7 @@ CONFIG_COMMON_CLK_CS2000_CP=3Dy CONFIG_COMMON_CLK_FSL_SAI=3Dy CONFIG_COMMON_CLK_S2MPS11=3Dy CONFIG_COMMON_CLK_PWM=3Dy +CONFIG_COMMON_CLK_RP1=3Dm CONFIG_COMMON_CLK_RS9_PCIE=3Dy CONFIG_COMMON_CLK_VC3=3Dy CONFIG_COMMON_CLK_VC5=3Dy --=20 2.35.3