board-bonito.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/gpio.h>
  27. #include <mach/common.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/map.h>
  31. #include <asm/mach/time.h>
  32. #include <asm/hardware/cache-l2x0.h>
  33. #include <mach/r8a7740.h>
  34. /*
  35. * CS Address device note
  36. *----------------------------------------------------------------
  37. * 0 0x0000_0000 NOR Flash (64MB) SW12 : bit3 = OFF
  38. * 2 0x0800_0000 ExtNOR (64MB) SW12 : bit3 = OFF
  39. * 4 -
  40. * 5A -
  41. * 5B 0x1600_0000 SRAM (8MB)
  42. * 6 0x1800_0000 FPGA (64K)
  43. * 0x1801_0000 Ether (4KB)
  44. * 0x1801_1000 USB (4KB)
  45. */
  46. /*
  47. * SW12
  48. *
  49. * bit1 bit2 bit3
  50. *----------------------------------------------------------------------------
  51. * ON NOR WriteProtect NAND WriteProtect CS0 ExtNOR / CS2 NOR
  52. * OFF NOR Not WriteProtect NAND Not WriteProtect CS0 NOR / CS2 ExtNOR
  53. */
  54. /*
  55. * FPGA
  56. */
  57. #define A1MDSR 0x10E0
  58. #define BVERR 0x1100
  59. static u16 bonito_fpga_read(u32 offset)
  60. {
  61. return __raw_readw(0xf0003000 + offset);
  62. }
  63. static void bonito_fpga_write(u32 offset, u16 val)
  64. {
  65. __raw_writew(val, 0xf0003000 + offset);
  66. }
  67. /*
  68. * devices
  69. */
  70. static struct platform_device *bonito_devices[] __initdata = {
  71. };
  72. /*
  73. * map I/O
  74. */
  75. static struct map_desc bonito_io_desc[] __initdata = {
  76. /*
  77. * for CPGA/INTC/PFC
  78. * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
  79. */
  80. {
  81. .virtual = 0xe6000000,
  82. .pfn = __phys_to_pfn(0xe6000000),
  83. .length = 160 << 20,
  84. .type = MT_DEVICE_NONSHARED
  85. },
  86. #ifdef CONFIG_CACHE_L2X0
  87. /*
  88. * for l2x0_init()
  89. * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
  90. */
  91. {
  92. .virtual = 0xf0002000,
  93. .pfn = __phys_to_pfn(0xf0100000),
  94. .length = PAGE_SIZE,
  95. .type = MT_DEVICE_NONSHARED
  96. },
  97. #endif
  98. /*
  99. * for FPGA (0x1800000-0x19ffffff)
  100. * 0x18000000-0x18002000 -> 0xf0003000-0xf0005000
  101. */
  102. {
  103. .virtual = 0xf0003000,
  104. .pfn = __phys_to_pfn(0x18000000),
  105. .length = PAGE_SIZE * 2,
  106. .type = MT_DEVICE_NONSHARED
  107. }
  108. };
  109. static void __init bonito_map_io(void)
  110. {
  111. iotable_init(bonito_io_desc, ARRAY_SIZE(bonito_io_desc));
  112. /* setup early devices and console here as well */
  113. r8a7740_add_early_devices();
  114. shmobile_setup_console();
  115. }
  116. /*
  117. * board init
  118. */
  119. static void __init bonito_init(void)
  120. {
  121. u16 val;
  122. r8a7740_pinmux_init();
  123. /* FPGA */
  124. gpio_request(GPIO_FN_CS5B, NULL);
  125. gpio_request(GPIO_FN_CS6A, NULL);
  126. gpio_request(GPIO_FN_CS5A_PORT105, NULL);
  127. gpio_request(GPIO_FN_IRQ10, NULL);
  128. val = bonito_fpga_read(BVERR);
  129. pr_info("bonito version: cpu %02x, base %02x\n",
  130. ((val >> 8) & 0xFF),
  131. ((val >> 0) & 0xFF));
  132. /* SCIFA5 */
  133. gpio_request(GPIO_FN_SCIFA5_TXD_PORT91, NULL);
  134. gpio_request(GPIO_FN_SCIFA5_RXD_PORT92, NULL);
  135. #ifdef CONFIG_CACHE_L2X0
  136. /* Early BRESP enable, Shared attribute override enable, 32K*8way */
  137. l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff);
  138. #endif
  139. r8a7740_add_standard_devices();
  140. platform_add_devices(bonito_devices, ARRAY_SIZE(bonito_devices));
  141. }
  142. static void __init bonito_timer_init(void)
  143. {
  144. u16 val;
  145. u8 md_ck = 0;
  146. /* read MD_CK value */
  147. val = bonito_fpga_read(A1MDSR);
  148. if (val & (1 << 10))
  149. md_ck |= MD_CK2;
  150. if (val & (1 << 9))
  151. md_ck |= MD_CK1;
  152. if (val & (1 << 8))
  153. md_ck |= MD_CK0;
  154. r8a7740_clock_init(md_ck);
  155. shmobile_timer.init();
  156. }
  157. struct sys_timer bonito_timer = {
  158. .init = bonito_timer_init,
  159. };
  160. MACHINE_START(BONITO, "bonito")
  161. .map_io = bonito_map_io,
  162. .init_irq = r8a7740_init_irq,
  163. .handle_irq = shmobile_handle_irq_intc,
  164. .init_machine = bonito_init,
  165. .timer = &bonito_timer,
  166. MACHINE_END