platform-mxc_nand.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #define imx_mxc_nand_data_entry_single(soc, _size) \
  13. { \
  14. .iobase = soc ## _NFC_BASE_ADDR, \
  15. .iosize = _size, \
  16. .irq = soc ## _INT_NFC \
  17. }
  18. #define imx_mxc_nandv3_data_entry_single(soc, _size) \
  19. { \
  20. .id = -1, \
  21. .iobase = soc ## _NFC_BASE_ADDR, \
  22. .iosize = _size, \
  23. .axibase = soc ## _NFC_AXI_BASE_ADDR, \
  24. .irq = soc ## _INT_NFC \
  25. }
  26. #ifdef CONFIG_SOC_IMX21
  27. const struct imx_mxc_nand_data imx21_mxc_nand_data __initconst =
  28. imx_mxc_nand_data_entry_single(MX21, SZ_4K);
  29. #endif /* ifdef CONFIG_SOC_IMX21 */
  30. #ifdef CONFIG_SOC_IMX25
  31. const struct imx_mxc_nand_data imx25_mxc_nand_data __initconst =
  32. imx_mxc_nand_data_entry_single(MX25, SZ_8K);
  33. #endif /* ifdef CONFIG_SOC_IMX25 */
  34. #ifdef CONFIG_SOC_IMX27
  35. const struct imx_mxc_nand_data imx27_mxc_nand_data __initconst =
  36. imx_mxc_nand_data_entry_single(MX27, SZ_4K);
  37. #endif /* ifdef CONFIG_SOC_IMX27 */
  38. #ifdef CONFIG_SOC_IMX31
  39. const struct imx_mxc_nand_data imx31_mxc_nand_data __initconst =
  40. imx_mxc_nand_data_entry_single(MX31, SZ_4K);
  41. #endif
  42. #ifdef CONFIG_SOC_IMX35
  43. const struct imx_mxc_nand_data imx35_mxc_nand_data __initconst =
  44. imx_mxc_nand_data_entry_single(MX35, SZ_8K);
  45. #endif
  46. #ifdef CONFIG_SOC_IMX51
  47. const struct imx_mxc_nand_data imx51_mxc_nand_data __initconst =
  48. imx_mxc_nandv3_data_entry_single(MX51, SZ_16K);
  49. #endif
  50. struct platform_device *__init imx_add_mxc_nand(
  51. const struct imx_mxc_nand_data *data,
  52. const struct mxc_nand_platform_data *pdata)
  53. {
  54. /* AXI has to come first, that's how the mxc_nand driver expect it */
  55. struct resource res[] = {
  56. {
  57. .start = data->axibase,
  58. .end = data->axibase + SZ_16K - 1,
  59. .flags = IORESOURCE_MEM,
  60. }, {
  61. .start = data->iobase,
  62. .end = data->iobase + data->iosize - 1,
  63. .flags = IORESOURCE_MEM,
  64. }, {
  65. .start = data->irq,
  66. .end = data->irq,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. return imx_add_platform_device("mxc_nand", data->id,
  71. res + !data->axibase,
  72. ARRAY_SIZE(res) - !data->axibase,
  73. pdata, sizeof(*pdata));
  74. }