From patchwork Tue May 28 19:23:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10965711 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 DC52E933 for ; Tue, 28 May 2019 19:24:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC87728807 for ; Tue, 28 May 2019 19:24:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFB0A2882E; Tue, 28 May 2019 19:24:03 +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 002FD28807 for ; Tue, 28 May 2019 19:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726994AbfE1TYC (ORCPT ); Tue, 28 May 2019 15:24:02 -0400 Received: from mail-out.m-online.net ([212.18.0.10]:34641 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfE1TYC (ORCPT ); Tue, 28 May 2019 15:24:02 -0400 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 45D3g26qMPz1rZJ4; Tue, 28 May 2019 21:23:58 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 45D3g26083z1qqkZ; Tue, 28 May 2019 21:23:58 +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 8mZ_js3Y9rox; Tue, 28 May 2019 21:23:56 +0200 (CEST) X-Auth-Info: DlH0NurDGI8SzNeUy8ZE7mDMC4Enu71knP7qqY9Y3VI= 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 21:23:56 +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 V2] net: phy: tja11xx: Add IRQ support to the driver Date: Tue, 28 May 2019 21:23:24 +0200 Message-Id: <20190528192324.28862-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 --- V2: - Define each bit of the MII_INTEN register and a mask - Drop IRQ acking from tja11xx_config_intr() --- drivers/net/phy/nxp-tja11xx.c | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index b705d0bd798b..b41af609607d 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -40,6 +40,29 @@ #define MII_INTSRC_TEMP_ERR BIT(1) #define MII_INTSRC_UV_ERR BIT(3) +#define MII_INTEN 22 +#define MII_INTEN_PWON_EN BIT(15) +#define MII_INTEN_WAKEUP_EN BIT(14) +#define MII_INTEN_PHY_INIT_FAIL_EN BIT(11) +#define MII_INTEN_LINK_STATUS_FAIL_EN BIT(10) +#define MII_INTEN_LINK_STATUS_UP_EN BIT(9) +#define MII_INTEN_SYM_ERR_EN BIT(8) +#define MII_INTEN_TRAINING_FAILED_EN BIT(7) +#define MII_INTEN_SQI_WARNING_EN BIT(6) +#define MII_INTEN_CONTROL_ERR_EN BIT(5) +#define MII_INTEN_UV_ERR_EN BIT(3) +#define MII_INTEN_UV_RECOVERY_EN BIT(2) +#define MII_INTEN_TEMP_ERR_EN BIT(1) +#define MII_INTEN_SLEEP_ABORT_EN BIT(0) +#define MII_INTEN_MASK \ + (MII_INTEN_PWON_EN | MII_INTEN_WAKEUP_EN | \ + MII_INTEN_PHY_INIT_FAIL_EN | MII_INTEN_LINK_STATUS_FAIL_EN | \ + MII_INTEN_LINK_STATUS_UP_EN | MII_INTEN_SYM_ERR_EN | \ + MII_INTEN_TRAINING_FAILED_EN | MII_INTEN_SQI_WARNING_EN | \ + MII_INTEN_CONTROL_ERR_EN | MII_INTEN_UV_ERR_EN | \ + MII_INTEN_UV_RECOVERY_EN | MII_INTEN_TEMP_ERR_EN | \ + MII_INTEN_SLEEP_ABORT_EN) + #define MII_COMMSTAT 23 #define MII_COMMSTAT_LINK_UP BIT(15) @@ -239,6 +262,25 @@ 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, MII_INTEN_MASK); + else + ret = phy_write(phydev, MII_INTEN, 0); + + 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 +408,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 +426,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,