summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mtac-mfser/serial-enable-tx-enable.patch
blob: 5fc216dbc3dac7e0e347de28e8cd933b69912b7c (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
diff --git a/mtac_mfser.c b/mtac_mfser.c
index d8548cb..fd7b0b6 100644
--- a/mtac_mfser.c
+++ b/mtac_mfser.c
@@ -1,4 +1,4 @@
-#define DRIVER_VERSION  "v1.1.1"
+#define DRIVER_VERSION  "v1.2.0"
 #define DRIVER_AUTHOR   "Multi-Tech"
 #define DRIVER_DESC "MTS Multi-Fuction Serial Accessory Card"
 #define DRIVER_NAME "mtac-mfser"
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/mtac.h>
 #include <linux/mts_io.h>
+#include <linux/mts_io_module.h>
 #ifdef TI43X
 #include <linux/ti43x_gpio.h>
 #endif
@@ -54,6 +55,86 @@ static struct gpio_pin gpio_pins_mtac_mfser[] = {
 			.label = "ap1-gpio4",
 		}
 	},
+
+	// gpio pins for Accessory Card 2
+	{
+		.name = "AP2_GPIO1",
+		.pin = {
+			.gpio = M_AP2_GPIO1,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap2-gpio1",
+		},
+		.active_low = 1,
+	},
+	{
+		.name = "AP2_GPIO2",
+		.pin = {
+			.gpio = M_AP2_GPIO2,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap2-gpio2",
+		}
+	},
+	{
+		.name = "AP2_GPIO3",
+		.pin = {
+			.gpio = M_AP2_GPIO3,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap2-gpio3",
+		}
+	},
+	{
+		.name = "AP2_GPIO4",
+		.pin = {
+			.gpio = M_AP2_GPIO4,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap2-gpio4",
+		}
+	},
+        { },
+};
+static struct gpio_pin gpio_pins_mtac_mfser_RI[] = {
+	// gpio pins for Accessory Card 1
+	{
+		.name = "AP1_GPIO1",
+		.pin = {
+			.gpio = M_AP1_GPIO1,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap1-gpio1",
+		},
+		.active_low = 1,
+	},
+	{
+		.name = "AP1_GPIO2",
+		.pin = {
+			.gpio = M_AP1_GPIO2,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap1-gpio2",
+		}
+	},
+	{
+		.name = "AP1_GPIO3",
+		.pin = {
+			.gpio = M_AP1_GPIO3,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap1-gpio3",
+		}
+	},
+	{
+		.name = "AP1_GPIO4",
+		.pin = {
+			.gpio = M_AP1_GPIO4,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap1-gpio4",
+		}
+	},
+	{  // MTCDT-0.2 only
+		.name = "AP1_ENABLE_TX_ENABLE",
+		.pin = {
+			.gpio = AT91_PIN_PC31,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap1-enable-tx-enable",
+		}
+	},
 	
 
 	// gpio pins for Accessory Card 2
@@ -90,7 +171,15 @@ static struct gpio_pin gpio_pins_mtac_mfser[] = {
 			.label = "ap2-gpio4",
 		}
 	},
-	{ },
+	{  // MTCDT-0.2 only
+		.name = "AP2_ENABLE_TX_ENABLE",
+		.pin = {
+			.gpio = AT91_PIN_PC30,
+			.flags = GPIOF_OUT_INIT_LOW,
+			.label = "ap2-enable-tx-enable",
+		}
+	},
+        { },
 };
 
 static char* mfser_gpio_pin_name_by_attr_name(const char* name, int port) {
@@ -251,8 +340,9 @@ static ssize_t mts_attr_store_mfser_mode(struct kobject *kobj,
 // 1 product-id
 // 1 device-id
 // 1 hw-version
+// 1 enable_tx_enable
 // NULL
-static size_t ap_mfser_attrs_size = 8;
+static size_t ap_mfser_attrs_size = 9;
 
 static bool mfser_setup(enum ap port) {
 	int i;
@@ -264,6 +354,7 @@ static bool mfser_setup(enum ap port) {
 	struct kobj_attribute* attr;
 	struct attribute **attrs;
 	struct kobject *subdir;
+        char *tmp;
 
 	log_info("loading MFSER accessory card in port %d", port);
 
@@ -273,8 +364,10 @@ static bool mfser_setup(enum ap port) {
 		log_error("kobject_create_and_add for MFSER in port %d failed", port);
 		return false;
 	}
-
-	mtac_set_port_pins(port_index,gpio_pins_mtac_mfser,subdir);
+        if ((tmp=HW_VERSION_MTCDT_0_2),strncmp(mts_get_hw_version(), tmp, strlen(tmp)) == 0)
+            mtac_set_port_pins(port_index,gpio_pins_mtac_mfser_RI,subdir);
+        else
+            mtac_set_port_pins(port_index,gpio_pins_mtac_mfser,subdir);
 
 	// create the link to the apX directory this card is in
 	// if we're in the first slot, we get plain "mfser"
@@ -334,6 +427,18 @@ static bool mfser_setup(enum ap port) {
 	attr->store = mtac_attr_store_ap_gpio_pin;
 	attrs[index++] = &attr->attr;
 
+        if ((tmp=HW_VERSION_MTCDT_0_2),strncmp(mts_get_hw_version(), tmp, strlen(tmp)) == 0) {
+            sprintf(buf, "enable-tx-enable");
+            attr = mtac_create_attribute(buf, MTS_ATTR_MODE_RW);
+            if (! attr) {
+                    log_error("failed to create attribute [%s] for MFSER in port %d", buf, port);
+                    return false;
+            }
+            attr->show = mtac_attr_show_ap_gpio_pin;
+            attr->store = mtac_attr_store_ap_gpio_pin;
+            attrs[index++] = &attr->attr;
+        }
+
 	// add attributes for eeprom contents
 	if (! mtac_add_product_info_attributes(port, attrs, &index)) {
 		log_error("failed to add product info attributes for MFSER in port %d", port);