blob: 6d93ed2dd741c0e32d24919061250801251314bd [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Damien Zammite983f0c2016-05-21 02:24:19 +10002
3/*
Damien Zammitf5dd23f2016-12-01 23:29:34 +11004 * This driver resets the 10ec:8168 NIC then tries to read
5 * "macaddress" string XX:XX:XX:XX:XX:XX from CBFS.
6 * If no MAC is found, it programs a default MAC address in the device
Damien Zammite983f0c2016-05-21 02:24:19 +10007 * so that if the EEPROM/efuse is unconfigured it still has a default MAC.
8 */
9
Damien Zammitf5dd23f2016-12-01 23:29:34 +110010#include <cbfs.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -070011#include <acpi/acpi_device.h>
12#include <acpi/acpigen.h>
Damien Zammitf5dd23f2016-12-01 23:29:34 +110013#include <string.h>
Damien Zammite983f0c2016-05-21 02:24:19 +100014#include <arch/io.h>
Shelley Chen0528b612017-06-12 18:29:24 -070015#include <console/console.h>
Damien Zammite983f0c2016-05-21 02:24:19 +100016#include <device/device.h>
17#include <device/pci.h>
18#include <device/pci_ops.h>
Alan Huang769994c2021-11-10 10:59:13 +080019#include <device/pci_ids.h>
Damien Zammite983f0c2016-05-21 02:24:19 +100020#include <delay.h>
Shelley Chen0528b612017-06-12 18:29:24 -070021#include <fmap.h>
Elyes HAOUASbd1683d2019-05-15 21:05:37 +020022#include <types.h>
23
Gaggery Tsai65623ef2017-09-29 11:15:23 +080024#include "chip.h"
Damien Zammite983f0c2016-05-21 02:24:19 +100025
26#define NIC_TIMEOUT 1000
27
28#define CMD_REG 0x37
29#define CMD_REG_RESET 0x10
Gaggery Tsai65623ef2017-09-29 11:15:23 +080030#define CMD_LED0_LED1 0x18
Rory Liu2b1e7372021-11-22 10:42:25 +080031#define CMD_LED_FEATURE 0x94
32#define CMD_LEDSEL0 0x18
33#define CMD_LEDSEL2 0x84
Damien Zammite983f0c2016-05-21 02:24:19 +100034
35#define CFG_9346 0x50
36#define CFG_9346_LOCK 0x00
37#define CFG_9346_UNLOCK 0xc0
Alan Huangad90edc2022-01-18 11:39:05 +080038#define CMD_REG_ASPM 0xb0
39#define ASPM_L1_2_MASK 0xe059000f
Damien Zammite983f0c2016-05-21 02:24:19 +100040
Gaggery Tsai1f847042017-12-26 17:13:52 +080041#define DEVICE_INDEX_BYTE 12
42#define MAX_DEVICE_SUPPORT 10
Shelley Chen0528b612017-06-12 18:29:24 -070043/**
44 * search: Find first instance of string in a given region
45 * @param p string to find
46 * @param a start address of region to search
47 * @param lengthp length of string to search for
48 * @param lengtha length of region to search in
49 * @return offset offset from start address a where string was found.
50 * If string not found, return lengtha.
51 */
52static size_t search(const char *p, const u8 *a, size_t lengthp,
53 size_t lengtha)
54{
55 size_t i, j;
56
57 if (lengtha < lengthp)
58 return lengtha;
59 /* Searching */
60 for (j = 0; j <= lengtha - lengthp; j++) {
61 for (i = 0; i < lengthp && p[i] == a[i + j]; i++)
62 ;
David Wu9a0d9e02018-05-04 15:37:37 +080063 if (i >= lengthp && a[j - 1] == lengthp)
Shelley Chen0528b612017-06-12 18:29:24 -070064 return j;
65 }
66 return lengtha;
67}
68
Damien Zammitf5dd23f2016-12-01 23:29:34 +110069static u8 get_hex_digit(const u8 c)
Damien Zammite983f0c2016-05-21 02:24:19 +100070{
Damien Zammitf5dd23f2016-12-01 23:29:34 +110071 u8 ret = 0;
Damien Zammite983f0c2016-05-21 02:24:19 +100072
Damien Zammitf5dd23f2016-12-01 23:29:34 +110073 ret = c - '0';
74 if (ret > 0x09) {
75 ret = c - 'A' + 0x0a;
76 if (ret > 0x0f)
77 ret = c - 'a' + 0x0a;
78 }
79 if (ret > 0x0f) {
Julius Wernere9665952022-01-21 17:06:20 -080080 printk(BIOS_ERR, "Invalid hex digit found: "
Shelley Chen0528b612017-06-12 18:29:24 -070081 "%c - 0x%02x\n", (char)c, c);
Damien Zammitf5dd23f2016-12-01 23:29:34 +110082 ret = 0;
83 }
84 return ret;
85}
Damien Zammite983f0c2016-05-21 02:24:19 +100086
Shelley Chen0528b612017-06-12 18:29:24 -070087#define MACLEN 17
88
Edward O'Callaghan2a82f742020-03-25 12:52:50 +110089/* Returns MAC address based on the key that is passed in. */
90static enum cb_err fetch_mac_vpd_key(u8 *macstrbuf, const char *vpd_key)
Shelley Chen0528b612017-06-12 18:29:24 -070091{
92 struct region_device rdev;
93 void *search_address;
94 size_t search_length;
95 size_t offset;
Edward O'Callaghan2a82f742020-03-25 12:52:50 +110096
97 if (fmap_locate_area_as_rdev("RO_VPD", &rdev)) {
Julius Wernere9665952022-01-21 17:06:20 -080098 printk(BIOS_ERR, "Couldn't find RO_VPD region.");
Edward O'Callaghan2a82f742020-03-25 12:52:50 +110099 return CB_ERR;
100 }
101 search_address = rdev_mmap_full(&rdev);
102 if (search_address == NULL) {
103 printk(BIOS_ERR, "LAN: VPD not found.\n");
104 return CB_ERR;
105 }
106
107 search_length = region_device_sz(&rdev);
108 offset = search(vpd_key, search_address, strlen(vpd_key),
109 search_length);
110
111 if (offset == search_length) {
Matt DeVillier8a1de832023-01-26 14:37:44 -0600112 printk(BIOS_WARNING, "Could not locate '%s' in VPD\n", vpd_key);
Edward O'Callaghand08bc5a2020-03-26 14:37:37 +1100113 rdev_munmap(&rdev, search_address);
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100114 return CB_ERR;
115 }
116 printk(BIOS_DEBUG, "Located '%s' in VPD\n", vpd_key);
117
118 offset += strlen(vpd_key) + 1; /* move to next character */
119
120 if (offset + MACLEN > search_length) {
Edward O'Callaghand08bc5a2020-03-26 14:37:37 +1100121 rdev_munmap(&rdev, search_address);
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100122 printk(BIOS_ERR, "Search result too small!\n");
123 return CB_ERR;
124 }
125 memcpy(macstrbuf, search_address + offset, MACLEN);
Edward O'Callaghand08bc5a2020-03-26 14:37:37 +1100126 rdev_munmap(&rdev, search_address);
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100127
128 return CB_SUCCESS;
129}
130
131/* Prepares vpd_key by concatenating ethernet_mac with device_index */
132static enum cb_err fetch_mac_vpd_dev_idx(u8 *macstrbuf, u8 device_index)
133{
Gaggery Tsai1f847042017-12-26 17:13:52 +0800134 char key[] = "ethernet_mac "; /* Leave a space at tail to stuff an index */
135
136 /*
Edward O'Callaghan0e138062020-03-23 13:06:42 +1100137 * Map each NIC on the DUT to "ethernet_macN", where N is [0-9].
138 * Translate index number from integer to ascii by adding '0' char.
Gaggery Tsai1f847042017-12-26 17:13:52 +0800139 */
Edward O'Callaghan0e138062020-03-23 13:06:42 +1100140 key[DEVICE_INDEX_BYTE] = device_index + '0';
Shelley Chen0528b612017-06-12 18:29:24 -0700141
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100142 return fetch_mac_vpd_key(macstrbuf, key);
143}
144
145static void fetch_mac_string_vpd(struct drivers_net_config *config, u8 *macstrbuf)
146{
147 if (!config)
148 return;
149
150 /* Current implementation is up to 10 NIC cards */
151 if (config->device_index > MAX_DEVICE_SUPPORT) {
152 printk(BIOS_ERR, "r8168: the maximum device_index should be less then %d\n."
153 " Using default 00:e0:4c:00:c0:b0\n", MAX_DEVICE_SUPPORT);
154 return;
Shelley Chen0528b612017-06-12 18:29:24 -0700155 }
156
Edward O'Callaghan0e138062020-03-23 13:06:42 +1100157 if (fetch_mac_vpd_dev_idx(macstrbuf, config->device_index) == CB_SUCCESS)
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100158 return;
Gaggery Tsai1f847042017-12-26 17:13:52 +0800159
Edward O'Callaghan0e138062020-03-23 13:06:42 +1100160 if (!CONFIG(RT8168_SUPPORT_LEGACY_VPD_MAC)) {
161 printk(BIOS_ERR, "r8168: mac address not found in VPD,"
162 " using default 00:e0:4c:00:c0:b0\n");
163 return;
164 }
165
Edward O'Callaghan2a0a02f2020-03-26 16:47:55 +1100166 if (fetch_mac_vpd_key(macstrbuf, "ethernet_mac") != CB_SUCCESS)
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100167 printk(BIOS_ERR, "r8168: mac address not found in VPD,"
168 " using default 00:e0:4c:00:c0:b0\n");
Shelley Chen0528b612017-06-12 18:29:24 -0700169}
170
171static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf)
172{
Julius Werner77639e42021-02-05 16:51:25 -0800173 if (!cbfs_load("rt8168-macaddress", macstrbuf, MACLEN)) {
174 printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n");
175 return CB_ERR;
Shelley Chen0528b612017-06-12 18:29:24 -0700176 }
Julius Werner77639e42021-02-05 16:51:25 -0800177 return CB_SUCCESS;
Shelley Chen0528b612017-06-12 18:29:24 -0700178}
179
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100180static void get_mac_address(u8 *macaddr, const u8 *strbuf)
181{
182 size_t offset = 0;
183 int i;
184
Shelley Chen0528b612017-06-12 18:29:24 -0700185 if ((strbuf[2] != ':') || (strbuf[5] != ':') ||
186 (strbuf[8] != ':') || (strbuf[11] != ':') ||
187 (strbuf[14] != ':')) {
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100188 printk(BIOS_ERR, "r8168: ignore invalid MAC address in cbfs\n");
189 return;
190 }
191
192 for (i = 0; i < 6; i++) {
193 macaddr[i] = 0;
194 macaddr[i] |= get_hex_digit(strbuf[offset]) << 4;
195 macaddr[i] |= get_hex_digit(strbuf[offset + 1]);
196 offset += 3;
197 }
198}
199
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100200static void program_mac_address(struct device *dev, u16 io_base)
201{
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100202 u8 macstrbuf[MACLEN] = { 0 };
203 int i = 0;
Shelley Chen0528b612017-06-12 18:29:24 -0700204 /* Default MAC Address of 00:E0:4C:00:C0:B0 */
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100205 u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 };
Gaggery Tsai1f847042017-12-26 17:13:52 +0800206 struct drivers_net_config *config = dev->chip_info;
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100207
Shelley Chen0528b612017-06-12 18:29:24 -0700208 /* check the VPD for the mac address */
Julius Wernercd49cce2019-03-05 16:53:33 -0800209 if (CONFIG(RT8168_GET_MAC_FROM_VPD)) {
Edward O'Callaghan2a82f742020-03-25 12:52:50 +1100210 fetch_mac_string_vpd(config, macstrbuf);
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100211 } else {
Shelley Chen0528b612017-06-12 18:29:24 -0700212 if (fetch_mac_string_cbfs(macstrbuf) != CB_SUCCESS)
213 printk(BIOS_ERR, "r8168: Error reading MAC from CBFS,"
Gaggery Tsai1f847042017-12-26 17:13:52 +0800214 " using default 00:e0:4c:00:c0:b0\n");
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100215 }
Shelley Chen0528b612017-06-12 18:29:24 -0700216 get_mac_address(mac, macstrbuf);
Damien Zammite983f0c2016-05-21 02:24:19 +1000217
218 /* Reset NIC */
219 printk(BIOS_DEBUG, "r8168: Resetting NIC...");
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100220 outb(CMD_REG_RESET, io_base + CMD_REG);
Damien Zammite983f0c2016-05-21 02:24:19 +1000221
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100222 /* Poll for reset, with 1sec timeout */
223 while (i < NIC_TIMEOUT && (inb(io_base + CMD_REG) & CMD_REG_RESET)) {
Damien Zammite983f0c2016-05-21 02:24:19 +1000224 udelay(1000);
225 if (++i >= NIC_TIMEOUT)
Shelley Chen0528b612017-06-12 18:29:24 -0700226 printk(BIOS_ERR, "timeout waiting for nic to reset\n");
Damien Zammite983f0c2016-05-21 02:24:19 +1000227 }
228 if (i < NIC_TIMEOUT)
229 printk(BIOS_DEBUG, "done\n");
230
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100231 printk(BIOS_DEBUG, "r8168: Programming MAC Address...");
Damien Zammite983f0c2016-05-21 02:24:19 +1000232
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100233 /* Disable register protection */
234 outb(CFG_9346_UNLOCK, io_base + CFG_9346);
Damien Zammite983f0c2016-05-21 02:24:19 +1000235
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100236 /* Set MAC address: only 4-byte write accesses allowed */
237 outl(mac[4] | mac[5] << 8, io_base + 4);
238 inl(io_base + 4);
239 outl(mac[0] | mac[1] << 8 | mac[2] << 16 | mac[3] << 24,
240 io_base);
241 inl(io_base);
Damien Zammite983f0c2016-05-21 02:24:19 +1000242 /* Lock config regs */
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100243 outb(CFG_9346_LOCK, io_base + CFG_9346);
244
245 printk(BIOS_DEBUG, "done\n");
246}
247
Alan Huangad90edc2022-01-18 11:39:05 +0800248static void enable_aspm_l1_2(u16 io_base)
249{
250 printk(BIOS_INFO, "rtl: Enable ASPM L1.2\n");
251
252 /* Disable register protection */
253 outb(CFG_9346_UNLOCK, io_base + CFG_9346);
254
255 /* Enable ASPM_L1.2 */
256 outl(ASPM_L1_2_MASK, io_base + CMD_REG_ASPM);
257
258 /* Lock config regs */
259 outb(CFG_9346_LOCK, io_base + CFG_9346);
260}
261
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800262static void r8168_set_customized_led(struct device *dev, u16 io_base)
263{
264 struct drivers_net_config *config = dev->chip_info;
265
266 if (!config)
267 return;
268
Felix Singer43b7f412022-03-07 04:34:52 +0100269 if (dev->device == PCI_DID_REALTEK_8125) {
Rory Liu2b1e7372021-11-22 10:42:25 +0800270 /* Set LED global Feature register */
271 outb(config->led_feature, io_base + CMD_LED_FEATURE);
272 printk(BIOS_DEBUG, "r8125: read back LED global feature setting as 0x%x\n",
273 inb(io_base + CMD_LED_FEATURE));
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800274
Rory Liu2b1e7372021-11-22 10:42:25 +0800275 /*
276 * Refer to RTL8125 datasheet 5.Customizable LED Configuration
277 * Register Name IO Address
278 * LEDSEL0 0x18
279 * LEDSEL2 0x84
280 * LEDFEATURE 0x94
281 *
282 * LEDSEL Bit[] Description
283 * Bit0 Link10M
284 * Bit1 Link100M
285 * Bit3 Link1000M
286 * Bit5 Link2.5G
287 * Bit9 ACT
288 * Bit10 preboot enable
289 * Bit11 lp enable
290 * Bit12 active low/high
291 *
292 * LEDFEATURE Description
293 * Bit0 LED Table V1/V2
294 * Bit1~3 Reserved
295 * Bit4~5 LED Blinking Duty Cycle 12.5%/ 25%/ 50%/ 75%
296 * Bit6~7 LED Blinking Freq. 240ms/160ms/80ms/Link-Speed-Dependent
297 */
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800298
Rory Liu2b1e7372021-11-22 10:42:25 +0800299 /* Set customized LED0 register */
300 outw(config->customized_led0, io_base + CMD_LEDSEL0);
301 printk(BIOS_DEBUG, "r8125: read back LED0 setting as 0x%x\n",
302 inw(io_base + CMD_LEDSEL0));
303
304 /* Set customized LED2 register */
305 outw(config->customized_led2, io_base + CMD_LEDSEL2);
306 printk(BIOS_DEBUG, "r8125: read back LED2 setting as 0x%x\n",
307 inw(io_base + CMD_LEDSEL2));
308 } else {
309 /* Read the customized LED setting from devicetree */
310 printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds);
311
312 /*
313 * Refer to RTL8111H datasheet 7.2 Customizable LED Configuration
314 * Starting from offset 0x18
315 * Bit[15:12] LED Feature Control(FC)
316 * Bit[11:08] LED Select for PINLED2
317 * Bit[07:04] LED Select for PINLED1
318 * Bit[03:00] LED Select for PINLED0
319 *
320 * Speed Link10M Link100M Link1000M ACT/Full
321 * LED0 Bit0 Bit1 Bit2 Bit3
322 * LED1 Bit4 Bit5 Bit6 Bit7
323 * LED2 Bit8 Bit9 Bit10 Bit11
324 * FC Bit12 Bit13 Bit14 Bit15
325 */
326
327 /* Set customized LED registers */
328 outw(config->customized_leds, io_base + CMD_LED0_LED1);
329 printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n",
330 inw(io_base + CMD_LED0_LED1));
331 }
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800332}
333
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100334static void r8168_init(struct device *dev)
335{
336 /* Get the resource of the NIC mmio */
337 struct resource *nic_res = find_resource(dev, PCI_BASE_ADDRESS_0);
338 u16 io_base = (u16)nic_res->base;
339
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800340 /* Check if the base is invalid */
341 if (!io_base) {
Martin Roth0949e732021-10-01 14:28:22 -0600342 printk(BIOS_ERR, "r8168: Error can't find IO resource\n");
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800343 return;
344 }
Damien Zammitf5dd23f2016-12-01 23:29:34 +1100345 /* Enable but do not set bus master */
346 pci_write_config16(dev, PCI_COMMAND,
347 PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
348
349 /* Program MAC address based on CBFS "macaddress" containing
350 * a string AA:BB:CC:DD:EE:FF */
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800351 program_mac_address(dev, io_base);
352
353 /* Program customized LED mode */
Julius Wernercd49cce2019-03-05 16:53:33 -0800354 if (CONFIG(RT8168_SET_LED_MODE))
Gaggery Tsai65623ef2017-09-29 11:15:23 +0800355 r8168_set_customized_led(dev, io_base);
Alan Huangad90edc2022-01-18 11:39:05 +0800356
357 struct drivers_net_config *config = dev->chip_info;
358 if (CONFIG(PCIEXP_ASPM) && config->enable_aspm_l1_2)
359 enable_aspm_l1_2(io_base);
Damien Zammite983f0c2016-05-21 02:24:19 +1000360}
361
Julius Wernercd49cce2019-03-05 16:53:33 -0800362#if CONFIG(HAVE_ACPI_TABLES)
Gaggery Tsai6919a932017-11-16 17:21:23 +0800363#define R8168_ACPI_HID "R8168"
Furquan Shaikh7536a392020-04-24 21:59:21 -0700364static void r8168_net_fill_ssdt(const struct device *dev)
Gaggery Tsai6919a932017-11-16 17:21:23 +0800365{
366 struct drivers_net_config *config = dev->chip_info;
Arthur Heymans7fcd4d52023-08-24 15:12:19 +0200367 const char *path = acpi_device_path(dev->upstream->dev);
Gaggery Tsai6919a932017-11-16 17:21:23 +0800368 u32 address;
369
370 if (!path || !config)
371 return;
372
373 /* Device */
374 acpigen_write_scope(path);
375 acpigen_write_device(acpi_device_name(dev));
376 acpigen_write_name_string("_HID", R8168_ACPI_HID);
Patrick Rudolphc83bab62019-12-13 12:16:06 +0100377 acpi_device_write_uid(dev);
378
Gaggery Tsai6919a932017-11-16 17:21:23 +0800379 if (dev->chip_ops)
380 acpigen_write_name_string("_DDN", dev->chip_ops->name);
Matt DeVillierb8a0e642019-05-04 17:58:38 -0500381 acpigen_write_STA(ACPI_STATUS_DEVICE_HIDDEN_ON);
Gaggery Tsai6919a932017-11-16 17:21:23 +0800382
Edward O'Callaghanb765fa62020-01-21 21:01:32 +1100383 /* Power Resource */
Arthur Heymans59a348b2021-10-27 18:27:58 +0200384 if (CONFIG(RT8168_GEN_ACPI_POWER_RESOURCE) && config->has_power_resource) {
Edward O'Callaghanb765fa62020-01-21 21:01:32 +1100385 const struct acpi_power_res_params power_res_params = {
386 .stop_gpio = &config->stop_gpio,
387 .stop_delay_ms = config->stop_delay_ms,
388 .stop_off_delay_ms = config->stop_off_delay_ms
389 };
390 acpi_device_add_power_res(&power_res_params);
391 }
392
Gaggery Tsai6919a932017-11-16 17:21:23 +0800393 /* Address */
394 address = PCI_SLOT(dev->path.pci.devfn) & 0xffff;
395 address <<= 16;
396 address |= PCI_FUNC(dev->path.pci.devfn) & 0xffff;
397 acpigen_write_name_dword("_ADR", address);
398
399 /* Wake capabilities */
400 if (config->wake)
401 acpigen_write_PRW(config->wake, 3);
402
Kapil Porwal4c2c2c42022-11-26 02:34:58 +0530403 if (config->add_acpi_dma_property)
404 acpi_device_add_dma_property(NULL);
405
Gaggery Tsai6919a932017-11-16 17:21:23 +0800406 acpigen_pop_len(); /* Device */
407 acpigen_pop_len(); /* Scope */
408
409 printk(BIOS_INFO, "%s.%s: %s %s\n", path, acpi_device_name(dev),
410 dev->chip_ops ? dev->chip_ops->name : "", dev_path(dev));
411}
412
413static const char *r8168_net_acpi_name(const struct device *dev)
414{
415 return "RLTK";
416}
417#endif
418
Damien Zammite983f0c2016-05-21 02:24:19 +1000419static struct device_operations r8168_ops = {
Martin Rothb9810a42017-07-23 20:00:04 -0600420 .read_resources = pci_dev_read_resources,
421 .set_resources = pci_dev_set_resources,
422 .enable_resources = pci_dev_enable_resources,
423 .init = r8168_init,
Julius Wernercd49cce2019-03-05 16:53:33 -0800424#if CONFIG(HAVE_ACPI_TABLES)
Nico Huber68680dd2020-03-31 17:34:52 +0200425 .acpi_name = r8168_net_acpi_name,
426 .acpi_fill_ssdt = r8168_net_fill_ssdt,
Gaggery Tsai6919a932017-11-16 17:21:23 +0800427#endif
Damien Zammite983f0c2016-05-21 02:24:19 +1000428};
429
Alan Huang769994c2021-11-10 10:59:13 +0800430static const unsigned short pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +0100431 PCI_DID_REALTEK_8168,
432 PCI_DID_REALTEK_8125,
Raihow Shicb772e52022-03-23 11:24:33 +0800433 PCI_DID_REALTEK_8111,
Alan Huang769994c2021-11-10 10:59:13 +0800434 0
435};
436
Damien Zammite983f0c2016-05-21 02:24:19 +1000437static const struct pci_driver r8168_driver __pci_driver = {
Martin Rothb9810a42017-07-23 20:00:04 -0600438 .ops = &r8168_ops,
Felix Singer43b7f412022-03-07 04:34:52 +0100439 .vendor = PCI_VID_REALTEK,
Alan Huang769994c2021-11-10 10:59:13 +0800440 .devices = pci_device_ids,
Damien Zammite983f0c2016-05-21 02:24:19 +1000441};
Gaggery Tsai6919a932017-11-16 17:21:23 +0800442
443struct chip_operations drivers_net_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +0900444 .name = "Realtek r8168",
Gaggery Tsai6919a932017-11-16 17:21:23 +0800445};