setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * arch/sh/boards/landisk/setup.c
  3. *
  4. * Copyright (C) 2000 Kazumoto Kojima
  5. * Copyright (C) 2002 Paul Mundt
  6. *
  7. * I-O DATA Device, Inc. LANDISK Support.
  8. *
  9. * Modified for LANDISK by
  10. * Atom Create Engineering Co., Ltd. 2002.
  11. *
  12. * modifed by kogiidena
  13. * 2005.09.16
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file "COPYING" in the main directory of this archive
  17. * for more details.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/pm.h>
  21. #include <linux/mm.h>
  22. #include <asm/machvec.h>
  23. #include <asm/rtc.h>
  24. #include <asm/landisk/iodata_landisk.h>
  25. #include <asm/io.h>
  26. void landisk_time_init(void);
  27. void init_landisk_IRQ(void);
  28. int landisk_ledparam;
  29. int landisk_buzzerparam;
  30. int landisk_arch;
  31. /* cycle the led's in the clasic knightrider/sun pattern */
  32. static void heartbeat_landisk(void)
  33. {
  34. static unsigned int cnt = 0, blink = 0x00, period = 25;
  35. volatile u8 *p = (volatile u8 *)PA_LED;
  36. char data;
  37. if ((landisk_ledparam & 0x080) == 0)
  38. return;
  39. cnt += 1;
  40. if (cnt < period)
  41. return;
  42. cnt = 0;
  43. blink++;
  44. data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
  45. data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
  46. data |= landisk_ledparam;
  47. /* buzzer */
  48. if (landisk_buzzerparam & 0x1) {
  49. data |= 0x80;
  50. } else {
  51. data &= 0x7f;
  52. }
  53. *p = data;
  54. if (((landisk_ledparam & 0x007f7f00) == 0) &&
  55. (landisk_buzzerparam == 0))
  56. landisk_ledparam &= (~0x0080);
  57. landisk_buzzerparam >>= 1;
  58. }
  59. static void landisk_power_off(void)
  60. {
  61. ctrl_outb(0x01, PA_SHUTDOWN);
  62. }
  63. static void check_usl5p(void)
  64. {
  65. volatile u8 *p = (volatile u8 *)PA_LED;
  66. u8 tmp1, tmp2;
  67. tmp1 = *p;
  68. *p = 0x40;
  69. tmp2 = *p;
  70. *p = tmp1;
  71. landisk_arch = (tmp2 == 0x40);
  72. if (landisk_arch == 1) {
  73. /* arch == usl-5p */
  74. landisk_ledparam = 0x00000380;
  75. landisk_ledparam |= (tmp1 & 0x07c);
  76. } else {
  77. /* arch == landisk */
  78. landisk_ledparam = 0x02000180;
  79. landisk_ledparam |= 0x04;
  80. }
  81. }
  82. void *area5_io_base;
  83. void *area6_io_base;
  84. static int __init landisk_cf_init(void)
  85. {
  86. pgprot_t prot;
  87. unsigned long paddrbase, psize;
  88. /* open I/O area window */
  89. paddrbase = virt_to_phys((void *)PA_AREA5_IO);
  90. psize = PAGE_SIZE;
  91. prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
  92. area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  93. if (!area5_io_base) {
  94. printk("allocate_cf_area : can't open CF I/O window!\n");
  95. return -ENOMEM;
  96. }
  97. paddrbase = virt_to_phys((void *)PA_AREA6_IO);
  98. psize = PAGE_SIZE;
  99. prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
  100. area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
  101. if (!area6_io_base) {
  102. printk("allocate_cf_area : can't open HDD I/O window!\n");
  103. return -ENOMEM;
  104. }
  105. printk(KERN_INFO "Allocate Area5/6 success.\n");
  106. /* XXX : do we need attribute and common-memory area also? */
  107. return 0;
  108. }
  109. static void __init landisk_setup(char **cmdline_p)
  110. {
  111. device_initcall(landisk_cf_init);
  112. landisk_buzzerparam = 0;
  113. check_usl5p();
  114. printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
  115. board_time_init = landisk_time_init;
  116. pm_power_off = landisk_power_off;
  117. }
  118. /*
  119. * The Machine Vector
  120. */
  121. struct sh_machine_vector mv_landisk __initmv = {
  122. .mv_name = "LANDISK",
  123. .mv_setup = landisk_setup,
  124. .mv_nr_irqs = 72,
  125. .mv_inb = landisk_inb,
  126. .mv_inw = landisk_inw,
  127. .mv_inl = landisk_inl,
  128. .mv_outb = landisk_outb,
  129. .mv_outw = landisk_outw,
  130. .mv_outl = landisk_outl,
  131. .mv_inb_p = landisk_inb_p,
  132. .mv_inw_p = landisk_inw,
  133. .mv_inl_p = landisk_inl,
  134. .mv_outb_p = landisk_outb_p,
  135. .mv_outw_p = landisk_outw,
  136. .mv_outl_p = landisk_outl,
  137. .mv_insb = landisk_insb,
  138. .mv_insw = landisk_insw,
  139. .mv_insl = landisk_insl,
  140. .mv_outsb = landisk_outsb,
  141. .mv_outsw = landisk_outsw,
  142. .mv_outsl = landisk_outsl,
  143. .mv_ioport_map = landisk_ioport_map,
  144. .mv_init_irq = init_landisk_IRQ,
  145. #ifdef CONFIG_HEARTBEAT
  146. .mv_heartbeat = heartbeat_landisk,
  147. #endif
  148. };
  149. ALIAS_MV(landisk)