Skip to contentSkip to conversation

Add support for the Freescale eSDHC found on 8379 and 8536 SoCs

PATCH New Andy Fleming 1 participant 3 messages Feb 2, 2009 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 6/8 Add support for the Freescale eSDHC found on 8379 and 8536 SoCs

This uses the new MMC framework

Some contributions by Dave Liu <[email protected]>

---

Changed how we got eSDHC address, and used clrsetbits_be32, where appropriate.

 drivers/mmc/Makefile    |    1 +
 drivers/mmc/fsl_esdhc.c |  348 +++++++++++++++++++++++++++++++++++++++++++++++
 include/fsl_esdhc.h     |  145 ++++++++++++++++++++
 3 files changed, 494 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mmc/fsl_esdhc.c
 create mode 100644 include/fsl_esdhc.h
drivers/mmc/Makefile +1 -0
index d5a969c..040be8d 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libmmc.a
 
 COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
 COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o
+COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/mmc/fsl_esdhc.c new file +348 -0

348 lines not on this page · raw message

include/fsl_esdhc.h new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
1.5.4.GIT
#1 lore raw

PATCH v2 7/8 85xx: Add eSDHC support for 8536 DS

---

Changed how we got the pmuxcr address, and used setbits_be32 for writing it Also shifted some #defines around to better places, and switched to using CONFIG_SYS_FSL_ESDHC_ADDR for the eSDHC address

 board/freescale/mpc8536ds/mpc8536ds.c |   14 ++++++++++++++
 cpu/mpc85xx/cpu.c                     |   15 +++++++++++++++
 include/asm-ppc/immap_85xx.h          |    3 +++
 include/configs/MPC8536DS.h           |   14 ++++++++++++++
 4 files changed, 46 insertions(+), 0 deletions(-)
board/freescale/mpc8536ds/mpc8536ds.c +14 -0
index eb80500..62c247e 100644
@@ -44,6 +44,20 @@
 
 phys_size_t fixed_sdram(void);
 
+int board_early_init_f (void)
+{
+#ifdef CONFIG_MMC
+	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+	setbits_be32(&gur->pmuxcr,
+			(MPC85xx_PMUXCR_SD_DATA |
+			 MPC85xx_PMUXCR_SDHC_CD |
+			 MPC85xx_PMUXCR_SDHC_WP));
+
+#endif
+	return 0;
+}
+
 int checkboard (void)
 {
 	printf ("Board: MPC8536DS, System ID: 0x%02x, "
cpu/mpc85xx/cpu.c +15 -0
index bbea50f..fa1c0e1 100644
@@ -31,6 +31,7 @@
 #include <command.h>
 #include <tsec.h>
 #include <netdev.h>
+#include <fsl_esdhc.h>
 #include <asm/cache.h>
 #include <asm/io.h>
 
@@ -392,5 +393,19 @@ int cpu_eth_init(bd_t *bis)
 #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_MPC85XX_FEC)
 	tsec_standard_init(bis);
 #endif
+
 	return 0;
 }
+
+/*
+ * Initializes on-chip MMC controllers.
+ * to override, implement board_mmc_init()
+ */
+int cpu_mmc_init(bd_t *bis)
+{
+#ifdef CONFIG_FSL_ESDHC
+	return fsl_esdhc_mmc_init(bis);
+#else
+	return 0;
+#endif
+}
include/asm-ppc/immap_85xx.h +3 -0
index ed8dded..7b97fe0 100644
@@ -1614,6 +1614,9 @@ typedef struct ccsr_gur {
 	uint	gpindr;		/* 0xe0050 - General-purpose input data register */
 	char	res5[12];
 	uint	pmuxcr;		/* 0xe0060 - Alternate function signal multiplex control */
+#define MPC85xx_PMUXCR_SD_DATA		0x80000000
+#define MPC85xx_PMUXCR_SDHC_CD		0x40000000
+#define MPC85xx_PMUXCR_SDHC_WP		0x20000000
 	char	res6[12];
 	uint	devdisr;	/* 0xe0070 - Device disable control */
 #define MPC85xx_DEVDISR_PCI1		0x80000000
include/configs/MPC8536DS.h +14 -0
index e379d53..bbb448d 100644
@@ -72,6 +72,8 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 #define CONFIG_L2_CACHE			/* toggle L2 cache */
 #define CONFIG_BTB			/* toggle branch predition */
 
+#define CONFIG_BOARD_EARLY_INIT_F	1	/* Call board_pre_init */
+
 #define CONFIG_ENABLE_36BIT_PHYS	1
 
 #define CONFIG_SYS_MEMTEST_START	0x00000000	/* memtest works on */
@@ -528,6 +530,18 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 
 #undef CONFIG_WATCHDOG			/* watchdog disabled */
 
+#define CONFIG_MMC     1
+
+#ifdef CONFIG_MMC
+#define CONFIG_FSL_ESDHC
+#define CONFIG_SYS_FSL_ESDHC_ADDR	CONFIG_SYS_MPC85xx_ESDHC_ADDR
+#define CONFIG_CMD_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
 /*
  * Miscellaneous configurable options
  */
Signature · 1 line
1.5.4.GIT
#2 lore raw

PATCH v2 8/8 83xx: Add eSDHC support on 8379 EMDS board

---
Addressed Kim's comments

 board/freescale/mpc837xemds/mpc837xemds.c |   23 ++++++++++++++++++-----
 cpu/mpc83xx/cpu.c                         |   14 ++++++++++++++
 include/asm-ppc/immap_83xx.h              |    2 ++
 include/configs/MPC837XEMDS.h             |   15 +++++++++++++++
 include/mpc83xx.h                         |    3 +++
 5 files changed, 52 insertions(+), 5 deletions(-)
board/freescale/mpc837xemds/mpc837xemds.c +18 -5
index 156d808..062d762 100644
@@ -23,6 +23,7 @@
 
 int board_early_init_f(void)
 {
+	struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR;
 	u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
 
 	/* Enable flash write */
@@ -30,6 +31,18 @@ int board_early_init_f(void)
 	/* Clear all of the interrupt of BCSR */
 	bcsr[0xe] = 0xff;
 
+#ifdef CONFIG_MMC
+	/* Set SPI_SD, SER_SD, and IRQ4_WP so that SD signals go through */
+	bcsr[0xc] |= 0x4c;
+
+	/* Set proper bits in SICR to allow SD signals through */
+	clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD);
+
+	clrsetbits_be32(&im->sysconf.sicrh, (SICRH_GPIO2_E | SICRH_SPI),
+			(SICRH_GPIO2_E_SD | SICRH_SPI_SD));
+
+#endif
+
 #ifdef CONFIG_FSL_SERDES
 	immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 	u32 spridr = in_be32(&immr->sysconf.spridr);
@@ -38,21 +51,21 @@ int board_early_init_f(void)
 	switch (PARTID_NO_E(spridr)) {
 	case SPR_8377:
 		fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
-				 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+				FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
 		break;
 	case SPR_8378:
 		fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SGMII,
-				 FSL_SERDES_CLK_125, FSL_SERDES_VDD_1V);
+				FSL_SERDES_CLK_125, FSL_SERDES_VDD_1V);
 		break;
 	case SPR_8379:
 		fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_SATA,
-				 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+				FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
 		fsl_setup_serdes(CONFIG_FSL_SERDES2, FSL_SERDES_PROTO_SATA,
-				 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
+				FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
 		break;
 	default:
 		printf("serdes not configured: unknown CPU part number: "
-		       "%04x\n", spridr >> 16);
+				"%04x\n", spridr >> 16);
 		break;
 	}
 #endif /* CONFIG_FSL_SERDES */
