setup.c 4.0 KB

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