cerf.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-sa1100/cerf.c
  4. *
  5. * Apr-2003 : Removed some old PDA crud [FB]
  6. * Oct-2003 : Added uart2 resource [FB]
  7. * Jan-2004 : Removed io map for flash [FB]
  8. */
  9. #include <linux/init.h>
  10. #include <linux/gpio/machine.h>
  11. #include <linux/kernel.h>
  12. #include <linux/tty.h>
  13. #include <linux/platform_data/sa11x0-serial.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/irq.h>
  16. #include <linux/mtd/mtd.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/gpio.h>
  19. #include <linux/leds.h>
  20. #include <mach/hardware.h>
  21. #include <asm/setup.h>
  22. #include <asm/mach-types.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach/flash.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/cerf.h>
  27. #include <linux/platform_data/mfd-mcp-sa11x0.h>
  28. #include <mach/irqs.h>
  29. #include "generic.h"
  30. static struct resource cerfuart2_resources[] = {
  31. [0] = DEFINE_RES_MEM(0x80030000, SZ_64K),
  32. };
  33. static struct platform_device cerfuart2_device = {
  34. .name = "sa11x0-uart",
  35. .id = 2,
  36. .num_resources = ARRAY_SIZE(cerfuart2_resources),
  37. .resource = cerfuart2_resources,
  38. };
  39. /* Compact Flash */
  40. static struct gpiod_lookup_table cerf_cf_gpio_table = {
  41. .dev_id = "sa11x0-pcmcia.1",
  42. .table = {
  43. GPIO_LOOKUP("gpio", 19, "bvd2", GPIO_ACTIVE_HIGH),
  44. GPIO_LOOKUP("gpio", 20, "bvd1", GPIO_ACTIVE_HIGH),
  45. GPIO_LOOKUP("gpio", 21, "reset", GPIO_ACTIVE_HIGH),
  46. GPIO_LOOKUP("gpio", 22, "ready", GPIO_ACTIVE_HIGH),
  47. GPIO_LOOKUP("gpio", 23, "detect", GPIO_ACTIVE_LOW),
  48. { },
  49. },
  50. };
  51. /* LEDs */
  52. struct gpio_led cerf_gpio_leds[] = {
  53. {
  54. .name = "cerf:d0",
  55. .default_trigger = "heartbeat",
  56. .gpio = 0,
  57. },
  58. {
  59. .name = "cerf:d1",
  60. .default_trigger = "cpu0",
  61. .gpio = 1,
  62. },
  63. {
  64. .name = "cerf:d2",
  65. .default_trigger = "default-on",
  66. .gpio = 2,
  67. },
  68. {
  69. .name = "cerf:d3",
  70. .default_trigger = "default-on",
  71. .gpio = 3,
  72. },
  73. };
  74. static struct gpio_led_platform_data cerf_gpio_led_info = {
  75. .leds = cerf_gpio_leds,
  76. .num_leds = ARRAY_SIZE(cerf_gpio_leds),
  77. };
  78. static struct platform_device *cerf_devices[] __initdata = {
  79. &cerfuart2_device,
  80. };
  81. #ifdef CONFIG_SA1100_CERF_FLASH_32MB
  82. # define CERF_FLASH_SIZE 0x02000000
  83. #elif defined CONFIG_SA1100_CERF_FLASH_16MB
  84. # define CERF_FLASH_SIZE 0x01000000
  85. #elif defined CONFIG_SA1100_CERF_FLASH_8MB
  86. # define CERF_FLASH_SIZE 0x00800000
  87. #else
  88. # error "Undefined flash size for CERF"
  89. #endif
  90. static struct mtd_partition cerf_partitions[] = {
  91. {
  92. .name = "Bootloader",
  93. .size = 0x00020000,
  94. .offset = 0x00000000,
  95. }, {
  96. .name = "Params",
  97. .size = 0x00040000,
  98. .offset = 0x00020000,
  99. }, {
  100. .name = "Kernel",
  101. .size = 0x00100000,
  102. .offset = 0x00060000,
  103. }, {
  104. .name = "Filesystem",
  105. .size = CERF_FLASH_SIZE-0x00160000,
  106. .offset = 0x00160000,
  107. }
  108. };
  109. static struct flash_platform_data cerf_flash_data = {
  110. .map_name = "cfi_probe",
  111. .parts = cerf_partitions,
  112. .nr_parts = ARRAY_SIZE(cerf_partitions),
  113. };
  114. static struct resource cerf_flash_resource =
  115. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
  116. static void __init cerf_init_irq(void)
  117. {
  118. sa1100_init_irq();
  119. irq_set_irq_type(CERF_ETH_IRQ, IRQ_TYPE_EDGE_RISING);
  120. }
  121. static struct map_desc cerf_io_desc[] __initdata = {
  122. { /* Crystal Ethernet Chip */
  123. .virtual = 0xf0000000,
  124. .pfn = __phys_to_pfn(0x08000000),
  125. .length = 0x00100000,
  126. .type = MT_DEVICE
  127. }
  128. };
  129. static void __init cerf_map_io(void)
  130. {
  131. sa1100_map_io();
  132. iotable_init(cerf_io_desc, ARRAY_SIZE(cerf_io_desc));
  133. sa1100_register_uart(0, 3);
  134. sa1100_register_uart(1, 2); /* disable this and the uart2 device for sa1100_fir */
  135. sa1100_register_uart(2, 1);
  136. }
  137. static struct mcp_plat_data cerf_mcp_data = {
  138. .mccr0 = MCCR0_ADM,
  139. .sclk_rate = 11981000,
  140. };
  141. static void __init cerf_init(void)
  142. {
  143. sa11x0_ppc_configure_mcp();
  144. platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
  145. gpio_led_register_device(-1, &cerf_gpio_led_info);
  146. sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1);
  147. sa11x0_register_mcp(&cerf_mcp_data);
  148. sa11x0_register_pcmcia(1, &cerf_cf_gpio_table);
  149. }
  150. MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
  151. /* Maintainer: [email protected] */
  152. .map_io = cerf_map_io,
  153. .nr_irqs = SA1100_NR_IRQS,
  154. .init_irq = cerf_init_irq,
  155. .init_time = sa1100_timer_init,
  156. .init_machine = cerf_init,
  157. .init_late = sa11x0_init_late,
  158. .restart = sa11x0_restart,
  159. MACHINE_END