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