gemini: add Linux 4.4 support
[openwrt/staging/yousong.git] / target / linux / gemini / patches-4.4 / 150-gemini-pata.patch
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 @@ -31,6 +31,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
38 extern void gemini_restart(enum reboot_mode mode, const char *cmd);
39
40 --- a/arch/arm/mach-gemini/devices.c
41 +++ b/arch/arm/mach-gemini/devices.c
42 @@ -248,3 +248,67 @@ int __init platform_register_usb(unsigne
43 return platform_device_register(&usb_device[id]);
44 }
45
46 +static u64 pata_gemini_dmamask0 = 0xffffffffUL;
47 +static u64 pata_gemini_dmamask1 = 0xffffffffUL;
48 +
49 +static struct resource pata_gemini_resources0[] =
50 +{
51 + [0] = {
52 + .start = GEMINI_IDE0_BASE,
53 + .end = GEMINI_IDE0_BASE + 0x40,
54 + .flags = IORESOURCE_MEM,
55 + },
56 + [1] = {
57 + .start = IRQ_IDE0,
58 + .end = IRQ_IDE0,
59 + .flags = IORESOURCE_IRQ,
60 + },
61 +};
62 +
63 +static struct resource pata_gemini_resources1[] =
64 +{
65 + [0] = {
66 + .start = GEMINI_IDE1_BASE,
67 + .end = GEMINI_IDE1_BASE + 0x40,
68 + .flags = IORESOURCE_MEM,
69 + },
70 + [1] = {
71 + .start = IRQ_IDE1,
72 + .end = IRQ_IDE1,
73 + .flags = IORESOURCE_IRQ,
74 + },
75 +};
76 +
77 +static struct platform_device pata_gemini_devices[] =
78 +{
79 + {
80 + .name = "pata-gemini",
81 + .id = 0,
82 + .dev =
83 + {
84 + .dma_mask = &pata_gemini_dmamask0,
85 + .coherent_dma_mask = 0xffffffff,
86 + },
87 + .num_resources = ARRAY_SIZE(pata_gemini_resources0),
88 + .resource = pata_gemini_resources0,
89 + },
90 + {
91 + .name = "pata-gemini",
92 + .id = 1,
93 + .dev =
94 + {
95 + .dma_mask = &pata_gemini_dmamask1,
96 + .coherent_dma_mask = 0xffffffff,
97 + },
98 + .num_resources = ARRAY_SIZE(pata_gemini_resources1),
99 + .resource = pata_gemini_resources1,
100 + },
101 +};
102 +
103 +int __init platform_register_pata(unsigned int id)
104 +{
105 + if (id > 1)
106 + return -EINVAL;
107 +
108 + return platform_device_register(&pata_gemini_devices[id]);
109 +}
110 --- a/arch/arm/mach-gemini/mm.c
111 +++ b/arch/arm/mach-gemini/mm.c
112 @@ -24,6 +24,11 @@ static struct map_desc gemini_io_desc[]
113 .length = SZ_512K,
114 .type = MT_DEVICE,
115 }, {
116 + .virtual = (unsigned long)IO_ADDRESS(GEMINI_SATA_BASE),
117 + .pfn = __phys_to_pfn(GEMINI_SATA_BASE),
118 + .length = SZ_512K,
119 + .type = MT_DEVICE,
120 + }, {
121 .virtual = (unsigned long)IO_ADDRESS(GEMINI_UART_BASE),
122 .pfn = __phys_to_pfn(GEMINI_UART_BASE),
123 .length = SZ_512K,
124 --- a/drivers/ata/Kconfig
125 +++ b/drivers/ata/Kconfig
126 @@ -564,6 +564,16 @@ config PATA_EP93XX
127
128 If unsure, say N.
129
130 +config PATA_GEMINI
131 + tristate "Gemini PATA support (Experimental)"
132 + depends on ARCH_GEMINI
133 + help
134 + This option enables support for the Gemini PATA-Controller.
135 + Note that the Gemini SoC has no native SATA-Controller but an
136 + onboard PATA-SATA bridge.
137 +
138 + If unsure, say N.
139 +
140 config PATA_HPT366
141 tristate "HPT 366/368 PATA support"
142 depends on PCI
143 --- a/drivers/ata/Makefile
144 +++ b/drivers/ata/Makefile
145 @@ -56,6 +56,7 @@ obj-$(CONFIG_PATA_CS5536) += pata_cs5536
146 obj-$(CONFIG_PATA_CYPRESS) += pata_cypress.o
147 obj-$(CONFIG_PATA_EFAR) += pata_efar.o
148 obj-$(CONFIG_PATA_EP93XX) += pata_ep93xx.o
149 +obj-$(CONFIG_PATA_GEMINI) += pata_gemini.o
150 obj-$(CONFIG_PATA_HPT366) += pata_hpt366.o
151 obj-$(CONFIG_PATA_HPT37X) += pata_hpt37x.o
152 obj-$(CONFIG_PATA_HPT3X2N) += pata_hpt3x2n.o
153 --- a/arch/arm/mach-gemini/board-nas4220b.c
154 +++ b/arch/arm/mach-gemini/board-nas4220b.c
155 @@ -146,11 +146,28 @@ static void __init usb_ib4220b_init(void
156 GLOBAL_MISC_CTRL));
157 }
158
159 +static void __init sata_ib4220b_init(void)
160 +{
161 + unsigned val;
162 +
163 + val = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
164 + GLOBAL_MISC_CTRL));
165 + val &= ~(IDE_IOMUX_MASK | PFLASH_PADS_DISABLE);
166 + val |= IDE_PADS_ENABLE;
167 + writel(val, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
168 + GLOBAL_MISC_CTRL));
169 +
170 + /* enabling ports for presence detection, master only */
171 + writel(0x00000001, (void __iomem*)(IO_ADDRESS(GEMINI_SATA_BASE) + 0x18));
172 + writel(0x00000001, (void __iomem*)(IO_ADDRESS(GEMINI_SATA_BASE) + 0x1c));
173 +}
174 +
175 static void __init ib4220b_init(void)
176 {
177 gemini_gpio_init();
178 ib4220b_gmac_init();
179 usb_ib4220b_init();
180 + sata_ib4220b_init();
181 platform_register_uart();
182 platform_register_pflash(SZ_16M, NULL, 0);
183 platform_device_register(&ib4220b_led_device);
184 @@ -161,6 +178,8 @@ static void __init ib4220b_init(void)
185 platform_register_ethernet(&ib4220b_gmac_data);
186 platform_register_usb(0);
187 platform_register_usb(1);
188 + platform_register_pata(0);
189 + platform_register_pata(1);
190 }
191
192 MACHINE_START(NAS4220B, "Raidsonic NAS IB-4220-B")