summaryrefslogtreecommitdiff
path: root/kernel-headers/linux/mmc/sd_misc.h
blob: 06682737fe0fa3443dd5d3e292b292602fc72eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#ifndef SD_MISC_H
#define SD_MISC_H

#ifdef __KERNEL__
#include <linux/bitops.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
#include <linux/mmc/core.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#endif



struct msdc_ioctl {
    int opcode;
    int host_num;
    int iswrite;
    int trans_type;
    unsigned int total_size;
    unsigned int address;
    unsigned int *buffer;
    int cmd_pu_driving;
    int cmd_pd_driving;
    int dat_pu_driving;
    int dat_pd_driving;
    int clk_pu_driving;
    int clk_pd_driving;
    int ds_pu_driving;
    int ds_pd_driving;
    int rst_pu_driving;
    int rst_pd_driving;
    int clock_freq;
    int partition;
    int hopping_bit;
    int hopping_time;
    int result;
    int sd30_mode;
    int sd30_max_current;
    int sd30_drive;
    int sd30_power_control;
};

/**************for msdc_ssc***********************/
#define AUDPLL_CTL_REG12                   (0xF0007070)
#define AUDPLL_CTL_REG01                   (0xF00071E0)
#define AUDPLL_CTL_REG02                   (0xF100000C)

#define AUDPLL_TSEL_MASK                   (1792)   /* MASK = 00000111 00000000 */
#define AUDPLL_TSEL_RESULT1                (0)  /* REG = 00000000 00000000   30.5us */
#define AUDPLL_TSEL_RESULT2                (256)    /* REG = 00000001 00000000   61.0us */
#define AUDPLL_TSEL_RESULT3                (512)    /* REG = 00000010 00000000   122.1us */
#define AUDPLL_TSEL_RESULT4                (768)    /* REG = 00000011 00000000   244.1us */
#define AUDPLL_TSEL_RESULT5                (1024)   /* REG = 00000100 00000000   448.3us */

#define AUDPLL_BSEL_MASK                   (7)  /* MASK = 00000000 00000111 */
#define AUDPLL_BSEL_RESULT0                (0)  /* REG = 00000000 00000000   REG init val */
#define AUDPLL_BSEL_RESULT1                (1)  /* REG = 00000000 00000001   2.26MHz */
#define AUDPLL_BSEL_RESULT2                (2)  /* REG = 00000000 00000010   4.52MHz */
#define AUDPLL_BSEL_RESULT3                (4)  /* REG = 00000000 00000100   9.04MHz */

#define SET_HOP_BIT_NONE                   (0)
#define SET_HOP_BIT1                       (1)
#define SET_HOP_BIT2                       (2)
#define SET_HOP_BIT3                       (3)

#define SET_HOP_TIME0                      (0)
#define SET_HOP_TIME1                      (1)
#define SET_HOP_TIME2                      (2)
#define SET_HOP_TIME3                      (3)
#define SET_HOP_TIME4                      (4)


/**************for msdc_ssc***********************/

#define MSDC_DRIVING_SETTING                (0)
#define MSDC_CLOCK_FREQUENCY                (1)
#define MSDC_SINGLE_READ_WRITE              (2)
#define MSDC_MULTIPLE_READ_WRITE            (3)
#define MSDC_GET_CID                        (4)
#define MSDC_GET_CSD                        (5)
#define MSDC_GET_EXCSD                      (6)
#define MSDC_ERASE_PARTITION                (7)
#define MSDC_HOPPING_SETTING                (8)

#define MSDC_REINIT_SDCARD            _IOW('r', 9, int)

#define MSDC_SD30_MODE_SWITCH               (10)
#define MSDC_GET_BOOTPART                   (11)
#define MSDC_SET_BOOTPART                   (12)
#define MSDC_GET_PARTSIZE                   (13)
#define MSDC_ERASE_SELECTED_AREA            (0x20)
#define MSDC_CARD_DUNM_FUNC                 (0xff)

typedef enum {
    USER_PARTITION = 0,
    BOOT_PARTITION_1,
    BOOT_PARTITION_2,
    RPMB_PARTITION,
    GP_PARTITION_1,
    GP_PARTITION_2,
    GP_PARTITION_3,
    GP_PARTITION_4,
} PARTITON_ACCESS_T;

