setup.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * KFR2R09 board support code
  3. *
  4. * Copyright (C) 2009 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/mtd/physmap.h>
  14. #include <linux/delay.h>
  15. #include <linux/clk.h>
  16. #include <linux/gpio.h>
  17. #include <linux/input.h>
  18. #include <asm/clock.h>
  19. #include <asm/machvec.h>
  20. #include <asm/io.h>
  21. #include <asm/sh_keysc.h>
  22. #include <cpu/sh7724.h>
  23. static struct mtd_partition kfr2r09_nor_flash_partitions[] =
  24. {
  25. {
  26. .name = "boot",
  27. .offset = 0,
  28. .size = (4 * 1024 * 1024),
  29. .mask_flags = MTD_WRITEABLE, /* Read-only */
  30. },
  31. {
  32. .name = "other",
  33. .offset = MTDPART_OFS_APPEND,
  34. .size = MTDPART_SIZ_FULL,
  35. },
  36. };
  37. static struct physmap_flash_data kfr2r09_nor_flash_data = {
  38. .width = 2,
  39. .parts = kfr2r09_nor_flash_partitions,
  40. .nr_parts = ARRAY_SIZE(kfr2r09_nor_flash_partitions),
  41. };
  42. static struct resource kfr2r09_nor_flash_resources[] = {
  43. [0] = {
  44. .name = "NOR Flash",
  45. .start = 0x00000000,
  46. .end = 0x03ffffff,
  47. .flags = IORESOURCE_MEM,
  48. }
  49. };
  50. static struct platform_device kfr2r09_nor_flash_device = {
  51. .name = "physmap-flash",
  52. .resource = kfr2r09_nor_flash_resources,
  53. .num_resources = ARRAY_SIZE(kfr2r09_nor_flash_resources),
  54. .dev = {
  55. .platform_data = &kfr2r09_nor_flash_data,
  56. },
  57. };
  58. static struct sh_keysc_info kfr2r09_sh_keysc_info = {
  59. .mode = SH_KEYSC_MODE_1, /* KEYOUT0->4, KEYIN0->4 */
  60. .scan_timing = 3,
  61. .delay = 10,
  62. .keycodes = {
  63. KEY_PHONE, KEY_CLEAR, KEY_MAIL, KEY_WWW, KEY_ENTER,
  64. KEY_1, KEY_2, KEY_3, 0, KEY_UP,
  65. KEY_4, KEY_5, KEY_6, 0, KEY_LEFT,
  66. KEY_7, KEY_8, KEY_9, KEY_PROG1, KEY_RIGHT,
  67. KEY_S, KEY_0, KEY_P, KEY_PROG2, KEY_DOWN,
  68. 0, 0, 0, 0, 0
  69. },
  70. };
  71. static struct resource kfr2r09_sh_keysc_resources[] = {
  72. [0] = {
  73. .name = "KEYSC",
  74. .start = 0x044b0000,
  75. .end = 0x044b000f,
  76. .flags = IORESOURCE_MEM,
  77. },
  78. [1] = {
  79. .start = 79,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. };
  83. static struct platform_device kfr2r09_sh_keysc_device = {
  84. .name = "sh_keysc",
  85. .id = 0, /* "keysc0" clock */
  86. .num_resources = ARRAY_SIZE(kfr2r09_sh_keysc_resources),
  87. .resource = kfr2r09_sh_keysc_resources,
  88. .dev = {
  89. .platform_data = &kfr2r09_sh_keysc_info,
  90. },
  91. };
  92. static struct platform_device *kfr2r09_devices[] __initdata = {
  93. &kfr2r09_nor_flash_device,
  94. &kfr2r09_sh_keysc_device,
  95. };
  96. #define BSC_CS0BCR 0xfec10004
  97. #define BSC_CS0WCR 0xfec10024
  98. static int __init kfr2r09_devices_setup(void)
  99. {
  100. /* enable SCIF1 serial port for YC401 console support */
  101. gpio_request(GPIO_FN_SCIF1_RXD, NULL);
  102. gpio_request(GPIO_FN_SCIF1_TXD, NULL);
  103. /* setup NOR flash at CS0 */
  104. ctrl_outl(0x36db0400, BSC_CS0BCR);
  105. ctrl_outl(0x00000500, BSC_CS0WCR);
  106. /* setup KEYSC pins */
  107. gpio_request(GPIO_FN_KEYOUT0, NULL);
  108. gpio_request(GPIO_FN_KEYOUT1, NULL);
  109. gpio_request(GPIO_FN_KEYOUT2, NULL);
  110. gpio_request(GPIO_FN_KEYOUT3, NULL);
  111. gpio_request(GPIO_FN_KEYOUT4_IN6, NULL);
  112. gpio_request(GPIO_FN_KEYIN0, NULL);
  113. gpio_request(GPIO_FN_KEYIN1, NULL);
  114. gpio_request(GPIO_FN_KEYIN2, NULL);
  115. gpio_request(GPIO_FN_KEYIN3, NULL);
  116. gpio_request(GPIO_FN_KEYIN4, NULL);
  117. gpio_request(GPIO_FN_KEYOUT5_IN5, NULL);
  118. return platform_add_devices(kfr2r09_devices,
  119. ARRAY_SIZE(kfr2r09_devices));
  120. }
  121. device_initcall(kfr2r09_devices_setup);
  122. /* Return the board specific boot mode pin configuration */
  123. static int kfr2r09_mode_pins(void)
  124. {
  125. /* MD0=1, MD1=1, MD2=0: Clock Mode 3
  126. * MD3=0: 16-bit Area0 Bus Width
  127. * MD5=1: Little Endian
  128. * MD8=1: Test Mode Disabled
  129. */
  130. return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8;
  131. }
  132. /*
  133. * The Machine Vector
  134. */
  135. static struct sh_machine_vector mv_kfr2r09 __initmv = {
  136. .mv_name = "kfr2r09",
  137. .mv_mode_pins = kfr2r09_mode_pins,
  138. };