Skip to contentSkip to conversation

msdc: Add mediatek MMC driver

RFC PATCH Superseded Chaotian Jing 5 participants 14 messages Jan 27, 2015 – Feb 10, 2015

Subsystems (8)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Chaotian Jing

author maintainer
#0 lore raw

cover msdc: Add mediatek MMC driver

This series enables MMC support on the MT8135/MT8173 platform. MT8135 has 5 MMC controllers and MT8173 has 4 MMC controllers. These controllers share one source clock.

This depends on 3.19-rc1 + Hongzhou's mt8135 pinctrl support[1] + James's mt8135 clock support[2].

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/318450.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/313793.html

Chaotian Jing (6):
mmc: mediatek: Add Mediatek MMC driver
ARM: mediatek: Add Mediatek MMC support in multi_v7_defconfig
arm64: mediatek: Add Mediatek MMC support in defconfig
mmc: dt-bindings: add Mediatek MMC bindings
dts: mediatek: Add MT8135 mmc dts
arm64: dts: mediatek: Add MT8173 MMC dts

Yingjoe Chen (1):
pinctrl: mediatek: emulate GPIO interrupt on both-edges

 Documentation/devicetree/bindings/mmc/mtk-sd.txt |   33 +
 arch/arm/boot/dts/mt8135-evbp1.dts               |  137 ++
 arch/arm/boot/dts/mt8135.dtsi                    |   27 +
 arch/arm/configs/multi_v7_defconfig              |    1 +
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts      |  115 ++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi         |   19 +-
 arch/arm64/configs/defconfig                     |    1 +
 drivers/mmc/host/Kconfig                         |    8 +
 drivers/mmc/host/Makefile                        |    1 +
 drivers/mmc/host/mtk-sd.c                        | 1786 ++++++++++++++++++++++
 drivers/pinctrl/mediatek/pinctrl-mt8135.c        |    3 +
 drivers/pinctrl/mediatek/pinctrl-mt8173.c        |    3 +
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c    |   76 +-
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h    |    4 +
 14 files changed, 2210 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mtk-sd.txt
 create mode 100644 drivers/mmc/host/mtk-sd.c
author maintainer
#1 lore raw

PATCH 1/7 pinctrl: mediatek: emulate GPIO interrupt on both-edges

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

---
 drivers/pinctrl/mediatek/pinctrl-mt8135.c     |  3 ++
 drivers/pinctrl/mediatek/pinctrl-mt8173.c     |  3 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 76 +++++++++++++++++++++++++--
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |  4 ++
 4 files changed, 83 insertions(+), 3 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mt8135.c +3 -0
