From patchwork Thu Dec 7 14:27:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 120986 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8425476qgn; Thu, 7 Dec 2017 06:28:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMbB0KTDtUDEY6TSBV8Cme7z07zfLZAcpPOpwJDBfNVnX085FK9UCwCizisydEg9usdCmElp X-Received: by 10.84.169.67 with SMTP id g61mr26010936plb.152.1512656885559; Thu, 07 Dec 2017 06:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512656885; cv=none; d=google.com; s=arc-20160816; b=WH/albz0vLVvptjePOR9lV2iYUQdadOoTCn8dYYzuWGcj+sS5buc7uQjwJeRFKf4LR EFWdM079FXzxJO0gGod2QoGPxMb+x5ZvSNedEcF3ZWaYassIFlwsizMmwPPqnDk6XP9E dHE35r9YWkRM6uoF8I32a/54ZxPe3p1pF6FZ41G+gTD5DI7/8lZz2Z5OXYZfQuu9fNt+ s8eS6qxwdagHZQgAoQ5orGZuzJpzGLhdCZA+gsthPGgdy6sVmxqYCc6JmTEqos0Dz4LR nTYmTtlxRPFAnoJL8finZL3rGUlZxgiPLuh84FDxz5FnJVCGXBqNJPimcAh+UHmjtYkL uWVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=D9e33m8eYc8i3EnNuM0oIMqS70qglGoD6u5VklvZrbo=; b=SZNuLZxT7P/HkwE+B85rC57UhM/kVJx0ZVJQujvRfbECN7rO+now6Yb9KUdfFixsA5 tKnNqy4EAcpEaZ5H3bpybwp/T2fX9KhNQ0dJvWCyn5Svb7eG3OMi9BmdPNi2PyK2JQRa Kvl8mxeaayZ75OGDScR2lu/YK1jU4iadZcICS0PZMSCZsyneL9LMMFZ9kFhAQYnUu9Wm xCfwSc/jocgDOoQ+L6OUOrf6aM5YRWFu7LkxHRZRFLU3EUbfqV7/WTLavrXtqQxuVc0I Nwrf17XLEAXmT0KqZc0jRQ2p+xPM9czN6CscdCGL00bDAjZuTap8jm81ydNLUPGLmjcQ s/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Seru7aNo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92si3781739pli.692.2017.12.07.06.28.05; Thu, 07 Dec 2017 06:28:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Seru7aNo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753975AbdLGO2D (ORCPT + 22 others); Thu, 7 Dec 2017 09:28:03 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:41371 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753854AbdLGO10 (ORCPT ); Thu, 7 Dec 2017 09:27:26 -0500 Received: by mail-wm0-f66.google.com with SMTP id g75so13503135wme.0 for ; Thu, 07 Dec 2017 06:27:26 -0800 (PST) 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=D9e33m8eYc8i3EnNuM0oIMqS70qglGoD6u5VklvZrbo=; b=Seru7aNoof5wMNGUqn2SOLwZWYltExTKXuASWi+jmi5ioMpD+JY68To0bMVdFUZ7o9 m/J4XJctM62wLZEO3dvHWD8qiVfS6sWTLngdMkuyoEr7ct7fyzI9zt2DCQoxL7OE/iwg oQ8BEQ4CLbNui3OtUCvgrpSaOE2/0MxWhfP3WkU9RfE29+6ofiufJaUroqNVsOG65w3z M0ugmDTUOBs9jd8XTTSDf9x/BZK55wrIBWul12ZFAoLgoqI5fDipUVpDGp+isZxdfj+h S/9ozUqC1DkD899nXDuzvGkdMTprnK/xLmJ2XRMZQ2USfxOZgGEubNBK7JAd/DFnpsGD fN9Q== 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=D9e33m8eYc8i3EnNuM0oIMqS70qglGoD6u5VklvZrbo=; b=Yf0JqV7EGtYNaFloBOCg8AenGPV7tl6WEr3VZqxhSBbDsQ6LFB11qg1CG5CNAm9x+q XFtWzMcyqMLtZ+jAmiOxO2JQbBqAQqm97SZi5tVvzw6C5JKX5tA6U8PgXbNd/8T2jI6h EuhF2KN4dPMA3YfSGOIWtmlhxN+5JgydDK9hxr/5clDNZKwVpYWlMyfQ8RTlhl47ptLQ Qnt12QuaGxr92s3iBvmQsWmS3Zdxfvv4ihPxChKFKL0ZTU6be9rsipO+7OI0/r9KcVxn EqxzW7wLClZd9Bmsb/dQE0/A/5aDu49r9yuAdqTT7ASZ+OqYZPTcc0vD2+cidEpXa5gW 5iHQ== X-Gm-Message-State: AKGB3mJHIBy5J3xi8ywvqZC/itEMhyb+Xwr6gRXsBqtBPm84sJRHYkM2 uarlTvBRwe0lauq9H+g9B1zouA== X-Received: by 10.28.224.4 with SMTP id x4mr1288856wmg.118.1512656845491; Thu, 07 Dec 2017 06:27:25 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id t138sm6264520wme.16.2017.12.07.06.27.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Dec 2017 06:27:24 -0800 (PST) From: Jerome Brunet To: Andrew Lunn , Florian Fainelli Cc: Jerome Brunet , Kevin Hilman , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 7/8] net: phy: meson-gxl: add interrupt support Date: Thu, 7 Dec 2017 15:27:14 +0100 Message-Id: <20171207142715.32578-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171207142715.32578-1-jbrunet@baylibre.com> References: <20171207142715.32578-1-jbrunet@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable interrupt support in meson-gxl PHY driver Signed-off-by: Jerome Brunet --- drivers/net/phy/meson-gxl.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) -- 2.14.3 diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index 5325940fe899..861b021b9758 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c @@ -33,6 +33,14 @@ #define TSTCNTL_WRITE_ADDRESS GENMASK(4, 0) #define TSTREAD1 21 #define TSTWRITE 23 +#define INTSRC_FLAG 29 +#define INTSRC_ANEG_PR BIT(1) +#define INTSRC_PARALLEL_FAULT BIT(2) +#define INTSRC_ANEG_LP_ACK BIT(3) +#define INTSRC_LINK_DOWN BIT(4) +#define INTSRC_REMOTE_FAULT BIT(5) +#define INTSRC_ANEG_COMPLETE BIT(6) +#define INTSRC_MASK 30 #define BANK_ANALOG_DSP 0 #define BANK_WOL 1 @@ -193,17 +201,44 @@ int meson_gxl_read_status(struct phy_device *phydev) return genphy_read_status(phydev); } +static int meson_gxl_ack_interrupt(struct phy_device *phydev) +{ + int ret = phy_read(phydev, INTSRC_FLAG); + + return ret < 0 ? ret : 0; +} + +static int meson_gxl_config_intr(struct phy_device *phydev) +{ + u16 val; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + val = INTSRC_ANEG_PR + | INTSRC_PARALLEL_FAULT + | INTSRC_ANEG_LP_ACK + | INTSRC_LINK_DOWN + | INTSRC_REMOTE_FAULT + | INTSRC_ANEG_COMPLETE; + } else { + val = 0; + } + + return phy_write(phydev, INTSRC_MASK, val); +} + 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, + .flags = PHY_IS_INTERNAL | PHY_HAS_INTERRUPT, .config_init = meson_gxl_config_init, .config_aneg = genphy_config_aneg, .aneg_done = genphy_aneg_done, .read_status = meson_gxl_read_status, + .ack_interrupt = meson_gxl_ack_interrupt, + .config_intr = meson_gxl_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, },