summaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/r8152_shield.c
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2014-01-01 22:22:39 -0500
committerVladislav Zhurba <vzhurba@nvidia.com>2018-02-01 16:57:58 -0500
commit26c5bcdd8ecc8beb4e548fe49a3f5b82dd34ef65 (patch)
treed1f983978f1ee769ca544afae33811be2f789949 /drivers/net/usb/r8152_shield.c
parentdf32fe069c3439a38199df192f53f895e8b68cca (diff)
r8152: move rtl8152_unload and ocp_reg_write
Change the locations of rtl8152_unload() and ocp_reg_write(). Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Preetham Chandru R <pchandru@nvidia.com> (cherry picked from commit e3fe0b1a5460252e77791a720649c5092336ae40) Change-Id: I0048fdc377a585e8677ac2f41f3fdad33fef316d Reviewed-on: http://git-master/r/370000 Tested-by: Aly Hirani <ahirani@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>
Diffstat (limited to 'drivers/net/usb/r8152_shield.c')
-rw-r--r--drivers/net/usb/r8152_shield.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/drivers/net/usb/r8152_shield.c b/drivers/net/usb/r8152_shield.c
index 51073721e..79bb55302 100644
--- a/drivers/net/usb/r8152_shield.c
+++ b/drivers/net/usb/r8152_shield.c
@@ -653,6 +653,20 @@ static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data)
653 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); 653 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
654} 654}
655 655
656static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 data)
657{
658 u16 ocp_base, ocp_index;
659
660 ocp_base = addr & 0xf000;
661 if (ocp_base != tp->ocp_base) {
662 ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base);
663 tp->ocp_base = ocp_base;
664 }
665
666 ocp_index = (addr & 0x0fff) | 0xb000;
667 ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data);
668}
669
656static void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value) 670static void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value)
657{ 671{
658 u32 ocp_data; 672 u32 ocp_data;
@@ -715,20 +729,6 @@ void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val)
715 r8152_mdio_write(tp, reg, val); 729 r8152_mdio_write(tp, reg, val);
716} 730}
717 731
718static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 data)
719{
720 u16 ocp_base, ocp_index;
721
722 ocp_base = addr & 0xf000;
723 if (ocp_base != tp->ocp_base) {
724 ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base);
725 tp->ocp_base = ocp_base;
726 }
727
728 ocp_index = (addr & 0x0fff) | 0xb000;
729 ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data);
730}
731
732static 732static
733int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags); 733int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags);
734 734
@@ -2079,6 +2079,21 @@ static void r8152b_get_version(struct r8152 *tp)
2079 } 2079 }
2080} 2080}
2081 2081
2082static void rtl8152_unload(struct r8152 *tp)
2083{
2084 u32 ocp_data;
2085
2086 if (tp->version != RTL_VER_01) {
2087 ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL);
2088 ocp_data |= POWER_CUT;
2089 ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data);
2090 }
2091
2092 ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS);
2093 ocp_data &= ~RWSUME_INDICATE;
2094 ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data);
2095}
2096
2082static int rtl8152_probe(struct usb_interface *intf, 2097static int rtl8152_probe(struct usb_interface *intf,
2083 const struct usb_device_id *id) 2098 const struct usb_device_id *id)
2084{ 2099{
@@ -2150,21 +2165,6 @@ out:
2150 return ret; 2165 return ret;
2151} 2166}
2152 2167
2153static void rtl8152_unload(struct r8152 *tp)
2154{
2155 u32 ocp_data;
2156
2157 if (tp->version != RTL_VER_01) {
2158 ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL);
2159 ocp_data |= POWER_CUT;
2160 ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data);
2161 }
2162
2163 ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS);
2164 ocp_data &= ~RWSUME_INDICATE;
2165 ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data);
2166}
2167
2168static void rtl8152_disconnect(struct usb_interface *intf) 2168static void rtl8152_disconnect(struct usb_interface *intf)
2169{ 2169{
2170 struct r8152 *tp = usb_get_intfdata(intf); 2170 struct r8152 *tp = usb_get_intfdata(intf);