index b6ee2b2..1296d6d 100644
@@ -325,6 +325,9 @@ static const struct mtk_pinctrl_devdata mt8135_pinctrl_data = {
 		.sens      = 0x140,
 		.sens_set  = 0x180,
 		.sens_clr  = 0x1c0,
+		.soft      = 0x200,
+		.soft_set  = 0x240,
+		.soft_clr  = 0x280,
 		.pol       = 0x300,
 		.pol_set   = 0x340,
 		.pol_clr   = 0x380,
drivers/pinctrl/mediatek/pinctrl-mt8173.c +3 -0
index 444d88d..717000e 100644
@@ -278,6 +278,9 @@ static const struct mtk_pinctrl_devdata mt8173_pinctrl_data = {
 		.sens      = 0x140,
 		.sens_set  = 0x180,
 		.sens_clr  = 0x1c0,
+		.soft      = 0x200,
+		.soft_set  = 0x240,
+		.soft_clr  = 0x280,
 		.pol       = 0x300,
 		.pol_set   = 0x340,
 		.pol_clr   = 0x380,
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +73 -3

142 lines not on this page · raw message

drivers/pinctrl/mediatek/pinctrl-mtk-common.h +4 -0
index 740e6d2..375771d 100644
@@ -131,6 +131,9 @@ struct mtk_eint_offsets {
 	unsigned int  sens;
 	unsigned int  sens_set;
 	unsigned int  sens_clr;
+	unsigned int  soft;
+	unsigned int  soft_set;
+	unsigned int  soft_clr;
 	unsigned int  pol;
 	unsigned int  pol_set;
 	unsigned int  pol_clr;
@@ -217,6 +220,7 @@ struct mtk_pinctrl {
 	const struct mtk_pinctrl_devdata  *devdata;
 	void __iomem		*eint_reg_base;
 	struct irq_domain	*domain;
+	int			*eint_dual_edges;
 };
 
 int mtk_pctrl_init(struct platform_device *pdev,
Signature · 1 line
1.8.1.1.dirty
#2 lore raw

Re: [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges

Quoted 9 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

Hongzhu, if you're fine with this patch can you ACK it as maintainer of the pinctrl driver so I can merge it immediately on top of your drivern whenever we consider it finished (and if it applies still...)

Yours,
Linus Walleij

#3 lore raw

PATCH 1/7 pinctrl: mediatek: emulate GPIO interrupt on both-edges

Quoted 10 lines · Linus Walleij
Quoted 7 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

Quoted 6 lines
Quoted 2 lines

Hongzhu, if you're fine with this patch can you ACK it as maintainer of the pinctrl driver so I can merge it immediately on top of your drivern whenever we consider it finished (and if it applies still...)

Hi Linus,

Thanks for reviewing.
Please note this patch depends on mt8173 pinctrl driver patch[1], and modify files introduced in that patch. So this patch should be merged after that series.

Joe.C

[1]
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-January/320066.html

#4 lore raw

PATCH 1/7 pinctrl: mediatek: emulate GPIO interrupt on both-edges

In reply to Linus Walleij
Quoted 13 lines · Linus Walleij
Quoted 9 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

Quoted 6 lines

Hongzhu, if you're fine with this patch can you ACK it as maintainer of the pinctrl driver so I can merge it immediately on top of your drivern whenever we consider it finished (and if it applies still...)

Yours,
Linus Walleij

Hi Linus,

I think it's good, thank you.

Yours,
Hongzhou

#5 lore raw

Re: [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges

In reply to Chaotian Jing
Quoted 9 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

Patch applied on top of the rest of the mtk pinctrl support. Adding Hongzhou's ACK on top.

Yours,
Linus Walleij

#6 lore raw

Re: [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges

In reply to Chaotian Jing

Hello,

Quoted 89 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

---
 drivers/pinctrl/mediatek/pinctrl-mt8135.c     |  3 ++
 drivers/pinctrl/mediatek/pinctrl-mt8173.c     |  3 ++
 drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 76 +++++++++++++++++++++++++--
 drivers/pinctrl/mediatek/pinctrl-mtk-common.h |  4 ++
 4 files changed, 83 insertions(+), 3 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mt8135.c +3 -0
index b6ee2b2..1296d6d 100644
@@ -325,6 +325,9 @@ static const struct mtk_pinctrl_devdata mt8135_pinctrl_data = {
 		.sens      = 0x140,
 		.sens_set  = 0x180,
 		.sens_clr  = 0x1c0,
+		.soft      = 0x200,
+		.soft_set  = 0x240,
+		.soft_clr  = 0x280,
 		.pol       = 0x300,
 		.pol_set   = 0x340,
 		.pol_clr   = 0x380,
drivers/pinctrl/mediatek/pinctrl-mt8173.c +3 -0
index 444d88d..717000e 100644
@@ -278,6 +278,9 @@ static const struct mtk_pinctrl_devdata mt8173_pinctrl_data = {
 		.sens      = 0x140,
 		.sens_set  = 0x180,
 		.sens_clr  = 0x1c0,
+		.soft      = 0x200,
+		.soft_set  = 0x240,
+		.soft_clr  = 0x280,
 		.pol       = 0x300,
 		.pol_set   = 0x340,
 		.pol_clr   = 0x380,
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +29 -0
index 109a882..820ce9e 100644
@@ -792,6 +792,32 @@ static unsigned int mtk_eint_get_mask(struct mtk_pinctrl *pctl,
 	return !!(readl(reg) & bit);
 }
 
+static int mtk_eint_flip_edge(struct mtk_pinctrl *pctl, int hwirq)
+{
+	int start_level, curr_level;
+	unsigned int reg_offset;
+	const struct mtk_eint_offsets *eint_offsets = &(pctl->devdata->eint_offsets);
+	u32 mask = 1 << (hwirq & 0x1f);
+	u32 port = (hwirq >> 5) & eint_offsets->port_mask;
+	void __iomem *reg = pctl->eint_reg_base + (port << 2);
+	const struct mtk_desc_pin *pin;
+
+	pin = mtk_find_pin_by_eint_num(pctl, hwirq);
+	curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
+	do {
+		start_level = curr_level;
+		if (start_level)
+			reg_offset = eint_offsets->pol_clr;
+		else
+			reg_offset = eint_offsets->pol_set;
+		writel(mask, reg + reg_offset);
+
+		curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
+	} while (start_level != curr_level);
+
+	return start_level;
+}
+
 static void mtk_eint_mask(struct irq_data *d)
 {
 	struct mtk_pinctrl *pctl = irq_data_get_irq_chip_data(d);
@@ -814,6 +840,9 @@ static void mtk_eint_unmask(struct irq_data *d)
 			eint_offsets->mask_clr);
 
 	writel(mask, reg);
+
+	if (pctl->eint_dual_edges[d->hwirq])
+		mtk_eint_flip_edge(pctl, d->hwirq);
 }
Quoted 1 line

From looking at the code it seems to me that there is a bug. Consider

the following to happen:

pin changes level, say high to low, triggers irq

irq is masked by writel(mask, reg) in mtk_eint_mask

mtk_eint_flip_edge gets curr_level = low

pin goes up

writel(mask, reg + eint_offsets->pol_set);

oh, pin is high, so: writel(mask, reg + eint_offsets->pol_clr

So now you trigger the irq the next time when the pin goes down again. But that means to missed to trigger on the "pin goes up" in the above list, right?

Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#7 lore raw

Re: [PATCH 1/7] pinctrl: mediatek: emulate GPIO interrupt on both-edges

Quoted 9 lines · Uwe Kleine-K?nig

Hello,

Quoted 6 lines · Chaotian Jing

From: Yingjoe Chen <[email protected]>

MTK EINT does not support generating interrupt on both edges. Emulate this by changing edge polarity while enable irq, set types and interrupt handling. This follows an example of drivers/gpio/gpio-mxc.c.

<...>

Quoted 48 lines
Quoted 30 lines
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +26 -0
+static int mtk_eint_flip_edge(struct mtk_pinctrl *pctl, int hwirq)
+{
+	int start_level, curr_level;
+	unsigned int reg_offset;
+	const struct mtk_eint_offsets *eint_offsets = &(pctl->devdata->eint_offsets);
+	u32 mask = 1 << (hwirq & 0x1f);
+	u32 port = (hwirq >> 5) & eint_offsets->port_mask;
+	void __iomem *reg = pctl->eint_reg_base + (port << 2);
+	const struct mtk_desc_pin *pin;
+
+	pin = mtk_find_pin_by_eint_num(pctl, hwirq);
+	curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
+	do {
+		start_level = curr_level;
+		if (start_level)
+			reg_offset = eint_offsets->pol_clr;
+		else
+			reg_offset = eint_offsets->pol_set;
+		writel(mask, reg + reg_offset);
+
+		curr_level = mtk_gpio_get(pctl->chip, pin->pin.number);
+	} while (start_level != curr_level);
+
+	return start_level;
+}
+
 static void mtk_eint_mask(struct irq_data *d)
 {
 	struct mtk_pinctrl *pctl = irq_data_get_irq_chip_data(d);

drivers/pinctrl/mediatek/pinctrl-mtk-common.c static void mtk_eint_unmask(struct irq_data *d) · line 846

Quoted 7 lines
drivers/pinctrl/mediatek/pinctrl-mtk-common.c +3 -0
@@ -814,6 +840,9 @@ static void mtk_eint_unmask(struct irq_data *d)
 			eint_offsets->mask_clr);
 
 	writel(mask, reg);
+
+	if (pctl->eint_dual_edges[d->hwirq])
+		mtk_eint_flip_edge(pctl, d->hwirq);
 }

From looking at the code it seems to me that there is a bug. Consider the following to happen:

pin changes level, say high to low, triggers irq

irq is masked by writel(mask, reg) in mtk_eint_mask

mtk_eint_flip_edge gets curr_level = low

pin goes up

Quoted 7 lines

writel(mask, reg + eint_offsets->pol_set);

oh, pin is high, so: writel(mask, reg + eint_offsets->pol_clr

So now you trigger the irq the next time when the pin goes down again. But that means to missed to trigger on the "pin goes up" in the above list, right?

Hi Uwe,

Yes, this could be a problem when irq happen. So I fix/workaround this in mtk_eint_irq_handler() using soft-irq. When this bit is set, eint will trigger the same interrupt again.

+ if (dual_edges) {
+ curr_level = mtk_eint_flip_edge(pctl, index);
+
+ /* If level changed, we might lost one edge
+ interrupt, raised it through soft-irq */
+ if (start_level != curr_level)
+ writel(BIT(offset), reg -
+ eint_offsets->stat +
+ eint_offsets->soft_set);
+ }

Joe.C

author maintainer
#8 lore raw

PATCH 2/7 mmc: mediatek: Add Mediatek MMC driver

In reply to Chaotian Jing

Add Mediatek MMC driver code

---
 drivers/mmc/host/Kconfig  |    8 +
 drivers/mmc/host/Makefile |    1 +
 drivers/mmc/host/mtk-sd.c | 1786 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1795 insertions(+)
 create mode 100644 drivers/mmc/host/mtk-sd.c
drivers/mmc/host/Kconfig +8 -0
index 2d6fbdd..c37b705 100644
@@ -753,3 +753,11 @@ config MMC_TOSHIBA_PCI
 	tristate "Toshiba Type A SD/MMC Card Interface Driver"
 	depends on PCI
 	help
+
+config MMC_MTK
+	tristate "MediaTek SD/MMC Card Interface support"
+	help
+	  This selects the MediaTek(R) Secure digital and Multimedia card Interface.
+	  If you have a machine with a integrated SD/MMC card reader, say Y or M here.
+	  This is needed if support for any SD/SDIO/MMC devices is required.
+	  If unsure, say N.
drivers/mmc/host/Makefile +1 -0
index f7b0a77..f55f299 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_MMC_SDHCI_SIRF)   	+= sdhci-sirf.o
 obj-$(CONFIG_MMC_SDHCI_SPEAR)	+= sdhci-spear.o
 obj-$(CONFIG_MMC_WBSD)		+= wbsd.o
 obj-$(CONFIG_MMC_AU1X)		+= au1xmmc.o
+obj-$(CONFIG_MMC_MTK)           += mtk-sd.o
 obj-$(CONFIG_MMC_OMAP)		+= omap.o
 obj-$(CONFIG_MMC_OMAP_HS)	+= omap_hsmmc.o
 obj-$(CONFIG_MMC_ATMELMCI)	+= atmel-mci.o
drivers/mmc/host/mtk-sd.c new file +1786 -0

1,786 lines not on this page · raw message

Signature · 1 line
1.8.1.1.dirty
author maintainer
#9 lore raw

PATCH 3/7 ARM: mediatek: Add Mediatek MMC support in multi_v7_defconfig

In reply to Chaotian Jing

Add CONFIG_MMC_MTK=y in multi_v7_defconfig

---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
index 19e58aa..7eea580 100644
@@ -362,6 +362,7 @@ CONFIG_MMC_DW_IDMAC=y
 CONFIG_MMC_DW_EXYNOS=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SUNXI=y
+CONFIG_MMC_MTK=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
Signature · 1 line
1.8.1.1.dirty
author maintainer
#10 lore raw

PATCH 4/7 arm64: mediatek: Add Mediatek MMC support in defconfig

In reply to Chaotian Jing

Add CONFIG_MMC_MTK=y in defconfig

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 5afda35..678c583 100644
@@ -121,6 +121,7 @@ CONFIG_MMC_ARMMMCI=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_SPI=y
+CONFIG_MMC_MTK=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_EFI=y
 CONFIG_RTC_DRV_XGENE=y
Signature · 1 line
1.8.1.1.dirty
author maintainer
#11 lore raw

PATCH 5/7 mmc: dt-bindings: add Mediatek MMC bindings

In reply to Chaotian Jing

Document the device-tree binding of Mediatek MMC host

---
 Documentation/devicetree/bindings/mmc/mtk-sd.txt | 33 ++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/mtk-sd.txt
Documentation/devicetree/bindings/mmc/mtk-sd.txt new file +33 -0
new file mode 100644
index 0000000..7667ec7
@@ -0,0 +1,33 @@
+* MTK MMC controller
+
+The MTK  MSDC can act as a MMC controller
+to support MMC, SD, and SDIO types of memory cards.
+
+This file documents differences between the core properties in mmc.txt
+and the properties used by the msdc driver.
+
+Required properties:
+- compatible: Should be "mediatek,mt8173-mmc","mediatek,mt8135-mmc".
+- interrupts: Should contain MSDC interrupt number
+- core-power-supply: power to the Core
+- clocks: MSDC source clock
+- clock-names: "source"
+- pinctrl-names: should be "default", "state_uhs"
+- pinctrl-0: should contain default/high speed pin ctrl
+- pinctrl-1: should contain uhs mode pin ctrl
+
+Optional properties:
+- io-power-supply: power to the IO(for SD/SDIO)
+
+Examples:
+mmc0: mmc at 11230000 {
+	compatible = "mediatek,mt8173-mmc","mediatek,mt8135-mmc";
+	reg = <0 0x11230000 0 0x108>;
+	interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_LOW>;
+	core-power-supply = <&mt6397_vemc_3v3_reg>;
+	clocks = <&pericfg PERI_MSDC20_1_CK>;
+	clock-names = "source";
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+};
Signature · 1 line
1.8.1.1.dirty
author maintainer
#12 lore raw

PATCH 6/7 dts: mediatek: Add MT8135 mmc dts

In reply to Chaotian Jing

Add node mmc0, mmc1, mmc2

---
 arch/arm/boot/dts/mt8135-evbp1.dts | 137 +++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/mt8135.dtsi      |  27 ++++++++
 2 files changed, 164 insertions(+)
arch/arm/boot/dts/mt8135-evbp1.dts +137 -0
index 73a833b..34abca6 100644
@@ -226,3 +226,140 @@
 		};
 	};
 };
+
+&pio {
+	mmc0_pins_default: mmc0default {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_0_MSDC0_DAT7__FUNC_MSDC0_DAT7>,
+				<MT8135_PIN_1_MSDC0_DAT6__FUNC_MSDC0_DAT6>,
+				<MT8135_PIN_2_MSDC0_DAT5__FUNC_MSDC0_DAT5>,
+				<MT8135_PIN_3_MSDC0_DAT4__FUNC_MSDC0_DAT4>,
+				<MT8135_PIN_4_MSDC0_CMD__FUNC_MSDC0_CMD>,
+				<MT8135_PIN_6_MSDC0_DAT3__FUNC_MSDC0_DAT3>,
+				<MT8135_PIN_7_MSDC0_DAT2__FUNC_MSDC0_DAT2>,
+				<MT8135_PIN_8_MSDC0_DAT1__FUNC_MSDC0_DAT1>,
+				<MT8135_PIN_9_MSDC0_DAT0__FUNC_MSDC0_DAT0>,
+				<MT8135_PIN_33_MSDC0_RSTB__FUNC_MSDC0_RSTB>;
+			bias-pull-up;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_5_MSDC0_CLK__FUNC_MSDC0_CLK>;
+			bias-pull-down;
+		};
+	};
+
+	mmc1_pins_default: mmc1default {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_83_MSDC1_DAT0__FUNC_MSDC1_DAT0>,
+			     <MT8135_PIN_84_MSDC1_DAT1__FUNC_MSDC1_DAT1>,
+			     <MT8135_PIN_85_MSDC1_CMD__FUNC_MSDC1_CMD>,
+			     <MT8135_PIN_87_MSDC1_DAT2__FUNC_MSDC1_DAT2>,
+			     <MT8135_PIN_88_MSDC1_DAT3__FUNC_MSDC1_DAT3>,
+			     <MT8135_PIN_63_MSDC1_INSI__FUNC_MSDC1_INSI>;
+			bias-pull-up;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_86_MSDC1_CLK__FUNC_MSDC1_CLK>;
+			bias-pull-down;
+		};
+	};
+
+	mmc2_pins_default: mmc2default {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_82_MSDC2_DAT0__FUNC_MSDC2_DAT0>,
+			     <MT8135_PIN_81_MSDC2_DAT1__FUNC_MSDC2_DAT1>,
+			     <MT8135_PIN_79_MSDC2_CMD__FUNC_MSDC2_CMD>,
+			     <MT8135_PIN_77_MSDC2_DAT2__FUNC_MSDC2_DAT2>,
+			     <MT8135_PIN_78_MSDC2_DAT3__FUNC_MSDC2_DAT3>,
+			     <MT8135_PIN_65_MSDC2_INSI__FUNC_MSDC2_INSI>;
+			bias-pull-up;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_80_MSDC2_CLK__FUNC_MSDC2_CLK>;
+		bias-pull-down;
+		};
+	};
+
+	mmc0_pins_uhs: mmc0 at 0 {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_0_MSDC0_DAT7__FUNC_MSDC0_DAT7>,
+			     <MT8135_PIN_1_MSDC0_DAT6__FUNC_MSDC0_DAT6>,
+			     <MT8135_PIN_2_MSDC0_DAT5__FUNC_MSDC0_DAT5>,
+			     <MT8135_PIN_3_MSDC0_DAT4__FUNC_MSDC0_DAT4>,
+			     <MT8135_PIN_4_MSDC0_CMD__FUNC_MSDC0_CMD>,
+			     <MT8135_PIN_6_MSDC0_DAT3__FUNC_MSDC0_DAT3>,
+			     <MT8135_PIN_7_MSDC0_DAT2__FUNC_MSDC0_DAT2>,
+			     <MT8135_PIN_8_MSDC0_DAT1__FUNC_MSDC0_DAT1>,
+			     <MT8135_PIN_9_MSDC0_DAT0__FUNC_MSDC0_DAT0>,
+			     <MT8135_PIN_33_MSDC0_RSTB__FUNC_MSDC0_RSTB>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_6mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_5_MSDC0_CLK__FUNC_MSDC0_CLK>;
+			drive-strength = <MTK_DRIVE_6mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
+		};
+	};
+
+	mmc1_pins_uhs: mmc1 at 0 {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_83_MSDC1_DAT0__FUNC_MSDC1_DAT0>,
+			     <MT8135_PIN_84_MSDC1_DAT1__FUNC_MSDC1_DAT1>,
+			     <MT8135_PIN_85_MSDC1_CMD__FUNC_MSDC1_CMD>,
+			     <MT8135_PIN_87_MSDC1_DAT2__FUNC_MSDC1_DAT2>,
+			     <MT8135_PIN_88_MSDC1_DAT3__FUNC_MSDC1_DAT3>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_86_MSDC1_CLK__FUNC_MSDC1_CLK>;
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+		};
+	};
+
+	mmc2_pins_uhs: mmc2 at 0 {
+		pins_cmd_dat {
+			pins = <MT8135_PIN_82_MSDC2_DAT0__FUNC_MSDC2_DAT0>,
+			     <MT8135_PIN_81_MSDC2_DAT1__FUNC_MSDC2_DAT1>,
+			     <MT8135_PIN_79_MSDC2_CMD__FUNC_MSDC2_CMD>,
+			     <MT8135_PIN_77_MSDC2_DAT2__FUNC_MSDC2_DAT2>,
+			     <MT8135_PIN_78_MSDC2_DAT3__FUNC_MSDC2_DAT3>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+		};
+		pins_clk {
+			pins = <MT8135_PIN_80_MSDC2_CLK__FUNC_MSDC2_CLK>;
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+		};
+	};
+};
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	status = "okay";
+	bus-width = <8>;
+	max-frequency = <50000000>;
+	cap-mmc-highspeed;
+	core-power-supply = <&mt6397_vemc_3v3_reg>;
+	non-removable;
+};
+
+&mmc1 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc1_pins_default>;
+	pinctrl-1 = <&mmc1_pins_uhs>;
+	status = "okay";
+	bus-width = <4>;
+	max-frequency = <50000000>;
+	core-power-supply = <&mt6397_vmch_reg>;
+	io-power-supply = <&mt6397_vmc_reg>;
+	cd-gpios = <&pio 63 0>;
+};
arch/arm/boot/dts/mt8135.dtsi +27 -0
index 53ce89f..cc2550c 100644
@@ -253,5 +253,32 @@
 			      <0 0x10214000 0 0x2000>,
 			      <0 0x10216000 0 0x2000>;
 		};
