summaryrefslogtreecommitdiff
path: root/packages/mamona/cx3110x-770he-0.8.1/fix_mem_allign.patch
blob: 6c452196aa7a015d3c44663c6c58e8abddceb325 (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
Index: cx3110x-0.8.1/src/sm_drv_spi_io.c
===================================================================
--- cx3110x-0.8.1.orig/src/sm_drv_spi_io.c	2008-04-22 14:54:42.000000000 -0300
+++ cx3110x-0.8.1/src/sm_drv_spi_io.c	2008-04-22 15:00:07.000000000 -0300
@@ -240,18 +240,21 @@
 	omap_start_dma(spi_dma.dma_tx_ch);
 
 	/* We don't want to turn CS off before transfer is done */
-	
+
+        while(!spi_dma.dma_rx_done) {
+                udelay(5);
+        }
+
 	while(!spi_dma.dma_tx_done) {
 		udelay(5);
 	}
 
+	spi_dma.dma_rx_done = 0;
 	spi_dma.dma_tx_done = 0;
 
 	/* UMAC may send us odd number of bytes long frames */
 	if (length % 2) {
-		u16 last_word;
-		
-		last_word = *(uint16_t *)(buffer + length - 1);		
+		u16 last_word = *((uint8_t *)buffer + length - 1);
 		omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, last_word);
 	}
 
@@ -264,7 +267,6 @@
 int cx3110x_spi_read(struct net_device *dev, unsigned long address, unsigned char * buffer, unsigned int length)
 {
 	int i;
-	u16 * short_buffer = (u16 *) buffer;
 	unsigned int r_length = length >> 1;
 
 	DEBUG(DBG_SPI_IO, "omap_wlan_spi_read\n");
@@ -274,8 +276,13 @@
 	omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, 
 				      (address << 8) | ADDR_READ_BIT_15);
 
-	for (i = 0 ; i < r_length ; i++)
-		omap_mcbsp_spi_master_recv_word_poll(OMAP_MCBSP2, (u32*)(short_buffer + i));
+        for (i = 0 ; i < r_length ; i++) {
+                u32 tmp;
+                omap_mcbsp_spi_master_recv_word_poll(OMAP_MCBSP2, &tmp);
+                /* Assume little endian byte order */
+                buffer[i * 2 + 0] = tmp & 0xFF;
+                buffer[i * 2 + 1] = (tmp >> 8) & 0xFF;
+        }
 
 	SPI_CS_OFF();
 	return 0;
@@ -285,24 +292,22 @@
 int cx3110x_spi_write(struct net_device *dev, unsigned long address, unsigned char * buffer, unsigned int length)
 {
 	int i;
-	u16 * short_buffer = (u16 *) buffer;
 	unsigned int w_length = length >> 1;
 
-
 	DEBUG(DBG_SPI_IO, "omap_wlan_spi_write (%d bytes @ 0x%lx)\n", length, address << 8);
 
 	SPI_CS_ON();
 
 	omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, address << 8);
 	
-	for (i = 0 ; i < w_length ; i++)
-		omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, short_buffer[i]); 
+        for (i = 0 ; i < w_length ; i++) {
+                /* Assume little endian byte order */
+                omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, (u32)buffer[i * 2] | ((u32)buffer[i * 2 + 1] << 8));
+        }
 
 	/* UMAC may send us odd number of bytes long frames */
 	if (length % 2) {
-		u16 last_word;
-
-		last_word = buffer[length - 1];
+                u16 last_word = buffer[length - 1];
 		omap_mcbsp_spi_master_xmit_word_poll(OMAP_MCBSP2, last_word); 
 	}
 
@@ -366,6 +371,9 @@
 	while(rate_mhz/div >= max_mhz)
 		div++;
 		
+        printk("McBSP2: freq_limit=%dMHz, base_freq=%dMHz, divisor=%d (%d.%dMHz)\n",
+                max_mhz, rate_mhz, div, rate_mhz / div, (rate_mhz * 10 / div) % 10);
+
 	spi_dma.dma_tx_done = 0;
 	spi_dma.dma_rx_done = 0;