Skip to contentSkip to conversation

IPQ40xx: Improve support

PATCH New Robert Marko 3 participants 15 messages Oct 8, 2020 – Dec 14, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover IPQ40xx: Improve support

This is a third patch series working towards providing a usable U-boot support for Qualcomm IPQ40xx SoC-s.

This patch series adds SPI driver so booting is finally possible, RNG driver for the built in pseudo RNG and MDIO driver to prepare for future ethernet support.

Booting Linux is now possible.

Robert Marko (6):
spi: Add Qualcomm QUP SPI controller driver
IPQ40xx: Add SPI support
net: Add IPQ40xx MDIO driver
IPQ40xx: Add support for MDIO
rng: Add Qualcomm MSM PRNG driver
IPQ40xx: Add PRNG support

 MAINTAINERS                              |   3 +
 arch/arm/dts/qcom-ipq4019.dtsi           |  47 ++
 arch/arm/mach-ipq40xx/clock-ipq4019.c    |  21 +-
 arch/arm/mach-ipq40xx/pinctrl-ipq4019.c  |   7 +
 doc/device-tree-bindings/spi/spi-qup.txt |  33 +
 drivers/net/Kconfig                      |   7 +
 drivers/net/Makefile                     |   1 +
 drivers/net/mdio-ipq4019.c               | 146 +++++
 drivers/rng/Kconfig                      |   7 +
 drivers/rng/Makefile                     |   1 +
 drivers/rng/msm_rng.c                    | 143 ++++
 drivers/spi/Kconfig                      |  10 +
 drivers/spi/Makefile                     |   1 +
 drivers/spi/spi-qup.c                    | 803 +++++++++++++++++++++++
 14 files changed, 1228 insertions(+), 2 deletions(-)
 create mode 100644 doc/device-tree-bindings/spi/spi-qup.txt
 create mode 100644 drivers/net/mdio-ipq4019.c
 create mode 100644 drivers/rng/msm_rng.c
 create mode 100644 drivers/spi/spi-qup.c
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/6 spi: Add Qualcomm QUP SPI controller driver

This patch adds support for the Qualcomm QUP SPI controller that is commonly found in most of Qualcomm SoC-s.

Driver currently supports v1.1.1, v2.1.1 and v2.2.1 HW.
FIFO and Block modes are supported, no support for DMA mode is planned.

---
 MAINTAINERS                              |   1 +
 doc/device-tree-bindings/spi/spi-qup.txt |  33 +
 drivers/spi/Kconfig                      |  10 +
 drivers/spi/Makefile                     |   1 +
 drivers/spi/spi-qup.c                    | 803 +++++++++++++++++++++++
 5 files changed, 848 insertions(+)
 create mode 100644 doc/device-tree-bindings/spi/spi-qup.txt
 create mode 100644 drivers/spi/spi-qup.c
MAINTAINERS +1 -0
index ed5e354873..aa6cbb965d 100644
@@ -241,6 +241,7 @@ F:	include/dt-bindings/clock/qcom,ipq4019-gcc.h
 F:	include/dt-bindings/reset/qcom,ipq4019-reset.h
 F:	drivers/reset/reset-ipq4019.c
 F:	drivers/phy/phy-qcom-ipq4019-usb.c
+F:	drivers/spi/spi-qup.c
 
 ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X ARMADA-37XX ARMADA-7K/8K
 M:	Stefan Roese <[email protected]>
doc/device-tree-bindings/spi/spi-qup.txt new file +33 -0
new file mode 100644
index 0000000000..3697df2631
@@ -0,0 +1,33 @@
+Qualcomm QUP SPI controller Device Tree Bindings
+-------------------------------------------
+
+Required properties:
+- compatible : Should be "qcom,spi-qup-v1.1.1", "qcom,spi-qup-v2.1.1"
+				or "qcom,spi-qup-v2.2.1"
+- reg : Physical base address and size of SPI registers map.
+- clock	: Clock phandle (see clock bindings for details).
+- #address-cells : Number of cells required to define a chip select
+                	address on the SPI bus. Should be set to 1.
+- #size-cells : Should be zero.
+- pinctrl-names : Must be "default"
+- pinctrl-n : At least one pinctrl phandle
+- cs-gpios : Should specify GPIOs used for chipselects.
+				The gpios will be referred to as reg = <index> in the
+				SPI child nodes.
+
+Optional properties:
+- num-cs : total number of chipselects
+
+Example:
+
+	blsp1_spi1: spi at 78b5000 {
+		compatible = "qcom,spi-qup-v2.2.1";
+		reg = <0x78b5000 0x600>;
+		clock = <&gcc 23>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		pinctrl-names = "spi";
+		pinctrl-0 = <&blsp_spi0>;
+		num-cs = <2>;
+		cs-gpios = <&soc_gpios 54 GPIO_ACTIVE_HIGH>, <&soc_gpios 4 GPIO_ACTIVE_HIGH>;
+	};
drivers/spi/Kconfig +10 -0
index 5df97c80fa..f7a9852565 100644
@@ -271,6 +271,16 @@ config PL022_SPI
 	  controller. If you have an embedded system with an AMBA(R)
 	  bus and a PL022 controller, say Y or M here.
 
