summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap/devices-gpmc-nand.c
blob: 64ca66619fa2f1214a4144b1e5839fa5cc65e147 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * @file
 * @brief GPMC specific NAND devices
 *
 * FileName: arch/arm/boards/omap/devices-gpmc-nand.c
 *
 */
/*
 * (C) Copyright 2006-2008
 * Texas Instruments, <www.ti.com>
 * Nishanth Menon <x0nishan@ti.com>
 *
 * 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 <console.h>
#include <init.h>
#include <driver.h>
#include <clock.h>
#include <io.h>

#include <mach/silicon.h>
#include <mach/gpmc.h>
#include <mach/gpmc_nand.h>

#define GPMC_CONF1_VALx8	0x00000800
#define GPMC_CONF1_VALx16	0x00001800

/**
 * @brief gpmc_generic_nand_devices_init - init generic nand device
 *
 * @return success/fail based on device function
 */
int omap_add_gpmc_nand_device(struct gpmc_nand_platform_data *pdata)
{
	if (pdata->device_width == 16)
		pdata->nand_cfg->cfg[0] = GPMC_CONF1_VALx16;
	else
		pdata->nand_cfg->cfg[0] = GPMC_CONF1_VALx8;

	/* Configure GPMC CS before register */
	gpmc_cs_config(pdata->cs, pdata->nand_cfg);

	add_generic_device("gpmc_nand", DEVICE_ID_DYNAMIC, NULL, OMAP_GPMC_BASE,
			1024 * 4, IORESOURCE_MEM, pdata);

	return 0;
}