2008-06-27 23:24:34 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Dave Chapman
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* 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.
|
2008-06-27 23:24:34 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-10-04 15:02:40 +00:00
|
|
|
#include "config.h"
|
2008-06-27 23:24:34 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include "thread.h"
|
|
|
|
#include "disk.h"
|
2009-10-04 15:02:40 +00:00
|
|
|
#include "storage.h"
|
2008-06-27 23:24:34 +00:00
|
|
|
#include "panic.h"
|
|
|
|
#include "usb.h"
|
2009-10-04 15:02:40 +00:00
|
|
|
#include "ftl-target.h"
|
2009-10-11 10:10:49 +00:00
|
|
|
#include "nand-target.h"
|
2008-06-27 23:24:34 +00:00
|
|
|
|
|
|
|
/** static, private data **/
|
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
/* API Functions */
|
2013-08-17 16:18:22 +00:00
|
|
|
int nand_read_sectors(IF_MD(int drive,) unsigned long start, int incount,
|
2008-06-27 23:24:34 +00:00
|
|
|
void* inbuf)
|
|
|
|
{
|
2009-11-08 14:55:30 +00:00
|
|
|
return ftl_read(start, incount, inbuf);
|
2008-06-27 23:24:34 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 16:18:22 +00:00
|
|
|
int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count,
|
2008-06-27 23:24:34 +00:00
|
|
|
const void* outbuf)
|
|
|
|
{
|
2009-11-08 14:55:30 +00:00
|
|
|
return ftl_write(start, count, outbuf);
|
2008-06-27 23:24:34 +00:00
|
|
|
}
|
|
|
|
|
2009-07-17 16:34:34 +00:00
|
|
|
void nand_spindown(int seconds)
|
|
|
|
{
|
|
|
|
(void)seconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nand_sleep(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-10-09 20:36:09 +00:00
|
|
|
void nand_sleepnow(void)
|
|
|
|
{
|
2009-10-11 10:10:49 +00:00
|
|
|
nand_power_down();
|
2009-10-09 20:36:09 +00:00
|
|
|
}
|
|
|
|
|
2009-07-17 16:34:34 +00:00
|
|
|
void nand_spin(void)
|
|
|
|
{
|
2009-11-08 14:55:30 +00:00
|
|
|
nand_set_active();
|
2009-07-17 16:34:34 +00:00
|
|
|
}
|
|
|
|
|
2008-11-04 19:36:17 +00:00
|
|
|
void nand_enable(bool on)
|
2008-06-27 23:24:34 +00:00
|
|
|
{
|
2009-07-12 19:36:27 +00:00
|
|
|
(void)on;
|
|
|
|
}
|
|
|
|
|
2013-08-17 16:18:22 +00:00
|
|
|
void nand_get_info(IF_MD(int drive,) struct storage_info *info)
|
2009-07-12 19:36:27 +00:00
|
|
|
{
|
2009-10-17 23:00:49 +00:00
|
|
|
uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
|
2009-10-23 23:50:32 +00:00
|
|
|
(*info).sector_size = SECTOR_SIZE;
|
|
|
|
(*info).num_sectors = (*ftl_nand_type).userblocks * ppb;
|
|
|
|
(*info).vendor = "Apple";
|
|
|
|
(*info).product = "iPod Nano 2G";
|
2009-10-17 23:00:49 +00:00
|
|
|
(*info).revision = "1.0";
|
2009-07-12 19:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long nand_last_disk_activity(void)
|
|
|
|
{
|
2009-11-08 14:55:30 +00:00
|
|
|
return nand_last_activity();
|
2008-06-27 23:24:34 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
int nand_flush(void)
|
|
|
|
{
|
2009-10-12 08:54:51 +00:00
|
|
|
int rc = ftl_sync();
|
|
|
|
if (rc != 0) panicf("Failed to unmount flash: %X", rc);
|
|
|
|
return rc;
|
2009-10-09 20:36:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-04 19:36:17 +00:00
|
|
|
int nand_init(void)
|
2008-06-27 23:24:34 +00:00
|
|
|
{
|
2009-10-04 15:02:40 +00:00
|
|
|
if (ftl_init()) return 1;
|
|
|
|
|
2009-07-12 19:36:27 +00:00
|
|
|
initialized = true;
|
|
|
|
return 0;
|
2008-06-27 23:24:34 +00:00
|
|
|
}
|
2009-07-12 19:36:27 +00:00
|
|
|
|
2009-07-17 22:28:49 +00:00
|
|
|
#ifdef CONFIG_STORAGE_MULTI
|
|
|
|
int nand_num_drives(int first_drive)
|
|
|
|
{
|
|
|
|
/* We don't care which logical drive number(s) we have been assigned */
|
|
|
|
(void)first_drive;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|