+config SPI_QUP
+	bool "Qualcomm SPI controller with QUP interface"
+	depends on ARCH_IPQ40XX
+	help
+	  Qualcomm Universal Peripheral (QUP) core is an AHB slave that
+	  provides a common data path (an output FIFO and an input FIFO)
+	  for serial peripheral interface (SPI) mini-core. SPI in master
+	  mode supports up to 50MHz, up to four chip selects, programmable
+	  data path from 4 bits to 32 bits and numerous protocol variants.
+
 config RENESAS_RPC_SPI
 	bool "Renesas RPC SPI driver"
 	depends on RCAR_GEN3 || RZA1
drivers/spi/Makefile +1 -0
index b5c9ff1af8..d9b5bd9b79 100644
@@ -47,6 +47,7 @@ obj-$(CONFIG_OCTEON_SPI) += octeon_spi.o
 obj-$(CONFIG_OMAP3_SPI) += omap3_spi.o
 obj-$(CONFIG_PIC32_SPI) += pic32_spi.o
 obj-$(CONFIG_PL022_SPI) += pl022_spi.o
+obj-$(CONFIG_SPI_QUP) += spi-qup.o
 obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o
 obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o
 obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o
drivers/spi/spi-qup.c new file +803 -0

803 lines not on this page · raw message

Signature · 1 line
2.28.0
#2 lore raw

PATCH 1/6 spi: Add Qualcomm QUP SPI controller driver

Quoted 8 lines · Robert Marko

This patch adds support for the Qualcomm QUP SPI controller that is commonly found in most of Qualcomm SoC-s.

Driver currently supports v1.1.1, v2.1.1 and v2.2.1 HW.
FIFO and Block modes are supported, no support for DMA mode is planned.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/9c4a41a9/attachment.sig>
#3 lore raw

PATCH 2/6 IPQ40xx: Add SPI support

In reply to Robert Marko

Since we have SPI driver for IPQ40xx QUP SPI controller, lets add the necessary nodes, pinctrl and clocks.

---
 arch/arm/dts/qcom-ipq4019.dtsi          | 12 ++++++++++++
 arch/arm/mach-ipq40xx/clock-ipq4019.c   | 17 +++++++++++++++--
 arch/arm/mach-ipq40xx/pinctrl-ipq4019.c |  3 +++
 3 files changed, 30 insertions(+), 2 deletions(-)
arch/arm/dts/qcom-ipq4019.dtsi +12 -0
index e0e4188e5d..936ef74f94 100644
@@ -22,6 +22,7 @@
 
 	aliases {
 		serial0 = &blsp1_uart1;
+		spi0 = &blsp1_spi1;
 	};
 
 	reserved-memory {
@@ -89,6 +90,17 @@
 			gpio-count = <100>;
 			gpio-bank-name="soc";
 			#gpio-cells = <2>;
+			u-boot,dm-pre-reloc;
+		};
+
+		blsp1_spi1: spi at 78b5000 {
+			compatible = "qcom,spi-qup-v2.2.1";
+			reg = <0x78b5000 0x600>;
+			clocks = <&gcc GCC_BLSP1_QUP1_SPI_APPS_CLK>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+			u-boot,dm-pre-reloc;
 		};
 
 		usb3_ss_phy: ssphy at 9a000 {
arch/arm/mach-ipq40xx/clock-ipq4019.c +15 -2
index 83a688e625..d5b5f4cb79 100644
@@ -2,7 +2,7 @@
 /*
  * Clock drivers for Qualcomm IPQ40xx
  *
- * Copyright (c) 2019 Sartura Ltd.
+ * Copyright (c) 2020 Sartura Ltd.
  *
  * Author: Robert Marko <[email protected]>
  *
@@ -24,7 +24,7 @@ ulong msm_set_rate(struct clk *clk, ulong rate)
 	switch (clk->id) {
 	case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/
 		/* This clock is already initialized by SBL1 */
-		return 0; 
+		return 0;
 		break;
 	default:
 		return 0;
@@ -47,8 +47,21 @@ static ulong msm_clk_set_rate(struct clk *clk, ulong rate)
 	return msm_set_rate(clk, rate);
 }
 
