Skip to content

Commit

Permalink
[gmac] added patchset from 4.14 (some rejects must be fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-w committed Jul 22, 2018
1 parent ba92430 commit 5703b24
Show file tree
Hide file tree
Showing 20 changed files with 525 additions and 46 deletions.
10 changes: 10 additions & 0 deletions arch/arm/boot/dts/mt7623.dtsi.rej
@@ -0,0 +1,10 @@
--- arch/arm/boot/dts/mt7623.dtsi
+++ arch/arm/boot/dts/mt7623.dtsi
@@ -1221,6 +1221,7 @@
"syscon";
reg = <0 0x1b000000 0 0x1000>;
#clock-cells = <1>;
+ #reset-cells = <1>;
};

eth: ethernet@1b100000 {
25 changes: 22 additions & 3 deletions arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
Expand Up @@ -21,6 +21,10 @@
stdout-path = "serial2:115200n8";
};

memory {
reg = <0 0x80000000 0 0x20000000>;
};

cpus {
cpu@0 {
proc-supply = <&mt6323_vproc_reg>;
Expand Down Expand Up @@ -174,29 +178,46 @@
port@0 {
reg = <0>;
label = "wan";
cpu = <&cpu_port1>;
};

port@1 {
reg = <1>;
label = "lan0";
cpu = <&cpu_port0>;
};

port@2 {
reg = <2>;
label = "lan1";
cpu = <&cpu_port0>;
};

port@3 {
reg = <3>;
label = "lan2";
cpu = <&cpu_port0>;
};

port@4 {
reg = <4>;
label = "lan3";
cpu = <&cpu_port0>;
};

port@6 {
cpu_port1: port@5 {
reg = <5>;
label = "cpu";
ethernet = <&gmac1>;
phy-mode = "trgmii";

fixed-link {
speed = <1000>;
full-duplex;
};
};

cpu_port0: port@6 {
reg = <6>;
label = "cpu";
ethernet = <&gmac0>;
Expand All @@ -209,8 +230,6 @@
};
};
};
};
};

&i2c0 {
pinctrl-names = "default";
Expand Down
65 changes: 65 additions & 0 deletions arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts.rej
@@ -0,0 +1,65 @@
--- arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
+++ arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
@@ -96,17 +100,21 @@
default-state = "off";
};
};
-
+/*
memory@80000000 {
reg = <0 0x80000000 0 0x40000000>;
};
-
+*/
vdd_fixed_vgpu_reg: fixedregulator@0 {
compatible = "regulator-fixed";
regulator-name = "vdd_fixed_vgpu";
regulator-min-microvolt = <1150000>;
regulator-max-microvolt = <1150000>;
};
+
+ mt7530: switch@0 {
+ compatible = "mediatek,mt7530";
+ };
};

&cir {
@@ -134,20 +142,35 @@
};
};

+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "trgmii";
+
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ pause;
+ };
+ };
+
mdio: mdio-bus {
#address-cells = <1>;
#size-cells = <0>;
-
- switch@0 {
+ };
+};
+ &mt7530 {
compatible = "mediatek,mt7530";
#address-cells = <1>;
#size-cells = <0>;
- reg = <0>;
+ //reg = <0>;
pinctrl-names = "default";
reset-gpios = <&pio 33 0>;
core-supply = <&mt6323_vpa_reg>;
io-supply = <&mt6323_vemc3v3_reg>;

+ dsa,mii-bus = <&mdio>;
+
ports {
#address-cells = <1>;
#size-cells = <0>;
2 changes: 1 addition & 1 deletion drivers/clk/clk.c
Expand Up @@ -1029,7 +1029,7 @@ static void clk_disable_unused_subtree(struct clk_core *core)
clk_core_disable_unprepare(core->parent);
}

static bool clk_ignore_unused;
static bool clk_ignore_unused = true;
static int __init clk_ignore_unused_setup(char *__unused)
{
clk_ignore_unused = true;
Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/mediatek/clk-mt2701.c
Expand Up @@ -770,6 +770,8 @@ static void __init mtk_infrasys_init_early(struct device_node *node)
if (r)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

mtk_register_reset_controller(node, 2, 0x30);
}
CLK_OF_DECLARE_DRIVER(mtk_infra, "mediatek,mt2701-infracfg",
mtk_infrasys_init_early);
Expand Down
49 changes: 36 additions & 13 deletions drivers/net/dsa/mt7530.c
Expand Up @@ -678,10 +678,18 @@ static int
mt7530_cpu_port_enable(struct mt7530_priv *priv,
int port)
{
u8 port_mask = 0;
int i;

/* Enable Mediatek header mode on the cpu port */
mt7530_write(priv, MT7530_PVC_P(port),
PORT_SPEC_TAG);

/* Enable Mediatek header mode on the GMAC that the cpu port
* connects to */
regmap_write_bits(priv->ethernet, MTK_GDMA_FWD_CFG(port),
GDMA_SPEC_TAG, GDMA_SPEC_TAG);

/* Setup the MAC by default for the cpu port */
mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPUP_LINK);

Expand All @@ -705,6 +713,7 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
struct phy_device *phy)
{
struct mt7530_priv *priv = ds->priv;
u8 upstream = dsa_port_upstream_port(ds, port);

mutex_lock(&priv->reg_mutex);

Expand All @@ -715,7 +724,7 @@ mt7530_port_enable(struct dsa_switch *ds, int port,
* restore the port matrix if the port is the member of a certain
* bridge.
*/
priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT));
priv->ports[port].pm |= PCR_MATRIX(BIT(upstream));
priv->ports[port].enable = true;
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
priv->ports[port].pm);
Expand Down Expand Up @@ -778,7 +787,8 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port,
struct net_device *bridge)
{
struct mt7530_priv *priv = ds->priv;
u32 port_bitmap = BIT(MT7530_CPU_PORT);
u8 upstream = dsa_port_upstream_port(ds, port);
u32 port_bitmap = BIT(upstream);
int i;

mutex_lock(&priv->reg_mutex);
Expand Down Expand Up @@ -879,6 +889,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
struct net_device *bridge)
{
struct mt7530_priv *priv = ds->priv;
u8 upstream = dsa_port_upstream_port(ds, port);
int i;

mutex_lock(&priv->reg_mutex);
Expand Down Expand Up @@ -906,8 +917,8 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
*/
if (priv->ports[port].enable)
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
PCR_MATRIX(BIT(MT7530_CPU_PORT)));
priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT));
PCR_MATRIX(BIT(upstream)));
priv->ports[port].pm = PCR_MATRIX(BIT(upstream));

