Skip to contentSkip to conversation

mtd: spi-nor: aspeed: introduce a "spi-max-frequency" property

PATCH Superseded Cédric Le Goater 3 participants 9 messages Jun 8, 2018 – Jun 19, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover mtd: spi-nor: aspeed: introduce a "spi-max-frequency" property

Hello,

The property protects some optimistic settings of optimize read algo on certain chips (old ones). It also makes the read access to the alternate FMC chip 3 times faster.

Thanks,

C.

Cédric Le Goater (2):
ARM: dts: aspeed: Add "spi-max-frequency" property
mtd: spi-nor: aspeed: limit the maximum SPI frequency

 drivers/mtd/spi-nor/aspeed-smc.c                 | 18 ++++++++++++++----
 arch/arm/boot/dts/aspeed-ast2500-evb.dts         |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts    |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts     |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  3 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts       |  2 ++
 arch/arm/boot/dts/aspeed-g4.dtsi                 |  2 ++
 arch/arm/boot/dts/aspeed-g5.dtsi                 |  7 +++++++
 8 files changed, 34 insertions(+), 4 deletions(-)
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/2 ARM: dts: aspeed: Add "spi-max-frequency" property

Keep the FMC controller chips at a safe 50 MHz rate but use 100 MHz for the PNOR.

---
 arch/arm/boot/dts/aspeed-ast2500-evb.dts         | 2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts    | 2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts     | 2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 3 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts       | 2 ++
 arch/arm/boot/dts/aspeed-g4.dtsi                 | 2 ++
 arch/arm/boot/dts/aspeed-g5.dtsi                 | 7 +++++++
 7 files changed, 20 insertions(+)
arch/arm/boot/dts/aspeed-ast2500-evb.dts +2 -0
index c0a7f51e7eb6..6b78e40d3259 100644
@@ -41,6 +41,7 @@
 		status = "okay";
 		m25p,fast-read;
 		label = "bmc";
+		spi-max-frequency = <50000000>;
 #include "openbmc-flash-layout.dtsi"
 	};
 };
@@ -51,6 +52,7 @@
 		status = "okay";
 		m25p,fast-read;
 		label = "pnor";
+		spi-max-frequency = <100000000>;
 	};
 };
 
arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts +2 -0
index 9e2bb8053f74..76098ebc03bf 100644
@@ -66,6 +66,7 @@
 		status = "okay";
 		m25p,fast-read;
 		label = "bmc";
+		spi-max-frequency = <50000000>;
 #include "openbmc-flash-layout.dtsi"
 	};
 };
@@ -78,6 +79,7 @@
 	flash@0 {
 		status = "okay";
 		m25p,fast-read;
+		spi-max-frequency = <50000000>;
 		label = "pnor";
 	};
 };
arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts +2 -0
index 0fdf08077ed3..fd909ebfed5b 100644
@@ -93,6 +93,7 @@
 		status = "okay";
 		m25p,fast-read;
 		label = "bmc";
+		spi-max-frequency = <50000000>;
 #include "openbmc-flash-layout.dtsi"
 
 	};
@@ -107,6 +108,7 @@
 		status = "okay";
 		m25p,fast-read;
 		label = "pnor";
+		spi-max-frequency = <100000000>;
 	};
 };
 
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +3 -0
index 214718b7784d..ee7e99bbbc05 100644
@@ -190,6 +190,7 @@
 		status = "okay";
 		label = "bmc";
 		m25p,fast-read;
+		spi-max-frequency = <50000000>;
 #include "openbmc-flash-layout.dtsi"
 	};
 
@@ -197,6 +198,7 @@
 		status = "okay";
 		label = "alt";
 		m25p,fast-read;
+		spi-max-frequency = <50000000>;
 	};
 };
 
@@ -209,6 +211,7 @@
 		status = "okay";
 		label = "pnor";
 		m25p,fast-read;
