lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1528534127-6213-1-git-send-email-kranke.kirill@gmail.com>
Date:   Sat,  9 Jun 2018 11:48:47 +0300
From:   Kirill Kranke <kranke.kirill@...il.com>
To:     andrew@...n.ch, f.fainelli@...il.com, davem@...emloft.net,
        netdev@...r.kernel.org
Cc:     Kirill Kranke <kranke.kirill@...il.com>
Subject: [PATCH net-next V3] net: phy: Add TJA1100 BroadR-Reach PHY driver.

Current generic PHY driver does not work with TJA1100 BroadR-REACH PHY
properly. TJA1100 does not have any standard ability enabled at MII_BMSR
register. Instead it has BroadR-REACH ability at MII_ESTATUS enabled, which
is not handled by generic driver yet. Therefore generic driver is unable to
guess required link speed, duplex etc. Device is started up with 10Mbps
halfduplex which is incorrect.

BroadR-REACH able flag is not specified in IEEE802.3-2015. Which is why I
did not add BroadR-REACH able flag support at generic driver. Once
BroadR-REACH able flag gets into IEEE802.3 it should be reasonable to
support it in the generic PHY driver.

Signed-off-by: Kirill Kranke <kranke.kirill@...il.com>

---

Notes:

Second edition of the patch miss changes list and V2 flag. Changes are
included here.

Changes from V1 to V2:
        - Remove unused #define from tja1100.c
        - Do not touch phydev->supported and phydev->advertising
        at tja1100_phy_config_init
        - Use proper error codes at tja1100_phy_config_aneg
        - Use phydev_err instead of pr_err
        - Do not specify read_status and soft_reset while they
        are default to required value
        - Correct wrong Signed-off-by email address

Changes from V2 to V3:
        - Add 'net-next' tree
        - Add this notes
        - Rename config option from TJA1100_PHY to NXP_TJA1100_PHY
        - Minor update to config help message: specify that able flag
        is TJA1100's custom
	- Add SUPPORTED_TP feature

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 343989f..ec30de4 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -387,6 +387,15 @@ config NATIONAL_PHY
 	---help---
 	  Currently supports the DP83865 PHY.
 
+config NXP_TJA1100_PHY
+	tristate "NXP TJA1100 PHY"
+	help
+	  Support of NXP TJA1100 BroadR-REACH ethernet PHY.
+	  Generic driver is not suitable for TJA1100 PHY while the PHY does not
+	  advertise any standard IEEE capabilities. It uses custom BroadR-REACH
+	  able flag instead. This driver configures capabilities of the PHY
+	  properly.
+
 config QSEMI_PHY
 	tristate "Quality Semiconductor PHYs"
 	---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 5805c0b..c1bc14d4 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -76,6 +76,7 @@ obj-$(CONFIG_MICROCHIP_PHY)	+= microchip.o
 obj-$(CONFIG_MICROCHIP_T1_PHY)	+= microchip_t1.o
 obj-$(CONFIG_MICROSEMI_PHY)	+= mscc.o
 obj-$(CONFIG_NATIONAL_PHY)	+= national.o
+obj-$(CONFIG_NXP_TJA1100_PHY)	+= tja1100.o
 obj-$(CONFIG_QSEMI_PHY)		+= qsemi.o
 obj-$(CONFIG_REALTEK_PHY)	+= realtek.o
 obj-$(CONFIG_RENESAS_PHY)	+= uPD60620.o
diff --git a/drivers/net/phy/tja1100.c b/drivers/net/phy/tja1100.c
new file mode 100644
index 0000000..2b03057
--- /dev/null
+++ b/drivers/net/phy/tja1100.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0
+/* tja1100.c: TJA1100 BoardR-REACH PHY driver.
+ *
+ * Copyright (c) 2017 Kirill Kranke <kirill.kranke@...il.com>
+ * Author: Kirill Kranke <kirill.kranke@...il.com>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/phy.h>
+
+static int tja1100_phy_config_init(struct phy_device *phydev)
+{
+	phydev->autoneg = AUTONEG_DISABLE;
+	phydev->speed = SPEED_100;
+	phydev->duplex = DUPLEX_FULL;
+
+	return 0;
+}
+
+static int tja1100_phy_config_aneg(struct phy_device *phydev)
+{
+	if (phydev->autoneg == AUTONEG_ENABLE) {
+		phydev_err(phydev, "autonegotiation is not supported\n");
+		return -EINVAL;
+	}
+
+	if (phydev->speed != SPEED_100 || phydev->duplex != DUPLEX_FULL) {
+		phydev_err(phydev, "only 100MBps Full Duplex allowed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static struct phy_driver tja1100_phy_driver[] = {
+	{
+		.phy_id = 0x0180dc48,
+		.phy_id_mask = 0xfffffff0,
+		.name = "NXP TJA1100",
+
+		/* TJA1100 has only 100BASE-BroadR-REACH ability specified
+		 * at MII_ESTATUS register. Standard modes are not
+		 * supported. Therefore BroadR-REACH allow only 100Mbps
+		 * full duplex without autoneg.
+		 */
+		.features = SUPPORTED_100baseT_Full | SUPPORTED_MII
+				| SUPPORTED_TP,
+
+		.config_aneg = tja1100_phy_config_aneg,
+		.config_init = tja1100_phy_config_init,
+
+		.suspend = genphy_suspend,
+		.resume = genphy_resume,
+	}
+};
+
+module_phy_driver(tja1100_phy_driver);
+
+MODULE_DESCRIPTION("NXP TJA1100 driver");
+MODULE_AUTHOR("Kirill Kranke <kkranke@...con.com>");
+MODULE_LICENSE("GPL");
+
+static struct mdio_device_id __maybe_unused nxp_tbl[] = {
+	{ 0x0180dc48, 0xfffffff0 },
+	{}
+};
+
+MODULE_DEVICE_TABLE(mdio, nxp_tbl);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