Skip to content

Commit 9c63b84

Browse files
committed
spi: spi-mem: Convert Aspeed SMC driver to spi-mem
Merge series from Cédric Le Goater <[email protected]>: This series adds a new SPI driver using the spi-mem interface for the Aspeed static memory controllers of the AST2600, AST2500 and AST2400 SoCs. * AST2600 Firmware SPI Memory Controller (FMC) * AST2600 SPI Flash Controller (SPI1 and SPI2) * AST2500 Firmware SPI Memory Controller (FMC) * AST2500 SPI Flash Controller (SPI1 and SPI2) * AST2400 New Static Memory Controller (also referred as FMC) * AST2400 SPI Flash Controller (SPI) It is based on the current OpenBMC kernel driver [1], using directly the MTD SPI-NOR interface and on a patchset [2] previously proposed adding support for the AST2600 only. This driver takes a slightly different approach to cover all 6 controllers. It does not make use of the controller register disabling Address and Data byte lanes because is not available on the AST2400 SoC. We could introduce a specific handler for new features available on recent SoCs if needed. As there is not much difference on performance, the driver chooses the common denominator: "User mode" which has been heavily tested in [1]. "User mode" is also used as a fall back method when flash device mapping window is too small. Problems to address with spi-mem were the configuration of the mapping windows and the calibration of the read timings. The driver handles them in the direct mapping handler when some knowledge on the size of the flash device is know. It is not perfect but not incorrect either. The algorithm is one from [1] because it doesn't require the DMA registers which are not available on all controllers. Direct mapping for writes is not supported (yet). I have seen some corruption with writes and I preferred to use the safer and proven method of the initial driver [1]. We can improve that later. The driver supports Quad SPI RX transfers on the AST2600 SoC but it didn't have the expected results. Therefore it is not activated yet. There are some issues on the pinctrl to investigate first. Tested on: * OpenPOWER Palmetto (AST2400) * Facebook Wedge 100 BMC (AST2400) by Tao Ren <[email protected]> * Evaluation board (AST2500) * Inspur FP5280G2 BMC (AST2500) by John Wang <[email protected]> * Facebook Backpack CMM BMC (AST2500) by Tao Ren <[email protected]> * OpenPOWER Witherspoon (AST2500) * Evaluation board (AST2600 A0 and A3) * Rainier board (AST2600) [1] https://github.com/openbmc/linux/blob/dev-5.15/drivers/mtd/spi-nor/controllers/aspeed-smc.c [2] https://patchwork.ozlabs.org/project/linux-aspeed/list/?series=212394
2 parents b1849f5 + 73ae97e commit 9c63b84

File tree

9 files changed

+1314
-983
lines changed

9 files changed

+1314
-983
lines changed

Documentation/devicetree/bindings/mtd/aspeed-smc.txt

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/spi/aspeed,ast2600-fmc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Aspeed SMC controllers bindings
8+
9+
maintainers:
10+
- Chin-Ting Kuo <[email protected]>
11+
- Cédric Le Goater <[email protected]>
12+
13+
description: |
14+
This binding describes the Aspeed Static Memory Controllers (FMC and
15+
SPI) of the AST2400, AST2500 and AST2600 SOCs.
16+
17+
allOf:
18+
- $ref: "spi-controller.yaml#"
19+
20+
properties:
21+
compatible:
22+
enum:
23+
- aspeed,ast2600-fmc
24+
- aspeed,ast2600-spi
25+
- aspeed,ast2500-fmc
26+
- aspeed,ast2500-spi
27+
- aspeed,ast2400-fmc
28+
- aspeed,ast2400-spi
29+
30+
reg:
31+
items:
32+
- description: registers
33+
- description: memory mapping
34+
35+
clocks:
36+
maxItems: 1
37+
38+
interrupts:
39+
maxItems: 1
40+
41+
required:
42+
- compatible
43+
- reg
44+
- clocks
45+
46+
unevaluatedProperties: false
47+
48+
examples:
49+
- |
50+
#include <dt-bindings/interrupt-controller/arm-gic.h>
51+
#include <dt-bindings/interrupt-controller/aspeed-scu-ic.h>
52+
#include <dt-bindings/clock/ast2600-clock.h>
53+
54+
spi@1e620000 {
55+
reg = <0x1e620000 0xc4>, <0x20000000 0x10000000>;
56+
#address-cells = <1>;
57+
#size-cells = <0>;
58+
compatible = "aspeed,ast2600-fmc";
59+
clocks = <&syscon ASPEED_CLK_AHB>;
60+
interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
61+
62+
flash@0 {
63+
reg = < 0 >;
64+
compatible = "jedec,spi-nor";
65+
spi-max-frequency = <50000000>;
66+
spi-rx-bus-width = <2>;
67+
};
68+
69+
flash@1 {
70+
reg = < 1 >;
71+
compatible = "jedec,spi-nor";
72+
spi-max-frequency = <50000000>;
73+
spi-rx-bus-width = <2>;
74+
};
75+
76+
flash@2 {
77+
reg = < 2 >;
78+
compatible = "jedec,spi-nor";
79+
spi-max-frequency = <50000000>;
80+
spi-rx-bus-width = <2>;
81+
};
82+
};

MAINTAINERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,6 +3099,16 @@ S: Maintained
30993099
F: Documentation/devicetree/bindings/mmc/aspeed,sdhci.yaml
31003100
F: drivers/mmc/host/sdhci-of-aspeed*
31013101

3102+
ASPEED SMC SPI DRIVER
3103+
M: Chin-Ting Kuo <[email protected]>
3104+
M: Cédric Le Goater <[email protected]>
3105+
L: [email protected] (moderated for non-subscribers)
3106+
L: [email protected] (moderated for non-subscribers)
3107+
3108+
S: Maintained
3109+
F: Documentation/devicetree/bindings/spi/aspeed,ast2600-fmc.yaml
3110+
F: drivers/spi/spi-aspeed-smc.c
3111+
31023112
ASPEED VIDEO ENGINE DRIVER
31033113
M: Eddie James <[email protected]>
31043114

drivers/mtd/spi-nor/controllers/Kconfig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
config SPI_ASPEED_SMC
3-
tristate "Aspeed flash controllers in SPI mode"
4-
depends on ARCH_ASPEED || COMPILE_TEST
5-
depends on HAS_IOMEM && OF
6-
help
7-
This enables support for the Firmware Memory controller (FMC)
8-
in the Aspeed AST2500/AST2400 SoCs when attached to SPI NOR chips,
9-
and support for the SPI flash memory controller (SPI) for
10-
the host firmware. The implementation only supports SPI NOR.
11-
122
config SPI_HISI_SFC
133
tristate "Hisilicon FMC SPI NOR Flash Controller(SFC)"
144
depends on ARCH_HISI || COMPILE_TEST
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
obj-$(CONFIG_SPI_ASPEED_SMC) += aspeed-smc.o
32
obj-$(CONFIG_SPI_HISI_SFC) += hisi-sfc.o
43
obj-$(CONFIG_SPI_NXP_SPIFI) += nxp-spifi.o

0 commit comments

Comments
 (0)