Merge "[qca-ssdk]: ssdk clock support for HK board"
diff --git a/include/init/ssdk_plat.h b/include/init/ssdk_plat.h
index 486b7d1..fc38c27 100644
--- a/include/init/ssdk_plat.h
+++ b/include/init/ssdk_plat.h
@@ -271,7 +271,6 @@
/*qm_err_check end*/
a_uint8_t device_id;
struct device_node *of_node;
- struct mii_bus miibus;
/*dess_rgmii_mac*/
struct mutex rgmii_lock;
struct delayed_work rgmii_dwork;
@@ -280,6 +279,7 @@
struct mutex mac_sw_sync_lock;
struct delayed_work mac_sw_sync_dwork;
/*hppe_mac_sw_sync end*/
+ struct mii_bus *miibus;
u64 *mib_counters;
/* dump buf */
diff --git a/src/init/ssdk_plat.c b/src/init/ssdk_plat.c
index 78fcb5f..d4b69a8 100644
--- a/src/init/ssdk_plat.c
+++ b/src/init/ssdk_plat.c
@@ -49,9 +49,11 @@
#endif
#if defined(CONFIG_OF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(4,1,0))
#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#elif defined(CONFIG_OF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
#include <linux/of.h>
+#include <linux/of_mdio.h>
#include <drivers/leds/leds-ipq40xx.h>
#include <linux/of_platform.h>
#include <linux/reset.h>
@@ -174,6 +176,9 @@
uint16_t r1, r2, page;
uint16_t lo, hi;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
split_addr((uint32_t) reg, &r1, &r2, &page);
mutex_lock(&switch_mdio_lock);
mdiobus_write(bus, switch_chip_id, switch_chip_reg, page);
@@ -191,6 +196,9 @@
uint16_t r1, r2, r3;
uint16_t lo, hi;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
split_addr((a_uint32_t) reg, &r1, &r2, &r3);
lo = val & 0xffff;
hi = (a_uint16_t) (val >> 16);
@@ -224,6 +232,9 @@
{
struct mii_bus *bus = miibus;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
if (A_TRUE != phy_addr_validation_check (phy_addr))
{
return SW_BAD_PARAM;
@@ -239,6 +250,9 @@
{
struct mii_bus *bus = miibus;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
if (A_TRUE != phy_addr_validation_check (phy_addr))
{
return SW_BAD_PARAM;
@@ -254,6 +268,9 @@
{
struct mii_bus *bus = miibus;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
if (A_TRUE != phy_addr_validation_check (phy_addr))
{
return;
@@ -269,6 +286,9 @@
{
struct mii_bus *bus = miibus;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
if (A_TRUE != phy_addr_validation_check (phy_addr))
{
return;
@@ -285,6 +305,9 @@
{
struct mii_bus *bus = miibus;
+ if (!bus)
+ bus = qca_phy_priv_global[dev_id]->miibus;
+
if (A_TRUE != phy_addr_validation_check (phy_addr))
{
return;
@@ -508,8 +531,20 @@
#if defined(CONFIG_OF) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
#ifndef BOARD_AR71XX
struct device_node *mdio_node = NULL;
+ struct device_node *switch_node = NULL;
struct platform_device *mdio_plat = NULL;
struct ipq40xx_mdio_data *mdio_data = NULL;
+ struct qca_phy_priv *priv;
+
+ priv = qca_phy_priv_global[dev_id];
+ switch_node = qca_phy_priv_global[dev_id]->of_node;
+ if (priv && switch_node) {
+ mdio_node = of_parse_phandle(switch_node, "mdio-bus", 0);
+ if (mdio_node) {
+ priv->miibus = of_mdio_find_bus(mdio_node);
+ return 0;
+ }
+ }
if(ssdk_dt_global.ssdk_dt_switch_nodes[dev_id]->switch_reg_access_mode == HSL_REG_LOCAL_BUS)
mdio_node = of_find_compatible_node(NULL, NULL, "qcom,ipq40xx-mdio");