summaryrefslogtreecommitdiff
path: root/FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/portable/Zynq/xsdps_info.h
blob: 94e822f969ada34ad82db828f7f7f1c2d6f9e9da (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
/******************************************************************************
 *
 * mmc_decode_cid() and sd_decode_csd()
 *
 * analyse the meta data of an SD-card to read its capacity and some other properties.
 *
 * CID and CSD Analysis borrowed from the Linux kernel.
 *
 ******************************************************************************/

#ifndef SDPS_INFO_H_

#define SDPS_INFO_H_  1

#include <stdint.h>

struct mmc_cid {
	uint32_t	manfid;
	char		prod_name[8];
	uint32_t	serial;
	uint16_t	oemid;
	uint16_t	year;
	uint8_t		hwrev;
	uint8_t		fwrev;
	uint8_t		month;
};

struct mmc_csd {
	volatile uint64_t	capacity_bytes;
	uint32_t	sd_last_block_address;
	uint8_t		mmca_vsn;
	uint16_t	erase_size;
	uint8_t		spare;
	uint16_t	cmdclass;
	uint16_t	tacc_clks;
	int32_t		erase_shift;
	uint32_t	tacc_ns;
	uint32_t	r2w_factor;
	uint32_t	max_dtr;
	uint32_t	read_blkbits;
	uint32_t	write_blkbits;
	uint32_t	capacity;
	uint32_t	pref_erase;
	uint32_t	read_partial : 1,
				read_misalign : 1,
				write_partial : 1,
				write_misalign : 1;
};

extern struct mmc_cid myCID;
extern struct mmc_csd myCSD;

int mmc_decode_cid( const struct mmc_csd *pxCSD, struct mmc_cid *pxCID, uint32_t *raw_data );
int sd_decode_csd( struct mmc_csd *pxCSD, uint32_t *ulResponse );

#endif /* SDPS_INFO_H_ */