setup.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * arch/xtensa/platforms/xt2000/setup.c
  3. *
  4. * Platform specific functions for the XT2000 board.
  5. *
  6. * Authors: Chris Zankel <chris@zankel.net>
  7. * Joe Taylor <joe@tensilica.com>
  8. *
  9. * Copyright 2001 - 2004 Tensilica Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. *
  16. */
  17. #include <linux/stddef.h>
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/errno.h>
  21. #include <linux/reboot.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/types.h>
  24. #include <linux/major.h>
  25. #include <linux/console.h>
  26. #include <linux/delay.h>
  27. #include <linux/stringify.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/serial.h>
  30. #include <linux/serial_8250.h>
  31. #include <asm/processor.h>
  32. #include <asm/platform.h>
  33. #include <asm/bootparam.h>
  34. #include <platform/hardware.h>
  35. #include <platform/serial.h>
  36. /* Assumes s points to an 8-chr string. No checking for NULL. */
  37. static void led_print (int f, char *s)
  38. {
  39. unsigned long* led_addr = (unsigned long*) (XT2000_LED_ADDR + 0xE0) + f;
  40. int i;
  41. for (i = f; i < 8; i++)
  42. if ((*led_addr++ = *s++) == 0)
  43. break;
  44. }
  45. void platform_halt(void)
  46. {
  47. led_print (0, " HALT ");
  48. local_irq_disable();
  49. while (1);
  50. }
  51. void platform_power_off(void)
  52. {
  53. led_print (0, "POWEROFF");
  54. local_irq_disable();
  55. while (1);
  56. }
  57. void platform_restart(void)
  58. {
  59. /* Flush and reset the mmu, simulate a processor reset, and
  60. * jump to the reset vector. */
  61. cpu_reset();
  62. /* control never gets here */
  63. }
  64. void __init platform_setup(char** cmdline)
  65. {
  66. led_print (0, "LINUX ");
  67. }
  68. /* early initialization */
  69. void __init platform_init(bp_tag_t *first)
  70. {
  71. }
  72. /* Heartbeat. Let the LED blink. */
  73. void platform_heartbeat(void)
  74. {
  75. static int i=0, t = 0;
  76. if (--t < 0)
  77. {
  78. t = 59;
  79. led_print(7, i ? ".": " ");
  80. i ^= 1;
  81. }
  82. }
  83. //#define RS_TABLE_SIZE 2
  84. #define _SERIAL_PORT(_base,_irq) \
  85. { \
  86. .mapbase = (_base), \
  87. .membase = (void*)(_base), \
  88. .irq = (_irq), \
  89. .uartclk = DUART16552_XTAL_FREQ, \
  90. .iotype = UPIO_MEM, \
  91. .flags = UPF_BOOT_AUTOCONF, \
  92. .regshift = 2, \
  93. }
  94. static struct plat_serial8250_port xt2000_serial_data[] = {
  95. #if XCHAL_HAVE_BE
  96. _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
  97. _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
  98. #else
  99. _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
  100. _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
  101. #endif
  102. { }
  103. };
  104. static struct platform_device xt2000_serial8250_device = {
  105. .name = "serial8250",
  106. .id = PLAT8250_DEV_PLATFORM,
  107. .dev = {
  108. .platform_data = xt2000_serial_data,
  109. },
  110. };
  111. static struct resource xt2000_sonic_res[] = {
  112. {
  113. .start = SONIC83934_ADDR,
  114. .end = SONIC83934_ADDR + 0xff,
  115. .flags = IORESOURCE_MEM,
  116. },
  117. {
  118. .start = SONIC83934_INTNUM,
  119. .end = SONIC83934_INTNUM,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. };
  123. static struct platform_device xt2000_sonic_device = {
  124. .name = "xtsonic",
  125. .num_resources = ARRAY_SIZE(xt2000_sonic_res),
  126. .resource = xt2000_sonic_res,
  127. };
  128. static int __init xt2000_setup_devinit(void)
  129. {
  130. platform_device_register(&xt2000_serial8250_device);
  131. platform_device_register(&xt2000_sonic_device);
  132. return 0;
  133. }
  134. device_initcall(xt2000_setup_devinit);