Commit dff95381 authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller

dpaa2-mac: retrieve API version and detect features

Retrieve the API version running on the firmware and based on it detect
which features are available for usage.
The first one to be listed is the capability to change the MAC protocol
at runtime.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 332b9ea5
...@@ -11,6 +11,28 @@ ...@@ -11,6 +11,28 @@
#define phylink_to_dpaa2_mac(config) \ #define phylink_to_dpaa2_mac(config) \
container_of((config), struct dpaa2_mac, phylink_config) container_of((config), struct dpaa2_mac, phylink_config)
#define DPMAC_PROTOCOL_CHANGE_VER_MAJOR 4
#define DPMAC_PROTOCOL_CHANGE_VER_MINOR 8
#define DPAA2_MAC_FEATURE_PROTOCOL_CHANGE BIT(0)
static int dpaa2_mac_cmp_ver(struct dpaa2_mac *mac,
u16 ver_major, u16 ver_minor)
{
if (mac->ver_major == ver_major)
return mac->ver_minor - ver_minor;
return mac->ver_major - ver_major;
}
static void dpaa2_mac_detect_features(struct dpaa2_mac *mac)
{
mac->features = 0;
if (dpaa2_mac_cmp_ver(mac, DPMAC_PROTOCOL_CHANGE_VER_MAJOR,
DPMAC_PROTOCOL_CHANGE_VER_MINOR) >= 0)
mac->features |= DPAA2_MAC_FEATURE_PROTOCOL_CHANGE;
}
static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode) static int phy_mode(enum dpmac_eth_if eth_if, phy_interface_t *if_mode)
{ {
*if_mode = PHY_INTERFACE_MODE_NA; *if_mode = PHY_INTERFACE_MODE_NA;
...@@ -359,6 +381,14 @@ int dpaa2_mac_open(struct dpaa2_mac *mac) ...@@ -359,6 +381,14 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
goto err_close_dpmac; goto err_close_dpmac;
} }
err = dpmac_get_api_version(mac->mc_io, 0, &mac->ver_major, &mac->ver_minor);
if (err) {
netdev_err(net_dev, "dpmac_get_api_version() = %d\n", err);
goto err_close_dpmac;
}
dpaa2_mac_detect_features(mac);
/* Find the device node representing the MAC device and link the device /* Find the device node representing the MAC device and link the device
* behind the associated netdev to it. * behind the associated netdev to it.
*/ */
......
...@@ -17,6 +17,8 @@ struct dpaa2_mac { ...@@ -17,6 +17,8 @@ struct dpaa2_mac {
struct net_device *net_dev; struct net_device *net_dev;
struct fsl_mc_io *mc_io; struct fsl_mc_io *mc_io;
struct dpmac_attr attr; struct dpmac_attr attr;
u16 ver_major, ver_minor;
unsigned long features;
struct phylink_config phylink_config; struct phylink_config phylink_config;
struct phylink *phylink; struct phylink *phylink;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment