board-edosk7760.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Renesas Europe EDOSK7760 Board Support
  3. *
  4. * Copyright (C) 2008 SPES Societa' Progettazione Elettronica e Software Ltd.
  5. * Author: Luca Santini <luca.santini@spesonline.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; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/init.h>
  22. #include <linux/types.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/smc91x.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/sh_intc.h>
  27. #include <linux/i2c.h>
  28. #include <linux/mtd/physmap.h>
  29. #include <asm/machvec.h>
  30. #include <asm/io.h>
  31. #include <asm/addrspace.h>
  32. #include <asm/delay.h>
  33. #include <asm/i2c-sh7760.h>
  34. #include <asm/sizes.h>
  35. /* Bus state controller registers for CS4 area */
  36. #define BSC_CS4BCR 0xA4FD0010
  37. #define BSC_CS4WCR 0xA4FD0030
  38. #define SMC_IOBASE 0xA2000000
  39. #define SMC_IO_OFFSET 0x300
  40. #define SMC_IOADDR (SMC_IOBASE + SMC_IO_OFFSET)
  41. /* NOR flash */
  42. static struct mtd_partition edosk7760_nor_flash_partitions[] = {
  43. {
  44. .name = "bootloader",
  45. .offset = 0,
  46. .size = SZ_256K,
  47. .mask_flags = MTD_WRITEABLE, /* Read-only */
  48. }, {
  49. .name = "kernel",
  50. .offset = MTDPART_OFS_APPEND,
  51. .size = SZ_2M,
  52. }, {
  53. .name = "fs",
  54. .offset = MTDPART_OFS_APPEND,
  55. .size = (26 << 20),
  56. }, {
  57. .name = "other",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = MTDPART_SIZ_FULL,
  60. },
  61. };
  62. static struct physmap_flash_data edosk7760_nor_flash_data = {
  63. .width = 4,
  64. .parts = edosk7760_nor_flash_partitions,
  65. .nr_parts = ARRAY_SIZE(edosk7760_nor_flash_partitions),
  66. };
  67. static struct resource edosk7760_nor_flash_resources[] = {
  68. [0] = {
  69. .name = "NOR Flash",
  70. .start = 0x00000000,
  71. .end = 0x00000000 + SZ_32M - 1,
  72. .flags = IORESOURCE_MEM,
  73. }
  74. };
  75. static struct platform_device edosk7760_nor_flash_device = {
  76. .name = "physmap-flash",
  77. .resource = edosk7760_nor_flash_resources,
  78. .num_resources = ARRAY_SIZE(edosk7760_nor_flash_resources),
  79. .dev = {
  80. .platform_data = &edosk7760_nor_flash_data,
  81. },
  82. };
  83. /* i2c initialization functions */
  84. static struct sh7760_i2c_platdata i2c_pd = {
  85. .speed_khz = 400,
  86. };
  87. static struct resource sh7760_i2c1_res[] = {
  88. {
  89. .start = SH7760_I2C1_MMIO,
  90. .end = SH7760_I2C1_MMIOEND,
  91. .flags = IORESOURCE_MEM,
  92. },{
  93. .start = evt2irq(0x9e0),
  94. .end = evt2irq(0x9e0),
  95. .flags = IORESOURCE_IRQ,
  96. },
  97. };
  98. static struct platform_device sh7760_i2c1_dev = {
  99. .dev = {
  100. .platform_data = &i2c_pd,
  101. },
  102. .name = SH7760_I2C_DEVNAME,
  103. .id = 1,
  104. .resource = sh7760_i2c1_res,
  105. .num_resources = ARRAY_SIZE(sh7760_i2c1_res),
  106. };
  107. static struct resource sh7760_i2c0_res[] = {
  108. {
  109. .start = SH7760_I2C0_MMIO,
  110. .end = SH7760_I2C0_MMIOEND,
  111. .flags = IORESOURCE_MEM,
  112. }, {
  113. .start = evt2irq(0x9c0),
  114. .end = evt2irq(0x9c0),
  115. .flags = IORESOURCE_IRQ,
  116. },
  117. };
  118. static struct platform_device sh7760_i2c0_dev = {
  119. .dev = {
  120. .platform_data = &i2c_pd,
  121. },
  122. .name = SH7760_I2C_DEVNAME,
  123. .id = 0,
  124. .resource = sh7760_i2c0_res,
  125. .num_resources = ARRAY_SIZE(sh7760_i2c0_res),
  126. };
  127. /* eth initialization functions */
  128. static struct smc91x_platdata smc91x_info = {
  129. .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL,
  130. };
  131. static struct resource smc91x_res[] = {
  132. [0] = {
  133. .start = SMC_IOADDR,
  134. .end = SMC_IOADDR + SZ_32 - 1,
  135. .flags = IORESOURCE_MEM,
  136. },
  137. [1] = {
  138. .start = evt2irq(0x2a0),
  139. .end = evt2irq(0x2a0),
  140. .flags = IORESOURCE_IRQ ,
  141. }
  142. };
  143. static struct platform_device smc91x_dev = {
  144. .name = "smc91x",
  145. .id = -1,
  146. .num_resources = ARRAY_SIZE(smc91x_res),
  147. .resource = smc91x_res,
  148. .dev = {
  149. .platform_data = &smc91x_info,
  150. },
  151. };
  152. /* platform init code */
  153. static struct platform_device *edosk7760_devices[] __initdata = {
  154. &smc91x_dev,
  155. &edosk7760_nor_flash_device,
  156. &sh7760_i2c0_dev,
  157. &sh7760_i2c1_dev,
  158. };
  159. static int __init init_edosk7760_devices(void)
  160. {
  161. plat_irq_setup_pins(IRQ_MODE_IRQ);
  162. return platform_add_devices(edosk7760_devices,
  163. ARRAY_SIZE(edosk7760_devices));
  164. }
  165. device_initcall(init_edosk7760_devices);
  166. /*
  167. * The Machine Vector
  168. */
  169. struct sh_machine_vector mv_edosk7760 __initmv = {
  170. .mv_name = "EDOSK7760",
  171. };