summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.23/patches/e680-mci.patch
blob: 73981823cf227e050045572ad39a98995075809b (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
Index: linux-2.6.23/arch/arm/mach-pxa/ezx-e680.c
===================================================================
--- linux-2.6.23.orig/arch/arm/mach-pxa/ezx-e680.c	2007-10-24 13:03:06.000000000 +0200
+++ linux-2.6.23/arch/arm/mach-pxa/ezx-e680.c	2007-10-24 18:54:35.000000000 +0200
@@ -13,6 +13,8 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/fb.h>
+#include <linux/mmc/host.h>
+#include <linux/irq.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -20,12 +22,104 @@
 #include <asm/arch/pxafb.h>
 #include <asm/arch/ezx.h>
 #include <asm/arch/ezx-pcap.h>
+#include <asm/arch/mmc.h>
 
 #include "generic.h"
 
 extern void ezx_lcd_power(int, struct fb_var_screeninfo *);
 extern void ezx_backlight_power(int);
 
+#ifdef CONFIG_EZX_PCAP
+extern int ezx_pcap_mmcsd_power(int);
+extern void ezx_pcap_mmcsd_voltage(u_int32_t);
+#else
+#define ezx_pcap_mmcsd_voltage(x) {}
+#define ezx_pcap_mmcsd_power(x) {}
+#endif
+
+static struct pxamci_platform_data e680_mci_platform_data;
+
+static u_int8_t mmc_voltage[] = {
+	[ilog2(MMC_VDD_165_195)] = 3,
+	[ilog2(MMC_VDD_20_21)] = 3,
+	[ilog2(MMC_VDD_21_22)] = 3,
+	[ilog2(MMC_VDD_22_23)] = 3,
+	[ilog2(MMC_VDD_23_24)] = 3,
+	[ilog2(MMC_VDD_24_25)] = 3,
+	[ilog2(MMC_VDD_25_26)] = 3,
+	[ilog2(MMC_VDD_26_27)] = 3,
+	[ilog2(MMC_VDD_27_28)] = 3,
+	[ilog2(MMC_VDD_28_29)] = 3,
+	[ilog2(MMC_VDD_29_30)] = 3,
+	[ilog2(MMC_VDD_30_31)] = 3,
+	[ilog2(MMC_VDD_31_32)] = 3,
+	[ilog2(MMC_VDD_32_33)] = 3,
+	[ilog2(MMC_VDD_33_34)] = 3,
+	[ilog2(MMC_VDD_34_35)] = 3,
+	[ilog2(MMC_VDD_35_36)] = 3,
+};
+
+static int e680_mci_init(struct device *dev,
+                       irqreturn_t (*ezx_detect_int)(int, void *),
+                       void *data)
+{
+       int err;
+
+       /* Setup GPIO for PXA27x MMC/SD controller */
+       pxa_gpio_mode(GPIO32_MMCCLK_MD);
+       pxa_gpio_mode(GPIO112_MMCCMD_MD);
+       pxa_gpio_mode(GPIO92_MMCDAT0_MD);
+       pxa_gpio_mode(GPIO109_MMCDAT1_MD);
+       pxa_gpio_mode(GPIO110_MMCDAT2_MD);
+       pxa_gpio_mode(GPIO111_MMCDAT3_MD);
+
+       ezx_pcap_mmcsd_power(1);
+
+       e680_mci_platform_data.detect_delay = msecs_to_jiffies(250);
+
+       err = request_irq(0x49, ezx_detect_int, IRQF_DISABLED,
+                       "MMC card detect", data);
+       if (err) {
+               printk(KERN_ERR "ezx_mci_detect: MMC/SD: can't request "
+                       "MMC card detect IRQ\n");
+               return -1;
+       }
+
+       set_irq_type(0x0b, IRQT_BOTHEDGE);
+
+       return 0;
+}
+
+
+static inline int e680_mci_get_ro(struct device *dev)
+{
+        return (GPLR3 & 0x800);
+}
+
+static void e680_mci_setpower(struct device *dev, unsigned int vdd)
+{
+	struct pxamci_platform_data* p_d = dev->platform_data;
+
+	if (( 1 << vdd) & p_d->ocr_mask)
+		ezx_pcap_mmcsd_voltage(mmc_voltage[vdd]);
+
+	ezx_pcap_mmcsd_power(1);
+}
+
+static void e680_mci_exit(struct device *dev, void *data)
+{
+	ezx_pcap_mmcsd_power(0);
+	free_irq(0x49, data);
+}
+
+static struct pxamci_platform_data e680_mci_platform_data = {
+	.ocr_mask       = MMC_VDD_27_28,
+	.init           = e680_mci_init,
+	.get_ro		= e680_mci_get_ro,
+	.setpower       = e680_mci_setpower,
+	.exit           = e680_mci_exit,
+};
+
 static struct pxafb_mode_info mode_e680 = {
 	.pixclock	= 150000,
 	.xres		= 240,
@@ -136,6 +230,7 @@
 	PSLR  = 0x05800f00;
 
 	set_pxa_fb_info(&e680_fb_info);
+	pxa_set_mci_info(&e680_mci_platform_data);
 
         /* clear EMU MUX1/MUX2 (low) to close the audio path to EMU */
 	pxa_gpio_mode(GPIO_EMU_MUX1|GPIO_OUT);