Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2286215rwb; Thu, 8 Dec 2022 23:31:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4+6m2xqjox5VNlRRc5h++wMKMZXmiLLQYddDyGKRXXucK/K0/TrEvY6u+kc06PMJxTFNtJ X-Received: by 2002:a05:6a21:3d0c:b0:ac:ba82:f6ab with SMTP id bi12-20020a056a213d0c00b000acba82f6abmr6901650pzc.33.1670571065207; Thu, 08 Dec 2022 23:31:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670571065; cv=none; d=google.com; s=arc-20160816; b=NpBkRMXMoYxt19KYh4d1gQFKLikjufORtIJuDr/XjisX3UDTAcm9FM9M1N8Uk7akHJ armsXgLMXyrbNGqp7pqcAmf5yEDBkhretOv4ayOCZovBrLHykYTYZIbvcRZwB10sCtgx z0tTLeZNlYxiQj2xUmzYNxxKT0JVAh0o+HoRQ0PPcPZTBOtQR1jFPUfKwBHVYOlK+b15 voMf6VJzszPe8wdQs22zpuZ9Hk4d6ZtWypO/vw0V2gP3sU4h14h7btdwjrXA7McXuGzF CpcpT7AzlOeDiaGPZ+SJ4+rR9daykxcmX0P3QLc106A/wbvRIUlPRwrLJtjY8d6XK5rc 9igw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E/gAYyDtMcHAFfmldcj8ULLhn/wG2hwgT+LDRRxFdq0=; b=A1SVV2cpG4tMornDJdZarBwzqBN3oAQJlOlLKrOOakYgphJ2pNVE2XXBG/z/ErxQ+o RXwXYSUzFBCerldwGYHtHP4AnB/HLGPfRs4guiSTEi1E/6TnGRVZe0voupTGMUy7xXAn KoWsvmVaeN/WEVBaZwHg9hOpPZShAjDJJ90N/bSAPT84jE14SaeeReXG4HenBKIQ379L PZfx7s/zOM0ntOyH9Fj2fSuf1lj8Nteu4VlLtTbPB+Zi4pQcqC80Bo6AsnmiQJJC1P7a ZCPipmMusIrDCFU50qxeB4xoiPYC0tLsNz24cI6d0hm1S/0CKFU3IAaRqklCoov5JUcm hyvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zMGGKyDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a635641000000b00439f026cf5dsi806994pgm.612.2022.12.08.23.30.55; Thu, 08 Dec 2022 23:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zMGGKyDH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230224AbiLIH2P (ORCPT + 74 others); Fri, 9 Dec 2022 02:28:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiLIH1T (ORCPT ); Fri, 9 Dec 2022 02:27:19 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9097F40454; Thu, 8 Dec 2022 23:27:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1670570824; x=1702106824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kVJXGUEL1IK7sv2durqWviWr/jhrNhCEOoQFcMo4sd8=; b=zMGGKyDHLuozSUdwYc7i9ahWTw/xU5Efu7hKXshU7aX0DVwflU0pz1Wz WzLt4MPz16THpZ0XXbNBwaMOD0353nYV26UYcz7ALn/NaYvLCrbVQqugG 2js8GUeF8mYD824chs5Ev82SuxHECC7FTvjNXeWl3RxozsB1IIANK+GK3 spa6XGNAxLEQTRMy/qq4Ynu/7Gjy/adlGGq9EKjCmXDMB+Cuvat3KeS+w byUDItCp3OzC3tixR+mWW6PtL7rRb9BlJp4xRChLBkGBI7Cy4zMML+MIO +u78Z22a/CT/kaHP3CHFqN9RUk1PKHA5PWtfAmSjlVRckLRHTdyWQaEcL A==; X-IronPort-AV: E=Sophos;i="5.96,230,1665471600"; d="scan'208";a="127292958" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 09 Dec 2022 00:27:03 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 9 Dec 2022 00:27:03 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 9 Dec 2022 00:26:57 -0700 From: Arun Ramadoss To: , CC: , , , , , , , , , , , , , Subject: [Patch net-next v3 13/13] net: dsa: microchip: ptp: lan937x: Enable periodic output in LED pins Date: Fri, 9 Dec 2022 12:54:37 +0530 Message-ID: <20221209072437.18373-14-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221209072437.18373-1-arun.ramadoss@microchip.com> References: <20221209072437.18373-1-arun.ramadoss@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is difference in implementation of per_out pins between KSZ9563 and LAN937x. In KSZ9563, Timestamping control register (0x052C) bit 6, if 1 - timestamp input and 0 - trigger output. But it is opposite for LAN937x 1 - trigger output and 0 - timestamp input. As per per_out gpio pins, KSZ9563 has four Led pins and two dedicated gpio pins. But in LAN937x dedicated gpio pins are removed instead there are up to 10 LED pins out of which LED_0 and LED_1 can be mapped to PTP tou 0, 1 or 2. This patch sets the bit 6 in 0x052C register and configure the LED override and source register for LAN937x series of switches alone. Signed-off-by: Arun Ramadoss --- drivers/net/dsa/microchip/ksz_ptp.c | 26 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ptp_reg.h | 8 ++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c index ccb635585721..99aae649c4a7 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -33,6 +33,28 @@ static int _ksz_ptp_gettime(struct ksz_device *dev, struct timespec64 *ts); +static int ksz_ptp_tou_gpio(struct ksz_device *dev) +{ + int ret; + + if (!is_lan937x(dev)) + return 0; + + ret = ksz_rmw32(dev, REG_PTP_CTRL_STAT__4, GPIO_OUT, + GPIO_OUT); + if (ret) + return ret; + + ret = ksz_rmw32(dev, REG_SW_GLOBAL_LED_OVR__4, LED_OVR_1 | LED_OVR_2, + LED_OVR_1 | LED_OVR_2); + if (ret) + return ret; + + return ksz_rmw32(dev, REG_SW_GLOBAL_LED_SRC__4, + LED_SRC_PTP_GPIO_1 | LED_SRC_PTP_GPIO_2, + LED_SRC_PTP_GPIO_1 | LED_SRC_PTP_GPIO_2); +} + static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit) { u32 data; @@ -229,6 +251,10 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev, if (ret) return ret; + ret = ksz_ptp_tou_gpio(dev); + if (ret) + return ret; + ret = ksz_ptp_tou_start(dev, request->index); if (ret) return ret; diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/microchip/ksz_ptp_reg.h index dbccfedf89e4..6fea39629460 100644 --- a/drivers/net/dsa/microchip/ksz_ptp_reg.h +++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h @@ -6,6 +6,14 @@ #ifndef __KSZ_PTP_REGS_H #define __KSZ_PTP_REGS_H +#define REG_SW_GLOBAL_LED_OVR__4 0x0120 +#define LED_OVR_2 BIT(1) +#define LED_OVR_1 BIT(0) + +#define REG_SW_GLOBAL_LED_SRC__4 0x0128 +#define LED_SRC_PTP_GPIO_1 BIT(3) +#define LED_SRC_PTP_GPIO_2 BIT(2) + /* 5 - PTP Clock */ #define REG_PTP_CLK_CTRL 0x0500 -- 2.36.1