From patchwork Wed Oct 18 08:02:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10014007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 556B0602C8 for ; Wed, 18 Oct 2017 08:02:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4690328390 for ; Wed, 18 Oct 2017 08:02:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ADAD28AF8; Wed, 18 Oct 2017 08:02:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7363D28390 for ; Wed, 18 Oct 2017 08:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2odO16dbVjj2/xj8oKnQmWRNRznjz7mNqwaVjIjUMy8=; b=g337slOpFWUxI4P6M1O/ZMT7Ct T38KZauGaGoP7NtTaV3o/L6ije3eTUJBbb6Ds841xVSIKMQNK9zUzlNrzgoEh3uQab7UQI11CfGSM jzVyqO8dkPhnsvehdkVSjOatQe35CZQZpfBr30YW1oGNInniq1s7d6jaLtv96vL63QqU5tE7z+/y6 qN3xmdpETP/dHScl+fsXrM99iT5mU/bUOTQ5wqae0oypbz/utBKEBG+sYouvLjonsTpmZ1/zmUDXj f1oGT3zCBpE53DimBh7XvkRaQz98ZXdj9E8B5i0THcEsldrQFaC/DElkZhUsJMbWZL0Tba21yCdWY zmuJoo1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4jJM-0000Fr-Do; Wed, 18 Oct 2017 08:02:44 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4jJI-0000Ca-FX for linux-amlogic@lists.infradead.org; Wed, 18 Oct 2017 08:02:42 +0000 Received: by mail-wm0-x236.google.com with SMTP id i124so8382724wmf.3 for ; Wed, 18 Oct 2017 01:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+NxLgViG2fC8qdKAp5Gx3WGvuOo4bw2RsqW3YnbyC58=; b=nxwGqC17EbItCvWmZSfkAKotwQCo3muV038tTY48AyPD11I8BEfyGcX3da2NklzmUn ariZcRWhARF/MzJCKbxpmOncERYnEtalLTMBfcWGSVVMApp6+in7yg4FQtEfOtQ5SBt2 N3o6Akh3MhqBlnfa7Yu0awIxJlHCghgfhkCzYBcXm4q2ajcUaGz0OqjAGH8vB55kuWH9 Z4TX0uEF01y6wOnFVXVc1JfjYsQVTqmGbf3JHzSRqKsKkhvGIhPp1eOjIiqZ/OSExm6+ fPFEGG1k+XOsvdUyganizUzUAl+w+s+Ta9B1fmzHII/XBp1JWHWLYxEQ+gBFstzLMpYy hGrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+NxLgViG2fC8qdKAp5Gx3WGvuOo4bw2RsqW3YnbyC58=; b=YNL62u9I5MOZvF+4p85y78TrR1IyYs7mluKdOgkJPoDUYE7J1hot/P/4z8DnOZIOIv 547kazUurAT/tv5BMaPYlSwrnUX4UJ9gehH9625V88oqTUrffYGSYv/7QVdBX9R9fa4w sqdezGgdxUmPABmwMlvk8k3QNmTJvGxeOosC3eVPvmdi3gFoqqpNRTF6WRjUbRimK7Yy 1WBaLNv0OJz4uRW++pmemVJT/ezdQiFc7IZGw+TL3AIQxUTgfZeEeWj5DNoBrhO4W0Ho cB3IhPxCupEE86OSBZzkiYV1E0WDTkP365ZgGJmBRI8DkFrKLjtueEK/aYPQ8hgLdKSn TQ/Q== X-Gm-Message-State: AMCzsaUJkDV353zHqlBSPYIqGkOWk8qWYm+j99rjbMhhjNyU3BtiYUiQ sSYctHkXrZccfSQDTsuVwMwVNA== X-Google-Smtp-Source: ABhQp+SKt7vK6g35QiIEzmjKGwUeWYBVD+Vh5P079+qA+VMvcNpPITcOGZFQBvoIRdRYDw4PRA7VYg== X-Received: by 10.28.185.75 with SMTP id j72mr5824722wmf.138.1508313738686; Wed, 18 Oct 2017 01:02:18 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id v8sm8693254wrg.80.2017.10.18.01.02.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Oct 2017 01:02:17 -0700 (PDT) From: Neil Armstrong To: u-boot@lists.denx.de, albert.u.boot@aribaud.net, joe.hershberger@ni.com Subject: [PATCH u-boot 1/3] net: phy: Add Amlogic Meson GXL Internal PHY support Date: Wed, 18 Oct 2017 10:02:10 +0200 Message-Id: <1508313732-19282-2-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508313732-19282-1-git-send-email-narmstrong@baylibre.com> References: <1508313732-19282-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171018_010240_688291_D39D2BA0 X-CRM114-Status: GOOD ( 13.29 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: b.galvani@gmail.com, trini@konsulko.com, sjg@chromium.org, linux-amlogic@lists.infradead.org, Neil Armstrong MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/net/phy/Kconfig | 3 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 3 +++ include/phy.h | 1 + 5 files changed, 65 insertions(+) create mode 100644 drivers/net/phy/meson-gxl.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 4d02d8b..e32f1eb 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -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 diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 54f32f6..1e264b2 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -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 index 0000000..ccf70c9 --- /dev/null +++ b/drivers/net/phy/meson-gxl.c @@ -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 + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include +#include +#include +#include + +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; +} diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 5be51d7..fd3dd55 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -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 diff --git a/include/phy.h b/include/phy.h index a0b1f12..50f1e12 100644 --- a/include/phy.h +++ b/include/phy.h @@ -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);