Skip to content

Commit a475109

Browse files
committed
Merge branch 'Add-comphy-support-for-Armada-38x'
Russell King says: ==================== Add comphy support for Armada 38x This series adds support for the comphy for Armada 38x, which allows these SoCs to use 2500BASE-X mode with appropriate SFP modules. Tested on SolidRun Clearfog after updating for the 5.0 merge window changes. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f06f095 + f548ced commit a475109

File tree

8 files changed

+369
-5
lines changed

8 files changed

+369
-5
lines changed

Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Optional properties:
1919
"marvell,armada-370-neta" and 9800B for others.
2020
- clock-names: List of names corresponding to clocks property; shall be
2121
"core" for core clock and "bus" for the optional bus clock.
22-
22+
- phys: comphy for the ethernet port, see ../phy/phy-bindings.txt
2323

2424
Optional properties (valid only for Armada XP/38x):
2525

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
mvebu armada 38x comphy driver
2+
------------------------------
3+
4+
This comphy controller can be found on Marvell Armada 38x. It provides a
5+
number of shared PHYs used by various interfaces (network, sata, usb,
6+
PCIe...).
7+
8+
Required properties:
9+
10+
- compatible: should be "marvell,armada-380-comphy"
11+
- reg: should contain the comphy register location and length.
12+
- #address-cells: should be 1.
13+
- #size-cells: should be 0.
14+
15+
A sub-node is required for each comphy lane provided by the comphy.
16+
17+
Required properties (child nodes):
18+
19+
- reg: comphy lane number.
20+
- #phy-cells : from the generic phy bindings, must be 1. Defines the
21+
input port to use for a given comphy lane.
22+
23+
Example:
24+
25+
comphy: phy@18300 {
26+
compatible = "marvell,armada-380-comphy";
27+
reg = <0x18300 0x100>;
28+
#address-cells = <1>;
29+
#size-cells = <0>;
30+
31+
cpm_comphy0: phy@0 {
32+
reg = <0>;
33+
#phy-cells = <1>;
34+
};
35+
36+
cpm_comphy1: phy@1 {
37+
reg = <1>;
38+
#phy-cells = <1>;
39+
};
40+
};

arch/arm/boot/dts/armada-388-clearfog.dtsi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
bm,pool-long = <2>;
9494
bm,pool-short = <1>;
9595
buffer-manager = <&bm>;
96+
phys = <&comphy1 1>;
9697
phy-mode = "sgmii";
9798
status = "okay";
9899
};
@@ -103,6 +104,7 @@
103104
bm,pool-short = <1>;
104105
buffer-manager = <&bm>;
105106
managed = "in-band-status";
107+
phys = <&comphy5 2>;
106108
phy-mode = "sgmii";
107109
sfp = <&sfp>;
108110
status = "okay";

arch/arm/boot/dts/armada-38x.dtsi

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,43 @@
335335
#clock-cells = <1>;
336336
};
337337

