setup.c 3.0 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 <[email protected]>
  8. * Joe Taylor <[email protected]>
  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 <asm/processor.h>
  27. #include <asm/platform.h>
  28. #include <asm/bootparam.h>
  29. #include <platform/hardware.h>
  30. #include <platform/serial.h>
  31. /* Assumes s points to an 8-chr string. No checking for NULL. */
  32. static void led_print (int f, char *s)
  33. {
  34. unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;
  35. int i;
  36. for (i = f; i < 8; i++)
  37. if ((*led_addr++ = *s++) == 0)
  38. break;
  39. }
  40. void platform_halt(void)
  41. {
  42. led_print (0, " HALT ");
  43. local_irq_disable();
  44. while (1);
  45. }
  46. void platform_power_off(void)
  47. {
  48. led_print (0, "POWEROFF");
  49. local_irq_disable();
  50. while (1);
  51. }
  52. void platform_restart(void)
  53. {
  54. /* Flush and reset the mmu, simulate a processor reset, and
  55. * jump to the reset vector. */
  56. cpu_reset();
  57. /* control never gets here */
  58. }
  59. void __init platform_setup(char** cmdline)
  60. {
  61. led_print (0, "LINUX ");
  62. }
  63. /* early initialization */
  64. void __init platform_init(bp_tag_t *first)
  65. {
  66. }
  67. /* Heartbeat. Let the LED blink. */
  68. void platform_heartbeat(void)
  69. {
  70. static int i, t;
  71. if (--t < 0)
  72. {
  73. t = 59;
  74. led_print(7, i ? ".": " ");
  75. i ^= 1;
  76. }
  77. }
  78. //#define RS_TABLE_SIZE 2
  79. #define _SERIAL_PORT(_base,_irq) \
  80. { \
  81. .mapbase = (_base), \
  82. .membase = (void*)(_base), \
  83. .irq = (_irq), \
  84. .uartclk = DUART16552_XTAL_FREQ, \
  85. .iotype = UPIO_MEM, \
  86. .flags = UPF_BOOT_AUTOCONF, \
  87. .regshift = 2, \
  88. }
  89. static struct plat_serial8250_port xt2000_serial_data[] = {
  90. #if XCHAL_HAVE_BE
  91. _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
  92. _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
  93. #else
  94. _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
  95. _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
  96. #endif
  97. { }
  98. };
  99. static struct platform_device xt2000_serial8250_device = {
  100. .name = "serial8250",
  101. .id = PLAT8250_DEV_PLATFORM,
  102. .dev = {
  103. .platform_data = xt2000_serial_data,
  104. },
  105. };
  106. static struct resource xt2000_sonic_res[] = {
  107. {
  108. .start = SONIC83934_ADDR,
  109. .end = SONIC83934_ADDR + 0xff,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. {
  113. .start = SONIC83934_INTNUM,
  114. .end = SONIC83934_INTNUM,
  115. .flags = IORESOURCE_IRQ,
  116. },
  117. };
  118. static struct platform_device xt2000_sonic_device = {
  119. .name = "xtsonic",
  120. .num_resources = ARRAY_SIZE(xt2000_sonic_res),
  121. .resource = xt2000_sonic_res,
  122. };
  123. static int __init xt2000_setup_devinit(void)
  124. {
  125. platform_device_register(&xt2000_serial8250_device);
  126. platform_device_register(&xt2000_sonic_device);
  127. return 0;
  128. }
  129. device_initcall(xt2000_setup_devinit);