Skip to content

Commit 991f5c4

Browse files
adureghello-tsstorulf
authored andcommitted
m68k: mcf5441x: add support for esdhc mmc controller
Add support for sdhci-edshc mmc controller. Signed-off-by: Angelo Dureghello <[email protected]> Acked-by: Greg Ungerer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 1f8153e commit 991f5c4

File tree

6 files changed

+91
-3
lines changed

6 files changed

+91
-3
lines changed

arch/m68k/coldfire/clk.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ struct clk_ops clk_ops1 = {
7373
#endif /* MCFPM_PPMCR1 */
7474
#endif /* MCFPM_PPMCR0 */
7575

76+
static void __clk_enable2(struct clk *clk)
77+
{
78+
__raw_writel(__raw_readl(MCFSDHC_CLK) | (1 << clk->slot), MCFSDHC_CLK);
79+
}
80+
81+
static void __clk_disable2(struct clk *clk)
82+
{
83+
__raw_writel(__raw_readl(MCFSDHC_CLK) & ~(1 << clk->slot), MCFSDHC_CLK);
84+
}
85+
86+
struct clk_ops clk_ops2 = {
87+
.enable = __clk_enable2,
88+
.disable = __clk_disable2,
89+
};
90+
7691
struct clk *clk_get(struct device *dev, const char *id)
7792
{
7893
const char *clk_name = dev ? dev_name(dev) : id ? id : NULL;

arch/m68k/coldfire/device.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <asm/mcfqspi.h>
2323
#include <linux/platform_data/edma.h>
2424
#include <linux/platform_data/dma-mcf-edma.h>
25+
#include <linux/platform_data/mmc-esdhc-mcf.h>
2526

2627
/*
2728
* All current ColdFire parts contain from 2, 3, 4 or 10 UARTS.
@@ -551,9 +552,35 @@ static struct platform_device mcf_edma = {
551552
.platform_data = &mcf_edma_data,
552553
}
553554
};
554-
555555
#endif /* IS_ENABLED(CONFIG_MCF_EDMA) */
556556

557+
#if IS_ENABLED(CONFIG_MMC)
558+
static struct mcf_esdhc_platform_data mcf_esdhc_data = {
559+
.max_bus_width = 4,
560+
.cd_type = ESDHC_CD_NONE,
561+
};
562+
563+
static struct resource mcf_esdhc_resources[] = {
564+
{
565+
.start = MCFSDHC_BASE,
566+
.end = MCFSDHC_BASE + MCFSDHC_SIZE - 1,
567+
.flags = IORESOURCE_MEM,
568+
}, {
569+
.start = MCF_IRQ_SDHC,
570+
.end = MCF_IRQ_SDHC,
571+
.flags = IORESOURCE_IRQ,
572+
},
573+
};
574+
575+
static struct platform_device mcf_esdhc = {
576+
.name = "sdhci-esdhc-mcf",
577+
.id = 0,
578+
.num_resources = ARRAY_SIZE(mcf_esdhc_resources),
579+
.resource = mcf_esdhc_resources,
580+
.dev.platform_data = &mcf_esdhc_data,
581+
};
582+
#endif /* IS_ENABLED(CONFIG_MMC) */
583+
557584
static struct platform_device *mcf_devices[] __initdata = {
558585
&mcf_uart,
559586
#if IS_ENABLED(CONFIG_FEC)
@@ -586,6 +613,9 @@ static struct platform_device *mcf_devices[] __initdata = {
586613
#if IS_ENABLED(CONFIG_MCF_EDMA)
587614
&mcf_edma,
588615
#endif
616+
#if IS_ENABLED(CONFIG_MMC)
617+
&mcf_esdhc,
618+
#endif
589619
};
590620

591621
/*
@@ -614,4 +644,3 @@ static int __init mcf_init_devices(void)
614644
}
615645

616646
arch_initcall(mcf_init_devices);
617-

arch/m68k/coldfire/m5441x.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ DEFINE_CLK(0, "mcfssi.0", 47, MCF_CLK);
5252
DEFINE_CLK(0, "pll.0", 48, MCF_CLK);
5353
DEFINE_CLK(0, "mcfrng.0", 49, MCF_CLK);
5454
DEFINE_CLK(0, "mcfssi.1", 50, MCF_CLK);
55-
DEFINE_CLK(0, "mcfsdhc.0", 51, MCF_CLK);
55+
DEFINE_CLK(0, "sdhci-esdhc-mcf.0", 51, MCF_CLK);
5656
DEFINE_CLK(0, "enet-fec.0", 53, MCF_CLK);
5757
DEFINE_CLK(0, "enet-fec.1", 54, MCF_CLK);
5858
DEFINE_CLK(0, "switch.0", 55, MCF_CLK);
@@ -74,6 +74,10 @@ DEFINE_CLK(1, "mcfpwm.0", 34, MCF_BUSCLK);
7474
DEFINE_CLK(1, "sys.0", 36, MCF_BUSCLK);
7575
DEFINE_CLK(1, "gpio.0", 37, MCF_BUSCLK);
7676

77+
DEFINE_CLK(2, "ipg.0", 0, MCF_CLK);
78+
DEFINE_CLK(2, "ahb.0", 1, MCF_CLK);
79+
DEFINE_CLK(2, "per.0", 2, MCF_CLK);
80+
7781
struct clk *mcf_clks[] = {
7882
&__clk_0_2,
7983
&__clk_0_8,
@@ -131,6 +135,11 @@ struct clk *mcf_clks[] = {
131135
&__clk_1_34,
132136
&__clk_1_36,
133137
&__clk_1_37,
138+
139+
&__clk_2_0,
140+
&__clk_2_1,
141+
&__clk_2_2,
142+
134143
NULL,
135144
};
136145

@@ -151,6 +160,7 @@ static struct clk * const enable_clks[] __initconst = {
151160
&__clk_0_33, /* pit.1 */
152161
&__clk_0_37, /* eport */
153162
&__clk_0_48, /* pll */
163+
&__clk_0_51, /* esdhc */
154164

155165
&__clk_1_36, /* CCM/reset module/Power management */
156166
&__clk_1_37, /* gpio */

arch/m68k/include/asm/m5441xsim.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,13 @@
278278
#define MCFGPIO_IRQ_VECBASE (MCFINT_VECBASE - MCFGPIO_IRQ_MIN)
279279
#define MCFGPIO_PIN_MAX 87
280280

281+
/*
282+
* Phase Locked Loop (PLL)
283+
*/
284+
#define MCF_PLL_CR 0xFC0C0000
285+
#define MCF_PLL_DR 0xFC0C0004
286+
#define MCF_PLL_SR 0xFC0C0008
287+
281288
/*
282289
* DSPI module.
283290
*/
@@ -298,5 +305,13 @@
298305
#define MCFEDMA_IRQ_INTR16 (MCFINT1_VECBASE + MCFEDMA_EDMA_INTR16)
299306
#define MCFEDMA_IRQ_INTR56 (MCFINT2_VECBASE + MCFEDMA_EDMA_INTR56)
300307
#define MCFEDMA_IRQ_ERR (MCFINT0_VECBASE + MCFINT0_EDMA_ERR)
308+
/*
309+
* esdhc module.
310+
*/
311+
#define MCFSDHC_BASE 0xfc0cc000
312+
#define MCFSDHC_SIZE 256
313+
#define MCFINT2_SDHC 31
314+
#define MCF_IRQ_SDHC (MCFINT2_VECBASE + MCFINT2_SDHC)
315+
#define MCFSDHC_CLK (MCFSDHC_BASE + 0x2c)
301316

302317
#endif /* m5441xsim_h */

arch/m68k/include/asm/mcfclk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ extern struct clk_ops clk_ops0;
3030
extern struct clk_ops clk_ops1;
3131
#endif /* MCFPM_PPMCR1 */
3232

33+
extern struct clk_ops clk_ops2;
34+
3335
#define DEFINE_CLK(clk_bank, clk_name, clk_slot, clk_rate) \
3436
static struct clk __clk_##clk_bank##_##clk_slot = { \
3537
.name = clk_name, \
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef __LINUX_PLATFORM_DATA_MCF_ESDHC_H__
4+
#define __LINUX_PLATFORM_DATA_MCF_ESDHC_H__
5+
6+
enum cd_types {
7+
ESDHC_CD_NONE, /* no CD, neither controller nor gpio */
8+
ESDHC_CD_CONTROLLER, /* mmc controller internal CD */
9+
ESDHC_CD_PERMANENT, /* no CD, card permanently wired to host */
10+
};
11+
12+
struct mcf_esdhc_platform_data {
13+
int max_bus_width;
14+
int cd_type;
15+
};
16+
17+
#endif /* __LINUX_PLATFORM_DATA_MCF_ESDHC_H__ */

0 commit comments

Comments
 (0)