platform-mxc_nand.c 2.5 KB

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