]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
net: ethernet: xilinx: Add support for config structure
authorKedareswara rao Appana <appanad@xilinx.com>
Mon, 18 Sep 2017 05:58:43 +0000 (11:28 +0530)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 15 Mar 2018 14:17:45 +0000 (15:17 +0100)
This patch adds config structure in the driver to differentiate
different macs.

Signed-off-by: Kedareswara rao Appana <appanad@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/net/ethernet/xilinx/xilinx_axienet.h
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index d8132b18a89d5bdf4512cb4ca11e12a17b5fc527..7e7be706e381f61511e2a8bb2e9c7840fb7f60f2 100644 (file)
@@ -428,6 +428,7 @@ struct axidma_bd {
  * @phy_interface: Phy interface type.
  * @phy_flags: Phy interface flags.
  * @eth_hasnobuf: Ethernet is configured in Non buf mode.
+ * @axienet_config: Ethernet config structure
  */
 struct axienet_local {
        struct net_device *ndev;
@@ -476,6 +477,22 @@ struct axienet_local {
        u32 phy_interface;
        u32 phy_flags;
        bool eth_hasnobuf;
+       const struct axienet_config *axienet_config;
+};
+
+/**
+ * enum axienet_ip_type - AXIENET IP/MAC type.
+ *
+ * @XAXIENET_1G:        IP is 1G MAC
+ *
+ */
+enum axienet_ip_type {
+       XAXIENET_1G = 0,
+};
+
+struct axienet_config {
+       enum axienet_ip_type mactype;
+       void (*setoptions)(struct net_device *ndev, u32 options);
 };
 
 /**
index 4c5c0a95f1222e3daa17c7ba8ce89f890bb13d3f..a37ecedf2669ac31806c3b5da344d60652fbd2cf 100644 (file)
 
 #define AXIENET_REGS_N         32
 
-/* Match table for of_platform binding */
-static const struct of_device_id axienet_of_match[] = {
-       { .compatible = "xlnx,axi-ethernet-1.00.a", },
-       { .compatible = "xlnx,axi-ethernet-1.01.a", },
-       { .compatible = "xlnx,axi-ethernet-2.01.a", },
-       {},
-};
-
-MODULE_DEVICE_TABLE(of, axienet_of_match);
-
 /* Option table for setting up Axi Ethernet hardware options */
 static struct axienet_option axienet_options[] = {
        /* Turn on jumbo packet support for both Rx and Tx */
@@ -1544,6 +1534,21 @@ static void axienet_dma_err_handler(unsigned long data)
        axienet_setoptions(ndev, lp->options);
 }
 
+static const struct axienet_config axienet_1g_config = {
+       .mactype = XAXIENET_1G,
+       .setoptions = axienet_setoptions,
+};
+
+/* Match table for of_platform binding */
+static const struct of_device_id axienet_of_match[] = {
+       { .compatible = "xlnx,axi-ethernet-1.00.a", .data = &axienet_1g_config},
+       { .compatible = "xlnx,axi-ethernet-1.01.a", .data = &axienet_1g_config},
+       { .compatible = "xlnx,axi-ethernet-2.01.a", .data = &axienet_1g_config},
+       {},
+};
+
+MODULE_DEVICE_TABLE(of, axienet_of_match);
+
 /**
  * axienet_probe - Axi Ethernet probe function.
  * @pdev:      Pointer to platform device structure.
@@ -1598,6 +1603,14 @@ static int axienet_probe(struct platform_device *pdev)
        /* Setup checksum offload, but default to off if not specified */
        lp->features = 0;
 
+       if (pdev->dev.of_node) {
+               const struct of_device_id *match;
+
+               match = of_match_node(axienet_of_match, pdev->dev.of_node);
+               if (match && match->data)
+                       lp->axienet_config = match->data;
+       }
+
        ret = of_property_read_u32(pdev->dev.of_node, "xlnx,txcsum", &value);
        if (!ret) {
                switch (value) {