hackkit.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-sa1100/hackkit.c
  4. *
  5. * Copyright (C) 2002 Stefan Eletzhofer <[email protected]>
  6. *
  7. * This file contains all HackKit tweaks. Based on original work from
  8. * Nicolas Pitre's assabet fixes
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/sched.h>
  13. #include <linux/tty.h>
  14. #include <linux/module.h>
  15. #include <linux/errno.h>
  16. #include <linux/cpufreq.h>
  17. #include <linux/platform_data/sa11x0-serial.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/tty.h>
  22. #include <linux/gpio.h>
  23. #include <linux/leds.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/pgtable.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/setup.h>
  28. #include <asm/page.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/flash.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/irq.h>
  33. #include <mach/hardware.h>
  34. #include <mach/irqs.h>
  35. #include "generic.h"
  36. /**********************************************************************
  37. * prototypes
  38. */
  39. /* init funcs */
  40. static void __init hackkit_map_io(void);
  41. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
  42. /**********************************************************************
  43. * global data
  44. */
  45. /**********************************************************************
  46. * static data
  47. */
  48. static struct map_desc hackkit_io_desc[] __initdata = {
  49. { /* Flash bank 0 */
  50. .virtual = 0xe8000000,
  51. .pfn = __phys_to_pfn(0x00000000),
  52. .length = 0x01000000,
  53. .type = MT_DEVICE
  54. },
  55. };
  56. static struct sa1100_port_fns hackkit_port_fns __initdata = {
  57. .pm = hackkit_uart_pm,
  58. };
  59. /**********************************************************************
  60. * Static functions
  61. */
  62. static void __init hackkit_map_io(void)
  63. {
  64. sa1100_map_io();
  65. iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
  66. sa1100_register_uart_fns(&hackkit_port_fns);
  67. sa1100_register_uart(0, 1); /* com port */
  68. sa1100_register_uart(1, 2);
  69. sa1100_register_uart(2, 3); /* radio module */
  70. Ser1SDCR0 |= SDCR0_SUS;
  71. }
  72. /**
  73. * hackkit_uart_pm - powermgmt callback function for system 3 UART
  74. * @port: uart port structure
  75. * @state: pm state
  76. * @oldstate: old pm state
  77. *
  78. */
  79. static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  80. {
  81. /* TODO: switch on/off uart in powersave mode */
  82. }
  83. static struct mtd_partition hackkit_partitions[] = {
  84. {
  85. .name = "BLOB",
  86. .size = 0x00040000,
  87. .offset = 0x00000000,
  88. .mask_flags = MTD_WRITEABLE, /* force read-only */
  89. }, {
  90. .name = "config",
  91. .size = 0x00040000,
  92. .offset = MTDPART_OFS_APPEND,
  93. }, {
  94. .name = "kernel",
  95. .size = 0x00100000,
  96. .offset = MTDPART_OFS_APPEND,
  97. }, {
  98. .name = "initrd",
  99. .size = 0x00180000,
  100. .offset = MTDPART_OFS_APPEND,
  101. }, {
  102. .name = "rootfs",
  103. .size = 0x700000,
  104. .offset = MTDPART_OFS_APPEND,
  105. }, {
  106. .name = "data",
  107. .size = MTDPART_SIZ_FULL,
  108. .offset = MTDPART_OFS_APPEND,
  109. }
  110. };
  111. static struct flash_platform_data hackkit_flash_data = {
  112. .map_name = "cfi_probe",
  113. .parts = hackkit_partitions,
  114. .nr_parts = ARRAY_SIZE(hackkit_partitions),
  115. };
  116. static struct resource hackkit_flash_resource =
  117. DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
  118. /* LEDs */
  119. struct gpio_led hackkit_gpio_leds[] = {
  120. {
  121. .name = "hackkit:red",
  122. .default_trigger = "cpu0",
  123. .gpio = 22,
  124. },
  125. {
  126. .name = "hackkit:green",
  127. .default_trigger = "heartbeat",
  128. .gpio = 23,
  129. },
  130. };
  131. static struct gpio_led_platform_data hackkit_gpio_led_info = {
  132. .leds = hackkit_gpio_leds,
  133. .num_leds = ARRAY_SIZE(hackkit_gpio_leds),
  134. };
  135. static struct platform_device hackkit_leds = {
  136. .name = "leds-gpio",
  137. .id = -1,
  138. .dev = {
  139. .platform_data = &hackkit_gpio_led_info,
  140. }
  141. };
  142. static void __init hackkit_init(void)
  143. {
  144. sa11x0_register_mtd(&hackkit_flash_data, &hackkit_flash_resource, 1);
  145. platform_device_register(&hackkit_leds);
  146. }
  147. /**********************************************************************
  148. * Exported Functions
  149. */
  150. MACHINE_START(HACKKIT, "HackKit Cpu Board")
  151. .atag_offset = 0x100,
  152. .map_io = hackkit_map_io,
  153. .nr_irqs = SA1100_NR_IRQS,
  154. .init_irq = sa1100_init_irq,
  155. .init_time = sa1100_timer_init,
  156. .init_machine = hackkit_init,
  157. .init_late = sa11x0_init_late,
  158. .restart = sa11x0_restart,
  159. MACHINE_END