linux/arch/arm/plat-mxc/devices/platform-mxc_nand.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2009-2010 Pengutronix
   3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
   4 *
   5 * This program is free software; you can redistribute it and/or modify it under
   6 * the terms of the GNU General Public License version 2 as published by the
   7 * Free Software Foundation.
   8 */
   9#include <asm/sizes.h>
  10#include <mach/hardware.h>
  11#include <mach/devices-common.h>
  12
  13#define imx_mxc_nand_data_entry_single(soc, _size)                      \
  14        {                                                               \
  15                .iobase = soc ## _NFC_BASE_ADDR,                        \
  16                .iosize = _size,                                        \
  17                .irq = soc ## _INT_NFC                                  \
  18        }
  19
  20#define imx_mxc_nandv3_data_entry_single(soc, _size)                    \
  21        {                                                               \
  22                .id = -1,                                               \
  23                .iobase = soc ## _NFC_BASE_ADDR,                        \
  24                .iosize = _size,                                        \
  25                .axibase = soc ## _NFC_AXI_BASE_ADDR,                   \
  26                .irq = soc ## _INT_NFC                                  \
  27        }
  28
  29#ifdef CONFIG_SOC_IMX21
  30const struct imx_mxc_nand_data imx21_mxc_nand_data __initconst =
  31        imx_mxc_nand_data_entry_single(MX21, SZ_4K);
  32#endif /* ifdef CONFIG_SOC_IMX21 */
  33
  34#ifdef CONFIG_SOC_IMX25
  35const struct imx_mxc_nand_data imx25_mxc_nand_data __initconst =
  36        imx_mxc_nand_data_entry_single(MX25, SZ_8K);
  37#endif /* ifdef CONFIG_SOC_IMX25 */
  38
  39#ifdef CONFIG_SOC_IMX27
  40const struct imx_mxc_nand_data imx27_mxc_nand_data __initconst =
  41        imx_mxc_nand_data_entry_single(MX27, SZ_4K);
  42#endif /* ifdef CONFIG_SOC_IMX27 */
  43
  44#ifdef CONFIG_SOC_IMX31
  45const struct imx_mxc_nand_data imx31_mxc_nand_data __initconst =
  46        imx_mxc_nand_data_entry_single(MX31, SZ_4K);
  47#endif
  48
  49#ifdef CONFIG_SOC_IMX35
  50const struct imx_mxc_nand_data imx35_mxc_nand_data __initconst =
  51        imx_mxc_nand_data_entry_single(MX35, SZ_8K);
  52#endif
  53
  54#ifdef CONFIG_SOC_IMX51
  55const struct imx_mxc_nand_data imx51_mxc_nand_data __initconst =
  56        imx_mxc_nandv3_data_entry_single(MX51, SZ_16K);
  57#endif
  58
  59struct platform_device *__init imx_add_mxc_nand(
  60                const struct imx_mxc_nand_data *data,
  61                const struct mxc_nand_platform_data *pdata)
  62{
  63        /* AXI has to come first, that's how the mxc_nand driver expect it */
  64        struct resource res[] = {
  65                {
  66                        .start = data->axibase,
  67                        .end = data->axibase + SZ_16K - 1,
  68                        .flags = IORESOURCE_MEM,
  69                }, {
  70                        .start = data->iobase,
  71                        .end = data->iobase + data->iosize - 1,
  72                        .flags = IORESOURCE_MEM,
  73                }, {
  74                        .start = data->irq,
  75                        .end = data->irq,
  76                        .flags = IORESOURCE_IRQ,
  77                },
  78        };
  79        return imx_add_platform_device("mxc_nand", data->id,
  80                        res + !data->axibase,
  81                        ARRAY_SIZE(res) - !data->axibase,
  82                        pdata, sizeof(*pdata));
  83}
  84