Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.14 gmac #32

Merged
merged 3 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arch/arm/boot/dts/mt7623.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@
clocks = <&mmsys CLK_MM_MDP_BLS_26M>,
<&mmsys CLK_MM_DISP_BLS>;
clock-names = "main", "mm";
status = "disabled";
status = "disabled";
};

color@1400b000 {
Expand Down Expand Up @@ -1236,5 +1236,6 @@
"syscon";
reg = <0 0x1c000000 0 0x1000>;
#clock-cells = <1>;
#reset-cells = <1>;
};
};
55 changes: 44 additions & 11 deletions arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
stdout-path = "serial2:115200n8";
};

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

cpus {
cpu@0 {
proc-supply = <&mt6323_vproc_reg>;
Expand Down Expand Up @@ -111,17 +115,16 @@
};
};

memory@80000000 {
device_type = "memory";
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";
};
};

&bls {
Expand Down Expand Up @@ -158,20 +161,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>;
Expand All @@ -180,29 +198,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>;
};

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

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

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

&cec {
status = "okay";
Expand Down
2 changes: 1 addition & 1 deletion drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,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
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ static void 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
65 changes: 42 additions & 23 deletions drivers/net/dsa/mt7530.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,10 +670,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 @@ -686,8 +694,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;
}
Expand All @@ -697,6 +709,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 @@ -707,7 +720,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 @@ -770,7 +783,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 @@ -808,6 +822,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 All @@ -832,8 +847,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));

mutex_unlock(&priv->reg_mutex);
}
Expand Down Expand Up @@ -908,15 +923,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
Expand Down Expand Up @@ -989,8 +996,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 @@ -1037,10 +1049,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 @@ -1088,7 +1100,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 @@ -1098,8 +1115,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 @@ -1116,6 +1133,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 @@ -1124,16 +1143,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 <[email protected]>");
MODULE_DESCRIPTION("Driver for Mediatek MT7530 Switch");
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/dsa/mt7530.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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
Loading