572659117aec3e9bac0b707186142f953d14666c
[openwrt.git] / target / linux / generic-2.6 / files / drivers / net / phy / ip175c.c
1 /*
2 * swconfig-ip175c.c: Swconfig configuration for IC+ IP175C switch
3 *
4 * Copyright (C) 2008 Patrick Horn <patrick.horn@gmail.com>
5 * Copyright (C) 2008 Martin Mares <mj@ucw.cz>
6 * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/list.h>
23 #include <linux/skbuff.h>
24 #include <linux/mii.h>
25 #include <linux/phy.h>
26 #include <linux/delay.h>
27 #include <linux/switch.h>
28
29 #define MAX_VLANS 16
30 #define MAX_PORTS 9
31 #undef DUMP_MII_IO
32
33 typedef struct ip175c_reg {
34 u16 p; // phy
35 u16 m; // mii
36 } reg;
37 typedef char bitnum;
38
39 #define NOTSUPPORTED {-1,-1}
40
41 #define REG_SUPP(x) (((x).m != ((u16)-1)) && ((x).p != (u16)-1))
42
43 struct ip175c_state;
44
45 /*********** CONSTANTS ***********/
46 struct register_mappings {
47 char *NAME;
48 u16 MODEL_NO; // Compare to bits 4-9 of MII register 0,3.
49 bitnum NUM_PORTS;
50 bitnum CPU_PORT;
51
52 /* The default VLAN for each port.
53 Default: 0x0001 for Ports 0,1,2,3
54 0x0002 for Ports 4,5 */
55 reg VLAN_DEFAULT_TAG_REG[MAX_PORTS];
56
57 /* These ports are tagged.
58 Default: 0x00 */
59 reg ADD_TAG_REG;
60 reg REMOVE_TAG_REG;
61 bitnum ADD_TAG_BIT[MAX_PORTS];
62 /* These ports are untagged.
63 Default: 0x00 (i.e. do not alter any VLAN tags...)
64 Maybe set to 0 if user disables VLANs. */
65 bitnum REMOVE_TAG_BIT[MAX_PORTS];
66
67 /* Port M and Port N are on the same VLAN.
68 Default: All ports on all VLANs. */
69 // Use register {29, 19+N/2}
70 reg VLAN_LOOKUP_REG;
71 // Port 5 uses register {30, 18} but same as odd bits.
72 reg VLAN_LOOKUP_REG_5; // in a different register on IP175C.
73 bitnum VLAN_LOOKUP_EVEN_BIT[MAX_PORTS];
74 bitnum VLAN_LOOKUP_ODD_BIT[MAX_PORTS];
75
76 /* This VLAN corresponds to which ports.
77 Default: 0x2f,0x30,0x3f,0x3f... */
78 reg TAG_VLAN_MASK_REG;
79 bitnum TAG_VLAN_MASK_EVEN_BIT[MAX_PORTS];
80 bitnum TAG_VLAN_MASK_ODD_BIT[MAX_PORTS];
81
82 int RESET_VAL;
83 reg RESET_REG;
84
85 reg MODE_REG;
86 int MODE_VAL;
87
88 /* General flags */
89 reg ROUTER_CONTROL_REG;
90 reg VLAN_CONTROL_REG;
91 bitnum TAG_VLAN_BIT;
92 bitnum ROUTER_EN_BIT;
93 bitnum NUMLAN_GROUPS_MAX;
94 bitnum NUMLAN_GROUPS_BIT;
95
96 reg MII_REGISTER_EN;
97 bitnum MII_REGISTER_EN_BIT;
98
99 // set to 1 for 178C, 0 for 175C.
100 bitnum SIMPLE_VLAN_REGISTERS; // 175C has two vlans per register but 178C has only one.
101
102 // Pointers to functions which manipulate hardware state
103 int (*get_flags)(struct ip175c_state *state);
104 int (*get_state)(struct ip175c_state *state);
105 int (*update_state)(struct ip175c_state *state);
106 int (*set_vlan_mode)(struct ip175c_state *state);
107 int (*reset)(struct ip175c_state *state);
108 };
109
110 static int ip175c_get_flags(struct ip175c_state *state);
111 static int ip175c_get_state(struct ip175c_state *state);
112 static int ip175c_update_state(struct ip175c_state *state);
113 static int ip175c_set_vlan_mode(struct ip175c_state *state);
114 static int ip175c_do_reset(struct ip175c_state *state);
115
116 static const struct register_mappings IP178C = {
117 .NAME = "IP178C",
118 .MODEL_NO = 0x18,
119 .VLAN_DEFAULT_TAG_REG = {
120 {30,3},{30,4},{30,5},{30,6},{30,7},{30,8},
121 {30,9},{30,10},{30,11},
122 },
123
124 .ADD_TAG_REG = {30,12},
125 .ADD_TAG_BIT = {0,1,2,3,4,5,6,7,8},
126 .REMOVE_TAG_REG = {30,13},
127 .REMOVE_TAG_BIT = {4,5,6,7,8,9,10,11,12},
128
129 .SIMPLE_VLAN_REGISTERS = 1,
130
131 .VLAN_LOOKUP_REG = {31,0},// +N
132 .VLAN_LOOKUP_REG_5 = NOTSUPPORTED, // not used with SIMPLE_VLAN_REGISTERS
133 .VLAN_LOOKUP_EVEN_BIT = {0,1,2,3,4,5,6,7,8},
134 .VLAN_LOOKUP_ODD_BIT = {0,1,2,3,4,5,6,7,8},
135
136 .TAG_VLAN_MASK_REG = {30,14}, // +N
137 .TAG_VLAN_MASK_EVEN_BIT = {0,1,2,3,4,5,6,7,8},
138 .TAG_VLAN_MASK_ODD_BIT = {0,1,2,3,4,5,6,7,8},
139
140 .RESET_VAL = 0x55AA,
141 .RESET_REG = {30,0},
142 .MODE_VAL = 0,
143 .MODE_REG = NOTSUPPORTED,
144
145 .ROUTER_CONTROL_REG = {30,30},
146 .ROUTER_EN_BIT = 11,
147 .NUMLAN_GROUPS_MAX = 8,
148 .NUMLAN_GROUPS_BIT = 8, // {0-2}
149
150 .VLAN_CONTROL_REG = {30,13},
151 .TAG_VLAN_BIT = 3,
152
153 .CPU_PORT = 8,
154 .NUM_PORTS = 9,
155
156 .MII_REGISTER_EN = NOTSUPPORTED,
157
158 .get_flags = ip175c_get_flags,
159 .get_state = ip175c_get_state,
160 .update_state = ip175c_update_state,
161 .set_vlan_mode = ip175c_set_vlan_mode,
162 .reset = ip175c_do_reset,
163 };
164
165 static const struct register_mappings IP175C = {
166 .NAME = "IP175C",
167 .MODEL_NO = 0x18,
168 .VLAN_DEFAULT_TAG_REG = {
169 {29,24},{29,25},{29,26},{29,27},{29,28},{29,30},
170 NOTSUPPORTED,NOTSUPPORTED,NOTSUPPORTED
171 },
172
173 .ADD_TAG_REG = {29,23},
174 .REMOVE_TAG_REG = {29,23},
175 .ADD_TAG_BIT = {11,12,13,14,15,1,-1,-1,-1},
176 .REMOVE_TAG_BIT = {6,7,8,9,10,0,-1,-1,-1},
177
178 .SIMPLE_VLAN_REGISTERS = 0,
179
180 .VLAN_LOOKUP_REG = {29,19},// +N/2
181 .VLAN_LOOKUP_REG_5 = {30,18},
182 .VLAN_LOOKUP_EVEN_BIT = {8,9,10,11,12,15,-1,-1,-1},
183 .VLAN_LOOKUP_ODD_BIT = {0,1,2,3,4,7,-1,-1,-1},
184
185 .TAG_VLAN_MASK_REG = {30,1}, // +N/2
186 .TAG_VLAN_MASK_EVEN_BIT = {0,1,2,3,4,5,-1,-1,-1},
187 .TAG_VLAN_MASK_ODD_BIT = {8,9,10,11,12,13,-1,-1,-1},
188
189 .RESET_VAL = 0x175C,
190 .RESET_REG = {30,0},
191 .MODE_VAL = 0x175C,
192 .MODE_REG = {29,31},
193
194 .ROUTER_CONTROL_REG = {30,9},
195 .ROUTER_EN_BIT = 3,
196 .NUMLAN_GROUPS_MAX = 8,
197 .NUMLAN_GROUPS_BIT = 0, // {0-2}
198
199 .VLAN_CONTROL_REG = {30,9},
200 .TAG_VLAN_BIT = 7,
201
202 .NUM_PORTS = 6,
203 .CPU_PORT = 5,
204
205 .MII_REGISTER_EN = NOTSUPPORTED,
206
207 .get_flags = ip175c_get_flags,
208 .get_state = ip175c_get_state,
209 .update_state = ip175c_update_state,
210 .set_vlan_mode = ip175c_set_vlan_mode,
211 .reset = ip175c_do_reset,
212 };
213
214 static const struct register_mappings IP175A = {
215 .NAME = "IP175A",
216 .MODEL_NO = 0x05,
217 .VLAN_DEFAULT_TAG_REG = {
218 {0,24},{0,25},{0,26},{0,27},{0,28},NOTSUPPORTED,
219 NOTSUPPORTED,NOTSUPPORTED,NOTSUPPORTED
220 },
221
222 .ADD_TAG_REG = {0,23},
223 .REMOVE_TAG_REG = {0,23},
224 .ADD_TAG_BIT = {11,12,13,14,15,-1,-1,-1,-1},
225 .REMOVE_TAG_BIT = {6,7,8,9,10,-1,-1,-1,-1},
226
227 .SIMPLE_VLAN_REGISTERS = 0,
228
229 // Only programmable via EEPROM
230 .VLAN_LOOKUP_REG = NOTSUPPORTED,// +N/2
231 .VLAN_LOOKUP_REG_5 = NOTSUPPORTED,
232 .VLAN_LOOKUP_EVEN_BIT = {8,9,10,11,12,-1,-1,-1,-1},
233 .VLAN_LOOKUP_ODD_BIT = {0,1,2,3,4,-1,-1,-1,-1},
234
235 .TAG_VLAN_MASK_REG = NOTSUPPORTED, // +N/2,
236 .TAG_VLAN_MASK_EVEN_BIT = {-1,-1,-1,-1,-1,-1,-1,-1,-1},
237 .TAG_VLAN_MASK_ODD_BIT = {-1,-1,-1,-1,-1,-1,-1,-1,-1},
238
239 .RESET_VAL = -1,
240 .RESET_REG = NOTSUPPORTED,
241 .MODE_VAL = 0,
242 .MODE_REG = NOTSUPPORTED,
243
244 .ROUTER_CONTROL_REG = NOTSUPPORTED,
245 .VLAN_CONTROL_REG = NOTSUPPORTED,
246 .TAG_VLAN_BIT = -1,
247 .ROUTER_EN_BIT = -1,
248 .NUMLAN_GROUPS_MAX = -1,
249 .NUMLAN_GROUPS_BIT = -1, // {0-2}
250
251 .NUM_PORTS = 5,
252 .CPU_PORT = 4,
253
254 .MII_REGISTER_EN = {0, 18},
255 .MII_REGISTER_EN_BIT = 7,
256
257 .get_flags = ip175c_get_flags,
258 .get_state = ip175c_get_state,
259 .update_state = ip175c_update_state,
260 .set_vlan_mode = ip175c_set_vlan_mode,
261 .reset = ip175c_do_reset,
262 };
263
264
265 struct ip175c_state {
266 struct switch_dev dev;
267 struct mii_bus *mii_bus;
268 bool registered;
269
270 int router_mode; // ROUTER_EN
271 int vlan_enabled; // TAG_VLAN_EN
272 struct port_state {
273 u16 pvid;
274 unsigned int shareports;
275 } ports[MAX_PORTS];
276 unsigned int add_tag;
277 unsigned int remove_tag;
278 int num_vlans;
279 struct vlan_state {
280 unsigned int ports;
281 } vlans[MAX_VLANS];
282 const struct register_mappings *regs;
283 reg proc_mii; // phy/reg for the low level register access via swconfig
284
285 char buf[80];
286 };
287
288
289 static int ip_phy_read(struct ip175c_state *state, int port, int reg)
290 {
291 int val = mdiobus_read(state->mii_bus, port, reg);
292 if (val < 0)
293 pr_warning("IP175C: Unable to get MII register %d,%d: error %d\n", port, reg, -val);
294 #ifdef DUMP_MII_IO
295 else
296 pr_debug("IP175C: Read MII(%d,%d) -> %04x\n", port, reg, val);
297 #endif
298 return val;
299 }
300
301 static int ip_phy_write(struct ip175c_state *state, int port, int reg, u16 val)
302 {
303 int err;
304
305 #ifdef DUMP_MII_IO
306 pr_debug("IP175C: Write MII(%d,%d) <- %04x\n", port, reg, val);
307 #endif
308 err = mdiobus_write(state->mii_bus, port, reg, val);
309 if (err < 0)
310 pr_warning("IP175C: Unable to write MII register %d,%d: error %d\n", port, reg, -err);
311 return err;
312 }
313
314 static int ip_phy_write_masked(struct ip175c_state *state, int port, int reg, unsigned int mask, unsigned int data)
315 {
316 int val = ip_phy_read(state, port, reg);
317 if (val < 0)
318 return 0;
319 return ip_phy_write(state, port, reg, (val & ~mask) | data);
320 }
321
322 static int getPhy(struct ip175c_state *state, reg mii)
323 {
324 if (!REG_SUPP(mii))
325 return -EFAULT;
326 return ip_phy_read(state, mii.p, mii.m);
327 }
328
329 static int setPhy(struct ip175c_state *state, reg mii, u16 value)
330 {
331 int err;
332
333 if (!REG_SUPP(mii))
334 return -EFAULT;
335 err = ip_phy_write(state, mii.p, mii.m, value);
336 if (err < 0)
337 return err;
338 getPhy(state, mii);
339 return 0;
340 }
341
342
343 /**
344 * These two macros are to simplify the mapping of logical bits to the bits in hardware.
345 * NOTE: these macros will return if there is an error!
346 */
347
348 #define GET_PORT_BITS(state, bits, addr, bit_lookup) \
349 do { \
350 int i, val = getPhy((state), (addr)); \
351 if (val < 0) \
352 return val; \
353 (bits) = 0; \
354 for (i = 0; i < MAX_PORTS; i++) { \
355 if ((bit_lookup)[i] == -1) continue; \
356 if (val & (1<<(bit_lookup)[i])) \
357 (bits) |= (1<<i); \
358 } \
359 } while (0)
360
361 #define SET_PORT_BITS(state, bits, addr, bit_lookup) \
362 do { \
363 int i, val = getPhy((state), (addr)); \
364 if (val < 0) \
365 return val; \
366 for (i = 0; i < MAX_PORTS; i++) { \
367 unsigned int newmask = ((bits)&(1<<i)); \
368 if ((bit_lookup)[i] == -1) continue; \
369 val &= ~(1<<(bit_lookup)[i]); \
370 val |= ((newmask>>i)<<(bit_lookup)[i]); \
371 } \
372 val = setPhy((state), (addr), val); \
373 if (val < 0) \
374 return val; \
375 } while (0)
376
377
378 static int get_model(struct ip175c_state *state)
379 {
380 reg oui_id_reg = {0, 2};
381 int oui_id;
382 reg model_no_reg = {0, 3};
383 int model_no, model_no_orig;
384
385 // 175 and 178 have the same oui ID.
386 reg oui_id_reg_178c = {5, 2}; // returns error on IP175C.
387 int is_178c = 0;
388
389 oui_id = getPhy(state, oui_id_reg);
390 if (oui_id != 0x0243) {
391 // non
392 return -ENODEV; // Not a IC+ chip.
393 }
394 oui_id = getPhy(state, oui_id_reg_178c);
395 if (oui_id == 0x0243) {
396 is_178c = 1;
397 }
398
399 model_no_orig = getPhy(state, model_no_reg);
400 if (model_no_orig < 0) {
401 return -ENODEV;
402 }
403 model_no = model_no_orig >> 4; // shift out revision number.
404 model_no &= 0x3f; // only take the model number (low 6 bits).
405 if (model_no == IP175A.MODEL_NO) {
406 state->regs = &IP175A;
407 } else if (model_no == IP175C.MODEL_NO) {
408 if (is_178c) {
409 state->regs = &IP178C;
410 } else {
411 state->regs = &IP175C;
412 }
413 } else {
414 printk(KERN_WARNING "ip175c: Found an unknown IC+ switch with model number %02Xh.\n", model_no_orig);
415 return -EPERM;
416 }
417 return 0;
418 }
419
420 /** Get only the vlan and router flags on the router **/
421 static int ip175c_get_flags(struct ip175c_state *state)
422 {
423 int val;
424
425 state->router_mode = 0;
426 state->vlan_enabled = -1; // hack
427 state->num_vlans = 0;
428
429 if (!REG_SUPP(state->regs->ROUTER_CONTROL_REG)) {
430 return 0; // not an error if it doesn't support enable vlan.
431 }
432
433 val = getPhy(state, state->regs->ROUTER_CONTROL_REG);
434 if (val < 0) {
435 return val;
436 }
437 if (state->regs->ROUTER_EN_BIT >= 0)
438 state->router_mode = ((val>>state->regs->ROUTER_EN_BIT) & 1);
439
440 if (state->regs->NUMLAN_GROUPS_BIT >= 0) {
441 state->num_vlans = (val >> state->regs->NUMLAN_GROUPS_BIT);
442 state->num_vlans &= (state->regs->NUMLAN_GROUPS_MAX-1);
443 state->num_vlans+=1; // does not include WAN.
444 }
445
446 val = getPhy(state, state->regs->VLAN_CONTROL_REG);
447 if (val < 0) {
448 return 0;
449 }
450 if (state->regs->TAG_VLAN_BIT >= 0)
451 state->vlan_enabled = ((val>>state->regs->TAG_VLAN_BIT) & 1);
452
453 return 0;
454 }
455
456 /** Get all state variables for VLAN mappings and port-based tagging **/
457 static int ip175c_get_state(struct ip175c_state *state)
458 {
459 int i, j;
460 int ret;
461
462 ret = ip175c_get_flags(state);
463 if (ret < 0) {
464 return ret;
465 }
466
467 GET_PORT_BITS(state, state->remove_tag,
468 state->regs->REMOVE_TAG_REG, state->regs->REMOVE_TAG_BIT);
469 GET_PORT_BITS(state, state->add_tag,
470 state->regs->ADD_TAG_REG, state->regs->ADD_TAG_BIT);
471
472 if (state->vlan_enabled == -1) {
473 // not sure how to get this...
474 state->vlan_enabled = (state->remove_tag || state->add_tag);
475 }
476
477 if (REG_SUPP(state->regs->VLAN_LOOKUP_REG)) {
478 for (j=0; j<MAX_PORTS; j++) {
479 state->ports[j].shareports = 0; // initialize them in case.
480 }
481 for (j=0; j<state->regs->NUM_PORTS; j++) {
482 reg addr;
483 const bitnum *bit_lookup = (j%2==0)?
484 state->regs->VLAN_LOOKUP_EVEN_BIT:
485 state->regs->VLAN_LOOKUP_ODD_BIT;
486 addr = state->regs->VLAN_LOOKUP_REG;
487 if (state->regs->SIMPLE_VLAN_REGISTERS) {
488 addr.m += j;
489 } else {
490 switch (j) {
491 case 0:
492 case 1:
493 break;
494 case 2:
495 case 3:
496 addr.m+=1;
497 break;
498 case 4:
499 addr.m+=2;
500 break;
501 case 5:
502 addr = state->regs->VLAN_LOOKUP_REG_5;
503 break;
504 }
505 }
506
507 if (REG_SUPP(addr)) {
508 GET_PORT_BITS(state, state->ports[j].shareports, addr, bit_lookup);
509 }
510 }
511 } else {
512 for (j=0; j<MAX_PORTS; j++) {
513 state->ports[j].shareports = 0xff;
514 }
515 }
516
517 for (i=0; i<MAX_PORTS; i++) {
518 if (REG_SUPP(state->regs->VLAN_DEFAULT_TAG_REG[i])) {
519 int val = getPhy(state, state->regs->VLAN_DEFAULT_TAG_REG[i]);
520 if (val < 0) {
521 return val;
522 }
523 state->ports[i].pvid = val;
524 } else {
525 state->ports[i].pvid = 0;
526 }
527 }
528
529 if (REG_SUPP(state->regs->TAG_VLAN_MASK_REG)) {
530 for (j=0; j<MAX_VLANS; j++) {
531 reg addr = state->regs->TAG_VLAN_MASK_REG;
532 const bitnum *bit_lookup = (j%2==0)?
533 state->regs->TAG_VLAN_MASK_EVEN_BIT:
534 state->regs->TAG_VLAN_MASK_ODD_BIT;
535 if (state->regs->SIMPLE_VLAN_REGISTERS) {
536 addr.m += j;
537 } else {
538 addr.m += j/2;
539 }
540 GET_PORT_BITS(state, state->vlans[j].ports, addr, bit_lookup);
541 }
542 } else {
543 for (j=0; j<MAX_VLANS; j++) {
544 state->vlans[j].ports = 0;
545 for (i=0; i<state->regs->NUM_PORTS; i++) {
546 if ((state->ports[i].pvid == j) ||
547 (state->ports[i].pvid == 0)) {
548 state->vlans[j].ports |= (1<<i);
549 }
550 }
551 }
552 }
553
554 return 0;
555 }
556
557 /** Only set vlan and router flags in the switch **/
558 static int ip175c_set_flags(struct ip175c_state *state)
559 {
560 int val;
561
562 if (!REG_SUPP(state->regs->ROUTER_CONTROL_REG)) {
563 return 0;
564 }
565
566 val = getPhy(state, state->regs->ROUTER_CONTROL_REG);
567 if (val < 0) {
568 return val;
569 }
570 if (state->regs->ROUTER_EN_BIT >= 0) {
571 if (state->router_mode) {
572 val |= (1<<state->regs->ROUTER_EN_BIT);
573 } else {
574 val &= (~(1<<state->regs->ROUTER_EN_BIT));
575 }
576 }
577 if (state->regs->TAG_VLAN_BIT >= 0) {
578 if (state->vlan_enabled) {
579 val |= (1<<state->regs->TAG_VLAN_BIT);
580 } else {
581 val &= (~(1<<state->regs->TAG_VLAN_BIT));
582 }
583 }
584 if (state->regs->NUMLAN_GROUPS_BIT >= 0) {
585 val &= (~((state->regs->NUMLAN_GROUPS_MAX-1)<<state->regs->NUMLAN_GROUPS_BIT));
586 if (state->num_vlans > state->regs->NUMLAN_GROUPS_MAX) {
587 val |= state->regs->NUMLAN_GROUPS_MAX << state->regs->NUMLAN_GROUPS_BIT;
588 } else if (state->num_vlans >= 1) {
589 val |= (state->num_vlans-1) << state->regs->NUMLAN_GROUPS_BIT;
590 }
591 }
592 return setPhy(state, state->regs->ROUTER_CONTROL_REG, val);
593 }
594
595 /** Set all VLAN and port state. Usually you should call "correct_vlan_state" first. **/
596 static int ip175c_set_state(struct ip175c_state *state)
597 {
598 int j;
599 int i;
600 SET_PORT_BITS(state, state->add_tag,
601 state->regs->ADD_TAG_REG, state->regs->ADD_TAG_BIT);
602 SET_PORT_BITS(state, state->remove_tag,
603 state->regs->REMOVE_TAG_REG, state->regs->REMOVE_TAG_BIT);
604
605 if (REG_SUPP(state->regs->VLAN_LOOKUP_REG)) {
606 for (j=0; j<state->regs->NUM_PORTS; j++) {
607 reg addr;
608 const bitnum *bit_lookup = (j%2==0)?
609 state->regs->VLAN_LOOKUP_EVEN_BIT:
610 state->regs->VLAN_LOOKUP_ODD_BIT;
611
612 // duplicate code -- sorry
613 addr = state->regs->VLAN_LOOKUP_REG;
614 if (state->regs->SIMPLE_VLAN_REGISTERS) {
615 addr.m += j;
616 } else {
617 switch (j) {
618 case 0:
619 case 1:
620 break;
621 case 2:
622 case 3:
623 addr.m+=1;
624 break;
625 case 4:
626 addr.m+=2;
627 break;
628 case 5:
629 addr = state->regs->VLAN_LOOKUP_REG_5;
630 break;
631 default:
632 addr.m = -1; // shouldn't get here, but...
633 break;
634 }
635 }
636 //printf("shareports for %d is %02X\n",j,state->ports[j].shareports);
637 if (REG_SUPP(addr)) {
638 SET_PORT_BITS(state, state->ports[j].shareports, addr, bit_lookup);
639 }
640 }
641 }
642 if (REG_SUPP(state->regs->TAG_VLAN_MASK_REG)) {
643 for (j=0; j<MAX_VLANS; j++) {
644 reg addr = state->regs->TAG_VLAN_MASK_REG;
645 const bitnum *bit_lookup = (j%2==0)?
646 state->regs->TAG_VLAN_MASK_EVEN_BIT:
647 state->regs->TAG_VLAN_MASK_ODD_BIT;
648 unsigned int vlan_mask;
649 if (state->regs->SIMPLE_VLAN_REGISTERS) {
650 addr.m += j;
651 } else {
652 addr.m += j/2;
653 }
654 vlan_mask = state->vlans[j].ports;
655 SET_PORT_BITS(state, vlan_mask, addr, bit_lookup);
656 }
657 }
658
659 for (i=0; i<MAX_PORTS; i++) {
660 if (REG_SUPP(state->regs->VLAN_DEFAULT_TAG_REG[i])) {
661 int err = setPhy(state, state->regs->VLAN_DEFAULT_TAG_REG[i],
662 state->ports[i].pvid);
663 if (err < 0) {
664 return err;
665 }
666 }
667 }
668
669 return ip175c_set_flags(state);
670 }
671
672 /**
673 * Uses only the VLAN port mask and the add tag mask to generate the other fields:
674 * which ports are part of the same VLAN, removing vlan tags, and VLAN tag ids.
675 */
676 static void ip175c_correct_vlan_state(struct ip175c_state *state)
677 {
678 int i, j;
679 state->num_vlans = 0;
680 for (i=0; i<MAX_VLANS; i++) {
681 if (state->vlans[i].ports != 0) {
682 state->num_vlans = i+1; // Hack -- we need to store the "set" vlans somewhere...
683 }
684 }
685
686 for (i=0; i<state->regs->NUM_PORTS; i++) {
687 unsigned int portmask = (1<<i);
688 if (!state->vlan_enabled) {
689 // Share with everybody!
690 state->ports[i].shareports = (1<<state->regs->NUM_PORTS)-1;
691 continue;
692 }
693 state->ports[i].shareports = portmask;
694 for (j=0; j<MAX_VLANS; j++) {
695 if (state->vlans[j].ports & portmask)
696 state->ports[i].shareports |= state->vlans[j].ports;
697 }
698 }
699 state->remove_tag = ((~state->add_tag) & ((1<<state->regs->NUM_PORTS)-1));
700 }
701
702 static int ip175c_update_state(struct ip175c_state *state)
703 {
704 ip175c_correct_vlan_state(state);
705 return ip175c_set_state(state);
706 }
707
708 static int ip175c_set_vlan_mode(struct ip175c_state *state)
709 {
710 return ip175c_update_state(state);
711 }
712
713 static int ip175c_do_reset(struct ip175c_state *state)
714 {
715 int err;
716
717 if (REG_SUPP(state->regs->MODE_REG)) {
718 err = setPhy(state, state->regs->MODE_REG, state->regs->MODE_VAL);
719 if (err < 0)
720 return err;
721 err = getPhy(state, state->regs->MODE_REG);
722 if (err < 0)
723 return err;
724 }
725
726 return 0;
727 }
728
729 static int ip175c_get_enable_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
730 {
731 struct ip175c_state *state = dev->priv;
732 int err;
733
734 err = state->regs->get_state(state); // May be set in get_state.
735 if (err < 0)
736 return err;
737 val->value.i = state->vlan_enabled;
738 return 0;
739 }
740
741 static void ip175c_reset_vlan_config(struct ip175c_state *state)
742 {
743 int i;
744
745 state->remove_tag = 0x0000;
746 state->add_tag = 0x0000;
747 for (i = 0; i < MAX_VLANS; i++)
748 state->vlans[i].ports = 0x0000;
749 for (i = 0; i < MAX_PORTS; i++)
750 state->ports[i].pvid = 0;
751 }
752
753 static int ip175c_set_enable_vlan(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
754 {
755 struct ip175c_state *state = dev->priv;
756 int err;
757 int enable;
758
759 err = state->regs->get_state(state);
760 if (err < 0)
761 return err;
762 enable = val->value.i;
763
764 if (state->vlan_enabled == enable) {
765 // Do not change any state.
766 return 0;
767 }
768 state->vlan_enabled = enable;
769
770 // Otherwise, if we are switching state, set fields to a known default.
771 ip175c_reset_vlan_config(state);
772
773 return state->regs->set_vlan_mode(state);
774 }
775
776 static int ip175c_get_ports(struct switch_dev *dev, struct switch_val *val)
777 {
778 struct ip175c_state *state = dev->priv;
779 int err;
780 int b;
781 int ind;
782 unsigned int ports;
783
784 if (val->port_vlan >= dev->vlans || val->port_vlan < 0)
785 return -EINVAL;
786
787 err = state->regs->get_state(state);
788 if (err<0)
789 return err;
790
791 ports = state->vlans[val->port_vlan].ports;
792 b = 0;
793 ind = 0;
794 while (b < MAX_PORTS) {
795 if (ports&1) {
796 int istagged = ((state->add_tag >> b) & 1);
797 val->value.ports[ind].id = b;
798 val->value.ports[ind].flags = (istagged << SWITCH_PORT_FLAG_TAGGED);
799 ind++;
800 }
801 b++;
802 ports >>= 1;
803 }
804 val->len = ind;
805
806 return 0;
807 }
808
809 static int ip175c_set_ports(struct switch_dev *dev, struct switch_val *val)
810 {
811 struct ip175c_state *state = dev->priv;
812 int i;
813 int err;
814
815 if (val->port_vlan >= dev->vlans || val->port_vlan < 0)
816 return -EINVAL;
817
818 err = state->regs->get_state(state);
819 if (err < 0)
820 return err;
821
822 state->vlans[val->port_vlan].ports = 0;
823 for (i = 0; i < val->len; i++) {
824 int bitmask = (1<<val->value.ports[i].id);
825 state->vlans[val->port_vlan].ports |= bitmask;
826 if (val->value.ports[i].flags & (1<<SWITCH_PORT_FLAG_TAGGED)) {
827 state->add_tag |= bitmask;
828 } else {
829 state->add_tag &= (~bitmask);
830 }
831 }
832
833 return state->regs->update_state(state);
834 }
835
836 static int ip175c_apply(struct switch_dev *dev)
837 {
838 struct ip175c_state *state = dev->priv;
839 int err;
840
841 err = state->regs->get_flags(state);
842 if (err < 0)
843 return err;
844
845 if (REG_SUPP(state->regs->MII_REGISTER_EN)) {
846 int val = getPhy(state, state->regs->MII_REGISTER_EN);
847 if (val < 0) {
848 return val;
849 }
850 val |= (1<<state->regs->MII_REGISTER_EN_BIT);
851 return setPhy(state, state->regs->MII_REGISTER_EN, val);
852 }
853 return 0;
854 }
855
856 static int ip175c_reset(struct switch_dev *dev)
857 {
858 struct ip175c_state *state = dev->priv;
859 int i, err;
860
861 err = state->regs->get_flags(state);
862 if (err < 0)
863 return err;
864
865 if (REG_SUPP(state->regs->RESET_REG)) {
866 err = setPhy(state, state->regs->RESET_REG, state->regs->RESET_VAL);
867 if (err < 0)
868 return err;
869 err = getPhy(state, state->regs->RESET_REG);
870
871 /*
872 * Data sheet specifies reset period to be 2 msec.
873 * (I don't see any mention of the 2ms delay in the IP178C spec, only
874 * in IP175C, but it can't hurt.)
875 */
876 mdelay(2);
877 }
878
879 /* reset switch ports */
880 for (i = 0; i < state->regs->NUM_PORTS-1; i++) {
881 err = ip_phy_write(state, i, MII_BMCR, BMCR_RESET);
882 if (err < 0)
883 return err;
884 }
885
886 ip175c_reset_vlan_config(state);
887
888 return state->regs->reset(state);
889 }
890
891 static int ip175c_get_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
892 {
893 struct ip175c_state *state = dev->priv;
894 int err;
895
896 err = state->regs->get_state(state);
897 if (err < 0)
898 return err;
899
900 if (state->add_tag & (1<<val->port_vlan)) {
901 if (state->remove_tag & (1<<val->port_vlan))
902 val->value.i = 3; // shouldn't ever happen.
903 else
904 val->value.i = 1;
905 } else {
906 if (state->remove_tag & (1<<val->port_vlan))
907 val->value.i = 0;
908 else
909 val->value.i = 2;
910 }
911 return 0;
912 }
913
914 static int ip175c_set_tagged(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
915 {
916 struct ip175c_state *state = dev->priv;
917 int err;
918
919 err = state->regs->get_state(state);
920 if (err < 0)
921 return err;
922
923 state->add_tag &= ~(1<<val->port_vlan);
924 state->remove_tag &= ~(1<<val->port_vlan);
925
926 if (val->value.i == 0)
927 state->remove_tag |= (1<<val->port_vlan);
928 if (val->value.i == 1)
929 state->add_tag |= (1<<val->port_vlan);
930
931 return state->regs->update_state(state);
932 }
933
934 /** Get the current phy address */
935 static int ip175c_get_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
936 {
937 struct ip175c_state *state = dev->priv;
938
939 val->value.i = state->proc_mii.p;
940 return 0;
941 }
942
943 /** Set a new phy address for low level access to registers */
944 static int ip175c_set_phy(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
945 {
946 struct ip175c_state *state = dev->priv;
947 int new_reg = val->value.i;
948
949 if (new_reg < 0 || new_reg > 31)
950 state->proc_mii.p = (u16)-1;
951 else
952 state->proc_mii.p = (u16)new_reg;
953 return 0;
954 }
955
956 /** Get the current register number */
957 static int ip175c_get_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
958 {
959 struct ip175c_state *state = dev->priv;
960
961 val->value.i = state->proc_mii.m;
962 return 0;
963 }
964
965 /** Set a new register address for low level access to registers */
966 static int ip175c_set_reg(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
967 {
968 struct ip175c_state *state = dev->priv;
969 int new_reg = val->value.i;
970
971 if (new_reg < 0 || new_reg > 31)
972 state->proc_mii.m = (u16)-1;
973 else
974 state->proc_mii.m = (u16)new_reg;
975 return 0;
976 }
977
978 /** Get the register content of state->proc_mii */
979 static int ip175c_get_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
980 {
981 struct ip175c_state *state = dev->priv;
982 int retval = -EINVAL;
983 if (REG_SUPP(state->proc_mii))
984 retval = getPhy(state, state->proc_mii);
985
986 if (retval < 0) {
987 return retval;
988 } else {
989 val->value.i = retval;
990 return 0;
991 }
992 }
993
994 /** Write a value to the register defined by phy/reg above */
995 static int ip175c_set_val(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
996 {
997 struct ip175c_state *state = dev->priv;
998 int myval, err = -EINVAL;
999
1000 myval = val->value.i;
1001 if (myval <= 0xffff && myval >= 0 && REG_SUPP(state->proc_mii)) {
1002 err = setPhy(state, state->proc_mii, (u16)myval);
1003 }
1004 return err;
1005 }
1006
1007 static int ip175c_read_name(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
1008 {
1009 struct ip175c_state *state = dev->priv;
1010 val->value.s = state->regs->NAME; // Just a const pointer, won't be freed by swconfig.
1011 return 0;
1012 }
1013
1014 static int ip175c_set_port_speed(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
1015 {
1016 struct ip175c_state *state = dev->priv;
1017 int nr = val->port_vlan;
1018 int ctrl;
1019 int autoneg;
1020 int speed;
1021 if (val->value.i == 100) {
1022 speed = 1;
1023 autoneg = 0;
1024 } else if (val->value.i == 10) {
1025 speed = 0;
1026 autoneg = 0;
1027 } else {
1028 autoneg = 1;
1029 speed = 1;
1030 }
1031
1032 /* Can't set speed for cpu port */
1033 if (nr == state->regs->CPU_PORT)
1034 return -EINVAL;
1035
1036 if (nr >= dev->ports || nr < 0)
1037 return -EINVAL;
1038
1039 ctrl = ip_phy_read(state, nr, 0);
1040 if (ctrl < 0)
1041 return -EIO;
1042
1043 ctrl &= (~(1<<12));
1044 ctrl &= (~(1<<13));
1045 ctrl |= (autoneg<<12);
1046 ctrl |= (speed<<13);
1047
1048 return ip_phy_write(state, nr, 0, ctrl);
1049 }
1050
1051 static int ip175c_get_port_speed(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
1052 {
1053 struct ip175c_state *state = dev->priv;
1054 int nr = val->port_vlan;
1055 int speed, status;
1056
1057 if (nr == state->regs->CPU_PORT) {
1058 val->value.i = 100;
1059 return 0;
1060 }
1061
1062 if (nr >= dev->ports || nr < 0)
1063 return -EINVAL;
1064
1065 status = ip_phy_read(state, nr, 1);
1066 speed = ip_phy_read(state, nr, 18);
1067 if (status < 0 || speed < 0)
1068 return -EIO;
1069
1070 if (status & 4)
1071 val->value.i = ((speed & (1<<11)) ? 100 : 10);
1072 else
1073 val->value.i = 0;
1074
1075 return 0;
1076 }
1077
1078 static int ip175c_get_port_status(struct switch_dev *dev, const struct switch_attr *attr, struct switch_val *val)
1079 {
1080 struct ip175c_state *state = dev->priv;
1081 int ctrl, speed, status;
1082 int nr = val->port_vlan;
1083 int len;
1084 char *buf = state->buf; // fixed-length at 80.
1085
1086 if (nr == state->regs->CPU_PORT) {
1087 sprintf(buf, "up, 100 Mbps, cpu port");
1088 val->value.s = buf;
1089 return 0;
1090 }
1091
1092 if (nr >= dev->ports || nr < 0)
1093 return -EINVAL;
1094
1095 ctrl = ip_phy_read(state, nr, 0);
1096 status = ip_phy_read(state, nr, 1);
1097 speed = ip_phy_read(state, nr, 18);
1098 if (ctrl < 0 || status < 0 || speed < 0)
1099 return -EIO;
1100
1101 if (status & 4)
1102 len = sprintf(buf, "up, %d Mbps, %s duplex",
1103 ((speed & (1<<11)) ? 100 : 10),
1104 ((speed & (1<<10)) ? "full" : "half"));
1105 else
1106 len = sprintf(buf, "down");
1107
1108 if (ctrl & (1<<12)) {
1109 len += sprintf(buf+len, ", auto-negotiate");
1110 if (!(status & (1<<5)))
1111 len += sprintf(buf+len, " (in progress)");
1112 } else {
1113 len += sprintf(buf+len, ", fixed speed (%d)",
1114 ((ctrl & (1<<13)) ? 100 : 10));
1115 }
1116
1117 buf[len] = '\0';
1118 val->value.s = buf;
1119 return 0;
1120 }
1121
1122 static int ip175c_get_pvid(struct switch_dev *dev, int port, int *val)
1123 {
1124 struct ip175c_state *state = dev->priv;
1125
1126 *val = state->ports[port].pvid;
1127 return 0;
1128 }
1129
1130 static int ip175c_set_pvid(struct switch_dev *dev, int port, int val)
1131 {
1132 struct ip175c_state *state = dev->priv;
1133 int err;
1134
1135 if (val < 0 || val >= MAX_VLANS)
1136 return -EINVAL;
1137
1138 err = state->regs->get_state(state);
1139 if (err < 0)
1140 return err;
1141
1142 state->ports[port].pvid = val;
1143
1144 return state->regs->update_state(state);
1145 }
1146
1147
1148 enum Ports {
1149 IP175C_PORT_STATUS,
1150 IP175C_PORT_LINK,
1151 IP175C_PORT_TAGGED,
1152 IP175C_PORT_PVID,
1153 };
1154
1155 enum Globals {
1156 IP175C_ENABLE_VLAN,
1157 IP175C_GET_NAME,
1158 IP175C_REGISTER_PHY,
1159 IP175C_REGISTER_MII,
1160 IP175C_REGISTER_VALUE,
1161 IP175C_REGISTER_ERRNO,
1162 };
1163
1164 static const struct switch_attr ip175c_global[] = {
1165 [IP175C_ENABLE_VLAN] = {
1166 .id = IP175C_ENABLE_VLAN,
1167 .type = SWITCH_TYPE_INT,
1168 .name = "enable_vlan",
1169 .description = "Flag to enable or disable VLANs and tagging",
1170 .get = ip175c_get_enable_vlan,
1171 .set = ip175c_set_enable_vlan,
1172 },
1173 [IP175C_GET_NAME] = {
1174 .id = IP175C_GET_NAME,
1175 .type = SWITCH_TYPE_STRING,
1176 .description = "Returns the type of IC+ chip.",
1177 .name = "name",
1178 .get = ip175c_read_name,
1179 .set = NULL,
1180 },
1181 /* jal: added for low level debugging etc. */
1182 [IP175C_REGISTER_PHY] = {
1183 .id = IP175C_REGISTER_PHY,
1184 .type = SWITCH_TYPE_INT,
1185 .description = "Direct register access: set PHY (0-4, or 29,30,31)",
1186 .name = "phy",
1187 .get = ip175c_get_phy,
1188 .set = ip175c_set_phy,
1189 },
1190 [IP175C_REGISTER_MII] = {
1191 .id = IP175C_REGISTER_MII,
1192 .type = SWITCH_TYPE_INT,
1193 .description = "Direct register access: set MII register number (0-31)",
1194 .name = "reg",
1195 .get = ip175c_get_reg,
1196 .set = ip175c_set_reg,
1197 },
1198 [IP175C_REGISTER_VALUE] = {
1199 .id = IP175C_REGISTER_VALUE,
1200 .type = SWITCH_TYPE_INT,
1201 .description = "Direct register access: read/write to register (0-65535)",
1202 .name = "val",
1203 .get = ip175c_get_val,
1204 .set = ip175c_set_val,
1205 },
1206 };
1207
1208 static const struct switch_attr ip175c_vlan[] = {
1209 };
1210
1211 static const struct switch_attr ip175c_port[] = {
1212 [IP175C_PORT_STATUS] = {
1213 .id = IP175C_PORT_STATUS,
1214 .type = SWITCH_TYPE_STRING,
1215 .description = "Returns Detailed port status",
1216 .name = "status",
1217 .get = ip175c_get_port_status,
1218 .set = NULL,
1219 },
1220 [IP175C_PORT_LINK] = {
1221 .id = IP175C_PORT_LINK,
1222 .type = SWITCH_TYPE_INT,
1223 .description = "Link speed. Can write 0 for auto-negotiate, or 10 or 100",
1224 .name = "link",
1225 .get = ip175c_get_port_speed,
1226 .set = ip175c_set_port_speed,
1227 },
1228 [IP175C_PORT_TAGGED] = {
1229 .id = IP175C_PORT_LINK,
1230 .type = SWITCH_TYPE_INT,
1231 .description = "0 = untag, 1 = add tags, 2 = do not alter (This value is reset if vlans are altered)",
1232 .name = "tagged",
1233 .get = ip175c_get_tagged,
1234 .set = ip175c_set_tagged,
1235 },
1236 };
1237
1238 static int ip175c_probe(struct phy_device *pdev)
1239 {
1240 struct ip175c_state *state;
1241 struct switch_dev *dev;
1242 int err;
1243
1244 /* We only attach to PHY 0, but use all available PHYs */
1245 if (pdev->addr != 0)
1246 return -ENODEV;
1247
1248 state = kzalloc(sizeof(*state), GFP_KERNEL);
1249 if (!state)
1250 return -ENOMEM;
1251
1252 dev = &state->dev;
1253 dev->attr_global.attr = ip175c_global;
1254 dev->attr_global.n_attr = ARRAY_SIZE(ip175c_global);
1255 dev->attr_port.attr = ip175c_port;
1256 dev->attr_port.n_attr = ARRAY_SIZE(ip175c_port);
1257 dev->attr_vlan.attr = ip175c_vlan;
1258 dev->attr_vlan.n_attr = ARRAY_SIZE(ip175c_vlan);
1259
1260 dev->get_port_pvid = ip175c_get_pvid;
1261 dev->set_port_pvid = ip175c_set_pvid;
1262 dev->get_vlan_ports = ip175c_get_ports;
1263 dev->set_vlan_ports = ip175c_set_ports;
1264 dev->apply_config = ip175c_apply;
1265 dev->reset_switch = ip175c_reset;
1266
1267 dev->priv = state;
1268 pdev->priv = state;
1269 state->mii_bus = pdev->bus;
1270
1271 err = get_model(state);
1272 if (err < 0)
1273 goto error;
1274
1275 dev->vlans = MAX_VLANS;
1276 dev->cpu_port = state->regs->CPU_PORT;
1277 dev->ports = state->regs->NUM_PORTS;
1278 dev->name = state->regs->NAME;
1279
1280 return 0;
1281
1282 error:
1283 kfree(state);
1284 return err;
1285 }
1286
1287 static int ip175c_config_init(struct phy_device *pdev)
1288 {
1289 struct ip175c_state *state = pdev->priv;
1290 struct net_device *dev = pdev->attached_dev;
1291 int err;
1292
1293 pdev->irq = PHY_IGNORE_INTERRUPT;
1294 err = register_switch(&state->dev, dev);
1295 if (err < 0)
1296 return err;
1297
1298 ip175c_reset(&state->dev);
1299
1300 state->registered = true;
1301 netif_carrier_on(pdev->attached_dev);
1302
1303 return 0;
1304 }
1305
1306 static void ip175c_remove(struct phy_device *pdev)
1307 {
1308 struct ip175c_state *state = pdev->priv;
1309
1310 if (state->registered)
1311 unregister_switch(&state->dev);
1312 kfree(state);
1313 }
1314
1315 static int ip175c_config_aneg(struct phy_device *pdev)
1316 {
1317 return 0;
1318 }
1319
1320 static int ip175c_read_status(struct phy_device *pdev)
1321 {
1322 pdev->speed = SPEED_100;
1323 pdev->duplex = DUPLEX_FULL;
1324 pdev->pause = pdev->asym_pause = 0;
1325 return 0;
1326 }
1327
1328 static struct phy_driver ip175c_driver = {
1329 .name = "IC+ IP175C",
1330 .phy_id = 0x02430d80,
1331 .phy_id_mask = 0x0ffffff0,
1332 .features = PHY_BASIC_FEATURES,
1333 .probe = ip175c_probe,
1334 .remove = ip175c_remove,
1335 .config_init = ip175c_config_init,
1336 .config_aneg = ip175c_config_aneg,
1337 .read_status = ip175c_read_status,
1338 .driver = { .owner = THIS_MODULE },
1339 };
1340
1341 static struct phy_driver ip175a_driver = {
1342 .name = "IC+ IP175A",
1343 .phy_id = 0x02430c50,
1344 .phy_id_mask = 0x0ffffff0,
1345 .features = PHY_BASIC_FEATURES,
1346 .probe = ip175c_probe,
1347 .remove = ip175c_remove,
1348 .config_init = ip175c_config_init,
1349 .config_aneg = ip175c_config_aneg,
1350 .read_status = ip175c_read_status,
1351 .driver = { .owner = THIS_MODULE },
1352 };
1353
1354
1355 int __init ip175c_init(void)
1356 {
1357 int ret;
1358
1359 ret = phy_driver_register(&ip175a_driver);
1360 if (ret < 0)
1361 return ret;
1362
1363 return phy_driver_register(&ip175c_driver);
1364 }
1365
1366 void __exit ip175c_exit(void)
1367 {
1368 phy_driver_unregister(&ip175c_driver);
1369 phy_driver_unregister(&ip175a_driver);
1370 }
1371
1372 MODULE_AUTHOR("Patrick Horn <patrick.horn@gmail.com>");
1373 MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
1374 MODULE_LICENSE("GPL");
1375
1376 module_init(ip175c_init);
1377 module_exit(ip175c_exit);
This page took 0.106804 seconds and 3 git commands to generate.