+
+		mmc0: mmc at 11230000 {
+			compatible = "mediatek,mt8135-mmc";
+			reg = <0 0x11230000 0 0x108>;
+			interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&pericfg PERI_MSDC20_1_CK>;
+			clock-names = "source";
+			status = "disabled";
+		};
+
+		mmc1: mmc at 11240000 {
+			compatible = "mediatek,mt8135-mmc";
+			reg = <0 0x11240000 0 0x108>;
+			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&pericfg PERI_MSDC20_2_CK>;
+			clock-names = "source";
+			status = "disabled";
+		};
+
+		mmc2: mmc at 11250000 {
+			compatible = "mediatek,mt8135-mmc";
+			reg = <0 0x11250000 0 0x108>;
+			interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&pericfg PERI_MSDC30_1_CK>;
+			clock-names = "source";
+			status = "disabled";
+		};
 	};
 };
Signature · 1 line
1.8.1.1.dirty
author maintainer
#13 lore raw

PATCH 7/7 arm64: dts: mediatek: Add MT8173 MMC dts

In reply to Chaotian Jing

Add node mmc0 and mmc1

---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 115 ++++++++++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    |  19 ++++-
 2 files changed, 133 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8173-evb.dts +115 -0
index a58ea20..bfbe18d 100644
@@ -235,3 +235,118 @@
 		};
 	};
 };
