summaryrefslogtreecommitdiffstats
path: root/drivers/net/designware_rockchip.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/designware_rockchip.c')
-rw-r--r--drivers/net/designware_rockchip.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/net/designware_rockchip.c b/drivers/net/designware_rockchip.c
index e4f74f646f..04e2b7f12d 100644
--- a/drivers/net/designware_rockchip.c
+++ b/drivers/net/designware_rockchip.c
@@ -1,10 +1,10 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0-only
#include <common.h>
#include <init.h>
#include <dma.h>
#include <net.h>
-#include <regmap.h>
+#include <linux/regmap.h>
#include <of_net.h>
#include <mfd/syscon.h>
#include <linux/iopoll.h>
@@ -21,6 +21,7 @@ struct rk_gmac_ops {
void (*set_rmii_speed)(struct eqos *eqos, int speed);
void (*set_rgmii_speed)(struct eqos *eqos, int speed);
void (*integrated_phy_powerup)(struct eqos *eqos);
+ const u32 *regs;
};
struct eqos_rk_gmac {
@@ -32,7 +33,7 @@ struct eqos_rk_gmac {
int bus_id;
u32 tx_delay;
u32 rx_delay;
- struct device_d *dev;
+ struct device *dev;
};
enum {
@@ -44,7 +45,6 @@ enum {
CLK_MAC_PCLK,
CLK_MAC_SPEED,
CLK_PTP_REF,
- CLK_XPCS_PCLK,
};
static const struct clk_bulk_data rk_gmac_clks[] = {
@@ -56,7 +56,6 @@ static const struct clk_bulk_data rk_gmac_clks[] = {
[CLK_MAC_PCLK] = { .id = "pclk_mac" },
[CLK_MAC_SPEED] = { .id = "clk_mac_speed" },
[CLK_PTP_REF] = { .id = "ptp_ref" },
- [CLK_XPCS_PCLK] = { .id = "pclk_xpcs" },
};
static inline struct eqos_rk_gmac *to_rk_gmac(struct eqos *eqos)
@@ -102,7 +101,7 @@ static void rk3568_set_to_rgmii(struct eqos *eqos,
int tx_delay, int rx_delay)
{
struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
- struct device_d *dev = priv->dev;
+ struct device *dev = priv->dev;
u32 offset_con0, offset_con1;
if (IS_ERR(priv->grf)) {
@@ -128,7 +127,7 @@ static void rk3568_set_to_rgmii(struct eqos *eqos,
static void rk3568_set_to_rmii(struct eqos *eqos)
{
struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
- struct device_d *dev = priv->dev;
+ struct device *dev = priv->dev;
u32 offset_con1;
if (IS_ERR(priv->grf)) {
@@ -146,7 +145,7 @@ static void rk3568_set_to_rmii(struct eqos *eqos)
static void rk3568_set_gmac_speed(struct eqos *eqos, int speed)
{
struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
- struct device_d *dev = priv->dev;
+ struct device *dev = priv->dev;
unsigned long rate;
int ret;
@@ -176,12 +175,17 @@ static const struct rk_gmac_ops rk3568_ops = {
.set_to_rmii = rk3568_set_to_rmii,
.set_rmii_speed = rk3568_set_gmac_speed,
.set_rgmii_speed = rk3568_set_gmac_speed,
+ .regs = (u32 []) {
+ 0xfe2a0000, /* gmac0 */
+ 0xfe010000, /* gmac1 */
+ 0x0, /* sentinel */
+ },
};
static int rk_gmac_powerup(struct eqos *eqos)
{
struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
- struct device_d *dev = priv->dev;
+ struct device *dev = priv->dev;
/*rmii or rgmii*/
switch (eqos->interface) {
@@ -226,11 +230,11 @@ static void eqos_rk_adjust_link(struct eth_device *edev)
eqos_adjust_link(edev);
}
-static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
+static int eqos_init_rk_gmac(struct device *dev, struct eqos *eqos)
{
- struct device_node *np = dev->device_node;
+ struct device_node *np = dev->of_node;
struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
- int ret;
+ int i = 0, ret;
const char *strings;
priv->dev = dev;
@@ -249,7 +253,15 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
priv->ops = device_get_match_data(dev);
- priv->bus_id = of_alias_get_id(np, "ethernet");
+ if (dev->num_resources > 0 && priv->ops->regs) {
+ while (priv->ops->regs[i]) {
+ if (priv->ops->regs[i] == dev->resource[0].start) {
+ priv->bus_id = i;
+ break;
+ }
+ i++;
+ }
+ }
priv->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
if (IS_ERR(priv->grf)) {
@@ -294,7 +306,7 @@ static struct eqos_ops rk_gmac_ops = {
.config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_AV,
};
-static int rk_gmac_probe(struct device_d *dev)
+static int rk_gmac_probe(struct device *dev)
{
return eqos_probe(dev, &rk_gmac_ops, xzalloc(sizeof(struct eqos_rk_gmac)));
}
@@ -307,8 +319,9 @@ static __maybe_unused struct of_device_id rk_gmac_compatible[] = {
/* sentinel */
}
};
+MODULE_DEVICE_TABLE(of, rk_gmac_compatible);
-static struct driver_d rk_gmac_driver = {
+static struct driver rk_gmac_driver = {
.name = "eqos-rockchip",
.probe = rk_gmac_probe,
.remove = eqos_remove,