summaryrefslogtreecommitdiff
path: root/multitech/recipes/multitech/mts-io/mts-io-pcieh5.patch
blob: 15a1e281ba1aa13e5b86d9c084ecde5b4e4bc208 (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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
Index: io-module/mts_io.c
===================================================================
--- io-module.orig/mts_io.c
+++ io-module/mts_io.c
@@ -317,17 +317,19 @@ static struct gpio_pin gpio_pins_mt100eo
 		.output_value = 1,
 		.use_pullup = 0,
 	},
+	// MTPCIE-H5: Wifi and BT enable pins 
+	// (was TXD1 and DTR1) (PB17 and PB7 are tied together)
 	{
-		.name = "TXD1",
-		.pin = AT91_PIN_PB17,
-		.direction = GPIO_DIR_INPUT,
+		.name = "WLAN_EN",
+		.pin = AT91_PIN_PB7,
+		.direction = GPIO_DIR_OUTPUT,
 		.output_value = 0,
 		.use_pullup = 0,
 	},
 	{
-		.name = "DTR1",
+		.name = "BT_EN",
 		.pin = AT91_PIN_PB18,
-		.direction = GPIO_DIR_INPUT,
+		.direction = GPIO_DIR_OUTPUT,
 		.output_value = 0,
 		.use_pullup = 0,
 	},
@@ -338,6 +340,8 @@ static struct gpio_pin gpio_pins_mt100eo
 		.output_value = 1,
 		.use_pullup = 0,
 	},
+	// PCIE-H5 GPIO11 used for WLAN_IRQ
+#if 0
 	{
 		.name = "GPIO11",
 		.pin = AT91_PIN_PB19,
@@ -345,6 +349,7 @@ static struct gpio_pin gpio_pins_mt100eo
 		.output_value = 1,
 		.use_pullup = 1,
 	},
+#endif
 	{
 		.name = "GPIO12",
 		.pin = AT91_PIN_PB20,
@@ -400,6 +405,13 @@ static int mts_id_eeprom_load(void)
 		mts_product_id = MTCDP_E1_DK_1_0;
 	}
 
+	// PCIE-H5 hard-coded to EOCG
+	gpio_pins = gpio_pins_mt100eocg_0_0;
+	mts_product_id = MT100EOCG_0_0;
+	DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GPS);
+	DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DIN);
+	DEVICE_CAPA_SET(id_eeprom.capa, CAPA_DOUT);
+
 	log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout));
 	log_info("vendor-id: %.32s", id_eeprom.vendor_id);
 	log_info("product-id: %.32s",  id_eeprom.product_id);
@@ -1976,6 +1988,100 @@ static ssize_t mts_attr_store_cd(struct 
 	return count;
 }
 
+static ssize_t mts_attr_show_bt_enabled(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int value;
+	struct gpio_pin *pin = gpio_pin_by_name("BT_EN");
+
+	if (!pin) {
+		return -ENODEV;
+	}
+
+	mutex_lock(&mts_io_mutex);
+
+	value = at91_get_gpio_value(pin->pin);
+
+	mutex_unlock(&mts_io_mutex);
+
+	if (value < 0) {
+		return value;
+	}
+
+	return sprintf(buf, "%d\n", value);
+}
+
+static ssize_t mts_attr_store_bt_enabled(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	int value;
+	int err;
+	struct gpio_pin *pin = gpio_pin_by_name("BT_EN");
+
+	if (!pin) {
+		return -ENODEV;
+	}
+
+	if (sscanf(buf, "%i", &value) != 1) {
+		return -EINVAL;
+	}
+
+	mutex_lock(&mts_io_mutex);
+
+	err = at91_set_gpio_value(pin->pin, value);
+
+	mutex_unlock(&mts_io_mutex);
+
+	return count;
+}
+
+static ssize_t mts_attr_show_wlan_enabled(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	int value;
+	struct gpio_pin *pin = gpio_pin_by_name("WLAN_EN");
+
+	if (!pin) {
+		return -ENODEV;
+	}
+
+	mutex_lock(&mts_io_mutex);
+
+	value = at91_get_gpio_value(pin->pin);
+
+	mutex_unlock(&mts_io_mutex);
+
+	if (value < 0) {
+		return value;
+	}
+
+	return sprintf(buf, "%d\n", value);
+}
+
+static ssize_t mts_attr_store_wlan_enabled(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	int value;
+	int err;
+	struct gpio_pin *pin = gpio_pin_by_name("WLAN_EN");
+
+	if (!pin) {
+		return -ENODEV;
+	}
+
+	if (sscanf(buf, "%i", &value) != 1) {
+		return -EINVAL;
+	}
+
+	mutex_lock(&mts_io_mutex);
+
+	err = at91_set_gpio_value(pin->pin, value);
+
+	mutex_unlock(&mts_io_mutex);
+
+	return count;
+}
+
 
 static struct device_attribute dev_attr_gpo1 = {
 	.attr = {
@@ -2137,6 +2243,24 @@ static struct device_attribute dev_attr_
 	.store = mts_attr_store_gpio12,
 };
 
+static struct device_attribute dev_attr_bt_enabled = {
+	.attr = {
+		.name = "bt-enabled",
+		.mode = MTS_ATTR_MODE_RW,
+	},
+	.show = mts_attr_show_bt_enabled,
+	.store = mts_attr_store_bt_enabled,
+};
+
+static struct device_attribute dev_attr_wlan_enabled = {
+	.attr = {
+		.name = "wlan-enabled",
+		.mode = MTS_ATTR_MODE_RW,
+	},
+	.show = mts_attr_show_wlan_enabled,
+	.store = mts_attr_store_wlan_enabled,
+};
+
 static struct device_attribute dev_attr_rsersrc = {
 	.attr = {
 		.name = "rsersrc",
@@ -2157,13 +2281,13 @@ static struct device_attribute dev_attr_
 
 
 static struct attribute *mt100eocg_platform_attributes[] = {
-	&dev_attr_extserial_dtr.attr,
 	&dev_attr_extserial_cd.attr,
 	&dev_attr_rsersrc.attr,
 	&dev_attr_radio_reset.attr,
 	&dev_attr_eth0_enabled.attr,
-	&dev_attr_gpio11.attr,
 	&dev_attr_gpio12.attr,
+	&dev_attr_bt_enabled.attr,
+	&dev_attr_wlan_enabled.attr,
 
 	&dev_attr_gpo1.attr,
 	&dev_attr_gpo2.attr,
@@ -2323,7 +2447,7 @@ static int __devinit mts_spi_dout_probe(
 		return tmp;
 	}
 
-	spi_dout_value = 0x00;
+	spi_dout_value = 0xFF;	// 0x00;
 	spi_writen(spi, &spi_dout_value, 1);
 
 	spi_dout_dev = spi;
@@ -2521,11 +2645,14 @@ static int __init mts_io_init(void)
 
 	if ( mts_product_id == MT100EOCG_0_0 ) {
 		//Set open drain for GPIO11 and GPIO12 using multi drive
+	// PCIE-H5 GPIO11 used for WLAN_IRQ
+#if 0
 		pin = gpio_pin_by_name("GPIO11");
 		if (pin) {
 			log_info("Set open drain for GPIO11");
 			at91_set_multi_drive(pin->pin, true);
 		}
+#endif
 		pin = gpio_pin_by_name("GPIO12");
 		if (pin) {
 			log_info("Set open drain for GPIO12");