From patchwork Thu Sep 27 20:16:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuiko Oshino X-Patchwork-Id: 975864 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=microchip.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42LlB925RFz9s3x for ; Fri, 28 Sep 2018 05:24:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728711AbeI1Boa (ORCPT ); Thu, 27 Sep 2018 21:44:30 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:41344 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728101AbeI1Boa (ORCPT ); Thu, 27 Sep 2018 21:44:30 -0400 X-IronPort-AV: E=Sophos;i="5.54,311,1534834800"; d="scan'208";a="18564781" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Sep 2018 12:24:42 -0700 Received: from validation1-HP-EliteBook-8540p.mchp-main.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Thu, 27 Sep 2018 12:24:41 -0700 From: Yuiko Oshino To: , , , , CC: , , , , , Subject: [PATCH v2 net-next 1/2] net: phy: micrel: add Microchip KSZ9131 inital driver Date: Thu, 27 Sep 2018 16:16:42 -0400 Message-ID: <1538079402-6208-1-git-send-email-yuiko.oshino@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for Microchip Technology KSZ9131 10/100/1000 Ethernet PHY Signed-off-by: Yuiko Oshino --- drivers/net/phy/micrel.c | 32 +++++++++++++++++++++++++++++--- include/linux/micrel_phy.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 3db06b4..a4473cb 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -14,7 +14,7 @@ * option) any later version. * * Support : Micrel Phys: - * Giga phys: ksz9021, ksz9031 + * Giga phys: ksz9021, ksz9031, ksz9131 * 100/10 Phys : ksz8001, ksz8721, ksz8737, ksz8041 * ksz8021, ksz8031, ksz8051, * ksz8081, ksz8091, @@ -425,6 +425,7 @@ static int ksz9021_config_init(struct phy_device *phydev) #define MII_KSZ9031RN_MMD_REGDATA_REG 0x0e #define OP_DATA 1 #define KSZ9031_PS_TO_REG 60 +#define KSZ9131_PS_TO_REG 100 /* Extended registers */ /* MMD Address 0x0 */ @@ -470,6 +471,10 @@ static int ksz9031_of_load_skew_values(struct phy_device *phydev, u16 maxval; u16 newval; int i; + int pstoreg = KSZ9031_PS_TO_REG; + + if (phydev->drv->phy_id == PHY_ID_KSZ9131) + pstoreg = KSZ9131_PS_TO_REG; for (i = 0; i < numfields; i++) if (!of_property_read_u32(of_node, field[i], val + i)) @@ -489,7 +494,7 @@ static int ksz9031_of_load_skew_values(struct phy_device *phydev, mask = 0xffff; mask ^= maxval << (field_sz * i); newval = (newval & mask) | - (((val[i] / KSZ9031_PS_TO_REG) & maxval) + (((val[i] / pstoreg) & maxval) << (field_sz * i)); } @@ -602,7 +607,10 @@ static int ksz9031_config_init(struct phy_device *phydev) } } - return ksz9031_center_flp_timing(phydev); + if (phydev->drv->phy_id == PHY_ID_KSZ9031) + return ksz9031_center_flp_timing(phydev); + else + return 0; err_force_master: phydev_err(phydev, "failed to force the phy to master mode\n"); @@ -975,6 +983,23 @@ static struct phy_driver ksphy_driver[] = { .suspend = genphy_suspend, .resume = kszphy_resume, }, { + .phy_id = PHY_ID_KSZ9131, + .phy_id_mask = MICREL_PHY_ID_MASK, + .name = "Microchip KSZ9131 Gigabit PHY", + .features = PHY_GBIT_FEATURES, + .flags = PHY_HAS_INTERRUPT, + .driver_data = &ksz9021_type, + .probe = kszphy_probe, + .config_init = ksz9031_config_init, + .read_status = ksz9031_read_status, + .ack_interrupt = kszphy_ack_interrupt, + .config_intr = kszphy_config_intr, + .get_sset_count = kszphy_get_sset_count, + .get_strings = kszphy_get_strings, + .get_stats = kszphy_get_stats, + .suspend = genphy_suspend, + .resume = kszphy_resume, +}, { .phy_id = PHY_ID_KSZ8873MLL, .phy_id_mask = MICREL_PHY_ID_MASK, .name = "Micrel KSZ8873MLL Switch", @@ -1022,6 +1047,7 @@ MODULE_LICENSE("GPL"); static struct mdio_device_id __maybe_unused micrel_tbl[] = { { PHY_ID_KSZ9021, 0x000ffffe }, { PHY_ID_KSZ9031, MICREL_PHY_ID_MASK }, + { PHY_ID_KSZ9131, MICREL_PHY_ID_MASK }, { PHY_ID_KSZ8001, 0x00fffffc }, { PHY_ID_KS8737, MICREL_PHY_ID_MASK }, { PHY_ID_KSZ8021, 0x00ffffff }, diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h index 472fa4d..7361cd3 100644 --- a/include/linux/micrel_phy.h +++ b/include/linux/micrel_phy.h @@ -31,6 +31,7 @@ #define PHY_ID_KSZ8081 0x00221560 #define PHY_ID_KSZ8061 0x00221570 #define PHY_ID_KSZ9031 0x00221620 +#define PHY_ID_KSZ9131 0x00221640 #define PHY_ID_KSZ886X 0x00221430 #define PHY_ID_KSZ8863 0x00221435