board-autcpu12.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * linux/arch/arm/mach-clps711x/autcpu12.c
  3. *
  4. * (c) 2001 Thomas Gleixner, autronix automation <gleixner@autronix.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/types.h>
  23. #include <linux/string.h>
  24. #include <linux/mm.h>
  25. #include <linux/io.h>
  26. #include <linux/gpio.h>
  27. #include <linux/ioport.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/mtd/partitions.h>
  30. #include <linux/mtd/nand-gpio.h>
  31. #include <linux/platform_device.h>
  32. #include <linux/basic_mmio_gpio.h>
  33. #include <mach/hardware.h>
  34. #include <asm/sizes.h>
  35. #include <asm/setup.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/mach/arch.h>
  38. #include <asm/pgtable.h>
  39. #include <asm/page.h>
  40. #include <asm/mach/map.h>
  41. #include <mach/autcpu12.h>
  42. #include "common.h"
  43. #define AUTCPU12_CS8900_BASE (CS2_PHYS_BASE + 0x300)
  44. #define AUTCPU12_CS8900_IRQ (IRQ_EINT3)
  45. #define AUTCPU12_SMC_BASE (CS1_PHYS_BASE + 0x06000000)
  46. #define AUTCPU12_SMC_SEL_BASE (AUTCPU12_SMC_BASE + 0x10)
  47. #define AUTCPU12_MMGPIO_BASE (CLPS711X_NR_GPIO)
  48. #define AUTCPU12_SMC_NCE (AUTCPU12_MMGPIO_BASE + 0) /* Bit 0 */
  49. #define AUTCPU12_SMC_RDY CLPS711X_GPIO(1, 2)
  50. #define AUTCPU12_SMC_ALE CLPS711X_GPIO(1, 3)
  51. #define AUTCPU12_SMC_CLE CLPS711X_GPIO(1, 3)
  52. static struct resource autcpu12_cs8900_resource[] __initdata = {
  53. DEFINE_RES_MEM(AUTCPU12_CS8900_BASE, SZ_1K),
  54. DEFINE_RES_IRQ(AUTCPU12_CS8900_IRQ),
  55. };
  56. static struct resource autcpu12_nvram_resource[] __initdata = {
  57. DEFINE_RES_MEM_NAMED(AUTCPU12_PHYS_NVRAM, SZ_128K, "SRAM"),
  58. };
  59. static struct platform_device autcpu12_nvram_pdev __initdata = {
  60. .name = "autcpu12_nvram",
  61. .id = -1,
  62. .resource = autcpu12_nvram_resource,
  63. .num_resources = ARRAY_SIZE(autcpu12_nvram_resource),
  64. };
  65. static struct resource autcpu12_nand_resource[] __initdata = {
  66. DEFINE_RES_MEM(AUTCPU12_SMC_BASE, SZ_16),
  67. };
  68. static struct mtd_partition autcpu12_nand_parts[] __initdata = {
  69. {
  70. .name = "Flash partition 1",
  71. .offset = 0,
  72. .size = SZ_8M,
  73. },
  74. {
  75. .name = "Flash partition 2",
  76. .offset = MTDPART_OFS_APPEND,
  77. .size = MTDPART_SIZ_FULL,
  78. },
  79. };
  80. static void __init autcpu12_adjust_parts(struct gpio_nand_platdata *pdata,
  81. size_t sz)
  82. {
  83. switch (sz) {
  84. case SZ_16M:
  85. case SZ_32M:
  86. break;
  87. case SZ_64M:
  88. case SZ_128M:
  89. pdata->parts[0].size = SZ_16M;
  90. break;
  91. default:
  92. pr_warn("Unsupported SmartMedia device size %u\n", sz);
  93. break;
  94. }
  95. }
  96. static struct gpio_nand_platdata autcpu12_nand_pdata __initdata = {
  97. .gpio_rdy = AUTCPU12_SMC_RDY,
  98. .gpio_nce = AUTCPU12_SMC_NCE,
  99. .gpio_ale = AUTCPU12_SMC_ALE,
  100. .gpio_cle = AUTCPU12_SMC_CLE,
  101. .gpio_nwp = -1,
  102. .chip_delay = 20,
  103. .parts = autcpu12_nand_parts,
  104. .num_parts = ARRAY_SIZE(autcpu12_nand_parts),
  105. .adjust_parts = autcpu12_adjust_parts,
  106. };
  107. static struct platform_device autcpu12_nand_pdev __initdata = {
  108. .name = "gpio-nand",
  109. .id = -1,
  110. .resource = autcpu12_nand_resource,
  111. .num_resources = ARRAY_SIZE(autcpu12_nand_resource),
  112. .dev = {
  113. .platform_data = &autcpu12_nand_pdata,
  114. },
  115. };
  116. static struct resource autcpu12_mmgpio_resource[] __initdata = {
  117. DEFINE_RES_MEM_NAMED(AUTCPU12_SMC_SEL_BASE, SZ_1, "dat"),
  118. };
  119. static struct bgpio_pdata autcpu12_mmgpio_pdata __initdata = {
  120. .base = AUTCPU12_MMGPIO_BASE,
  121. .ngpio = 8,
  122. };
  123. static struct platform_device autcpu12_mmgpio_pdev __initdata = {
  124. .name = "basic-mmio-gpio",
  125. .id = -1,
  126. .resource = autcpu12_mmgpio_resource,
  127. .num_resources = ARRAY_SIZE(autcpu12_mmgpio_resource),
  128. .dev = {
  129. .platform_data = &autcpu12_mmgpio_pdata,
  130. },
  131. };
  132. static void __init autcpu12_init(void)
  133. {
  134. platform_device_register_simple("video-clps711x", 0, NULL, 0);
  135. platform_device_register_simple("cs89x0", 0, autcpu12_cs8900_resource,
  136. ARRAY_SIZE(autcpu12_cs8900_resource));
  137. platform_device_register(&autcpu12_mmgpio_pdev);
  138. platform_device_register(&autcpu12_nvram_pdev);
  139. }
  140. static void __init autcpu12_init_late(void)
  141. {
  142. if (IS_ENABLED(MTD_NAND_GPIO) && IS_ENABLED(GPIO_GENERIC_PLATFORM)) {
  143. /* We are need both drivers to handle NAND */
  144. platform_device_register(&autcpu12_nand_pdev);
  145. }
  146. }
  147. MACHINE_START(AUTCPU12, "autronix autcpu12")
  148. /* Maintainer: Thomas Gleixner */
  149. .atag_offset = 0x20000,
  150. .nr_irqs = CLPS711X_NR_IRQS,
  151. .map_io = clps711x_map_io,
  152. .init_irq = clps711x_init_irq,
  153. .timer = &clps711x_timer,
  154. .init_machine = autcpu12_init,
  155. .init_late = autcpu12_init_late,
  156. .handle_irq = clps711x_handle_irq,
  157. .restart = clps711x_restart,
  158. MACHINE_END