From patchwork Fri Aug 11 16:44:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuiko Oshino X-Patchwork-Id: 800647 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xTW9v057Jz9t2Z for ; Sat, 12 Aug 2017 02:46:42 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A7714C21DAC; Fri, 11 Aug 2017 16:46:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 20767C21C8B; Fri, 11 Aug 2017 16:46:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BF402C21C97; Fri, 11 Aug 2017 16:46:33 +0000 (UTC) Received: from esa5.microchip.iphmx.com (esa5.microchip.iphmx.com [216.71.150.166]) by lists.denx.de (Postfix) with ESMTPS id C0DF0C21C26 for ; Fri, 11 Aug 2017 16:46:32 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.41,358,1498546800"; d="scan'208";a="3777784" 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; 11 Aug 2017 09:46:31 -0700 Received: from localhost.localdomain (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Fri, 11 Aug 2017 09:46:30 -0700 From: To: Date: Fri, 11 Aug 2017 12:44:57 -0400 Message-ID: <1502469898-994-1-git-send-email-yuiko.oshino@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v4 1/2] net: Add mii_resolve_flowctrl_fdx() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Yuiko Oshino Add support for Microchip LAN7500, LAN7800 and LAN7850, USB to 10/100/1000 Ethernet Controllers. Signed-off-by: Yuiko Oshino Acked-by: Joe Hershberger --- Changes in v4: - none. Changes in v3: - This patch is added to a series. Changes in v2: - The patch's tag is changed to net:. include/linux/mii.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/mii.h b/include/linux/mii.h index 66b83d8..19afb74 100644 --- a/include/linux/mii.h +++ b/include/linux/mii.h @@ -190,4 +190,27 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock, return 0; } +/** + * mii_resolve_flowctrl_fdx + * @lcladv: value of MII ADVERTISE register + * @rmtadv: value of MII LPA register + * + * Resolve full duplex flow control as per IEEE 802.3-2005 table 28B-3 + */ +static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv) +{ + u8 cap = 0; + + if (lcladv & rmtadv & ADVERTISE_PAUSE_CAP) { + cap = FLOW_CTRL_TX | FLOW_CTRL_RX; + } else if (lcladv & rmtadv & ADVERTISE_PAUSE_ASYM) { + if (lcladv & ADVERTISE_PAUSE_CAP) + cap = FLOW_CTRL_RX; + else if (rmtadv & ADVERTISE_PAUSE_CAP) + cap = FLOW_CTRL_TX; + } + + return cap; +} + #endif /* __LINUX_MII_H__ */