3 * Texas Instruments, <www.ti.com>
4 * Sukumar Ghorai <s-ghorai@ti.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation's version 2 of
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/errno.h>
31 #include <asm/arch/sc8810_reg_base.h>
32 #include <asm/arch/mfp.h>
33 #include <asm/arch/sc8810_reg_ahb.h>
34 //#include <asm/arch/mmc_host_def.h>
35 #include <asm/arch/ldo.h>
36 #include <asm/arch/sdio_reg_v3.h>
37 #include <asm/arch/chip_drv_common_io.h>
38 #include <asm/arch/sc8810_reg_global.h>
39 #include <asm/arch/sc8810_module_config.h>
42 #define MMCSD_SECTOR_SIZE 512
45 #define REG_AHB_CTL0 (*((volatile unsigned int *)(AHB_CTL0)))
46 #define REG_AHB_SOFT_RST (*((volatile unsigned int *)(AHB_SOFT_RST)))
47 #define REG_AHB_SDIO_CTL (*((volatile unsigned int *)(AHB_SDIO_CTL)))
50 SDIO_REG_CFG *mmc_base;
51 static struct mmc_cmd command;
52 static block_dev_desc_t sprd_mmc_dev;
53 static unsigned char mmc_rsp_buf[16];
55 block_dev_desc_t *mmc_get_dev(int dev)
57 return ((block_dev_desc_t *) & sprd_mmc_dev);
60 static unsigned long mmc_bwrite(int dev_num, unsigned long blknr,
61 lbaint_t blkcnt, void *dst)
63 if(Emmc_Write(0, blknr, blkcnt, (uint8*)dst))
74 static unsigned long mmc_bread(int dev_num, unsigned long blknr,
75 lbaint_t blkcnt, void *dst)
77 if(Emmc_Read(0, blknr, blkcnt, (uint8*)dst))
88 int mmc_legacy_init(int dev)
90 int retries, rc = -ENODEV;
95 if(TRUE == Emmc_Init())
97 sprd_mmc_dev.if_type = IF_TYPE_UNKNOWN;
98 sprd_mmc_dev.if_type = IF_TYPE_MMC;
99 sprd_mmc_dev.part_type = PART_TYPE_EFI;
100 sprd_mmc_dev.dev = 0;
101 sprd_mmc_dev.lun = 0;
102 sprd_mmc_dev.type = 0;
104 /* FIXME fill in the correct size (is set to 32MByte) */
105 sprd_mmc_dev.blksz = MMCSD_SECTOR_SIZE;
107 sprd_mmc_dev.lba = Emmc_GetCapacity(0);;
108 sprd_mmc_dev.removable = 0;
109 sprd_mmc_dev.block_read = mmc_bread;
110 sprd_mmc_dev.block_write = mmc_bwrite;