Commit c16cc6a0 authored by Biao Huang's avatar Biao Huang Committed by David S. Miller

net: ethernet: mtk-star-emac: store bit_clk_div in compat structure

Not all the SoC are using the same clock divider. Move the divider into
a compat structure specific to the SoCs.
Signed-off-by: default avatarBiao Huang <biao.huang@mediatek.com>
Signed-off-by: default avatarFabien Parent <fparent@baylibre.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfc71514
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -231,6 +232,10 @@ struct mtk_star_ring { ...@@ -231,6 +232,10 @@ struct mtk_star_ring {
unsigned int tail; unsigned int tail;
}; };
struct mtk_star_compat {
unsigned char bit_clk_div;
};
struct mtk_star_priv { struct mtk_star_priv {
struct net_device *ndev; struct net_device *ndev;
...@@ -256,6 +261,8 @@ struct mtk_star_priv { ...@@ -256,6 +261,8 @@ struct mtk_star_priv {
int duplex; int duplex;
int pause; int pause;
const struct mtk_star_compat *compat_data;
/* Protects against concurrent descriptor access. */ /* Protects against concurrent descriptor access. */
spinlock_t lock; spinlock_t lock;
...@@ -898,7 +905,7 @@ static void mtk_star_init_config(struct mtk_star_priv *priv) ...@@ -898,7 +905,7 @@ static void mtk_star_init_config(struct mtk_star_priv *priv)
regmap_write(priv->regs, MTK_STAR_REG_SYS_CONF, val); regmap_write(priv->regs, MTK_STAR_REG_SYS_CONF, val);
regmap_update_bits(priv->regs, MTK_STAR_REG_MAC_CLK_CONF, regmap_update_bits(priv->regs, MTK_STAR_REG_MAC_CLK_CONF,
MTK_STAR_MSK_MAC_CLK_CONF, MTK_STAR_MSK_MAC_CLK_CONF,
MTK_STAR_BIT_CLK_DIV_10); priv->compat_data->bit_clk_div);
} }
static void mtk_star_set_mode_rmii(struct mtk_star_priv *priv) static void mtk_star_set_mode_rmii(struct mtk_star_priv *priv)
...@@ -1460,6 +1467,7 @@ static int mtk_star_probe(struct platform_device *pdev) ...@@ -1460,6 +1467,7 @@ static int mtk_star_probe(struct platform_device *pdev)
priv = netdev_priv(ndev); priv = netdev_priv(ndev);
priv->ndev = ndev; priv->ndev = ndev;
priv->compat_data = of_device_get_match_data(&pdev->dev);
SET_NETDEV_DEV(ndev, dev); SET_NETDEV_DEV(ndev, dev);
platform_set_drvdata(pdev, ndev); platform_set_drvdata(pdev, ndev);
...@@ -1556,10 +1564,17 @@ static int mtk_star_probe(struct platform_device *pdev) ...@@ -1556,10 +1564,17 @@ static int mtk_star_probe(struct platform_device *pdev)
} }
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct mtk_star_compat mtk_star_mt8516_compat = {
.bit_clk_div = MTK_STAR_BIT_CLK_DIV_10,
};
static const struct of_device_id mtk_star_of_match[] = { static const struct of_device_id mtk_star_of_match[] = {
{ .compatible = "mediatek,mt8516-eth", }, { .compatible = "mediatek,mt8516-eth",
{ .compatible = "mediatek,mt8518-eth", }, .data = &mtk_star_mt8516_compat },
{ .compatible = "mediatek,mt8175-eth", }, { .compatible = "mediatek,mt8518-eth",
.data = &mtk_star_mt8516_compat },
{ .compatible = "mediatek,mt8175-eth",
.data = &mtk_star_mt8516_compat },
{ } { }
}; };
MODULE_DEVICE_TABLE(of, mtk_star_of_match); MODULE_DEVICE_TABLE(of, mtk_star_of_match);
......
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