+static int msm_enable(struct clk *clk)
+{
+	switch (clk->id) {
+	case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/
+		/* This clock is already initialized by SBL1 */
+		return 0;
+		break;
+	default:
+		return 0;
+	}
+}
+
 static struct clk_ops msm_clk_ops = {
 	.set_rate = msm_clk_set_rate,
+	.enable = msm_enable,
 };
 
 static const struct udevice_id msm_clk_ids[] = {
arch/arm/mach-ipq40xx/pinctrl-ipq4019.c +3 -0
index 06a57f2e5e..1f283516cb 100644
@@ -18,6 +18,9 @@ static const struct pinctrl_function msm_pinctrl_functions[] = {
 	{"blsp_uart0_0", 1}, /* Only for GPIO:16,17 */
 	{"blsp_uart0_1", 2}, /* Only for GPIO:60,61 */
 	{"blsp_uart1", 1},
+	{"blsp_spi0_0", 1}, /* Only for GPIO:12,13,14,15 */
+	{"blsp_spi0_1", 2}, /* Only for GPIO:54,55,56,57 */
+	{"blsp_spi1", 2},
 };
 
 static const char *ipq4019_get_function_name(struct udevice *dev,
Signature · 1 line
2.28.0
#4 lore raw

PATCH 2/6 IPQ40xx: Add SPI support

Quoted 4 lines · Robert Marko

Since we have SPI driver for IPQ40xx QUP SPI controller, lets add the necessary nodes, pinctrl and clocks.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/d029eeda/attachment.sig>
#5 lore raw

PATCH 3/6 net: Add IPQ40xx MDIO driver

In reply to Robert Marko

This adds the driver for the IPQ40xx built-in MDIO. This will be needed to support future PHY driver.

---
 MAINTAINERS                |   1 +
 drivers/net/Kconfig        |   7 ++
 drivers/net/Makefile       |   1 +
 drivers/net/mdio-ipq4019.c | 146 +++++++++++++++++++++++++++++++++++++
 4 files changed, 155 insertions(+)
 create mode 100644 drivers/net/mdio-ipq4019.c
MAINTAINERS +1 -0
index aa6cbb965d..5f1a815c88 100644
@@ -242,6 +242,7 @@ F:	include/dt-bindings/reset/qcom,ipq4019-reset.h
 F:	drivers/reset/reset-ipq4019.c
 F:	drivers/phy/phy-qcom-ipq4019-usb.c
 F:	drivers/spi/spi-qup.c
+F:	drivers/net/mdio-ipq4019.c
 
 ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X ARMADA-37XX ARMADA-7K/8K
 M:	Stefan Roese <[email protected]>
drivers/net/Kconfig +7 -0
index a0d2d21a55..09a4688d69 100644
@@ -701,6 +701,13 @@ config MDIO_MUX_I2CREG
 	  an I2C chip.  The board it was developed for uses a mux controlled by
 	  on-board FPGA which in turn is accessed as a chip over I2C.
 
+config MDIO_IPQ4019
+	bool "Qualcomm IPQ4019 MDIO interface support"
+	depends on DM_MDIO
+	help
+	  This driver supports the MDIO interface found in Qualcomm
+	  IPQ40xx series Soc-s.
+
 config MVMDIO
 	bool "Marvell MDIO interface support"
 	depends on DM_MDIO
drivers/net/Makefile +1 -0
index 03f01921ea..9cd4b36f57 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_LAN91C96) += lan91c96.o
 obj-$(CONFIG_LPC32XX_ETH) += lpc32xx_eth.o
 obj-$(CONFIG_MACB) += macb.o
 obj-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
+obj-$(CONFIG_MDIO_IPQ4019) += mdio-ipq4019.o
 obj-$(CONFIG_MDIO_MUX_I2CREG) += mdio_mux_i2creg.o
 obj-$(CONFIG_MDIO_MUX_SANDBOX) += mdio_mux_sandbox.o
 obj-$(CONFIG_MPC8XX_FEC) += mpc8xx_fec.o
drivers/net/mdio-ipq4019.c new file +146 -0

146 lines not on this page · raw message

Signature · 1 line
2.28.0
#6 lore raw

PATCH 3/6 net: Add IPQ40xx MDIO driver

Quoted 5 lines · Robert Marko

This adds the driver for the IPQ40xx built-in MDIO. This will be needed to support future PHY driver.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/9443b6be/attachment.sig>
#7 lore raw

PATCH 4/6 IPQ40xx: Add support for MDIO

In reply to Robert Marko

Lets add the necessary DTS node and pinctrl properties for newly added MDIO driver.

---
 arch/arm/dts/qcom-ipq4019.dtsi          | 28 +++++++++++++++++++++++++
 arch/arm/mach-ipq40xx/pinctrl-ipq4019.c |  4 ++++
 2 files changed, 32 insertions(+)
arch/arm/dts/qcom-ipq4019.dtsi +28 -0
index 936ef74f94..031691e5d2 100644
@@ -103,6 +103,34 @@
 			u-boot,dm-pre-reloc;
 		};
 
