aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/igc/igc_main.c
diff options
context:
space:
mode:
authorSasha Neftin <sasha.neftin@intel.com>2018-10-11 03:17:08 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-10-17 15:14:54 -0400
commitd89f88419f999f03af2282789f2d2eea6468c00a (patch)
tree53e347670c8d9465b48e68edbe7d04c20fbe3312 /drivers/net/ethernet/intel/igc/igc_main.c
parentaadd4355918fe6e9044a9042fa5968e0a0901681 (diff)
igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller support
This patch adds the beginning framework onto which I am going to add the igc driver which supports the Intel(R) I225-LM/I225-V 2.5G Ethernet Controller. Signed-off-by: Sasha Neftin <sasha.neftin@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/igc/igc_main.c')
-rw-r--r--drivers/net/ethernet/intel/igc/igc_main.c146
1 files changed, 146 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
new file mode 100644
index 000000000000..753749ce5ae0
--- /dev/null
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -0,0 +1,146 @@
1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2018 Intel Corporation */
3
4#include <linux/module.h>
5#include <linux/types.h>
6
7#include "igc.h"
8#include "igc_hw.h"
9
10#define DRV_VERSION "0.0.1-k"
11#define DRV_SUMMARY "Intel(R) 2.5G Ethernet Linux Driver"
12
13MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
14MODULE_DESCRIPTION(DRV_SUMMARY);
15MODULE_LICENSE("GPL v2");
16MODULE_VERSION(DRV_VERSION);
17
18char igc_driver_name[] = "igc";
19char igc_driver_version[] = DRV_VERSION;
20static const char igc_driver_string[] = DRV_SUMMARY;
21static const char igc_copyright[] =
22 "Copyright(c) 2018 Intel Corporation.";
23
24static const struct pci_device_id igc_pci_tbl[] = {
25 { PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_LM) },
26 { PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_V) },
27 /* required last entry */
28 {0, }
29};
30
31MODULE_DEVICE_TABLE(pci, igc_pci_tbl);
32
33/**
34 * igc_probe - Device Initialization Routine
35 * @pdev: PCI device information struct
36 * @ent: entry in igc_pci_tbl
37 *
38 * Returns 0 on success, negative on failure
39 *
40 * igc_probe initializes an adapter identified by a pci_dev structure.
41 * The OS initialization, configuring the adapter private structure,
42 * and a hardware reset occur.
43 */
44static int igc_probe(struct pci_dev *pdev,
45 const struct pci_device_id *ent)
46{
47 int err, pci_using_dac;
48
49 err = pci_enable_device_mem(pdev);
50 if (err)
51 return err;
52
53 pci_using_dac = 0;
54 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
55 if (!err) {
56 err = dma_set_coherent_mask(&pdev->dev,
57 DMA_BIT_MASK(64));
58 if (!err)
59 pci_using_dac = 1;
60 } else {
61 err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
62 if (err) {
63 err = dma_set_coherent_mask(&pdev->dev,
64 DMA_BIT_MASK(32));
65 if (err) {
66 IGC_ERR("Wrong DMA configuration, aborting\n");
67 goto err_dma;
68 }
69 }
70 }
71
72 err = pci_request_selected_regions(pdev,
73 pci_select_bars(pdev,
74 IORESOURCE_MEM),
75 igc_driver_name);
76 if (err)
77 goto err_pci_reg;
78
79 pci_set_master(pdev);
80 err = pci_save_state(pdev);
81 return 0;
82
83err_pci_reg:
84err_dma:
85 pci_disable_device(pdev);
86 return err;
87}
88
89/**
90 * igc_remove - Device Removal Routine
91 * @pdev: PCI device information struct
92 *
93 * igc_remove is called by the PCI subsystem to alert the driver
94 * that it should release a PCI device. This could be caused by a
95 * Hot-Plug event, or because the driver is going to be removed from
96 * memory.
97 */
98static void igc_remove(struct pci_dev *pdev)
99{
100 pci_release_selected_regions(pdev,
101 pci_select_bars(pdev, IORESOURCE_MEM));
102
103 pci_disable_device(pdev);
104}
105
106static struct pci_driver igc_driver = {
107 .name = igc_driver_name,
108 .id_table = igc_pci_tbl,
109 .probe = igc_probe,
110 .remove = igc_remove,
111};
112
113/**
114 * igc_init_module - Driver Registration Routine
115 *
116 * igc_init_module is the first routine called when the driver is
117 * loaded. All it does is register with the PCI subsystem.
118 */
119static int __init igc_init_module(void)
120{
121 int ret;
122
123 pr_info("%s - version %s\n",
124 igc_driver_string, igc_driver_version);
125
126 pr_info("%s\n", igc_copyright);
127
128 ret = pci_register_driver(&igc_driver);
129 return ret;
130}
131
132module_init(igc_init_module);
133
134/**
135 * igc_exit_module - Driver Exit Cleanup Routine
136 *
137 * igc_exit_module is called just before the driver is removed
138 * from memory.
139 */
140static void __exit igc_exit_module(void)
141{
142 pci_unregister_driver(&igc_driver);
143}
144
145module_exit(igc_exit_module);
146/* igc_main.c */