]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
net: phy: Add Amlogic Meson GXL Internal PHY support
authorNeil Armstrong <narmstrong@baylibre.com>
Wed, 18 Oct 2017 08:02:10 +0000 (10:02 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 17 Nov 2017 12:44:13 +0000 (07:44 -0500)
The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right
before it's configuration.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
drivers/net/phy/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/meson-gxl.c [new file with mode: 0644]
drivers/net/phy/phy.c
include/phy.h

index 4d02d8bb19a953420a1dc50cfe00cb405554c401..e32f1eb1c047016e5dfeba5921f34210b2a5988b 100644 (file)
@@ -55,6 +55,9 @@ config PHY_LXT
 config PHY_MARVELL
        bool "Marvell Ethernet PHYs support"
 
+config PHY_MESON_GXL
+       bool "Amlogic Meson GXL Internal PHY support"
+
 config PHY_MICREL
        bool "Micrel Ethernet PHYs support"
        help
index 54f32f606be3fed7b65f81c5155de843afcddb0c..1e264b2f2b0347cc4e13474da5a9d565ed337aef 100644 (file)
@@ -21,6 +21,7 @@ obj-$(CONFIG_PHY_LXT) += lxt.o
 obj-$(CONFIG_PHY_MARVELL) += marvell.o
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
+obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
 obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
 obj-$(CONFIG_PHY_REALTEK) += realtek.o
 obj-$(CONFIG_PHY_SMSC) += smsc.o
diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c
new file mode 100644 (file)
index 0000000..ccf70c9
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Meson GXL Internal PHY Driver
+ *
+ * Copyright (C) 2015 Amlogic, Inc. All rights reserved.
+ * Copyright (C) 2016 BayLibre, SAS. All rights reserved.
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <config.h>
+#include <common.h>
+#include <linux/bitops.h>
+#include <phy.h>
+
+static int meson_gxl_phy_config(struct phy_device *phydev)
+{
+       /* Enable Analog and DSP register Bank access by */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x0000);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x0400);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x0000);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x0400);
+
+       /* Write Analog register 23 */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x8E0D);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x4417);
+
+       /* Enable fractional PLL */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x0005);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x5C1B);
+
+       /* Program fraction FR_PLL_DIV1 */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0x029A);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x5C1D);
+
+       /* Program fraction FR_PLL_DIV1 */
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x17, 0xAAAA);
+       phy_write(phydev, MDIO_DEVAD_NONE, 0x14, 0x5C1C);
+
+       return genphy_config(phydev);
+}
+
+static struct phy_driver meson_gxl_phy_driver = {
+       .name = "Meson GXL Internal PHY",
+       .uid = 0x01814400,
+       .mask = 0xfffffff0,
+       .features = PHY_BASIC_FEATURES,
+       .config = &meson_gxl_phy_config,
+       .startup = &genphy_startup,
+       .shutdown = &genphy_shutdown,
+};
+
+int phy_meson_gxl_init(void)
+{
+       phy_register(&meson_gxl_phy_driver);
+
+       return 0;
+}
index 5be51d73ce623cc7e8f66c7ab7171e781f68bc49..fd3dd556c8794f2524b0b1710b406394d21880a2 100644 (file)
@@ -494,6 +494,9 @@ int phy_init(void)
 #ifdef CONFIG_PHY_MICREL_KSZ90X1
        phy_micrel_ksz90x1_init();
 #endif
+#ifdef CONFIG_PHY_MESON_GXL
+       phy_meson_gxl_init();
+#endif
 #ifdef CONFIG_PHY_NATSEMI
        phy_natsemi_init();
 #endif
index a0b1f12317f317ca808bf1e2e27ea2b307715135..50f1e12f8c2c6bf73a3a83a4b31dce5ba57c838c 100644 (file)
@@ -268,6 +268,7 @@ int phy_lxt_init(void);
 int phy_marvell_init(void);
 int phy_micrel_ksz8xxx_init(void);
 int phy_micrel_ksz90x1_init(void);
+int phy_meson_gxl_init(void);
 int phy_natsemi_init(void);
 int phy_realtek_init(void);
 int phy_smsc_init(void);