typedef enum {
    SDHC_HIGHSPEED = 0, /* 0 Host supports HS mode */
    UHS_SDR12,      /* 1 Host supports UHS SDR12 mode */
    UHS_SDR25,      /* 2 Host supports UHS SDR25 mode */
    UHS_SDR50,      /* 3 Host supports UHS SDR50 mode */
    UHS_SDR104,     /* 4 Host supports UHS SDR104 mode */
    UHS_DDR50,      /* 5 Host supports UHS DDR50 mode */
} SD3_MODE;

typedef enum {
    DRIVER_TYPE_A = 0,  /* 0 Host supports Driver Type A */
    DRIVER_TYPE_B,      /* 1 Host supports Driver Type B */
    DRIVER_TYPE_C,      /* 2 Host supports Driver Type C */
    DRIVER_TYPE_D,      /* 3 Host supports Driver Type D */
} SD3_DRIVE;

typedef enum {
    MAX_CURRENT_200 = 0,    /* 0 Host max current limit is 200mA */
    MAX_CURRENT_400,    /* 1 Host max current limit is 400mA */
    MAX_CURRENT_600,    /* 2 Host max current limit is 600mA */
    MAX_CURRENT_800,    /* 3 Host max current limit is 800mA */
} SD3_MAX_CURRENT;

typedef enum {
    SDXC_NO_POWER_CONTROL = 0,  /* 0  Host not supports >150mA current at 3.3V /3.0V/1.8V */
    SDXC_POWER_CONTROL, /* 1 Host supports >150mA current at 3.3V /3.0V/1.8V */
} SD3_POWER_CONTROL;

typedef enum {
    DUMP_INTO_BOOT_CARD_IPANIC = 0,
    DUMP_INTO_BOOT_CARD_KDUMP = 1,
    DUMP_INTO_EXTERN_CARD = 2,
} DUMP_STORAGE_TYPE;

typedef enum {
    EMMC_CARD_BOOT = 0,
    SD_CARD_BOOT,
    EMMC_CARD,
    SD_CARD,
} STORAGE_TPYE;

#define EXT_CSD_BOOT_SIZE_MULT           (226) /* R */
#define EXT_CSD_HC_ERASE_GRP_SIZE        (224) /* RO */
#define EXT_CSD_HC_WP_GPR_SIZE           (221) /* RO */
#define EXT_CSD_RPMB_SIZE_MULT           (168) /* R */
#define EXT_CSD_GP1_SIZE_MULT            (143) /* R/W 3 bytes */
#define EXT_CSD_GP2_SIZE_MULT            (146) /* R/W 3 bytes */
#define EXT_CSD_GP3_SIZE_MULT            (149) /* R/W 3 bytes */
#define EXT_CSD_GP4_SIZE_MULT            (152) /* R/W 3 bytes */
#define EXT_CSD_PART_CFG                 (179) /* R/W/E & R/W/E_P */
#define EXT_CSD_CACHE_FLUSH              (32)
#define EXT_CSD_CACHE_CTRL               (33)
#define CAPACITY_2G                      (2 * 1024 * 1024 * 1024ULL)

typedef enum {
    EMMC_BOOT_NO_EN = 0,
    EMMC_BOOT1_EN,
    EMMC_BOOT2_EN,
    EMMC_BOOT_USER = 7,
    EMMC_BOOT_END
} BOOT_PARTITION_EN;

#ifdef CONFIG_MTK_GPT_SCHEME_SUPPORT
typedef enum {
    EMMC_PART_UNKNOWN=0
    ,EMMC_PART_BOOT1
    ,EMMC_PART_BOOT2
    ,EMMC_PART_RPMB
    ,EMMC_PART_GP1
    ,EMMC_PART_GP2
    ,EMMC_PART_GP3
    ,EMMC_PART_GP4
    ,EMMC_PART_USER
    ,EMMC_PART_END
} Region;
#endif

typedef enum {
    CARD_INFO = 0,
    DISK_INFO,
    EMMC_USER_CAPACITY,
    EMMC_CAPACITY,
    EMMC_RESERVE,
} GET_STORAGE_INFO;

struct storage_info {
    struct mmc_card *card;
    struct gendisk *disk;
    unsigned long long emmc_user_capacity;
    unsigned long long emmc_capacity;
    int emmc_reserve;
};

int msdc_get_info(STORAGE_TPYE storage_type, GET_STORAGE_INFO info_type, struct storage_info *info);

#endif              /* end of SD_MISC_H */