board-edosk7760.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Renesas Europe EDOSK7760 Board Support
  4. *
  5. * Copyright (C) 2008 SPES Societa' Progettazione Elettronica e Software Ltd.
  6. * Author: Luca Santini <[email protected]>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/types.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/smc91x.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/sh_intc.h>
  14. #include <linux/i2c.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <asm/machvec.h>
  17. #include <asm/io.h>
  18. #include <asm/addrspace.h>
  19. #include <asm/delay.h>
  20. #include <asm/i2c-sh7760.h>
  21. #include <linux/sizes.h>
  22. /* Bus state controller registers for CS4 area */
  23. #define BSC_CS4BCR 0xA4FD0010
  24. #define BSC_CS4WCR 0xA4FD0030
  25. #define SMC_IOBASE 0xA2000000
  26. #define SMC_IO_OFFSET 0x300
  27. #define SMC_IOADDR (SMC_IOBASE + SMC_IO_OFFSET)
  28. /* NOR flash */
  29. static struct mtd_partition edosk7760_nor_flash_partitions[] = {
  30. {
  31. .name = "bootloader",
  32. .offset = 0,
  33. .size = SZ_256K,
  34. .mask_flags = MTD_WRITEABLE, /* Read-only */
  35. }, {
  36. .name = "kernel",
  37. .offset = MTDPART_OFS_APPEND,
  38. .size = SZ_2M,
  39. }, {
  40. .name = "fs",
  41. .offset = MTDPART_OFS_APPEND,
  42. .size = (26 << 20),
  43. }, {
  44. .name = "other",
  45. .offset = MTDPART_OFS_APPEND,
  46. .size = MTDPART_SIZ_FULL,
  47. },
  48. };
  49. static struct physmap_flash_data edosk7760_nor_flash_data = {
  50. .width = 4,
  51. .parts = edosk7760_nor_flash_partitions,
  52. .nr_parts = ARRAY_SIZE(edosk7760_nor_flash_partitions),
  53. };
  54. static struct resource edosk7760_nor_flash_resources[] = {
  55. [0] = {
  56. .name = "NOR Flash",
  57. .start = 0x00000000,
  58. .end = 0x00000000 + SZ_32M - 1,
  59. .flags = IORESOURCE_MEM,
  60. }
  61. };
  62. static struct platform_device edosk7760_nor_flash_device = {
  63. .name = "physmap-flash",
  64. .resource = edosk7760_nor_flash_resources,
  65. .num_resources = ARRAY_SIZE(edosk7760_nor_flash_resources),
  66. .dev = {
  67. .platform_data = &edosk7760_nor_flash_data,
  68. },
  69. };
  70. /* i2c initialization functions */
  71. static struct sh7760_i2c_platdata i2c_pd = {
  72. .speed_khz = 400,
  73. };
  74. static struct resource sh7760_i2c1_res[] = {
  75. {
  76. .start = SH7760_I2C1_MMIO,
  77. .end = SH7760_I2C1_MMIOEND,
  78. .flags = IORESOURCE_MEM,
  79. },{
  80. .start = evt2irq(0x9e0),
  81. .end = evt2irq(0x9e0),
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. };
  85. static struct platform_device sh7760_i2c1_dev = {
  86. .dev = {
  87. .platform_data = &i2c_pd,
  88. },
  89. .name = SH7760_I2C_DEVNAME,
  90. .id = 1,
  91. .resource = sh7760_i2c1_res,
  92. .num_resources = ARRAY_SIZE(sh7760_i2c1_res),
  93. };
  94. static struct resource sh7760_i2c0_res[] = {
  95. {
  96. .start = SH7760_I2C0_MMIO,
  97. .end = SH7760_I2C0_MMIOEND,
  98. .flags = IORESOURCE_MEM,
  99. }, {
  100. .start = evt2irq(0x9c0),
  101. .end = evt2irq(0x9c0),
  102. .flags = IORESOURCE_IRQ,
  103. },
  104. };
  105. static struct platform_device sh7760_i2c0_dev = {
  106. .dev = {
  107. .platform_data = &i2c_pd,
  108. },
  109. .name = SH7760_I2C_DEVNAME,
  110. .id = 0,
  111. .resource = sh7760_i2c0_res,
  112. .num_resources = ARRAY_SIZE(sh7760_i2c0_res),
  113. };
  114. /* eth initialization functions */
  115. static struct smc91x_platdata smc91x_info = {
  116. .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL,
  117. };
  118. static struct resource smc91x_res[] = {
  119. [0] = {
  120. .start = SMC_IOADDR,
  121. .end = SMC_IOADDR + SZ_32 - 1,
  122. .flags = IORESOURCE_MEM,
  123. },
  124. [1] = {
  125. .start = evt2irq(0x2a0),
  126. .end = evt2irq(0x2a0),
  127. .flags = IORESOURCE_IRQ ,
  128. }
  129. };
  130. static struct platform_device smc91x_dev = {
  131. .name = "smc91x",
  132. .id = -1,
  133. .num_resources = ARRAY_SIZE(smc91x_res),
  134. .resource = smc91x_res,
  135. .dev = {
  136. .platform_data = &smc91x_info,
  137. },
  138. };
  139. /* platform init code */
  140. static struct platform_device *edosk7760_devices[] __initdata = {
  141. &smc91x_dev,
  142. &edosk7760_nor_flash_device,
  143. &sh7760_i2c0_dev,
  144. &sh7760_i2c1_dev,
  145. };
  146. static int __init init_edosk7760_devices(void)
  147. {
  148. plat_irq_setup_pins(IRQ_MODE_IRQ);
  149. return platform_add_devices(edosk7760_devices,
  150. ARRAY_SIZE(edosk7760_devices));
  151. }
  152. device_initcall(init_edosk7760_devices);
  153. /*
  154. * The Machine Vector
  155. */
  156. struct sh_machine_vector mv_edosk7760 __initmv = {
  157. .mv_name = "EDOSK7760",
  158. };