layerscape: add Traverse LS1043-S support
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.9 / 820-rgmii-fixed-link.patch
1 From f27ef8941ca29b2d10428754be51e8ee06bb1263 Mon Sep 17 00:00:00 2001
2 From: Mathew McBride <matt@traverse.com.au>
3 Date: Mon, 7 Aug 2017 10:19:48 +1000
4 Subject: [PATCH] Recognize when an RGMII Link is set as fixed (in the device
5 tree) and set up the MAC accordingly
6
7 ---
8 drivers/net/ethernet/freescale/sdk_dpaa/mac.c | 1
9 drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c | 13 ++++++++++
10 2 files changed, 14 insertions(+)
11
12 --- a/drivers/net/ethernet/freescale/sdk_dpaa/mac.c
13 +++ b/drivers/net/ethernet/freescale/sdk_dpaa/mac.c
14 @@ -386,6 +386,7 @@ static int __cold mac_probe(struct platf
15 mac_dev->fixed_link->duplex = phy->duplex;
16 mac_dev->fixed_link->pause = phy->pause;
17 mac_dev->fixed_link->asym_pause = phy->asym_pause;
18 + printk(KERN_INFO "Setting up fixed link, speed %d duplex %d\n", mac_dev->fixed_link->speed, mac_dev->fixed_link->duplex);
19 }
20
21 _errno = mac_dev->init(mac_dev);
22 --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
23 +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
24 @@ -36,6 +36,8 @@
25
26 @Description FM mEMAC driver
27 *//***************************************************************************/
28 +#include <../../../../sdk_dpaa/mac.h>
29 +#include <linux/phy_fixed.h>
30
31 #include "std_ext.h"
32 #include "string_ext.h"
33 @@ -48,6 +50,8 @@
34 #include "memac.h"
35
36
37 +static t_Error MemacAdjustLink(t_Handle h_Memac, e_EnetSpeed speed, bool fullDuplex);
38 +
39 /*****************************************************************************/
40 /* Internal routines */
41 /*****************************************************************************/
42 @@ -276,11 +280,20 @@ static t_Error MemacEnable(t_Handle h_Me
43 {
44 t_Memac *p_Memac = (t_Memac *)h_Memac;
45
46 + struct mac_device *mac_dev = (struct mac_device *)p_Memac->h_App;
47 +
48 SANITY_CHECK_RETURN_ERROR(p_Memac, E_INVALID_HANDLE);
49 SANITY_CHECK_RETURN_ERROR(!p_Memac->p_MemacDriverParam, E_INVALID_STATE);
50
51 fman_memac_enable(p_Memac->p_MemMap, (mode & e_COMM_MODE_RX), (mode & e_COMM_MODE_TX));
52
53 + if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_RGMII) {
54 + if (mac_dev->fixed_link) {
55 + printk(KERN_INFO "This is a fixed-link, forcing speed %d duplex %d\n",mac_dev->fixed_link->speed,mac_dev->fixed_link->duplex);
56 + MemacAdjustLink(h_Memac,mac_dev->fixed_link->speed,mac_dev->fixed_link->duplex);
57 + }
58 + }
59 +
60 return E_OK;
61 }
62