mt7530_port_set_vlan_unaware(ds, port);

Expand Down Expand Up @@ -1279,8 +1290,13 @@ mt7530_setup(struct dsa_switch *ds)

/* Enable Port 6 only; P5 as GMAC5 which currently is not supported */
val = mt7530_read(priv, MT7530_MHWTRAP);
val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
val &= ~MHWTRAP_P5_DIS & ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
val |= MHWTRAP_MANUAL;
if (!dsa_is_cpu_port(ds, 5)) {
val |= MHWTRAP_P5_DIS;
val |= MHWTRAP_P5_MAC_SEL;
val |= MHWTRAP_P5_RGMII_MODE;
}
mt7530_write(priv, MT7530_MHWTRAP, val);

/* Enable and reset MIB counters */
Expand Down Expand Up @@ -1331,10 +1347,10 @@ static const struct dsa_switch_ops mt7530_switch_ops = {
};

static int
mt7530_probe(struct mdio_device *mdiodev)
mt7530_probe(struct platform_device *mdiodev)
{
struct mt7530_priv *priv;
struct device_node *dn;
struct device_node *dn, *mdio;

dn = mdiodev->dev.of_node;

Expand Down Expand Up @@ -1382,7 +1398,12 @@ mt7530_probe(struct mdio_device *mdiodev)
}
}

priv->bus = mdiodev->bus;
mdio = of_parse_phandle(dn, "dsa,mii-bus", 0);
if (!mdio)
return -EINVAL;
priv->bus = of_mdio_find_bus(mdio);
if (!priv->bus)
return -EPROBE_DEFER;
priv->dev = &mdiodev->dev;
priv->ds->priv = priv;
priv->ds->ops = &mt7530_switch_ops;
Expand All @@ -1392,8 +1413,8 @@ mt7530_probe(struct mdio_device *mdiodev)
return dsa_register_switch(priv->ds);
}

static void
mt7530_remove(struct mdio_device *mdiodev)
static int
mt7530_remove(struct platform_device *mdiodev)
{
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
int ret = 0;
Expand All @@ -1410,6 +1431,8 @@ mt7530_remove(struct mdio_device *mdiodev)

dsa_unregister_switch(priv->ds);
mutex_destroy(&priv->reg_mutex);

return 0;
}

static const struct of_device_id mt7530_of_match[] = {
Expand All @@ -1418,16 +1441,16 @@ static const struct of_device_id mt7530_of_match[] = {
};
MODULE_DEVICE_TABLE(of, mt7530_of_match);

static struct mdio_driver mt7530_mdio_driver = {
static struct platform_driver mtk_mt7530_driver = {
.probe = mt7530_probe,
.remove = mt7530_remove,
.mdiodrv.driver = {
.driver = {
.name = "mt7530",
.of_match_table = mt7530_of_match,
},
};
module_platform_driver(mtk_mt7530_driver);

mdio_module_driver(mt7530_mdio_driver);

MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");
Expand Down
33 changes: 33 additions & 0 deletions drivers/net/dsa/mt7530.c.rej
@@ -0,0 +1,33 @@
--- drivers/net/dsa/mt7530.c
+++ drivers/net/dsa/mt7530.c
@@ -694,8 +702,12 @@ mt7530_cpu_port_enable(struct mt7530_priv *priv,
/* CPU port gets connected to all user ports of
* the switch
*/
+ for (i = 0; i < MT7530_NUM_PORTS; i++)
+ if ((priv->ds->enabled_port_mask & BIT(i)) &&
+ (dsa_port_upstream_port(priv->ds, i) == port))
+ port_mask |= BIT(i);
mt7530_write(priv, MT7530_PCR_P(port),
- PCR_MATRIX(priv->ds->enabled_port_mask));
+ PCR_MATRIX(port_mask));

return 0;
}
@@ -919,15 +934,7 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
static enum dsa_tag_protocol
mtk_get_tag_protocol(struct dsa_switch *ds)
{
- struct mt7530_priv *priv = ds->priv;
-
- if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) {
- dev_warn(priv->dev,
- "port not matched with tagging CPU port\n");
- return DSA_TAG_PROTO_NONE;
- } else {
- return DSA_TAG_PROTO_MTK;
- }
+ return DSA_TAG_PROTO_MTK;
}

static int
4 changes: 4 additions & 0 deletions drivers/net/dsa/mt7530.h
Expand Up @@ -23,6 +23,10 @@

#define TRGMII_BASE(x) (0x10000 + (x))

/* Registers for GDMA configuration access */
#define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000))
#define GDMA_SPEC_TAG BIT(24)

/* Registers to ethsys access */
#define ETHSYS_CLKCFG0 0x2c
#define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11)
Expand Down

0 comments on commit 5703b24

Please sign in to comment.