cpu/mpc83xx/cpu.c +14 -0
index 587fca3..9e0a05d 100644
@@ -34,6 +34,7 @@
 #include <libfdt.h>
 #include <tsec.h>
 #include <netdev.h>
+#include <fsl_esdhc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -385,3 +386,16 @@ int cpu_eth_init(bd_t *bis)
 #endif
 	return 0;
 }
+
+/*
+ * Initializes on-chip MMC controllers.
+ * to override, implement board_mmc_init()
+ */
+int cpu_mmc_init(bd_t *bis)
+{
+#ifdef CONFIG_FSL_ESDHC
+	return fsl_esdhc_mmc_init(bis);
+#else
+	return 0;
+#endif
+}
include/asm-ppc/immap_83xx.h +2 -0
index 77c09db..7b847f8 100644
@@ -895,4 +895,6 @@ typedef struct immap {
 } immap_t;
 #endif
 
+#define CONFIG_SYS_MPC83xx_ESDHC_OFFSET	(0x2e000)
+#define CONFIG_SYS_MPC83xx_ESDHC_ADDR	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC83xx_ESDHC_OFFSET)
 #endif				/* __IMMAP_83xx__ */
include/configs/MPC837XEMDS.h +15 -0
index 0dd6ef5..75b67b4 100644
@@ -319,6 +319,9 @@
 #define CONFIG_OF_BOARD_SETUP	1
 #define CONFIG_OF_STDOUT_VIA_ALIAS	1
 
+#define CONFIG_SYS_64BIT_STRTOUL		1
+#define CONFIG_SYS_64BIT_VSPRINTF		1
+
 /* I2C */
 #define CONFIG_HARD_I2C		/* I2C with hardware support */
 #undef CONFIG_SOFT_I2C		/* I2C bit-banged */
@@ -502,6 +505,18 @@ extern int board_pci_host_broken(void);
 
 #undef CONFIG_WATCHDOG		/* watchdog disabled */
 
+#define CONFIG_MMC     1
+
+#ifdef CONFIG_MMC
+#define CONFIG_FSL_ESDHC
+#define CONFIG_SYS_FSL_ESDHC_ADDR	CONFIG_SYS_MPC83xx_ESDHC_ADDR
+#define CONFIG_CMD_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_FAT
+#define CONFIG_DOS_PARTITION
+#endif
+
 /*
  * Miscellaneous configurable options
  */
include/mpc83xx.h +3 -0
index 191488a..3554fdd 100644
@@ -266,6 +266,7 @@
 /* SICRL bits - MPC837x specific */
 #define SICRL_USB_A			0xC0000000
 #define SICRL_USB_B			0x30000000
+#define SICRL_USB_B_SD			0x20000000
 #define SICRL_UART			0x0C000000
 #define SICRL_GPIO_A			0x02000000
 #define SICRL_GPIO_B			0x01000000
@@ -307,10 +308,12 @@
 #define SICRH_GPIO2_C			0x00002000
 #define SICRH_GPIO2_D			0x00001000
 #define SICRH_GPIO2_E			0x00000C00
+#define SICRH_GPIO2_E_SD		0x00000800
 #define SICRH_GPIO2_F			0x00000300
 #define SICRH_GPIO2_G			0x000000C0
 #define SICRH_GPIO2_H			0x00000030
 #define SICRH_SPI			0x00000003
+#define SICRH_SPI_SD			0x00000001
 #endif
 
 /* SWCRR - System Watchdog Control Register
Signature · 1 line
1.5.4.GIT