338+
comphy: phy@18300 {
339+
compatible = "marvell,armada-380-comphy";
340+
reg = <0x18300 0x100>;
341+
#address-cells = <1>;
342+
#size-cells = <0>;
343+
344+
comphy0: phy@0 {
345+
reg = <0>;
346+
#phy-cells = <1>;
347+
};
348+
349+
comphy1: phy@1 {
350+
reg = <1>;
351+
#phy-cells = <1>;
352+
};
353+
354+
comphy2: phy@2 {
355+
reg = <2>;
356+
#phy-cells = <1>;
357+
};
358+
359+
comphy3: phy@3 {
360+
reg = <3>;
361+
#phy-cells = <1>;
362+
};
363+
364+
comphy4: phy@4 {
365+
reg = <4>;
366+
#phy-cells = <1>;
367+
};
368+
369+
comphy5: phy@5 {
370+
reg = <5>;
371+
#phy-cells = <1>;
372+
};
373+
};
374+
338375
coreclk: mvebu-sar@18600 {
339376
compatible = "marvell,armada-380-core-clock";
340377
reg = <0x18600 0x04>;

drivers/net/ethernet/marvell/mvneta.c

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <linux/of_irq.h>
2828
#include <linux/of_mdio.h>
2929
#include <linux/of_net.h>
30+
#include <linux/phy/phy.h>
3031
#include <linux/phy.h>
3132
#include <linux/phylink.h>
3233
#include <linux/platform_device.h>
@@ -436,6 +437,7 @@ struct mvneta_port {
436437
struct device_node *dn;
437438
unsigned int tx_csum_limit;
438439
struct phylink *phylink;
440+
struct phy *comphy;
439441

440442
struct mvneta_bm *bm_priv;
441443
struct mvneta_bm_pool *pool_long;
@@ -3151,6 +3153,8 @@ static void mvneta_start_dev(struct mvneta_port *pp)
31513153
{
31523154
int cpu;
31533155

3156+
WARN_ON(phy_power_on(pp->comphy));
3157+
31543158
mvneta_max_rx_size_set(pp, pp->pkt_size);
31553159
mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
31563160

@@ -3213,6 +3217,8 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
32133217

32143218
mvneta_tx_reset(pp);
32153219
mvneta_rx_reset(pp);
3220+
3221+
WARN_ON(phy_power_off(pp->comphy));
32163222
}
32173223

32183224
static void mvneta_percpu_enable(void *arg)
@@ -3338,6 +3344,7 @@ static int mvneta_set_mac_addr(struct net_device *dev, void *addr)
33383344
static void mvneta_validate(struct net_device *ndev, unsigned long *supported,
33393345
struct phylink_link_state *state)
33403346
{
3347+
struct mvneta_port *pp = netdev_priv(ndev);
33413348
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
33423349

33433350
/* We only support QSGMII, SGMII, 802.3z and RGMII modes */
@@ -3358,8 +3365,13 @@ static void mvneta_validate(struct net_device *ndev, unsigned long *supported,
33583365
phylink_set(mask, Pause);
33593366

33603367
/* Half-duplex at speeds higher than 100Mbit is unsupported */
3361-
phylink_set(mask, 1000baseT_Full);
3362-
phylink_set(mask, 1000baseX_Full);
3368+
if (pp->comphy || state->interface != PHY_INTERFACE_MODE_2500BASEX) {
3369+
phylink_set(mask, 1000baseT_Full);
3370+
phylink_set(mask, 1000baseX_Full);
3371+
}
3372+
if (pp->comphy || state->interface == PHY_INTERFACE_MODE_2500BASEX) {
3373+
phylink_set(mask, 2500baseX_Full);
3374+
}
33633375

33643376
if (!phy_interface_mode_is_8023z(state->interface)) {
33653377
/* 10M and 100M are only supported in non-802.3z mode */
@@ -3373,6 +3385,11 @@ static void mvneta_validate(struct net_device *ndev, unsigned long *supported,
33733385
__ETHTOOL_LINK_MODE_MASK_NBITS);
33743386
bitmap_and(state->advertising, state->advertising, mask,
33753387
__ETHTOOL_LINK_MODE_MASK_NBITS);
3388+
3389+
/* We can only operate at 2500BaseX or 1000BaseX. If requested
3390+
* to advertise both, only report advertising at 2500BaseX.
3391+
*/
3392+
phylink_helper_basex_speed(state);
33763393
}
33773394

33783395
static int mvneta_mac_link_state(struct net_device *ndev,
@@ -3384,7 +3401,9 @@ static int mvneta_mac_link_state(struct net_device *ndev,
33843401
gmac_stat = mvreg_read(pp, MVNETA_GMAC_STATUS);
33853402

33863403
if (gmac_stat & MVNETA_GMAC_SPEED_1000)
3387-
state->speed = SPEED_1000;
3404+
state->speed =
3405+
state->interface == PHY_INTERFACE_MODE_2500BASEX ?
3406+
SPEED_2500 : SPEED_1000;
33883407
else if (gmac_stat & MVNETA_GMAC_SPEED_100)
33893408
state->speed = SPEED_100;
33903409
else
@@ -3499,12 +3518,20 @@ static void mvneta_mac_config(struct net_device *ndev, unsigned int mode,
34993518
MVNETA_GMAC_FORCE_LINK_DOWN);
35003519
}
35013520

3521+
35023522
/* When at 2.5G, the link partner can send frames with shortened
35033523
* preambles.
35043524
*/
35053525
if (state->speed == SPEED_2500)
35063526
new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE;
35073527

3528+
if (pp->comphy &&
3529+
(state->interface == PHY_INTERFACE_MODE_SGMII ||
3530+
state->interface == PHY_INTERFACE_MODE_1000BASEX ||
3531+
state->interface == PHY_INTERFACE_MODE_2500BASEX))
3532+
WARN_ON(phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET,
3533+
state->interface));
3534+
35083535
if (new_ctrl0 != gmac_ctrl0)
35093536
mvreg_write(pp, MVNETA_GMAC_CTRL_0, new_ctrl0);
35103537
if (new_ctrl2 != gmac_ctrl2)
@@ -4404,7 +4431,7 @@ static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
44044431
if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
44054432
mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_QSGMII_SERDES_PROTO);
44064433
else if (phy_mode == PHY_INTERFACE_MODE_SGMII ||
4407-
phy_mode == PHY_INTERFACE_MODE_1000BASEX)
4434+
phy_interface_mode_is_8023z(phy_mode))
44084435
mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
44094436
else if (!phy_interface_mode_is_rgmii(phy_mode))
44104437
return -EINVAL;
@@ -4421,6 +4448,7 @@ static int mvneta_probe(struct platform_device *pdev)
44214448
struct mvneta_port *pp;
44224449
struct net_device *dev;
44234450
struct phylink *phylink;
4451+
struct phy *comphy;
44244452
const char *dt_mac_addr;
44254453
char hw_mac_addr[ETH_ALEN];
44264454
const char *mac_from;
@@ -4446,6 +4474,14 @@ static int mvneta_probe(struct platform_device *pdev)
44464474
goto err_free_irq;
44474475
}
44484476

4477+
comphy = devm_of_phy_get(&pdev->dev, dn, NULL);
4478+
if (comphy == ERR_PTR(-EPROBE_DEFER)) {
4479+
err = -EPROBE_DEFER;
4480+
goto err_free_irq;
4481+
} else if (IS_ERR(comphy)) {
4482+
comphy = NULL;
4483+
}
4484+
44494485
phylink = phylink_create(dev, pdev->dev.fwnode, phy_mode,
44504486
&mvneta_phylink_ops);
44514487
if (IS_ERR(phylink)) {
@@ -4462,6 +4498,7 @@ static int mvneta_probe(struct platform_device *pdev)
44624498
pp = netdev_priv(dev);
44634499
spin_lock_init(&pp->lock);
44644500
pp->phylink = phylink;
4501+
pp->comphy = comphy;
44654502
pp->phy_interface = phy_mode;
44664503
pp->dn = dn;
44674504

drivers/phy/marvell/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ config PHY_BERLIN_USB
2121
help
2222
Enable this to support the USB PHY on Marvell Berlin SoCs.
2323

24+
config PHY_MVEBU_A38X_COMPHY
25+
tristate "Marvell Armada 38x comphy driver"
26+
depends on ARCH_MVEBU || COMPILE_TEST
27+
depends on OF
28+
select GENERIC_PHY
29+
help
30+
This driver allows to control the comphy, an hardware block providing
31+
shared serdes PHYs on Marvell Armada 38x. Its serdes lanes can be
32+
used by various controllers (Ethernet, sata, usb, PCIe...).
33+
2434
config PHY_MVEBU_CP110_COMPHY
2535
tristate "Marvell CP110 comphy driver"
2636
depends on ARCH_MVEBU || COMPILE_TEST

drivers/phy/marvell/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
33
obj-$(CONFIG_PHY_BERLIN_SATA) += phy-berlin-sata.o
44
obj-$(CONFIG_PHY_BERLIN_USB) += phy-berlin-usb.o
5+
obj-$(CONFIG_PHY_MVEBU_A38X_COMPHY) += phy-armada38x-comphy.o
56
obj-$(CONFIG_PHY_MVEBU_CP110_COMPHY) += phy-mvebu-cp110-comphy.o
67
obj-$(CONFIG_PHY_MVEBU_SATA) += phy-mvebu-sata.o
78
obj-$(CONFIG_PHY_PXA_28NM_HSIC) += phy-pxa-28nm-hsic.o

0 commit comments

Comments
 (0)