synchronousMemoryDatabase.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * bonito board support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/i2c.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/irq.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/gpio.h>
  28. #include <linux/regulator/fixed.h>
  29. #include <linux/regulator/machine.h>
  30. #include <linux/smsc911x.h>
  31. #include <linux/videodev2.h>
  32. #include <mach/common.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/time.h>
  37. #include <asm/hardware/cache-l2x0.h>
  38. #include <mach/r8a7740.h>
  39. #include <mach/irqs.h>
  40. #include <video/sh_mobile_lcdc.h>
  41. /*
  42. * CS Address device note
  43. *----------------------------------------------------------------
  44. * 0 0x0000_0000 NOR Flash (64MB) SW12 : bit3 = OFF
  45. * 2 0x0800_0000 ExtNOR (64MB) SW12 : bit3 = OFF
  46. * 4 -
  47. * 5A -
  48. * 5B 0x1600_0000 SRAM (8MB)
  49. * 6 0x1800_0000 FPGA (64K)
  50. * 0x1801_0000 Ether (4KB)
  51. * 0x1801_1000 USB (4KB)
  52. */
  53. /*
  54. * SW12
  55. *
  56. * bit1 bit2 bit3
  57. *----------------------------------------------------------------------------
  58. * ON NOR WriteProtect NAND WriteProtect CS0 ExtNOR / CS2 NOR
  59. * OFF NOR Not WriteProtect NAND Not WriteProtect CS0 NOR / CS2 ExtNOR
  60. */
  61. /*
  62. * SCIFA5 (CN42)
  63. *
  64. * S38.3 = ON
  65. * S39.6 = ON
  66. * S43.1 = ON
  67. */
  68. /*
  69. * LCDC0 (CN3/CN4/CN7)
  70. *
  71. * S38.1 = OFF
  72. * S38.2 = OFF
  73. */
  74. /* Dummy supplies, where voltage doesn't matter */
  75. static struct regulator_consumer_supply dummy_supplies[] = {
  76. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  77. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  78. };
  79. /*
  80. * FPGA
  81. */
  82. #define IRQSR0 0x0020
  83. #define IRQSR1 0x0022
  84. #define IRQMR0 0x0030
  85. #define IRQMR1 0x0032
  86. #define BUSSWMR1 0x0070
  87. #define BUSSWMR2 0x0072
  88. #define BUSSWMR3 0x0074
  89. #define BUSSWMR4 0x0076
  90. #define LCDCR 0x10B4
  91. #define DEVRSTCR1 0x10D0
  92. #define DEVRSTCR2 0x10D2
  93. #define A1MDSR 0x10E0
  94. #define BVERR 0x1100
  95. /* FPGA IRQ */
  96. #define FPGA_IRQ_BASE (512)
  97. #define FPGA_IRQ0 (FPGA_IRQ_BASE)
  98. #define FPGA_IRQ1 (FPGA_IRQ_BASE + 16)
  99. #define FPGA_ETH_IRQ (FPGA_IRQ0 + 15)
  100. static u16 bonito_fpga_read(u32 offset)
  101. {
  102. return __raw_readw(IOMEM(0xf0003000) + offset);
  103. }
  104. static void bonito_fpga_write(u32 offset, u16 val)
  105. {
  106. __raw_writew(val, IOMEM(0xf0003000) + offset);
  107. }
  108. static void bonito_fpga_irq_disable(struct irq_data *data)
  109. {
  110. unsigned int irq = data->irq;
  111. u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1;
  112. int shift = irq % 16;
  113. bonito_fpga_write(addr, bonito_fpga_read(addr) | (1 << shift));
  114. }
  115. static void bonito_fpga_irq_enable(struct irq_data *data)
  116. {
  117. unsigned int irq = data->irq;
  118. u32 addr = (irq < 1016) ? IRQMR0 : IRQMR1;
  119. int shift = irq % 16;
  120. bonito_fpga_write(addr, bonito_fpga_read(addr) & ~(1 << shift));
  121. }
  122. static struct irq_chip bonito_fpga_irq_chip __read_mostly = {
  123. .name = "bonito FPGA",
  124. .irq_mask = bonito_fpga_irq_disable,
  125. .irq_unmask = bonito_fpga_irq_enable,
  126. };
  127. static void bonito_fpga_irq_demux(unsigned int irq, struct irq_desc *desc)
  128. {
  129. u32 val = bonito_fpga_read(IRQSR1) << 16 |
  130. bonito_fpga_read(IRQSR0);
  131. u32 mask = bonito_fpga_read(IRQMR1) << 16 |
  132. bonito_fpga_read(IRQMR0);
  133. int i;
  134. val &= ~mask;
  135. for (i = 0; i < 32; i++) {
  136. if (!(val & (1 << i)))
  137. continue;
  138. generic_handle_irq(FPGA_IRQ_BASE + i);
  139. }
  140. }
  141. static void bonito_fpga_init(void)
  142. {
  143. int i;
  144. bonito_fpga_write(IRQMR0, 0xffff); /* mask all */
  145. bonito_fpga_write(IRQMR1, 0xffff); /* mask all */
  146. /* Device reset */
  147. bonito_fpga_write(DEVRSTCR1,
  148. (1 << 2)); /* Eth */
  149. /* FPGA irq require special handling */
  150. for (i = FPGA_IRQ_BASE; i < FPGA_IRQ_BASE + 32; i++) {
  151. irq_set_chip_and_handler_name(i, &bonito_fpga_irq_chip,
  152. handle_level_irq, "level");
  153. set_irq_flags(i, IRQF_VALID); /* yuck */
  154. }
  155. irq_set_chained_handler(evt2irq(0x0340), bonito_fpga_irq_demux);