Davinci MMCSD Support
Subsystems (2)
PATCH 2/5 Davinci MMCSD Support
Added support for MMC/SD cards for Davinci. This feature is enabled by CONFIG_DAVINCI_MMC and is dependant on CONFIG_MMC and CONFIG_GENERIC_MMC options. This is tested on DM355 and DM365 EVMs with both the available mmc controllers.
Signed-off-by Alagu Sankar <[email protected]>
--- arch/arm/include/asm/arch-davinci/sdmmc_defs.h | 175 +++++++++++ board/davinci/dm355evm/dm355evm.c | 44 +++ board/davinci/dm365evm/dm365evm.c | 51 +++ drivers/mmc/Makefile | 1 + drivers/mmc/davinci_mmc.c | 399 ++++++++++++++++++++++++ include/configs/davinci_dm355evm.h | 21 +- include/configs/davinci_dm365evm.h | 13 + 7 files changed, 700 insertions(+), 4 deletions(-) create mode 100644 arch/arm/include/asm/arch-davinci/sdmmc_defs.h create mode 100644 drivers/mmc/davinci_mmc.c
arch/arm/include/asm/arch-davinci/sdmmc_defs.h new file +175 -0
@@ -0,0 +1,175 @@ +/* +* Davinci MMC Controller Defines - Based on Linux davinci_mmc.c +* +* Copyright (C) Texas Instruments. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _SDMMC_DEFS_H_ +#define _SDMMC_DEFS_H_ + +#include <asm/arch/hardware.h> + +/* MMC Control Reg fields */ +#define MMCCTL_DATRST (1 << 0) +#define MMCCTL_CMDRST (1 << 1) +#define MMCCTL_WIDTH_4_BIT (1 << 2) +#define MMCCTL_DATEG_DISABLED (0 << 6) +#define MMCCTL_DATEG_RISING (1 << 6) +#define MMCCTL_DATEG_FALLING (2 << 6) +#define MMCCTL_DATEG_BOTH (3 << 6) +#define MMCCTL_PERMDR_LE (0 << 9) +#define MMCCTL_PERMDR_BE (1 << 9) +#define MMCCTL_PERMDX_LE (0 << 10) +#define MMCCTL_PERMDX_BE (1 << 10) + +/* MMC Clock Control Reg fields */ +#define MMCCLK_CLKEN (1 << 8) +#define MMCCLK_CLKRT_MASK (0xFF << 0) + +/* MMC Status Reg0 fields */ +#define MMCST0_DATDNE (1 << 0) +#define MMCST0_BSYDNE (1 << 1) +#define MMCST0_RSPDNE (1 << 2) +#define MMCST0_TOUTRD (1 << 3) +#define MMCST0_TOUTRS (1 << 4) +#define MMCST0_CRCWR (1 << 5) +#define MMCST0_CRCRD (1 << 6) +#define MMCST0_CRCRS (1 << 7) +#define MMCST0_DXRDY (1 << 9) +#define MMCST0_DRRDY (1 << 10) +#define MMCST0_DATED (1 << 11) +#define MMCST0_TRNDNE (1 << 12) + +#define MMCST0_ERR_MASK (0x00F8) + +/* MMC Status Reg1 fields */ +#define MMCST1_BUSY (1 << 0) +#define MMCST1_CLKSTP (1 << 1) +#define MMCST1_DXEMP (1 << 2) +#define MMCST1_DRFUL (1 << 3) +#define MMCST1_DAT3ST (1 << 4) +#define MMCST1_FIFOEMP (1 << 5) +#define MMCST1_FIFOFUL (1 << 6) + +/* MMC INT Mask Reg fields */ +#define MMCIM_EDATDNE (1 << 0) +#define MMCIM_EBSYDNE (1 << 1) +#define MMCIM_ERSPDNE (1 << 2) +#define MMCIM_ETOUTRD (1 << 3) +#define MMCIM_ETOUTRS (1 << 4) +#define MMCIM_ECRCWR (1 << 5) +#define MMCIM_ECRCRD (1 << 6) +#define MMCIM_ECRCRS (1 << 7) +#define MMCIM_EDXRDY (1 << 9) +#define MMCIM_EDRRDY (1 << 10) +#define MMCIM_EDATED (1 << 11) +#define MMCIM_ETRNDNE (1 << 12) + +#define MMCIM_MASKALL (0xFFFFFFFF) + +/* MMC Resp Tout Reg fields */ +#define MMCTOR_TOR_MASK (0xFF)/* dont write to reg, | it */ +#define MMCTOR_TOD_20_16_SHIFT (8) + +/* MMC Data Read Tout Reg fields */ +#define MMCTOD_TOD_0_15_MASK (0xFFFF) + +/* MMC Block len Reg fields */ +#define MMCBLEN_BLEN_MASK (0xFFF) + +/* MMC Num Blocks Reg fields */ +#define MMCNBLK_NBLK_MASK (0xFFFF) +#define MMCNBLK_NBLK_MAX (0xFFFF) + +/* MMC Num Blocks Counter Reg fields */ +#define MMCNBLC_NBLC_MASK (0xFFFF) + +/* MMC Cmd Reg fields */ +#define MMCCMD_CMD_MASK (0x3F) +#define MMCCMD_PPLEN (1 << 7) +#define MMCCMD_BSYEXP (1 << 8) +#define MMCCMD_RSPFMT_NONE (0 << 9) +#define MMCCMD_RSPFMT_R1567 (1 << 9) +#define MMCCMD_RSPFMT_R2 (2 << 9) +#define MMCCMD_RSPFMT_R3 (3 << 9) +#define MMCCMD_DTRW (1 << 11) +#define MMCCMD_STRMTP (1 << 12) +#define MMCCMD_WDATX (1 << 13) +#define MMCCMD_INITCK (1 << 14) +#define MMCCMD_DCLR (1 << 15) +#define MMCCMD_DMATRIG (1 << 16) + +/* FIFO control Reg fields */ +#define MMCFIFOCTL_FIFORST (1 << 0) +#define MMCFIFOCTL_FIFODIR (1 << 1) +#define MMCFIFOCTL_FIFOLEV (1 << 2) +#define MMCFIFOCTL_ACCWD_4 (0 << 3)/* access width of 4 bytes */ +#define MMCFIFOCTL_ACCWD_3 (1 << 3)/* access width of 3 bytes */ +#define MMCFIFOCTL_ACCWD_2 (2 << 3)/* access width of 2 bytes */ +#define MMCFIFOCTL_ACCWD_1 (3 << 3)/* access width of 1 byte */ + +/* Davinci MMC Register definitions */ +struct davinci_mmc_regs { +dv_reg mmcctl; +dv_reg mmcclk; +dv_reg mmcst0; +dv_reg mmcst1; +dv_reg mmcim; +dv_reg mmctor; +dv_reg mmctod; +dv_reg mmcblen; +dv_reg mmcnblk; +dv_reg mmcnblc; +dv_reg mmcdrr; +dv_reg mmcdxr; +dv_reg mmccmd; +dv_reg mmcarghl; +dv_reg mmcrsp01; +dv_reg mmcrsp23; +dv_reg mmcrsp45; +dv_reg mmcrsp67; +dv_reg mmcdrsp; +dv_reg mmcetok; +dv_reg mmccidx; +dv_reg mmcckc; +dv_reg mmctorc; +dv_reg mmctodc; +dv_reg mmcblnc; +dv_reg sdioctl; +dv_reg sdiost0; +dv_reg sdioien; +dv_reg sdioist; +dv_reg mmcfifoctl; +}; + +/* Davinci MMC board definitions */ +struct davinci_mmc { +struct davinci_mmc_regs *reg_base;/* Register base address */ +uint input_clk;/* Input clock to MMC controller */ +uint host_caps;/* Host capabilities */ +uint voltages;/* Host supported voltages */ +uint version;/* MMC Controller version */ +}; + +enum { +MMC_CTLR_VERSION_1 =0 ,/* DM644x and DM355 */ +MMC_CTLR_VERSION_2 ,/* DA830 */ +}; + +int davinci_mmc_init (bd_t *bis,struct davinci_mmc *host); + +#endif /* _SDMMC_DEFS_H */
board/davinci/dm355evm/dm355evm.c +44 -0
53 lines not on this page · raw message
board/davinci/dm365evm/dm365evm.c +51 -0
60 lines not on this page · raw message
drivers/mmc/Makefile +1 -0
@@ -32,6 +32,7 @@ COBJS-$(CONFIG_OMAP3_MMC) += omap3_mmc.o COBJS-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o COBJS-$(CONFIG_PXA_MMC) += pxa_mmc.o +COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mmc/davinci_mmc.c new file +399 -0
399 lines not on this page · raw message
include/configs/davinci_dm355evm.h +17 -4
@@ -78,6 +78,12 @@#define CONFIG_SYS_MAX_NAND_DEVICE 1#define CONFIG_SYS_NAND_MAX_CHIPS 2 +/* SD/MMC */ +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_DAVINCI_MMC +#define CONFIG_DAVINCI_MMC_SD1 +/* USB: OTG connector */ /* NYET -- #define CONFIG_USB_DAVINCI */
@@ -95,6 +101,13 @@#define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_MMC +#define CONFIG_DOS_PARTITION +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_FAT +#define CONFIG_CMD_MMC +#endif +#ifdef CONFIG_NAND_DAVINCI #define CONFIG_CMD_MTDPARTS #define CONFIG_MTD_PARTITIONS
@@ -123,7 +136,7 @@#define CONFIG_SYS_PROMPT "DM355 EVM # "/* Monitor Command Prompt */ #define CONFIG_SYS_CBSIZE 1024/* Console I/O Buffer Size */ #define CONFIG_SYS_PBSIZE /* Print buffer size */ \ - (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16) + (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)#define CONFIG_SYS_MAXARGS 16/* max number of command args */ #define CONFIG_SYS_HUSH_PARSER #define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
@@ -138,10 +151,10 @@#define CONFIG_BOOTDELAY 5#define CONFIG_BOOTCOMMAND \ - "dhcp;bootm" + "dhcp;bootm"#define CONFIG_BOOTARGS \ - "console=ttyS0,115200n8 " \ - "root=/dev/mmcblk0p1 rootwait rootfstype=ext3 ro" + "console=ttyS0,115200n8 " \ +"root=/dev/mmcblk0p1 rootwait rootfstype=ext3 ro"#define CONFIG_CMDLINE_EDITING #define CONFIG_VERSION_VARIABLE
include/configs/davinci_dm365evm.h +13 -0
@@ -85,6 +85,12 @@#define CONFIG_SYS_MAX_NAND_DEVICE 1#define CONFIG_SYS_NAND_MAX_CHIPS 2 +/* SD/MMC */ +#define CONFIG_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_DAVINCI_MMC +#define CONFIG_DAVINCI_MMC_SD1 +#define PINMUX4_USBDRVBUS_BITCLEAR 0x3000#define PINMUX4_USBDRVBUS_BITSET 0x2000
@@ -137,6 +143,13 @@#define CONFIG_CMD_PING #define CONFIG_CMD_SAVES +#ifdef CONFIG_MMC +#define CONFIG_DOS_PARTITION +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_FAT +#define CONFIG_CMD_MMC +#endif +#ifdef CONFIG_NAND_DAVINCI #define CONFIG_CMD_MTDPARTS #define CONFIG_MTD_PARTITIONS
Signature · 1 line
1.6.0.6
PATCH 2/5 Davinci MMCSD Support
Quoted 6 lines · Alagu Sankar
Added support for MMC/SD cards for Davinci. ?This feature is enabled by
CONFIG_DAVINCI_MMCand is dependant onCONFIG_MMCandCONFIG_GENERIC_MMCoptions. This is tested on DM355 and DM365 EVMs with both the available mmc controllers.Signed-off-by Alagu Sankar <[email protected]>
I'm thinking this is probably the ARM maintainer's domain, so I'll just say:
Acked-by Andy Fleming <[email protected]>