Commit b37d41aa authored by Marek Vasut's avatar Marek Vasut Committed by Wolfgang Denk

Block: Remove MG DISK support

This driver is unused and obsolete.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: unsik Kim <donari75@gmail.com>
parent 3648ff2d
......@@ -52,7 +52,6 @@ COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
XCOBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
COBJS-$(CONFIG_ENV_IS_IN_MG_DISK) += env_mgdisk.o
COBJS-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
COBJS-$(CONFIG_ENV_IS_IN_FAT) += env_fat.o
COBJS-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
......@@ -115,7 +114,6 @@ COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o
COBJS-$(CONFIG_CMD_MD5SUM) += cmd_md5sum.o
COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o
COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o
COBJS-$(CONFIG_CMD_MG_DISK) += cmd_mgdisk.o
COBJS-$(CONFIG_MII) += miiphyutil.o
COBJS-$(CONFIG_CMD_MII) += miiphyutil.o
COBJS-$(CONFIG_PHYLIB) += miiphyutil.o
......
/*
* (C) Copyright 2009 mGine co.
* unsik Kim <donari75@gmail.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <command.h>
#include <mg_disk.h>
int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
u32 from, to, size;
switch (argc) {
case 2:
if (!strcmp(argv[1], "init"))
mg_disk_init();
else
return 1;
break;
case 5:
from = simple_strtoul(argv[2], NULL, 0);
to = simple_strtoul(argv[3], NULL, 0);
size = simple_strtoul(argv[4], NULL, 0);
if (!strcmp(argv[1], "read"))
mg_disk_read(from, (u8 *)to, size);
else if (!strcmp(argv[1], "write"))
mg_disk_write(to, (u8 *)from, size);
else if (!strcmp(argv[1], "readsec"))
mg_disk_read_sects((void *)to, from, size);
else if (!strcmp(argv[1], "writesec"))
mg_disk_write_sects((void *)from, to, size);
else
return 1;
break;
default:
return CMD_RET_USAGE;
}
return 0;
}
U_BOOT_CMD(
mgd, 5, 0, do_mg_disk_cmd,
"mgine m[g]flash command\n",
": mgine mflash IO mode (disk) command\n"
" - initialize : mgd init\n"
" - random read : mgd read [from] [to] [size]\n"
" - random write : mgd write [from] [to] [size]\n"
" - sector read : mgd readsec [sector] [to] [counts]\n"
" - sector write : mgd writesec [from] [sector] [counts]"
);
......@@ -59,7 +59,6 @@ DECLARE_GLOBAL_DATA_PTR;
#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \
!defined(CONFIG_ENV_IS_IN_FLASH) && \
!defined(CONFIG_ENV_IS_IN_DATAFLASH) && \
!defined(CONFIG_ENV_IS_IN_MG_DISK) && \
!defined(CONFIG_ENV_IS_IN_MMC) && \
!defined(CONFIG_ENV_IS_IN_FAT) && \
!defined(CONFIG_ENV_IS_IN_NAND) && \
......@@ -69,7 +68,7 @@ DECLARE_GLOBAL_DATA_PTR;
!defined(CONFIG_ENV_IS_IN_REMOTE) && \
!defined(CONFIG_ENV_IS_NOWHERE)
# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
SPI_FLASH|MG_DISK|NVRAM|MMC|FAT|REMOTE} or CONFIG_ENV_IS_NOWHERE
SPI_FLASH|NVRAM|MMC|FAT|REMOTE} or CONFIG_ENV_IS_NOWHERE
#endif
#define XMK_STR(x) #x
......
/*
* (C) Copyright 2009 mGine co.
* unsik Kim <donari75@gmail.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <command.h>
#include <environment.h>
#include <linux/stddef.h>
#include <mg_disk.h>
char *env_name_spec = "MG_DISK";
env_t *env_ptr;
DECLARE_GLOBAL_DATA_PTR;
void env_relocate_spec(void)
{
char buf[CONFIG_ENV_SIZE];
unsigned int err, rc;
err = mg_disk_init();
if (err) {
set_default_env("!mg_disk_init error");
return;
}
err = mg_disk_read(CONFIG_ENV_ADDR, buf, CONFIG_ENV_SIZE);
if (err) {
set_default_env("!mg_disk_read error");
return;
}
env_import(buf, 1);
}
int saveenv(void)
{
unsigned int err;
env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
err = mg_disk_write(CONFIG_ENV_ADDR, (u_char *)env_ptr,
CONFIG_ENV_SIZE);
if (err)
puts("*** Warning - mg_disk_write error\n\n");
return err;
}
int env_init(void)
{
/* use default */
gd->env_addr = (ulong)&default_environment[0];
gd->env_valid = 1;
return 0;
}
......@@ -35,7 +35,6 @@
#endif
#if (defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......@@ -65,9 +64,6 @@ static const struct block_drvr block_drvr[] = {
#endif
#if defined(CONFIG_SYSTEMACE)
{ .name = "ace", .get_dev = systemace_get_dev, },
#endif
#if defined(CONFIG_CMD_MG_DISK)
{ .name = "mgd", .get_dev = mg_disk_get_dev, },
#endif
{ },
};
......@@ -108,7 +104,6 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
#endif
#if (defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......@@ -244,7 +239,6 @@ void dev_print (block_dev_desc_t *dev_desc)
#endif
#if (defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......
......@@ -27,7 +27,6 @@
#include "part_amiga.h"
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
defined(CONFIG_MMC) || \
......
......@@ -36,7 +36,6 @@
#include "part_dos.h"
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......
......@@ -38,7 +38,6 @@
#include <linux/ctype.h>
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......
......@@ -26,7 +26,6 @@
#include "part_iso.h"
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_USB) || \
......
......@@ -35,7 +35,6 @@
#include "part_mac.h"
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_USB) || \
......
This document describes m[g]flash support in u-boot.
Contents
1. Overview
2. Porting mflash driver
3. Mflash command
4. Misc.
1. Overview
Mflash and gflash are embedded flash drive. The only difference is mflash is
MCP(Multi Chip Package) device. These two device operate exactly same way.
So the rest mflash repersents mflash and gflash altogether.
2. Porting mflash driver
2-1. Board configuration
* Mflash driver support
#define CONFIG_CMD_MG_DISK
#define CONFIG_LIBATA
* Environment variable support (optional)
#define CONFIG_ENV_IS_IN_MG_DISK
Also CONFIG_ENV_ADDR and CONFIG_ENV_SIZE should be defined.
CONFIG_ENV_ADDR is byte offset starting from 0.
Following example sets environment variable location to 0x80000 (1024'th
sector) and size of 0x400 (1024 byte)
#define CONFIG_ENV_ADDR 0x80000
#define CONFIG_ENV_SIZE 0x400
* Reserved size config (optional)
If you want to use some reserved area for bootloader, environment variable or
whatever, use CONFIG_MG_DISK_RES. The unit is KB. Mflash's block operation
method use this value as start offset. So any u-boot's partition table parser
and file system command work consistently. You can access this area by using
mflash command.
Following example sets 10MB of reserved area.
#define CONFIG_MG_DISK_RES 10240
2-2. Porting mg_get_drv_data function
Mflash is active device and need some gpio control for proper operation.
This board dependency resolved by using mg_get_drv_data function.
Port this function at your board init file. See include/mg_disk.h
Here is some pseudo example.
static void custom_hdrst_pin (u8 level)
{
if (level)
/* set hard reset pin to high */
else
/* set hard reset pin to low */
}
static void custom_ctrl_pin_init (void)
{
/* Set hard reset, write protect, deep power down pins
* to gpio.
* Set these pins to output high
*/
}
struct mg_drv_data* mg_get_drv_data (void)
{
static struct mg_drv_data prv;
prv.base = /* base address of mflash */
prv.mg_ctrl_pin_init = custom_ctrl_pin_init;
prv.mg_hdrst_pin = custom_hdrst_pin;
return &prv;
}
3. Mflash command
* initialize : mgd init
* random read : mgd read [from] [to] [size]
ex) read 256 bytes from 0x300000 of mflash to 0xA0100000 of host memory
mgd read 0x300000 0xA0100000 256
* random write : mgd write [from] [to] [size]
* sector read : mgd readsec [sector] [to] [count]
ex) read 10 sectors starts from 400 sector to 0xA0100000
mgd readsec 400 0xA0100000 10
* sector write : mgd writesec [from] [sector] [count]
4. Misc.
Mflash's device interface name for block driver is "mgd".
Here is ext2 file system access example.
mgd init
ext2ls mgd 0:1 /boot
ext2load mgd 0:1 0xa0010000 /boot/uImage 1954156
......@@ -31,7 +31,6 @@ COBJS-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
COBJS-$(CONFIG_IDE_FTIDE020) += ftide020.o
COBJS-$(CONFIG_LIBATA) += libata.o
COBJS-$(CONFIG_CMD_MG_DISK) += mg_disk.o
COBJS-$(CONFIG_MVSATA_IDE) += mvsata_ide.o
COBJS-$(CONFIG_MX51_PATA) += mxc_ata.o
COBJS-$(CONFIG_PATA_BFIN) += pata_bfin.o
......
This diff is collapsed.
/*
* (C) Copyright 2009 mGine co.
* unsik Kim <donari75@gmail.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __MG_DISK_PRV_H__
#define __MG_DISK_PRV_H__
#include <mg_disk.h>
/* name for block device */
#define MG_DISK_NAME "mgd"
/* name for platform device */
#define MG_DEV_NAME "mg_disk"
#define MG_DISK_MAJ 240
#define MG_DISK_MAX_PART 16
#define MG_SECTOR_SIZE 512
#define MG_SECTOR_SIZE_MASK (512 - 1)
#define MG_SECTOR_SIZE_SHIFT (9)
#define MG_MAX_SECTS 256
/* Register offsets */
#define MG_BUFF_OFFSET 0x8000
#define MG_STORAGE_BUFFER_SIZE 0x200
#define MG_REG_OFFSET 0xC000
#define MG_REG_FEATURE (MG_REG_OFFSET + 2) /* write case */
#define MG_REG_ERROR (MG_REG_OFFSET + 2) /* read case */
#define MG_REG_SECT_CNT (MG_REG_OFFSET + 4)
#define MG_REG_SECT_NUM (MG_REG_OFFSET + 6)
#define MG_REG_CYL_LOW (MG_REG_OFFSET + 8)
#define MG_REG_CYL_HIGH (MG_REG_OFFSET + 0xA)
#define MG_REG_DRV_HEAD (MG_REG_OFFSET + 0xC)
#define MG_REG_COMMAND (MG_REG_OFFSET + 0xE) /* write case */
#define MG_REG_STATUS (MG_REG_OFFSET + 0xE) /* read case */
#define MG_REG_DRV_CTRL (MG_REG_OFFSET + 0x10)
#define MG_REG_BURST_CTRL (MG_REG_OFFSET + 0x12)
/* "Drive Select/Head Register" bit values */
#define MG_REG_HEAD_MUST_BE_ON 0xA0 /* These 2 bits are always on */
#define MG_REG_HEAD_DRIVE_MASTER (0x00 | MG_REG_HEAD_MUST_BE_ON)
#define MG_REG_HEAD_DRIVE_SLAVE (0x10 | MG_REG_HEAD_MUST_BE_ON)
#define MG_REG_HEAD_LBA_MODE (0x40 | MG_REG_HEAD_MUST_BE_ON)
/* "Device Control Register" bit values */
#define MG_REG_CTRL_INTR_ENABLE 0x0
#define MG_REG_CTRL_INTR_DISABLE (0x1 << 1)
#define MG_REG_CTRL_RESET (0x1 << 2)
#define MG_REG_CTRL_INTR_POLA_ACTIVE_HIGH 0x0
#define MG_REG_CTRL_INTR_POLA_ACTIVE_LOW (0x1 << 4)
#define MG_REG_CTRL_DPD_POLA_ACTIVE_LOW 0x0
#define MG_REG_CTRL_DPD_POLA_ACTIVE_HIGH (0x1 << 5)
#define MG_REG_CTRL_DPD_DISABLE 0x0
#define MG_REG_CTRL_DPD_ENABLE (0x1 << 6)
/* Status register bit */
/* error bit in status register */
#define MG_REG_STATUS_BIT_ERROR 0x01
/* corrected error in status register */
#define MG_REG_STATUS_BIT_CORRECTED_ERROR 0x04
/* data request bit in status register */
#define MG_REG_STATUS_BIT_DATA_REQ 0x08
/* DSC - Drive Seek Complete */
#define MG_REG_STATUS_BIT_SEEK_DONE 0x10
/* DWF - Drive Write Fault */
#define MG_REG_STATUS_BIT_WRITE_FAULT 0x20
#define MG_REG_STATUS_BIT_READY 0x40
#define MG_REG_STATUS_BIT_BUSY 0x80
/* handy status */
#define MG_STAT_READY (MG_REG_STATUS_BIT_READY | MG_REG_STATUS_BIT_SEEK_DONE)
#define MG_READY_OK(s) (((s) & (MG_STAT_READY | \
(MG_REG_STATUS_BIT_BUSY | \
MG_REG_STATUS_BIT_WRITE_FAULT | \
MG_REG_STATUS_BIT_ERROR))) == MG_STAT_READY)
/* Error register */
#define MG_REG_ERR_AMNF 0x01
#define MG_REG_ERR_ABRT 0x04
#define MG_REG_ERR_IDNF 0x10
#define MG_REG_ERR_UNC 0x40
#define MG_REG_ERR_BBK 0x80
/* error code for others */
#define MG_ERR_NONE 0
#define MG_ERR_TIMEOUT 0x100
#define MG_ERR_INIT_STAT 0x101
#define MG_ERR_TRANSLATION 0x102
#define MG_ERR_CTRL_RST 0x103
#define MG_ERR_NO_DRV_DATA 0x104
#define MG_MAX_ERRORS 16 /* Max read/write errors/sector */
#define MG_RESET_FREQ 4 /* Reset controller every 4th retry */
/* command */
#define MG_CMD_RD 0x20
#define MG_CMD_WR 0x30
#define MG_CMD_SLEEP 0x99
#define MG_CMD_WAKEUP 0xC3
#define MG_CMD_ID 0xEC
#define MG_CMD_WR_CONF 0x3C
#define MG_CMD_RD_CONF 0x40
union mg_uniwb{
u16 w;
u8 b[2];
};
/* main structure for mflash driver */
struct mg_host {
struct mg_drv_data *drv_data;
/* for future use */
};
/*
* Debugging macro and defines
*/
#undef DO_MG_DEBUG
#ifdef DO_MG_DEBUG
# define MG_DBG(fmt, args...) printf("%s:%d "fmt"\n", __func__, __LINE__,##args)
#else /* CONFIG_MG_DEBUG */
# define MG_DBG(fmt, args...) do { } while(0)
#endif /* CONFIG_MG_DEBUG */
#endif
......@@ -70,7 +70,6 @@ int fat_register_device (block_dev_desc_t * dev_desc, int part_no)
cur_dev = NULL;
#if (defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......@@ -1128,7 +1127,6 @@ int file_fat_detectfs (void)
}
#if defined(CONFIG_CMD_IDE) || \
defined(CONFIG_CMD_MG_DISK) || \
defined(CONFIG_CMD_SATA) || \
defined(CONFIG_CMD_SCSI) || \
defined(CONFIG_CMD_USB) || \
......
......@@ -55,7 +55,6 @@
#define CONFIG_CMD_LOADS /* loads */
#define CONFIG_CMD_MEMORY /* md mm nm mw cp cmp crc base loop mtest */
#define CONFIG_CMD_MFSL /* FSL support for Microblaze */
#define CONFIG_CMD_MG_DISK /* mGine m(g)flash IO node support */
#define CONFIG_CMD_MII /* MII support */
#define CONFIG_CMD_MISC /* Misc functions like sleep etc*/
#define CONFIG_CMD_MMC /* MMC support */
......
......@@ -96,15 +96,6 @@ extern unsigned long nand_env_oob_offset;
# endif
#endif /* CONFIG_ENV_IS_IN_NAND */
#if defined(CONFIG_ENV_IS_IN_MG_DISK)
# ifndef CONFIG_ENV_ADDR
# error "Need to define CONFIG_ENV_ADDR when using CONFIG_ENV_IS_IN_MG_DISK"
# endif
# ifndef CONFIG_ENV_SIZE
# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_MG_DISK"
# endif
#endif /* CONFIG_ENV_IS_IN_MG_DISK */
/* Embedded env is only supported for some flash types */
#ifdef CONFIG_ENV_IS_EMBEDDED
# if !defined(CONFIG_ENV_IS_IN_FLASH) && \
......
/*
* (C) Copyright 2009 mGine co.
* unsik Kim <donari75@gmail.com>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef MG_DISK_H_
#define MG_DISK_H_
#include <asm/types.h>
/* private driver data */
struct mg_drv_data {
/* base address of mflash */
u32 base;
/* Initialize hard reset, write protect, deep power down pins.
* Set these pins to GPIO and output high
*/
void (*mg_ctrl_pin_init) (void);
/* Set hard reset pin for given level
* level : logical level of hard reset pin (0 or 1)
*/
void (*mg_hdrst_pin) (u8 level);
};
struct mg_drv_data* mg_get_drv_data (void);
unsigned int mg_disk_init (void);
unsigned int mg_disk_read (u32 addr, u8 *buff, u32 len);
unsigned int mg_disk_write(u32 addr, u8 *buff, u32 len);
unsigned int mg_disk_write_sects(void *buff, u32 sect_num, u32 sect_cnt);
unsigned int mg_disk_read_sects(void *buff, u32 sect_num, u32 sect_cnt);
#endif /*MG_DISK_H_*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment