connectTheSignalSlot.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * arch/arm/mach-orion5x/kurobox_pro-setup.c
  3. *
  4. * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/pci.h>
  15. #include <linux/irq.h>
  16. #include <linux/delay.h>
  17. #include <linux/mtd/physmap.h>
  18. #include <linux/mtd/nand.h>
  19. #include <linux/mv643xx_eth.h>
  20. #include <linux/i2c.h>
  21. #include <linux/serial_reg.h>
  22. #include <linux/ata_platform.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/pci.h>
  26. #include <mach/orion5x.h>
  27. #include <linux/platform_data/mtd-orion_nand.h>
  28. #include "common.h"
  29. #include "mpp.h"
  30. /*****************************************************************************
  31. * KUROBOX-PRO Info
  32. ****************************************************************************/
  33. /*
  34. * 256K NOR flash Device bus boot chip select
  35. */
  36. #define KUROBOX_PRO_NOR_BOOT_BASE 0xf4000000
  37. #define KUROBOX_PRO_NOR_BOOT_SIZE SZ_256K
  38. /*
  39. * 256M NAND flash on Device bus chip select 1
  40. */
  41. #define KUROBOX_PRO_NAND_BASE 0xfc000000
  42. #define KUROBOX_PRO_NAND_SIZE SZ_2M
  43. /*****************************************************************************
  44. * 256MB NAND Flash on Device bus CS0
  45. ****************************************************************************/
  46. static struct mtd_partition kurobox_pro_nand_parts[] = {
  47. {
  48. .name = "uImage",
  49. .offset = 0,
  50. .size = SZ_4M,
  51. }, {
  52. .name = "rootfs",
  53. .offset = SZ_4M,
  54. .size = SZ_64M,
  55. }, {
  56. .name = "extra",
  57. .offset = SZ_4M + SZ_64M,
  58. .size = SZ_256M - (SZ_4M + SZ_64M),
  59. },
  60. };
  61. static struct resource kurobox_pro_nand_resource = {
  62. .flags = IORESOURCE_MEM,
  63. .start = KUROBOX_PRO_NAND_BASE,
  64. .end = KUROBOX_PRO_NAND_BASE + KUROBOX_PRO_NAND_SIZE - 1,
  65. };
  66. static struct orion_nand_data kurobox_pro_nand_data = {
  67. .parts = kurobox_pro_nand_parts,
  68. .nr_parts = ARRAY_SIZE(kurobox_pro_nand_parts),
  69. .cle = 0,
  70. .ale = 1,
  71. .width = 8,
  72. };
  73. static struct platform_device kurobox_pro_nand_flash = {
  74. .name = "orion_nand",
  75. .id = -1,
  76. .dev = {
  77. .platform_data = &kurobox_pro_nand_data,
  78. },
  79. .resource = &kurobox_pro_nand_resource,
  80. .num_resources = 1,
  81. };
  82. /*****************************************************************************
  83. * 256KB NOR Flash on BOOT Device
  84. ****************************************************************************/
  85. static struct physmap_flash_data kurobox_pro_nor_flash_data = {
  86. .width = 1,
  87. };
  88. static struct resource kurobox_pro_nor_flash_resource = {
  89. .flags = IORESOURCE_MEM,
  90. .start = KUROBOX_PRO_NOR_BOOT_BASE,
  91. .end = KUROBOX_PRO_NOR_BOOT_BASE + KUROBOX_PRO_NOR_BOOT_SIZE - 1,
  92. };
  93. static struct platform_device kurobox_pro_nor_flash = {
  94. .name = "physmap-flash",
  95. .id = 0,
  96. .dev = {
  97. .platform_data = &kurobox_pro_nor_flash_data,
  98. },
  99. .num_resources = 1,
  100. .resource = &kurobox_pro_nor_flash_resource,
  101. };
  102. /*****************************************************************************
  103. * PCI
  104. ****************************************************************************/
  105. static int __init kurobox_pro_pci_map_irq(const struct pci_dev *dev, u8 slot,
  106. u8 pin)
  107. {
  108. int irq;
  109. /*
  110. * Check for devices with hard-wired IRQs.
  111. */
  112. irq = orion5x_pci_map_irq(dev, slot, pin);
  113. if (irq != -1)
  114. return irq;
  115. /*
  116. * PCI isn't used on the Kuro
  117. */
  118. return -1;
  119. }
  120. static struct hw_pci kurobox_pro_pci __initdata = {
  121. .nr_controllers = 2,
  122. .setup = orion5x_pci_sys_setup,
  123. .scan = orion5x_pci_sys_scan_bus,
  124. .map_irq = kurobox_pro_pci_map_irq,
  125. };
  126. static int __init kurobox_pro_pci_init(void)
  127. {
  128. if (machine_is_kurobox_pro()) {
  129. orion5x_pci_disable();
  130. pci_common_init(&kurobox_pro_pci);
  131. }
  132. return 0;
  133. }
  134. subsys_initcall(kurobox_pro_pci_init);
  135. /*****************************************************************************
  136. * Ethernet
  137. ****************************************************************************/
  138. static struct mv643xx_eth_platform_data kurobox_pro_eth_data = {
  139. .phy_addr = MV643XX_ETH_PHY_ADDR(8),
  140. };
  141. /*****************************************************************************
  142. * RTC 5C372a on I2C bus
  143. ****************************************************************************/
  144. static struct i2c_board_info __initdata kurobox_pro_i2c_rtc = {
  145. I2C_BOARD_INFO("rs5c372a", 0x32),
  146. };
  147. /*****************************************************************************
  148. * SATA
  149. ****************************************************************************/
  150. static struct mv_sata_platform_data kurobox_pro_sata_data = {
  151. .n_ports = 2,
  152. };
  153. /*****************************************************************************
  154. * Kurobox Pro specific power off method via UART1-attached microcontroller
  155. ****************************************************************************/
  156. #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
  157. static int kurobox_pro_miconread(unsigned char *buf, int count)
  158. {
  159. int i;
  160. int timeout;
  161. for (i = 0; i < count; i++) {
  162. timeout = 10;
  163. while (!(readl(UART1_REG(LSR)) & UART_LSR_DR)) {
  164. if (--timeout == 0)
  165. break;
  166. udelay(1000);
  167. }
  168. if (timeout == 0)
  169. break;
  170. buf[i] = readl(UART1_REG(RX));
  171. }
  172. /* return read bytes */
  173. return i;
  174. }
  175. static int kurobox_pro_miconwrite(const unsigned char *buf, int count)
  176. {
  177. int i = 0;
  178. while (count--) {
  179. while (!(readl(UART1_REG(LSR)) & UART_LSR_THRE))
  180. barrier();
  181. writel(buf[i++], UART1_REG(TX));
  182. }
  183. return 0;
  184. }
  185. static int kurobox_pro_miconsend(const unsigned char *data, int count)
  186. {
  187. int i;
  188. unsigned char checksum = 0;
  189. unsigned char recv_buf[40];
  190. unsigned char send_buf[40];
  191. unsigned char correct_ack[3];
  192. int retry = 2;
  193. /* Generate checksum */
  194. for (i = 0; i < count; i++)
  195. checksum -= data[i];
  196. do {
  197. /* Send data */