2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-19 19:14:01 +08:00

Merge branch 'r8152-minor-adjustments'

Hayes Wang says:

====================
r8152: minor adjustments

These patches are used to adjust the code.
====================

Link: https://lore.kernel.org/r/1394712342-15778-341-Taiwan-albertk@realtek.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2021-02-23 12:36:04 -08:00
commit 2c8396de72

View File

@ -2632,21 +2632,24 @@ static inline u8 rtl8152_get_speed(struct r8152 *tp)
return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS);
}
static void rtl_set_eee_plus(struct r8152 *tp)
static void rtl_eee_plus_en(struct r8152 *tp, bool enable)
{
u32 ocp_data;
u8 speed;
speed = rtl8152_get_speed(tp);
if (speed & _10bps) {
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
if (enable)
ocp_data |= EEEP_CR_EEEP_TX;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
} else {
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR);
else
ocp_data &= ~EEEP_CR_EEEP_TX;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
}
ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data);
}
static void rtl_set_eee_plus(struct r8152 *tp)
{
if (rtl8152_get_speed(tp) & _10bps)
rtl_eee_plus_en(tp, true);
else
rtl_eee_plus_en(tp, false);
}
static void rxdy_gated_en(struct r8152 *tp, bool enable)
@ -3150,10 +3153,22 @@ static void r8153b_ups_flags(struct r8152 *tp)
ocp_write_dword(tp, MCU_TYPE_USB, USB_UPS_FLAGS, ups_flags);
}
static void r8153b_green_en(struct r8152 *tp, bool enable)
static void rtl_green_en(struct r8152 *tp, bool enable)
{
u16 data;
data = sram_read(tp, SRAM_GREEN_CFG);
if (enable)
data |= GREEN_ETH_EN;
else
data &= ~GREEN_ETH_EN;
sram_write(tp, SRAM_GREEN_CFG, data);
tp->ups_info.green = enable;
}
static void r8153b_green_en(struct r8152 *tp, bool enable)
{
if (enable) {
sram_write(tp, 0x8045, 0); /* 10M abiq&ldvbias */
sram_write(tp, 0x804d, 0x1222); /* 100M short abiq&ldvbias */
@ -3164,11 +3179,7 @@ static void r8153b_green_en(struct r8152 *tp, bool enable)
sram_write(tp, 0x805d, 0x2444); /* 1000M short abiq&ldvbias */
}
data = sram_read(tp, SRAM_GREEN_CFG);
data |= GREEN_ETH_EN;
sram_write(tp, SRAM_GREEN_CFG, data);
tp->ups_info.green = enable;
rtl_green_en(tp, true);
}
static u16 r8153_phy_status(struct r8152 *tp, u16 desired)
@ -3360,7 +3371,7 @@ static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable)
r8153b_ups_en(tp, false);
r8153_queue_wake(tp, false);
rtl_runtime_suspend_enable(tp, false);
if (tp->udev->speed != USB_SPEED_HIGH)
if (tp->udev->speed >= USB_SPEED_SUPER)
r8153b_u1u2en(tp, true);
}
}
@ -5056,7 +5067,7 @@ static void rtl8153b_up(struct r8152 *tp)
r8153_aldps_en(tp, true);
if (tp->udev->speed != USB_SPEED_HIGH)
if (tp->udev->speed >= USB_SPEED_SUPER)
r8153b_u1u2en(tp, true);
}
@ -5572,8 +5583,9 @@ static void r8153b_init(struct r8152 *tp)
ocp_data |= POLL_LINK_CHG;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_EXTRA_STATUS, ocp_data);
if (tp->udev->speed != USB_SPEED_HIGH)
if (tp->udev->speed >= USB_SPEED_SUPER)
r8153b_u1u2en(tp, true);
usb_enable_lpm(tp->udev);
/* MAC clock speed down */
@ -5756,6 +5768,9 @@ static int rtl8152_runtime_suspend(struct r8152 *tp)
struct net_device *netdev = tp->netdev;
int ret = 0;
if (!tp->rtl_ops.autosuspend_en)
return -EBUSY;
set_bit(SELECTIVE_SUSPEND, &tp->flags);
smp_mb__after_atomic();
@ -6155,6 +6170,11 @@ rtl_ethtool_get_eee(struct net_device *net, struct ethtool_eee *edata)
struct r8152 *tp = netdev_priv(net);
int ret;
if (!tp->rtl_ops.eee_get) {
ret = -EOPNOTSUPP;
goto out;
}
ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
goto out;
@ -6177,6 +6197,11 @@ rtl_ethtool_set_eee(struct net_device *net, struct ethtool_eee *edata)
struct r8152 *tp = netdev_priv(net);
int ret;
if (!tp->rtl_ops.eee_set) {
ret = -EOPNOTSUPP;
goto out;
}
ret = usb_autopm_get_interface(tp->intf);
if (ret < 0)
goto out;
@ -6576,7 +6601,7 @@ static int rtl_ops_init(struct r8152 *tp)
default:
ret = -ENODEV;
netif_err(tp, probe, tp->netdev, "Unknown Device\n");
dev_err(&tp->intf->dev, "Unknown Device\n");
break;
}
@ -6833,7 +6858,7 @@ static int rtl8152_probe(struct usb_interface *intf,
ret = register_netdev(netdev);
if (ret != 0) {
netif_err(tp, probe, netdev, "couldn't register the device\n");
dev_err(&intf->dev, "couldn't register the device\n");
goto out1;
}