hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/net/ethernet/wiznet/w5100-spi.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Ethernet driver for the WIZnet W5100/W5200/W5500 chip.
34 *
45 * Copyright (C) 2016 Akinobu Mita <akinobu.mita@gmail.com>
5
- *
6
- * Licensed under the GPL-2 or later.
76 *
87 * Datasheet:
98 * http://www.wiznet.co.kr/wp-content/uploads/wiznethome/Chip/W5100/Document/W5100_Datasheet_v1.2.6.pdf
....@@ -16,6 +15,7 @@
1615 #include <linux/delay.h>
1716 #include <linux/netdevice.h>
1817 #include <linux/of_net.h>
18
+#include <linux/of_device.h>
1919 #include <linux/spi/spi.h>
2020
2121 #include "w5100.h"
....@@ -410,14 +410,32 @@
410410 .init = w5500_spi_init,
411411 };
412412
413
+static const struct of_device_id w5100_of_match[] = {
414
+ { .compatible = "wiznet,w5100", .data = (const void*)W5100, },
415
+ { .compatible = "wiznet,w5200", .data = (const void*)W5200, },
416
+ { .compatible = "wiznet,w5500", .data = (const void*)W5500, },
417
+ { },
418
+};
419
+MODULE_DEVICE_TABLE(of, w5100_of_match);
420
+
413421 static int w5100_spi_probe(struct spi_device *spi)
414422 {
415
- const struct spi_device_id *id = spi_get_device_id(spi);
423
+ const struct of_device_id *of_id;
416424 const struct w5100_ops *ops;
425
+ kernel_ulong_t driver_data;
417426 int priv_size;
418427 const void *mac = of_get_mac_address(spi->dev.of_node);
419428
420
- switch (id->driver_data) {
429
+ if (spi->dev.of_node) {
430
+ of_id = of_match_device(w5100_of_match, &spi->dev);
431
+ if (!of_id)
432
+ return -ENODEV;
433
+ driver_data = (kernel_ulong_t)of_id->data;
434
+ } else {
435
+ driver_data = spi_get_device_id(spi)->driver_data;
436
+ }
437
+
438
+ switch (driver_data) {
421439 case W5100:
422440 ops = &w5100_spi_ops;
423441 priv_size = 0;
....@@ -454,6 +472,7 @@
454472 .driver = {
455473 .name = "w5100",
456474 .pm = &w5100_pm_ops,
475
+ .of_match_table = w5100_of_match,
457476 },
458477 .probe = w5100_spi_probe,
459478 .remove = w5100_spi_remove,