2 This document describes m[g]flash support in u-boot.
6 2. Porting mflash driver
11 Mflash and gflash are embedded flash drive. The only difference is mflash is
12 MCP(Multi Chip Package) device. These two device operate exactly same way.
13 So the rest mflash repersents mflash and gflash altogether.
15 2. Porting mflash driver
17 2-1. Board configuration
18 * Mflash driver support
19 #define CONFIG_CMD_MG_DISK
22 * Environment variable support (optional)
23 #define CONFIG_ENV_IS_IN_MG_DISK
24 Also CONFIG_ENV_ADDR and CONFIG_ENV_SIZE should be defined.
25 CONFIG_ENV_ADDR is byte offset starting from 0.
27 Following example sets environment variable location to 0x80000 (1024'th
28 sector) and size of 0x400 (1024 byte)
29 #define CONFIG_ENV_ADDR 0x80000
30 #define CONFIG_ENV_SIZE 0x400
32 * Reserved size config (optional)
33 If you want to use some reserved area for bootloader, environment variable or
34 whatever, use CONFIG_MG_DISK_RES. The unit is KB. Mflash's block operation
35 method use this value as start offset. So any u-boot's partition table parser
36 and file system command work consistently. You can access this area by using
39 Following example sets 10MB of reserved area.
40 #define CONFIG_MG_DISK_RES 10240
42 2-2. Porting mg_get_drv_data function
43 Mflash is active device and need some gpio control for proper operation.
44 This board dependency resolved by using mg_get_drv_data function.
45 Port this function at your board init file. See include/mg_disk.h
47 Here is some pseudo example.
49 static void custom_hdrst_pin (u8 level)
52 /* set hard reset pin to high */
54 /* set hard reset pin to low */
57 static void custom_ctrl_pin_init (void)
59 /* Set hard reset, write protect, deep power down pins
61 * Set these pins to output high
65 struct mg_drv_data* mg_get_drv_data (void)
67 static struct mg_drv_data prv;
69 prv.base = /* base address of mflash */
70 prv.mg_ctrl_pin_init = custom_ctrl_pin_init;
71 prv.mg_hdrst_pin = custom_hdrst_pin;
78 * initialize : mgd init
79 * random read : mgd read [from] [to] [size]
80 ex) read 256 bytes from 0x300000 of mflash to 0xA0100000 of host memory
81 mgd read 0x300000 0xA0100000 256
82 * random write : mgd write [from] [to] [size]
83 * sector read : mgd readsec [sector] [to] [count]
84 ex) read 10 sectors starts from 400 sector to 0xA0100000
85 mgd readsec 400 0xA0100000 10
86 * sector write : mgd writesec [from] [sector] [count]
89 Mflash's device interface name for block driver is "mgd".
90 Here is ext2 file system access example.
94 ext2load mgd 0:1 0xa0010000 /boot/uImage 1954156