]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/mmc.h
Merge branch 'u-boot/master'
[karo-tx-uboot.git] / include / mmc.h
index e1060b9ff2794f5b3ebb77b14321ccad1c499d54..bc11f45a6fca691bcc8ecb873af5a0bbafb76def 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <linux/list.h>
 #include <linux/compiler.h>
+#include <part.h>
 
 #define SD_VERSION_SD  0x20000
 #define SD_VERSION_3   (SD_VERSION_SD | 0x300)
 #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_RST_N_FUNCTION         162     /* R/W */
 #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_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)
@@ -247,20 +252,40 @@ struct mmc_data {
        uint blocksize;
 };
 
+/* forward decl. */
+struct mmc;
+
+struct mmc_ops {
+       int (*send_cmd)(struct mmc *mmc,
+                       struct mmc_cmd *cmd, struct mmc_data *data);
+       void (*set_ios)(struct mmc *mmc);
+       int (*init)(struct mmc *mmc);
+       int (*getcd)(struct mmc *mmc);
+       int (*getwp)(struct mmc *mmc);
+};
+
+struct mmc_config {
+       const char *name;
+       const struct mmc_ops *ops;
+       uint host_caps;
+       uint voltages;
+       uint f_min;
+       uint f_max;
+       uint b_max;
+       unsigned char part_type;
+};
+
+/* TODO struct mmc should be in mmc_private but it's hard to fix right now */
 struct mmc {
        struct list_head link;
-       char name[32];
-       void *priv;
-       uint voltages;
+       const struct mmc_config *cfg;   /* provided configuration */
        uint version;
+       void *priv;
        uint has_init;
-       uint f_min;
-       uint f_max;
        int high_capacity;
        uint bus_width;
        uint clock;
        uint card_caps;
-       uint host_caps;
        uint ocr;
        uint dsr;
        uint dsr_imp;
@@ -280,13 +305,6 @@ struct mmc {
        u64 capacity_rpmb;
        u64 capacity_gp[4];
        block_dev_desc_t block_dev;
-       int (*send_cmd)(struct mmc *mmc,
-                       struct mmc_cmd *cmd, struct mmc_data *data);
-       void (*set_ios)(struct mmc *mmc);
-       int (*init)(struct mmc *mmc);
-       int (*getcd)(struct mmc *mmc);
-       int (*getwp)(struct mmc *mmc);
-       uint b_max;
        char op_cond_pending;   /* 1 if we are waiting on an op_cond command */
        char init_in_progress;  /* 1 if we have done mmc_start_init() */
        char preinit;           /* start init as early as possible */
@@ -294,6 +312,8 @@ struct mmc {
 };
 
 int mmc_register(struct mmc *mmc);
+struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
+void mmc_destroy(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);
@@ -310,8 +330,12 @@ 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 send commands to open/close the specified boot partition */
-int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access);
+/* 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);
+/* Function to modify the RST_n_FUNCTION field of EXT_CSD */
+int mmc_set_rst_n_function(struct mmc *mmc, u8 enable);
 
 /**
  * Start device initialization and return immediately; it does not block on
@@ -340,7 +364,7 @@ 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)
+#define mmc_host_is_spi(mmc)   ((mmc)->cfg->host_caps & MMC_MODE_SPI)
 #else
 #define mmc_host_is_spi(mmc)   0
 #endif
@@ -349,4 +373,11 @@ struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
 int mmc_legacy_init(int verbose);
 #endif
 
+int board_mmc_init(bd_t *bis);
+
+/* 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
+#endif
+
 #endif /* _MMC_H_ */