From patchwork Tue May 28 18:16:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10965603 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E2BC1398 for ; Tue, 28 May 2019 18:16:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E9D9285CE for ; Tue, 28 May 2019 18:16:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40F0128649; Tue, 28 May 2019 18:16:51 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2FEE285CE for ; Tue, 28 May 2019 18:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbfE1SQu (ORCPT ); Tue, 28 May 2019 14:16:50 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:53157 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727470AbfE1SQu (ORCPT ); Tue, 28 May 2019 14:16:50 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 45D29W6Lqfz1rYjs; Tue, 28 May 2019 20:16:47 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 45D29W66S4z1qqkH; Tue, 28 May 2019 20:16:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rOi1F258y-BX; Tue, 28 May 2019 20:16:46 +0200 (CEST) X-Auth-Info: r1INEhT01ndBmm6Gh2kFkm12Wkkgu9fPcuguq6b9K30= Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz [86.49.110.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 28 May 2019 20:16:46 +0200 (CEST) From: Marek Vasut To: netdev@vger.kernel.org Cc: Marek Vasut , Andrew Lunn , Florian Fainelli , Guenter Roeck , Heiner Kallweit , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH] net: phy: tja11xx: Add IRQ support to the driver Date: Tue, 28 May 2019 20:16:16 +0200 Message-Id: <20190528181616.2019-1-marex@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for handling the TJA11xx PHY IRQ signal. Signed-off-by: Marek Vasut Cc: Andrew Lunn Cc: Florian Fainelli Cc: Guenter Roeck Cc: Heiner Kallweit Cc: Jean Delvare Cc: linux-hwmon@vger.kernel.org --- drivers/net/phy/nxp-tja11xx.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index b705d0bd798b..0be9fe9a9604 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -40,6 +40,8 @@ #define MII_INTSRC_TEMP_ERR BIT(1) #define MII_INTSRC_UV_ERR BIT(3) +#define MII_INTEN 22 + #define MII_COMMSTAT 23 #define MII_COMMSTAT_LINK_UP BIT(15) @@ -239,6 +241,30 @@ static int tja11xx_read_status(struct phy_device *phydev) return 0; } +static int tja11xx_config_intr(struct phy_device *phydev) +{ + int ret; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + ret = phy_write(phydev, MII_INTEN, 0xcfef); + else + ret = phy_write(phydev, MII_INTEN, 0); + + if (ret < 0) + return ret; + + ret = phy_read(phydev, MII_INTSRC); + + return ret < 0 ? ret : 0; +} + +static int tja11xx_ack_interrupt(struct phy_device *phydev) +{ + int ret = phy_read(phydev, MII_INTSRC); + + return ret < 0 ? ret : 0; +} + static int tja11xx_get_sset_count(struct phy_device *phydev) { return ARRAY_SIZE(tja11xx_hw_stats); @@ -366,6 +392,9 @@ static struct phy_driver tja11xx_driver[] = { .suspend = genphy_suspend, .resume = genphy_resume, .set_loopback = genphy_loopback, + /* IRQ related */ + .config_intr = tja11xx_config_intr, + .ack_interrupt = tja11xx_ack_interrupt, /* Statistics */ .get_sset_count = tja11xx_get_sset_count, .get_strings = tja11xx_get_strings, @@ -381,6 +410,9 @@ static struct phy_driver tja11xx_driver[] = { .suspend = genphy_suspend, .resume = genphy_resume, .set_loopback = genphy_loopback, + /* IRQ related */ + .config_intr = tja11xx_config_intr, + .ack_interrupt = tja11xx_ack_interrupt, /* Statistics */ .get_sset_count = tja11xx_get_sset_count, .get_strings = tja11xx_get_strings,