setup.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * arch/xtensa/platforms/xt2000/setup.c
  4. *
  5. * Platform specific functions for the XT2000 board.
  6. *
  7. * Authors: Chris Zankel <chris@zankel.net>
  8. * Joe Taylor <joe@tensilica.com>
  9. *
  10. * Copyright 2001 - 2004 Tensilica Inc.
  11. */
  12. #include <linux/stddef.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/errno.h>
  16. #include <linux/reboot.h>
  17. #include <linux/kdev_t.h>
  18. #include <linux/types.h>
  19. #include <linux/major.h>
  20. #include <linux/console.h>
  21. #include <linux/delay.h>
  22. #include <linux/stringify.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/serial.h>
  25. #include <linux/serial_8250.h>
  26. #include <linux/timer.h>
  27. #include <asm/processor.h>
  28. #include <asm/platform.h>
  29. #include <asm/bootparam.h>
  30. #include <platform/hardware.h>
  31. #include <platform/serial.h>
  32. /* Assumes s points to an 8-chr string. No checking for NULL. */
  33. static void led_print (int f, char *s)
  34. {
  35. unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;
  36. int i;
  37. for (i = f; i < 8; i++)
  38. if ((*led_addr++ = *s++) == 0)
  39. break;
  40. }
  41. static int xt2000_power_off(struct sys_off_data *unused)
  42. {
  43. led_print (0, "POWEROFF");
  44. local_irq_disable();
  45. while (1);
  46. return NOTIFY_DONE;
  47. }
  48. static int xt2000_restart(struct notifier_block *this,
  49. unsigned long event, void *ptr)
  50. {
  51. /* Flush and reset the mmu, simulate a processor reset, and
  52. * jump to the reset vector. */
  53. cpu_reset();
  54. return NOTIFY_DONE;
  55. }
  56. static struct notifier_block xt2000_restart_block = {
  57. .notifier_call = xt2000_restart,
  58. };
  59. void __init platform_setup(char** cmdline)
  60. {
  61. led_print (0, "LINUX ");
  62. }
  63. /* Heartbeat. Let the LED blink. */
  64. static void xt2000_heartbeat(struct timer_list *unused);
  65. static DEFINE_TIMER(heartbeat_timer, xt2000_heartbeat);
  66. static void xt2000_heartbeat(struct timer_list *unused)
  67. {
  68. static int i;
  69. led_print(7, i ? "." : " ");
  70. i ^= 1;
  71. mod_timer(&heartbeat_timer, jiffies + HZ / 2);
  72. }
  73. //#define RS_TABLE_SIZE 2
  74. #define _SERIAL_PORT(_base,_irq) \
  75. { \
  76. .mapbase = (_base), \
  77. .membase = (void*)(_base), \
  78. .irq = (_irq), \
  79. .uartclk = DUART16552_XTAL_FREQ, \
  80. .iotype = UPIO_MEM, \
  81. .flags = UPF_BOOT_AUTOCONF, \
  82. .regshift = 2, \
  83. }
  84. static struct plat_serial8250_port xt2000_serial_data[] = {
  85. #if XCHAL_HAVE_BE
  86. _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
  87. _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
  88. #else
  89. _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
  90. _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
  91. #endif
  92. { }
  93. };
  94. static struct platform_device xt2000_serial8250_device = {
  95. .name = "serial8250",
  96. .id = PLAT8250_DEV_PLATFORM,
  97. .dev = {
  98. .platform_data = xt2000_serial_data,
  99. },
  100. };
  101. static struct resource xt2000_sonic_res[] = {
  102. {
  103. .start = SONIC83934_ADDR,
  104. .end = SONIC83934_ADDR + 0xff,
  105. .flags = IORESOURCE_MEM,
  106. },
  107. {
  108. .start = SONIC83934_INTNUM,
  109. .end = SONIC83934_INTNUM,
  110. .flags = IORESOURCE_IRQ,
  111. },
  112. };
  113. static struct platform_device xt2000_sonic_device = {
  114. .name = "xtsonic",
  115. .num_resources = ARRAY_SIZE(xt2000_sonic_res),
  116. .resource = xt2000_sonic_res,
  117. };
  118. static int __init xt2000_setup_devinit(void)
  119. {
  120. platform_device_register(&xt2000_serial8250_device);
  121. platform_device_register(&xt2000_sonic_device);
  122. mod_timer(&heartbeat_timer, jiffies + HZ / 2);
  123. register_restart_handler(&xt2000_restart_block);
  124. register_sys_off_handler(SYS_OFF_MODE_POWER_OFF,
  125. SYS_OFF_PRIO_DEFAULT,
  126. xt2000_power_off, NULL);
  127. return 0;
  128. }
  129. device_initcall(xt2000_setup_devinit);