From e3a14b6684bc591d0648e2bb8de383074ee81f43 Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Tue, 25 Jun 2019 13:39:01 +0200 Subject: mmc: mvebu: Remove unused MMC_CAP.. macros Removed MMC_CAP_NONREMOVABLE, MMC_CAP_NEEDS_POLL macros from mvebu_mmc.h to avoid redefining of these macros when compiled with mvebu based configs. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- include/mvebu_mmc.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/mvebu_mmc.h b/include/mvebu_mmc.h index d51b1fe..7397165 100644 --- a/include/mvebu_mmc.h +++ b/include/mvebu_mmc.h @@ -222,13 +222,9 @@ #define MMC_CAP_SDIO_IRQ (1 << 3) /* Talks only SPI protocols */ #define MMC_CAP_SPI (1 << 4) -/* Needs polling for card-detection */ -#define MMC_CAP_NEEDS_POLL (1 << 5) /* Can the host do 8 bit transfers */ #define MMC_CAP_8_BIT_DATA (1 << 6) -/* Nonremovable e.g. eMMC */ -#define MMC_CAP_NONREMOVABLE (1 << 8) /* Waits while card is busy */ #define MMC_CAP_WAIT_WHILE_BUSY (1 << 9) /* Allow erase/trim commands */ -- cgit v1.1 From 86a94e7b2b8cdf37138e2c5cef10193f6093a9bd Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Tue, 25 Jun 2019 13:39:02 +0200 Subject: mmc: Read sd card detect properties from DT This patch reads card detect properties from device tree & added mmc capability macros in mmc.h. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- include/mmc.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 1f30f71..2be3e91 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -66,6 +66,10 @@ #define MMC_MODE_HS200 MMC_CAP(MMC_HS_200) #define MMC_MODE_HS400 MMC_CAP(MMC_HS_400) +#define MMC_CAP_NONREMOVABLE BIT(14) +#define MMC_CAP_NEEDS_POLL BIT(15) +#define MMC_CAP_CD_ACTIVE_HIGH BIT(16) + #define MMC_MODE_8BIT BIT(30) #define MMC_MODE_4BIT BIT(29) #define MMC_MODE_1BIT BIT(28) -- cgit v1.1 From c5bda37589683ea5d26424ec75c2474226f4dd62 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 2 Jul 2019 10:53:50 +0200 Subject: Revert "mmc: Add a new callback function to perform the 74 clocks cycle sequence" This reverts commit 318a7a576bc49aa8b4207e694d3fbd48c663d6ac. The last and only user of this callback had been the omap_hsmmc driver. It is not used anymore. Removing the callback. Signed-off-by: Jean-Jacques Hiblot --- include/mmc.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 2be3e91..7f95c35 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -419,14 +419,6 @@ struct dm_mmc_ops { int (*set_ios)(struct udevice *dev); /** - * send_init_stream() - send the initialization stream: 74 clock cycles - * This is used after power up before sending the first command - * - * @dev: Device to update - */ - void (*send_init_stream)(struct udevice *dev); - - /** * get_cd() - See whether a card is present * * @dev: Device to check @@ -472,7 +464,6 @@ struct dm_mmc_ops { int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data); int dm_mmc_set_ios(struct udevice *dev); -void dm_mmc_send_init_stream(struct udevice *dev); int dm_mmc_get_cd(struct udevice *dev); int dm_mmc_get_wp(struct udevice *dev); int dm_mmc_execute_tuning(struct udevice *dev, uint opcode); @@ -480,7 +471,6 @@ int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout); /* Transition functions for compatibility */ int mmc_set_ios(struct mmc *mmc); -void mmc_send_init_stream(struct mmc *mmc); int mmc_getcd(struct mmc *mmc); int mmc_getwp(struct mmc *mmc); int mmc_execute_tuning(struct mmc *mmc, uint opcode); -- cgit v1.1 From cd0b80ec9c97bdd9fb6642671efad8ef3cb33858 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 2 Jul 2019 10:53:53 +0200 Subject: mmc: if possible, poll the busy state using DAT0 Using the DAT0 line as a rdy/busy line is an alternative to reading the status register of the card. It especially useful in situation where the bus is not in a good shape, like when modes are switched. This is also how the linux driver behaves. Note of warning: As per the specification, while polling on DAT0 the CLK must not turned off: "[...] Without a clock edge the Device (unless previously disconnected by a deselect command (CMD7)) will force the DAT0 line down, forever. [...]" Signed-off-by: Jean-Jacques Hiblot --- include/mmc.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 7f95c35..cf83b74 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -445,7 +445,6 @@ struct dm_mmc_ops { int (*execute_tuning)(struct udevice *dev, uint opcode); #endif -#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) /** * wait_dat0() - wait until dat0 is in the target state * (CLK must be running during the wait) @@ -456,7 +455,6 @@ struct dm_mmc_ops { * @return 0 if dat0 is in the target state, -ve on error */ int (*wait_dat0)(struct udevice *dev, int state, int timeout); -#endif }; #define mmc_get_ops(dev) ((struct dm_mmc_ops *)(dev)->driver->ops) -- cgit v1.1 From 39320c537def08bafa07ef3dd0f519465e56d57d Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 2 Jul 2019 10:53:54 +0200 Subject: mmc: use the generic timeout for cmd6 (SWITCH) provided in the ext_csd Starting with rev 4.5, the eMMC can define a generic timeout for the SWITCH command. Following Linux Kernel code, the timeout also changed from 1000 -> 500 Signed-off-by: Jean-Jacques Hiblot --- include/mmc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index cf83b74..711cb5d1 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -230,6 +230,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ #define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ #define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ /* @@ -585,6 +586,7 @@ struct mmc { u8 part_attr; u8 wr_rel_set; u8 part_config; + u8 gen_cmd6_time; uint tran_speed; uint legacy_speed; /* speed for the legacy mode provided by the card */ uint read_bl_len; -- cgit v1.1 From 513e00b64e63c277ad6dd667b823282ef4d177c1 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 2 Jul 2019 10:53:55 +0200 Subject: mmc: When switching partition, use the timeout specified in the ext_csd The e-MMC spec allows the e-MMC to specify a timeout for the partition switch command. It can take up to 2550 ms. There is no lower limit to this value in the spec, but do as the the linux driver does and force it to be at least 300ms. Signed-off-by: Jean-Jacques Hiblot --- include/mmc.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 711cb5d1..032873c 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -226,6 +226,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_HS_TIMING 185 /* R/W */ #define EXT_CSD_REV 192 /* RO */ #define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ #define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ @@ -587,6 +588,7 @@ struct mmc { u8 wr_rel_set; u8 part_config; u8 gen_cmd6_time; + u8 part_switch_time; uint tran_speed; uint legacy_speed; /* speed for the legacy mode provided by the card */ uint read_bl_len; @@ -833,6 +835,9 @@ extern uint mmc_get_env_part(struct mmc *mmc); # endif int mmc_get_env_dev(void); +/* Minimum partition switch timeout in units of 10-milliseconds */ +#define MMC_MIN_PART_SWITCH_TIME 30 /* 300 ms */ + /* Set block count limit because of 16 bit register limit on some hardware*/ #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT #define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535 -- cgit v1.1 From a897269c932999a5c028654489ad68baa6806fdb Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Mon, 8 Jul 2019 04:10:55 +0000 Subject: cmd: Remove mmc_spi command The mmc_spi command was added to manually setup MMC over SPI bus using command. This was required by the legacy non-DM MMC_SPI driver. With DM based MMC_SPI driver in-place, we can now use all general storge commands and mmc command for MMC over SPI bus hence we remove the mmc_spi command all it's references. Suggested-by: Bin Meng Signed-off-by: Anup Patel Reviewed-by: Bin Meng --- include/configs/UCP1020.h | 1 - include/mmc.h | 1 - 2 files changed, 2 deletions(-) (limited to 'include') diff --git a/include/configs/UCP1020.h b/include/configs/UCP1020.h index 268a41c..6a01a90 100644 --- a/include/configs/UCP1020.h +++ b/include/configs/UCP1020.h @@ -438,7 +438,6 @@ #ifdef CONFIG_MMC #define CONFIG_SYS_FSL_ESDHC_ADDR CONFIG_SYS_MPC85xx_ESDHC_ADDR -#define CONFIG_MMC_SPI #endif /* Misc Extra Settings */ diff --git a/include/mmc.h b/include/mmc.h index 032873c..0ef891f 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -824,7 +824,6 @@ void mmc_set_preinit(struct mmc *mmc, int preinit); #else #define mmc_host_is_spi(mmc) 0 #endif -struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode); void board_mmc_power_init(void); int board_mmc_init(bd_t *bis); -- cgit v1.1 From 44acd492480f8c8047326f3cb02d3e4d3760ecd0 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Wed, 10 Jul 2019 14:43:07 +0800 Subject: mmc: support hs400 enhanced strobe mode eMMC 5.1+ supports HS400 Enhances Strobe mode without the need for tuning procedure. The flow is as following: - set HS_TIMIMG (Highspeed) - Host change freq to <= 52Mhz - set the bus width to Enhanced strobe and DDR8Bit(CMD6), EXT_CSD[183] = 0x86 instead of 0x80 - set HS_TIMING to 0x3 (HS400) - Host change freq to <= 200Mhz - Host select HS400 enhanced strobe complete Signed-off-by: Peng Fan --- include/mmc.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/mmc.h b/include/mmc.h index 0ef891f..46422f4 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -65,6 +65,7 @@ #define MMC_MODE_DDR_52MHz MMC_CAP(MMC_DDR_52) #define MMC_MODE_HS200 MMC_CAP(MMC_HS_200) #define MMC_MODE_HS400 MMC_CAP(MMC_HS_400) +#define MMC_MODE_HS400_ES MMC_CAP(MMC_HS_400_ES) #define MMC_CAP_NONREMOVABLE BIT(14) #define MMC_CAP_NEEDS_POLL BIT(15) @@ -223,6 +224,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_BOOT_BUS_WIDTH 177 #define EXT_CSD_PART_CONF 179 /* R/W */ #define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_STROBE_SUPPORT 184 /* R/W */ #define EXT_CSD_HS_TIMING 185 /* R/W */ #define EXT_CSD_REV 192 /* RO */ #define EXT_CSD_CARD_TYPE 196 /* RO */ @@ -266,11 +268,13 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ #define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ #define EXT_CSD_DDR_FLAG BIT(2) /* Flag for DDR mode */ +#define EXT_CSD_BUS_WIDTH_STROBE BIT(7) /* Enhanced strobe mode */ #define EXT_CSD_TIMING_LEGACY 0 /* no high speed */ #define EXT_CSD_TIMING_HS 1 /* HS */ #define EXT_CSD_TIMING_HS200 2 /* HS200 */ #define EXT_CSD_TIMING_HS400 3 /* HS400 */ +#define EXT_CSD_DRV_STR_SHIFT 4 /* Driver Strength shift */ #define EXT_CSD_BOOT_ACK_ENABLE (1 << 6) #define EXT_CSD_BOOT_PARTITION_ENABLE (1 << 3) @@ -457,6 +461,11 @@ struct dm_mmc_ops { * @return 0 if dat0 is in the target state, -ve on error */ int (*wait_dat0)(struct udevice *dev, int state, int timeout); + +#if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT) + /* set_enhanced_strobe() - set HS400 enhanced strobe */ + int (*set_enhanced_strobe)(struct udevice *dev); +#endif }; #define mmc_get_ops(dev) ((struct dm_mmc_ops *)(dev)->driver->ops) @@ -475,6 +484,7 @@ int mmc_getcd(struct mmc *mmc); int mmc_getwp(struct mmc *mmc); int mmc_execute_tuning(struct mmc *mmc, uint opcode); int mmc_wait_dat0(struct mmc *mmc, int state, int timeout); +int mmc_set_enhanced_strobe(struct mmc *mmc); #else struct mmc_ops { @@ -520,6 +530,7 @@ enum bus_mode { UHS_SDR104, MMC_HS_200, MMC_HS_400, + MMC_HS_400_ES, MMC_MODES_END }; @@ -538,6 +549,10 @@ static inline bool mmc_is_mode_ddr(enum bus_mode mode) else if (mode == MMC_HS_400) return true; #endif +#if CONFIG_IS_ENABLED(MMC_HS400_ES_SUPPORT) + else if (mode == MMC_HS_400_ES) + return true; +#endif else return false; } -- cgit v1.1