From patchwork Mon Oct 31 16:56:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9406053 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 583C860588 for ; Mon, 31 Oct 2016 17:00:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 446F728F93 for ; Mon, 31 Oct 2016 17:00:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34A2C29321; Mon, 31 Oct 2016 17:00:08 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC72E28F93 for ; Mon, 31 Oct 2016 17:00:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1FuR-0002RH-9R; Mon, 31 Oct 2016 16:58:07 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1FtJ-0001uk-H5 for linux-arm-kernel@lists.infradead.org; Mon, 31 Oct 2016 16:57:00 +0000 Received: by mail-wm0-x232.google.com with SMTP id a197so31783822wmd.0 for ; Mon, 31 Oct 2016 09:56:37 -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=+9YN8ly9ZZVZPFcxa6YXwQaDnSJlwKo5yZ81QXm1zhY=; b=dTCTf/i5MZIJk+Bw54kikhVqodv1d6UqAj35SGMQ2t9uuwDio1VjPah+Z/+uoZR8rc 7c4Z5yCJ5pgfxAvljaJ8GZI9+CD11Df4mwz5LU9mKYlkTPKQsgx2Q17ZsEkNgVjhwxN/ tg7e++KfdNJd0iu9oNlyGNbjlHPT9SfC9YfvcV/42xiAbit7AToPOdVP20y9maEdb6D3 bUTvGrJ0+/dwJXXs21XDjbe6QZXFst54GUBdQtTChzKOCQnDwSE/5flWchdsHK5v3249 yx3BYFewR1ccf/YkrcPxW8PcvPd8L7TNd/JyGsdZ4hXlJDUwI64DUD1O8DjKtg5r2b6a 6o1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+9YN8ly9ZZVZPFcxa6YXwQaDnSJlwKo5yZ81QXm1zhY=; b=GQvD8cH+6jsJ7ltJyzUPpVb6xWw7+ozsvVmlrbJCvHjL+0vJNBOuJoKgImzbYVTVIi h311EzCDuhOhmxU3tXItKTjgWBZnhT8S2JC2NAnvrKa5nAqZm15kcnbUsJZGFeerJTJx Y7lAt6l4X2aGK8NNOvE8i8dbNrfdPRb3kD56bOHSInAv36VHNOjPe7uCOCMlfw7rsuax vbT7gcPNTHxUQh7NBj1FE7kBJvwIr1YkqrYIqxxF0VgSSQnGX6RatvsRuXOqVTuOVBfX osu9k8f9Ofk06tJ4pPjyoCcy+GT4TG1uqQzhPTwT8UcazOs15w8cabwO/St27Cwm+2aC IVWg== X-Gm-Message-State: ABUngvea9nXOxzV4bQFEXOz2Nc1zNTpEpv4GM7DSwwgqmULuCEXdYBOfudicXDvJuBCUN3hH X-Received: by 10.28.14.194 with SMTP id 185mr10782199wmo.89.1477932995470; Mon, 31 Oct 2016 09:56:35 -0700 (PDT) Received: from localhost.localdomain (home.amouriers.starnux.net. [82.228.250.61]) by smtp.gmail.com with ESMTPSA id p184sm25751792wmg.3.2016.10.31.09.56.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Oct 2016 09:56:34 -0700 (PDT) From: Neil Armstrong To: f.fainelli@gmail.com, khilman@baylibre.com, carlo@caione.org, andrew@lunn.ch Subject: [RFC PATCH v2 2/5] net: phy: Add Meson GXL Internal PHY driver Date: Mon, 31 Oct 2016 17:56:24 +0100 Message-Id: <1477932987-27871-3-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477932987-27871-1-git-send-email-narmstrong@baylibre.com> References: <1477932987-27871-1-git-send-email-narmstrong@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161031_095657_996088_8F6A7629 X-CRM114-Status: GOOD ( 18.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Neil Armstrong MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add driver for the Internal RMII PHY found in the Amlogic Meson GXL SoCs. This PHY seems to only implement some standard registers and need some workarounds to provide autoneg values from vendor registers. Some magic values are currently used to configure the PHY, and this a temporary setup until clarification about these registers names and registers fields are provided by Amlogic. Signed-off-by: Neil Armstrong --- drivers/net/phy/Kconfig | 5 +++ drivers/net/phy/Makefile | 1 + drivers/net/phy/meson-gxl.c | 81 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 drivers/net/phy/meson-gxl.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 2651c8d..09342b6 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -226,6 +226,11 @@ config DP83867_PHY ---help--- Currently supports the DP83867 PHY. +config MESON_GXL_PHY + tristate "Amlogic Meson GXL Internal PHY" + ---help--- + Currently has a driver for the Amlogic Meson GXL Internal PHY + config FIXED_PHY tristate "MDIO Bus/PHY emulation with fixed speed/link PHYs" depends on PHYLIB diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index e58667d..1511b3e 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_MARVELL_PHY) += marvell.o obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o obj-$(CONFIG_MICREL_PHY) += micrel.o obj-$(CONFIG_MICROCHIP_PHY) += microchip.o +obj-$(CONFIG_MESON_GXL_PHY) += meson-gxl.o obj-$(CONFIG_MICROSEMI_PHY) += mscc.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c new file mode 100644 index 0000000..1ea69b7 --- /dev/null +++ b/drivers/net/phy/meson-gxl.c @@ -0,0 +1,81 @@ +/* + * Amlogic Meson GXL Internal PHY Driver + * + * Copyright (C) 2015 Amlogic, Inc. All rights reserved. + * Copyright (C) 2016 BayLibre, SAS. All rights reserved. + * Author: Neil Armstrong + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ +#include +#include +#include +#include +#include +#include + +static int meson_gxl_config_init(struct phy_device *phydev) +{ + /* Enable Analog and DSP register Bank access by */ + phy_write(phydev, 0x14, 0x0000); + phy_write(phydev, 0x14, 0x0400); + phy_write(phydev, 0x14, 0x0000); + phy_write(phydev, 0x14, 0x0400); + + /* Write Analog register 23 */ + phy_write(phydev, 0x17, 0x8E0D); + phy_write(phydev, 0x14, 0x4417); + + /* Enable fractional PLL */ + phy_write(phydev, 0x17, 0x0005); + phy_write(phydev, 0x14, 0x5C1B); + + /* Program fraction FR_PLL_DIV1 */ + phy_write(phydev, 0x17, 0x029A); + phy_write(phydev, 0x14, 0x5C1D); + + /* Program fraction FR_PLL_DIV1 */ + phy_write(phydev, 0x17, 0xAAAA); + phy_write(phydev, 0x14, 0x5C1C); + + return 0; +} + +static struct phy_driver meson_gxl_phy[] = { + { + .phy_id = 0x01814400, + .phy_id_mask = 0xfffffff0, + .name = "Meson GXL Internal PHY", + .features = PHY_BASIC_FEATURES, + .flags = PHY_IS_INTERNAL, + .config_init = meson_gxl_config_init, + .config_aneg = genphy_config_aneg, + .aneg_done = genphy_aneg_done, + .read_status = genphy_read_status, + .suspend = genphy_suspend, + .resume = genphy_resume, + }, +}; + +static struct mdio_device_id __maybe_unused meson_gxl_tbl[] = { + { 0x01814400, 0xfffffff0 }, + { } +}; + +module_phy_driver(meson_gxl_phy); + +MODULE_DEVICE_TABLE(mdio, meson_gxl_tbl); + +MODULE_DESCRIPTION("Amlogic Meson GXL Internal PHY driver"); +MODULE_AUTHOR("Baoqi wang"); +MODULE_AUTHOR("Neil Armstrong "); +MODULE_LICENSE("GPL");