From 33a2e90bf491f13a4546d09a6105582c0ba7f313 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Fri, 2 Jul 2010 13:47:39 +0200 Subject: Replace MMC/SD driver to fit new framework. IR265772: MMC driver does not detect SDHC cards. IR254201: Restructure MMC/SD driver for U8500 board according to the block device framework in mainline U-Boot. Changes to mmc framework: - Multi Block Read support in mmc framework. - Wrap Multi Block Write/Read to be able to adopt for large transaction. - Removed incorrect check in EXT CSD for high capacity MMC. - Corrected check for high capacity SD cards. - Set MMC buswidth to 8, prio of using 4. Known limitations/bugs in mmc framework: - High capacity MMC, will likely not get the correct density. - High speed is set, whether or not the host supports it or not. board/st/u8500/mmc_utils: IMPORTANT FOR DEVELOPERS: - Removed unessary U-Boot commands which is already supported in cmd_fat. - mmc_read_cmd_file: Read command.txt into bootcmd env from FAT FS in SD card. - write_partition_block: Writes the MBR if it is not already written. board/st/u8500/mmc_host[c.h]: - Implements the entire MMC/SD host driver for the PL180 block. - There is still room for optimization: Increase CLK-speed. Use high-speed for SD cards. Is GPIO setup correctly for both cards an eMMC. EarlyDrop support not fully tested. Dynamically turn on voltage/clocks to SD, not always. More... Note: - Increased read/write performance for eMMC, to around 5.4 MB/s for sequential read/write. Earlier measurements was 3.5 MB/s for read and 2.6 MB/s for write. ST-Ericsson ID: ER265772, CR267996, ER267993 Change-Id: I921102edbde761407ff5ad476d1bb99f5dc7a2ef Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/2288 Reviewed-by: Michael BRANDT Tested-by: Michael BRANDT Reviewed-by: Martin LUNDHOLM Tested-by: Martin LUNDHOLM Reviewed-by: Mikael LARSSON Tested-by: Mikael LARSSON --- include/asm-arm/arch-stw8500/emmc.h | 36 ---------------- include/asm-arm/arch-stw8500/mmc.h | 84 ------------------------------------- include/configs/u8500.h | 12 ++++-- include/mmc.h | 1 - 4 files changed, 8 insertions(+), 125 deletions(-) delete mode 100755 include/asm-arm/arch-stw8500/emmc.h delete mode 100755 include/asm-arm/arch-stw8500/mmc.h (limited to 'include') diff --git a/include/asm-arm/arch-stw8500/emmc.h b/include/asm-arm/arch-stw8500/emmc.h deleted file mode 100755 index 62256ae9e..000000000 --- a/include/asm-arm/arch-stw8500/emmc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2009 - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef _STM_EMMC_H -#define _STM_EMMC_H - - -#include - -extern int emmc_init (u8); -int emmc_erase(u32, u32); -int emmc_read (u32,u32,u32); -int emmc_write(u32,u32,u32); -int emmc_write_pib(void); - - -#endif /* !defined(_STM_EMMC_H) */ diff --git a/include/asm-arm/arch-stw8500/mmc.h b/include/asm-arm/arch-stw8500/mmc.h deleted file mode 100755 index 0e089338a..000000000 --- a/include/asm-arm/arch-stw8500/mmc.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) ST-Ericsson SA 2009 - * - * See file CREDITS for list of people who contributed to this - * project. - * - * 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., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ -#ifndef __MMC_NOMADIK_P_H__ -#define __MMC_NOMADIK_P_H__ - -#define MAX_ERROR_VALUE -65 -typedef enum -{ - /* MMC specific error defines */ - MMC_CMD_CRC_FAIL = (MAX_ERROR_VALUE - 1), /* Command response received (but CRC check failed) */ - MMC_DATA_CRC_FAIL = (MAX_ERROR_VALUE - 2), /* Data bock sent/received (CRC check Failed) */ - MMC_CMD_RSP_TIMEOUT = (MAX_ERROR_VALUE - 3), /* Command response timeout */ - MMC_DATA_TIMEOUT = (MAX_ERROR_VALUE - 4), /* Data time out*/ - MMC_TX_UNDERRUN = (MAX_ERROR_VALUE - 5), /* Transmit FIFO under-run */ - MMC_RX_OVERRUN = (MAX_ERROR_VALUE - 6), /* Receive FIFO over-run */ - MMC_START_BIT_ERR = (MAX_ERROR_VALUE - 7), /* Start bit not detected on all data signals in widE bus mode */ - MMC_CMD_OUT_OF_RANGE = (MAX_ERROR_VALUE - 8), /* CMD's argument was out of range.*/ - MMC_ADDR_MISALIGNED = (MAX_ERROR_VALUE - 9), /* Misaligned address */ - MMC_BLOCK_LEN_ERR = (MAX_ERROR_VALUE - 10), /* Transferred block length is not allowed for the card or the number of transferred bytes does not match the block length */ - MMC_ERASE_SEQ_ERR = (MAX_ERROR_VALUE - 11), /* An error in the sequence of erase command occurs.*/ - MMC_BAD_ERASE_PARAM = (MAX_ERROR_VALUE - 12), /* An Invalid selection for erase groups */ - MMC_WRITE_PROT_VIOLATION = (MAX_ERROR_VALUE - 13), /* Attempt to program a write protect block */ - MMC_LOCK_UNLOCK_FAILED = (MAX_ERROR_VALUE - 14), /* Sequence or password error has been detected in unlock command or if there was an attempt to access a locked card */ - MMC_COM_CRC_FAILED = (MAX_ERROR_VALUE - 15), /* CRC check of the previous command failed */ - MMC_ILLEGAL_CMD = (MAX_ERROR_VALUE - 16), /* Command is not legal for the card state */ - MMC_CARD_ECC_FAILED = (MAX_ERROR_VALUE - 17), /* Card internal ECC was applied but failed to correct the data */ - MMC_CC_ERROR = (MAX_ERROR_VALUE - 18), /* Internal card controller error */ - MMC_GENERAL_UNKNOWN_ERROR = (MAX_ERROR_VALUE - 19), /* General or Unknown error */ - MMC_STREAM_READ_UNDERRUN = (MAX_ERROR_VALUE - 20), /* The card could not sustain data transfer in stream read operation. */ - MMC_STREAM_WRITE_OVERRUN = (MAX_ERROR_VALUE - 21), /* The card could not sustain data programming in stream mode */ - MMC_CID_CSD_OVERWRITE = (MAX_ERROR_VALUE - 22), /* CID/CSD overwrite error */ - MMC_WP_ERASE_SKIP = (MAX_ERROR_VALUE - 23), /* only partial address space was erased */ - MMC_CARD_ECC_DISABLED = (MAX_ERROR_VALUE - 24), /* Command has been executed without using internal ECC */ - MMC_ERASE_RESET = (MAX_ERROR_VALUE - 25), /* Erase sequence was cleared before executing because an out of erase sequence command was received */ - MMC_AKE_SEQ_ERROR = (MAX_ERROR_VALUE - 26), /* Error in sequence of authentication. */ - MMC_INVALID_VOLTRANGE = (MAX_ERROR_VALUE - 27), - MMC_ADDR_OUT_OF_RANGE = (MAX_ERROR_VALUE - 28), - MMC_SWITCH_ERROR = (MAX_ERROR_VALUE - 29), - MMC_SDIO_DISABLED = (MAX_ERROR_VALUE - 30), - MMC_SDIO_FUNCTION_BUSY = (MAX_ERROR_VALUE - 31), - MMC_SDIO_FUNCTION_FAILED = (MAX_ERROR_VALUE - 32), - MMC_SDIO_UNKNOWN_FUNCTION = MAX_ERROR_VALUE, - - /* standard error defines */ - MMC_INTERNAL_ERROR = -8, - MMC_NOT_CONFIGURED = -7, - MMC_REQUEST_PENDING = -6, - MMC_REQUEST_NOT_APPLICABLE = -5, - MMC_INVALID_PARAMETER = -4, - MMC_UNSUPPORTED_FEATURE = -3, - MMC_UNSUPPORTED_HW = -2, - MMC_ERROR = -1, - MMC_OK = 0, - MMC_INTERNAL_EVENT = 1, - MMC_REMAINING_PENDING_EVENTS = 2, - MMC_REMAINING_FILTER_PENDING_EVENTS = 3, - MMC_NO_MORE_PENDING_EVENT = 4, - MMC_NO_MORE_FILTER_PENDING_EVENT = 5, - MMC_NO_PENDING_EVENT_ERROR = 7, -} t_mmc_error; - -int init_mmc_card(void); - -#endif - diff --git a/include/configs/u8500.h b/include/configs/u8500.h index 21c48fe66..4df4b8952 100644 --- a/include/configs/u8500.h +++ b/include/configs/u8500.h @@ -80,6 +80,7 @@ * Devices and file systems */ #define CONFIG_MMC 1 +#define CONFIG_GENERIC_MMC 1 #define CONFIG_DOS_PARTITION 1 /* @@ -126,7 +127,7 @@ "commonargs=setenv bootargs cachepolicy=writealloc noinitrd " \ "init=init " \ "board_id=${board_id} " \ - "logo.${logo} " \ + "logo.${logo} " \ "startup_graphics=${startup_graphics}\0" \ "emmcargs=setenv bootargs ${bootargs} " \ "root=/dev/mmcblk0p2 " \ @@ -135,7 +136,8 @@ "console=${console}\0" \ "emmcboot=echo Booting from eMMC ...; " \ "run commonargs emmcargs addcons memargs;" \ - "emmc_read ${loadaddr} 0x14000000 0x300000; " \ + "write_partition_block;" \ + "mmc read 0 ${loadaddr} 0xA0000 0x4000;" \ "bootm ${loadaddr}\0" \ "cmdfile=mmc init 1;mmc_read_cmd_file;run bootcmd\0" \ "flash=mmc init 1;fatload mmc 1 ${loadaddr} flash.scr;" \ @@ -211,6 +213,7 @@ */ #define MMC_BLOCK_SIZE 512 #define CFG_MMC_BASE 0x80126000 /* MMC base for 8500 */ +#define CONFIG_MMC_DEV_NUM 1 /*----------------------------------------------------------------------- * EMMC related configs @@ -222,7 +225,8 @@ #define CONFIG_CMD_SAVEENV /* CMD_ENV is obsolete but used in env_emmc.c */ #define CONFIG_ENV_IS_IN_EMMC 1 #define CONFIG_ENV_OFFSET_START 0x13F80000 -#define CONFIG_ENV_OFFSET_END 0x13FE0000 +#define CONFIG_ENV_OFFSET_END 0x13FE0000 +#define CONFIG_EMMC_DEV_NUM 0 /*----------------------------------------------------------------------- * USB related configs @@ -242,7 +246,7 @@ * FLASH and environment organization */ -#define CONFIG_SYS_MAX_FLASH_SECT 512 +#define CONFIG_SYS_MAX_FLASH_SECT 512 #define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of memory banks */ /*----------------------------------------------------------------------- diff --git a/include/mmc.h b/include/mmc.h index 2dc69abb6..bcc291568 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -269,7 +269,6 @@ struct mmc { int mmc_register(struct mmc *mmc); int mmc_initialize(bd_t *bis); int mmc_init(struct mmc *mmc); -int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size); struct mmc *find_mmc_device(int dev_num); void print_mmc_devices(char separator); -- cgit v1.2.3