+		spi-max-frequency = <100000000>;
 	};
 };
 
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts +2 -0
index 085926935574..1eae30727fc2 100644
@@ -124,6 +124,7 @@
 		status = "okay";
 		label = "bmc";
 		m25p,fast-read;
+		spi-max-frequency = <50000000>;
 #include "openbmc-flash-layout.dtsi"
 	};
 };
@@ -137,6 +138,7 @@
 		status = "okay";
 		label = "pnor";
 		m25p,fast-read;
+		spi-max-frequency = <100000000>;
 	};
 };
 
arch/arm/boot/dts/aspeed-g4.dtsi +2 -0
index 9354ac92d928..fd14eb1b8c22 100644
@@ -60,6 +60,7 @@
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 		};
@@ -75,6 +76,7 @@
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 		};
arch/arm/boot/dts/aspeed-g5.dtsi +7 -0
index f7c33fbcdaee..f155c32aefbc 100644
@@ -60,16 +60,19 @@
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 			flash@1 {
 				reg = < 1 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 			flash@2 {
 				reg = < 2 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 		};
@@ -85,11 +88,13 @@
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 			flash@1 {
 				reg = < 1 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 		};
@@ -105,11 +110,13 @@
 			flash@0 {
 				reg = < 0 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 			flash@1 {
 				reg = < 1 >;
 				compatible = "jedec,spi-nor";
+				spi-max-frequency = <50000000>;
 				status = "disabled";
 			};
 		};
Signature · 1 line
2.13.6
#2 lore raw

PATCH 2/2 mtd: spi-nor: aspeed: limit the maximum SPI frequency

In reply to Cédric Le Goater

The optimize read algo can choose a 100MHz SPI frequency which might be a bit too high for dual output IO on some chips, for the W25Q256 on palmetto for instance. The MX66L1G45G on witherspoon should be fine though. Also, the second chip of the FMC controller does not get any optimize settings for reads. Only the first is configured by U-Boot.

To fix these two issues, we introduce a "spi-max-frequency" property in the device tree which will be used to cap the optimize read algorithm and we run the algo on the FMC controller chips as well.

By default, the frequency setting is 50MHz.

---
 drivers/mtd/spi-nor/aspeed-smc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/aspeed-smc.c +14 -4
index a301895d1f06..e4a0123b12b3 100644
@@ -83,6 +83,7 @@ static const struct aspeed_smc_info fmc_2500_info = {
 	.ctl0 = 0x10,
 	.timing = 0x94,
 	.set_4b = aspeed_smc_chip_set_4b,
+	.optimize_read = aspeed_smc_optimize_read,
 };
 
 static const struct aspeed_smc_info spi_2500_info = {
@@ -114,6 +115,7 @@ struct aspeed_smc_chip {
 	u32 ctl_val[smc_max];			/* control settings */
 	enum aspeed_smc_flash_type type;	/* what type of flash */
 	struct spi_nor nor;
+	u32 clk_rate;
 };
 
 struct aspeed_smc_controller {
@@ -130,6 +132,8 @@ struct aspeed_smc_controller {
 	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
 };
 
+#define ASPEED_SPI_DEFAULT_FREQ		50000000
+
 /*
  * SPI Flash Configuration Register (AST2500 SPI)
  *     or
@@ -993,11 +997,10 @@ static int aspeed_smc_chip_setup_finish(struct aspeed_smc_chip *chip)
 	dev_info(controller->dev, "read control register: %08x\n",
 		chip->ctl_val[smc_read]);
 
-	/*
-	 * TODO: get max freq from chip
-	 */
+
 	if (optimize_read && info->optimize_read)
-		info->optimize_read(chip, 104000000);
+		info->optimize_read(chip, chip->clk_rate);
+
 	return 0;
 }
 
@@ -1051,6 +1054,13 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller,
 			break;
 		}
 
+		if (of_property_read_u32(child, "spi-max-frequency",
+					 &chip->clk_rate)) {
+			chip->clk_rate = ASPEED_SPI_DEFAULT_FREQ;
+		}
+		dev_info(dev, "Using %d MHz SPI frequency\n",
+			 chip->clk_rate / 1000000);
+
 		chip->controller = controller;
 		chip->ctl = controller->regs + info->ctl0 + cs * 4;
 		chip->cs = cs;
Signature · 1 line
2.13.6
#3 lore raw

Re: [PATCH 2/2] mtd: spi-nor: aspeed: limit the maximum SPI frequency

Quoted 9 lines · Cédric Le Goater

The optimize read algo can choose a 100MHz SPI frequency which might be a bit too high for dual output IO on some chips, for the W25Q256 on palmetto for instance. The MX66L1G45G on witherspoon should be fine though. Also, the second chip of the FMC controller does not get any optimize settings for reads. Only the first is configured by U-Boot.

To fix these two issues, we introduce a "spi-max-frequency" property in the device tree which will be used to cap the optimize read algorithm and we run the algo on the FMC controller chips as well.

Might be a silly question, but why didn't you add support for optimized reads for the AST2400 FMC given we can limit the speed through the devicetree property?

Quoted 13 lines

By default, the frequency setting is 50MHz.

---
 drivers/mtd/spi-nor/aspeed-smc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/aspeed-smc.c +0 -0
index a301895d1f06..e4a0123b12b3 100644

drivers/mtd/spi-nor/aspeed-smc.c static const struct aspeed_smc_info fmc_2500_info = { · line 86

Quoted 4 lines
drivers/mtd/spi-nor/aspeed-smc.c +1 -0
@@ -83,6 +83,7 @@ static const struct aspeed_smc_info fmc_2500_info = {
 	.ctl0 = 0x10,
 	.timing = 0x94,
 	.set_4b = aspeed_smc_chip_set_4b,
+	.optimize_read = aspeed_smc_optimize_read,

i.e. here you add the support for the 2500 FMC, but the 2400 FMC info struct is unchanged.

Quoted 54 lines
drivers/mtd/spi-nor/aspeed-smc.c +13 -4
 };
 
 static const struct aspeed_smc_info spi_2500_info = {
@@ -114,6 +115,7 @@ struct aspeed_smc_chip {
 	u32 ctl_val[smc_max];			/* control settings */
 	enum aspeed_smc_flash_type type;	/* what type of flash */
 	struct spi_nor nor;
+	u32 clk_rate;
 };
 
 struct aspeed_smc_controller {
@@ -130,6 +132,8 @@ struct aspeed_smc_controller {
 	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
 };
 
+#define ASPEED_SPI_DEFAULT_FREQ		50000000
+
 /*
  * SPI Flash Configuration Register (AST2500 SPI)
  *     or
@@ -993,11 +997,10 @@ static int aspeed_smc_chip_setup_finish(struct 
 aspeed_smc_chip *chip)
 	dev_info(controller->dev, "read control register: %08x\n",
 		chip->ctl_val[smc_read]);
 
-	/*
-	 * TODO: get max freq from chip
-	 */
+
 	if (optimize_read && info->optimize_read)
-		info->optimize_read(chip, 104000000);
+		info->optimize_read(chip, chip->clk_rate);
+
 	return 0;
 }
@@ -1051,6 +1054,13 @@ static int aspeed_smc_setup_flash(struct 
 aspeed_smc_controller *controller,
 			break;
 		}
 
+		if (of_property_read_u32(child, "spi-max-frequency",
+					 &chip->clk_rate)) {
+			chip->clk_rate = ASPEED_SPI_DEFAULT_FREQ;
+		}
+		dev_info(dev, "Using %d MHz SPI frequency\n",
+			 chip->clk_rate / 1000000);
+
 		chip->controller = controller;
 		chip->ctl = controller->regs + info->ctl0 + cs * 4;

chip->cs = cs;

Signature · 1 line
2.13.6
#4 lore raw

Re: [PATCH 2/2] mtd: spi-nor: aspeed: limit the maximum SPI frequency

Quoted 22 lines · Andrew Jeffery
Quoted 9 lines · Cédric Le Goater

The optimize read algo can choose a 100MHz SPI frequency which might be a bit too high for dual output IO on some chips, for the W25Q256 on palmetto for instance. The MX66L1G45G on witherspoon should be fine though. Also, the second chip of the FMC controller does not get any optimize settings for reads. Only the first is configured by U-Boot.

To fix these two issues, we introduce a "spi-max-frequency" property in the device tree which will be used to cap the optimize read algorithm and we run the algo on the FMC controller chips as well.

Might be a silly question, but why didn't you add support for optimized reads for the AST2400 FMC given we can limit the speed through the devicetree property ? >

Quoted 8 lines

By default, the frequency setting is 50MHz.

---
 drivers/mtd/spi-nor/aspeed-smc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
Quoted 11 lines

drivers/mtd/spi-nor/aspeed-smc.c static const struct aspeed_smc_info fmc_2500_info = { · line 86

Quoted 9 lines
drivers/mtd/spi-nor/aspeed-smc.c +1 -0
index a301895d1f06..e4a0123b12b3 100644
@@ -83,6 +83,7 @@ static const struct aspeed_smc_info fmc_2500_info = {
 	.ctl0 = 0x10,
 	.timing = 0x94,
 	.set_4b = aspeed_smc_chip_set_4b,
+	.optimize_read = aspeed_smc_optimize_read,

i.e. here you add the support for the 2500 FMC, but the 2400 FMC info struct is unchanged.

Ah I understand now your remark. It is missing indeed. I didn't notice because I was targeting the alt fmc chip on the witherspoon and too high frequencies on the PNOR. I will check how it behaves on the new 4.17 tree.

Thanks !

C.

Quoted 55 lines
Quoted 55 lines
drivers/mtd/spi-nor/aspeed-smc.c +13 -4
 };
 
 static const struct aspeed_smc_info spi_2500_info = {
@@ -114,6 +115,7 @@ struct aspeed_smc_chip {
 	u32 ctl_val[smc_max];			/* control settings */
 	enum aspeed_smc_flash_type type;	/* what type of flash */
 	struct spi_nor nor;
+	u32 clk_rate;
 };
 
 struct aspeed_smc_controller {
@@ -130,6 +132,8 @@ struct aspeed_smc_controller {
 	struct aspeed_smc_chip *chips[0];	/* pointers to attached chips */
 };
 
+#define ASPEED_SPI_DEFAULT_FREQ		50000000
+
 /*
  * SPI Flash Configuration Register (AST2500 SPI)
  *     or
@@ -993,11 +997,10 @@ static int aspeed_smc_chip_setup_finish(struct 
 aspeed_smc_chip *chip)
 	dev_info(controller->dev, "read control register: %08x\n",
 		chip->ctl_val[smc_read]);
 
-	/*
-	 * TODO: get max freq from chip
-	 */
+
 	if (optimize_read && info->optimize_read)
-		info->optimize_read(chip, 104000000);
+		info->optimize_read(chip, chip->clk_rate);
+
 	return 0;
 }
@@ -1051,6 +1054,13 @@ static int aspeed_smc_setup_flash(struct 
 aspeed_smc_controller *controller,
 			break;
 		}
 
+		if (of_property_read_u32(child, "spi-max-frequency",
+					 &chip->clk_rate)) {
+			chip->clk_rate = ASPEED_SPI_DEFAULT_FREQ;
+		}
+		dev_info(dev, "Using %d MHz SPI frequency\n",
+			 chip->clk_rate / 1000000);
+
 		chip->controller = controller;
 		chip->ctl = controller->regs + info->ctl0 + cs * 4;

chip->cs = cs;

Signature · 1 line
2.13.6
maintainer
#5 lore raw
In reply to Cédric Le Goater

Hi Cedric,

Quoted 5 lines · Cédric Le Goater

Hello,

The property protects some optimistic settings of optimize read algo on certain chips (old ones). It also makes the read access to the alternate FMC chip 3 times faster.

The changes look okay to me. Do you plan to submit them for upstream inclusion?

I'd feel happier if we had some review on them before merging device tree changes.

Cheers,

Joel

Quoted 22 lines

Thanks,

C.

Cédric Le Goater (2):
ARM: dts: aspeed: Add "spi-max-frequency" property
mtd: spi-nor: aspeed: limit the maximum SPI frequency

 drivers/mtd/spi-nor/aspeed-smc.c                 | 18 ++++++++++++++----
 arch/arm/boot/dts/aspeed-ast2500-evb.dts         |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts    |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts     |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  3 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts       |  2 ++
 arch/arm/boot/dts/aspeed-g4.dtsi                 |  2 ++
 arch/arm/boot/dts/aspeed-g5.dtsi                 |  7 +++++++
 8 files changed, 34 insertions(+), 4 deletions(-)

--
2.13.6

#6 lore raw
Quoted 10 lines · Joel Stanley

Hi Cedric,

Quoted 5 lines · Cédric Le Goater

Hello,

The property protects some optimistic settings of optimize read algo on certain chips (old ones). It also makes the read access to the alternate FMC chip 3 times faster.

The changes look okay to me. Do you plan to submit them for upstream inclusion?

yes. I would like to have some testing first and also make sure it fits OpenBMC needs.

Thanks,

C.

Quoted 30 lines

I'd feel happier if we had some review on them before merging device tree changes.

Cheers,

Joel

Quoted 22 lines

Thanks,

C.

Cédric Le Goater (2):
ARM: dts: aspeed: Add "spi-max-frequency" property
mtd: spi-nor: aspeed: limit the maximum SPI frequency

 drivers/mtd/spi-nor/aspeed-smc.c                 | 18 ++++++++++++++----
 arch/arm/boot/dts/aspeed-ast2500-evb.dts         |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dts    |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts     |  2 ++
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  3 +++
 arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts       |  2 ++
 arch/arm/boot/dts/aspeed-g4.dtsi                 |  2 ++
 arch/arm/boot/dts/aspeed-g5.dtsi                 |  7 +++++++
 8 files changed, 34 insertions(+), 4 deletions(-)

--
2.13.6

maintainer
#7 lore raw
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines · Joel Stanley

Hi Cedric,

Quoted 2 lines · Cédric Le Goater

Hello,

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The property protects some optimistic settings of optimize read algo on certain chips (old ones). It also makes the read access to the alternate FMC chip 3 times faster.

The changes look okay to me. Do you plan to submit them for upstream inclusion?

yes. I would like to have some testing first and also make sure it fits OpenBMC needs.

Okay.

I suggest we wait until openbmc has moved to the new 4.17 tree (probably next week), and once we've verified there are no regressions, we can add your patches in.

#8 lore raw
Quoted 13 lines · Joel Stanley
Quoted 12 lines · Cédric Le Goater
Quoted 10 lines · Joel Stanley

Hi Cedric,

Quoted 5 lines · Cédric Le Goater

Hello,

The property protects some optimistic settings of optimize read algo on certain chips (old ones). It also makes the read access to the alternate FMC chip 3 times faster.

The changes look okay to me. Do you plan to submit them for upstream inclusion?

Quoted 9 lines
Quoted 2 lines

yes. I would like to have some testing first and also make sure it fits OpenBMC needs.

Okay.

I suggest we wait until openbmc has moved to the new 4.17 tree (probably next week), and once we've verified there are no regressions, we can add your patches in.

Good. Being on a 4.17 tree would be even better.

Thanks,

C.