blob: 50133b461f9814e871219182a70e1ab50b625d99 [file] [log] [blame]
unsik Kim75eb82e2009-02-25 11:31:24 +09001
2This document describes m[g]flash support in u-boot.
3
4Contents
5 1. Overview
6 2. Porting mflash driver
7 3. Mflash command
8 4. Misc.
9
101. Overview
11Mflash and gflash are embedded flash drive. The only difference is mflash is
12MCP(Multi Chip Package) device. These two device operate exactly same way.
13So the rest mflash repersents mflash and gflash altogether.
14
152. Porting mflash driver
16
172-1. Board configuration
18* Mflash driver support
19#define CONFIG_CMD_MG_DISK
20#define CONFIG_LIBATA
21
22* Environment variable support (optional)
23#define CONFIG_ENV_IS_IN_MG_DISK
24Also CONFIG_ENV_ADDR and CONFIG_ENV_SIZE should be defined.
25CONFIG_ENV_ADDR is byte offset starting from 0.
26
27Following example sets environment variable location to 0x80000 (1024'th
28sector) and size of 0x400 (1024 byte)
29#define CONFIG_ENV_ADDR 0x80000
30#define CONFIG_ENV_SIZE 0x400
31
32* Reserved size config (optional)
33If you want to use some reserved area for bootloader, environment variable or
34whatever, use CONFIG_MG_DISK_RES. The unit is KB. Mflash's block operation
35method use this value as start offset. So any u-boot's partition table parser
36and file system command work consistently. You can access this area by using
37mflash command.
38
39Following example sets 10MB of reserved area.
40#define CONFIG_MG_DISK_RES 10240
41
422-2. Porting mg_get_drv_data function
43Mflash is active device and need some gpio control for proper operation.
44This board dependency resolved by using mg_get_drv_data function.
45Port this function at your board init file. See include/mg_disk.h
46
47Here is some pseudo example.
48
49static void custom_hdrst_pin (u8 level)
50{
51 if (level)
52 /* set hard reset pin to high */
53 else
54 /* set hard reset pin to low */
55}
56
57static void custom_ctrl_pin_init (void)
58{
59 /* Set hard reset, write protect, deep power down pins
60 * to gpio.
61 * Set these pins to output high
62 */
63}
64
65struct mg_drv_data* mg_get_drv_data (void)
66{
67 static struct mg_drv_data prv;
68
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;
72
73 return &prv;
74}
75
763. Mflash command
77
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]
87
884. Misc.
89Mflash's device interface name for block driver is "mgd".
90Here is ext2 file system access example.
91
92 mgd init
93 ext2ls mgd 0:1 /boot
94 ext2load mgd 0:1 0xa0010000 /boot/uImage 1954156