Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | /* |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 15 | * This driver resets the 10ec:8168 NIC then tries to read |
| 16 | * "macaddress" string XX:XX:XX:XX:XX:XX from CBFS. |
| 17 | * If no MAC is found, it programs a default MAC address in the device |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 18 | * so that if the EEPROM/efuse is unconfigured it still has a default MAC. |
| 19 | */ |
| 20 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 21 | #include <cbfs.h> |
Gaggery Tsai | 6919a93 | 2017-11-16 17:21:23 +0800 | [diff] [blame] | 22 | #include <arch/acpi_device.h> |
| 23 | #include <arch/acpigen.h> |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 24 | #include <string.h> |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 25 | #include <arch/io.h> |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 26 | #include <console/console.h> |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 27 | #include <device/device.h> |
| 28 | #include <device/pci.h> |
| 29 | #include <device/pci_ops.h> |
| 30 | #include <device/pci_def.h> |
| 31 | #include <delay.h> |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 32 | #include <fmap.h> |
Elyes HAOUAS | bd1683d | 2019-05-15 21:05:37 +0200 | [diff] [blame] | 33 | #include <types.h> |
| 34 | |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 35 | #include "chip.h" |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 36 | |
| 37 | #define NIC_TIMEOUT 1000 |
| 38 | |
| 39 | #define CMD_REG 0x37 |
| 40 | #define CMD_REG_RESET 0x10 |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 41 | #define CMD_LED0_LED1 0x18 |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 42 | |
| 43 | #define CFG_9346 0x50 |
| 44 | #define CFG_9346_LOCK 0x00 |
| 45 | #define CFG_9346_UNLOCK 0xc0 |
| 46 | |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 47 | #define DEVICE_INDEX_BYTE 12 |
| 48 | #define MAX_DEVICE_SUPPORT 10 |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 49 | /** |
| 50 | * search: Find first instance of string in a given region |
| 51 | * @param p string to find |
| 52 | * @param a start address of region to search |
| 53 | * @param lengthp length of string to search for |
| 54 | * @param lengtha length of region to search in |
| 55 | * @return offset offset from start address a where string was found. |
| 56 | * If string not found, return lengtha. |
| 57 | */ |
| 58 | static size_t search(const char *p, const u8 *a, size_t lengthp, |
| 59 | size_t lengtha) |
| 60 | { |
| 61 | size_t i, j; |
| 62 | |
| 63 | if (lengtha < lengthp) |
| 64 | return lengtha; |
| 65 | /* Searching */ |
| 66 | for (j = 0; j <= lengtha - lengthp; j++) { |
| 67 | for (i = 0; i < lengthp && p[i] == a[i + j]; i++) |
| 68 | ; |
David Wu | 9a0d9e0 | 2018-05-04 15:37:37 +0800 | [diff] [blame] | 69 | if (i >= lengthp && a[j - 1] == lengthp) |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 70 | return j; |
| 71 | } |
| 72 | return lengtha; |
| 73 | } |
| 74 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 75 | static u8 get_hex_digit(const u8 c) |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 76 | { |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 77 | u8 ret = 0; |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 78 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 79 | ret = c - '0'; |
| 80 | if (ret > 0x09) { |
| 81 | ret = c - 'A' + 0x0a; |
| 82 | if (ret > 0x0f) |
| 83 | ret = c - 'a' + 0x0a; |
| 84 | } |
| 85 | if (ret > 0x0f) { |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 86 | printk(BIOS_ERR, "Error: Invalid hex digit found: " |
| 87 | "%c - 0x%02x\n", (char)c, c); |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 88 | ret = 0; |
| 89 | } |
| 90 | return ret; |
| 91 | } |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 92 | |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 93 | #define MACLEN 17 |
| 94 | |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 95 | static enum cb_err fetch_mac_string_vpd(u8 *macstrbuf, const u8 device_index) |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 96 | { |
| 97 | struct region_device rdev; |
| 98 | void *search_address; |
| 99 | size_t search_length; |
| 100 | size_t offset; |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 101 | char key[] = "ethernet_mac "; /* Leave a space at tail to stuff an index */ |
| 102 | |
| 103 | /* |
| 104 | * The device_index 0 is treated as an special case matching to |
| 105 | * "ethernet_mac" with single NIC on DUT. When there are mulitple |
| 106 | * NICs on DUT, they are mapping to "ethernet_macN", where |
| 107 | * N is [0-9]. |
| 108 | */ |
| 109 | if (device_index == 0) |
| 110 | key[DEVICE_INDEX_BYTE] = '\0'; |
| 111 | else |
| 112 | /* Translate index number from integer to ascii */ |
| 113 | key[DEVICE_INDEX_BYTE] = (device_index - 1) + '0'; |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 114 | |
| 115 | if (fmap_locate_area_as_rdev("RO_VPD", &rdev)) { |
| 116 | printk(BIOS_ERR, "Error: Couldn't find RO_VPD region."); |
| 117 | return CB_ERR; |
| 118 | } |
| 119 | search_address = rdev_mmap_full(&rdev); |
| 120 | if (search_address == NULL) { |
| 121 | printk(BIOS_ERR, "LAN: VPD not found.\n"); |
| 122 | return CB_ERR; |
| 123 | } |
| 124 | |
| 125 | search_length = region_device_sz(&rdev); |
| 126 | offset = search(key, search_address, strlen(key), |
| 127 | search_length); |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 128 | |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 129 | if (offset == search_length) { |
| 130 | printk(BIOS_ERR, |
| 131 | "Error: Could not locate '%s' in VPD\n", key); |
| 132 | return CB_ERR; |
| 133 | } |
| 134 | printk(BIOS_DEBUG, "Located '%s' in VPD\n", key); |
| 135 | |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 136 | offset += strlen(key) + 1; /* move to next character */ |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 137 | |
| 138 | if (offset + MACLEN > search_length) { |
| 139 | printk(BIOS_ERR, "Search result too small!\n"); |
| 140 | return CB_ERR; |
| 141 | } |
| 142 | memcpy(macstrbuf, search_address + offset, MACLEN); |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 143 | return CB_SUCCESS; |
| 144 | } |
| 145 | |
| 146 | static enum cb_err fetch_mac_string_cbfs(u8 *macstrbuf) |
| 147 | { |
| 148 | struct cbfsf fh; |
| 149 | uint32_t matchraw = CBFS_TYPE_RAW; |
| 150 | |
| 151 | if (!cbfs_boot_locate(&fh, "rt8168-macaddress", &matchraw)) { |
| 152 | /* check the cbfs for the mac address */ |
| 153 | if (rdev_readat(&fh.data, macstrbuf, 0, MACLEN) != MACLEN) { |
| 154 | printk(BIOS_ERR, "r8168: Error reading MAC from CBFS\n"); |
| 155 | return CB_ERR; |
| 156 | } |
| 157 | return CB_SUCCESS; |
| 158 | } |
| 159 | return CB_ERR; |
| 160 | } |
| 161 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 162 | static void get_mac_address(u8 *macaddr, const u8 *strbuf) |
| 163 | { |
| 164 | size_t offset = 0; |
| 165 | int i; |
| 166 | |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 167 | if ((strbuf[2] != ':') || (strbuf[5] != ':') || |
| 168 | (strbuf[8] != ':') || (strbuf[11] != ':') || |
| 169 | (strbuf[14] != ':')) { |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 170 | printk(BIOS_ERR, "r8168: ignore invalid MAC address in cbfs\n"); |
| 171 | return; |
| 172 | } |
| 173 | |
| 174 | for (i = 0; i < 6; i++) { |
| 175 | macaddr[i] = 0; |
| 176 | macaddr[i] |= get_hex_digit(strbuf[offset]) << 4; |
| 177 | macaddr[i] |= get_hex_digit(strbuf[offset + 1]); |
| 178 | offset += 3; |
| 179 | } |
| 180 | } |
| 181 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 182 | static void program_mac_address(struct device *dev, u16 io_base) |
| 183 | { |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 184 | u8 macstrbuf[MACLEN] = { 0 }; |
| 185 | int i = 0; |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 186 | /* Default MAC Address of 00:E0:4C:00:C0:B0 */ |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 187 | u8 mac[6] = { 0x00, 0xe0, 0x4c, 0x00, 0xc0, 0xb0 }; |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 188 | struct drivers_net_config *config = dev->chip_info; |
David Wu | 9a0d9e0 | 2018-05-04 15:37:37 +0800 | [diff] [blame] | 189 | bool mac_found = false; |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 190 | |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 191 | /* check the VPD for the mac address */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 192 | if (CONFIG(RT8168_GET_MAC_FROM_VPD)) { |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 193 | /* Current implementation is up to 10 NIC cards */ |
| 194 | if (config && config->device_index <= MAX_DEVICE_SUPPORT) { |
David Wu | 9a0d9e0 | 2018-05-04 15:37:37 +0800 | [diff] [blame] | 195 | /* check "ethernet_mac" first when the device index is 1 */ |
| 196 | if (config->device_index == 1 && |
| 197 | fetch_mac_string_vpd(macstrbuf, 0) == CB_SUCCESS) |
| 198 | mac_found = true; |
| 199 | if (!mac_found && fetch_mac_string_vpd(macstrbuf, |
| 200 | config->device_index) != CB_SUCCESS) |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 201 | printk(BIOS_ERR, "r8168: mac address not found in VPD," |
| 202 | " using default 00:e0:4c:00:c0:b0\n"); |
| 203 | } else { |
| 204 | printk(BIOS_ERR, "r8168: the maximum device_index should be" |
| 205 | " less then %d\n. Using default 00:e0:4c:00:c0:b0\n", |
| 206 | MAX_DEVICE_SUPPORT); |
| 207 | } |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 208 | } else { |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 209 | if (fetch_mac_string_cbfs(macstrbuf) != CB_SUCCESS) |
| 210 | printk(BIOS_ERR, "r8168: Error reading MAC from CBFS," |
Gaggery Tsai | 1f84704 | 2017-12-26 17:13:52 +0800 | [diff] [blame] | 211 | " using default 00:e0:4c:00:c0:b0\n"); |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 212 | } |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 213 | get_mac_address(mac, macstrbuf); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 214 | |
| 215 | /* Reset NIC */ |
| 216 | printk(BIOS_DEBUG, "r8168: Resetting NIC..."); |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 217 | outb(CMD_REG_RESET, io_base + CMD_REG); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 218 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 219 | /* Poll for reset, with 1sec timeout */ |
| 220 | while (i < NIC_TIMEOUT && (inb(io_base + CMD_REG) & CMD_REG_RESET)) { |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 221 | udelay(1000); |
| 222 | if (++i >= NIC_TIMEOUT) |
Shelley Chen | 0528b61 | 2017-06-12 18:29:24 -0700 | [diff] [blame] | 223 | printk(BIOS_ERR, "timeout waiting for nic to reset\n"); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 224 | } |
| 225 | if (i < NIC_TIMEOUT) |
| 226 | printk(BIOS_DEBUG, "done\n"); |
| 227 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 228 | printk(BIOS_DEBUG, "r8168: Programming MAC Address..."); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 229 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 230 | /* Disable register protection */ |
| 231 | outb(CFG_9346_UNLOCK, io_base + CFG_9346); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 232 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 233 | /* Set MAC address: only 4-byte write accesses allowed */ |
| 234 | outl(mac[4] | mac[5] << 8, io_base + 4); |
| 235 | inl(io_base + 4); |
| 236 | outl(mac[0] | mac[1] << 8 | mac[2] << 16 | mac[3] << 24, |
| 237 | io_base); |
| 238 | inl(io_base); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 239 | /* Lock config regs */ |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 240 | outb(CFG_9346_LOCK, io_base + CFG_9346); |
| 241 | |
| 242 | printk(BIOS_DEBUG, "done\n"); |
| 243 | } |
| 244 | |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 245 | static void r8168_set_customized_led(struct device *dev, u16 io_base) |
| 246 | { |
| 247 | struct drivers_net_config *config = dev->chip_info; |
| 248 | |
| 249 | if (!config) |
| 250 | return; |
| 251 | |
| 252 | /* Read the customized LED setting from devicetree */ |
| 253 | printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds); |
| 254 | |
| 255 | /* |
| 256 | * Refer to RTL8111H datasheet 7.2 Customizable LED Configuration |
| 257 | * Starting from offset 0x18 |
| 258 | * Bit[15:12] LED Feature Control(FC) |
| 259 | * Bit[11:08] LED Select for PINLED2 |
| 260 | * Bit[07:04] LED Select for PINLED1 |
| 261 | * Bit[03:00] LED Select for PINLED0 |
| 262 | * |
| 263 | * Speed Link10M Link100M Link1000M ACT/Full |
| 264 | * LED0 Bit0 Bit1 Bit2 Bit3 |
| 265 | * LED1 Bit4 Bit5 Bit6 Bit7 |
| 266 | * LED2 Bit8 Bit9 Bit10 Bit11 |
| 267 | * FC Bit12 Bit13 Bit14 Bit15 |
| 268 | */ |
| 269 | |
| 270 | /* Set customized LED registers */ |
| 271 | outw(config->customized_leds, io_base + CMD_LED0_LED1); |
| 272 | printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n", |
| 273 | inw(io_base + CMD_LED0_LED1)); |
| 274 | } |
| 275 | |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 276 | static void r8168_init(struct device *dev) |
| 277 | { |
| 278 | /* Get the resource of the NIC mmio */ |
| 279 | struct resource *nic_res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 280 | u16 io_base = (u16)nic_res->base; |
| 281 | |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 282 | /* Check if the base is invalid */ |
| 283 | if (!io_base) { |
| 284 | printk(BIOS_ERR, "r8168: Error cant find IO resource\n"); |
| 285 | return; |
| 286 | } |
Damien Zammit | f5dd23f | 2016-12-01 23:29:34 +1100 | [diff] [blame] | 287 | /* Enable but do not set bus master */ |
| 288 | pci_write_config16(dev, PCI_COMMAND, |
| 289 | PCI_COMMAND_MEMORY | PCI_COMMAND_IO); |
| 290 | |
| 291 | /* Program MAC address based on CBFS "macaddress" containing |
| 292 | * a string AA:BB:CC:DD:EE:FF */ |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 293 | program_mac_address(dev, io_base); |
| 294 | |
| 295 | /* Program customized LED mode */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 296 | if (CONFIG(RT8168_SET_LED_MODE)) |
Gaggery Tsai | 65623ef | 2017-09-29 11:15:23 +0800 | [diff] [blame] | 297 | r8168_set_customized_led(dev, io_base); |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 298 | } |
| 299 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 300 | #if CONFIG(HAVE_ACPI_TABLES) |
Gaggery Tsai | 6919a93 | 2017-11-16 17:21:23 +0800 | [diff] [blame] | 301 | #define R8168_ACPI_HID "R8168" |
| 302 | static void r8168_net_fill_ssdt(struct device *dev) |
| 303 | { |
| 304 | struct drivers_net_config *config = dev->chip_info; |
| 305 | const char *path = acpi_device_path(dev->bus->dev); |
| 306 | u32 address; |
| 307 | |
| 308 | if (!path || !config) |
| 309 | return; |
| 310 | |
| 311 | /* Device */ |
| 312 | acpigen_write_scope(path); |
| 313 | acpigen_write_device(acpi_device_name(dev)); |
| 314 | acpigen_write_name_string("_HID", R8168_ACPI_HID); |
Patrick Rudolph | c83bab6 | 2019-12-13 12:16:06 +0100 | [diff] [blame] | 315 | acpi_device_write_uid(dev); |
| 316 | |
Gaggery Tsai | 6919a93 | 2017-11-16 17:21:23 +0800 | [diff] [blame] | 317 | if (dev->chip_ops) |
| 318 | acpigen_write_name_string("_DDN", dev->chip_ops->name); |
| 319 | |
| 320 | /* Address */ |
| 321 | address = PCI_SLOT(dev->path.pci.devfn) & 0xffff; |
| 322 | address <<= 16; |
| 323 | address |= PCI_FUNC(dev->path.pci.devfn) & 0xffff; |
| 324 | acpigen_write_name_dword("_ADR", address); |
| 325 | |
| 326 | /* Wake capabilities */ |
| 327 | if (config->wake) |
| 328 | acpigen_write_PRW(config->wake, 3); |
| 329 | |
| 330 | acpigen_pop_len(); /* Device */ |
| 331 | acpigen_pop_len(); /* Scope */ |
| 332 | |
| 333 | printk(BIOS_INFO, "%s.%s: %s %s\n", path, acpi_device_name(dev), |
| 334 | dev->chip_ops ? dev->chip_ops->name : "", dev_path(dev)); |
| 335 | } |
| 336 | |
| 337 | static const char *r8168_net_acpi_name(const struct device *dev) |
| 338 | { |
| 339 | return "RLTK"; |
| 340 | } |
| 341 | #endif |
| 342 | |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 343 | static struct device_operations r8168_ops = { |
Martin Roth | b9810a4 | 2017-07-23 20:00:04 -0600 | [diff] [blame] | 344 | .read_resources = pci_dev_read_resources, |
| 345 | .set_resources = pci_dev_set_resources, |
| 346 | .enable_resources = pci_dev_enable_resources, |
| 347 | .init = r8168_init, |
| 348 | .scan_bus = 0, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 349 | #if CONFIG(HAVE_ACPI_TABLES) |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 350 | .acpi_name = r8168_net_acpi_name, |
| 351 | .acpi_fill_ssdt_generator = r8168_net_fill_ssdt, |
Gaggery Tsai | 6919a93 | 2017-11-16 17:21:23 +0800 | [diff] [blame] | 352 | #endif |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | static const struct pci_driver r8168_driver __pci_driver = { |
Martin Roth | b9810a4 | 2017-07-23 20:00:04 -0600 | [diff] [blame] | 356 | .ops = &r8168_ops, |
| 357 | .vendor = 0x10ec, |
| 358 | .device = 0x8168, |
Damien Zammit | e983f0c | 2016-05-21 02:24:19 +1000 | [diff] [blame] | 359 | }; |
Gaggery Tsai | 6919a93 | 2017-11-16 17:21:23 +0800 | [diff] [blame] | 360 | |
| 361 | struct chip_operations drivers_net_ops = { |
| 362 | CHIP_NAME("Realtek r8168") |
| 363 | }; |