]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/mmc.h
fw_env: calculate default number of env sectors
[karo-tx-uboot.git] / include / mmc.h
index ea198d87b7a3228d8310c49d90f18004e3ac0565..e95a2376d20001ff71e667daf4505e92afc688a7 100644 (file)
@@ -4,23 +4,7 @@
  *
  * Based (loosely) on the Linux code
  *
- * 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
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #ifndef _MMC_H_
 #define MMC_CMD_APP_CMD                        55
 #define MMC_CMD_SPI_READ_OCR           58
 #define MMC_CMD_SPI_CRC_ON_OFF         59
+#define MMC_CMD_RES_MAN                        62
+
+#define MMC_CMD62_ARG1                 0xefac62ec
+#define MMC_CMD62_ARG2                 0xcbaea7
+
 
 #define SD_CMD_SEND_RELATIVE_ADDR      3
 #define SD_CMD_SWITCH_FUNC             6
  * EXT_CSD fields
  */
 #define EXT_CSD_GP_SIZE_MULT           143     /* R/W */
+#define EXT_CSD_PARTITIONS_ATTRIBUTE   156     /* R/W */
 #define EXT_CSD_PARTITIONING_SUPPORT   160     /* RO */
 #define EXT_CSD_RPMB_MULT              168     /* RO */
 #define EXT_CSD_ERASE_GROUP_DEF                175     /* R/W */
+#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_HS_TIMING              185     /* R/W */
 #define EXT_CSD_BUS_WIDTH_4    1       /* Card is in 4 bit mode */
 #define EXT_CSD_BUS_WIDTH_8    2       /* Card is in 8 bit mode */
 
+#define EXT_CSD_BOOT_ACK_ENABLE                        (1 << 6)
+#define EXT_CSD_BOOT_PARTITION_ENABLE          (1 << 3)
+#define EXT_CSD_PARTITION_ACCESS_ENABLE                (1 << 0)
+#define EXT_CSD_PARTITION_ACCESS_DISABLE       (0 << 0)
+
+#define EXT_CSD_BOOT_ACK(x)            (x << 6)
+#define EXT_CSD_BOOT_PART_NUM(x)       (x << 3)
+#define EXT_CSD_PARTITION_ACCESS(x)    (x << 0)
+
+#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3)
+#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)        (x << 2)
+#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)        (x)
+
 #define R1_ILLEGAL_COMMAND             (1 << 22)
 #define R1_APP_CMD                     (1 << 5)
 
 #define MMCPART_NOAVAILABLE    (0xff)
 #define PART_ACCESS_MASK       (0x7)
 #define PART_SUPPORT           (0x1)
+#define PART_ENH_ATTRIB                (0x1f)
 
 /* Maximum block size for MMC */
 #define MMC_MAX_BLOCK_LEN      512
 
+/* The number of MMC physical partitions.  These consist of:
+ * boot partitions (2), general purpose partitions (4) in MMC v4.4.
+ */
+#define MMC_NUM_BOOT_PARTITION 2
+
 struct mmc_cid {
        unsigned long psn;
        unsigned short oid;
@@ -255,6 +265,8 @@ struct mmc {
        uint card_caps;
        uint host_caps;
        uint ocr;
+       uint dsr;
+       uint dsr_imp;
        uint scr[2];
        uint csd[4];
        uint cid[4];
@@ -297,7 +309,14 @@ int board_mmc_getcd(struct mmc *mmc);
 int mmc_switch_part(int dev_num, unsigned int part_num);
 int mmc_getcd(struct mmc *mmc);
 int mmc_getwp(struct mmc *mmc);
-void spl_mmc_load(void) __noreturn;
+int mmc_set_dsr(struct mmc *mmc, u16 val);
+/* Function to change the size of boot partition and rpmb partitions */
+int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize,
+                                       unsigned long rpmbsize);
+/* Function to modify the PARTITION_CONFIG field of EXT_CSD */
+int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
+/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */
+int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode);
 
 /**
  * Start device initialization and return immediately; it does not block on
@@ -325,7 +344,11 @@ int mmc_start_init(struct mmc *mmc);
 void mmc_set_preinit(struct mmc *mmc, int preinit);
 
 #ifdef CONFIG_GENERIC_MMC
+#ifdef CONFIG_MMC_SPI
 #define mmc_host_is_spi(mmc)   ((mmc)->host_caps & MMC_MODE_SPI)
+#else
+#define mmc_host_is_spi(mmc)   0
+#endif
 struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
 #else
 int mmc_legacy_init(int verbose);