150-gemini-pata.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. --- a/arch/arm/mach-gemini/include/mach/global_reg.h
  2. +++ b/arch/arm/mach-gemini/include/mach/global_reg.h
  3. @@ -227,7 +227,13 @@
  4. #define USB0_PLUG_MINIB (1 << 29)
  5. #define GMAC_GMII (1 << 28)
  6. #define GMAC_1_ENABLE (1 << 27)
  7. -/* TODO: define ATA/SATA bits */
  8. +/* 011 - ata0 <-> sata0, sata1; bring out ata1
  9. + * 010 - ata1 <-> sata1, sata0; bring out ata0
  10. + * 001 - ata0 <-> sata0, ata1 <-> sata1; bring out ata1
  11. + * 000 - ata0 <-> sata0, ata1 <-> sata1; bring out ata0 */
  12. +#define IDE_IOMUX_MASK (7 << 24)
  13. +#define IDE_IOMUX_SATA1_SATA0 (2 << 24)
  14. +#define IDE_IOMUX_SATA0_SATA1 (3 << 24)
  15. #define USB1_VBUS_ON (1 << 23)
  16. #define USB0_VBUS_ON (1 << 22)
  17. #define APB_CLKOUT_ENABLE (1 << 21)
  18. --- a/arch/arm/mach-gemini/irq.c
  19. +++ b/arch/arm/mach-gemini/irq.c
  20. @@ -89,6 +89,9 @@ void __init gemini_init_irq(void)
  21. irq_set_handler(i, handle_edge_irq);
  22. mode |= 1 << i;
  23. level |= 1 << i;
  24. + } else if (i >= IRQ_IDE0 && i <= IRQ_IDE1) {
  25. + irq_set_handler(i, handle_edge_irq);
  26. + mode |= 1 << i;
  27. } else {
  28. irq_set_handler(i, handle_level_irq);
  29. }
  30. --- a/arch/arm/mach-gemini/common.h
  31. +++ b/arch/arm/mach-gemini/common.h
  32. @@ -29,6 +29,7 @@ extern int platform_register_pflash(unsi
  33. extern int platform_register_watchdog(void);
  34. extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
  35. extern int platform_register_usb(unsigned int id);
  36. +extern int platform_register_pata(unsigned int id);
  37. extern void gemini_restart(enum reboot_mode mode, const char *cmd);
  38. --- a/arch/arm/mach-gemini/devices.c
  39. +++ b/arch/arm/mach-gemini/devices.c
  40. @@ -249,3 +249,67 @@ int __init platform_register_usb(unsigne
  41. return platform_device_register(&usb_device[id]);
  42. }
  43. +static u64 pata_gemini_dmamask0 = 0xffffffffUL;
  44. +static u64 pata_gemini_dmamask1 = 0xffffffffUL;
  45. +
  46. +static struct resource pata_gemini_resources0[] =
  47. +{
  48. + [0] = {
  49. + .start = GEMINI_IDE0_BASE,
  50. + .end = GEMINI_IDE0_BASE + 0x40,
  51. + .flags = IORESOURCE_MEM,
  52. + },
  53. + [1] = {
  54. + .start = IRQ_IDE0,
  55. + .end = IRQ_IDE0,
  56. + .flags = IORESOURCE_IRQ,
  57. + },
  58. +};
  59. +
  60. +static struct resource pata_gemini_resources1[] =
  61. +{
  62. + [0] = {
  63. + .start = GEMINI_IDE1_BASE,
  64. + .end = GEMINI_IDE1_BASE + 0x40,
  65. + .flags = IORESOURCE_MEM,
  66. + },
  67. + [1] = {
  68. + .start = IRQ_IDE1,
  69. + .end = IRQ_IDE1,
  70. + .flags = IORESOURCE_IRQ,
  71. + },
  72. +};
  73. +
  74. +static struct platform_device pata_gemini_devices[] =
  75. +{
  76. + {
  77. + .name = "pata-gemini",
  78. + .id = 0,
  79. + .dev =
  80. + {
  81. + .dma_mask = &pata_gemini_dmamask0,
  82. + .coherent_dma_mask = 0xffffffff,
  83. + },
  84. + .num_resources = ARRAY_SIZE(pata_gemini_resources0),
  85. + .resource = pata_gemini_resources0,
  86. + },
  87. + {
  88. + .name = "pata-gemini",
  89. + .id = 1,
  90. + .dev =
  91. + {
  92. + .dma_mask = &pata_gemini_dmamask1,
  93. + .coherent_dma_mask = 0xffffffff,
  94. + },
  95. + .num_resources = ARRAY_SIZE(pata_gemini_resources1),
  96. + .resource = pata_gemini_resources1,
  97. + },
  98. +};
  99. +
  100. +int __init platform_register_pata(unsigned int id)
  101. +{
  102. + if (id > 1)
  103. + return -EINVAL;
  104. +
  105. + return platform_device_register(&pata_gemini_devices[id]);
  106. +}
  107. --- a/arch/arm/mach-gemini/mm.c
  108. +++ b/arch/arm/mach-gemini/mm.c
  109. @@ -24,6 +24,11 @@ static struct map_desc gemini_io_desc[]
  110. .length = SZ_512K,
  111. .type = MT_DEVICE,
  112. }, {
  113. + .virtual = (unsigned long)IO_ADDRESS(GEMINI_SATA_BASE),
  114. + .pfn = __phys_to_pfn(GEMINI_SATA_BASE),
  115. + .length = SZ_512K,
  116. + .type = MT_DEVICE,
  117. + }, {
  118. .virtual = (unsigned long)IO_ADDRESS(GEMINI_UART_BASE),
  119. .pfn = __phys_to_pfn(GEMINI_UART_BASE),
  120. .length = SZ_512K,
  121. --- a/drivers/ata/Kconfig
  122. +++ b/drivers/ata/Kconfig
  123. @@ -539,6 +539,16 @@ config PATA_EP93XX
  124. If unsure, say N.
  125. +config PATA_GEMINI
  126. + tristate "Gemini PATA support (Experimental)"
  127. + depends on ARCH_GEMINI
  128. + help
  129. + This option enables support for the Gemini PATA-Controller.
  130. + Note that the Gemini SoC has no native SATA-Controller but an
  131. + onboard PATA-SATA bridge.
  132. +
  133. + If unsure, say N.
  134. +
  135. config PATA_HPT366
  136. tristate "HPT 366/368 PATA support"
  137. depends on PCI
  138. --- a/drivers/ata/Makefile
  139. +++ b/drivers/ata/Makefile
  140. @@ -53,6 +53,7 @@ obj-$(CONFIG_PATA_CS5536) += pata_cs5536
  141. obj-$(CONFIG_PATA_CYPRESS) += pata_cypress.o
  142. obj-$(CONFIG_PATA_EFAR) += pata_efar.o
  143. obj-$(CONFIG_PATA_EP93XX) += pata_ep93xx.o
  144. +obj-$(CONFIG_PATA_GEMINI) += pata_gemini.o
  145. obj-$(CONFIG_PATA_HPT366) += pata_hpt366.o
  146. obj-$(CONFIG_PATA_HPT37X) += pata_hpt37x.o
  147. obj-$(CONFIG_PATA_HPT3X2N) += pata_hpt3x2n.o
  148. --- a/arch/arm/mach-gemini/board-nas4220b.c
  149. +++ b/arch/arm/mach-gemini/board-nas4220b.c
  150. @@ -146,11 +146,28 @@ static void __init usb_ib4220b_init(void
  151. GLOBAL_MISC_CTRL));
  152. }
  153. +static void __init sata_ib4220b_init(void)
  154. +{
  155. + unsigned val;
  156. +
  157. + val = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  158. + GLOBAL_MISC_CTRL));
  159. + val &= ~(IDE_IOMUX_MASK | PFLASH_PADS_DISABLE);
  160. + val |= IDE_PADS_ENABLE;
  161. + writel(val, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  162. + GLOBAL_MISC_CTRL));
  163. +
  164. + /* enabling ports for presence detection, master only */
  165. + writel(0x00000001, (void __iomem*)(IO_ADDRESS(GEMINI_SATA_BASE) + 0x18));
  166. + writel(0x00000001, (void __iomem*)(IO_ADDRESS(GEMINI_SATA_BASE) + 0x1c));
  167. +}
  168. +
  169. static void __init ib4220b_init(void)
  170. {
  171. gemini_gpio_init();
  172. ib4220b_gmac_init();
  173. usb_ib4220b_init();
  174. + sata_ib4220b_init();
  175. platform_register_uart();
  176. platform_register_pflash(SZ_16M, NULL, 0);
  177. platform_device_register(&ib4220b_led_device);
  178. @@ -161,6 +178,8 @@ static void __init ib4220b_init(void)
  179. platform_register_ethernet(&ib4220b_gmac_data);
  180. platform_register_usb(0);
  181. platform_register_usb(1);
  182. + platform_register_pata(0);
  183. + platform_register_pata(1);
  184. }
  185. MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")