mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
net: stmmac: dwmac-oxnas: Add support for OX810SE
Add support for OX810SE dwmac glue setup, which is a simplified version of the OX820 introduced later with more control on the PHY interface. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
8973d7b863
commit
72f1f7e46c
1 changed files with 86 additions and 29 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_device.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
#include <linux/mfd/syscon.h>
|
#include <linux/mfd/syscon.h>
|
||||||
|
@ -48,16 +49,75 @@
|
||||||
#define DWMAC_RX_VARDELAY(d) ((d) << DWMAC_RX_VARDELAY_SHIFT)
|
#define DWMAC_RX_VARDELAY(d) ((d) << DWMAC_RX_VARDELAY_SHIFT)
|
||||||
#define DWMAC_RXN_VARDELAY(d) ((d) << DWMAC_RXN_VARDELAY_SHIFT)
|
#define DWMAC_RXN_VARDELAY(d) ((d) << DWMAC_RXN_VARDELAY_SHIFT)
|
||||||
|
|
||||||
|
struct oxnas_dwmac;
|
||||||
|
|
||||||
|
struct oxnas_dwmac_data {
|
||||||
|
int (*setup)(struct oxnas_dwmac *dwmac);
|
||||||
|
};
|
||||||
|
|
||||||
struct oxnas_dwmac {
|
struct oxnas_dwmac {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
const struct oxnas_dwmac_data *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int oxnas_dwmac_setup_ox810se(struct oxnas_dwmac *dwmac)
|
||||||
|
{
|
||||||
|
unsigned int value;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
|
||||||
|
value |= BIT(DWMAC_CKEN_GTX) |
|
||||||
|
/* Use simple mux for 25/125 Mhz clock switching */
|
||||||
|
BIT(DWMAC_SIMPLE_MUX);
|
||||||
|
|
||||||
|
regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int oxnas_dwmac_setup_ox820(struct oxnas_dwmac *dwmac)
|
||||||
|
{
|
||||||
|
unsigned int value;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
/* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
|
||||||
|
value |= BIT(DWMAC_CKEN_GTX) |
|
||||||
|
/* Use simple mux for 25/125 Mhz clock switching */
|
||||||
|
BIT(DWMAC_SIMPLE_MUX) |
|
||||||
|
/* set auto switch tx clock source */
|
||||||
|
BIT(DWMAC_AUTO_TX_SOURCE) |
|
||||||
|
/* enable tx & rx vardelay */
|
||||||
|
BIT(DWMAC_CKEN_TX_OUT) |
|
||||||
|
BIT(DWMAC_CKEN_TXN_OUT) |
|
||||||
|
BIT(DWMAC_CKEN_TX_IN) |
|
||||||
|
BIT(DWMAC_CKEN_RX_OUT) |
|
||||||
|
BIT(DWMAC_CKEN_RXN_OUT) |
|
||||||
|
BIT(DWMAC_CKEN_RX_IN);
|
||||||
|
regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);
|
||||||
|
|
||||||
|
/* set tx & rx vardelay */
|
||||||
|
value = DWMAC_TX_VARDELAY(4) |
|
||||||
|
DWMAC_TXN_VARDELAY(2) |
|
||||||
|
DWMAC_RX_VARDELAY(10) |
|
||||||
|
DWMAC_RXN_VARDELAY(8);
|
||||||
|
regmap_write(dwmac->regmap, OXNAS_DWMAC_DELAY_REGOFFSET, value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int oxnas_dwmac_init(struct platform_device *pdev, void *priv)
|
static int oxnas_dwmac_init(struct platform_device *pdev, void *priv)
|
||||||
{
|
{
|
||||||
struct oxnas_dwmac *dwmac = priv;
|
struct oxnas_dwmac *dwmac = priv;
|
||||||
unsigned int value;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Reset HW here before changing the glue configuration */
|
/* Reset HW here before changing the glue configuration */
|
||||||
|
@ -69,35 +129,11 @@ static int oxnas_dwmac_init(struct platform_device *pdev, void *priv)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = regmap_read(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, &value);
|
ret = dwmac->data->setup(dwmac);
|
||||||
if (ret < 0) {
|
if (ret)
|
||||||
clk_disable_unprepare(dwmac->clk);
|
clk_disable_unprepare(dwmac->clk);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable GMII_GTXCLK to follow GMII_REFCLK, required for gigabit PHY */
|
return ret;
|
||||||
value |= BIT(DWMAC_CKEN_GTX) |
|
|
||||||
/* Use simple mux for 25/125 Mhz clock switching */
|
|
||||||
BIT(DWMAC_SIMPLE_MUX) |
|
|
||||||
/* set auto switch tx clock source */
|
|
||||||
BIT(DWMAC_AUTO_TX_SOURCE) |
|
|
||||||
/* enable tx & rx vardelay */
|
|
||||||
BIT(DWMAC_CKEN_TX_OUT) |
|
|
||||||
BIT(DWMAC_CKEN_TXN_OUT) |
|
|
||||||
BIT(DWMAC_CKEN_TX_IN) |
|
|
||||||
BIT(DWMAC_CKEN_RX_OUT) |
|
|
||||||
BIT(DWMAC_CKEN_RXN_OUT) |
|
|
||||||
BIT(DWMAC_CKEN_RX_IN);
|
|
||||||
regmap_write(dwmac->regmap, OXNAS_DWMAC_CTRL_REGOFFSET, value);
|
|
||||||
|
|
||||||
/* set tx & rx vardelay */
|
|
||||||
value = DWMAC_TX_VARDELAY(4) |
|
|
||||||
DWMAC_TXN_VARDELAY(2) |
|
|
||||||
DWMAC_RX_VARDELAY(10) |
|
|
||||||
DWMAC_RXN_VARDELAY(8);
|
|
||||||
regmap_write(dwmac->regmap, OXNAS_DWMAC_DELAY_REGOFFSET, value);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void oxnas_dwmac_exit(struct platform_device *pdev, void *priv)
|
static void oxnas_dwmac_exit(struct platform_device *pdev, void *priv)
|
||||||
|
@ -128,6 +164,12 @@ static int oxnas_dwmac_probe(struct platform_device *pdev)
|
||||||
goto err_remove_config_dt;
|
goto err_remove_config_dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dwmac->data = (const struct oxnas_dwmac_data *)of_device_get_match_data(&pdev->dev);
|
||||||
|
if (!dwmac->data) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
goto err_remove_config_dt;
|
||||||
|
}
|
||||||
|
|
||||||
dwmac->dev = &pdev->dev;
|
dwmac->dev = &pdev->dev;
|
||||||
plat_dat->bsp_priv = dwmac;
|
plat_dat->bsp_priv = dwmac;
|
||||||
plat_dat->init = oxnas_dwmac_init;
|
plat_dat->init = oxnas_dwmac_init;
|
||||||
|
@ -166,8 +208,23 @@ err_remove_config_dt:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct oxnas_dwmac_data ox810se_dwmac_data = {
|
||||||
|
.setup = oxnas_dwmac_setup_ox810se,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct oxnas_dwmac_data ox820_dwmac_data = {
|
||||||
|
.setup = oxnas_dwmac_setup_ox820,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct of_device_id oxnas_dwmac_match[] = {
|
static const struct of_device_id oxnas_dwmac_match[] = {
|
||||||
{ .compatible = "oxsemi,ox820-dwmac" },
|
{
|
||||||
|
.compatible = "oxsemi,ox810se-dwmac",
|
||||||
|
.data = &ox810se_dwmac_data,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.compatible = "oxsemi,ox820-dwmac",
|
||||||
|
.data = &ox820_dwmac_data,
|
||||||
|
},
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
|
MODULE_DEVICE_TABLE(of, oxnas_dwmac_match);
|
||||||
|
|
Loading…
Add table
Reference in a new issue