+		mdio: mdio at 90000 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			compatible = "qcom,ipq4019-mdio";
+			reg = <0x90000 0x64>;
+			status = "disabled";
+
+			ethphy0: ethernet-phy at 0 {
+				reg = <0>;
+			};
+
+			ethphy1: ethernet-phy at 1 {
+				reg = <1>;
+			};
+
+			ethphy2: ethernet-phy at 2 {
+				reg = <2>;
+			};
+
+			ethphy3: ethernet-phy at 3 {
+				reg = <3>;
+			};
+
+			ethphy4: ethernet-phy at 4 {
+				reg = <4>;
+			};
+		};
+
 		usb3_ss_phy: ssphy at 9a000 {
 			compatible = "qcom,usb-ss-ipq4019-phy";
 			#phy-cells = <0>;
arch/arm/mach-ipq40xx/pinctrl-ipq4019.c +4 -0
index 1f283516cb..3e365f8cc8 100644
@@ -21,6 +21,10 @@ static const struct pinctrl_function msm_pinctrl_functions[] = {
 	{"blsp_spi0_0", 1}, /* Only for GPIO:12,13,14,15 */
 	{"blsp_spi0_1", 2}, /* Only for GPIO:54,55,56,57 */
 	{"blsp_spi1", 2},
+	{"mdio_0", 1}, /* Only for GPIO6 */
+	{"mdio_1", 2}, /* Only for GPIO53 */
+	{"mdc_0", 1}, /* Only for GPIO7 */
+	{"mdc_1", 2}, /* Only for GPIO52 */
 };
 
 static const char *ipq4019_get_function_name(struct udevice *dev,
Signature · 1 line
2.28.0
#8 lore raw

PATCH 4/6 IPQ40xx: Add support for MDIO

Quoted 4 lines · Robert Marko

Lets add the necessary DTS node and pinctrl properties for newly added MDIO driver.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/0cd7f803/attachment.sig>
#9 lore raw

PATCH 5/6 rng: Add Qualcomm MSM PRNG driver

In reply to Robert Marko

Add support for the hardware pseudo random number generator found in Qualcomm SoC-s.

---
 MAINTAINERS           |   1 +
 drivers/rng/Kconfig   |   7 +++
 drivers/rng/Makefile  |   1 +
 drivers/rng/msm_rng.c | 143 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 152 insertions(+)
 create mode 100644 drivers/rng/msm_rng.c
MAINTAINERS +1 -0
index 5f1a815c88..8a1bc97443 100644
@@ -243,6 +243,7 @@ F:	drivers/reset/reset-ipq4019.c
 F:	drivers/phy/phy-qcom-ipq4019-usb.c
 F:	drivers/spi/spi-qup.c
 F:	drivers/net/mdio-ipq4019.c
+F:	drivers/rng/msm_rng.c
 
 ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X ARMADA-37XX ARMADA-7K/8K
 M:	Stefan Roese <[email protected]>
drivers/rng/Kconfig +7 -0
index e4b22d79eb..11001c8ae7 100644
@@ -24,6 +24,13 @@ config RNG_SANDBOX
 	  Enable random number generator for sandbox. This is an
 	  emulation of a rng device.
 
+config RNG_MSM
+	bool "Qualcomm SoCs Random Number Generator support"
+	depends on DM_RNG
+	help
+	  This driver provides support for the Random Number
+	  Generator hardware found on Qualcomm SoCs.
+
 config RNG_STM32MP1
 	bool "Enable random number generator for STM32MP1"
 	depends on ARCH_STM32MP
drivers/rng/Makefile +1 -0
index 44a0003917..8953406882 100644
@@ -6,5 +6,6 @@
 obj-$(CONFIG_DM_RNG) += rng-uclass.o
 obj-$(CONFIG_RNG_MESON) += meson-rng.o
 obj-$(CONFIG_RNG_SANDBOX) += sandbox_rng.o
+obj-$(CONFIG_RNG_MSM) += msm_rng.o
 obj-$(CONFIG_RNG_STM32MP1) += stm32mp1_rng.o
 obj-$(CONFIG_RNG_ROCKCHIP) += rockchip_rng.o
drivers/rng/msm_rng.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
2.28.0
#10 lore raw

PATCH 5/6 rng: Add Qualcomm MSM PRNG driver

Quoted 5 lines · Robert Marko

Add support for the hardware pseudo random number generator found in Qualcomm SoC-s.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/d5ab8cc5/attachment.sig>
#11 lore raw

PATCH 5/6 rng: Add Qualcomm MSM PRNG driver

Quoted 9 lines · Tom Rini
Quoted 5 lines · Robert Marko

Add support for the hardware pseudo random number generator found in Qualcomm SoC-s.

Applied to u-boot/master, thanks!

Hello Robert,

Can we make CONFIG_RNG_MSM depend on CONFIG_ARCH_IPQ40XX so it is not shown as choice for other architectures?

Should CONFIG_RNG_MSM default to yes on ARCH_IPQ40XX?

Best regards

Heinrich

#12 lore raw

PATCH 5/6 rng: Add Qualcomm MSM PRNG driver

Quoted 9 lines · Heinrich Schuchardt
Quoted 2 lines · Tom Rini
Quoted 1 line · Robert Marko

Add support for the hardware pseudo random number generator found in

Qualcomm SoC-s.

Quoted 5 lines
Quoted 4 lines
Quoted 8 lines
Quoted 2 lines

Applied to u-boot/master, thanks!

Hello Robert,

Can we make CONFIG_RNG_MSM depend on CONFIG_ARCH_IPQ40XX so it is not shown as choice for other architectures?

Sure, as it's currently the only architecture using it.

Quoted 3 lines

Should CONFIG_RNG_MSM default to yes on ARCH_IPQ40XX?

It's currently enabled per board defconfig, I don't think it's vital enough to
default to yes.

Regards,
Robert

Quoted 8 lines

Best regards

Heinrich

#13 lore raw

PATCH 6/6 IPQ40xx: Add PRNG support

In reply to Robert Marko

Since we now have the driver for Qualcomm PRNG HW, lets use it and add the necessary clocks and nodes.

---
 arch/arm/dts/qcom-ipq4019.dtsi        | 7 +++++++
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 4 ++++
 2 files changed, 11 insertions(+)
arch/arm/dts/qcom-ipq4019.dtsi +7 -0
index 031691e5d2..7a52ea2c4e 100644
@@ -60,6 +60,13 @@
 			u-boot,dm-pre-reloc;
 		};
 
+		rng: rng at 22000 {
+			compatible = "qcom,prng";
+			reg = <0x22000 0x140>;
+			clocks = <&gcc GCC_PRNG_AHB_CLK>;
+			status = "disabled";
+		};
+
 		reset: gcc-reset at 1800000 {
 			compatible = "qcom,gcc-reset-ipq4019";
 			reg = <0x1800000 0x60000>;
arch/arm/mach-ipq40xx/clock-ipq4019.c +4 -0
index d5b5f4cb79..31ae9719e8 100644
@@ -54,6 +54,10 @@ static int msm_enable(struct clk *clk)
 		/* This clock is already initialized by SBL1 */
 		return 0;
 		break;
+	case GCC_PRNG_AHB_CLK: /*PRNG*/
+		/* This clock is already initialized by SBL1 */
+		return 0;
+		break;
 	default:
 		return 0;
 	}
Signature · 1 line
2.28.0
#14 lore raw

PATCH 6/6 IPQ40xx: Add PRNG support

Quoted 4 lines · Robert Marko

Since we now have the driver for Qualcomm PRNG HW, lets use it and add the necessary clocks and nodes.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/f54d1f60/attachment.sig>