ccdb57930692d4c952aa7c62eca1d5fef501e4d0
[openwrt.git] / target / linux / at91 / patches-2.6.21 / 016-v1-15-detect.patch
1 Index: linux-2.6.21.7/arch/arm/mach-at91/at91rm9200_devices.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/arch/arm/mach-at91/at91rm9200_devices.c
4 +++ linux-2.6.21.7/arch/arm/mach-at91/at91rm9200_devices.c
5 @@ -840,9 +840,9 @@ static inline void configure_usart3_pins
6         at91_set_B_periph(AT91_PIN_PA6, 0);             /* RXD3 */
7         at91_set_B_periph(AT91_PIN_PB0, 0);   /* RTS3 */
8         at91_set_B_periph(AT91_PIN_PB1, 0);   /* CTS3 */
9 -       at91_set_gpio_output(AT91_PIN_PB29, 1); /* DTR0 */
10 -       at91_set_gpio_output(AT91_PIN_PB2, 1);  /* RI0 */
11 -       at91_set_gpio_input(AT91_PIN_PA24, 1);  /* DCD0 */
12 +       at91_set_gpio_output(AT91_PIN_PB29, 1); /* DTR3 */
13 +       at91_set_gpio_output(AT91_PIN_PB2, 1);  /* RI3 */
14 +       at91_set_gpio_input(AT91_PIN_PA24, 1);  /* DCD3 */
15         at91_set_deglitch(AT91_PIN_PA24, 1);
16  }
17  
18 Index: linux-2.6.21.7/arch/arm/mach-at91/board-vlink.c
19 ===================================================================
20 --- linux-2.6.21.7.orig/arch/arm/mach-at91/board-vlink.c
21 +++ linux-2.6.21.7/arch/arm/mach-at91/board-vlink.c
22 @@ -126,6 +126,7 @@ static struct spi_board_info vlink_spi_d
23  
24  static void __init vlink_board_init(void)
25  {
26 +       int v100;
27         /* Serial */
28         at91_add_device_serial();
29         /* Ethernet */
30 @@ -147,6 +148,10 @@ static void __init vlink_board_init(void
31  //     at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
32         at91_add_device_mmc(0, &vlink_mmc_data);
33  #endif
34 +// Set VLink version PIN as an input with pull up (V1.5 = GND)
35 +       at91_set_gpio_input(AT91_PIN_PC2, 1);  
36 +       v100 = at91_get_gpio_value(AT91_PIN_PC2);
37 +
38         /* LEDs */
39  //     at91_gpio_leds(vlink_leds, ARRAY_SIZE(vlink_leds));
40  
41 @@ -164,10 +169,16 @@ static void __init vlink_board_init(void
42         /* SIM Cards */
43         if (at91_get_gpio_value(AT91_PIN_PB8)) {
44                 at91_set_gpio_output(AT91_PIN_PB11, 0);
45 -               at91_set_gpio_output(AT91_PIN_PB9, 1);
46 +               if (v100)
47 +                       at91_set_gpio_output(AT91_PIN_PB9, 1);
48 +               else
49 +                       at91_set_gpio_output(AT91_PIN_PC13, 1);
50         } else {
51                 at91_set_gpio_output(AT91_PIN_PB11, 1);
52 -               at91_set_gpio_output(AT91_PIN_PB9, 0);
53 +               if (v100)
54 +                       at91_set_gpio_output(AT91_PIN_PB9, 0);
55 +               else
56 +                       at91_set_gpio_output(AT91_PIN_PC13, 0);
57         }
58  
59         at91_set_gpio_output(AT91_PIN_PB10, 1); // ENBSC2
60 @@ -182,7 +193,18 @@ static void __init vlink_board_init(void
61         at91_set_gpio_input(AT91_PIN_PB27, 1);  // UDB_CNX
62         at91_set_gpio_output(AT91_PIN_PB28, 1); // UDB_PUP
63         at91_set_multi_drive(AT91_PIN_PB28, 1); // Set to multi-drive
64 -
65 +       
66 +       if (v100)
67 +       {       // V100
68 +               at91_set_gpio_input (AT91_PIN_PC12, 1);   // SD Card present
69 +       }
70 +       else
71 +       {       // DO special things for V1.5
72 +               at91_set_gpio_output(AT91_PIN_PB9 , 0);   // USB suspend
73 +               at91_set_gpio_input (AT91_PIN_PC10, 1);   // SD Card present
74 +               at91_set_gpio_output(AT91_PIN_PC11, 0);   // USB Vin CTRL for modules onboard 
75 +               at91_set_gpio_output(AT91_PIN_PC12, 0);   // SIM control 
76 +       }
77  }
78  
79  MACHINE_START(VLINK, "FDL VersaLink")
80 Index: linux-2.6.21.7/drivers/char/vlink_giu.c
81 ===================================================================
82 --- linux-2.6.21.7.orig/drivers/char/vlink_giu.c
83 +++ linux-2.6.21.7/drivers/char/vlink_giu.c
84 @@ -41,8 +41,7 @@ static int major;     /* default is dynamic 
85  module_param(major, int, 0);
86  MODULE_PARM_DESC(major, "Major device number");
87  
88 -#define VIO_NR_DEVS 96
89 -
90 +#define VIO_NR_DEVS   96
91  struct vio_dev {
92         struct cdev cdev;
93  };
94 @@ -50,6 +49,53 @@ struct vio_dev {
95  struct vio_dev *vio_devices;
96  static struct class *vio_class;
97  
98 +// KWJ + AJE
99 +#define MAX_VIO_NAMES 24
100 +typedef struct
101 +{
102 +       char port;
103 +       char pin;
104 +       char name100[10];
105 +       char name150[10];
106 +} VIO_NAMES;
107 +
108 +VIO_NAMES VioName[MAX_VIO_NAMES] = {  //Port,PIN, V100     , V150
109 +                                                                               {'A',19,"port1DTR" ,"port1DTR"},
110 +                                                                               {'A',24,"port2DTR" ,"port2DTR"},
111 +                                                                               {'B',8, "jigOn"    ,"jigOn"} ,
112 +                                                                               {'B',9, "enbSC3"   ,"usbSUSPND"},
113 +                                                                               {'B',10,"enbSC2"   ,"enbSC2"},
114 +                                                                               {'B',11,"enbSC1"   ,"enbSC1"},
115 +                                                                               {'B',12,"gsmONOFF" ,"gsmONOFF"},
116 +                                                                               {'B',14,"ledBAP1"  ,"ledBAP1"},
117 +                                                                               {'B',15,"ledBBP1"  ,"ledBBP1"},
118 +                                                                               {'B',16,"ledBAP2"  ,"ledBAP2"},
119 +                                                                               {'B',17,"ledBBP2"  ,"ledBBP2"},
120 +                                                                               {'B',27,"udpCNX"   ,"udpCNX"},
121 +                                                                               {'B',28,"udpPUP"   ,"udpPUP"},
122 +                                                                               {'B',29,"port2DCD" ,"port2DCD"},
123 +                                                                               {'C',2, "vlVer100" ,"vlVer150"},
124 +                                                                               {'C',7, "ledFAP1"  ,"ledFAP1"},
125 +                                                                               {'C',8, "ledFBP1"  ,"ledFBP1"},
126 +                                                                               {'C',10,"vioC10"   ,"sdCardON"},
127 +                                                                               {'C',11,"vioC11"   ,"vusbCTRL"},
128 +                                                                               {'C',12,"sdCardON" ,"simCTRL"},
129 +                                                                               {'C',13,"vioC13"   ,"enbSC3"},
130 +                                                                               {'C',14,"ledFBP2"  ,"ledFBP2"},
131 +                                                                               {'C',15,"ledFAP2"  ,"ledFAP2"},
132 +                                                                               {0,0,"",""}
133 +                                                                  };
134 +/*                                                                             {'B',18,"gsmRIO"  ,"gsmRIO"},
135 +                                                                               {'B',20,"gsmTX"   ,"gsmTX"},
136 +                                                                               {'B',21,"gsmRX"   ,"gsmRX"},
137 +                                                                               {'B',22,"gsmPIND" ,"gsmPIND"},
138 +                                                                               {'B',23,"gsmDCD"  ,"gsmDCD"},
139 +                                                                               {'B',24,"gsmCTS"  ,"gsmCTS"},
140 +                                                                               {'B',25,"gsmDSR"  ,"gsmDSR"},
141 +                                                                               {'B',26,"gsmRTS"  ,"gsmRTS"},*/
142 +static void lookupPINName(char version100, char *devName, char port, char pin);
143 +// EOF KWJ + AJE
144 +
145  static ssize_t gpio_read(struct file *file, char __user *buf, size_t len,
146                           loff_t *ppos)
147  {
148 @@ -160,6 +206,8 @@ static int vio_probe(struct platform_dev
149  {
150         int retval, i, j;
151         dev_t vdev = 0;
152 +       char devName[30];
153 +       int  vlinkV100;
154  
155         if (major) {
156                 vdev = MKDEV(major, 0);
157 @@ -185,6 +233,7 @@ static int vio_probe(struct platform_dev
158                 vio_remove(dev);
159                 return PTR_ERR(vio_class);
160         }
161 +    vlinkV100 = at91_get_gpio_value(AT91_PIN_PC2);             // Denotes V1.5 if ground
162  
163         vio_devices = kmalloc(VIO_NR_DEVS * sizeof(struct vio_dev), GFP_KERNEL);
164         if (!vio_devices) {
165 @@ -198,8 +247,10 @@ static int vio_probe(struct platform_dev
166                         int iodev = at91_is_pin_gpio(PIN_BASE + i*32 + j);
167                         if (iodev) {
168                                 vio_setup_cdev(&vio_devices[i*32 + j], i*32 + j);
169 -                               class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL,
170 -                                       "vio%c%d", i + 'A', j);
171 +                               // Lookup name of vio to create
172 +                               lookupPINName(vlinkV100, devName, i, j);
173 +                               class_device_create(vio_class, NULL, MKDEV(major, i*32 + j), NULL, devName);
174 +//                                     "vio%c%d", i + 'A', j);
175                         }
176                 }
177  
178 @@ -212,6 +263,29 @@ fail:
179         return retval;
180  }
181  
182 +static void lookupPINName(char version100, char *devName, char port, char pin)
183 +{
184 +       int i = -1;
185 +       char found = 0;
186 +       while (!found)
187 +       {
188 +               i++;
189 +               if (i >= MAX_VIO_NAMES)
190 +                       break;
191 +               if (VioName[i].port == port+'A' && VioName[i].pin == pin)
192 +               {
193 +                       printk(KERN_ERR "vio++: %c%d=%s\n",VioName[i].port,VioName[i].pin,VioName[i].name150);
194 +                       if (version100)
195 +                               strcpy(devName, VioName[i].name100);
196 +                       else
197 +                               strcpy(devName, VioName[i].name150);
198 +                       found = 1;
199 +               }
200 +       }
201 +       if (!found)
202 +               sprintf(devName, "vio%c%d", port + 'A', pin);
203 +}
204 +
205  static struct platform_device *vio_platform_device;
206  
207  static struct platform_driver vio_driver = {