Mario Scheithauer | d4ab2ee | 2022-11-04 10:23:43 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Mario Scheithauer | 1a97c89 | 2022-11-08 13:50:06 +0100 | [diff] [blame^] | 3 | #include <console/console.h> |
Mario Scheithauer | d4ab2ee | 2022-11-04 10:23:43 +0100 | [diff] [blame] | 4 | #include <device/device.h> |
Mario Scheithauer | 1a97c89 | 2022-11-08 13:50:06 +0100 | [diff] [blame^] | 5 | #include <device/mdio.h> |
| 6 | #include <device/pci.h> |
| 7 | #include "chip.h" |
| 8 | #include "m88e1512.h" |
| 9 | |
| 10 | static void switch_page(struct device *dev, uint8_t page) |
| 11 | { |
| 12 | mdio_write(dev, PAGE_REG, page); |
| 13 | } |
Mario Scheithauer | d4ab2ee | 2022-11-04 10:23:43 +0100 | [diff] [blame] | 14 | |
| 15 | static void m88e1512_init(struct device *dev) |
| 16 | { |
Mario Scheithauer | 1a97c89 | 2022-11-08 13:50:06 +0100 | [diff] [blame^] | 17 | struct drivers_net_phy_m88e1512_config *config = dev->chip_info; |
| 18 | uint16_t reg; |
| 19 | |
| 20 | /* Configure LEDs if requested. */ |
| 21 | if (config->configure_leds) { |
| 22 | printk(BIOS_DEBUG, "%s: Set a customized LED mode for %s.\n", |
| 23 | dev_path(dev->bus->dev), dev->chip_ops->name); |
| 24 | |
| 25 | /* Select page 3 to access LED function control register. */ |
| 26 | switch_page(dev, 3); |
| 27 | |
| 28 | /* Modify PHY LED mode. */ |
| 29 | reg = mdio_read(dev, LED_FUNC_CTRL_REG); |
| 30 | clrsetbits16(®, LED_FUNC_CTRL_MASK, config->led_0_ctrl | |
| 31 | (config->led_1_ctrl << 4) | (config->led_2_ctrl << 8)); |
| 32 | mdio_write(dev, LED_FUNC_CTRL_REG, reg); |
| 33 | |
| 34 | /* Switch back to page 0. */ |
| 35 | switch_page(dev, 0); |
| 36 | } |
Mario Scheithauer | d4ab2ee | 2022-11-04 10:23:43 +0100 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | struct device_operations m88e1512_ops = { |
| 40 | .read_resources = noop_read_resources, |
| 41 | .set_resources = noop_set_resources, |
| 42 | .init = m88e1512_init, |
| 43 | }; |
| 44 | |
| 45 | struct chip_operations drivers_net_phy_m88e1512_ops = { |
| 46 | CHIP_NAME("88E1512") |
| 47 | }; |