2008-08-06 11:08:46 +04:00
|
|
|
/*
|
|
|
|
* linux/drivers/mtd/onenand/omap2.c
|
|
|
|
*
|
|
|
|
* OneNAND driver for OMAP2 / OMAP3
|
|
|
|
*
|
|
|
|
* Copyright © 2005-2006 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Author: Jarkko Lavinen <jarkko.lavinen@nokia.com> and Juha Yrjölä
|
|
|
|
* IRQ and DMA support written by Timo Teras
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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; see the file COPYING. If not, write to the Free Software
|
|
|
|
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/mtd/mtd.h>
|
|
|
|
#include <linux/mtd/onenand.h>
|
|
|
|
#include <linux/mtd/partitions.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
2008-11-24 15:44:36 +03:00
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/io.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2010-02-19 17:39:53 +03:00
|
|
|
#include <linux/regulator/consumer.h>
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
#include <asm/mach/flash.h>
|
2009-10-20 20:40:47 +04:00
|
|
|
#include <plat/gpmc.h>
|
|
|
|
#include <plat/onenand.h>
|
2008-11-24 14:37:05 +03:00
|
|
|
#include <mach/gpio.h>
|
2008-08-06 11:08:46 +04:00
|
|
|
|
2009-10-20 20:40:47 +04:00
|
|
|
#include <plat/dma.h>
|
2008-08-06 11:08:46 +04:00
|
|
|
|
2009-10-20 20:40:47 +04:00
|
|
|
#include <plat/board.h>
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
#define DRIVER_NAME "omap2-onenand"
|
|
|
|
|
|
|
|
#define ONENAND_IO_SIZE SZ_128K
|
|
|
|
#define ONENAND_BUFRAM_SIZE (1024 * 5)
|
|
|
|
|
|
|
|
struct omap2_onenand {
|
|
|
|
struct platform_device *pdev;
|
|
|
|
int gpmc_cs;
|
|
|
|
unsigned long phys_base;
|
|
|
|
int gpio_irq;
|
|
|
|
struct mtd_info mtd;
|
|
|
|
struct mtd_partition *parts;
|
|
|
|
struct onenand_chip onenand;
|
|
|
|
struct completion irq_done;
|
|
|
|
struct completion dma_done;
|
|
|
|
int dma_channel;
|
|
|
|
int freq;
|
2011-02-07 11:46:59 +03:00
|
|
|
int (*setup)(void __iomem *base, int *freq_ptr);
|
2010-02-19 17:39:53 +03:00
|
|
|
struct regulator *regulator;
|
2008-08-06 11:08:46 +04:00
|
|
|
};
|
|
|
|
|
2009-12-30 09:40:16 +03:00
|
|
|
static const char *part_probes[] = { "cmdlinepart", NULL, };
|
|
|
|
|
2008-08-06 11:08:46 +04:00
|
|
|
static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = data;
|
|
|
|
|
|
|
|
complete(&c->dma_done);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t omap2_onenand_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = dev_id;
|
|
|
|
|
|
|
|
complete(&c->irq_done);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned short read_reg(struct omap2_onenand *c, int reg)
|
|
|
|
{
|
|
|
|
return readw(c->onenand.base + reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void write_reg(struct omap2_onenand *c, unsigned short value,
|
|
|
|
int reg)
|
|
|
|
{
|
|
|
|
writew(value, c->onenand.base + reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wait_err(char *msg, int state, unsigned int ctrl, unsigned int intr)
|
|
|
|
{
|
|
|
|
printk(KERN_ERR "onenand_wait: %s! state %d ctrl 0x%04x intr 0x%04x\n",
|
|
|
|
msg, state, ctrl, intr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wait_warn(char *msg, int state, unsigned int ctrl,
|
|
|
|
unsigned int intr)
|
|
|
|
{
|
|
|
|
printk(KERN_WARNING "onenand_wait: %s! state %d ctrl 0x%04x "
|
|
|
|
"intr 0x%04x\n", msg, state, ctrl, intr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap2_onenand_wait(struct mtd_info *mtd, int state)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
2010-11-03 13:55:20 +03:00
|
|
|
struct onenand_chip *this = mtd->priv;
|
2008-08-06 11:08:46 +04:00
|
|
|
unsigned int intr = 0;
|
2010-11-03 13:55:20 +03:00
|
|
|
unsigned int ctrl, ctrl_mask;
|
2008-08-06 11:08:46 +04:00
|
|
|
unsigned long timeout;
|
|
|
|
u32 syscfg;
|
|
|
|
|
2009-10-23 09:50:43 +04:00
|
|
|
if (state == FL_RESETING || state == FL_PREPARING_ERASE ||
|
|
|
|
state == FL_VERIFYING_ERASE) {
|
|
|
|
int i = 21;
|
|
|
|
unsigned int intr_flags = ONENAND_INT_MASTER;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case FL_RESETING:
|
|
|
|
intr_flags |= ONENAND_INT_RESET;
|
|
|
|
break;
|
|
|
|
case FL_PREPARING_ERASE:
|
|
|
|
intr_flags |= ONENAND_INT_ERASE;
|
|
|
|
break;
|
|
|
|
case FL_VERIFYING_ERASE:
|
|
|
|
i = 101;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-06 11:08:46 +04:00
|
|
|
|
2009-10-23 09:50:43 +04:00
|
|
|
while (--i) {
|
2008-08-06 11:08:46 +04:00
|
|
|
udelay(1);
|
|
|
|
intr = read_reg(c, ONENAND_REG_INTERRUPT);
|
|
|
|
if (intr & ONENAND_INT_MASTER)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
|
|
|
|
if (ctrl & ONENAND_CTRL_ERROR) {
|
|
|
|
wait_err("controller error", state, ctrl, intr);
|
|
|
|
return -EIO;
|
|
|
|
}
|
2011-02-07 11:47:01 +03:00
|
|
|
if ((intr & intr_flags) == intr_flags)
|
|
|
|
return 0;
|
|
|
|
/* Continue in wait for interrupt branch */
|
2008-08-06 11:08:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state != FL_READING) {
|
|
|
|
int result;
|
|
|
|
|
|
|
|
/* Turn interrupts on */
|
|
|
|
syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
|
2008-08-14 15:00:12 +04:00
|
|
|
if (!(syscfg & ONENAND_SYS_CFG1_IOBE)) {
|
|
|
|
syscfg |= ONENAND_SYS_CFG1_IOBE;
|
|
|
|
write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
|
|
|
|
if (cpu_is_omap34xx())
|
|
|
|
/* Add a delay to let GPIO settle */
|
|
|
|
syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
|
|
|
|
}
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
INIT_COMPLETION(c->irq_done);
|
|
|
|
if (c->gpio_irq) {
|
2008-12-11 04:35:25 +03:00
|
|
|
result = gpio_get_value(c->gpio_irq);
|
2008-08-06 11:08:46 +04:00
|
|
|
if (result == -1) {
|
|
|
|
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
|
|
|
|
intr = read_reg(c, ONENAND_REG_INTERRUPT);
|
|
|
|
wait_err("gpio error", state, ctrl, intr);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
result = 0;
|
|
|
|
if (result == 0) {
|
|
|
|
int retry_cnt = 0;
|
|
|
|
retry:
|
|
|
|
result = wait_for_completion_timeout(&c->irq_done,
|
|
|
|
msecs_to_jiffies(20));
|
|
|
|
if (result == 0) {
|
|
|
|
/* Timeout after 20ms */
|
|
|
|
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
|
2010-11-03 13:55:20 +03:00
|
|
|
if (ctrl & ONENAND_CTRL_ONGO &&
|
|
|
|
!this->ongoing) {
|
2008-08-06 11:08:46 +04:00
|
|
|
/*
|
|
|
|
* The operation seems to be still going
|
|
|
|
* so give it some more time.
|
|
|
|
*/
|
|
|
|
retry_cnt += 1;
|
|
|
|
if (retry_cnt < 3)
|
|
|
|
goto retry;
|
|
|
|
intr = read_reg(c,
|
|
|
|
ONENAND_REG_INTERRUPT);
|
|
|
|
wait_err("timeout", state, ctrl, intr);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
intr = read_reg(c, ONENAND_REG_INTERRUPT);
|
|
|
|
if ((intr & ONENAND_INT_MASTER) == 0)
|
|
|
|
wait_warn("timeout", state, ctrl, intr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2008-08-25 13:01:31 +04:00
|
|
|
int retry_cnt = 0;
|
|
|
|
|
2008-08-06 11:08:46 +04:00
|
|
|
/* Turn interrupts off */
|
|
|
|
syscfg = read_reg(c, ONENAND_REG_SYS_CFG1);
|
|
|
|
syscfg &= ~ONENAND_SYS_CFG1_IOBE;
|
|
|
|
write_reg(c, syscfg, ONENAND_REG_SYS_CFG1);
|
|
|
|
|
|
|
|
timeout = jiffies + msecs_to_jiffies(20);
|
2008-08-25 13:01:31 +04:00
|
|
|
while (1) {
|
|
|
|
if (time_before(jiffies, timeout)) {
|
|
|
|
intr = read_reg(c, ONENAND_REG_INTERRUPT);
|
|
|
|
if (intr & ONENAND_INT_MASTER)
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/* Timeout after 20ms */
|
|
|
|
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
|
|
|
|
if (ctrl & ONENAND_CTRL_ONGO) {
|
|
|
|
/*
|
|
|
|
* The operation seems to be still going
|
|
|
|
* so give it some more time.
|
|
|
|
*/
|
|
|
|
retry_cnt += 1;
|
|
|
|
if (retry_cnt < 3) {
|
|
|
|
timeout = jiffies +
|
|
|
|
msecs_to_jiffies(20);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2008-08-06 11:08:46 +04:00
|
|
|
break;
|
2008-08-25 13:01:31 +04:00
|
|
|
}
|
2008-08-06 11:08:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
intr = read_reg(c, ONENAND_REG_INTERRUPT);
|
|
|
|
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
|
|
|
|
|
|
|
|
if (intr & ONENAND_INT_READ) {
|
|
|
|
int ecc = read_reg(c, ONENAND_REG_ECC_STATUS);
|
|
|
|
|
|
|
|
if (ecc) {
|
|
|
|
unsigned int addr1, addr8;
|
|
|
|
|
|
|
|
addr1 = read_reg(c, ONENAND_REG_START_ADDRESS1);
|
|
|
|
addr8 = read_reg(c, ONENAND_REG_START_ADDRESS8);
|
|
|
|
if (ecc & ONENAND_ECC_2BIT_ALL) {
|
|
|
|
printk(KERN_ERR "onenand_wait: ECC error = "
|
|
|
|
"0x%04x, addr1 %#x, addr8 %#x\n",
|
|
|
|
ecc, addr1, addr8);
|
|
|
|
mtd->ecc_stats.failed++;
|
|
|
|
return -EBADMSG;
|
|
|
|
} else if (ecc & ONENAND_ECC_1BIT_ALL) {
|
|
|
|
printk(KERN_NOTICE "onenand_wait: correctable "
|
|
|
|
"ECC error = 0x%04x, addr1 %#x, "
|
|
|
|
"addr8 %#x\n", ecc, addr1, addr8);
|
|
|
|
mtd->ecc_stats.corrected++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (state == FL_READING) {
|
|
|
|
wait_err("timeout", state, ctrl, intr);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctrl & ONENAND_CTRL_ERROR) {
|
|
|
|
wait_err("controller error", state, ctrl, intr);
|
|
|
|
if (ctrl & ONENAND_CTRL_LOCK)
|
|
|
|
printk(KERN_ERR "onenand_wait: "
|
|
|
|
"Device is write protected!!!\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2010-11-03 13:55:20 +03:00
|
|
|
ctrl_mask = 0xFE9F;
|
|
|
|
if (this->ongoing)
|
|
|
|
ctrl_mask &= ~0x8000;
|
|
|
|
|
|
|
|
if (ctrl & ctrl_mask)
|
2008-08-06 11:08:46 +04:00
|
|
|
wait_warn("unexpected controller status", state, ctrl, intr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int omap2_onenand_bufferram_offset(struct mtd_info *mtd, int area)
|
|
|
|
{
|
|
|
|
struct onenand_chip *this = mtd->priv;
|
|
|
|
|
|
|
|
if (ONENAND_CURRENT_BUFFERRAM(this)) {
|
|
|
|
if (area == ONENAND_DATARAM)
|
2009-06-11 15:05:07 +04:00
|
|
|
return this->writesize;
|
2008-08-06 11:08:46 +04:00
|
|
|
if (area == ONENAND_SPARERAM)
|
|
|
|
return mtd->oobsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_OMAP3) || defined(MULTI_OMAP2)
|
|
|
|
|
|
|
|
static int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
unsigned char *buffer, int offset,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
struct onenand_chip *this = mtd->priv;
|
|
|
|
dma_addr_t dma_src, dma_dst;
|
|
|
|
int bram_offset;
|
|
|
|
unsigned long timeout;
|
|
|
|
void *buf = (void *)buffer;
|
|
|
|
size_t xtra;
|
|
|
|
volatile unsigned *done;
|
|
|
|
|
|
|
|
bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
|
|
|
|
if (bram_offset & 3 || (size_t)buf & 3 || count < 384)
|
|
|
|
goto out_copy;
|
|
|
|
|
2009-03-23 15:57:38 +03:00
|
|
|
/* panic_write() may be in an interrupt context */
|
2010-02-10 20:03:19 +03:00
|
|
|
if (in_interrupt() || oops_in_progress)
|
2009-03-23 15:57:38 +03:00
|
|
|
goto out_copy;
|
|
|
|
|
2008-08-06 11:08:46 +04:00
|
|
|
if (buf >= high_memory) {
|
|
|
|
struct page *p1;
|
|
|
|
|
|
|
|
if (((size_t)buf & PAGE_MASK) !=
|
|
|
|
((size_t)(buf + count - 1) & PAGE_MASK))
|
|
|
|
goto out_copy;
|
|
|
|
p1 = vmalloc_to_page(buf);
|
|
|
|
if (!p1)
|
|
|
|
goto out_copy;
|
|
|
|
buf = page_address(p1) + ((size_t)buf & ~PAGE_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
xtra = count & 3;
|
|
|
|
if (xtra) {
|
|
|
|
count -= xtra;
|
|
|
|
memcpy(buf + count, this->base + bram_offset + count, xtra);
|
|
|
|
}
|
|
|
|
|
|
|
|
dma_src = c->phys_base + bram_offset;
|
|
|
|
dma_dst = dma_map_single(&c->pdev->dev, buf, count, DMA_FROM_DEVICE);
|
|
|
|
if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
|
|
|
|
dev_err(&c->pdev->dev,
|
|
|
|
"Couldn't DMA map a %d byte buffer\n",
|
|
|
|
count);
|
|
|
|
goto out_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
|
|
|
|
count >> 2, 1, 0, 0, 0);
|
|
|
|
omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_src, 0, 0);
|
|
|
|
omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_dst, 0, 0);
|
|
|
|
|
|
|
|
INIT_COMPLETION(c->dma_done);
|
|
|
|
omap_start_dma(c->dma_channel);
|
|
|
|
|
|
|
|
timeout = jiffies + msecs_to_jiffies(20);
|
|
|
|
done = &c->dma_done.done;
|
|
|
|
while (time_before(jiffies, timeout))
|
|
|
|
if (*done)
|
|
|
|
break;
|
|
|
|
|
|
|
|
dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_FROM_DEVICE);
|
|
|
|
|
|
|
|
if (!*done) {
|
|
|
|
dev_err(&c->pdev->dev, "timeout waiting for DMA\n");
|
|
|
|
goto out_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_copy:
|
|
|
|
memcpy(buf, this->base + bram_offset, count);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
const unsigned char *buffer,
|
|
|
|
int offset, size_t count)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
struct onenand_chip *this = mtd->priv;
|
|
|
|
dma_addr_t dma_src, dma_dst;
|
|
|
|
int bram_offset;
|
|
|
|
unsigned long timeout;
|
|
|
|
void *buf = (void *)buffer;
|
|
|
|
volatile unsigned *done;
|
|
|
|
|
|
|
|
bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
|
|
|
|
if (bram_offset & 3 || (size_t)buf & 3 || count < 384)
|
|
|
|
goto out_copy;
|
|
|
|
|
|
|
|
/* panic_write() may be in an interrupt context */
|
2010-02-10 20:03:19 +03:00
|
|
|
if (in_interrupt() || oops_in_progress)
|
2008-08-06 11:08:46 +04:00
|
|
|
goto out_copy;
|
|
|
|
|
|
|
|
if (buf >= high_memory) {
|
|
|
|
struct page *p1;
|
|
|
|
|
|
|
|
if (((size_t)buf & PAGE_MASK) !=
|
|
|
|
((size_t)(buf + count - 1) & PAGE_MASK))
|
|
|
|
goto out_copy;
|
|
|
|
p1 = vmalloc_to_page(buf);
|
|
|
|
if (!p1)
|
|
|
|
goto out_copy;
|
|
|
|
buf = page_address(p1) + ((size_t)buf & ~PAGE_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
dma_src = dma_map_single(&c->pdev->dev, buf, count, DMA_TO_DEVICE);
|
|
|
|
dma_dst = c->phys_base + bram_offset;
|
2010-03-24 13:10:48 +03:00
|
|
|
if (dma_mapping_error(&c->pdev->dev, dma_src)) {
|
2008-08-06 11:08:46 +04:00
|
|
|
dev_err(&c->pdev->dev,
|
|
|
|
"Couldn't DMA map a %d byte buffer\n",
|
|
|
|
count);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
|
|
|
|
count >> 2, 1, 0, 0, 0);
|
|
|
|
omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_src, 0, 0);
|
|
|
|
omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_dst, 0, 0);
|
|
|
|
|
|
|
|
INIT_COMPLETION(c->dma_done);
|
|
|
|
omap_start_dma(c->dma_channel);
|
|
|
|
|
|
|
|
timeout = jiffies + msecs_to_jiffies(20);
|
|
|
|
done = &c->dma_done.done;
|
|
|
|
while (time_before(jiffies, timeout))
|
|
|
|
if (*done)
|
|
|
|
break;
|
|
|
|
|
2010-03-24 13:10:48 +03:00
|
|
|
dma_unmap_single(&c->pdev->dev, dma_src, count, DMA_TO_DEVICE);
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
if (!*done) {
|
|
|
|
dev_err(&c->pdev->dev, "timeout waiting for DMA\n");
|
|
|
|
goto out_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_copy:
|
|
|
|
memcpy(this->base + bram_offset, buf, count);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
int omap3_onenand_read_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
unsigned char *buffer, int offset,
|
|
|
|
size_t count);
|
|
|
|
|
|
|
|
int omap3_onenand_write_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
const unsigned char *buffer,
|
|
|
|
int offset, size_t count);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_OMAP2) || defined(MULTI_OMAP2)
|
|
|
|
|
|
|
|
static int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
unsigned char *buffer, int offset,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
struct onenand_chip *this = mtd->priv;
|
|
|
|
dma_addr_t dma_src, dma_dst;
|
|
|
|
int bram_offset;
|
|
|
|
|
|
|
|
bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
|
|
|
|
/* DMA is not used. Revisit PM requirements before enabling it. */
|
|
|
|
if (1 || (c->dma_channel < 0) ||
|
|
|
|
((void *) buffer >= (void *) high_memory) || (bram_offset & 3) ||
|
|
|
|
(((unsigned int) buffer) & 3) || (count < 1024) || (count & 3)) {
|
|
|
|
memcpy(buffer, (__force void *)(this->base + bram_offset),
|
|
|
|
count);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
dma_src = c->phys_base + bram_offset;
|
|
|
|
dma_dst = dma_map_single(&c->pdev->dev, buffer, count,
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
if (dma_mapping_error(&c->pdev->dev, dma_dst)) {
|
|
|
|
dev_err(&c->pdev->dev,
|
|
|
|
"Couldn't DMA map a %d byte buffer\n",
|
|
|
|
count);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S32,
|
|
|
|
count / 4, 1, 0, 0, 0);
|
|
|
|
omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_src, 0, 0);
|
|
|
|
omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_dst, 0, 0);
|
|
|
|
|
|
|
|
INIT_COMPLETION(c->dma_done);
|
|
|
|
omap_start_dma(c->dma_channel);
|
|
|
|
wait_for_completion(&c->dma_done);
|
|
|
|
|
|
|
|
dma_unmap_single(&c->pdev->dev, dma_dst, count, DMA_FROM_DEVICE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
const unsigned char *buffer,
|
|
|
|
int offset, size_t count)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
struct onenand_chip *this = mtd->priv;
|
|
|
|
dma_addr_t dma_src, dma_dst;
|
|
|
|
int bram_offset;
|
|
|
|
|
|
|
|
bram_offset = omap2_onenand_bufferram_offset(mtd, area) + area + offset;
|
|
|
|
/* DMA is not used. Revisit PM requirements before enabling it. */
|
|
|
|
if (1 || (c->dma_channel < 0) ||
|
|
|
|
((void *) buffer >= (void *) high_memory) || (bram_offset & 3) ||
|
|
|
|
(((unsigned int) buffer) & 3) || (count < 1024) || (count & 3)) {
|
|
|
|
memcpy((__force void *)(this->base + bram_offset), buffer,
|
|
|
|
count);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
dma_src = dma_map_single(&c->pdev->dev, (void *) buffer, count,
|
|
|
|
DMA_TO_DEVICE);
|
|
|
|
dma_dst = c->phys_base + bram_offset;
|
2010-03-24 13:10:48 +03:00
|
|
|
if (dma_mapping_error(&c->pdev->dev, dma_src)) {
|
2008-08-06 11:08:46 +04:00
|
|
|
dev_err(&c->pdev->dev,
|
|
|
|
"Couldn't DMA map a %d byte buffer\n",
|
|
|
|
count);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
omap_set_dma_transfer_params(c->dma_channel, OMAP_DMA_DATA_TYPE_S16,
|
|
|
|
count / 2, 1, 0, 0, 0);
|
|
|
|
omap_set_dma_src_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_src, 0, 0);
|
|
|
|
omap_set_dma_dest_params(c->dma_channel, 0, OMAP_DMA_AMODE_POST_INC,
|
|
|
|
dma_dst, 0, 0);
|
|
|
|
|
|
|
|
INIT_COMPLETION(c->dma_done);
|
|
|
|
omap_start_dma(c->dma_channel);
|
|
|
|
wait_for_completion(&c->dma_done);
|
|
|
|
|
2010-03-24 13:10:48 +03:00
|
|
|
dma_unmap_single(&c->pdev->dev, dma_src, count, DMA_TO_DEVICE);
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
int omap2_onenand_read_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
unsigned char *buffer, int offset,
|
|
|
|
size_t count);
|
|
|
|
|
|
|
|
int omap2_onenand_write_bufferram(struct mtd_info *mtd, int area,
|
|
|
|
const unsigned char *buffer,
|
|
|
|
int offset, size_t count);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct platform_driver omap2_onenand_driver;
|
|
|
|
|
|
|
|
static int __adjust_timing(struct device *dev, void *data)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct omap2_onenand *c;
|
|
|
|
|
|
|
|
c = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
BUG_ON(c->setup == NULL);
|
|
|
|
|
|
|
|
/* DMA is not in use so this is all that is needed */
|
|
|
|
/* Revisit for OMAP3! */
|
2011-02-07 11:46:59 +03:00
|
|
|
ret = c->setup(c->onenand.base, &c->freq);
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int omap2_onenand_rephase(void)
|
|
|
|
{
|
|
|
|
return driver_for_each_device(&omap2_onenand_driver.driver, NULL,
|
|
|
|
NULL, __adjust_timing);
|
|
|
|
}
|
|
|
|
|
2009-05-22 00:09:42 +04:00
|
|
|
static void omap2_onenand_shutdown(struct platform_device *pdev)
|
2008-08-06 11:08:46 +04:00
|
|
|
{
|
|
|
|
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
|
|
/* With certain content in the buffer RAM, the OMAP boot ROM code
|
|
|
|
* can recognize the flash chip incorrectly. Zero it out before
|
|
|
|
* soft reset.
|
|
|
|
*/
|
|
|
|
memset((__force void *)c->onenand.base, 0, ONENAND_BUFRAM_SIZE);
|
|
|
|
}
|
|
|
|
|
2010-02-19 17:39:53 +03:00
|
|
|
static int omap2_onenand_enable(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
|
|
|
|
ret = regulator_enable(c->regulator);
|
|
|
|
if (ret != 0)
|
2011-03-31 05:57:33 +04:00
|
|
|
dev_err(&c->pdev->dev, "can't enable regulator\n");
|
2010-02-19 17:39:53 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int omap2_onenand_disable(struct mtd_info *mtd)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd);
|
|
|
|
|
|
|
|
ret = regulator_disable(c->regulator);
|
|
|
|
if (ret != 0)
|
2011-03-31 05:57:33 +04:00
|
|
|
dev_err(&c->pdev->dev, "can't disable regulator\n");
|
2010-02-19 17:39:53 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-08-06 11:08:46 +04:00
|
|
|
static int __devinit omap2_onenand_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct omap_onenand_platform_data *pdata;
|
|
|
|
struct omap2_onenand *c;
|
2011-02-17 14:44:42 +03:00
|
|
|
struct onenand_chip *this;
|
2008-08-06 11:08:46 +04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
pdata = pdev->dev.platform_data;
|
|
|
|
if (pdata == NULL) {
|
|
|
|
dev_err(&pdev->dev, "platform data missing\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
c = kzalloc(sizeof(struct omap2_onenand), GFP_KERNEL);
|
|
|
|
if (!c)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
init_completion(&c->irq_done);
|
|
|
|
init_completion(&c->dma_done);
|
|
|
|
c->gpmc_cs = pdata->cs;
|
|
|
|
c->gpio_irq = pdata->gpio_irq;
|
|
|
|
c->dma_channel = pdata->dma_channel;
|
|
|
|
if (c->dma_channel < 0) {
|
|
|
|
/* if -1, don't use DMA */
|
|
|
|
c->gpio_irq = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = gpmc_cs_request(c->gpmc_cs, ONENAND_IO_SIZE, &c->phys_base);
|
|
|
|
if (r < 0) {
|
|
|
|
dev_err(&pdev->dev, "Cannot request GPMC CS\n");
|
|
|
|
goto err_kfree;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (request_mem_region(c->phys_base, ONENAND_IO_SIZE,
|
|
|
|
pdev->dev.driver->name) == NULL) {
|
|
|
|
dev_err(&pdev->dev, "Cannot reserve memory region at 0x%08lx, "
|
|
|
|
"size: 0x%x\n", c->phys_base, ONENAND_IO_SIZE);
|
|
|
|
r = -EBUSY;
|
|
|
|
goto err_free_cs;
|
|
|
|
}
|
|
|
|
c->onenand.base = ioremap(c->phys_base, ONENAND_IO_SIZE);
|
|
|
|
if (c->onenand.base == NULL) {
|
|
|
|
r = -ENOMEM;
|
|
|
|
goto err_release_mem_region;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pdata->onenand_setup != NULL) {
|
2011-02-07 11:46:59 +03:00
|
|
|
r = pdata->onenand_setup(c->onenand.base, &c->freq);
|
2008-08-06 11:08:46 +04:00
|
|
|
if (r < 0) {
|
|
|
|
dev_err(&pdev->dev, "Onenand platform setup failed: "
|
|
|
|
"%d\n", r);
|
|
|
|
goto err_iounmap;
|
|
|
|
}
|
|
|
|
c->setup = pdata->onenand_setup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c->gpio_irq) {
|
2009-01-15 14:09:52 +03:00
|
|
|
if ((r = gpio_request(c->gpio_irq, "OneNAND irq")) < 0) {
|
2008-08-06 11:08:46 +04:00
|
|
|
dev_err(&pdev->dev, "Failed to request GPIO%d for "
|
|
|
|
"OneNAND\n", c->gpio_irq);
|
|
|
|
goto err_iounmap;
|
|
|
|
}
|
2008-12-11 04:35:26 +03:00
|
|
|
gpio_direction_input(c->gpio_irq);
|
2008-08-06 11:08:46 +04:00
|
|
|
|
2008-12-11 04:35:26 +03:00
|
|
|
if ((r = request_irq(gpio_to_irq(c->gpio_irq),
|
2008-08-06 11:08:46 +04:00
|
|
|
omap2_onenand_interrupt, IRQF_TRIGGER_RISING,
|
|
|
|
pdev->dev.driver->name, c)) < 0)
|
|
|
|
goto err_release_gpio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c->dma_channel >= 0) {
|
|
|
|
r = omap_request_dma(0, pdev->dev.driver->name,
|
|
|
|
omap2_onenand_dma_cb, (void *) c,
|
|
|
|
&c->dma_channel);
|
|
|
|
if (r == 0) {
|
|
|
|
omap_set_dma_write_mode(c->dma_channel,
|
|
|
|
OMAP_DMA_WRITE_NON_POSTED);
|
|
|
|
omap_set_dma_src_data_pack(c->dma_channel, 1);
|
|
|
|
omap_set_dma_src_burst_mode(c->dma_channel,
|
|
|
|
OMAP_DMA_DATA_BURST_8);
|
|
|
|
omap_set_dma_dest_data_pack(c->dma_channel, 1);
|
|
|
|
omap_set_dma_dest_burst_mode(c->dma_channel,
|
|
|
|
OMAP_DMA_DATA_BURST_8);
|
|
|
|
} else {
|
|
|
|
dev_info(&pdev->dev,
|
|
|
|
"failed to allocate DMA for OneNAND, "
|
|
|
|
"using PIO instead\n");
|
|
|
|
c->dma_channel = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual "
|
2011-02-07 11:46:59 +03:00
|
|
|
"base %p, freq %d MHz\n", c->gpmc_cs, c->phys_base,
|
|
|
|
c->onenand.base, c->freq);
|
2008-08-06 11:08:46 +04:00
|
|
|
|
|
|
|
c->pdev = pdev;
|
2009-01-06 21:44:38 +03:00
|
|
|
c->mtd.name = dev_name(&pdev->dev);
|
2008-08-06 11:08:46 +04:00
|
|
|
c->mtd.priv = &c->onenand;
|
|
|
|
c->mtd.owner = THIS_MODULE;
|
|
|
|
|
2009-03-26 10:42:50 +03:00
|
|
|
c->mtd.dev.parent = &pdev->dev;
|
|
|
|
|
2011-02-17 14:44:42 +03:00
|
|
|
this = &c->onenand;
|
2008-08-06 11:08:46 +04:00
|
|
|
if (c->dma_channel >= 0) {
|
|
|
|
this->wait = omap2_onenand_wait;
|
|
|
|
if (cpu_is_omap34xx()) {
|
|
|
|
this->read_bufferram = omap3_onenand_read_bufferram;
|
|
|
|
this->write_bufferram = omap3_onenand_write_bufferram;
|
|
|
|
} else {
|
|
|
|
this->read_bufferram = omap2_onenand_read_bufferram;
|
|
|
|
this->write_bufferram = omap2_onenand_write_bufferram;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-19 17:39:53 +03:00
|
|
|
if (pdata->regulator_can_sleep) {
|
|
|
|
c->regulator = regulator_get(&pdev->dev, "vonenand");
|
|
|
|
if (IS_ERR(c->regulator)) {
|
|
|
|
dev_err(&pdev->dev, "Failed to get regulator\n");
|
|
|
|
goto err_release_dma;
|
|
|
|
}
|
|
|
|
c->onenand.enable = omap2_onenand_enable;
|
|
|
|
c->onenand.disable = omap2_onenand_disable;
|
|
|
|
}
|
|
|
|
|
2011-02-17 14:44:42 +03:00
|
|
|
if (pdata->skip_initial_unlocking)
|
|
|
|
this->options |= ONENAND_SKIP_INITIAL_UNLOCKING;
|
|
|
|
|
2008-08-06 11:08:46 +04:00
|
|
|
if ((r = onenand_scan(&c->mtd, 1)) < 0)
|
2010-02-19 17:39:53 +03:00
|
|
|
goto err_release_regulator;
|
2008-08-06 11:08:46 +04:00
|
|
|
|
2009-12-30 09:40:16 +03:00
|
|
|
r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0);
|
|
|
|
if (r > 0)
|
2011-05-23 13:23:38 +04:00
|
|
|
r = mtd_device_register(&c->mtd, c->parts, r);
|
2009-12-30 09:40:16 +03:00
|
|
|
else if (pdata->parts != NULL)
|
2011-05-23 13:23:38 +04:00
|
|
|
r = mtd_device_register(&c->mtd, pdata->parts, pdata->nr_parts);
|
2008-08-06 11:08:46 +04:00
|
|
|
else
|
2011-05-23 13:23:38 +04:00
|
|
|
r = mtd_device_register(&c->mtd, NULL, 0);
|
2009-12-30 09:40:16 +03:00
|
|
|
if (r)
|
2008-08-06 11:08:46 +04:00
|
|
|
goto err_release_onenand;
|
|
|
|
|
|
|
|
platform_set_drvdata(pdev, c);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_release_onenand:
|
|
|
|
onenand_release(&c->mtd);
|
2010-02-19 17:39:53 +03:00
|
|
|
err_release_regulator:
|
|
|
|
regulator_put(c->regulator);
|
2008-08-06 11:08:46 +04:00
|
|
|
err_release_dma:
|
|
|
|
if (c->dma_channel != -1)
|
|
|
|
omap_free_dma(c->dma_channel);
|
|
|
|
if (c->gpio_irq)
|
2008-12-11 04:35:26 +03:00
|
|
|
free_irq(gpio_to_irq(c->gpio_irq), c);
|
2008-08-06 11:08:46 +04:00
|
|
|
err_release_gpio:
|
|
|
|
if (c->gpio_irq)
|
2009-01-15 14:09:52 +03:00
|
|
|
gpio_free(c->gpio_irq);
|
2008-08-06 11:08:46 +04:00
|
|
|
err_iounmap:
|
|
|
|
iounmap(c->onenand.base);
|
|
|
|
err_release_mem_region:
|
|
|
|
release_mem_region(c->phys_base, ONENAND_IO_SIZE);
|
|
|
|
err_free_cs:
|
|
|
|
gpmc_cs_free(c->gpmc_cs);
|
|
|
|
err_kfree:
|
2009-12-30 09:40:16 +03:00
|
|
|
kfree(c->parts);
|
2008-08-06 11:08:46 +04:00
|
|
|
kfree(c);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __devexit omap2_onenand_remove(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct omap2_onenand *c = dev_get_drvdata(&pdev->dev);
|
|
|
|
|
|
|
|
onenand_release(&c->mtd);
|
2010-02-19 17:39:53 +03:00
|
|
|
regulator_put(c->regulator);
|
2008-08-06 11:08:46 +04:00
|
|
|
if (c->dma_channel != -1)
|
|
|
|
omap_free_dma(c->dma_channel);
|
|
|
|
omap2_onenand_shutdown(pdev);
|
|
|
|
platform_set_drvdata(pdev, NULL);
|
|
|
|
if (c->gpio_irq) {
|
2008-12-11 04:35:26 +03:00
|
|
|
free_irq(gpio_to_irq(c->gpio_irq), c);
|
2009-01-15 14:09:52 +03:00
|
|
|
gpio_free(c->gpio_irq);
|
2008-08-06 11:08:46 +04:00
|
|
|
}
|
|
|
|
iounmap(c->onenand.base);
|
|
|
|
release_mem_region(c->phys_base, ONENAND_IO_SIZE);
|
2009-06-25 16:32:19 +04:00
|
|
|
gpmc_cs_free(c->gpmc_cs);
|
2009-12-30 09:40:16 +03:00
|
|
|
kfree(c->parts);
|
2008-08-06 11:08:46 +04:00
|
|
|
kfree(c);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver omap2_onenand_driver = {
|
|
|
|
.probe = omap2_onenand_probe,
|
2009-05-22 00:09:42 +04:00
|
|
|
.remove = __devexit_p(omap2_onenand_remove),
|
2008-08-06 11:08:46 +04:00
|
|
|
.shutdown = omap2_onenand_shutdown,
|
|
|
|
.driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init omap2_onenand_init(void)
|
|
|
|
{
|
|
|
|
printk(KERN_INFO "OneNAND driver initializing\n");
|
|
|
|
return platform_driver_register(&omap2_onenand_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit omap2_onenand_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&omap2_onenand_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(omap2_onenand_init);
|
|
|
|
module_exit(omap2_onenand_exit);
|
|
|
|
|
2011-03-07 06:04:24 +03:00
|
|
|
MODULE_ALIAS("platform:" DRIVER_NAME);
|
2008-08-06 11:08:46 +04:00
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_AUTHOR("Jarkko Lavinen <jarkko.lavinen@nokia.com>");
|
|
|
|
MODULE_DESCRIPTION("Glue layer for OneNAND flash on OMAP2 / OMAP3");
|