2018-01-18 14:38:31

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 00/14] Add MMCI support for STM32F SoCs family

From: Patrice Chotard <[email protected]>

This series reworks patches submitted one year ago by Andrea Merello [1]
but without succeed to merged it.

STM32F4 and STM32F7 SoCs families embeds a variant of the ARM PrimeCell
PL18x SD host controller, for which the mmci driver exists.
This series adds support for these SoCs to the mmci driver.

As other variants, this one need some specific quirks, that this
series address.

This series has been tested on following boards :
_ stm32f429-eval
_ stm32f469-disco
_ stm32f746-eval
_ stm32f769-disco

DT update for stm32f7 pinctrl, stm32f746-eval and stm32f769-disco boards
will be sent later to avoid conflict with pending stm32f7 series [1] which
is not yet merged on kernel mainline.

[1] https://www.spinics.net/lists/linux-mmc/msg41616.html
[2] https://patchwork.kernel.org/patch/10104447/

v3: _ patch 3: use variant->opendrain instead of host->variant->opendrain
_ patch 4: exit from probe() if no pinctrl dt node are found
_ previous patch 15: removed as already applied in pinctrl tree

v2: _ add Revievied-by, Acked-by in some patches
_ replace bool by u32 for start_err and opendrain fields of struct variant_data
_ split previous patch 3 in two parts, first patch clean the open drain bit code
and second part add pinctrl pins management when no open drain bit is available.
_ replace "pl180" by "PL180" in patch "mmc: mmci: Add STM32 variant"

Andrea Merello (2):
ARM: dts: stm32: Add pin map for SDIO controller on stm32f4
ARM: dts: stm32: Enable SDIO controller on stm32f469 disco board

Patrice Chotard (12):
mmc: mmci: Don't pretend all variants to have MMCIMASK1 register
mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag
mmc: mmci: Don't pretend all variants to have OPENDRAIN bit
mmc: mmci: Add support for setting pad type via pinctrl
mmc: mmci: Add STM32 variant
ARM: dts: stm32: Add SDIO controller for stm32f746
ARM: dts: stm32: Add SDIO controller for stm32f429
ARM: dts: stm32: Enable SDIO controller on stm32429i-eval board
ARM: stm32: Add AMBA support for STM32F4 and STM32F7 SoCs
ARM: configs: stm32: Enable MMC_ARMMMCI support
ARM: configs: stm32: Enable EXT3_FS support
clk: stm32: Add clk entry for SDMMC2 on stm32F769

arch/arm/boot/dts/stm32429i-eval.dts | 19 +++++
arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 31 +++++++++
arch/arm/boot/dts/stm32f429.dtsi | 11 +++
arch/arm/boot/dts/stm32f469-disco.dts | 19 +++++
arch/arm/boot/dts/stm32f746.dtsi | 22 ++++++
arch/arm/configs/stm32_defconfig | 3 +
arch/arm/mach-stm32/Kconfig | 3 +
drivers/clk/clk-stm32f4.c | 3 +-
drivers/mmc/host/mmci.c | 124 ++++++++++++++++++++++++++++-----
drivers/mmc/host/mmci.h | 6 ++
10 files changed, 224 insertions(+), 17 deletions(-)

--
1.9.1



2018-01-18 14:37:21

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 02/14] mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag

From: Patrice Chotard <[email protected]>

This patch prepares for supporting the STM32 variant that
has no such bit in the status register.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ replace start_err bool type by u32


