From nobody Mon Nov 25 09:22:36 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 21A3A1DDA00 for ; Mon, 28 Oct 2024 14:07:16 +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=1730124440; cv=none; b=Z2Qa9izzW9vD+Wndz0Th1IimmSc5MqIJN17nyS1CLHVDniAuX7+TWl7DFlYrZI3aWchJUfPZvMecR0TFjAtwZaDkK522Z/glsLbALqug8NGJxePUXaxDnog6Ynvlb7I1ErUKJysvOXgIs4L9JIlPJhwHSU1uvLtobPlG+jEJcQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124440; c=relaxed/simple; bh=oGXIehuDVhM9IZGFOIbJVctZ7APEguA/CTruZW7c9xI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OIP5y7HVLQ4H6aoXzyhslqLKHuJ1sLPAR18GMxZewjES99esLuExHdT2bE2ljF2XxtM7bFEwVp6CV4u8Bzlz3MPWeXnowT4b7/XS3gxVrS1OmciJIMRK98gnCV2dgGR64ExxZOafGdMgjkEcOvsDITmBTkzOxeVEF6CMSKQNljQ= 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=MPPLteD8; 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="MPPLteD8" Received: by mail-ed1-f65.google.com with SMTP id 4fb4d7f45d1cf-5c9388a00cfso5049220a12.3 for ; Mon, 28 Oct 2024 07:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124435; x=1730729235; 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=sd56aOkuMysyT2KB8hGYnKh+/GEDQ2ezHMqu8x8AMhU=; b=MPPLteD87R/wadZn4a2nT5HV8odzZi4L0RGQDxqzP47mMGphVJZ3sYL296+m+8P1+F d/b7VimwMFqUIa68BRZ4LVyOZpL0vhuv7mpqfNA2vZixiDryzsLw1pqNKgVc/Hn5x5o9 vUUSkK3uWp30nHouLRax2ilB5IC2j3mYl1kuJYJZiL2Ld5xz+n9EMurtD+t25+02hkRz fvYIcK+u0FaAR9yZQvv4z5s7VPKak6ZycoUN7cRNo9OY3xDvvAf+Jia9+6v3331Azqt9 5XT5IZDbdNlK/NLqbtCLDeNF6G4+IeDKr1uOy0RCinMMS9B35YmCqvVYKAE87sNveQ7W e85w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124435; x=1730729235; 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=sd56aOkuMysyT2KB8hGYnKh+/GEDQ2ezHMqu8x8AMhU=; b=KV3cMoc3ZGcSjTa3DBK7Q3w/59a63jWojKiiziBudM+XjRgIOHDyXEXAmURbhVkDA/ 5tS8EuCKcvNY4sOZKFag9nTZEWSI+hcz7v9HjsJ50OrmXWF+3BpNx6qQGbafq+0JazCG gJxdn99a91c6vr9vZ34eUnGKX5kKg6Up1j7mXAwoOR2+xizTTyV3YmrmsYRJLTvwRpj0 8X05npuohlNuTU3hp7+a2PhjER2nGTeCTJNKfjN1I/ZGjpDwNphchhGWP3V6YSxJ7bCb IYqMjJ45423AB9r8br7xkiX1aoAIY2R4DTImYpsZUkQDaT0O2GDVkFGuNYf9S3ZJtVjF xxGQ== X-Forwarded-Encrypted: i=1; AJvYcCWu925MX884KN4qP3SB22W2ducyod/Uu/EUZMKEa9ztysUiX4iGggKb1CNn2P/4xCWOxr8eJl4gQvh9vfw=@vger.kernel.org X-Gm-Message-State: AOJu0YwOwAULXnqFWcZfgr9/lAqSWIPzGHtUFF02jR4H1LlRP6l2pjEn jsCMUUERIo7bT1ImVIifcRJlz7c2HzqnrTvnZiYAXnc990OBPN/uimdsOf+esek= X-Google-Smtp-Source: AGHT+IHnQmGNdgq4ua8lcOG0fpUd4ZzacA/KnXwPQaktYONOCK4jJ5VyW7kO53vvL4+ai760vMmRAQ== X-Received: by 2002:a05:6402:40d5:b0:5c9:6623:a11a with SMTP id 4fb4d7f45d1cf-5cbbf94abc2mr7214438a12.25.1730124435216; Mon, 28 Oct 2024 07:07:15 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb6347c06sm3197980a12.84.2024.10.28.07.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:14 -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 , Krzysztof Wilczynski , 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 v3 01/12] dt-bindings: clock: Add RaspberryPi RP1 clock bindings Date: Mon, 28 Oct 2024 15:07:18 +0100 Message-ID: <914978925d34cfb5bee10fe92603f98763af48b0.1730123575.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..a123dd619f8e --- /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 include/dt-bindings/clock/raspberrypi,rp1-clocks.h. + const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: xosc + +required: + - compatible + - reg + - '#clock-cells' + - clocks + +additionalProperties: false + +examples: + - | + #include + + rp1 { + #address-cells =3D <2>; + #size-cells =3D <2>; + + 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 "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..248efb895f35 --- /dev/null +++ b/include/dt-bindings/clock/raspberrypi,rp1-clocks.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * 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 Mon Nov 25 09:22:36 2024 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.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 5F7F31DC745 for ; Mon, 28 Oct 2024 14:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124441; cv=none; b=eeP6GQAexhuABRmqglglTGW7TOp872+bl+dLVQxZcmka2duFQSJqSj6CFOnScW+7dggxEdtidOkP7taDKVlOS38AVxJKHHoga1I5tI9ov9bvl6Zi4FORdK7fVw0cbOCavv96Wg09gYvnN2dsmBIgT81Z/TQhdo9fpvxlK4a3iaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124441; c=relaxed/simple; bh=mwYCVz6D8W9HmTW7vYsdq2zwOKnDl5x6fvHqNEXkl+g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h/p7VJGcAC8rhmvNKTiWFv0b6IqJoWZRAMm9FIGJUAlWkviP4Opd17z8xMoN12Tkt21aPHXaUT/P2k9wjxE7QCATOOPTXRGj7cfYq4LA1ldwBvJooidT8SLN808sFvCrAyfKFbPSZchNA9MRHvCQoueNt9rGfAERhs8Ktp5rLYQ= 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=HzHP2ebm; arc=none smtp.client-ip=209.85.218.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="HzHP2ebm" Received: by mail-ej1-f65.google.com with SMTP id a640c23a62f3a-a9a850270e2so720050066b.0 for ; Mon, 28 Oct 2024 07:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124437; x=1730729237; 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=3nL/aNuqQ0jfU5YRKIpGycLGZhiHvfbk6boSP0gW7YU=; b=HzHP2ebmGsVcef/b6mjh2ZvckZ/+gQpiyPr48oR3HsnrleZDdShSUlT5uNBnxdSpBM e+CA5smuGKZjCpK5Tkaw0bGRs0NvAXPoNu4OERM/t9kb03eaCiW5C3LvhSDrrewODR8Y MpHclY8xqXSMH3Z7zQnEKzPNgV5Omq8J4U1slzB2jyRIL04zn1HwIXIFB7IKzIbHsnDb Fdo/amtUDZn3AdT35c+Hea1YWf0nW8eclGvf9Fw547k1/lb+QAtyOeLTYuwHcuX5wURG 1BEny8RW9AIlk+LvxfAjM5lvzBUHGDpBQUk6AxLE4FtblVLAAeSCW2NnzPfPtCWrQFOh vQoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124437; x=1730729237; 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=3nL/aNuqQ0jfU5YRKIpGycLGZhiHvfbk6boSP0gW7YU=; b=rt70HV9DDuuOMuL5kIRuotxsOV5lnTQzG99JX0W4thkBH8OZn4oExzk828Pa1+qwb+ voJXHq/7M2lwQ5SaGyqgCfzwXPO3wvIkC6/eYBhp6sdZOrp917nmOdcCl7bHgnRZ4piW TjxH+dsQFN7sL4j2OsCc4lRDdyLGKvkXxuxUBbzVFGH2NarVy4jfD3b75aN7jnJgdR1b IgtnXvGsA6B3L9jO2RkB3uxY2N/UJpB/SsClWzlnhpx9vDzoWC+QxZjh7wOAAIiDMVjE GlYicDHCi9OcAuU/WaH5Lp3v2G3+KWOZbKnjaC5tanOyKAXSLBhCXXaE+zjfWM6HKKzJ K7LQ== X-Forwarded-Encrypted: i=1; AJvYcCWWvJ5pV91poL27Skv58Hv6FzWmMiEAyFRZcOYd2cR+6ZHxn/9umACTsszT//qquXTRLNbuvCPgoZYWJdc=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ+5HNqFVf0VLzu7i9yLmqQ8wJpqqw8JUgRYeDr286whcChvBK XkSy3jZ3Dty8nfV5Y1ZIkkxkJWl2iWG8xfWEWs+jPiJj7/nuI5K6DptgquP8lFo= X-Google-Smtp-Source: AGHT+IERr8XivDBajebydtWIWIIvd/nwOj10Iu4gpEnGicX7BoMfI323yDnTaPBK5OXEFfYVNbe1Fg== X-Received: by 2002:a17:907:7f29:b0:a9a:c57f:964f with SMTP id a640c23a62f3a-a9de5cea097mr747130466b.16.1730124436319; Mon, 28 Oct 2024 07:07:16 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b30d6fdc5sm381023066b.163.2024.10.28.07.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:15 -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 , Krzysztof Wilczynski , 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 v3 02/12] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings Date: Mon, 28 Oct 2024 15:07:19 +0100 Message-ID: <9a02498e0fbc135dcbe94adc7fc2d743cf190fac.1730123575.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 | 163 ++++++++++++++++++ MAINTAINERS | 2 + 2 files changed, 165 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..465a53a6d84f --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/raspberrypi,rp1-gpio.yaml @@ -0,0 +1,163 @@ +# 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. + +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 { + 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 Mon Nov 25 09:22:36 2024 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.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 326AE1DDC0C for ; Mon, 28 Oct 2024 14:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124444; cv=none; b=Wv1j380pOsEbaD1QghX9Mo6SoEvL176kY2+Lf2/5ZBknBLLAJuANbSvLU7SUx05ZuHkolap6dtHcw5f1Br0jfVczoEIUK2R64U2hQSjSbUl8PIiBlHEOE7xjxAGNZE8ALy+NkWugxKkX4F+85v/nL52/eophCQYsIo6/qMjL3hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124444; c=relaxed/simple; bh=37BIVVxAvp06DoclbS8nrf/h7HI7daZAV/SbOYBjkus=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtnxEJB01gXdLrShbeoS1nR2zlGcYMDutJrdySxMCTHG039TyC8Non3uo1JlybVTAuRRo8ZIWxz1SVZHKYGddjt9S5JcMp01zwlmpgkAbkue3cOVCfTXOtlThiUCqRsJ7PWmcbefnvu/blLkqdeu7cjs72b9P5MhweniY+0a7zw= 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=cKW6f0KG; arc=none smtp.client-ip=209.85.208.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="cKW6f0KG" Received: by mail-ed1-f68.google.com with SMTP id 4fb4d7f45d1cf-5c937b5169cso6743298a12.1 for ; Mon, 28 Oct 2024 07:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124438; x=1730729238; 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=SI9eKYh0F26+LR3GPe1sodJ7zzCtCgj8qtPEzcqglJE=; b=cKW6f0KGXDvrHC7G7k/BAaAJ3jvEXC7fyAodzN1DHl64lDld9JPbwHheE4xMRuU/be BfCjTNjMi6GwuxqG/yY4b8ALrVa12tOP0zucc5A2lU3vba9TaIBLicuKLKAx8lUJKSEC PX/gZzdsI9cP6y84OYl6oODL8B69QnqF+tam8IYXDEia+kpCj/XSgGAedTIlgoXgK+kg l0AG0LGsMLZjPJanlobKS0U7SrssbvVRUb9P7KLZGWqT2YpJ+Qg3oYw9G4VhCHv3LX35 HhY3JJx4gSnB2pSuMACuiMJ92IqetqXXbfDEdMosY+8lCz6PZJhyJ+CUiNos4Zqj0+LT 2WeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124438; x=1730729238; 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=SI9eKYh0F26+LR3GPe1sodJ7zzCtCgj8qtPEzcqglJE=; b=Hzj6jiVcI7A++guJvl8JfsrvlykPU6IQ70AZqYNqtWnbxAYFHDpHOdOC/s+JqsX0ui 5uzkvWV61wnCxNyuBWyplupijw/nC+ZuScYXElnvI4As+fpifIQu51WtNoeGTzVocafh YpkynU1A6lgmf99Siba6UDaxOt1cHylHQDyFyvrfxNlH9jqGtqm8Tj8VnGZNWDLuTR7E pujdHPj+d3Yhd2W5GCefcOnZ2GKTT45vI++hL+oChfoA5RKPW5ME0p+WjH1/5XxL94pj XvPVCCHi6A+eIf0mLqw4GBSbCPp0Loigsey0R2EMIMiskcgOl7/XSUr0hi2ziPdq5YWx BRsA== X-Forwarded-Encrypted: i=1; AJvYcCWyLvv6TI/lHS5C+SI13JUjoINAOPC5IK/TcG45XBRiwYSRtOU47pK/FUMh7SwVfPtPZdB6Zxim+xQJ5EY=@vger.kernel.org X-Gm-Message-State: AOJu0YwirI0wgW6wBOpAbjczfIedmhTVNSBUBFpsn63e1xSqfQndS1NO +O8yu6aba1kk4s2Hv26Cay4BqHmZ8wEt+hXa9XqRggaRwwYd+MhzOFSbo4DOQzw= X-Google-Smtp-Source: AGHT+IF5qNRgzKfi4MHhOJRZ8tqZIPrE0osHzwKattDyJF+pEfAMuUnEueh0yzfRuzZGt6IlIDK4Xg== X-Received: by 2002:a05:6402:1ed2:b0:5c8:df99:a6ec with SMTP id 4fb4d7f45d1cf-5cbbf20f089mr7633425a12.14.1730124438052; Mon, 28 Oct 2024 07:07:18 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb631a24dsm3186275a12.74.2024.10.28.07.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:17 -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 , Krzysztof Wilczynski , 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 v3 03/12] dt-bindings: pci: Add common schema for devices accessible through PCI BARs Date: Mon, 28 Oct 2024 15:07:20 +0100 Message-ID: <2948fdf8ccf8d83f59814d0b2a85ce8dac938764.1730123575.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" 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 | 58 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 59 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..e532621f226b --- /dev/null +++ b/Documentation/devicetree/bindings/pci/pci-ep-bus.yaml @@ -0,0 +1,58 @@ +# 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]$': + type: object + 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. + + additionalProperties: true + + properties: + compatible: + const: simple-bus + + required: + - compatible + +additionalProperties: true +... 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 Mon Nov 25 09:22:36 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 B80351DDC13 for ; Mon, 28 Oct 2024 14:07:20 +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=1730124444; cv=none; b=Y9xD/1KlRYjMmJf9ZF46CMe80Q05ALhpfuk1g34Pd9lDp5j6U/TC0tXIj20lkBXs6dEiTYGZZ7x0SW3dDsu3CgxtKJ++993YWp5v1bVk8jWqjUZPqYib5+aWs+pwwEPBJqHXZ5fK/swSyoMEQib0IBjyvXtH1+I/v4emQuAwecM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124444; c=relaxed/simple; bh=KWzJH01MBbP+2MBa2bGY8qrZZJMVX7VaS+5unE5ZJRA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LKR/U7hlPp9Cth+WjU65MqThGdJnkFHV1OUUHzwehhc8FLBkPe3qizy/PrBSUOPROCEuCrv1tTDaPi/KNirCkHM4ZSIT0kitPRXaRUL3s3l19X4+HIAx0XNUQL8mQl8K8FaFJdSQeRLJy8yqTGqXatIbZH5QTmpqC3x7Z5q9mrA= 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=csPIyBmi; 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="csPIyBmi" Received: by mail-ej1-f67.google.com with SMTP id a640c23a62f3a-a9a3dc089d8so646372166b.3 for ; Mon, 28 Oct 2024 07:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124439; x=1730729239; 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=iNEc7Ab11J7D2bwXEyWPM+PpwLENCKqu46gw0+Cu+lU=; b=csPIyBmimIuaIUUUOWaOirSwgf/xHd6HWzZ5vJ/Vbw0CEU9WnCRBp3n/9C+pcZAY/O eqfIA8IDBN8hUDq8xzLasWypEAfnDOIVo3KRGTj1+FiBQx1KD9QtIfE+Jr5uYeMtMlC0 iiU+xf0P9pEx5w3c0ELsG6d5IpyctBAidQ/i1jPRHOyYT7x9/s2QRCPjsHckiqAHFTik Ht17jfu1PzhHRah1/hXunwWXu7rmbdGWTqY2F7FPDf5L5K2EAqjLAJapKtL0XzEuJkc6 k17xGrQk0plppaMhEtQuBhpVNCG6pfuU5XxKygDwVDa+de0i5tSrKrERFEFc2QfbNeeW B4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124439; x=1730729239; 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=iNEc7Ab11J7D2bwXEyWPM+PpwLENCKqu46gw0+Cu+lU=; b=vGIIrDuzkvkmRlh/4jAyWmLtPZxRee2VRsa1pcNFYMu5rJSnh6zFKELfJm3wp7c+UH RNGD8i18MSz6y02L/nYDYjsZKiIDTD6+omHJqSBLiXONtCXDo6Oam73u3LsAMctxlB59 kU4BRj3PpT3YECsj70Pk7capI4L+K7JhVq5rFlQO8JwVPDQ8OFcIwi6biUcQRIS/wlqD KKO7/6hc3hX35W3ow4jHM3F8x5cgvvjTJbdG+QjzrYm76zV9uQFWJEBu0b2n5iEYsklE 0xicvgk4qF+5ZfgKSyofOS6RtlxB3/oSwY63HKW8k1c7nc++kGehgJ5OMezdsiuq81q6 4NiQ== X-Forwarded-Encrypted: i=1; AJvYcCVv+KsU99UdI9iHX0G/gkPTLx/zrb7UpW3kH+jYTviGvh3K0NqrIZJylbIrUR8OBRav1yI22+DL2PIvd2Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyxpZrc1yqavag4KyhSNt1ib4RHR6eNISqFOpQOretW/DTscpAK nTkfoub5bP+nau7VD0eRB0amAkbe5P0qg70eiC1FGQPUKdwOnpPKb/ih/vQPjZw= X-Google-Smtp-Source: AGHT+IGLRlQTVhRPQemiDdTWqan8eXJlYIgmzJ3VjDMdLX43CD2E2sNJ5FgkqwMaVS/d3Bu6+8CK3Q== X-Received: by 2002:a17:907:3da1:b0:a99:4e35:9a25 with SMTP id a640c23a62f3a-a9de61a17a1mr698709666b.44.1730124439054; Mon, 28 Oct 2024 07:07:19 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a08b29asm383846066b.225.2024.10.28.07.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:18 -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 , Krzysztof Wilczynski , 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 v3 04/12] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1 Date: Mon, 28 Oct 2024 15:07:21 +0100 Message-ID: <768d2307342e1054c58324a9d51957456dc82cbf.1730123575.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 | 80 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 81 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..d66b2fc130d1 --- /dev/null +++ b/Documentation/devicetree/bindings/misc/pci1de4,1.yaml @@ -0,0 +1,80 @@ +# 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 + + '#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 + +unevaluatedProperties: false + +required: + - compatible + - '#interrupt-cells' + - interrupt-controller + - pci-ep-bus@1 + +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>; + interrupt-controller; + #interrupt-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>; + + 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 "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 Mon Nov 25 09:22:36 2024 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 B5F5C1DDC16 for ; Mon, 28 Oct 2024 14:07:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124446; cv=none; b=Lq5gApRPSSao1Q0qWObMg+qFL4KaOHj6Ug3QoIvrzt/feKjcJmwUn3cTIj0yRTpCT+idsTU+FlJY2MXYuXNOv/AdNQc6sSjO7YynragS2QhAGKFalfRoadixsWJMJqpX/gtSw30NFdMYVIqRsDVVDQvJH34oI/9Q6OjP41nSO9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124446; c=relaxed/simple; bh=bBaN0X0jScd/15W+2/fScdw6Spc8ffLYU0CeQxKdTas=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WvIub3LzDT+8okgGvXYlwyxzVPdRp6361wLrtAj0yAjwxs4xpry2BiiO2qe+wvpfSf9jtWVo4+oGJH77a5fURzdyW9+eOqsO03c+mBEnv+PIKSJI80oSdBsgxbwqMKRYzWWAt8qmgWC0GpNWzBVKFQIjIoNgJYDNwqN3IBEwCUY= 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=BomfZmJl; arc=none smtp.client-ip=209.85.208.41 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="BomfZmJl" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c9388a00cfso5049342a12.3 for ; Mon, 28 Oct 2024 07:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124440; x=1730729240; 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=yqh56MHAf6NGyxNJb5XjKGyAFS1Pm7/dh/+rsUlSsqw=; b=BomfZmJlug7ZwpBY6Rw8s/hVg8VMdkshumj8yk04yvy72sDEPdWUREZq2Hhg0S4M8u gDJLYX5zIJAZF8guDj4/4a90eBM3JPx9O0eCsZcovLXelDNFW8lhr1XuhO+f5Gvoq7g3 2RdzF8Kxnj7MBV34UnZqFH2k0c+uRLezZBRIdtqqBM/tm9eFS1sZwatTjloHuVjTalmY zWOifKCEMs/rR3S8FsrgqmN4a6oOLrCl1Kij/mBRZAeQtNAhcyiw67Q6tS/z+fQ2avFr Ez9u30lvsd49FVcTxDrg25C5V4aYUUTUIBTe9iCyGrwRcaxRllKu5u32vLi7PRUTt0BG +OMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124440; x=1730729240; 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=yqh56MHAf6NGyxNJb5XjKGyAFS1Pm7/dh/+rsUlSsqw=; b=kjJMi/aC/+3L/DPSODdXZxukviIGbPGHS2q3ZHYhszLlvoq4u/nTBWaQq3pK/VD8q3 dADib2wn4L2knQ+Io8UOgHq/Sz6uD8FFyzy6bUH81BXCeD9fgENasmhD+VNLqyPJsWM1 /PAZm1QdEe/c1Yitgyxbq9L3EYXgn20TnMr54wyV6sXi2Lr6U6z2Sv65nc4CXdwbG3hE RteCEQuUnGr0AYpMRRHxnzO0K0DL4C8HqTE1kD+OwZYyo2kihjTq7SrAtdJ6RhRIvzfL nUk3+Ji+Dx68sUBKsL9bi5+932WXqTuASAAhqIAuttxoVFn8Da+5pqJ3xwtb542aayfL LeMQ== X-Forwarded-Encrypted: i=1; AJvYcCVcTCsw/qj9oOIu+y8NWlMKeicIMuEFy8pDgQK3wWZgSxLsss/Rt7j7yb+d9vjpv20E8U05r+uoARJLAoo=@vger.kernel.org X-Gm-Message-State: AOJu0YwAH5dJwp0g47DTnu2KrGJy30wIXCoa8KlmACTmbF8xkrl4funP 2PPIooh6HMGaB9WVsWOscldsOnyWJlctsTFAMvZ0LPZhOkIWsuuMYLOXAjghgbU= X-Google-Smtp-Source: AGHT+IEJsXz3JLUo8t8BMAbJDLTmQNDfk74M3MzGZPfukI0B32f64s3so2uEdukAd0Pl42XLPpmBkw== X-Received: by 2002:a17:907:3e1a:b0:a99:f4be:7a6c with SMTP id a640c23a62f3a-a9de61669cdmr835551966b.52.1730124440047; Mon, 28 Oct 2024 07:07:20 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b32455a14sm388970666b.178.2024.10.28.07.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:19 -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 , Krzysztof Wilczynski , 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 v3 05/12] PCI: of_property: Assign PCI instead of CPU bus address to dynamic bridge nodes Date: Mon, 28 Oct 2024 15:07:22 +0100 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" When populating "ranges" property for a PCI bridge, of_pci_prop_ranges() incorrectly use the CPU bus address of the resource. Since this is a PCI-PCI bridge, the window should instead be in PCI address space. Call pci_bus_address() on the resource in order to obtain the PCI bus address. Signed-off-by: Andrea della Porta Acked-by: Bjorn Helgaas Tested-by: Herve Codina --- drivers/pci/of_property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/of_property.c b/drivers/pci/of_property.c index 5a0b98e69795..886c236e5de6 100644 --- a/drivers/pci/of_property.c +++ b/drivers/pci/of_property.c @@ -126,7 +126,7 @@ static int of_pci_prop_ranges(struct pci_dev *pdev, str= uct of_changeset *ocs, if (of_pci_get_addr_flags(&res[j], &flags)) continue; =20 - val64 =3D res[j].start; + val64 =3D pci_bus_address(pdev, &res[j] - pdev->resource); of_pci_set_address(pdev, rp[i].parent_addr, val64, 0, flags, false); if (pci_is_bridge(pdev)) { --=20 2.35.3 From nobody Mon Nov 25 09:22:36 2024 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.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 8F9F81DE2AB for ; Mon, 28 Oct 2024 14:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124447; cv=none; b=IdoiQLSNCHhgmJx0DE0H4LZ/IGiZ0S3dpBOlYXkvazePbssIQdDoU5kpGYGwpk4JfiMnkZ89+HVyvHi2IWZqjuF8vrAeu9IMOCW7uh5gt7fhV2KdAyGb4HCme+/AK21Igtba5jH858zcduBO0isOi9pGX6QRxYQ5Je6eBRB73NY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124447; c=relaxed/simple; bh=GYXHeaG8wpR2BIrXpx816pDyYa9dHkRtT9dpld+pBs8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Syq8s4yM26ftEWdHJXINbq6YI00VTxynMHFs9oGDznNE/8KF35fr5qPvJGWL7eKkDbY2CF4D8Cdi4sljUph2fKtgTU9PKoh3jRM8BykLegKreKkNcXxdCi1AZ6xcicxrpZbvNLM891yEEALSJJNAKDV0EhXUyK+lJ6qhu0vBj3o= 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=Fwly0pM7; arc=none smtp.client-ip=209.85.218.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="Fwly0pM7" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a9a2cdc6f0cso587623866b.2 for ; Mon, 28 Oct 2024 07:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124441; x=1730729241; 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=GW6kvc4ZbQp7jOxwPlUXi8bHuXjPpwn11nTKKI/C1qY=; b=Fwly0pM7JZeed2l9/IOqhf6VXgJap3Odnu14FTJlEGBK9leaUm/+lGtlw51jL14whJ i+96cfa8Z4i6HCXX39/mC2MOE0yTiM6KxGDt04DB4uXFpN5bBhDU/ZNHXxQv7JnGDOci 9C1mnU2yr7Ll0ONE/+Y5jxfxWJyMI3SFf8aF72UmQ2RVjc6m7pljGOyy7QMKqX3OEtyy WMwgTYTXUKvRNbI2mwd5YI3cPDfjraeyiPVSd8RaeZsm8V9FriEF/rjx9rl9O8Gxmcby RYJwTD7UbCHUCJqzx/nIjP3mI9pWXWDN+rV/u4dodCc0YBzdGZGafCzIh0sSTkw76M0L D8QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124441; x=1730729241; 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=GW6kvc4ZbQp7jOxwPlUXi8bHuXjPpwn11nTKKI/C1qY=; b=HeloSJWrGw32CUrBqkQoRTqQ9yuSCvuvh+nreVfrPWgyoqCvxQhyZDwwt2wpqrJHep AHkgrd0B+PnMfWzg63SNNMWt9usZXzEcmNxTvQe0In+KvZFsksqGNpV7kvoJqBkCjG9n zlAYLd3puZRQzOJ17wd8LLgNWdYnxQr6qkk6AA2O5QCGJyi6N8RSpyvgx+hcNTpwIBTX khQwlk7rsk/BTR1gOmtiqhbgYy6Hv1u26hQUKkPhthpXSLA0s93oPga83QZl/2UGmD+C sY1TVYDD41XvioFvnwYvtp6C2mB7uHg75LtvLX+H+dg7zUwvlq9Mkre+sSFoZmKMNb5F u3Cw== X-Forwarded-Encrypted: i=1; AJvYcCWgPHsb15bQPLnAzH6DfArg0Sorgox0S1Gn86ydfk1rfb4InkRXO49904UHnxWdg9hAEigBh13BOifnI30=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/8ao10tLVgfy0LtmGsU+JCf+9I7cK1dJXkNCNO0zQx5oG3Ala si1eILaO2+/hprp6/w+pRzO4mJdYOqrOewsu3nM83dWhntZlchbGq/2TZrpAgs8= X-Google-Smtp-Source: AGHT+IE5csQvNeeQQV2TiEg3S3V6yZpGcfTplYGENkEB1u6HmkJa4la0HF/+Zf2tdkb6gQWZYObepQ== X-Received: by 2002:a17:907:9452:b0:a99:fbfc:5ff3 with SMTP id a640c23a62f3a-a9de5ce1611mr802908466b.18.1730124441130; Mon, 28 Oct 2024 07:07:21 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f2982ecsm376935166b.106.2024.10.28.07.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:20 -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 , Krzysztof Wilczynski , 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 v3 06/12] of: address: Preserve the flags portion on 1:1 dma-ranges mapping Date: Mon, 28 Oct 2024 15:07:23 +0100 Message-ID: <3029857353c9499659369c1540ba887d7860670f.1730123575.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 Tested-by: Herve Codina --- 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 Mon Nov 25 09:22:36 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 8534D1DD9AB for ; Mon, 28 Oct 2024 14:07:24 +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=1730124457; cv=none; b=BbWhZ+ccSRYXqO7n0VkLG2C9+efdj5wLTZ2KV2G2RvQerKsv7nGEGnwv0ipUH8b3a7rtUuBzkbGGZ1Apg4ZiN6rp4SRu09V5r0VhuuGpqg0Euawt66UyEq4OzLyPQacuV19dw4m04f8HGBolHiRg5EmLr1Dp9FB5Dn3nvOWmqBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124457; c=relaxed/simple; bh=vEKlRB7UU9s+r7IHJZc/+uAJAmi554y7MCo3uXNoh/g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e2y2HpLvaBQaw0YUdnRWvH2jd1sOZFao59ot5rxDY/cfnrV4osUx+WzgBhqIK+ZU+u2b63plIbt8oYXL81SUdsdqBDBB+G0K5qvcPE3WVJ027dasbmO+V9wQcDp2iQSeWpElqyGDh2C0uQid+nPEz0BxVfYmLqCjAJuR6DNJT2c= 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=RZ4qt8zU; 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="RZ4qt8zU" Received: by mail-ed1-f65.google.com with SMTP id 4fb4d7f45d1cf-5c94c4ad9d8so5479717a12.2 for ; Mon, 28 Oct 2024 07:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124442; x=1730729242; 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=GFveGfF8+WaDlbdVcjxcI792cAnYoMAh+Ajzj4ISmgA=; b=RZ4qt8zU/dISKPWOAXwYjx28o+dnqYc+CV9QDNTkiJffsKdp6r7WehNyCtk8V121U/ rY9YJbP3IW9DWNDNVL/89zrQvSAygv8Fj44Tq4kNHaBAX3LOBAwqnFWM7zsUU8jVHjIS PFUG1JNI5eF4k3M1w4GZC46ejXjXvFR+l3eLu9hyM8rienH/bdhEJl5rKNnCS1kJQMGK DkYNRIo3fs+h2q3ZPrHfhb0tGDaHP4iSHIhZ+BxtGCKqqBwfBCsXQ58zKLi7MId5eSz7 w5MgtmZHaWQG2enlrcL42XDWTTIyZs5vd+rqTq/Cx+7C9j3Xh/7EdyqtbtS6afBV0Emo WXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124442; x=1730729242; 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=GFveGfF8+WaDlbdVcjxcI792cAnYoMAh+Ajzj4ISmgA=; b=XWJaewrv6EtEGAlgGQd9136A4k3By74etPhaDyh3dod2dTcegd+l+cGAy8lYAcHVao 2om1K+TXlW/RgN1KmWmEILEON8PZxKannWHxWVexKrBHZiB4142CQX1kV4gyCmigorwx blmtw744RBQl8SnmqZeYp1H9plqQqkYFS83l9iWXT31REJomhlWd0PoR82DROdEPhVhX kvfr1KZkL9C5Yj1ONGWoPEEB2KUTEYBKwwD0el89egMWLNRlGdq+lqI6ED/APFBCdM/u 7Mlue/yRKolOwfv9ZuqVlTfO2r0Wgx821oq+N69c77PxAOFTh9GLMOs8k3Rrash+agl0 f0WA== X-Forwarded-Encrypted: i=1; AJvYcCV6QMK7EJ66XpMUmQ59NUz0Uogh9S9KC5tjxlr9LqCpdYC/qo5hohcxfJ0nazXPXhFlq+Lpi3aUDRbtRDk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywug6uHosk+/XtrEVq5Px/uYc9PcZox8TbDUXcdoOMHglBO/NjB aArE96B8Dx4mT2ddc8zG3TtLZ1PIT0gKULa7fXDqUDPtcE0Z7pgMm8yRXUp9eFQ= X-Google-Smtp-Source: AGHT+IGdyws+KRux024/cSIOD0MqnGLMxWdEiA9p8Zif1vqY/2dg/YCpcoKqWWfMqrgWbCiAhrNz2w== X-Received: by 2002:a17:906:dacd:b0:a9a:59f:dfb9 with SMTP id a640c23a62f3a-a9de5cfedb1mr883597266b.5.1730124442333; Mon, 28 Oct 2024 07:07:22 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f0298fdsm382615066b.54.2024.10.28.07.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:21 -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 , Krzysztof Wilczynski , 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 v3 07/12] clk: rp1: Add support for clocks provided by RP1 Date: Mon, 28 Oct 2024 15:07:24 +0100 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" 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 | 8 + drivers/clk/Makefile | 1 + drivers/clk/clk-rp1.c | 1540 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1550 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..f67ce3a3fb35 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -88,6 +88,14 @@ 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 MISC_RP1 || COMPILE_TEST + 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..69b9cf037cb2 --- /dev/null +++ b/drivers/clk/clk-rp1.c @@ -0,0 +1,1540 @@ +// 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 + +#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 LOCK_TIMEOUT_US 100000 +#define LOCK_POLL_DELAY_US 5 + +#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; + struct regmap *regmap; + spinlock_t regs_lock; /* spinlock for all clocks */ + + /* 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; + u32 ctrl_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_pll_ph_data { + const char *name; + unsigned int phase; + unsigned int fixed_divider; + u32 ph_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_pll_divider_data { + const char *name; + u32 sec_reg; + unsigned long flags; + u32 fc0_src; +}; + +struct rp1_clock_data { + const char *name; + 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_clk_desc { + struct clk_hw *(*clk_register)(struct rp1_clockman *clockman, + struct rp1_clk_desc *desc); + const void *data; + struct clk_hw hw; + struct rp1_clockman *clockman; + unsigned long cached_rate; + struct clk_divider div; +}; + +#define FIELD_SET(_reg, _mask, _val) \ +do { \ + u32 mask =3D (_mask); \ + (_reg) &=3D ~mask; \ + (_reg) |=3D FIELD_PREP(mask, (_val)); \ +} while (0) + +static inline +void clockman_write(struct rp1_clockman *clockman, u32 reg, u32 val) +{ + regmap_write(clockman->regmap, reg, val); +} + +static inline u32 clockman_read(struct rp1_clockman *clockman, u32 reg) +{ + u32 val; + + regmap_read(clockman->regmap, reg, &val); + + return val; +} + +static int rp1_pll_core_is_on(struct clk_hw *hw) +{ + struct rp1_clk_desc *pll_core =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *pll_core =3D container_of(hw, struct rp1_clk_desc, h= w); + struct rp1_clockman *clockman =3D pll_core->clockman; + const struct rp1_pll_core_data *data =3D pll_core->data; + + u32 fbdiv_frac, val; + int ret; + + 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. */ + ret =3D regmap_read_poll_timeout(clockman->regmap, data->cs_reg, val, + val & PLL_CS_LOCK, + LOCK_POLL_DELAY_US, LOCK_TIMEOUT_US); + if (ret) + dev_err(clockman->dev, "%s: can't lock PLL\n", + clk_hw_get_name(hw)); + + return ret; +} + +static void rp1_pll_core_off(struct clk_hw *hw) +{ + struct rp1_clk_desc *pll_core =3D container_of(hw, struct rp1_clk_desc, 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) +{ + u32 fbdiv_int, fbdiv_frac; + unsigned long calc_rate; + u64 shifted_fbdiv_int; + 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; + + shifted_fbdiv_int =3D (u64)fbdiv_int << 24; + calc_rate =3D (u64)parent_rate * (shifted_fbdiv_int + fbdiv_frac); + calc_rate +=3D BIT(23); + calc_rate >>=3D 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_clk_desc *pll_core =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *pll_core =3D container_of(hw, struct rp1_clk_desc, 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; + u64 shifted_fbdiv_int; + + fbdiv_int =3D clockman_read(clockman, data->fbdiv_int_reg); + fbdiv_frac =3D clockman_read(clockman, data->fbdiv_frac_reg); + + shifted_fbdiv_int =3D (u64)fbdiv_int << 24; + calc_rate =3D (u64)parent_rate * (shifted_fbdiv_int + fbdiv_frac); + calc_rate +=3D BIT(23); + calc_rate >>=3D 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; + + return get_pll_core_divider(hw, rate, *parent_rate, + &fbdiv_int, &fbdiv_frac); +} + +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_clk_desc *pll =3D container_of(hw, struct rp1_clk_desc, 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); + FIELD_SET(prim, PLL_PRIM_DIV1_MASK, prim_div1); + FIELD_SET(prim, PLL_PRIM_DIV2_MASK, prim_div2); + 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_clk_desc *pll =3D container_of(hw, struct rp1_clk_desc, 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 int rp1_pll_ph_is_on(struct clk_hw *hw) +{ + struct rp1_clk_desc *pll_ph =3D container_of(hw, struct rp1_clk_desc, hw); + struct rp1_clockman *clockman =3D pll_ph->clockman; + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + return !!(clockman_read(clockman, data->ph_reg) & PLL_PH_EN); +} + +static int rp1_pll_ph_on(struct clk_hw *hw) +{ + struct rp1_clk_desc *pll_ph =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *pll_ph =3D container_of(hw, struct rp1_clk_desc, 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 unsigned long rp1_pll_ph_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct rp1_clk_desc *pll_ph =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *pll_ph =3D container_of(hw, struct rp1_clk_desc, hw); + const struct rp1_pll_ph_data *data =3D pll_ph->data; + + return *parent_rate / data->fixed_divider; +} + +static int rp1_pll_divider_is_on(struct clk_hw *hw) +{ + struct rp1_clk_desc *divider =3D container_of(hw, struct rp1_clk_desc, di= v.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_clk_desc *divider =3D container_of(hw, struct rp1_clk_desc, di= v.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_clk_desc *divider =3D container_of(hw, struct rp1_clk_desc, di= v.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_clk_desc *divider =3D container_of(hw, struct rp1_clk_desc, di= v.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); + FIELD_SET(sec, PLL_SEC_DIV_MASK, div); + + /* 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 int rp1_clock_is_on(struct clk_hw *hw) +{ + struct rp1_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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 */ + FIELD_SET(ctrl, CLK_CTRL_AUXSRC_MASK, index - data->num_std_parents); + /* Set src to aux list */ + ctrl &=3D ~data->clk_src_mask; + ctrl |=3D (AUX_SEL << CLK_CTRL_SRC_SHIFT) & data->clk_src_mask; + } else { + ctrl &=3D ~data->clk_src_mask; + ctrl |=3D (index << CLK_CTRL_SRC_SHIFT) & data->clk_src_mask; + } + + 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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_clk_desc *clock =3D container_of(hw, struct rp1_clk_desc, 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 > 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 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, +}; + +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, +}; + +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, + .recalc_rate =3D rp1_pll_ph_recalc_rate, + .round_rate =3D rp1_pll_ph_round_rate, +}; + +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, +}; + +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, +}; + +static struct clk_hw *rp1_register_pll_core(struct rp1_clockman *clockman, + struct rp1_clk_desc *desc) +{ + const struct rp1_pll_core_data *pll_core_data =3D desc->data; + struct clk_init_data init =3D { }; + int ret; + + /* All of the PLL cores derive from the external oscillator. */ + init.parent_data =3D desc->hw.init->parent_data; + init.num_parents =3D desc->hw.init->num_parents; + 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; + + desc->clockman =3D clockman; + desc->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &desc->hw); + + if (ret) + return ERR_PTR(ret); + + return &desc->hw; +} + +static struct clk_hw *rp1_register_pll(struct rp1_clockman *clockman, + struct rp1_clk_desc *desc) +{ + const struct rp1_pll_data *pll_data =3D desc->data; + struct clk_init_data init =3D { }; + int ret; + + init.parent_data =3D desc->hw.init->parent_data; + init.num_parents =3D desc->hw.init->num_parents; + init.name =3D pll_data->name; + init.ops =3D &rp1_pll_ops; + init.flags =3D pll_data->flags | CLK_IGNORE_UNUSED | CLK_IS_CRITICAL; + + desc->clockman =3D clockman; + desc->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &desc->hw); + + if (ret) + return ERR_PTR(ret); + + return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_ph(struct rp1_clockman *clockman, + struct rp1_clk_desc *desc) +{ + const struct rp1_pll_ph_data *ph_data =3D desc->data; + struct clk_init_data init =3D { }; + int ret; + + init.parent_data =3D desc->hw.init->parent_data; + init.num_parents =3D desc->hw.init->num_parents; + init.name =3D ph_data->name; + init.ops =3D &rp1_pll_ph_ops; + init.flags =3D ph_data->flags | CLK_IGNORE_UNUSED; + + desc->clockman =3D clockman; + desc->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &desc->hw); + + if (ret) + return ERR_PTR(ret); + + return &desc->hw; +} + +static struct clk_hw *rp1_register_pll_divider(struct rp1_clockman *clockm= an, + struct rp1_clk_desc *desc) +{ + const struct rp1_pll_data *divider_data =3D desc->data; + struct clk_init_data init =3D { }; + int ret; + + init.parent_data =3D desc->hw.init->parent_data; + init.num_parents =3D desc->hw.init->num_parents; + 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; + + desc->div.reg =3D clockman->regs + divider_data->ctrl_reg; + desc->div.shift =3D PLL_SEC_DIV_SHIFT; + desc->div.width =3D PLL_SEC_DIV_WIDTH; + desc->div.flags =3D CLK_DIVIDER_ROUND_CLOSEST; + desc->div.flags |=3D CLK_IS_CRITICAL; + desc->div.lock =3D &clockman->regs_lock; + desc->div.hw.init =3D &init; + desc->div.table =3D pll_sec_div_table; + + desc->clockman =3D clockman; + + ret =3D devm_clk_hw_register(clockman->dev, &desc->div.hw); + + if (ret) + return ERR_PTR(ret); + + return &desc->div.hw; +} + +static struct clk_hw *rp1_register_clock(struct rp1_clockman *clockman, + struct rp1_clk_desc *desc) +{ + const struct rp1_clock_data *clock_data =3D desc->data; + struct clk_init_data init =3D { }; + 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 && + desc->hw.init->parent_data[AUX_SEL].index !=3D -1)) + return NULL; + + init.parent_data =3D desc->hw.init->parent_data; + init.num_parents =3D desc->hw.init->num_parents; + init.name =3D clock_data->name; + init.flags =3D clock_data->flags | CLK_IGNORE_UNUSED; + init.ops =3D &rp1_clk_ops; + + desc->clockman =3D clockman; + desc->hw.init =3D &init; + + ret =3D devm_clk_hw_register(clockman->dev, &desc->hw); + + if (ret) + return ERR_PTR(ret); + + return &desc->hw; +} + +/* Assignment helper macros for different clock types. */ +#define _REGISTER(f, ...) { .clk_register =3D f, __VA_ARGS__ } + +#define PARENT_CLK(pnum, ...) .hw.init =3D &(const struct clk_init_data) {= \ + .parent_data =3D (const struct \ + clk_parent_data[]) { \ + __VA_ARGS__ \ + }, \ + .num_parents =3D pnum } + +#define CLK_DATA(type, ...) .data =3D &(struct type) { __VA_ARGS__ } + +#define REGISTER_PLL_CORE(...) _REGISTER(&rp1_register_pll_core, \ + __VA_ARGS__) + +#define REGISTER_PLL(...) _REGISTER(&rp1_register_pll, \ + __VA_ARGS__) + +#define REGISTER_PLL_PH(...) _REGISTER(&rp1_register_pll_ph, \ + __VA_ARGS__) + +#define REGISTER_PLL_DIV(...) _REGISTER(&rp1_register_pll_divider, \ + __VA_ARGS__) + +#define REGISTER_CLK(...) _REGISTER(&rp1_register_clock, \ + __VA_ARGS__) + +static struct rp1_clk_desc clk_desc_array[] =3D { + [RP1_PLL_SYS_CORE] =3D REGISTER_PLL_CORE(PARENT_CLK(1, { .index =3D 0 }), + CLK_DATA(rp1_pll_core_data, + .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(PARENT_CLK(1, { .index =3D 0 }= ), + CLK_DATA(rp1_pll_core_data, + .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(PARENT_CLK(1, { .index =3D 0 }= ), + CLK_DATA(rp1_pll_core_data, + .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(PARENT_CLK(1, + { .hw =3D &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name =3D "pll_sys", + .ctrl_reg =3D PLL_SYS_PRIM, + .fc0_src =3D FC_NUM(0, 2), + )), + + [RP1_CLK_ETH_TSU] =3D REGISTER_CLK(PARENT_CLK(1, { .index =3D 0 }), + CLK_DATA(rp1_clock_data, + .name =3D "clk_eth_tsu", + .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 * HZ_PER_MHZ, + .fc0_src =3D FC_NUM(5, 7), + )), + + [RP1_CLK_SYS] =3D REGISTER_CLK(PARENT_CLK(3, + { .index =3D 0 }, + { .index =3D -1 }, + { .hw =3D &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_clock_data, + .name =3D "clk_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 * HZ_PER_MHZ, + .fc0_src =3D FC_NUM(0, 4), + .clk_src_mask =3D 0x3, + )), + + [RP1_PLL_SYS_PRI_PH] =3D REGISTER_PLL_PH(PARENT_CLK(1, + { .hw =3D &clk_desc_array[RP1_PLL_SYS].hw } + ), + CLK_DATA(rp1_pll_ph_data, + .name =3D "pll_sys_pri_ph", + .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(PARENT_CLK(1, + { .hw =3D &clk_desc_array[RP1_PLL_SYS_CORE].hw } + ), + CLK_DATA(rp1_pll_data, + .name =3D "pll_sys_sec", + .ctrl_reg =3D PLL_SYS_SEC, + .fc0_src =3D FC_NUM(2, 2), + )), +}; + +static const struct regmap_range rp1_reg_ranges[] =3D { + regmap_reg_range(PLL_SYS_CS, PLL_SYS_SEC), + regmap_reg_range(PLL_AUDIO_CS, PLL_AUDIO_TERN), + regmap_reg_range(PLL_VIDEO_CS, PLL_VIDEO_SEC), + regmap_reg_range(GPCLK_OE_CTRL, GPCLK_OE_CTRL), + regmap_reg_range(CLK_SYS_CTRL, CLK_SYS_DIV_INT), + regmap_reg_range(CLK_SYS_SEL, CLK_SYS_SEL), + regmap_reg_range(CLK_SLOW_SYS_CTRL, CLK_SLOW_SYS_DIV_INT), + regmap_reg_range(CLK_SLOW_SYS_SEL, CLK_SLOW_SYS_SEL), + regmap_reg_range(CLK_DMA_CTRL, CLK_DMA_DIV_INT), + regmap_reg_range(CLK_DMA_SEL, CLK_DMA_SEL), + regmap_reg_range(CLK_UART_CTRL, CLK_UART_DIV_INT), + regmap_reg_range(CLK_UART_SEL, CLK_UART_SEL), + regmap_reg_range(CLK_ETH_CTRL, CLK_ETH_DIV_INT), + regmap_reg_range(CLK_ETH_SEL, CLK_ETH_SEL), + regmap_reg_range(CLK_PWM0_CTRL, CLK_PWM0_SEL), + regmap_reg_range(CLK_PWM1_CTRL, CLK_PWM1_SEL), + regmap_reg_range(CLK_AUDIO_IN_CTRL, CLK_AUDIO_IN_DIV_INT), + regmap_reg_range(CLK_AUDIO_IN_SEL, CLK_AUDIO_IN_SEL), + regmap_reg_range(CLK_AUDIO_OUT_CTRL, CLK_AUDIO_OUT_DIV_INT), + regmap_reg_range(CLK_AUDIO_OUT_SEL, CLK_AUDIO_OUT_SEL), + regmap_reg_range(CLK_I2S_CTRL, CLK_I2S_DIV_INT), + regmap_reg_range(CLK_I2S_SEL, CLK_I2S_SEL), + regmap_reg_range(CLK_MIPI0_CFG_CTRL, CLK_MIPI0_CFG_DIV_INT), + regmap_reg_range(CLK_MIPI0_CFG_SEL, CLK_MIPI0_CFG_SEL), + regmap_reg_range(CLK_MIPI1_CFG_CTRL, CLK_MIPI1_CFG_DIV_INT), + regmap_reg_range(CLK_MIPI1_CFG_SEL, CLK_MIPI1_CFG_SEL), + regmap_reg_range(CLK_PCIE_AUX_CTRL, CLK_PCIE_AUX_DIV_INT), + regmap_reg_range(CLK_PCIE_AUX_SEL, CLK_PCIE_AUX_SEL), + regmap_reg_range(CLK_USBH0_MICROFRAME_CTRL, CLK_USBH0_MICROFRAME_DIV_INT), + regmap_reg_range(CLK_USBH0_MICROFRAME_SEL, CLK_USBH0_MICROFRAME_SEL), + regmap_reg_range(CLK_USBH1_MICROFRAME_CTRL, CLK_USBH1_MICROFRAME_DIV_INT), + regmap_reg_range(CLK_USBH1_MICROFRAME_SEL, CLK_USBH1_MICROFRAME_SEL), + regmap_reg_range(CLK_USBH0_SUSPEND_CTRL, CLK_USBH0_SUSPEND_DIV_INT), + regmap_reg_range(CLK_USBH0_SUSPEND_SEL, CLK_USBH0_SUSPEND_SEL), + regmap_reg_range(CLK_USBH1_SUSPEND_CTRL, CLK_USBH1_SUSPEND_DIV_INT), + regmap_reg_range(CLK_USBH1_SUSPEND_SEL, CLK_USBH1_SUSPEND_SEL), + regmap_reg_range(CLK_ETH_TSU_CTRL, CLK_ETH_TSU_DIV_INT), + regmap_reg_range(CLK_ETH_TSU_SEL, CLK_ETH_TSU_SEL), + regmap_reg_range(CLK_ADC_CTRL, CLK_ADC_DIV_INT), + regmap_reg_range(CLK_ADC_SEL, CLK_ADC_SEL), + regmap_reg_range(CLK_SDIO_TIMER_CTRL, CLK_SDIO_TIMER_DIV_INT), + regmap_reg_range(CLK_SDIO_TIMER_SEL, CLK_SDIO_TIMER_SEL), + regmap_reg_range(CLK_SDIO_ALT_SRC_CTRL, CLK_SDIO_ALT_SRC_DIV_INT), + regmap_reg_range(CLK_SDIO_ALT_SRC_SEL, CLK_SDIO_ALT_SRC_SEL), + regmap_reg_range(CLK_GP0_CTRL, CLK_GP0_SEL), + regmap_reg_range(CLK_GP1_CTRL, CLK_GP1_SEL), + regmap_reg_range(CLK_GP2_CTRL, CLK_GP2_SEL), + regmap_reg_range(CLK_GP3_CTRL, CLK_GP3_SEL), + regmap_reg_range(CLK_GP4_CTRL, CLK_GP4_SEL), + regmap_reg_range(CLK_GP5_CTRL, CLK_GP5_SEL), + regmap_reg_range(CLK_SYS_RESUS_CTRL, CLK_SYS_RESUS_CTRL), + regmap_reg_range(CLK_SLOW_SYS_RESUS_CTRL, CLK_SLOW_SYS_RESUS_CTRL), + regmap_reg_range(FC0_REF_KHZ, FC0_RESULT), + regmap_reg_range(VIDEO_CLK_VEC_CTRL, VIDEO_CLK_VEC_DIV_INT), + regmap_reg_range(VIDEO_CLK_VEC_SEL, VIDEO_CLK_DPI_DIV_INT), + regmap_reg_range(VIDEO_CLK_DPI_SEL, VIDEO_CLK_MIPI1_DPI_SEL), +}; + +static const struct regmap_access_table rp1_reg_table =3D { + .yes_ranges =3D rp1_reg_ranges, + .n_yes_ranges =3D ARRAY_SIZE(rp1_reg_ranges), +}; + +static const struct regmap_config rp1_clk_regmap_cfg =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, + .max_register =3D PLL_VIDEO_SEC, + .name =3D "rp1-clk", + .rd_table =3D &rp1_reg_table, +}; + +static int rp1_clk_probe(struct platform_device *pdev) +{ + const size_t asize =3D ARRAY_SIZE(clk_desc_array); + struct rp1_clk_desc *desc; + struct device *dev =3D &pdev->dev; + struct rp1_clockman *clockman; + 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); + + clockman->regmap =3D devm_regmap_init_mmio(dev, clockman->regs, + &rp1_clk_regmap_cfg); + if (IS_ERR(clockman->regmap)) { + dev_err(dev, "could not init clock regmap\n"); + return PTR_ERR(clockman->regmap); + } + + 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); + if (IS_ERR_OR_NULL(hws[i])) + dev_err_probe(dev, PTR_ERR(hws[i]), + "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, +}; + +module_platform_driver(rp1_clk_driver); + +MODULE_AUTHOR("Naushir Patuck "); +MODULE_AUTHOR("Andrea della Porta "); +MODULE_DESCRIPTION("RP1 clock driver"); +MODULE_LICENSE("GPL"); --=20 2.35.3 From nobody Mon Nov 25 09:22:36 2024 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 B7F6A1DE3B0 for ; Mon, 28 Oct 2024 14:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124452; cv=none; b=MlagGisSjsBeccH6I1MRein188Ypf5SJ1peR1nJZZNeOm5v2eO7PmbnUvYuHYFoua1bdZMN8REG5H6IOi76/YQ6wC6GraQR81fhwRbRmdvBuOypvAwEjN3PXSq7w2Jc6PxjfBLYrit6uTUNXMSaaTcRhQddPzKSbvP74vxSH0mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124452; c=relaxed/simple; bh=mI/xTbztY7xzzMo5N8ceXpphLQ4/wq+Aw1T/ZiUjw80=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QbZqFeuzKLuEFdxrBQ0D3sAF5kqfgXcX6pLDrhO9+PKyUSfwcq8DHWNVb2SeifHvZ7HcDiWz+VKXa6Ou/8Xk8D93fBJGSc7Hq5ldr7KhrMyAGEnMPbdk9Q0F9uthPl0O6Vm2cZtT3xt8uJCxVJp9Rj1+UDw2l9ewuf9sfaPR/5w= 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=bb0qOx8c; arc=none smtp.client-ip=209.85.218.42 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="bb0qOx8c" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a9a4031f69fso588715166b.0 for ; Mon, 28 Oct 2024 07:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124443; x=1730729243; 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=swCBcHFwbpQdYlunV/s1MTQ6ysUtUuoY2KcKt+W3ztU=; b=bb0qOx8c0XnZNoG2jz6nzkE0bdiVYITVUHYvRi+74cuAtjQy2MYBf8hcb9EpSnPezp oBwO0o0VmVHvLDItvcDapyE62nLb1aKyqTHyovRHkYPFv+NCZ1NPu3M7NgmXgRG4Sqfb LN1NlB3F0+OYQmjwqQAIvQatiARpFZnArCdSkMVBDqewquVgQlXg7Q4F7OpqiSUl7HzB a1WIETSJvarJKEuyyGyPLS4I/Yr4af+QNEH9QjGftkKDOj8WBHB4vPxaYxNYMmVeiy8e r2+ZwlHfbQEBhFWNccW0U6PwjyaBI+HiupoKCksPDrymnIUV16DTp+soimluyWsOhphq F0pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124443; x=1730729243; 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=swCBcHFwbpQdYlunV/s1MTQ6ysUtUuoY2KcKt+W3ztU=; b=fFvqC0fvhH2OSKv+ged/vcyXjAvWnyLRb9nDITEvSdmAyMDpxneU4V09BA7IGbJdHr lVbENCoNWgMZBzgFDnYtOTMSG0dTUhFJSXdZjFoCu5jEIn8hooZUXdtXdwVcnrKQqVfi 6qrIUPjVknLBFpYh5WRpkTGpkipYy4cLXTnFa4njxyjO9uNu2rq8ImHrU56itwQOD34l hezsev/S06IN0ai6Ig9Ze0vMqpQHh1T82SPFKP8ekxhBvHf1UQIYDRQkw2D4AKdlkdAM /BdyoePODxmWM2uiuLgop9+vHyQnFH2JwVrG1fN/zvSc358Ea//LKylrvmED6BwgGktC Ikfw== X-Forwarded-Encrypted: i=1; AJvYcCWwQTRY59qXNrzhwJUv4zRrVwBn0K+0hfM2z4szIR4b3bg74vmuMPIsK/l8isjYtShFym969EIX2WyOJ8A=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+WLzx3mFBiiYDSxOepsADn2be0jSA02mYiH1+/7BGjUVfpQhV qXylxTC96im72RwQLkdSfcpElqEqIWz2mkj0Cnw7ir6KCcg1lXnjZAbdZ2Na/m8= X-Google-Smtp-Source: AGHT+IGiitqycYCo3/lyoN3sj+Fb/wx8xhVEFZbV0XiyUCPIFMr64YsrwaAk6d7PqXLF1p56ePIhvQ== X-Received: by 2002:a17:907:7e8b:b0:a99:fd32:11dc with SMTP id a640c23a62f3a-a9de5d858aemr792499666b.24.1730124443374; Mon, 28 Oct 2024 07:07:23 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a084b10sm383779866b.195.2024.10.28.07.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:23 -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 , Krzysztof Wilczynski , 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 v3 08/12] pinctrl: rp1: Implement RaspberryPi RP1 gpio support Date: Mon, 28 Oct 2024 15:07:25 +0100 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 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 Reviewed-by: Linus Walleij --- MAINTAINERS | 1 + drivers/pinctrl/Kconfig | 11 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-rp1.c | 801 ++++++++++++++++++++++++++++++++++ 4 files changed, 814 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..853091893eeb --- /dev/null +++ b/drivers/pinctrl/pinctrl-rp1.c @@ -0,0 +1,801 @@ +// 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 + +#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]; +}; + +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 struct rp1_pinctrl rp1_pinctrl_data =3D {}; + +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; + } + + 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 Mon Nov 25 09:22:36 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 DC3631DE4CD for ; Mon, 28 Oct 2024 14:07:27 +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=1730124452; cv=none; b=s4ho+mF93VT9/8IxMZCjI+DknaSg/oaO4VvQQP4c0YNUPvSHTAzPEMDho6hRKlj/R3UmaPr5FUtgjbvLWfwgabB4w59zukpmo6Ppp5PEnEqO0VOa9K+5j7M8jLPwphyDke7x5oSgkry3jMheSsikKH/bn7TSHRqBtWVImI44bMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124452; c=relaxed/simple; bh=jVpFSFjRvCO431pFJM5NtQyQ/ko6vIsiLp52mklCu98=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oSg0+hqYXo3cRQtImLUy5/8+rAZZCiPE+uYhYpPlL26l7BcshTHSJFwlyR+Pf6zOjwPtIQrxZVBxrgb04uUVBg8ki+d94tpQ3dNIJHtvU+e+TS08YbL0garBvrTKughXa89TK1e9mPEexPQw0CPvfoVW/nOKEE1n3IM1fwxrf7Y= 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=SMecslP5; 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="SMecslP5" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a9acafdb745so782279566b.0 for ; Mon, 28 Oct 2024 07:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124445; x=1730729245; 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=nVZZiKyJj7ZnmSyKDxiL2Ewqy8l9yzTHRtpEpGvvetk=; b=SMecslP5R+XHNDJJDRWjDaPp0yrVA66icFom+/n2LAvdC5i6tr67KO6e6M8pi99om8 EX8I0CuW83XGmvWJcTJE8OUGjh8Ugceo6LqmmdE7TFrXthgeGTxG8j99HMndi3+o/Czr vUuVd6ts9DdMJM5HnlX4Ns1ChGNqGIU9GM4ifn4WcgZgwbxfDzvMlvXOdqkQMnZRZ8oI ttI0wQ0IUWoerN3nlfjeqGDLIqv3MRpITPDrD6CHwWpBYqAo1qy429TecWu8oq3KDVf/ Id6yvj5xXBGazXhXcKeyA4N/S/JM83J9MnHaApCktpqHZe5MqoiR1XGT6nA0zZervsko pw3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124445; x=1730729245; 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=nVZZiKyJj7ZnmSyKDxiL2Ewqy8l9yzTHRtpEpGvvetk=; b=iEMqQtqnjCPgdVERHwPX1L3ie2cP9zyXU5q/Rfx0KH3hfbMHu/pxSMLbq7v2sB3l7O QdIo5ita9W8qw/TVUkm2ejhn7pIL+Vau8yItN92b15XuROsNe85fVXlV1gQyXjse/Q5C 80IPB4SvtMemLXCgB3sj+YdGj1wSFTvCxF1/n2rhf5bwP/Rxa9YlC9e6EVsWBRURQwfI tsKAhSmxE97RztlgY3Ajc+lI4XlTeKbE6V69ArTUe5scKUKDg68F2akFvHX2W1R32a/H IPTWeFBLawiasHDVP8ML04DgcIAuRaiHG5fwVxucYbsQpjJGttI6Eks9tsL9XN3ThOjK VUnA== X-Forwarded-Encrypted: i=1; AJvYcCXWp65PO8t7lQwKwWx6EaCtW3crEK4ljIF768FRWksDN3J1MYvHCbeECmyxWpv8PG1Ywzdcfw1b4eC5Rpg=@vger.kernel.org X-Gm-Message-State: AOJu0YzERnHIeNQfS3b9R1SX5SYBTsse5OZyBpGZ1YM90WUmaFRv2Npl nGHdxcz/Rv6lYsAGEXvTqkstE6u2+QOzVuxQ4fHB4s1opiqgFFyoCASw8uaroTU= X-Google-Smtp-Source: AGHT+IEQdbITjqhgIXETXbiDGS9CpxFITbMxPJxEoYU59S+9lkAwLuR8Fmvi9lRxn9X6MPz0PlOOOw== X-Received: by 2002:a17:907:1c92:b0:a99:f9fa:5c01 with SMTP id a640c23a62f3a-a9de391b292mr763533366b.32.1730124445300; Mon, 28 Oct 2024 07:07:25 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec7d16sm378731766b.21.2024.10.28.07.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:24 -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 , Krzysztof Wilczynski , 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 v3 09/12] arm64: dts: rp1: Add support for RaspberryPi's RP1 device Date: Mon, 28 Oct 2024 15:07:26 +0100 Message-ID: <1f4cec50493ec5d3168735c0a005771787e5cd59.1730123575.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 v3 10/12] misc: rp1: RaspberryPi RP1 misc driver", since they are closely related in terms of compiling. MAINTAINERS | 1 + arch/arm64/boot/dts/broadcom/rp1.dtso | 61 +++++++++++++++++++++++++++ 2 files changed, 62 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..8d1bbf207a30 --- /dev/null +++ b/arch/arm64/boot/dts/broadcom/rp1.dtso @@ -0,0 +1,61 @@ +// 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>; + interrupt-controller; + #interrupt-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>; + + 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 "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 Mon Nov 25 09:22:36 2024 Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) (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 B0A1F1DE4DA for ; Mon, 28 Oct 2024 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124456; cv=none; b=N1R7H3O/sSLqdv7rdR32q+d42TcLPSpI/qTNc4KpYY0IBdh1u8+eyCWZPCA8grzWyZ1MCf9PyChST/q+FA0z7TVEqMbvQ7fq+j+S2nVURDGPf1a/TfpKDbAqaAS81d/MjJIFYIhb1fYZIG+nMs5yhv4BQbMqumd4umkRwNTXlrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124456; c=relaxed/simple; bh=t2Vr6kACCbn7a/MkxQ6eYT0hvLRwerI3EiUqhA8OyFw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QqAvrARwcMSH8GQbvpLTOFIf4K5IoDpBBu2zPazf+OKaByVSyCAWXbgG6ZWfW5FhD3GXWKtUHZmw+3V+m5/yBjVguDKXvf/OgeAS5ajb1WrJnYkzB0bYZhLmUcDEfP7AwsoJ245eS3QGvXvqt0u2+rXN+SGPGtT/m8sJDfvdkZY= 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=B/fNBldX; arc=none smtp.client-ip=209.85.218.66 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="B/fNBldX" Received: by mail-ej1-f66.google.com with SMTP id a640c23a62f3a-a9a0c7abaa6so533327966b.2 for ; Mon, 28 Oct 2024 07:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124446; x=1730729246; 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=/74YIWp0Vu7VBNMPZTV3EIK/YW6CtY9LVf+6E8zo6K0=; b=B/fNBldXXjAI4OXjStQmLeO3A4kzaHlwz2bMJ112Q/JJUDCqBo3OPpPBdi6zHeK4WC 6jqqA+DJhfmvgzs9WkhEW0KqOi8tEU/6kq6z209HcmGzbpwYjvJkLErHKQcZZMakEIs/ QtiSAdFTMTUFDQhFTGuICtQneus8l5h0CX6+fRlRJoenAXGkOnJVfgYotL5klKAqLmxh 2nP1CZ8WD4AaWag8T7QyVPY5B19siwKP0bkGXmSt+8eUKAvHfPIdLXv1gBDJ5TKqTAls NG/drMcFduRQbja8/D4RwOTUpERTVl5Oebf5mCns9MST+lsCX2jxScsnLtU05pPMmL74 aWMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124446; x=1730729246; 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=/74YIWp0Vu7VBNMPZTV3EIK/YW6CtY9LVf+6E8zo6K0=; b=USO+B40jLwRK381rZ8J8Ues9ymrs8k2Q9i8sjy7DTtkCywM1NxeHNlg02N4VKZxDpc P/2H2OBD9ssG36uFuD18I48XXTC/MU2HNQ7gVReg5lWNWvmggwZi6N2fG0m215i+lJPL Hr0WASn77VvE2aFoLuPCGzZFLPDBbeE25uv47VIsE4CDizt2DkWtNHBipaSeNHetP6xm QGxSZtBdfC8gj25pS7R24I7Q/WkymwN1DV3TC/VWjcpjH3sq80cdWh3j9m0vJqtnFIlQ dlWx9MqME9YipKb+XcJlAAqLHdPwfjgDcvrAENaBqRFFYV0Z9W0TMfuXpBC6bjoX7idT eQQg== X-Forwarded-Encrypted: i=1; AJvYcCXRqQGORlPpEh4yOKMIUlOISRexf8Dz03rkgIunmmhLLfvIbcO1rR2gfZk3mYa5ZAemBGSjEq3V87QwpV8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/PyvUuhI4S5HN5oEBlL8l/NVIO2b+e1THIgFEjo+3Y4v/aj3n 1Y3/MCVcF1g4lqPK+X9Ky8Y0U6UdeaGw+B8HuZOEaEilD1RGh3eNkD3RKGmFo0A= X-Google-Smtp-Source: AGHT+IHL72GN1t1uGBFid4CxIl3dKxzcBO57JgXyp44AzWRFg7IkwArUKacdjy8qFRCMW8jyW3KV6g== X-Received: by 2002:a17:906:f591:b0:a9a:9df:5581 with SMTP id a640c23a62f3a-a9de5ee8bacmr804767766b.38.1730124446467; Mon, 28 Oct 2024 07:07:26 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b30e64473sm381570266b.174.2024.10.28.07.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:26 -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 , Krzysztof Wilczynski , 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 v3 10/12] misc: rp1: RaspberryPi RP1 misc driver Date: Mon, 28 Oct 2024 15:07:27 +0100 Message-ID: <66f17842775bf03defd1f5cad41fada0f2b97bdc.1730123575.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 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 | 21 ++ drivers/misc/rp1/Makefile | 3 + drivers/misc/rp1/rp1-pci.dtso | 8 + drivers/misc/rp1/rp1_pci.c | 357 ++++++++++++++++++++++++++++++++++ drivers/misc/rp1/rp1_pci.h | 14 ++ drivers/pci/quirks.c | 1 + include/linux/pci_ids.h | 3 + 10 files changed, 410 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..39c4aa4bf634 --- /dev/null +++ b/drivers/misc/rp1/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# RaspberryPi RP1 misc device +# + +config MISC_RP1 + tristate "RaspberryPi RP1 PCIe support" + depends on OF_IRQ && PCI_MSI && PCI_QUIRKS + select OF_OVERLAY + 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..508b4cb05627 --- /dev/null +++ b/drivers/misc/rp1/Makefile @@ -0,0 +1,3 @@ +# 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 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..30d7a15dc7f1 --- /dev/null +++ b/drivers/misc/rp1/rp1_pci.c @@ -0,0 +1,357 @@ +// 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 "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 irq_domain *domain; + struct irq_data *pcie_irqds[64]; + void __iomem *bar1; + int ovcs_id; + bool level_triggered_irq[RP1_INT_END]; +}; + +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 void rp1_unregister_interrupts(struct pci_dev *pdev) +{ + struct rp1_dev *rp1 =3D pci_get_drvdata(pdev); + int irq, i; + + for (i =3D 0; i < RP1_INT_END; i++) { + irq =3D irq_find_mapping(rp1->domain, i); + irq_dispose_mapping(irq); + } + irq_domain_remove(rp1->domain); + pci_free_irq_vectors(pdev); +} + +static int rp1_probe(struct pci_dev *pdev, const struct pci_device_id *id) +{ + u32 dtbo_size =3D __dtbo_rp1_pci_end - __dtbo_rp1_pci_begin; + void *dtbo_start =3D __dtbo_rp1_pci_begin; + struct device *dev =3D &pdev->dev; + struct device_node *rp1_node; + 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; + + 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; + } + + 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); + return err; + } + + pci_set_drvdata(pdev, rp1); + rp1->domain =3D irq_domain_add_linear(rp1_node, 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_overlay_fdt_apply(dtbo_start, dtbo_size, &rp1->ovcs_id, rp1_no= de); + if (err) + goto err_unregister_interrupts; + + 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); +err_unregister_interrupts: + rp1_unregister_interrupts(pdev); + + 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); + rp1_unregister_interrupts(pdev); +} + +static const struct pci_device_id dev_id_table[] =3D { + { PCI_DEVICE(PCI_VENDOR_ID_RPI, PCI_DEVICE_ID_RPI_RP1_C0), }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, dev_id_table); + +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 Mon Nov 25 09:22:36 2024 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.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 CA00D1DDA31 for ; Mon, 28 Oct 2024 14:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124457; cv=none; b=T9ewEZXkwsnzxNaSx0/xtLFJD7Q9IiKmKft5lCLm5pK7Re7cbo+rfwXz99/+XaPU35cy95m9b3rpGnwMhwP96QcbAiWjhyEUD5/3hbVtAZAcAAKCWNp4oNeTRhALxGgguBmVyJfldaAwKepfccAb98gciR+TKVpVYCJnAXtHSXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124457; c=relaxed/simple; bh=rKJ6g2zPe+AmVP+2VuYqwsDW7Vw/1jwj4Zek+anRIcU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DmeVn8MWRhegHs7VGGFLKYcx7gncqbn/vUAnA9vHnh0AO6g7AwP7DBGU7OLgBYwR+4WGAfFDgTb94ZgZA4xg+seADW+oJAB9CEOv0Ul4zyqeTL+yJT+nwxIcvp43sHVIBvtSxcPBUufFsydaC3Z8YBajSaEQLlCJuA1LHGQb+Vg= 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=K8FS8A5p; arc=none smtp.client-ip=209.85.208.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="K8FS8A5p" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5cb72918bddso5750514a12.3 for ; Mon, 28 Oct 2024 07:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124448; x=1730729248; 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=K8FS8A5pzi2HL1uN/tNmS6bsPHpWmMmY3ix81otlH3SH0FMyrYmuR0M/5e4rwS4nsi BxOMelx4sWzG3IsM/Anz3uSIGX1DczEkCG0j9kd1clHRr76+6ei4ZsFv0coMInojadhT alBQua7+yax9fgncMlHN+QvJ1s17GLDJdHUE07sVdJdqPttZGcLCO2DSNTMnSStd7kRO mVuUwiOTqgiIvn4ijywa6XQvsHOK/AeULfKY3oQ0ejRQwUb4vZFbwz1RK25tTAkaaAFJ X+cfLitMl5FGX2viMmU4FRh3qnZI6I/Xcl/KlBoxmUJhb9non9TZZqNtIOcZgx2tTTtt KCmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124448; x=1730729248; 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=wSPLsQQGNCjo+0GiQ2MTMhq81tLLwfVBfuw6QuqsRBBVjoF2f1ZBgN3SoAMq/njWbj p2grzBVKYnS8sZ2UIYQBJh6bcrDJ1Ugh0YY8EYzkoYYqkmkneEvWk55xR1UVAWI0HSh+ EVX7g0nBaLQQ5UNo8xOdRo2i/Wt+zyka1YS8ozBV0ObOk3tvYaHP8ecXapmRjcytRkJ4 tn8Ol2Y5+2mJHjU3dBnCE1AzBS05JgBSmmuYsuB1JsMxHReF4LuZvFJyTZnbG2OhJb/6 O2AjGdqA6NkMy42jhw8NOof49/yXWMoPyLf1Vv8b1h1mJaOMrscyriVGr2HADyYD46L0 4Y8A== X-Forwarded-Encrypted: i=1; AJvYcCVSkK3iAljAfPXjPUyy72DQPE75mY5sOGF+Y17swmvadjPn+6zfpCMPP9aFOg0DBP2jatBuFFYzqXmv+pU=@vger.kernel.org X-Gm-Message-State: AOJu0YxZChSm+jGR8tKYMCsd58q8FP9SXrsAwjjm4qgwMQIouM+C9Zzj uhAvtHnAlbyYRHilbSOrRgvRWRhqJlvI35+6NoxF2FmkwXWM+nHmk9/6skUjy0s= X-Google-Smtp-Source: AGHT+IGfZma7X0ezVVYvvMm++bwyKvKeoZexLczbfZgPE9InzBp7Q/p9irVjhvXQTbzMj3l4IWc0BQ== X-Received: by 2002:a17:907:9608:b0:a9a:835:b4eb with SMTP id a640c23a62f3a-a9de5fa6071mr718089466b.38.1730124447425; Mon, 28 Oct 2024 07:07:27 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f029559sm380642166b.58.2024.10.28.07.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:27 -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 , Krzysztof Wilczynski , 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 v3 11/12] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5 Date: Mon, 28 Oct 2024 15:07:28 +0100 Message-ID: <13ad41f172cc8605cb9b324ea0f22296c4c97033.1730123575.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 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 Mon Nov 25 09:22:36 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 D2A901DE880 for ; Mon, 28 Oct 2024 14:07:32 +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=1730124457; cv=none; b=bpu2n9aTWO+HWzy/MezHb8lSlx+4K+4KFXgYpdILh0GnVF4tG+tRqMMUHTmquuXVc0Oo3SSrSF13MVKiHBGMN2eR2x5m5G5misAcwRLRtp4Thcv/zCNb3uI/mbKAksnPHVl7AdTlyu/HU9JY7TwfN1S/j4aSm9E1UNf/Vseg7ZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730124457; c=relaxed/simple; bh=mkLhLwSMHZ/hO35qXKlv3paIFazWoum0UehyHiC/QB0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J7hcHKVoyJtfz+779WXvVfMwb04bNNbKXUvFG4f0qGHAiUEl7naJe0Ck0Z9f+ySx5bfHH2CWPJ2m4wo0kCgt1Y7TKQ8bnaYAKmRKMSp69TqHdfrvI2NwAaCZIK/hj6wiQmp5zfTcYRz6TR129xi61m9pHY+VvNI0+kROjqF9HPc= 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=OAydYTtx; 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="OAydYTtx" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a9a68480164so603345366b.3 for ; Mon, 28 Oct 2024 07:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730124449; x=1730729249; 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=OAydYTtxT6dF0EJD6oJ2Gfci6sL/wr3lJitPSXu3cOeLjqixfX2bMIw3u6T6bVOdkc IXzif3HHy8MK82ptdUmZUBQftf1Mpr9y207rjJTvxzYGXHaSUmA3/4b7S24lVWGwq1Z4 gB+dNI94oZMOz2hvgNStNuzB1Il5SvO0jQFKrprX7BGZSZcTnfcp6wdLnB0tmbTMNK3H MYEFi2fJPlG+RY3tMmKoiWteE87gUntHgMGnTLXL/SwCFAeiOTFSXhxN0pm4I/LqlNws Er6+pC7IHlzpMxvrDdSVRg858gOWkr8ZfkrWTuxG0Dg3p7xkDd2Lni9rnypPFNe8tLNd nZGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730124449; x=1730729249; 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=iXsxa8IDlfYJkkUSRYwHOSnQmiTo0TTS6TP963+0E6hvM5MNBGzsUBWHWR4bQs0QFm MRAXizVV1O34hV4ZVJMcV5wxnxE/NtVUvJE+eUV7JhqRfAbmusMkC93wJb/2eELYHR+U y1rcvbIPsThxEf4A7+rsj5u+oIzUjPfhH1WT1NLpQZ/MVLtasDEHikZYBIcxTM2POZ5v HDK+xNqSU8/oq3sK41l/yOXEWdz89VGxeRmGiT8RksWRbbKmGVwqlTUixk/37/WVDwRN S53znFqMWeOsDxbsHUR6fhD/Xe5mmS2FkMmYoiNE6T0gJC3ENgXuBVZPtf8nbXam6uJz WREg== X-Forwarded-Encrypted: i=1; AJvYcCX7JpFiM2lCWNDMwNf4lhITTxhlrthjkUyx3ba6hq64rjkZN541/6D0X/cBOwAJ+9FOzx+Z0jUWAl51/PI=@vger.kernel.org X-Gm-Message-State: AOJu0YzcaqMzdWp2DkMO5GjRVtByODe9ZRzEmSwveu1a4wxsX0oGdE26 UeMKvbHmIPhbFTmKesnjN3m2lDV+GjmhX+1k2bMZMzKdHFbqg0BMJCdYa70ctkA= X-Google-Smtp-Source: AGHT+IGqxvdjrDjtQcNnn4jWGuT849mWymPdjWEdlc16+0LL2sooJ9QKroNYPN94MhkXvqI/l5IquA== X-Received: by 2002:a17:907:970a:b0:a9a:4a:284a with SMTP id a640c23a62f3a-a9de5d8690amr826616066b.26.1730124449033; Mon, 28 Oct 2024 07:07:29 -0700 (PDT) Received: from localhost (host-79-35-211-193.retail.telecomitalia.it. [79.35.211.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297a9csm374074266b.126.2024.10.28.07.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 07:07:28 -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 , Krzysztof Wilczynski , 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 v3 12/12] arm64: defconfig: Enable RP1 misc/clock/gpio drivers Date: Mon, 28 Oct 2024 15:07:29 +0100 Message-ID: <53f9c2cc91403070475ce01e2f1491e09abea72e.1730123575.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