summaryrefslogtreecommitdiff
path: root/recipes/linux/linux-2.6.24/hipox/hipox-sata-module.patch
blob: f7c47690c872bc1ddb10ad3719f441a6d3f106e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
diff -Nurd linux-2.6.24.orig//arch/arm/mach-hipox/dma.c linux-2.6.24/arch/arm/mach-hipox/dma.c
--- linux-2.6.24.orig//arch/arm/mach-hipox/dma.c	2009-08-20 08:10:53.000000000 +0200
+++ linux-2.6.24/arch/arm/mach-hipox/dma.c	2009-08-20 08:17:17.000000000 +0200
@@ -2847,3 +2847,8 @@
 EXPORT_SYMBOL(hipox_sata_dma_settings);
 EXPORT_SYMBOL(hipox_dpe_rx_dma_settings);
 EXPORT_SYMBOL(hipox_dpe_tx_dma_settings);
+
+EXPORT_SYMBOL(hipox_dma_device_set_sg);
+EXPORT_SYMBOL(hipox_dma_alloc_sg_entries);
+EXPORT_SYMBOL(hipox_dma_device_set_prd);
+EXPORT_SYMBOL(hipox_dma_free_sg_entries);
diff -Nurd linux-2.6.24.orig//drivers/ata/Kconfig linux-2.6.24/drivers/ata/Kconfig
--- linux-2.6.24.orig//drivers/ata/Kconfig	2009-08-20 08:10:53.000000000 +0200
+++ linux-2.6.24/drivers/ata/Kconfig	2009-08-20 08:17:17.000000000 +0200
@@ -190,7 +190,7 @@
 	  This option enables support for the 924 based sata core
 
 config SATA_OX810
-	bool "Oxford Semiconductor OX810 SATA support"
+	tristate "Oxford Semiconductor OX810 SATA support"
 	depends on ARCH_HIPOX && HIPOX_VERSION_0X810
 	default n
 	help
diff -Nurd linux-2.6.24.orig//drivers/ata/ox810sata.c linux-2.6.24/drivers/ata/ox810sata.c
--- linux-2.6.24.orig//drivers/ata/ox810sata.c	2009-08-20 08:10:53.000000000 +0200
+++ linux-2.6.24/drivers/ata/ox810sata.c	2009-08-20 08:17:17.000000000 +0200
@@ -52,7 +52,7 @@
 //#define SATA_DUMP_REGS
 //#define SATA_TF_DUMP
 //#define DEBUG_EOT_FAILURE
-#define ERROR_INJECTION
+//#define ERROR_INJECTION
 
 #define CRAZY_DUMP_DEBUG
 #if 0
@@ -192,6 +192,7 @@
     .error_inject = 0,
     .hw_raid_active = 0,
     .active_port = 0,
+    .spot_the_end_q = NULL,
 };
 
 /** If we were writing this in C++ then we would be deriving a subclass of 
@@ -274,7 +275,7 @@
 
 /**************************************************************************/
 MODULE_LICENSE("GPL");
-MODULE_VERSION(1.0);
+MODULE_VERSION("1.0");
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 
@@ -386,7 +387,11 @@
     }
 
     /* initialise a work queue to spot the end of transfers */
+	if(!ox810sata_driver.spot_the_end_q)
+	{
     ox810sata_driver.spot_the_end_q = create_singlethread_workqueue("sata-endQ");
+	}
+
     if (!ox810sata_driver.spot_the_end_q) {
         printk(KERN_ERR DRIVER_NAME " Couldn't create a work queue.\n");
         return -1;
@@ -416,6 +421,7 @@
     if (!host) {
         printk(KERN_ERR DRIVER_NAME " Couldn't create an ata host.\n");
         destroy_workqueue(ox810sata_driver.spot_the_end_q);
+        ox810sata_driver.spot_the_end_q = NULL;
     }
 
     /* set to base of ata core */
@@ -447,10 +453,19 @@
 
     // Disable the clock to the SATA block
     writel(1UL << SYS_CTRL_CKEN_SATA_BIT, SYS_CTRL_CKEN_CLR_CTRL);
+
+    if(ox810sata_driver.spot_the_end_q)
+    {
+        destroy_workqueue(ox810sata_driver.spot_the_end_q);
+        ox810sata_driver.spot_the_end_q = NULL;
+    }
     
     return 0;
 }
 
+static int ox810sata_device_init(void);
+static void ox810sata_device_exit(void);
+
 /** 
  * module initialisation
  * @return success
@@ -461,6 +476,9 @@
     
     ret = platform_driver_register( &ox810sata_driver.driver );
     DPRINTK(" %i\n", ret);    
+
+    if(ret)
+        return ret;
     
 #ifdef ERROR_INJECTION
 {
@@ -473,6 +491,9 @@
     //create_proc_read_entry("ox810sata_errorinject", 0, NULL, ox810sata_error_inject_show, NULL);
 }   
 #endif
+
+    ret = ox810sata_device_init();
+
     return ret; 
 }
 
@@ -481,6 +502,8 @@
  */
 static void __exit ox810sata_exit( void )
 {
+    ox810sata_device_exit();
+
     platform_driver_unregister( &ox810sata_driver.driver );
 }
 
@@ -1578,6 +1601,13 @@
 		pd->sg_entries = 0;
 	}
 
+	if(ap->prd)
+	{
+		struct device* pdev = ap->host->dev;
+
+		dma_free_coherent(pdev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
+	}
+
     kfree(pd);
 }
 
@@ -2233,6 +2263,10 @@
     },
 };
 
+static void ox810_device_release(struct device *dev)
+{
+}
+
 static struct platform_device ox810sata_dev0 = 
 {
     .name = DRIVER_NAME,
@@ -2240,6 +2274,7 @@
     .num_resources = 2,
 	.resource  = ox810sata_port0_resources,
     .dev.coherent_dma_mask = 0xffffffff,
+    .dev.release = ox810_device_release,
 }; 
 
 static struct platform_device ox810sata_dev1 = 
@@ -2249,13 +2284,14 @@
     .num_resources = 2,
 	.resource  = ox810sata_port1_resources,
     .dev.coherent_dma_mask = 0xffffffff,
+    .dev.release = ox810_device_release,
 }; 
 
 /** 
  * module initialisation
  * @return success is 0
  */
-static int __init ox810sata_device_init( void )
+static int ox810sata_device_init( void )
 {
     int ret;
 
@@ -2282,10 +2318,12 @@
 /** 
  * module cleanup
  */
-static void __exit ox810sata_device_exit(void)
+static void ox810sata_device_exit(void)
 {
-    platform_device_unregister( &ox810sata_dev0 );
+#ifndef CONFIG_OX810SATA_SINGLE_SATA
     platform_device_unregister( &ox810sata_dev1 );
+#endif /* CONFIG_OX810_SINGLE_SATA */
+    platform_device_unregister( &ox810sata_dev0 );
 }
 
 /**
@@ -2413,11 +2451,3 @@
 }
 
 #endif /* ERROR_INJECTION */
-
-
-
-/** 
- * macros to register intiialisation and exit functions with kernal
- */
-module_init(ox810sata_device_init);
-module_exit(ox810sata_device_exit);