+
+&pio {
+	mmc0_pins_default: mmc0default {
+		pins_cmd_dat {
+			pins = <MT8173_PIN_64_MSDC0_DAT7__FUNC_MSDC0_DAT7>,
+				<MT8173_PIN_63_MSDC0_DAT6__FUNC_MSDC0_DAT6>,
+				<MT8173_PIN_62_MSDC0_DAT5__FUNC_MSDC0_DAT5>,
+				<MT8173_PIN_61_MSDC0_DAT4__FUNC_MSDC0_DAT4>,
+				<MT8173_PIN_66_MSDC0_CMD__FUNC_MSDC0_CMD>,
+				<MT8173_PIN_60_MSDC0_DAT3__FUNC_MSDC0_DAT3>,
+				<MT8173_PIN_59_MSDC0_DAT2__FUNC_MSDC0_DAT2>,
+				<MT8173_PIN_58_MSDC0_DAT1__FUNC_MSDC0_DAT1>,
+				<MT8173_PIN_57_MSDC0_DAT0__FUNC_MSDC0_DAT0>,
+				<MT8173_PIN_68_MSDC0_RST___FUNC_MSDC0_RSTB>;
+				bias-pull-up;
+		};
+		pins_clk {
+			pins =  <MT8173_PIN_65_MSDC0_CLK__FUNC_MSDC0_CLK>;
+				bias-pull-down;
+		};
+	};
+
+	mmc1_pins_default: mmc1default {
+		pins_cmd_dat {
+			pins = <MT8173_PIN_73_MSDC1_DAT0__FUNC_MSDC1_DAT0>,
+			     <MT8173_PIN_74_MSDC1_DAT1__FUNC_MSDC1_DAT1>,
+			     <MT8173_PIN_78_MSDC1_CMD__FUNC_MSDC1_CMD>,
+			     <MT8173_PIN_75_MSDC1_DAT2__FUNC_MSDC1_DAT2>,
+			     <MT8173_PIN_76_MSDC1_DAT3__FUNC_MSDC1_DAT3>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_4mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+		};
+
+		pins_clk {
+			pins = <MT8173_PIN_77_MSDC1_CLK__FUNC_MSDC1_CLK>;
+			bias-pull-down;
+			drive-strength = <MTK_DRIVE_4mA>;
+		};
+
+		pins_insert {
+			pins= <MT8173_PIN_132_I2S0_DATA1__FUNC_GPIO132>;
+			bias-pull-up;
+		};
+	};
+
+	mmc0_pins_uhs: mmc0 at 0{
+		pins_cmd_dat {
+			pins = <MT8173_PIN_64_MSDC0_DAT7__FUNC_MSDC0_DAT7>,
+			     <MT8173_PIN_63_MSDC0_DAT6__FUNC_MSDC0_DAT6>,
+			     <MT8173_PIN_62_MSDC0_DAT5__FUNC_MSDC0_DAT5>,
+			     <MT8173_PIN_61_MSDC0_DAT4__FUNC_MSDC0_DAT4>,
+			     <MT8173_PIN_66_MSDC0_CMD__FUNC_MSDC0_CMD>,
+			     <MT8173_PIN_60_MSDC0_DAT3__FUNC_MSDC0_DAT3>,
+			     <MT8173_PIN_59_MSDC0_DAT2__FUNC_MSDC0_DAT2>,
+			     <MT8173_PIN_58_MSDC0_DAT1__FUNC_MSDC0_DAT1>,
+			     <MT8173_PIN_57_MSDC0_DAT0__FUNC_MSDC0_DAT0>,
+			     <MT8173_PIN_68_MSDC0_RST___FUNC_MSDC0_RSTB>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_2mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+		};
+
+		pins_clk {
+			pins = <MT8173_PIN_65_MSDC0_CLK__FUNC_MSDC0_CLK>;
+			drive-strength = <MTK_DRIVE_2mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
+		};
+	};
+
+	mmc1_pins_uhs: mmc1 at 0 {
+		pins_cmd_dat {
+			pins = <MT8173_PIN_73_MSDC1_DAT0__FUNC_MSDC1_DAT0>,
+			     <MT8173_PIN_74_MSDC1_DAT1__FUNC_MSDC1_DAT1>,
+			     <MT8173_PIN_78_MSDC1_CMD__FUNC_MSDC1_CMD>,
+			     <MT8173_PIN_75_MSDC1_DAT2__FUNC_MSDC1_DAT2>,
+			     <MT8173_PIN_76_MSDC1_DAT3__FUNC_MSDC1_DAT3>;
+			input-enable;
+			drive-strength = <MTK_DRIVE_4mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+		};
+
+		pins_clk {
+			pins = <MT8173_PIN_77_MSDC1_CLK__FUNC_MSDC1_CLK>;
+			drive-strength = <MTK_DRIVE_4mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+		};
+	};
+};
+
+&mmc0 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc0_pins_default>;
+	pinctrl-1 = <&mmc0_pins_uhs>;
+	status = "okay";
+	bus-width = <8>;
+	max-frequency = <50000000>;
+	cap-mmc-highspeed;
+	core-power-supply = <&mt6397_vemc_3v3_reg>;
+	non-removable;
+};
+
+&mmc1 {
+	pinctrl-names = "default", "state_uhs";
+	pinctrl-0 = <&mmc1_pins_default>;
+	pinctrl-1 = <&mmc1_pins_uhs>;
+	status = "okay";
+	bus-width = <4>;
+	max-frequency = <50000000>;
+	cap-sd-highspeed;
+	sd-uhs-sdr25;
+	cd-gpios = <&pio 132 0>;
+	core-power-supply = <&mt6397_vmch_reg>;
+	io-power-supply = <&mt6397_vmc_reg>;
+};
arch/arm64/boot/dts/mediatek/mt8173.dtsi +18 -1
index c2a057f..64a8a03 100644
@@ -249,7 +249,24 @@
 			interrupts = <0 86 8>;
 			clocks = <&uart_clk>;
 		};
-	};
 
+		mmc0: mmc at 11230000 {
+			compatible = "mediatek,mt8173-mmc","mediatek,mt8135-mmc";
+			reg = <0 0x11230000 0 0x108>;
+			interrupts = <0 71 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&perisys PERI_MSDC30_0>;
+			clock-names = "source";
+			status = "disabled";
+		};
+
+		mmc1: mmc at 11240000 {
+			compatible = "mediatek,mt8173-mmc","mediatek,mt8135-mmc";
+			reg = <0 0x11240000 0 0x108>;
+			interrupts = <0 72 IRQ_TYPE_LEVEL_LOW>;
+			clocks = <&perisys PERI_MSDC30_1>;
+			clock-names = "source";
+			status = "disabled";
+		};
+	};
 };
 
Signature · 1 line
1.8.1.1.dirty