Skip to contentSkip to conversation

fsi: aspeed: CFAM reset support

PATCH In review Joel Stanley 2 participants 7 messages Jul 24, 2020

Subsystems (3)
lore
Share & tools
lore

Joel Stanley

author maintainer
#0 lore raw

cover fsi: aspeed: CFAM reset support

See patch 1 for a description.

v2: Fix levels

Joel Stanley (3):
fsi: aspeed: Support CFAM reset GPIO
ARM: dts: aspeed: rainier: Add CFAM reset GPIO
ARM: dts: aspeed: tacoma: Add CFAM reset GPIO

 arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts |  6 +++
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts  |  1 +
 drivers/fsi/fsi-master-aspeed.c              | 43 ++++++++++++++++++++
 3 files changed, 50 insertions(+)
Signature · 1 line
2.27.0
author maintainer
#1 lore raw

PATCH 1/3 fsi: aspeed: Support CFAM reset GPIO

Systems have a line for restting the remote CFAM. This is not part of the FSI master, but is associated with it, so it makes sense to include it in the master driver.

This exposes a sysfs interface to reset the cfam, abstracting away the direction and polarity of the GPIO, as well as the timing of the reset pulse. Userspace will be blocked until the reset pulse is finished.

The reset is hard coded to be in the range of (900, 1000) us. It was observed with a scope to regularly be just over 1ms.

If the device tree property is not preset the driver will silently continue.

---
v2: Releasing the reset should set it to 0

---
 drivers/fsi/fsi-master-aspeed.c | 43 +++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
drivers/fsi/fsi-master-aspeed.c +43 -0
index b44f71f1f0a8..ef21362095f8 100644
@@ -22,6 +22,7 @@ struct fsi_master_aspeed {
 	struct device		*dev;
 	void __iomem		*base;
 	struct clk		*clk;
+	struct gpio_desc	*cfam_reset_gpio;
 };
 
 #define to_fsi_master_aspeed(m) \
@@ -429,6 +430,43 @@ static int aspeed_master_init(struct fsi_master_aspeed *aspeed)
 	return 0;
 }
 
+static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *attr,
+				const char *buf, size_t count)
+{
+	struct fsi_master_aspeed *aspeed = dev_get_drvdata(dev);
+
+	gpiod_set_value(aspeed->cfam_reset_gpio, 1);
+	usleep_range(900, 1000);
+	gpiod_set_value(aspeed->cfam_reset_gpio, 0);
+
+	return count;
+}
+
+static DEVICE_ATTR(cfam_reset, 0200, NULL, cfam_reset_store);
+
+static int setup_cfam_reset(struct fsi_master_aspeed *aspeed)
+{
+	struct device *dev = aspeed->dev;
+	struct gpio_desc *gpio;
+	int rc;
+
+	gpio = devm_gpiod_get_optional(dev, "cfam-reset", GPIOD_OUT_LOW);
+	if (IS_ERR(gpio))
+		return PTR_ERR(gpio);
+	if (!gpio)
+		return 0;
+
+	aspeed->cfam_reset_gpio = gpio;
+
+	rc = device_create_file(dev, &dev_attr_cfam_reset);
+	if (rc) {
+		devm_gpiod_put(dev, gpio);
+		return rc;
+	}
+
+	return 0;
+}
+
 static int tacoma_cabled_fsi_fixup(struct device *dev)
 {
 	struct gpio_desc *routing_gpio, *mux_gpio;
@@ -511,6 +549,11 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
 		return rc;
 	}
 
+	rc = setup_cfam_reset(aspeed);
+	if (rc) {
+		dev_err(&pdev->dev, "CFAM reset GPIO setup failed\n");
+	}
+
 	writel(0x1, aspeed->base + OPB_CLK_SYNC);
 	writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN,
 			aspeed->base + OPB_IRQ_MASK);
Signature · 1 line
2.27.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH linux dev-5.4 1/3] fsi: aspeed: Support CFAM reset GPIO

Quoted 8 lines · Joel Stanley

Systems have a line for restting the remote CFAM. This is not part of the FSI master, but is associated with it, so it makes sense to include it in the master driver.

This exposes a sysfs interface to reset the cfam, abstracting away the direction and polarity of the GPIO, as well as the timing of the reset pulse. Userspace will be blocked until the reset pulse is finished.

Quoted 7 lines

The reset is hard coded to be in the range of (900, 1000) us. It was observed with a scope to regularly be just over 1ms.

If the device tree property is not preset the driver will silently continue.

author maintainer
#3 lore raw

PATCH 2/3 ARM: dts: aspeed: rainier: Add CFAM reset GPIO

In reply to Joel Stanley

The GPIO on Q0 is used for resetting the CFAM of the processor that the ASPEED master is connected to.

The signal is wired as active high on the first pass systems.

---
v2: Fix polarity

---
 arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/aspeed-bmc-ibm-rainier.dts +6 -0
index 0b5c6cc1c66a..18e0b22d5e48 100644
@@ -126,6 +126,12 @@
 	#address-cells = <2>;
 	#size-cells = <0>;
 
+	/*
+	 * CFAM Reset is supposed to be active low but pass1 hardware is wired
+	 * active high.
+	 */
+	cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 0) GPIO_ACTIVE_HIGH>;
+
 	cfam@0,0 {
 		reg = <0 0>;
 		#address-cells = <1>;
Signature · 1 line
2.27.0
author maintainer
#5 lore raw

PATCH 3/3 ARM: dts: aspeed: tacoma: Add CFAM reset GPIO

In reply to Joel Stanley

The GPIO on Q0 is used for resetting the CFAM of the processor that the ASPEED master is connected to.

---
 arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts | 1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/aspeed-bmc-opp-tacoma.dts +1 -0
index 96a45014b7e5..59f30c6c22d1 100644
@@ -185,6 +185,7 @@
 
 	fsi-routing-gpios = <&gpio0 ASPEED_GPIO(Q, 7) GPIO_ACTIVE_HIGH>;
 	fsi-mux-gpios = <&gpio0 ASPEED_GPIO(B, 0) GPIO_ACTIVE_HIGH>;
+	cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 0) GPIO_ACTIVE_LOW>;
 
 	cfam@0,0 {
 		reg = <0 0>;
Signature · 1 line
2.27.0