drivers/mmc/host/mmci.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 3125dc0..8a4fbc2 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -83,6 +83,8 @@
* @qcom_dml: enables qcom specific dma glue for dma transfers.
* @reversed_irq_handling: handle data irq before cmd irq.
* @mmcimask1: true if variant have a MMCIMASK1 register.
+ * @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
+ * register.
*/
struct variant_data {
unsigned int clkreg;
@@ -113,6 +115,7 @@ struct variant_data {
bool qcom_dml;
bool reversed_irq_handling;
bool mmcimask1;
+ u32 start_err;
};

static struct variant_data variant_arm = {
@@ -123,6 +126,7 @@ struct variant_data {
.f_max = 100000000,
.reversed_irq_handling = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_arm_extended_fifo = {
@@ -132,6 +136,7 @@ struct variant_data {
.pwrreg_powerup = MCI_PWR_UP,
.f_max = 100000000,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_arm_extended_fifo_hwfc = {
@@ -142,6 +147,7 @@ struct variant_data {
.pwrreg_powerup = MCI_PWR_UP,
.f_max = 100000000,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_u300 = {
@@ -158,6 +164,7 @@ struct variant_data {
.pwrreg_clkgate = true,
.pwrreg_nopower = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_nomadik = {
@@ -175,6 +182,7 @@ struct variant_data {
.pwrreg_clkgate = true,
.pwrreg_nopower = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_ux500 = {
@@ -198,6 +206,7 @@ struct variant_data {
.busy_detect_mask = MCI_ST_BUSYENDMASK,
.pwrreg_nopower = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_ux500v2 = {
@@ -223,6 +232,7 @@ struct variant_data {
.busy_detect_mask = MCI_ST_BUSYENDMASK,
.pwrreg_nopower = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

static struct variant_data variant_qcom = {
@@ -242,6 +252,7 @@ struct variant_data {
.qcom_fifo = true,
.qcom_dml = true,
.mmcimask1 = true,
+ .start_err = MCI_STARTBITERR,
};

/* Busy detection for the ST Micro variant */
@@ -935,8 +946,9 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
return;

/* First check for errors */
- if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_STARTBITERR|
- MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
+ if (status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT |
+ host->variant->start_err |
+ MCI_TXUNDERRUN | MCI_RXOVERRUN)) {
u32 remain, success;

/* Terminate the DMA transfer */
--
1.9.1


2018-01-18 14:37:52

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 14/14] clk: stm32: Add clk entry for SDMMC2 on stm32F769

From: Patrice Chotard <[email protected]>

STM32F769 has 2 SDMMC port, add clock entry for the second one.

Signed-off-by: Alexandre TORGUE <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
Acked-by: Stephen Boyd <[email protected]>
---

v3: _ none

v2: _ Add Acked-by


drivers/clk/clk-stm32f4.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-stm32f4.c b/drivers/clk/clk-stm32f4.c
index da44f8d..e7e3965 100644
--- a/drivers/clk/clk-stm32f4.c
+++ b/drivers/clk/clk-stm32f4.c
@@ -282,6 +282,7 @@ struct stm32f4_gate_data {

{ STM32F4_RCC_APB2ENR, 0, "tim1", "apb2_mul" },
{ STM32F4_RCC_APB2ENR, 1, "tim8", "apb2_mul" },
+ { STM32F4_RCC_APB2ENR, 7, "sdmmc2", "sdmux" },
{ STM32F4_RCC_APB2ENR, 8, "adc1", "apb2_div" },
{ STM32F4_RCC_APB2ENR, 9, "adc2", "apb2_div" },
{ STM32F4_RCC_APB2ENR, 10, "adc3", "apb2_div" },
@@ -315,7 +316,7 @@ struct stm32f4_gate_data {

static const u64 stm32f746_gate_map[MAX_GATE_MAP] = { 0x000000f17ef417ffull,
0x0000000000000003ull,
- 0x04f77f033e01c9ffull };
+ 0x04f77f833e01c9ffull };

static const u64 *stm32f4_gate_map;

--
1.9.1


2018-01-18 14:38:11

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 03/14] mmc: mmci: Don't pretend all variants to have OPENDRAIN bit

From: Patrice Chotard <[email protected]>

This patch prepares for supporting STM32 variant which doesn't
have opendrain bit in MMCIPOWER register.
ST others variant (u300, nomadik and ux500) uses MCI_OD bit whereas
others variants uses MCI_ROD bit.

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ use variant->opendrain instead of host->variant->opendrain
_ remove comment about OD and ROD bit

v2: _ Replace opendrain bool type by u32
_ Clean opendrain bit management code

drivers/mmc/host/mmci.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 8a4fbc2..f0edfe7 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -85,6 +85,7 @@
* @mmcimask1: true if variant have a MMCIMASK1 register.
* @start_err: bitmask identifying the STARTBITERR bit inside MMCISTATUS
* register.
+ * @opendrain: bitmask identifying the OPENDRAIN bit inside MMCIPOWER register
*/
struct variant_data {
unsigned int clkreg;
@@ -116,6 +117,7 @@ struct variant_data {
bool reversed_irq_handling;
bool mmcimask1;
u32 start_err;
+ u32 opendrain;
};

static struct variant_data variant_arm = {
@@ -127,6 +129,7 @@ struct variant_data {
.reversed_irq_handling = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_ROD,
};

static struct variant_data variant_arm_extended_fifo = {
@@ -137,6 +140,7 @@ struct variant_data {
.f_max = 100000000,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_ROD,
};

static struct variant_data variant_arm_extended_fifo_hwfc = {
@@ -148,6 +152,7 @@ struct variant_data {
.f_max = 100000000,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_ROD,
};

static struct variant_data variant_u300 = {
@@ -165,6 +170,7 @@ struct variant_data {
.pwrreg_nopower = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_OD,
};

static struct variant_data variant_nomadik = {
@@ -183,6 +189,7 @@ struct variant_data {
.pwrreg_nopower = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_OD,
};

static struct variant_data variant_ux500 = {
@@ -207,6 +214,7 @@ struct variant_data {
.pwrreg_nopower = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_OD,
};

static struct variant_data variant_ux500v2 = {
@@ -233,6 +241,7 @@ struct variant_data {
.pwrreg_nopower = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_OD,
};

static struct variant_data variant_qcom = {
@@ -253,6 +262,7 @@ struct variant_data {
.qcom_dml = true,
.mmcimask1 = true,
.start_err = MCI_STARTBITERR,
+ .opendrain = MCI_ROD,
};

/* Busy detection for the ST Micro variant */
@@ -1455,17 +1465,8 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
~MCI_ST_DATA2DIREN);
}

- if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
- if (host->hw_designer != AMBA_VENDOR_ST)
- pwr |= MCI_ROD;
- else {
- /*
- * The ST Micro variant use the ROD bit for something
- * else and only has OD (Open Drain).
- */
- pwr |= MCI_OD;
- }
- }
+ if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN && variant->opendrain)
+ pwr |= variant->opendrain;

/*
* If clock = 0 and the variant requires the MMCIPOWER to be used for
--
1.9.1


2018-01-18 14:38:12

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 12/14] ARM: configs: stm32: Enable MMC_ARMMMCI support

From: Patrice Chotard <[email protected]>

Enable MMC_ARMMCI support to add SDIO support for
STM32F4 and STM32F7 SoCs family

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/configs/stm32_defconfig | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig
index 21b2bf7..8b64a9e 100644
--- a/arch/arm/configs/stm32_defconfig
+++ b/arch/arm/configs/stm32_defconfig
@@ -56,6 +56,8 @@ CONFIG_MFD_STMPE=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_ARMMMCI=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
--
1.9.1


2018-01-18 14:38:15

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 06/14] ARM: dts: stm32: Add SDIO controller for stm32f746

From: Patrice Chotard <[email protected]>

stm32f746 embeds ARM_PL180 sdio IP, adds SDIO controller
nodes to allow MMC support.

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none

arch/arm/boot/dts/stm32f746.dtsi | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi
index 5f66d15..7f55d00 100644
--- a/arch/arm/boot/dts/stm32f746.dtsi
+++ b/arch/arm/boot/dts/stm32f746.dtsi
@@ -429,6 +429,28 @@
status = "disabled";
};

+ sdio2: sdio2@40011c00 {
+ compatible = "arm,pl180", "arm,primecell";
+ arm,primecell-periphid = <0x00880180>;
+ reg = <0x40011c00 0x400>;
+ clocks = <&rcc 0 167>;
+ clock-names = "apb_pclk";
+ interrupts = <103>;
+ max-frequency = <48000000>;
+ status = "disabled";
+ };
+
+ sdio1: sdio1@40012c00 {
+ compatible = "arm,pl180", "arm,primecell";
+ arm,primecell-periphid = <0x00880180>;
+ reg = <0x40012c00 0x400>;
+ clocks = <&rcc 0 171>;
+ clock-names = "apb_pclk";
+ interrupts = <49>;
+ max-frequency = <48000000>;
+ status = "disabled";
+ };
+
syscfg: system-config@40013800 {
compatible = "syscon";
reg = <0x40013800 0x400>;
--
1.9.1


2018-01-18 14:38:22

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 13/14] ARM: configs: stm32: Enable EXT3_FS support

From: Patrice Chotard <[email protected]>

Enable EXT3_FS support to be able to read rootfs from MMC partition
formatted in EXT2/3/4 .

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/configs/stm32_defconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/stm32_defconfig b/arch/arm/configs/stm32_defconfig
index 8b64a9e..b736823 100644
--- a/arch/arm/configs/stm32_defconfig
+++ b/arch/arm/configs/stm32_defconfig
@@ -72,6 +72,7 @@ CONFIG_STM32_MDMA=y
CONFIG_IIO=y
CONFIG_STM32_ADC_CORE=y
CONFIG_STM32_ADC=y
+CONFIG_EXT3_FS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
--
1.9.1


2018-01-18 14:39:09

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 11/14] ARM: stm32: Add AMBA support for STM32F4 and STM32F7 SoCs

From: Patrice Chotard <[email protected]>

As both STM32F4 and STM32F7 SoCs embeds an AMBA PL180 mmci IP,
we need to enable AMBA support in mach-stm32.

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none

arch/arm/mach-stm32/Kconfig | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-stm32/Kconfig b/arch/arm/mach-stm32/Kconfig
index 0d1889b..f53a8db 100644
--- a/arch/arm/mach-stm32/Kconfig
+++ b/arch/arm/mach-stm32/Kconfig
@@ -13,16 +13,19 @@ config ARCH_STM32
config MACH_STM32F429
bool "STMicrolectronics STM32F429"
depends on ARCH_STM32
+ select ARM_AMBA
default y

config MACH_STM32F469
bool "STMicrolectronics STM32F469"
depends on ARCH_STM32
+ select ARM_AMBA
default y

config MACH_STM32F746
bool "STMicrolectronics STM32F746"
depends on ARCH_STM32
+ select ARM_AMBA
default y

config MACH_STM32H743
--
1.9.1


2018-01-18 14:40:11

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 04/14] mmc: mmci: Add support for setting pad type via pinctrl

From: Patrice Chotard <[email protected]>

If variant hasn't the control bit to switch pads in opendrain mode,
we can achieve the same result by asking to the pinmux driver to
configure pins for us.

This patch make the mmci driver able to do this whenever needed.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ Exit from probe() if no DT pinctrl node are found.

v2: _ Add pinctrl pin management when open drain bit is not available


drivers/mmc/host/mmci.c | 41 +++++++++++++++++++++++++++++++++++++++--
drivers/mmc/host/mmci.h | 5 +++++
2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index f0edfe7..9918a5f 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1465,8 +1465,19 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
~MCI_ST_DATA2DIREN);
}

- if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN && variant->opendrain)
- pwr |= variant->opendrain;
+ if (variant->opendrain) {
+ if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
+ pwr |= variant->opendrain;
+ } else {
+ /*
+ * If the variant cannot configure the pads by its own, then we
+ * expect the pinctrl to be able to do that for us
+ */
+ if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
+ pinctrl_select_state(host->pinctrl, host->pins_opendrain);
+ else
+ pinctrl_select_state(host->pinctrl, host->pins_default);
+ }

/*
* If clock = 0 and the variant requires the MMCIPOWER to be used for
@@ -1610,6 +1621,32 @@ static int mmci_probe(struct amba_device *dev,
host = mmc_priv(mmc);
host->mmc = mmc;

+ /*
+ * Some variant (STM32) doesn't have opendrain bit, nevertheless
+ * pins can be set accordingly using pinctrl
+ */
+ if (!variant->opendrain) {
+ host->pinctrl = devm_pinctrl_get(&dev->dev);
+ if (IS_ERR(host->pinctrl)) {
+ dev_err(&dev->dev, "failed to get pinctrl");
+ goto host_free;
+ }
+
+ host->pins_default = pinctrl_lookup_state(host->pinctrl,
+ PINCTRL_STATE_DEFAULT);
+ if (IS_ERR(host->pins_default)) {
+ dev_err(mmc_dev(mmc), "Can't select default pins\n");
+ goto host_free;
+ }
+
+ host->pins_opendrain = pinctrl_lookup_state(host->pinctrl,
+ MMCI_PINCTRL_STATE_OPENDRAIN);
+ if (IS_ERR(host->pins_opendrain)) {
+ dev_err(mmc_dev(mmc), "Can't select opendrain pins\n");
+ goto host_free;
+ }
+ }
+
host->hw_designer = amba_manf(dev);
host->hw_revision = amba_rev(dev);
dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer);
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 83160a9..f91cdf7 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -192,6 +192,8 @@

#define NR_SG 128

+#define MMCI_PINCTRL_STATE_OPENDRAIN "opendrain"
+
struct clk;
struct variant_data;
struct dma_chan;
@@ -227,6 +229,9 @@ struct mmci_host {
bool vqmmc_enabled;
struct mmci_platform_data *plat;
struct variant_data *variant;
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pins_default;
+ struct pinctrl_state *pins_opendrain;

u8 hw_designer;
u8 hw_revision:4;
--
1.9.1


2018-01-18 14:40:30

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 08/14] ARM: dts: stm32: Add pin map for SDIO controller on stm32f4

From: Andrea Merello <[email protected]>

This patch adds the pin configuration for SDIO controller on
stm32f4.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
index ae94d86..3520289 100644
--- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
+++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi
@@ -338,6 +338,37 @@
slew-rate = <3>;
};
};
+
+ sdio_pins: sdio_pins@0 {
+ pins {
+ pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDIO_D0 */
+ <STM32_PINMUX('C', 9, AF12)>, /* SDIO_D1 */
+ <STM32_PINMUX('C', 10, AF12)>, /* SDIO_D2 */
+ <STM32_PINMUX('C', 11, AF12)>, /* SDIO_D3 */
+ <STM32_PINMUX('C', 12, AF12)>, /* SDIO_CK */
+ <STM32_PINMUX('D', 2, AF12)>; /* SDIO_CMD */
+ drive-push-pull;
+ slew-rate = <2>;
+ };
+ };
+
+ sdio_pins_od: sdio_pins_od@0 {
+ pins1 {
+ pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDIO_D0 */
+ <STM32_PINMUX('C', 9, AF12)>, /* SDIO_D1 */
+ <STM32_PINMUX('C', 10, AF12)>, /* SDIO_D2 */
+ <STM32_PINMUX('C', 11, AF12)>, /* SDIO_D3 */
+ <STM32_PINMUX('C', 12, AF12)>; /* SDIO_CK */
+ drive-push-pull;
+ slew-rate = <2>;
+ };
+
+ pins2 {
+ pinmux = <STM32_PINMUX('D', 2, AF12)>; /* SDIO_CMD */
+ drive-open-drain;
+ slew-rate = <2>;
+ };
+ };
};
};
};
--
1.9.1


2018-01-18 14:41:01

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 07/14] ARM: dts: stm32: Add SDIO controller for stm32f429

From: Patrice Chotard <[email protected]>

stm32f429 embeds ARM_PL180 sdi IP, adds SDIO controller
node to allow MMC support.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/boot/dts/stm32f429.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index 10099df..ede77e0 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -511,6 +511,17 @@
};
};

+ sdio: sdio@40012c00 {
+ compatible = "arm,pl180", "arm,primecell";
+ arm,primecell-periphid = <0x00880180>;
+ reg = <0x40012c00 0x400>;
+ clocks = <&rcc 0 STM32F4_APB2_CLOCK(SDIO)>;
+ clock-names = "apb_pclk";
+ interrupts = <49>;
+ max-frequency = <48000000>;
+ status = "disabled";
+ };
+
syscfg: system-config@40013800 {
compatible = "syscon";
reg = <0x40013800 0x400>;
--
1.9.1


2018-01-18 14:41:14

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 01/14] mmc: mmci: Don't pretend all variants to have MMCIMASK1 register

From: Patrice Chotard <[email protected]>

Two mask registers are used in order to select which events have to
actually generate an interrupt on each IRQ line.

It seems that in the single-IRQ case it's assumed that the IRQs lines
are simply OR-ed, while the two mask registers are still present. The
driver still programs the two mask registers separately.

However the STM32 variant has only one IRQ, and also has only one mask
register.

This patch prepares for STM32 variant support by making the driver using
only one mask register.

This patch also optimize the MMCIMASK1 mask usage by caching it into
host->mask1_reg which avoid to read it into mmci_irq().

Tested only on STM32 variant. RFT for variants other than STM32

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
---
v3: _ none

v2: _ Add Reviewed-by

drivers/mmc/host/mmci.c | 28 ++++++++++++++++++++++++----
drivers/mmc/host/mmci.h | 1 +
2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 97da0fc..3125dc0 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -82,6 +82,7 @@
* @qcom_fifo: enables qcom specific fifo pio read logic.
* @qcom_dml: enables qcom specific dma glue for dma transfers.
* @reversed_irq_handling: handle data irq before cmd irq.
+ * @mmcimask1: true if variant have a MMCIMASK1 register.
*/
struct variant_data {
unsigned int clkreg;
@@ -111,6 +112,7 @@ struct variant_data {
bool qcom_fifo;
bool qcom_dml;
bool reversed_irq_handling;
+ bool mmcimask1;
};

static struct variant_data variant_arm = {
@@ -120,6 +122,7 @@ struct variant_data {
.pwrreg_powerup = MCI_PWR_UP,
.f_max = 100000000,
.reversed_irq_handling = true,
+ .mmcimask1 = true,
};

static struct variant_data variant_arm_extended_fifo = {
@@ -128,6 +131,7 @@ struct variant_data {
.datalength_bits = 16,
.pwrreg_powerup = MCI_PWR_UP,
.f_max = 100000000,
+ .mmcimask1 = true,
};

static struct variant_data variant_arm_extended_fifo_hwfc = {
@@ -137,6 +141,7 @@ struct variant_data {
.datalength_bits = 16,
.pwrreg_powerup = MCI_PWR_UP,
.f_max = 100000000,
+ .mmcimask1 = true,
};

static struct variant_data variant_u300 = {
@@ -152,6 +157,7 @@ struct variant_data {
.signal_direction = true,
.pwrreg_clkgate = true,
.pwrreg_nopower = true,
+ .mmcimask1 = true,
};

static struct variant_data variant_nomadik = {
@@ -168,6 +174,7 @@ struct variant_data {
.signal_direction = true,
.pwrreg_clkgate = true,
.pwrreg_nopower = true,
+ .mmcimask1 = true,
};

static struct variant_data variant_ux500 = {
@@ -190,6 +197,7 @@ struct variant_data {
.busy_detect_flag = MCI_ST_CARDBUSY,
.busy_detect_mask = MCI_ST_BUSYENDMASK,
.pwrreg_nopower = true,
+ .mmcimask1 = true,
};

static struct variant_data variant_ux500v2 = {
@@ -214,6 +222,7 @@ struct variant_data {
.busy_detect_flag = MCI_ST_CARDBUSY,
.busy_detect_mask = MCI_ST_BUSYENDMASK,
.pwrreg_nopower = true,
+ .mmcimask1 = true,
};

static struct variant_data variant_qcom = {
@@ -232,6 +241,7 @@ struct variant_data {
.explicit_mclk_control = true,
.qcom_fifo = true,
.qcom_dml = true,
+ .mmcimask1 = true,
};

/* Busy detection for the ST Micro variant */
@@ -396,6 +406,7 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
static void mmci_set_mask1(struct mmci_host *host, unsigned int mask)
{
void __iomem *base = host->base;
+ struct variant_data *variant = host->variant;

if (host->singleirq) {
unsigned int mask0 = readl(base + MMCIMASK0);
@@ -406,7 +417,10 @@ static void mmci_set_mask1(struct mmci_host *host, unsigned int mask)
writel(mask0, base + MMCIMASK0);
}

- writel(mask, base + MMCIMASK1);
+ if (variant->mmcimask1)
+ writel(mask, base + MMCIMASK1);
+
+ host->mask1_reg = mask;
}

static void mmci_stop_data(struct mmci_host *host)
@@ -1286,7 +1300,7 @@ static irqreturn_t mmci_irq(int irq, void *dev_id)
status = readl(host->base + MMCISTATUS);

if (host->singleirq) {
- if (status & readl(host->base + MMCIMASK1))
+ if (status & host->mask1_reg)
mmci_pio_irq(irq, dev_id);

status &= ~MCI_IRQ1MASK;
@@ -1729,7 +1743,10 @@ static int mmci_probe(struct amba_device *dev,
spin_lock_init(&host->lock);

writel(0, host->base + MMCIMASK0);
- writel(0, host->base + MMCIMASK1);
+
+ if (variant->mmcimask1)
+ writel(0, host->base + MMCIMASK1);
+
writel(0xfff, host->base + MMCICLEAR);

/*
@@ -1809,6 +1826,7 @@ static int mmci_remove(struct amba_device *dev)

if (mmc) {
struct mmci_host *host = mmc_priv(mmc);
+ struct variant_data *variant = host->variant;

/*
* Undo pm_runtime_put() in probe. We use the _sync
@@ -1819,7 +1837,9 @@ static int mmci_remove(struct amba_device *dev)
mmc_remove_host(mmc);

writel(0, host->base + MMCIMASK0);
- writel(0, host->base + MMCIMASK1);
+
+ if (variant->mmcimask1)
+ writel(0, host->base + MMCIMASK1);

writel(0, host->base + MMCICOMMAND);
writel(0, host->base + MMCIDATACTRL);
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 4a8bef1..83160a9 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -223,6 +223,7 @@ struct mmci_host {
u32 clk_reg;
u32 datactrl_reg;
u32 busy_status;
+ u32 mask1_reg;
bool vqmmc_enabled;
struct mmci_platform_data *plat;
struct variant_data *variant;
--
1.9.1


2018-01-18 14:41:19

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 10/14] ARM: dts: stm32: Enable SDIO controller on stm32429i-eval board

From: Patrice Chotard <[email protected]>

This patch adds SDIO related DT nodes for stm32429i-eval board.

Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/boot/dts/stm32429i-eval.dts | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/stm32429i-eval.dts b/arch/arm/boot/dts/stm32429i-eval.dts
index 1e3d4c6..6a5c701 100644
--- a/arch/arm/boot/dts/stm32429i-eval.dts
+++ b/arch/arm/boot/dts/stm32429i-eval.dts
@@ -144,6 +144,13 @@
};
};
};
+
+ mmc_vcard: mmc_vcard {
+ compatible = "regulator-fixed";
+ regulator-name = "mmc_vcard";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
};

&adc {
@@ -254,6 +261,18 @@
status = "okay";
};

+&sdio {
+ status = "okay";
+ vmmc-supply = <&mmc_vcard>;
+ cd-gpios = <&stmpegpio 15 GPIO_ACTIVE_HIGH>;
+ cd-inverted;
+ pinctrl-names = "default", "opendrain";
+ pinctrl-0 = <&sdio_pins>;
+ pinctrl-1 = <&sdio_pins_od>;
+ bus-width = <4>;
+ max-frequency = <12500000>;
+};
+
&timers1 {
status = "okay";

--
1.9.1


2018-01-18 14:42:04

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 09/14] ARM: dts: stm32: Enable SDIO controller on stm32f469 disco board

From: Andrea Merello <[email protected]>

This patch adds SDIO-related DT nodes required by stm32f469 board

There is a hardware issue on these boards, it misses a pullup on
the GPIO line used as card detect to allow correct SD card
detection. To allow correct card detection "broken-cd" property
is used.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Alexandre TORGUE <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---

v3: _ none

v2: _ none


arch/arm/boot/dts/stm32f469-disco.dts | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/stm32f469-disco.dts b/arch/arm/boot/dts/stm32f469-disco.dts
index 318fb12..ebb97c3 100644
--- a/arch/arm/boot/dts/stm32f469-disco.dts
+++ b/arch/arm/boot/dts/stm32f469-disco.dts
@@ -66,6 +66,13 @@
serial0 = &usart3;
};

+ mmc_vcard: mmc_vcard {
+ compatible = "regulator-fixed";
+ regulator-name = "mmc_vcard";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
soc {
dma-ranges = <0xc0000000 0x0 0x10000000>;
};
@@ -120,6 +127,18 @@
};
};

+&sdio {
+ status = "okay";
+ vmmc-supply = <&mmc_vcard>;
+ cd-gpios = <&gpiog 2 0>;
+ cd-inverted;
+ broken-cd;
+ pinctrl-names = "default", "opendrain";
+ pinctrl-0 = <&sdio_pins>;
+ pinctrl-1 = <&sdio_pins_od>;
+ bus-width = <4>;
+};
+
&usart3 {
pinctrl-0 = <&usart3_pins_a>;
pinctrl-names = "default";
--
1.9.1


2018-01-18 14:42:31

by Patrice CHOTARD

[permalink] [raw]
Subject: [PATCH v3 05/14] mmc: mmci: Add STM32 variant

From: Patrice Chotard <[email protected]>

STM32F4 and STM32F7 MCUs has a SDIO controller that looks like
an ARM PL810.
This patch adds the STM32 variant so that mmci driver supports it.

Signed-off-by: Andrea Merello <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
---

v3: _ none

v2: _ Replace "pl180" by "PL180" in commit message

drivers/mmc/host/mmci.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)

diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 9918a5f..30c93c9 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -244,6 +244,23 @@ struct variant_data {
.opendrain = MCI_OD,
};

+static struct variant_data variant_stm32 = {
+ .fifosize = 32 * 4,
+ .fifohalfsize = 8 * 4,
+ .clkreg = MCI_CLK_ENABLE,
+ .clkreg_enable = MCI_ST_UX500_HWFCEN,
+ .clkreg_8bit_bus_enable = MCI_ST_8BIT_BUS,
+ .clkreg_neg_edge_enable = MCI_ST_UX500_NEG_EDGE,
+ .datalength_bits = 24,
+ .datactrl_mask_sdio = MCI_DPSM_ST_SDIOEN,
+ .st_sdio = true,
+ .st_clkdiv = true,
+ .pwrreg_powerup = MCI_PWR_ON,
+ .f_max = 48000000,
+ .pwrreg_clkgate = true,
+ .pwrreg_nopower = true,
+};
+
static struct variant_data variant_qcom = {
.fifosize = 16 * 4,
.fifohalfsize = 8 * 4,
@@ -2021,6 +2038,11 @@ static int mmci_runtime_resume(struct device *dev)
.mask = 0xf0ffffff,
.data = &variant_ux500v2,
},
+ {
+ .id = 0x00880180,
+ .mask = 0x00ffffff,
+ .data = &variant_stm32,
+ },
/* Qualcomm variants */
{
.id = 0x00051180,
--
1.9.1


2018-01-18 17:05:07

by Alexandre Torgue

[permalink] [raw]
Subject: Re: [PATCH v3 00/14] Add MMCI support for STM32F SoCs family

Hi Patrice,


On 01/18/2018 03:34 PM, [email protected] wrote:
> From: Patrice Chotard <[email protected]>
>
> This series reworks patches submitted one year ago by Andrea Merello [1]
> but without succeed to merged it.
>
> STM32F4 and STM32F7 SoCs families embeds a variant of the ARM PrimeCell
> PL18x SD host controller, for which the mmci driver exists.
> This series adds support for these SoCs to the mmci driver.
>
> As other variants, this one need some specific quirks, that this
> series address.
>
> This series has been tested on following boards :
> _ stm32f429-eval
> _ stm32f469-disco
> _ stm32f746-eval
> _ stm32f769-disco
>
> DT update for stm32f7 pinctrl, stm32f746-eval and stm32f769-disco boards
> will be sent later to avoid conflict with pending stm32f7 series [1] which
> is not yet merged on kernel mainline.
>
> [1] https://www.spinics.net/lists/linux-mmc/msg41616.html
> [2] https://patchwork.kernel.org/patch/10104447/
>
> v3: _ patch 3: use variant->opendrain instead of host->variant->opendrain
> _ patch 4: exit from probe() if no pinctrl dt node are found
> _ previous patch 15: removed as already applied in pinctrl tree
>
> v2: _ add Revievied-by, Acked-by in some patches
> _ replace bool by u32 for start_err and opendrain fields of struct variant_data
> _ split previous patch 3 in two parts, first patch clean the open drain bit code
> and second part add pinctrl pins management when no open drain bit is available.
> _ replace "pl180" by "PL180" in patch "mmc: mmci: Add STM32 variant"
>
> Andrea Merello (2):
> ARM: dts: stm32: Add pin map for SDIO controller on stm32f4
> ARM: dts: stm32: Enable SDIO controller on stm32f469 disco board

Looks good for STM32 machine part (DT/configs/mach-stm32). I will apply
them in my next pull request.

Thanks.

Alex

>
> Patrice Chotard (12):
> mmc: mmci: Don't pretend all variants to have MMCIMASK1 register
> mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag
> mmc: mmci: Don't pretend all variants to have OPENDRAIN bit
> mmc: mmci: Add support for setting pad type via pinctrl
> mmc: mmci: Add STM32 variant
> ARM: dts: stm32: Add SDIO controller for stm32f746
> ARM: dts: stm32: Add SDIO controller for stm32f429
> ARM: dts: stm32: Enable SDIO controller on stm32429i-eval board
> ARM: stm32: Add AMBA support for STM32F4 and STM32F7 SoCs
> ARM: configs: stm32: Enable MMC_ARMMMCI support
> ARM: configs: stm32: Enable EXT3_FS support
> clk: stm32: Add clk entry for SDMMC2 on stm32F769
>
> arch/arm/boot/dts/stm32429i-eval.dts | 19 +++++
> arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 31 +++++++++
> arch/arm/boot/dts/stm32f429.dtsi | 11 +++
> arch/arm/boot/dts/stm32f469-disco.dts | 19 +++++
> arch/arm/boot/dts/stm32f746.dtsi | 22 ++++++
> arch/arm/configs/stm32_defconfig | 3 +
> arch/arm/mach-stm32/Kconfig | 3 +
> drivers/clk/clk-stm32f4.c | 3 +-
> drivers/mmc/host/mmci.c | 124 ++++++++++++++++++++++++++++-----
> drivers/mmc/host/mmci.h | 6 ++
> 10 files changed, 224 insertions(+), 17 deletions(-)
>

2018-01-18 17:17:10

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH v3 00/14] Add MMCI support for STM32F SoCs family

On 18 January 2018 at 15:34, <[email protected]> wrote:
> From: Patrice Chotard <[email protected]>
>
> This series reworks patches submitted one year ago by Andrea Merello [1]
> but without succeed to merged it.
>
> STM32F4 and STM32F7 SoCs families embeds a variant of the ARM PrimeCell
> PL18x SD host controller, for which the mmci driver exists.
> This series adds support for these SoCs to the mmci driver.
>
> As other variants, this one need some specific quirks, that this
> series address.
>
> This series has been tested on following boards :
> _ stm32f429-eval
> _ stm32f469-disco
> _ stm32f746-eval
> _ stm32f769-disco
>
> DT update for stm32f7 pinctrl, stm32f746-eval and stm32f769-disco boards
> will be sent later to avoid conflict with pending stm32f7 series [1] which
> is not yet merged on kernel mainline.
>
> [1] https://www.spinics.net/lists/linux-mmc/msg41616.html
> [2] https://patchwork.kernel.org/patch/10104447/
>
> v3: _ patch 3: use variant->opendrain instead of host->variant->opendrain
> _ patch 4: exit from probe() if no pinctrl dt node are found
> _ previous patch 15: removed as already applied in pinctrl tree
>
> v2: _ add Revievied-by, Acked-by in some patches
> _ replace bool by u32 for start_err and opendrain fields of struct variant_data
> _ split previous patch 3 in two parts, first patch clean the open drain bit code
> and second part add pinctrl pins management when no open drain bit is available.
> _ replace "pl180" by "PL180" in patch "mmc: mmci: Add STM32 variant"
>
> Andrea Merello (2):
> ARM: dts: stm32: Add pin map for SDIO controller on stm32f4
> ARM: dts: stm32: Enable SDIO controller on stm32f469 disco board
>
> Patrice Chotard (12):
> mmc: mmci: Don't pretend all variants to have MMCIMASK1 register
> mmc: mmci: Don't pretend all variants to have MCI_STARBITERR flag
> mmc: mmci: Don't pretend all variants to have OPENDRAIN bit
> mmc: mmci: Add support for setting pad type via pinctrl
> mmc: mmci: Add STM32 variant
> ARM: dts: stm32: Add SDIO controller for stm32f746
> ARM: dts: stm32: Add SDIO controller for stm32f429
> ARM: dts: stm32: Enable SDIO controller on stm32429i-eval board
> ARM: stm32: Add AMBA support for STM32F4 and STM32F7 SoCs
> ARM: configs: stm32: Enable MMC_ARMMMCI support
> ARM: configs: stm32: Enable EXT3_FS support
> clk: stm32: Add clk entry for SDMMC2 on stm32F769
>
> arch/arm/boot/dts/stm32429i-eval.dts | 19 +++++
> arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 31 +++++++++
> arch/arm/boot/dts/stm32f429.dtsi | 11 +++
> arch/arm/boot/dts/stm32f469-disco.dts | 19 +++++
> arch/arm/boot/dts/stm32f746.dtsi | 22 ++++++
> arch/arm/configs/stm32_defconfig | 3 +
> arch/arm/mach-stm32/Kconfig | 3 +
> drivers/clk/clk-stm32f4.c | 3 +-
> drivers/mmc/host/mmci.c | 124 ++++++++++++++++++++++++++++-----
> drivers/mmc/host/mmci.h | 6 ++
> 10 files changed, 224 insertions(+), 17 deletions(-)
>
> --
> 1.9.1
>

Thanks, applied patch1 to patch5 for next!

Kind regards
Uffe

2018-02-27 13:27:52

by Alexandre Torgue

[permalink] [raw]
Subject: Re: [PATCH v3 00/14] Add MMCI support for STM32F SoCs family

Hi Patrice,

On 01/18/2018 03:34 PM, [email protected] wrote:
> From: Patrice Chotard <[email protected]>
>
> This series reworks patches submitted one year ago by Andrea Merello [1]
> but without succeed to merged it.
>
> STM32F4 and STM32F7 SoCs families embeds a variant of the ARM PrimeCell
> PL18x SD host controller, for which the mmci driver exists.
> This series adds support for these SoCs to the mmci driver.
>
> As other variants, this one need some specific quirks, that this
> series address.
>
> This series has been tested on following boards :
> _ stm32f429-eval
> _ stm32f469-disco
> _ stm32f746-eval
> _ stm32f769-disco
>
> DT update for stm32f7 pinctrl, stm32f746-eval and stm32f769-disco boards
> will be sent later to avoid conflict with pending stm32f7 series [1] which
> is not yet merged on kernel mainline.
>
> [1] https://www.spinics.net/lists/linux-mmc/msg41616.html
> [2] https://patchwork.kernel.org/patch/10104447/
>
...

Patches 6 to 13 (DT/SoC/configs) applied on stm32-next.

Thanks
Alex