unsik Kim | 75eb82e | 2009-02-25 11:31:24 +0900 | [diff] [blame^] | 1 | |
| 2 | This document describes m[g]flash support in u-boot. |
| 3 | |
| 4 | Contents |
| 5 | 1. Overview |
| 6 | 2. Porting mflash driver |
| 7 | 3. Mflash command |
| 8 | 4. Misc. |
| 9 | |
| 10 | 1. Overview |
| 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. |
| 14 | |
| 15 | 2. Porting mflash driver |
| 16 | |
| 17 | 2-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 |
| 24 | Also CONFIG_ENV_ADDR and CONFIG_ENV_SIZE should be defined. |
| 25 | CONFIG_ENV_ADDR is byte offset starting from 0. |
| 26 | |
| 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 |
| 31 | |
| 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 |
| 37 | mflash command. |
| 38 | |
| 39 | Following example sets 10MB of reserved area. |
| 40 | #define CONFIG_MG_DISK_RES 10240 |
| 41 | |
| 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 |
| 46 | |
| 47 | Here is some pseudo example. |
| 48 | |
| 49 | static 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 | |
| 57 | static 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 | |
| 65 | struct 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 | |
| 76 | 3. 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 | |
| 88 | 4. Misc. |
| 89 | Mflash's device interface name for block driver is "mgd". |
| 90 | Here 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 |