setup.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. __asm__ __volatile__ ("movi a2, 15\n\t"
  62. "wsr a2, icountlevel\n\t"
  63. "movi a2, 0\n\t"
  64. "wsr a2, icount\n\t"
  65. "wsr a2, ibreakenable\n\t"
  66. "wsr a2, lcount\n\t"
  67. "movi a2, 0x1f\n\t"
  68. "wsr a2, ps\n\t"
  69. "isync\n\t"
  70. "jx %0\n\t"
  71. :
  72. : "a" (XCHAL_RESET_VECTOR_VADDR)
  73. : "a2"
  74. );
  75. /* control never gets here */
  76. }
  77. void __init platform_setup(char** cmdline)
  78. {
  79. led_print (0, "LINUX ");
  80. }
  81. /* early initialization */
  82. extern sysmem_info_t __initdata sysmem;
  83. void platform_init(bp_tag_t* first)
  84. {
  85. /* Set default memory block if not provided by the bootloader. */
  86. if (sysmem.nr_banks == 0) {
  87. sysmem.nr_banks = 1;
  88. sysmem.bank[0].start = PLATFORM_DEFAULT_MEM_START;
  89. sysmem.bank[0].end = PLATFORM_DEFAULT_MEM_START
  90. + PLATFORM_DEFAULT_MEM_SIZE;
  91. }
  92. }
  93. /* Heartbeat. Let the LED blink. */
  94. void platform_heartbeat(void)
  95. {
  96. static int i=0, t = 0;
  97. if (--t < 0)
  98. {
  99. t = 59;
  100. led_print(7, i ? ".": " ");
  101. i ^= 1;
  102. }
  103. }
  104. //#define RS_TABLE_SIZE 2
  105. //#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST)
  106. #define _SERIAL_PORT(_base,_irq) \
  107. { \
  108. .mapbase = (_base), \
  109. .membase = (void*)(_base), \
  110. .irq = (_irq), \
  111. .uartclk = DUART16552_XTAL_FREQ, \
  112. .iotype = UPIO_MEM, \
  113. .flags = UPF_BOOT_AUTOCONF, \
  114. .regshift = 2, \
  115. }
  116. static struct plat_serial8250_port xt2000_serial_data[] = {
  117. #if XCHAL_HAVE_BE
  118. _SERIAL_PORT(DUART16552_1_ADDR + 3, DUART16552_1_INTNUM),
  119. _SERIAL_PORT(DUART16552_2_ADDR + 3, DUART16552_2_INTNUM),
  120. #else
  121. _SERIAL_PORT(DUART16552_1_ADDR, DUART16552_1_INTNUM),
  122. _SERIAL_PORT(DUART16552_2_ADDR, DUART16552_2_INTNUM),
  123. #endif
  124. { }
  125. };
  126. static struct platform_device xt2000_serial8250_device = {
  127. .name = "serial8250",
  128. .id = PLAT8250_DEV_PLATFORM,
  129. .dev = {
  130. .platform_data = xt2000_serial_data,
  131. },
  132. };
  133. static struct resource xt2000_sonic_res[] = {
  134. {
  135. .start = SONIC83934_ADDR,
  136. .end = SONIC83934_ADDR + 0xff,
  137. .flags = IORESOURCE_MEM,
  138. },
  139. {
  140. .start = SONIC83934_INTNUM,
  141. .end = SONIC83934_INTNUM,
  142. .flags = IORESOURCE_IRQ,
  143. },
  144. };
  145. static struct platform_device xt2000_sonic_device = {
  146. .name = "xtsonic",
  147. .num_resources = ARRAY_SIZE(xt2000_sonic_res),
  148. .resource = xt2000_sonic_res,
  149. };
  150. static int __init xt2000_setup_devinit(void)
  151. {
  152. platform_device_register(&xt2000_serial8250_device);
  153. platform_device_register(&xt2000_sonic_device);
  154. return 0;
  155. }
  156. device_initcall(xt2000_setup_devinit);