diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2016-04-17 13:23:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-17 18:54:15 -0400 |
commit | f6271e676b7f62a609f8ee5523a6a8ed47c0f333 (patch) | |
tree | 300ccfc4909dce39e605f9bfd9823ad820e0d629 | |
parent | a439c0612d7bdbd5ce8ea868e6a1084f0d7300dc (diff) |
net: dsa: mv88e6xxx: add switch info
Add a new switch info structure which is meant to store switch models
static information, such as product number, name, number of ports,
number of databases, etc.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/dsa/mv88e6123.c | 15 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6131.c | 19 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6171.c | 19 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6352.c | 27 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.c | 18 | ||||
-rw-r--r-- | drivers/net/dsa/mv88e6xxx.h | 27 |
6 files changed, 93 insertions, 32 deletions
diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c index d6921ba144b9..62dffcf915a7 100644 --- a/drivers/net/dsa/mv88e6123.c +++ b/drivers/net/dsa/mv88e6123.c | |||
@@ -17,10 +17,17 @@ | |||
17 | #include <net/dsa.h> | 17 | #include <net/dsa.h> |
18 | #include "mv88e6xxx.h" | 18 | #include "mv88e6xxx.h" |
19 | 19 | ||
20 | static const struct mv88e6xxx_switch_id mv88e6123_table[] = { | 20 | static const struct mv88e6xxx_info mv88e6123_table[] = { |
21 | { PORT_SWITCH_ID_6123, "Marvell 88E6123" }, | 21 | { |
22 | { PORT_SWITCH_ID_6161, "Marvell 88E6161" }, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6123, |
23 | { PORT_SWITCH_ID_6165, "Marvell 88E6165" }, | 23 | .name = "Marvell 88E6123", |
24 | }, { | ||
25 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6161, | ||
26 | .name = "Marvell 88E6161", | ||
27 | }, { | ||
28 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6165, | ||
29 | .name = "Marvell 88E6165", | ||
30 | } | ||
24 | }; | 31 | }; |
25 | 32 | ||
26 | static const char *mv88e6123_drv_probe(struct device *dsa_dev, | 33 | static const char *mv88e6123_drv_probe(struct device *dsa_dev, |
diff --git a/drivers/net/dsa/mv88e6131.c b/drivers/net/dsa/mv88e6131.c index 8dc136576fe4..00567156f335 100644 --- a/drivers/net/dsa/mv88e6131.c +++ b/drivers/net/dsa/mv88e6131.c | |||
@@ -17,11 +17,20 @@ | |||
17 | #include <net/dsa.h> | 17 | #include <net/dsa.h> |
18 | #include "mv88e6xxx.h" | 18 | #include "mv88e6xxx.h" |
19 | 19 | ||
20 | static const struct mv88e6xxx_switch_id mv88e6131_table[] = { | 20 | static const struct mv88e6xxx_info mv88e6131_table[] = { |
21 | { PORT_SWITCH_ID_6085, "Marvell 88E6085" }, | 21 | { |
22 | { PORT_SWITCH_ID_6095, "Marvell 88E6095/88E6095F" }, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6095, |
23 | { PORT_SWITCH_ID_6131, "Marvell 88E6131" }, | 23 | .name = "Marvell 88E6095/88E6095F", |
24 | { PORT_SWITCH_ID_6185, "Marvell 88E6185" }, | 24 | }, { |
25 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6085, | ||
26 | .name = "Marvell 88E6085", | ||
27 | }, { | ||
28 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6131, | ||
29 | .name = "Marvell 88E6131", | ||
30 | }, { | ||
31 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6185, | ||
32 | .name = "Marvell 88E6185", | ||
33 | } | ||
25 | }; | 34 | }; |
26 | 35 | ||
27 | static const char *mv88e6131_drv_probe(struct device *dsa_dev, | 36 | static const char *mv88e6131_drv_probe(struct device *dsa_dev, |
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c index ae328750eae8..ea14ab22d313 100644 --- a/drivers/net/dsa/mv88e6171.c +++ b/drivers/net/dsa/mv88e6171.c | |||
@@ -17,11 +17,20 @@ | |||
17 | #include <net/dsa.h> | 17 | #include <net/dsa.h> |
18 | #include "mv88e6xxx.h" | 18 | #include "mv88e6xxx.h" |
19 | 19 | ||
20 | static const struct mv88e6xxx_switch_id mv88e6171_table[] = { | 20 | static const struct mv88e6xxx_info mv88e6171_table[] = { |
21 | { PORT_SWITCH_ID_6171, "Marvell 88E6171" }, | 21 | { |
22 | { PORT_SWITCH_ID_6175, "Marvell 88E6175" }, | 22 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6171, |
23 | { PORT_SWITCH_ID_6350, "Marvell 88E6350" }, | 23 | .name = "Marvell 88E6171", |
24 | { PORT_SWITCH_ID_6351, "Marvell 88E6351" }, | 24 | }, { |
25 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6175, | ||
26 | .name = "Marvell 88E6175", | ||
27 | }, { | ||
28 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6350, | ||
29 | .name = "Marvell 88E6350", | ||
30 | }, { | ||
31 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6351, | ||
32 | .name = "Marvell 88E6351", | ||
33 | } | ||
25 | }; | 34 | }; |
26 | 35 | ||
27 | static const char *mv88e6171_drv_probe(struct device *dsa_dev, | 36 | static const char *mv88e6171_drv_probe(struct device *dsa_dev, |
diff --git a/drivers/net/dsa/mv88e6352.c b/drivers/net/dsa/mv88e6352.c index 34f92b17146b..2f72606ecc9e 100644 --- a/drivers/net/dsa/mv88e6352.c +++ b/drivers/net/dsa/mv88e6352.c | |||
@@ -22,13 +22,26 @@ | |||
22 | #include <net/dsa.h> | 22 | #include <net/dsa.h> |
23 | #include "mv88e6xxx.h" | 23 | #include "mv88e6xxx.h" |
24 | 24 | ||
25 | static const struct mv88e6xxx_switch_id mv88e6352_table[] = { | 25 | static const struct mv88e6xxx_info mv88e6352_table[] = { |
26 | { PORT_SWITCH_ID_6172, "Marvell 88E6172" }, | 26 | { |
27 | { PORT_SWITCH_ID_6176, "Marvell 88E6176" }, | 27 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6320, |
28 | { PORT_SWITCH_ID_6240, "Marvell 88E6240" }, | 28 | .name = "Marvell 88E6320", |
29 | { PORT_SWITCH_ID_6320, "Marvell 88E6320" }, | 29 | }, { |
30 | { PORT_SWITCH_ID_6321, "Marvell 88E6321" }, | 30 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6321, |
31 | { PORT_SWITCH_ID_6352, "Marvell 88E6352" }, | 31 | .name = "Marvell 88E6321", |
32 | }, { | ||
33 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6172, | ||
34 | .name = "Marvell 88E6172", | ||
35 | }, { | ||
36 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6176, | ||
37 | .name = "Marvell 88E6176", | ||
38 | }, { | ||
39 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6240, | ||
40 | .name = "Marvell 88E6240", | ||
41 | }, { | ||
42 | .prod_num = PORT_SWITCH_ID_PROD_NUM_6352, | ||
43 | .name = "Marvell 88E6352", | ||
44 | } | ||
32 | }; | 45 | }; |
33 | 46 | ||
34 | static const char *mv88e6352_drv_probe(struct device *dsa_dev, | 47 | static const char *mv88e6352_drv_probe(struct device *dsa_dev, |
diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c index 49f085a8453d..5fb21e059f35 100644 --- a/drivers/net/dsa/mv88e6xxx.c +++ b/drivers/net/dsa/mv88e6xxx.c | |||
@@ -3169,24 +3169,25 @@ int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm) | |||
3169 | } | 3169 | } |
3170 | #endif /* CONFIG_NET_DSA_HWMON */ | 3170 | #endif /* CONFIG_NET_DSA_HWMON */ |
3171 | 3171 | ||
3172 | static const char * | 3172 | static const struct mv88e6xxx_info * |
3173 | mv88e6xxx_lookup_name(unsigned int id, const struct mv88e6xxx_switch_id *table, | 3173 | mv88e6xxx_lookup_info(unsigned int prod_num, const struct mv88e6xxx_info *table, |
3174 | unsigned int num) | 3174 | unsigned int num) |
3175 | { | 3175 | { |
3176 | int i; | 3176 | int i; |
3177 | 3177 | ||
3178 | for (i = 0; i < num; ++i) | 3178 | for (i = 0; i < num; ++i) |
3179 | if (table[i].id == (id & 0xfff0)) | 3179 | if (table[i].prod_num == prod_num) |
3180 | return table[i].name; | 3180 | return &table[i]; |
3181 | 3181 | ||
3182 | return NULL; | 3182 | return NULL; |
3183 | } | 3183 | } |
3184 | 3184 | ||
3185 | const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, | 3185 | const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, |
3186 | int sw_addr, void **priv, | 3186 | int sw_addr, void **priv, |
3187 | const struct mv88e6xxx_switch_id *table, | 3187 | const struct mv88e6xxx_info *table, |
3188 | unsigned int num) | 3188 | unsigned int num) |
3189 | { | 3189 | { |
3190 | const struct mv88e6xxx_info *info; | ||
3190 | struct mv88e6xxx_priv_state *ps; | 3191 | struct mv88e6xxx_priv_state *ps; |
3191 | struct mii_bus *bus; | 3192 | struct mii_bus *bus; |
3192 | const char *name; | 3193 | const char *name; |
@@ -3203,16 +3204,19 @@ const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, | |||
3203 | prod_num = (id & 0xfff0) >> 4; | 3204 | prod_num = (id & 0xfff0) >> 4; |
3204 | rev = id & 0x000f; | 3205 | rev = id & 0x000f; |
3205 | 3206 | ||
3206 | name = mv88e6xxx_lookup_name(id, table, num); | 3207 | info = mv88e6xxx_lookup_info(prod_num, table, num); |
3207 | if (!name) | 3208 | if (!info) |
3208 | return NULL; | 3209 | return NULL; |
3209 | 3210 | ||
3211 | name = info->name; | ||
3212 | |||
3210 | ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL); | 3213 | ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL); |
3211 | if (!ps) | 3214 | if (!ps) |
3212 | return NULL; | 3215 | return NULL; |
3213 | 3216 | ||
3214 | ps->bus = bus; | 3217 | ps->bus = bus; |
3215 | ps->sw_addr = sw_addr; | 3218 | ps->sw_addr = sw_addr; |
3219 | ps->info = info; | ||
3216 | ps->id = id & 0xfff0; | 3220 | ps->id = id & 0xfff0; |
3217 | 3221 | ||
3218 | *priv = ps; | 3222 | *priv = ps; |
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h index 6513450d60bf..b87f574a84de 100644 --- a/drivers/net/dsa/mv88e6xxx.h +++ b/drivers/net/dsa/mv88e6xxx.h | |||
@@ -68,6 +68,23 @@ | |||
68 | #define PORT_PCS_CTRL_UNFORCED 0x03 | 68 | #define PORT_PCS_CTRL_UNFORCED 0x03 |
69 | #define PORT_PAUSE_CTRL 0x02 | 69 | #define PORT_PAUSE_CTRL 0x02 |
70 | #define PORT_SWITCH_ID 0x03 | 70 | #define PORT_SWITCH_ID 0x03 |
71 | #define PORT_SWITCH_ID_PROD_NUM_6085 0x04a | ||
72 | #define PORT_SWITCH_ID_PROD_NUM_6095 0x095 | ||
73 | #define PORT_SWITCH_ID_PROD_NUM_6131 0x106 | ||
74 | #define PORT_SWITCH_ID_PROD_NUM_6320 0x115 | ||
75 | #define PORT_SWITCH_ID_PROD_NUM_6123 0x121 | ||
76 | #define PORT_SWITCH_ID_PROD_NUM_6161 0x161 | ||
77 | #define PORT_SWITCH_ID_PROD_NUM_6165 0x165 | ||
78 | #define PORT_SWITCH_ID_PROD_NUM_6171 0x171 | ||
79 | #define PORT_SWITCH_ID_PROD_NUM_6172 0x172 | ||
80 | #define PORT_SWITCH_ID_PROD_NUM_6175 0x175 | ||
81 | #define PORT_SWITCH_ID_PROD_NUM_6176 0x176 | ||
82 | #define PORT_SWITCH_ID_PROD_NUM_6185 0x1a7 | ||
83 | #define PORT_SWITCH_ID_PROD_NUM_6240 0x240 | ||
84 | #define PORT_SWITCH_ID_PROD_NUM_6321 0x310 | ||
85 | #define PORT_SWITCH_ID_PROD_NUM_6352 0x352 | ||
86 | #define PORT_SWITCH_ID_PROD_NUM_6350 0x371 | ||
87 | #define PORT_SWITCH_ID_PROD_NUM_6351 0x375 | ||
71 | #define PORT_SWITCH_ID_6031 0x0310 | 88 | #define PORT_SWITCH_ID_6031 0x0310 |
72 | #define PORT_SWITCH_ID_6035 0x0350 | 89 | #define PORT_SWITCH_ID_6035 0x0350 |
73 | #define PORT_SWITCH_ID_6046 0x0480 | 90 | #define PORT_SWITCH_ID_6046 0x0480 |
@@ -352,9 +369,9 @@ | |||
352 | 369 | ||
353 | #define MV88E6XXX_N_FID 4096 | 370 | #define MV88E6XXX_N_FID 4096 |
354 | 371 | ||
355 | struct mv88e6xxx_switch_id { | 372 | struct mv88e6xxx_info { |
356 | u16 id; | 373 | u16 prod_num; |
357 | char *name; | 374 | const char *name; |
358 | }; | 375 | }; |
359 | 376 | ||
360 | struct mv88e6xxx_atu_entry { | 377 | struct mv88e6xxx_atu_entry { |
@@ -382,6 +399,8 @@ struct mv88e6xxx_priv_port { | |||
382 | }; | 399 | }; |
383 | 400 | ||
384 | struct mv88e6xxx_priv_state { | 401 | struct mv88e6xxx_priv_state { |
402 | const struct mv88e6xxx_info *info; | ||
403 | |||
385 | /* The dsa_switch this private structure is related to */ | 404 | /* The dsa_switch this private structure is related to */ |
386 | struct dsa_switch *ds; | 405 | struct dsa_switch *ds; |
387 | 406 | ||
@@ -449,7 +468,7 @@ struct mv88e6xxx_hw_stat { | |||
449 | int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active); | 468 | int mv88e6xxx_switch_reset(struct dsa_switch *ds, bool ppu_active); |
450 | const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, | 469 | const char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev, |
451 | int sw_addr, void **priv, | 470 | int sw_addr, void **priv, |
452 | const struct mv88e6xxx_switch_id *table, | 471 | const struct mv88e6xxx_info *table, |
453 | unsigned int num); | 472 | unsigned int num); |
454 | 473 | ||
455 | int mv88e6xxx_setup_ports(struct dsa_switch *ds); | 474 | int mv88e6xxx_setup_ports(struct dsa_switch *ds); |