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/i2c.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <asm/machvec.h>
  29. #include <asm/io.h>
  30. #include <asm/addrspace.h>
  31. #include <asm/delay.h>
  32. #include <asm/i2c-sh7760.h>
  33. /* Bus state controller registers for CS4 area */
  34. #define BSC_CS4BCR 0xA4FD0010
  35. #define BSC_CS4WCR 0xA4FD0030
  36. #define SMC_IOBASE 0xA2000000
  37. #define SMC_IO_OFFSET 0x300
  38. #define SMC_IOADDR (SMC_IOBASE + SMC_IO_OFFSET)
  39. #define ETHERNET_IRQ 5
  40. /* NOR flash */
  41. static struct mtd_partition edosk7760_nor_flash_partitions[] = {
  42. {
  43. .name = "bootloader",
  44. .offset = 0,
  45. .size = (1 * 1024 * 1024), /*1MB*/
  46. .mask_flags = MTD_WRITEABLE, /* Read-only */
  47. }, {
  48. .name = "kernel",
  49. .offset = MTDPART_OFS_APPEND,
  50. .size = (2 * 1024 * 1024), /*2MB*/
  51. }, {
  52. .name = "fs",
  53. .offset = MTDPART_OFS_APPEND,
  54. .size = (26 * 1024 * 1024),
  55. }, {
  56. .name = "other",
  57. .offset = MTDPART_OFS_APPEND,
  58. .size = MTDPART_SIZ_FULL,
  59. },
  60. };
  61. static struct physmap_flash_data edosk7760_nor_flash_data = {
  62. .width = 4,
  63. .parts = edosk7760_nor_flash_partitions,
  64. .nr_parts = ARRAY_SIZE(edosk7760_nor_flash_partitions),
  65. };
  66. static struct resource edosk7760_nor_flash_resources[] = {
  67. [0] = {
  68. .name = "NOR Flash",
  69. .start = 0x00000000,
  70. .end = (32 * 1024 * 1024) -1, /* 32MB*/
  71. .flags = IORESOURCE_MEM,
  72. }
  73. };
  74. static struct platform_device edosk7760_nor_flash_device = {
  75. .name = "physmap-flash",
  76. .resource = edosk7760_nor_flash_resources,
  77. .num_resources = ARRAY_SIZE(edosk7760_nor_flash_resources),
  78. .dev = {
  79. .platform_data = &edosk7760_nor_flash_data,
  80. },
  81. };
  82. /* i2c initialization functions */
  83. static struct sh7760_i2c_platdata i2c_pd = {
  84. .speed_khz = 400,
  85. };
  86. static struct resource sh7760_i2c1_res[] = {
  87. {
  88. .start = SH7760_I2C1_MMIO,
  89. .end = SH7760_I2C1_MMIOEND,
  90. .flags = IORESOURCE_MEM,
  91. },{
  92. .start = SH7760_I2C1_IRQ,
  93. .end = SH7760_I2C1_IRQ,
  94. .flags = IORESOURCE_IRQ,
  95. },
  96. };
  97. static struct platform_device sh7760_i2c1_dev = {
  98. .dev = {
  99. .platform_data = &i2c_pd,
  100. },
  101. .name = SH7760_I2C_DEVNAME,
  102. .id = 1,
  103. .resource = sh7760_i2c1_res,
  104. .num_resources = ARRAY_SIZE(sh7760_i2c1_res),
  105. };
  106. static struct resource sh7760_i2c0_res[] = {
  107. {
  108. .start = SH7760_I2C0_MMIO,
  109. .end = SH7760_I2C0_MMIOEND,
  110. .flags = IORESOURCE_MEM,
  111. }, {
  112. .start = SH7760_I2C0_IRQ,
  113. .end = SH7760_I2C0_IRQ,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device sh7760_i2c0_dev = {
  118. .dev = {
  119. .platform_data = &i2c_pd,
  120. },
  121. .name = SH7760_I2C_DEVNAME,
  122. .id = 0,
  123. .resource = sh7760_i2c0_res,
  124. .num_resources = ARRAY_SIZE(sh7760_i2c0_res),
  125. };
  126. /* eth initialization functions */
  127. static struct smc91x_platdata smc91x_info = {
  128. .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL,
  129. };
  130. static struct resource smc91x_res[] = {
  131. [0] = {
  132. .start = SMC_IOADDR,
  133. .end = SMC_IOADDR + 0x1f,
  134. .flags = IORESOURCE_MEM,
  135. },
  136. [1] = {
  137. .start = ETHERNET_IRQ,
  138. .end = ETHERNET_IRQ,
  139. .flags = IORESOURCE_IRQ ,
  140. }
  141. };
  142. static struct platform_device smc91x_dev = {
  143. .name = "smc91x",
  144. .id = -1,
  145. .num_resources = ARRAY_SIZE(smc91x_res),
  146. .resource = smc91x_res,
  147. .dev = {
  148. .platform_data = &smc91x_info,
  149. },
  150. };
  151. /* platform init code */
  152. static struct platform_device *edosk7760_devices[] __initdata = {
  153. &smc91x_dev,
  154. &edosk7760_nor_flash_device,
  155. &sh7760_i2c0_dev,
  156. &sh7760_i2c1_dev,
  157. };
  158. static int __init init_edosk7760_devices(void)
  159. {
  160. plat_irq_setup_pins(IRQ_MODE_IRQ);
  161. return platform_add_devices(edosk7760_devices,
  162. ARRAY_SIZE(edosk7760_devices));
  163. }
  164. __initcall(init_edosk7760_devices);
  165. /*
  166. * The Machine Vector
  167. */
  168. struct sh_machine_vector mv_edosk7760 __initmv = {
  169. .mv_name = "EDOSK7760",
  170. .mv_nr_irqs = 128,
  171. };