Received: by 10.192.165.156 with SMTP id m28csp1992053imm; Thu, 12 Apr 2018 06:59:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx49yu3uvB1+ZRqIXoAUJCOnSytDwdh/+PJDlSg3f9EPZslsEvsuN3BVGwjm9bEr5gzm0SHtR X-Received: by 10.167.134.80 with SMTP id a16mr7821991pfo.172.1523541599608; Thu, 12 Apr 2018 06:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523541599; cv=none; d=google.com; s=arc-20160816; b=ZW/q/Htc7phDFJJlqMFUhmshqbcBob7X97dMq/tsRuAXEIAfDZP9FlCSBLON+eZ5hq ud6V3Ip4D7uoYDQ2RjL3gTZEUvIoFSiOWkqkjPEuL4p3j2Wicpz6GPwvwk6n3ZeyHQTV pC/sGaPeYt2DBlElfo1N0M/zcBjx8u7W9oKWX7DxBYqeIB0AaEqakbGU8n9CCr7oXENO mQXp0Io9J1VRXDSWMt1sNzFwuF/9RPGbN/YMBou+E2zCb4DNa8B54F6j2lZxa9uMiTZG sP20cKHPXFCZqyNu5rhBOjZjQ9cp+C8uY3+M8k17A3g9uiizgbATdSP1wPwkojf1aoeQ /2FQ== 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:dkim-signature :arc-authentication-results; bh=LWrWcwQ52N4eZD1lfkI9z9h5z7Apg2Hn/EBDf/PvPL4=; b=KAXSW3svZr/7sq3tpb9wyJLffc51DvHVVgnZPK+uEzCODcam/VaNvLfO4caQyCf5fJ 28djxLuPz2g5xqNKbRNgO7T+DG61/SudggJJOYFg+IxguCR+1RNQR187R8iZn9I8WDop wCjbagXp3mlWZMoAxFtd4WR8ImbhMK3PxqA3/qpm2N6oVfhrfdC8Op8hH9W7DpqHVcus AXrZWwlVLIIPtwyERmjTSQPvmvcHtFGHjb9PCq63iFavYo1ZDDVhqkpbsHah9bomNc6i nJHb8rzYNFqvu/PTeVTbbNLInYqzopmGgVOgGHFHG5o+UXyBJZ4V4ZTS6tQSbLqd9hPD ZiJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@raspberrypi.org header.s=pp header.b=Upghw51M; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=DEQPuLVL; 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 a25si2691613pfc.409.2018.04.12.06.59.22; Thu, 12 Apr 2018 06:59:59 -0700 (PDT) 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=fail header.i=@raspberrypi.org header.s=pp header.b=Upghw51M; dkim=pass header.i=@raspberrypi-org.20150623.gappssmtp.com header.s=20150623 header.b=DEQPuLVL; 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 S1752866AbeDLNz5 (ORCPT + 99 others); Thu, 12 Apr 2018 09:55:57 -0400 Received: from mx08-00252a01.pphosted.com ([91.207.212.211]:40370 "EHLO mx08-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752396AbeDLNzx (ORCPT ); Thu, 12 Apr 2018 09:55:53 -0400 Received: from pps.filterd (m0102629.ppops.net [127.0.0.1]) by mx08-00252a01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3CDrvOu012325 for ; Thu, 12 Apr 2018 14:55:52 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pp; bh=LWrWcwQ52N4eZD1lfkI9z9h5z7Apg2Hn/EBDf/PvPL4=; b=Upghw51MCDhRH7E0xJXnUpgjSdWEbOPoUAGPoXBOA30vzOjPRLWzCj0JX/x/XBE9Ktpg 7MPFENh5CK7AroKUQsWEG29VyoM6/2G/MQ0JycF2lt0UBX/T+MJDcUSwO7zjws3aFOSz mwQzpKetnxWRysbigmFCtsrdd8s+IDeVUNLbXo5K7kEaf0lUc6To1izsuQAgHvDPjDRj BB53QC0U9ROWw4VdDI7FanERBmgHlWwrFk7glRKAbCESj5dlC3XArYv3tOpanXT3sAue eIeTYWtRRAtjgrXzTR8EjpFS3RtXmC4oEBp3jlUE4vQBf2U/glEq+qn1KHPcRKm+9Kbf 7w== Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by mx08-00252a01.pphosted.com with ESMTP id 2h6trdtjs2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Thu, 12 Apr 2018 14:55:52 +0100 Received: by mail-wm0-f72.google.com with SMTP id m77so2812824wma.4 for ; Thu, 12 Apr 2018 06:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LWrWcwQ52N4eZD1lfkI9z9h5z7Apg2Hn/EBDf/PvPL4=; b=DEQPuLVLxo2n+tkWtG5oKrf++tS0VhDRyF9PoP6/nSydWzJrVDWPR0Tf5INFwDb91R 3jzWZa67O4Rm6ibrjNJkvFFOyRd16RHtcbXvS3+ujOT9WqGO/0smr5Wm11GGpSGFVM4m DgNZCt5VwF06l7nuVA5+WQcMjp62aqX9xnh/5wrqo2sYe/AR6W6AHAkWn2Xr++s6+C3P BoS6vJZ+3LIU77cOjTSSU2S+HfefDl3EwpAD33q3OqWTH1x9YEMKjXCisLTrMNA+zui2 NfPIr3lZygb3KhvF9t9K2mOxnwe9pPDyxLaSv0+9b8AXH9FXi57YXnMVFIBUvPAE8XtO IUxQ== 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=LWrWcwQ52N4eZD1lfkI9z9h5z7Apg2Hn/EBDf/PvPL4=; b=Kv3oHbuEkKaMgm9vaITr7WkivtjwYvI6N4znzdSkqL04NpXsPXZJ6cZlk37TYaMtfv kDLf1Dr058jlOdEubqfCmv5NDreWu7F0gq/6U6kt7OCXf5igAwJ/ZhkfY4K84TCuPC1h iiciAEDQLY2COtkUafLy8MBaQmxKf3dEtue6ZCJEDvcThFKWdKR/SOFU19T6EO2P8FOS LvypsEmrygh9Jjj4zNviDnA47KccSp8VA9CeJsUwPu29LFTt86j9mPBrUiO+cZ4f4Ys0 gWJCI3RzAvmjPSDKVFpoTBPTEbTMdZkwBmidepXJDHY0jXvk4NvaXOCjcdFeq1YEl0dN 1o+A== X-Gm-Message-State: ALQs6tBe+dpBXC0UXMwsMhXQSK99RTkFHkrKjo8xyjkCrmNTq1AFQSn5 sk7huX6D/4R/lF5mQDyGrDX8WWtmz9RYq3udH7r6sBg+emn7TxsqVYCfReyqb8c47sIOsHh1ZcT nLAqy0mSI/BRNC37zCq8QGbv6 X-Received: by 10.28.136.199 with SMTP id k190mr858470wmd.154.1523541351646; Thu, 12 Apr 2018 06:55:51 -0700 (PDT) X-Received: by 10.28.136.199 with SMTP id k190mr858460wmd.154.1523541351464; Thu, 12 Apr 2018 06:55:51 -0700 (PDT) Received: from buildbot.pitowers.org ([2a00:2381:fdf7:14:3403:8ea9:e6c1:e3f5]) by smtp.gmail.com with ESMTPSA id m83sm3491581wma.17.2018.04.12.06.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 06:55:50 -0700 (PDT) From: Phil Elwell To: Woojung Huh , Microchip Linux Driver Support , Rob Herring , Mark Rutland , "David S. Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linus Walleij , Andrew Morton , Randy Dunlap , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Phil Elwell Subject: [PATCH 3/4] lan78xx: Read LED modes from Device Tree Date: Thu, 12 Apr 2018 14:55:35 +0100 Message-Id: <1523541336-145953-4-git-send-email-phil@raspberrypi.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523541336-145953-1-git-send-email-phil@raspberrypi.org> References: <1523541336-145953-1-git-send-email-phil@raspberrypi.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-12_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for DT property "microchip,led-modes", a vector of two cells (u32s) in the range 0-15, each of which sets the mode for one of the two LEDs. Some possible values are: 0=link/activity 1=link1000/activity 2=link100/activity 3=link10/activity 4=link100/1000/activity 5=link10/1000/activity 6=link10/100/activity 14=off 15=on Also use the presence of the DT property to indicate that the LEDs should be enabled - necessary in the event that no valid OTP or EEPROM is available. Signed-off-by: Phil Elwell --- drivers/net/usb/lan78xx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index d98397b..ffb483d 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2008,6 +2008,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) { int ret; u32 mii_adv; + u32 led_modes[2]; struct phy_device *phydev; phydev = phy_find_first(dev->mdiobus); @@ -2097,6 +2098,25 @@ static int lan78xx_phy_init(struct lan78xx_net *dev) (void)lan78xx_set_eee(dev->net, &edata); } + if (!of_property_read_u32_array(dev->udev->dev.of_node, + "microchip,led-modes", + led_modes, ARRAY_SIZE(led_modes))) { + u32 reg; + int i; + + reg = phy_read(phydev, 0x1d); + for (i = 0; i < ARRAY_SIZE(led_modes); i++) { + reg &= ~(0xf << (i * 4)); + reg |= (led_modes[i] & 0xf) << (i * 4); + } + (void)phy_write(phydev, 0x1d, reg); + + /* Ensure the LEDs are enabled */ + lan78xx_read_reg(dev, HW_CFG, ®); + reg |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_; + lan78xx_write_reg(dev, HW_CFG, reg); + } + genphy_config_aneg(phydev); dev->fc_autoneg = phydev->autoneg; -- 2.7.4