Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
208 theseven 1
/***************************************************************************
2
 *             __________               __   ___.
3
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
4
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
5
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
6
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
7
 *                     \/            \/     \/    \/            \/
8
 * $Id$
9
 *
10
 * Copyright (C) 2007 Dave Chapman
11
 *
12
 * This program is free software; you can redistribute it and/or
13
 * modify it under the terms of the GNU General Public License
14
 * as published by the Free Software Foundation; either version 2
15
 * of the License, or (at your option) any later version.
16
 *
17
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18
 * KIND, either express or implied.
19
 *
20
 ****************************************************************************/
21
#include "global.h"
22
#include "thread.h"
23
#include "disk.h"
24
#include "storage.h"
25
#include "panic.h"
26
#include "ftl.h"
27
#include "nand.h"
28
 
29
/** static, private data **/ 
30
static bool initialized = false;
31
 
32
/* API Functions */
33
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
34
                     void* inbuf)
35
{
36
    return ftl_read(start, incount, inbuf);
37
}
38
 
39
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
40
                      const void* outbuf)
41
{
42
    return ftl_write(start, count, outbuf);
43
}
44
 
45
void nand_spindown(int seconds)
46
{
47
    (void)seconds;
48
}
49
 
50
void nand_sleep(void)
51
{
52
    nand_power_down();
53
}
54
 
55
void nand_sleepnow(void)
56
{
57
    nand_power_down();
58
}
59
 
60
void nand_spin(void)
61
{
62
    nand_set_active();
63
}
64
 
65
void nand_enable(bool on)
66
{
67
    (void)on;
68
}
69
 
70
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
71
{
72
    uint32_t ppb = ftl_banks * (*ftl_nand_type).pagesperblock;
73
    (*info).sector_size = SECTOR_SIZE;
74
    (*info).num_sectors = (*ftl_nand_type).userblocks * ppb;
75
    (*info).vendor = "Apple";
76
    (*info).product = "iPod Nano 2G";
77
    (*info).revision = "1.0";
78
}
79
 
80
long nand_last_disk_activity(void)
81
{
82
    return nand_last_activity();
83
}
84
 
85
#ifdef HAVE_STORAGE_FLUSH
86
int nand_flush(void)
87
{
88
    int rc = ftl_sync();
89
    if (rc != 0) panicf(PANIC_KILLUSERTHREADS, "Failed to unmount flash: %X", rc);
90
    return rc;
91
}
92
#endif
93
 
94
int nand_init(void)
95
{
96
    if (ftl_init()) return 1;
97
 
98
    initialized = true;
99
    return 0;
100
}
101
 
102
#ifdef CONFIG_STORAGE_MULTI
103
int nand_num_drives(int first_drive)
104
{
105
    /* We don't care which logical drive number(s) we have been assigned */
106
    (void)first_drive;
107
 
108
    return 1;
109
}
110
#endif