From patchwork Wed May 11 14:25:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Min Li X-Patchwork-Id: 12846233 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADCCFC433F5 for ; Wed, 11 May 2022 14:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244667AbiEKOZs (ORCPT ); Wed, 11 May 2022 10:25:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244585AbiEKOZf (ORCPT ); Wed, 11 May 2022 10:25:35 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2112.outbound.protection.outlook.com [40.107.114.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8519C68319; Wed, 11 May 2022 07:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=imZ8DLnN1CRT9X5plEvgA2pMv1RB1mgw26fSsXmKqR7OFuxeWxkGzjVyDp2HTQUNUEuDoo9nlgjUIL7hPQ8S47b8ysguzFO3YpvNfHunNW+GnEUMF/hRBNUt+rTOLEzKxV/FXHGITrgN/v+nAEGS0axOQmQR5Xn1yFpTRNJqmXXkG2xLBG0YOOZUwwKZPl2hTKa3R/+bJ1SmZ6VB83wG3VWLOtviMoWi5W+ZLoYHjnSB8tCDleqV/jSxvEm5ObOYT/1T7Km+UEGs7ilqnHc1SrTxL4SdqROYXBFLqJUgHrPdwHs+TIxXy1q7atM0P62QH2FHkuPwUze3NThK1FsV8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6UDTKeE5YHpaqiX+IT9Fc2liMQqo1AJQpWWX51vDjuA=; b=d+/WnsPqQL7fP0h+hn1DaPouNQCe0aM6npZvDDBoc6i7ICp8EvRUzOhz3HZAzklRLESnLt/6ip08CjR/+cswmnRKltqlSN+vabbEfKcxy3bAiHENkJXlPhy6qjKrKWKdBwv9c/AFP/+qCMgCKEtFfjalV7SIBuPHisyBnHckU0WPqpZOf+7IljpiVoQYR3dJj6o0XveR60KUBf0ZTenANuUPqYmg/7YlwmqB92DANWdc2PXT/gyM3Tger2qMjQlAnjSw4YEzPhTfuXmWvjbiU6heXsz/552jbbQRNsB7naTlbTLxkruD6nHG2+mJ2UWI9hMkyMgOu4io4dtHDZcIbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6UDTKeE5YHpaqiX+IT9Fc2liMQqo1AJQpWWX51vDjuA=; b=RhEE0jFWAG861LI5PBwWDCdwqp0m3jGdcSYn2PXm79zg84a2GZRLD+Uto49TCxTcXwVkUPXI//EmCqnPhgKdlCllIXOSQw8y4ChB0EDLiZNQi62vAL3Ndbj9PbrZlCRkqCWEEyLzv0FXen6ZX2hJTb1ZgUVX7AoX43+/Ztk0Fts= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) by OSAPR01MB4850.jpnprd01.prod.outlook.com (2603:1096:604:69::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 14:25:30 +0000 Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663]) by OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663%9]) with mapi id 15.20.5250.013; Wed, 11 May 2022 14:25:30 +0000 From: Min Li To: richardcochran@gmail.com, lee.jones@linaro.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Min Li Subject: [PATCH net v5 1/3] ptp: ptp_clockmatrix: Add PTP_CLK_REQ_EXTTS support Date: Wed, 11 May 2022 10:25:12 -0400 Message-Id: <1652279114-25939-1-git-send-email-min.li.xe@renesas.com> X-Mailer: git-send-email 2.7.4 X-ClientProxiedBy: BN9PR03CA0203.namprd03.prod.outlook.com (2603:10b6:408:f9::28) To OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f70cf68-f5f9-4449-7c28-08da335a1a11 X-MS-TrafficTypeDiagnostic: OSAPR01MB4850:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YTmUkcoAFoFMls4Y9ByrZn4UTYO58o9t8Yg8yM4dpYT0hNxi5Fp/X06jMmKyzAfJCC9KQNumT/niuVqvEhNbDcceLEcOrexj3mHuAP/tkyB/Phcxr/JTlxjTCikVO+vC4hkcgXg7ZcpXXdqwcft6vWwHPRxu8VwrDLSCPIDYr/KKygW4xmzGtdJ272/HLZSOyd+cuvptWBSljfjCY/66qneLFVnUsUxbA5eDmcHF3gF1yTGhaHiM+n5v4VrBN5UREuMLUFcfm4fW+FSrfYCoZZXihg+ZffOLCF3N7l6brFahfCWWaefTqZZykuBBbtUjMiJRYWdO7THDIzApVcOcAB/WL2ysoC1twgZ5iiMQBnDNZQyvgd2DW4yWBWsscd10GP/k45Z8YOqelC74HJStGijzOke+AwOMtoydP5UUXsNwJQp6dN7k9WiMR39XgRGKLGN0DTjQk25Z7XGf7WRiOhHba7Tetpw3t7EZX1zP8mLBkqcRxodoPoaDxIdS5Qg3ax4ekpmGcKg3a4lZiGS6gIM8l4LEIoaOoDODgSZGcvk1LJenKmcfJLOX8NXzvUpz2ruXgWwhA2PIOUcE67+YSJ4fF1Kqx+bYyCVijOc2StE7FFoA2DPAp6zSJM3Rgmip1YLaww4E58v0LggIkXHWoreY/6EJbHLph02FWoh3kmbc0e+E1aaYEIBDUJF8fT7wGcumauc5KkR1Tj/kAzqgLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB6593.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(30864003)(107886003)(508600001)(6512007)(26005)(6506007)(186003)(52116002)(316002)(86362001)(6666004)(2906002)(5660300002)(83380400001)(36756003)(2616005)(4326008)(8676002)(66476007)(66946007)(66556008)(38100700002)(38350700002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9enZPBT/N/XQU69ARoAIpsytFgqXVDpnyHYEDSvBhQvfNSZ7DTdzP7lYp7msQ1SLBW1VzHFHCPWfj54MmdVloQW/RUuQrSB2JHUHaR3KqUciDdXYz9Osz7f7f3U28/k2qEr3SnOCVDd+jRkE2JPsOaeFr3BIzzzTiYpJkHLvyxBrDplMYp5weEheAstDTc7+gk5482DTET2tV5O1Xo8TfzRdayoHGOfFJllDaXijcH/zPQxNEBn5FKG8DW8eNP6eK5oDuBoSD1C2rBeHSY89slO1Sra31pUs+IbWq2PnCBgHSIpsLWRjOo7dWv83Ykrqv3hgkw+jB7K9FjnIhCy3rZHGZxeg2WvQMP9Ri6A8Bm0Bm6k5XKr6EtHyvHGZAHQRz4PZauYd/oHYEG2cILQUPR2y548zFFkAJx7lBm57f6xuXDe7T1dO/Q/dZCDL/GgMBUVgE77hCOqQpG9zCXlpnUvRq3Nid4NCOfn7X5IhwZOBTYWn2KqZkSzyPuzyMq78nB46ZbQTJxMW5rPufQD9WEVJO0kJ3anmsYcgUyjSk3OW9jS3fFbCyijDoqGZRiXS2ZwnxV0nkWUuN7xQUEytMNwTqfFhu6uDagrPzK8cCn1ONC5h8dSrFJtzF/y0pS3mVhNimE0pBGUcMwMrxvsRfqItHTSzWapzS7OeIfrFLxpJFcMpjMuBunQfMq5/bqmtl37ScMXzRfsqCpK/7/hYJSacsI7qUfV3DNrr2DJJ2pkQsZyqNSWZUfHjrsW1PdNHJoWI246f59nRe9zTGiaIARemlB35m5zBa5Xb6GvLwqeeXURqMFpdb/io2CFO66qaW0nqNm79y51TXqAFaasJjWP+LmnFwupDBot2RPiGHhcBEm8/zso+oy+4fR/ez4amCw3HgS9LFJE1mfREUQ7rIfTcC0uO1LwXhj6Oh0L3rQRVSTplLz+2/xXJ4CQ9JXyMgNmNhymgGkfZcm2NrEM6N9iuig2bE8dXVYQ7hvkPwl0KdiohTXK/+PfzBGdgDP7rDWyjFnnmWIyoMy3DFZkXg8qi908Wqmfa5TEI03CeL+dKugUdPxfCy5p09Qadwrw6x4Zs6AqrjyzKS1aNk869BdON40O82CLxTKBbTh5y3kw9So3TBN2MuOHKkV6Wofw2+0QzeV3sWNPfWmwzPF2UHhSVtE22rxwF3ESHXMgZ0eavAbpNcRLYFZzGMOcOKOqABxWqMMr+DJri9mH9w4r3VsUbpUsUPfd2tmHrQ8WF72sh8QM4Uj9XJMDZ8H5ueq0vFxrngHbJ1agbSHZ6HZQcb3xvkIpQNiM1N4az+DmER8Z+y2U94AmkR4ZoNGuOXAu+mEfcB09jREuTthdsU+ip6lFKIVwpLgW31R0LE137blEd1e18btyk41rFD8fbbu/u6IUrK/rDbEyQjJEdBOMVrwyKJzb6ArI9NLCGMuZ8B4Ahqm1VpoW0rm2NYK5muBI4ylzuMUqqsWdkzs3gCCHqILtJXczpdRspThlOSmXFE8XIE8PhpwtPTyt8s1HIwz3DiTilh8xefSdjiAlV0AC6vZd9xhCca5b5es6amdIyIfAILewJeZ3lYEzq5jTqFij0CasbsD8UO6m0Vm7yI99BB/ZS59lsT9NFtjgSVYMLBkD++Is7ADtN99k0RQaFNwE6osqszReNaTAapMptW1vsbtj2fTYa/0qmtLR0tdK3w3AJis4BwL7R9qrXlBxeopB0LmchzCtc6c8HXrBursv71T8DFiLhSg4fng5UPGw6e3k= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f70cf68-f5f9-4449-7c28-08da335a1a11 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB6593.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 14:25:30.6441 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8RkZzElh7O3SMdj1B4okQ2qPAACMhP2Wc8pjNmHzLXvSYOGRC9Qtm061gCZ3M0/fZaVo1rUeS2wJrw3mXgBEug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSAPR01MB4850 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use TOD_READ_SECONDARY for extts to keep TOD_READ_PRIMARY for gettime and settime exclusively. Before this change, TOD_READ_PRIMARY was used for both extts and gettime/settime, which would result in changing TOD read/write triggers between operations. Using TOD_READ_SECONDARY would make extts independent of gettime/settime operation Signed-off-by: Min Li Acked-by: Richard Cochran --- -use div helpers to do 64b division -change comments to comply with kernel-doc format -Fix Jakub comments drivers/ptp/ptp_clockmatrix.c | 292 +++++++++++++++++++++++++-------------- drivers/ptp/ptp_clockmatrix.h | 5 + include/linux/mfd/idt8a340_reg.h | 12 +- 3 files changed, 203 insertions(+), 106 deletions(-) diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c index 08e429a..aaff5cd 100644 --- a/drivers/ptp/ptp_clockmatrix.c +++ b/drivers/ptp/ptp_clockmatrix.c @@ -239,73 +239,101 @@ static int wait_for_boot_status_ready(struct idtcm *idtcm) return -EBUSY; } -static int _idtcm_set_scsr_read_trig(struct idtcm_channel *channel, - enum scsr_read_trig_sel trig, u8 ref) +static int arm_tod_read_trig_sel_refclk(struct idtcm_channel *channel, u8 ref) { struct idtcm *idtcm = channel->idtcm; - u16 tod_read_cmd = IDTCM_FW_REG(idtcm->fw_ver, V520, TOD_READ_PRIMARY_CMD); - u8 val; + u16 tod_read_cmd = IDTCM_FW_REG(idtcm->fw_ver, V520, TOD_READ_SECONDARY_CMD); + u8 val = 0; int err; - if (trig == SCSR_TOD_READ_TRIG_SEL_REFCLK) { - err = idtcm_read(idtcm, channel->tod_read_primary, - TOD_READ_PRIMARY_SEL_CFG_0, &val, sizeof(val)); - if (err) - return err; - - val &= ~(WR_REF_INDEX_MASK << WR_REF_INDEX_SHIFT); - val |= (ref << WR_REF_INDEX_SHIFT); - - err = idtcm_write(idtcm, channel->tod_read_primary, - TOD_READ_PRIMARY_SEL_CFG_0, &val, sizeof(val)); - if (err) - return err; - } + val &= ~(WR_REF_INDEX_MASK << WR_REF_INDEX_SHIFT); + val |= (ref << WR_REF_INDEX_SHIFT); - err = idtcm_read(idtcm, channel->tod_read_primary, - tod_read_cmd, &val, sizeof(val)); + err = idtcm_write(idtcm, channel->tod_read_secondary, + TOD_READ_SECONDARY_SEL_CFG_0, &val, sizeof(val)); if (err) return err; - val &= ~(TOD_READ_TRIGGER_MASK << TOD_READ_TRIGGER_SHIFT); - val |= (trig << TOD_READ_TRIGGER_SHIFT); - val &= ~TOD_READ_TRIGGER_MODE; /* single shot */ + val = 0 | (SCSR_TOD_READ_TRIG_SEL_REFCLK << TOD_READ_TRIGGER_SHIFT); + + err = idtcm_write(idtcm, channel->tod_read_secondary, tod_read_cmd, + &val, sizeof(val)); + + if (err) + dev_err(idtcm->dev, "%s: err = %d", __func__, err); - err = idtcm_write(idtcm, channel->tod_read_primary, - tod_read_cmd, &val, sizeof(val)); return err; } -static int idtcm_enable_extts(struct idtcm_channel *channel, u8 todn, u8 ref, - bool enable) +static bool is_single_shot(u8 mask) { - struct idtcm *idtcm = channel->idtcm; - u8 old_mask = idtcm->extts_mask; - u8 mask = 1 << todn; + /* Treat single bit ToD masks as continuous trigger */ + if ((mask == 1) || (mask == 2) || (mask == 4) || (mask == 8)) + return false; + else + return true; +} + +static int idtcm_extts_enable(struct idtcm_channel *channel, + struct ptp_clock_request *rq, int on) +{ + u8 index = rq->extts.index; + struct idtcm *idtcm; + u8 mask = 1 << index; int err = 0; + u8 old_mask; + int ref; + + idtcm = channel->idtcm; + old_mask = idtcm->extts_mask; + + /* Reject requests with unsupported flags */ + if (rq->extts.flags & ~(PTP_ENABLE_FEATURE | + PTP_RISING_EDGE | + PTP_FALLING_EDGE | + PTP_STRICT_FLAGS)) + return -EOPNOTSUPP; + + /* Reject requests to enable time stamping on falling edge */ + if ((rq->extts.flags & PTP_ENABLE_FEATURE) && + (rq->extts.flags & PTP_FALLING_EDGE)) + return -EOPNOTSUPP; - if (todn >= MAX_TOD) + if (index >= MAX_TOD) return -EINVAL; - if (enable) { - if (ref > 0xF) /* E_REF_CLK15 */ - return -EINVAL; - if (idtcm->extts_mask & mask) - return 0; - err = _idtcm_set_scsr_read_trig(&idtcm->channel[todn], - SCSR_TOD_READ_TRIG_SEL_REFCLK, - ref); + if (on) { + /* Support triggering more than one TOD_0/1/2/3 by same pin */ + /* Use the pin configured for the channel */ + ref = ptp_find_pin(channel->ptp_clock, PTP_PF_EXTTS, channel->tod); + + if (ref < 0) { + dev_err(idtcm->dev, "%s: No valid pin found for TOD%d!\n", + __func__, channel->tod); + return -EBUSY; + } + + err = arm_tod_read_trig_sel_refclk(&idtcm->channel[index], ref); + if (err == 0) { idtcm->extts_mask |= mask; - idtcm->event_channel[todn] = channel; - idtcm->channel[todn].refn = ref; + idtcm->event_channel[index] = channel; + idtcm->channel[index].refn = ref; + idtcm->extts_single_shot = is_single_shot(idtcm->extts_mask); + + if (old_mask) + return 0; + + schedule_delayed_work(&idtcm->extts_work, + msecs_to_jiffies(EXTTS_PERIOD_MS)); } - } else + } else { idtcm->extts_mask &= ~mask; + idtcm->extts_single_shot = is_single_shot(idtcm->extts_mask); - if (old_mask == 0 && idtcm->extts_mask) - schedule_delayed_work(&idtcm->extts_work, - msecs_to_jiffies(EXTTS_PERIOD_MS)); + if (idtcm->extts_mask == 0) + cancel_delayed_work(&idtcm->extts_work); + } return err; } @@ -371,6 +399,34 @@ static void wait_for_chip_ready(struct idtcm *idtcm) "Continuing while SYS APLL/DPLL is not locked"); } +static int _idtcm_gettime_triggered(struct idtcm_channel *channel, + struct timespec64 *ts) +{ + struct idtcm *idtcm = channel->idtcm; + u16 tod_read_cmd = IDTCM_FW_REG(idtcm->fw_ver, V520, TOD_READ_SECONDARY_CMD); + u8 buf[TOD_BYTE_COUNT]; + u8 trigger; + int err; + + err = idtcm_read(idtcm, channel->tod_read_secondary, + tod_read_cmd, &trigger, sizeof(trigger)); + if (err) + return err; + + if (trigger & TOD_READ_TRIGGER_MASK) + return -EBUSY; + + err = idtcm_read(idtcm, channel->tod_read_secondary, + TOD_READ_SECONDARY_BASE, buf, sizeof(buf)); + + if (err) + return err; + + err = char_array_to_timespec(buf, sizeof(buf), ts); + + return err; +} + static int _idtcm_gettime(struct idtcm_channel *channel, struct timespec64 *ts, u8 timeout) { @@ -396,7 +452,7 @@ static int _idtcm_gettime(struct idtcm_channel *channel, } while (trigger & TOD_READ_TRIGGER_MASK); err = idtcm_read(idtcm, channel->tod_read_primary, - TOD_READ_PRIMARY, buf, sizeof(buf)); + TOD_READ_PRIMARY_BASE, buf, sizeof(buf)); if (err) return err; @@ -415,65 +471,40 @@ static int idtcm_extts_check_channel(struct idtcm *idtcm, u8 todn) extts_channel = &idtcm->channel[todn]; ptp_channel = idtcm->event_channel[todn]; + if (extts_channel == ptp_channel) dco_delay = ptp_channel->dco_delay; - err = _idtcm_gettime(extts_channel, &ts, 1); - if (err == 0) { - event.type = PTP_CLOCK_EXTTS; - event.index = todn; - event.timestamp = timespec64_to_ns(&ts) - dco_delay; - ptp_clock_event(ptp_channel->ptp_clock, &event); - } - return err; -} + err = _idtcm_gettime_triggered(extts_channel, &ts); -static u8 idtcm_enable_extts_mask(struct idtcm_channel *channel, - u8 extts_mask, bool enable) -{ - struct idtcm *idtcm = channel->idtcm; - int i, err; + if (err) + return err; - for (i = 0; i < MAX_TOD; i++) { - u8 mask = 1 << i; - u8 refn = idtcm->channel[i].refn; - - if (extts_mask & mask) { - /* check extts before disabling it */ - if (enable == false) { - err = idtcm_extts_check_channel(idtcm, i); - /* trigger happened so we won't re-enable it */ - if (err == 0) - extts_mask &= ~mask; - } - (void)idtcm_enable_extts(channel, i, refn, enable); - } - } + /* Triggered - save timestamp */ + event.type = PTP_CLOCK_EXTTS; + event.index = todn; + event.timestamp = timespec64_to_ns(&ts) - dco_delay; + ptp_clock_event(ptp_channel->ptp_clock, &event); - return extts_mask; + return err; } static int _idtcm_gettime_immediate(struct idtcm_channel *channel, struct timespec64 *ts) { struct idtcm *idtcm = channel->idtcm; - u8 extts_mask = 0; + + u16 tod_read_cmd = IDTCM_FW_REG(idtcm->fw_ver, V520, TOD_READ_PRIMARY_CMD); + u8 val = (SCSR_TOD_READ_TRIG_SEL_IMMEDIATE << TOD_READ_TRIGGER_SHIFT); int err; - /* Disable extts */ - if (idtcm->extts_mask) { - extts_mask = idtcm_enable_extts_mask(channel, idtcm->extts_mask, - false); - } + err = idtcm_write(idtcm, channel->tod_read_primary, + tod_read_cmd, &val, sizeof(val)); - err = _idtcm_set_scsr_read_trig(channel, - SCSR_TOD_READ_TRIG_SEL_IMMEDIATE, 0); - if (err == 0) - err = _idtcm_gettime(channel, ts, 10); + if (err) + return err; - /* Re-enable extts */ - if (extts_mask) - idtcm_enable_extts_mask(channel, extts_mask, true); + err = _idtcm_gettime(channel, ts, 10); return err; } @@ -1702,6 +1733,9 @@ static int initialize_dco_operating_mode(struct idtcm_channel *channel) /* * Maximum absolute value for write phase offset in picoseconds * + * @channel: channel + * @delta_ns: delta in nanoseconds + * * Destination signed register is 32-bit register in resolution of 50ps * * 0x7fffffff * 50 = 2147483647 * 50 = 107374182350 @@ -1958,8 +1992,7 @@ static int idtcm_enable(struct ptp_clock_info *ptp, err = idtcm_perout_enable(channel, &rq->perout, true); break; case PTP_CLK_REQ_EXTTS: - err = idtcm_enable_extts(channel, rq->extts.index, - rq->extts.rsv[0], on); + err = idtcm_extts_enable(channel, rq, on); break; default: break; @@ -1982,13 +2015,6 @@ static int idtcm_enable_tod(struct idtcm_channel *channel) u8 cfg; int err; - /* STEELAI-366 - Temporary workaround for ts2phc compatibility */ - if (0) { - err = idtcm_output_mask_enable(channel, false); - if (err) - return err; - } - /* * Start the TOD clock ticking. */ @@ -2038,17 +2064,35 @@ static void idtcm_set_version_info(struct idtcm *idtcm) product_id, hw_rev_id, config_select); } +static int idtcm_verify_pin(struct ptp_clock_info *ptp, unsigned int pin, + enum ptp_pin_function func, unsigned int chan) +{ + switch (func) { + case PTP_PF_NONE: + case PTP_PF_EXTTS: + break; + case PTP_PF_PEROUT: + case PTP_PF_PHYSYNC: + return -1; + } + return 0; +} + +static struct ptp_pin_desc pin_config[MAX_TOD][MAX_REF_CLK]; + static const struct ptp_clock_info idtcm_caps = { .owner = THIS_MODULE, .max_adj = 244000, .n_per_out = 12, .n_ext_ts = MAX_TOD, + .n_pins = MAX_REF_CLK, .adjphase = &idtcm_adjphase, .adjfine = &idtcm_adjfine, .adjtime = &idtcm_adjtime, .gettime64 = &idtcm_gettime, .settime64 = &idtcm_settime, .enable = &idtcm_enable, + .verify = &idtcm_verify_pin, .do_aux_work = &idtcm_work_handler, }; @@ -2057,12 +2101,14 @@ static const struct ptp_clock_info idtcm_caps_deprecated = { .max_adj = 244000, .n_per_out = 12, .n_ext_ts = MAX_TOD, + .n_pins = MAX_REF_CLK, .adjphase = &idtcm_adjphase, .adjfine = &idtcm_adjfine, .adjtime = &idtcm_adjtime_deprecated, .gettime64 = &idtcm_gettime, .settime64 = &idtcm_settime_deprecated, .enable = &idtcm_enable, + .verify = &idtcm_verify_pin, .do_aux_work = &idtcm_work_handler, }; @@ -2174,8 +2220,9 @@ static u32 idtcm_get_dco_delay(struct idtcm_channel *channel) n = 1; fodFreq = (u32)div_u64(m, n); + if (fodFreq >= 500000000) - return 18 * (u32)div_u64(NSEC_PER_SEC, fodFreq); + return (u32)div_u64(18 * (u64)NSEC_PER_SEC, fodFreq); return 0; } @@ -2188,24 +2235,28 @@ static int configure_channel_tod(struct idtcm_channel *channel, u32 index) switch (index) { case 0: channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_0); + channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_0); channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_0); channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_0); channel->sync_src = SYNC_SOURCE_DPLL0_TOD_PPS; break; case 1: channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_1); + channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_1); channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_1); channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_1); channel->sync_src = SYNC_SOURCE_DPLL1_TOD_PPS; break; case 2: channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_2); + channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_2); channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_2); channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_2); channel->sync_src = SYNC_SOURCE_DPLL2_TOD_PPS; break; case 3: channel->tod_read_primary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_PRIMARY_3); + channel->tod_read_secondary = IDTCM_FW_REG(fw_ver, V520, TOD_READ_SECONDARY_3); channel->tod_write = IDTCM_FW_REG(fw_ver, V520, TOD_WRITE_3); channel->tod_n = IDTCM_FW_REG(fw_ver, V520, TOD_3); channel->sync_src = SYNC_SOURCE_DPLL3_TOD_PPS; @@ -2221,6 +2272,7 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index) { struct idtcm_channel *channel; int err; + int i; if (!(index < MAX_TOD)) return -EINVAL; @@ -2248,6 +2300,17 @@ static int idtcm_enable_channel(struct idtcm *idtcm, u32 index) snprintf(channel->caps.name, sizeof(channel->caps.name), "IDT CM TOD%u", index); + channel->caps.pin_config = pin_config[index]; + + for (i = 0; i < channel->caps.n_pins; ++i) { + struct ptp_pin_desc *ppd = &channel->caps.pin_config[i]; + + snprintf(ppd->name, sizeof(ppd->name), "input_ref%d", i); + ppd->index = i; + ppd->func = PTP_PF_NONE; + ppd->chan = index; + } + err = initialize_dco_operating_mode(channel); if (err) return err; @@ -2302,26 +2365,40 @@ static int idtcm_enable_extts_channel(struct idtcm *idtcm, u32 index) static void idtcm_extts_check(struct work_struct *work) { struct idtcm *idtcm = container_of(work, struct idtcm, extts_work.work); - int err, i; + struct idtcm_channel *channel; + u8 mask; + int err; + int i; if (idtcm->extts_mask == 0) return; mutex_lock(idtcm->lock); + for (i = 0; i < MAX_TOD; i++) { - u8 mask = 1 << i; + mask = 1 << i; + + if ((idtcm->extts_mask & mask) == 0) + continue; + + err = idtcm_extts_check_channel(idtcm, i); - if (idtcm->extts_mask & mask) { - err = idtcm_extts_check_channel(idtcm, i); + if (err == 0) { /* trigger clears itself, so clear the mask */ - if (err == 0) + if (idtcm->extts_single_shot) { idtcm->extts_mask &= ~mask; + } else { + /* Re-arm */ + channel = &idtcm->channel[i]; + arm_tod_read_trig_sel_refclk(channel, channel->refn); + } } } if (idtcm->extts_mask) schedule_delayed_work(&idtcm->extts_work, msecs_to_jiffies(EXTTS_PERIOD_MS)); + mutex_unlock(idtcm->lock); } @@ -2342,6 +2419,11 @@ static void set_default_masks(struct idtcm *idtcm) idtcm->tod_mask = DEFAULT_TOD_MASK; idtcm->extts_mask = 0; + idtcm->channel[0].tod = 0; + idtcm->channel[1].tod = 1; + idtcm->channel[2].tod = 2; + idtcm->channel[3].tod = 3; + idtcm->channel[0].pll = DEFAULT_TOD0_PTP_PLL; idtcm->channel[1].pll = DEFAULT_TOD1_PTP_PLL; idtcm->channel[2].pll = DEFAULT_TOD2_PTP_PLL; @@ -2420,8 +2502,8 @@ static int idtcm_remove(struct platform_device *pdev) { struct idtcm *idtcm = platform_get_drvdata(pdev); + idtcm->extts_mask = 0; ptp_clock_unregister_all(idtcm); - cancel_delayed_work_sync(&idtcm->extts_work); return 0; diff --git a/drivers/ptp/ptp_clockmatrix.h b/drivers/ptp/ptp_clockmatrix.h index 0f3059a..4379650 100644 --- a/drivers/ptp/ptp_clockmatrix.h +++ b/drivers/ptp/ptp_clockmatrix.h @@ -10,11 +10,13 @@ #include #include +#include #include #define FW_FILENAME "idtcm.bin" #define MAX_TOD (4) #define MAX_PLL (8) +#define MAX_REF_CLK (16) #define MAX_ABS_WRITE_PHASE_PICOSECONDS (107374182350LL) @@ -90,6 +92,7 @@ struct idtcm_channel { u16 dpll_ctrl_n; u16 dpll_phase_pull_in; u16 tod_read_primary; + u16 tod_read_secondary; u16 tod_write; u16 tod_n; u16 hw_dpll_n; @@ -105,6 +108,7 @@ struct idtcm_channel { /* last input trigger for extts */ u8 refn; u8 pll; + u8 tod; u16 output_mask; }; @@ -116,6 +120,7 @@ struct idtcm { enum fw_version fw_ver; /* Polls for external time stamps */ u8 extts_mask; + bool extts_single_shot; struct delayed_work extts_work; /* Remember the ptp channel to report extts */ struct idtcm_channel *event_channel[MAX_TOD]; diff --git a/include/linux/mfd/idt8a340_reg.h b/include/linux/mfd/idt8a340_reg.h index a18c153..0c70608 100644 --- a/include/linux/mfd/idt8a340_reg.h +++ b/include/linux/mfd/idt8a340_reg.h @@ -407,7 +407,7 @@ #define TOD_READ_PRIMARY_0 0xcc40 #define TOD_READ_PRIMARY_0_V520 0xcc50 /* 8-bit subns, 32-bit ns, 48-bit seconds */ -#define TOD_READ_PRIMARY 0x0000 +#define TOD_READ_PRIMARY_BASE 0x0000 /* Counter increments after TOD write is completed */ #define TOD_READ_PRIMARY_COUNTER 0x000b /* Read trigger configuration */ @@ -424,6 +424,16 @@ #define TOD_READ_SECONDARY_0 0xcc90 #define TOD_READ_SECONDARY_0_V520 0xcca0 +/* 8-bit subns, 32-bit ns, 48-bit seconds */ +#define TOD_READ_SECONDARY_BASE 0x0000 +/* Counter increments after TOD write is completed */ +#define TOD_READ_SECONDARY_COUNTER 0x000b +/* Read trigger configuration */ +#define TOD_READ_SECONDARY_SEL_CFG_0 0x000c +/* Read trigger selection */ +#define TOD_READ_SECONDARY_CMD 0x000e +#define TOD_READ_SECONDARY_CMD_V520 0x000f + #define TOD_READ_SECONDARY_1 0xcca0 #define TOD_READ_SECONDARY_1_V520 0xccb0 #define TOD_READ_SECONDARY_2 0xccb0 From patchwork Wed May 11 14:25:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Min Li X-Patchwork-Id: 12846232 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B8D2C433EF for ; Wed, 11 May 2022 14:25:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244574AbiEKOZp (ORCPT ); Wed, 11 May 2022 10:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242913AbiEKOZh (ORCPT ); Wed, 11 May 2022 10:25:37 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2112.outbound.protection.outlook.com [40.107.114.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A23964737; Wed, 11 May 2022 07:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B9ViiWhZzNurn4F5xVSb8ZqJtGU7yP61gwRI/3q6dz5+XI0NwaKFD4/GODNyUcC2Hn4LfYul0yVAp9d2zWOwzSAaSX5PTl90zs3aW5CtYvMYgPB+eA7FVfryDM3hji+pjHtxdTW/R0qSSdJ3psLjBnN7DTuMEgeZe9JsiJPVf8V4HLPPvVpaJNeIdF/y6xEaqkdib1mxNSGK8mmb02gz3GfTEpwpq9Im8Sqf14jGXfTF3i8iEPcsM0FB9GDrLowSSMtUGGpt25f1yVAA82n85brs5nh92h0xF/PHWrAHIvi7yIXdongftEqz7FRFVXPozb/+6VEE/hvua0PrMVDxNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0SLGe36sfTPr6X3bEb/UxR3gcJbp6tf3M0YK1pXELk4=; b=d/OzeNM5Bez8Sxgw3AXif3ELVzoWWiJ44pup1UBuP2hkkKIzCGu2GaKBSlTj/s32ICUJiHU+AC8lcKp2/gsgko2ymDPrXWLl3D7+/Px7SpGPd0mFqxcNgZqNLBPUPD3hKfqnz1YGSDms27lBxJ/TDkOLmbZhw7DdmN6jASfCVkU1uRNwsUQKLMHt/V1NJp0I9zULoZ4so0JOZdP6adgeuO6ZMPHHoq9CSrmBiX1w2dcbfnzNlZGSrIpXIlBOCI2ucEAPApqo8htDmnv4OpO9JPzNnn4VkkR1Wt3VUtnvKhHvp8sMyc05neQEB3oCZKv7klnQnPoMHOV7ZP8fXGpV1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0SLGe36sfTPr6X3bEb/UxR3gcJbp6tf3M0YK1pXELk4=; b=i1hrbyA/TiOlBmU/XxfKS3F7NvzC9OeMfcznjD/sxm3JIhHUsZXoo30rjWS5Ig/9Jkf8xXCilhyR0QTSt4NtLQvlINOroBkRTrSmmbCCSOMmznPrv7MgpPSnXBfapx8gphaTFjfC/hrdV5qv7xZUWfgbZvjlqm/f+6qPpQkrk4w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) by OSAPR01MB4850.jpnprd01.prod.outlook.com (2603:1096:604:69::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 14:25:35 +0000 Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663]) by OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663%9]) with mapi id 15.20.5250.013; Wed, 11 May 2022 14:25:35 +0000 From: Min Li To: richardcochran@gmail.com, lee.jones@linaro.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Min Li Subject: [PATCH net v5 2/3] ptp: ptp_clockmatrix: return -EBUSY if phase pull-in is in progress Date: Wed, 11 May 2022 10:25:13 -0400 Message-Id: <1652279114-25939-2-git-send-email-min.li.xe@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1652279114-25939-1-git-send-email-min.li.xe@renesas.com> References: <1652279114-25939-1-git-send-email-min.li.xe@renesas.com> X-ClientProxiedBy: BN9PR03CA0203.namprd03.prod.outlook.com (2603:10b6:408:f9::28) To OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2a24860-0a8f-4e6c-d74e-08da335a1cb6 X-MS-TrafficTypeDiagnostic: OSAPR01MB4850:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sL5vMlchj+1dyrhseTj1eFhN/tde1VyBwb85ADCnHM8ozEAWe1Qgoanqyyq0PyzoZvcQvqxX/ShHOjnufyYgPJBCCMZ0hUUSRPmzKRv2ZnwJAEK86BPgjfBVBBaQVhcnL9VP1inn+GluRH3fOG+xtUVuXg/aA7pED4Js32NR6bUoz2AndF+GbJ5UnS3QLLFpWb6DGqZXOt7NKtBAI6cYBaX8nd7i/76VwaiMV4Un2K9lk6CnmuRROnFlXf8queHvzgdBX/0dcz+XA8cVFpCepNUnCGrjfhuTpdtgJbL08iklhi/K6yHzWK9Cqbdmix4FHmna6r9dWGyBSabeD6MClMdA74qHpkAPpZi7Rcm9rn6BXsuuFeaA7dMGSgpYaQXDi3OcnM59Zm/iD9ORXSC/3QN9dHXUS9HE+zwCzQDhBbvugSmFPn/SV7nsR6MlY+9GUmuYDpzLTalX+ylQU4mtfkM6DaGcF6D7ioxN9ZkWtTFiI2apc01vbWRE9GwJj8Xip62bLRvGNcUFz5pkQidTxYhr7u7v+CA7Jy3nLrcWuwxwBRxP6iVExBp2bS9KN1OukO8tw3kPhyNqjHx27pfMLGDJfjmSKBqQa3imxd4mL9/lWmIUo6REHz90m1psdmoKFxVW/RGamU7Pl6h5MtNUvOymT+Byk3lISBkPQIFa+2x4ax+GLoYnmT5Ieg/dkH/eUpQckGHtqBMzmQzuR9G9cQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB6593.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(107886003)(508600001)(6512007)(26005)(6506007)(186003)(52116002)(316002)(86362001)(6666004)(2906002)(5660300002)(83380400001)(36756003)(2616005)(4326008)(8676002)(66476007)(66946007)(66556008)(38100700002)(38350700002)(8936002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8Xu9/u4vOOPUiggt18SkO1XHXVvL3HNPXLmWKOC+Xf+entBQh5mnwLFxDCh3B9O5T5VdlYmoy1rz6WUvPW7eXlnKvQJupD8NIcZaLgnT0kU1k0xqSh1o8nMMuln93glC13AJReIerHVulI6qwjqUFWH4+09ZSIoqYvW0oy+thJRDAnZOoX3jfCc8W1a4EBSJtKQo1ykE2FsqnRX/4txRcXHTmjXNra5UwF0+f5J8WnwR1xRi6lizPnTqssIL2xhzGqUOd/bIL0y7/nBSZl8wMtSrZuE+XTHgMIaZn4EzoaIUIDP/R2pHIXR8RDdAAww7/On1wxTIYiS51IWSjBxQF8KkGyXJkh0rYyOqv067JH/3Ziu1I1Dk8Kpg0LrgtRvoQB4tzUDR7KhDgPpzzDdg2b+RUOZFFMpAzV2Rov1SdlhvX6gpwXomBXvIyo3ijYCgNb4EjkbRQZrXhTEScbzgnkhYr8DMo3CJNQWOvWgGQ155en7Q55t7TzMyshnwDA0Mw4mCwKI81iYgF0IApoJeJCQxizwwpPWRhmjcPSBp4bpN/8j0t36tm1JxVIqSzYug0gFN08Yr1OXSegHVTf7WDW63f8/Vmnj3P7cAenY2DUKZ3ZsYRSrbI4mDnEarVNj7Muopq7K1b6vrhL6eoAaVqsuKTCCX55sBkMP206XrdT6g/FGHku2KbhzS/S2Hbpqz3xGnvTQVflrgErHhmSUovOsm64HxcnlvTFPuMaJceNVGw1jBNjD/ANmmP4KPilZr71dVbSFZdyQITMw0gln4kDubg/vnlTZ+C1fS4RxbEOcc5lm3P5LIPKGEjjKbFLzqyOFSYSe0fwmrUag2Pc3UJyI1HVZCzpS2Pv2EyxLtHRp36Lnp3ntlVBCUcNiwDrvJ/8HmR4iqRJD8slQf6im/5Lt8Fl09ElBka6ppjJMMiofS4whQz75gs49ATTrH7yoNf26grvwYvgyBafDxvhjCCUF2YIIZgNaBn+gd6BR5P+e4dQRCnbCrkk4oRRb+E7ey1e0UKIwMKYGnQDwSnqvlFMMUS9DKrSTNjDhhcwZU841IV8WRI4nbQYaQ04JVslfi5JwdENLfKmGBEPX/VnLTua5FN/6CapvBO3Enud6SR0D9u+C0XTy6vL3iRjucLnKHvYFxQ1DDQY3u+lPK6jNZdlRoVlnnKCA4tCMEJtpSPNkM5cOYZQx5yFqoz09ivZsVXd1ePpiq2RKCCQmwga8/rfGkFBqEO9GIemCCdkPoGzdWrwP2tsBmebik/9/w5FHBp/c605CZpxjP02qqvqEm9lTIT6Ldn+HnXgxGRMzY3z/YSYZfkPAmaxWWFkuOysGudfocOzmwclYcuwDEPwvYZiIc7Tg6C3oZ8vSXAbEgmD/Uzn0EeKsOEk90/gqzy3DODEaJJaJmbpI/H9MVFz5yOl7Ob78/FYfpQFVwSu/yzbiY9OUUxYC+GUFd/fXL2DCUIWjyYAnOVPnukY44U+Cs6AoQ800oF4snvgXhcpMzvSfdf8KioPlJQie19gTBpEMkFYtFFQniwluPkqqn4ZFSEuIYY2R+VskzTlUVM/UPplyDwfwfgiIo+Qi+4iSqrU4AArshY75uRpFrJd9tV9u3JgLRr+cjhuUPosQCNr2iL9krUtLlfexdWkJ4DSnYf1RoQZmCeW3sGBwZiCRI9GEXxkWhNdkIdfTrpo4wsucewzzFVDXGnSmaf0FtHxrOMES38ePuBDS0CPmJKI9D5IUSlZpfDPOjX3mPdFL3buOVXVU= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2a24860-0a8f-4e6c-d74e-08da335a1cb6 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB6593.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 14:25:35.0351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x9dRXfFFMx0eY5+5Xr/zdfgSEJPHB9JEhANGfCFZG9gMVvtClanljtzS/QKiidaDN1pXpyJSdcoISLc1MycVig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSAPR01MB4850 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Also removes PEROUT_ENABLE_OUTPUT_MASK Signed-off-by: Min Li Acked-by: Richard Cochran --- drivers/ptp/ptp_clockmatrix.c | 32 ++------------------------------ drivers/ptp/ptp_clockmatrix.h | 2 -- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c index aaff5cd..ea87487 100644 --- a/drivers/ptp/ptp_clockmatrix.c +++ b/drivers/ptp/ptp_clockmatrix.c @@ -1363,43 +1363,15 @@ static int idtcm_output_enable(struct idtcm_channel *channel, return idtcm_write(idtcm, (u16)base, OUT_CTRL_1, &val, sizeof(val)); } -static int idtcm_output_mask_enable(struct idtcm_channel *channel, - bool enable) -{ - u16 mask; - int err; - u8 outn; - - mask = channel->output_mask; - outn = 0; - - while (mask) { - if (mask & 0x1) { - err = idtcm_output_enable(channel, enable, outn); - if (err) - return err; - } - - mask >>= 0x1; - outn++; - } - - return 0; -} - static int idtcm_perout_enable(struct idtcm_channel *channel, struct ptp_perout_request *perout, bool enable) { struct idtcm *idtcm = channel->idtcm; - unsigned int flags = perout->flags; struct timespec64 ts = {0, 0}; int err; - if (flags == PEROUT_ENABLE_OUTPUT_MASK) - err = idtcm_output_mask_enable(channel, enable); - else - err = idtcm_output_enable(channel, enable, perout->index); + err = idtcm_output_enable(channel, enable, perout->index); if (err) { dev_err(idtcm->dev, "Unable to set output enable"); @@ -1903,7 +1875,7 @@ static int idtcm_adjtime(struct ptp_clock_info *ptp, s64 delta) int err; if (channel->phase_pull_in == true) - return 0; + return -EBUSY; mutex_lock(idtcm->lock); diff --git a/drivers/ptp/ptp_clockmatrix.h b/drivers/ptp/ptp_clockmatrix.h index 4379650..bf1e49409 100644 --- a/drivers/ptp/ptp_clockmatrix.h +++ b/drivers/ptp/ptp_clockmatrix.h @@ -54,8 +54,6 @@ #define LOCK_TIMEOUT_MS (2000) #define LOCK_POLL_INTERVAL_MS (10) -#define PEROUT_ENABLE_OUTPUT_MASK (0xdeadbeef) - #define IDTCM_MAX_WRITE_COUNT (512) #define PHASE_PULL_IN_MAX_PPB (144000) From patchwork Wed May 11 14:25:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Min Li X-Patchwork-Id: 12846234 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E807C433F5 for ; Wed, 11 May 2022 14:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244674AbiEKOZ6 (ORCPT ); Wed, 11 May 2022 10:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244660AbiEKOZp (ORCPT ); Wed, 11 May 2022 10:25:45 -0400 Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2101.outbound.protection.outlook.com [40.107.114.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A075E9B; Wed, 11 May 2022 07:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CkHbLy6hSYmDvcfcu/LH+91HmqHSyUiDrwEexN10Wmjl1BFsQFkuzVfRMonnpOfe8c/+azYW7GpNd1OSfLnc9ooUg9iN80VXjhRUQzGfAol88rQmm3htAMdEh4rCHyoUI5uu32nCXiv9/6UI5F0u5tzUhzvR6CmD5eRNCYoEcthTeVsgokkQY8+D9+CyTzS6wjFTYGxC5tex+LR+EyOoANrUmWGm76NzFh/BNcEauVA51RhNCB2AGNIaJgP+nVphmJESxVy7MXn0Ye1M0JcVMvzgc7hmAKYbfdnBXmtkaejscUiT2heEPY39lCTR5UgJORVVZRsZjFbBp6K1Tw4/gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0YWEn41LK6IgDcRT84tlqkHUgJFOtdqr46aFsWge7Ow=; b=f6+/x8TCDKJbEIMSsQMaLu8kBU40ZcT66l29Ts6TvDlwHdwWZiMUNIRkrhjjjRQL/qqBg25tBUAe9X6OzIlpCYyPCh5DpBrsh+QDENRfcuuZwACCmDg9XWjUsgcU7+aT3eR9RpBH44y9uczJeE5iCwVyH3wV9kpsyqmnmvc6gc/F5hmhMam3jlgpMEmKYCH43o6CWne0i6WgsRyzIQr3sWXawwsegRN/jMmpYbV5SX+oktjIpD0eWTWWsGF+WhYKL03j67gXUjDpkgd/B5NAAc0u+9RECWtcC0C4zuqfqs7ndoJp8p6EBw/y9TYAuRWlCUk93tXSK7Ogpi2h8CJ2yA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0YWEn41LK6IgDcRT84tlqkHUgJFOtdqr46aFsWge7Ow=; b=nJZkfUWeP8bfi3zRzw96WeXIqNa4+KnnX/tY5bV3zKQumuCGJwehC9/dM8KXzfp8OWHjlvIJyLRBzELp50C5yiWy5XdlDqjRa7wK5lPmxx4faeZLK0dQV6NWE+CChQuU4mA1r6Cs8BZp5zs5PMqJY7TbFp0GeR81Ix9P8jkynj8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) by OS3PR01MB9545.jpnprd01.prod.outlook.com (2603:1096:604:1ca::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.21; Wed, 11 May 2022 14:25:39 +0000 Received: from OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663]) by OS3PR01MB6593.jpnprd01.prod.outlook.com ([fe80::a07c:4b38:65f3:6663%9]) with mapi id 15.20.5250.013; Wed, 11 May 2022 14:25:38 +0000 From: Min Li To: richardcochran@gmail.com, lee.jones@linaro.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Min Li Subject: [PATCH net v5 3/3] ptp: clockmatrix: miscellaneous cosmetic change Date: Wed, 11 May 2022 10:25:14 -0400 Message-Id: <1652279114-25939-3-git-send-email-min.li.xe@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1652279114-25939-1-git-send-email-min.li.xe@renesas.com> References: <1652279114-25939-1-git-send-email-min.li.xe@renesas.com> X-ClientProxiedBy: BN9PR03CA0203.namprd03.prod.outlook.com (2603:10b6:408:f9::28) To OS3PR01MB6593.jpnprd01.prod.outlook.com (2603:1096:604:101::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 462001d4-4fb7-4805-3311-08da335a1f04 X-MS-TrafficTypeDiagnostic: OS3PR01MB9545:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9b/m8H4PQp8ekJwH94fetiYgXDjF1WEK/Iu3WYl63J3ofjTHbYJDkZew1YPGFUI1XnK+bHj8GiXHHZNyOUi1vkaEdmSi3GtXq2WpTZcNeleQsWyUJvLij8iCuGd4ST/nYQtKvWGP/W0B9rbbSeFjTbY5jP+e6gzJ0uerlwjg5CDNvJcy0/VTmfA3OEJH1T87jCqyOQC7FfyOBe1IHdgzEEFTEzEbqtscFYNXI8zi2YnCeO3EqRda97gT064gMKaWRiEuZgqzgAqZ4g5aQnPf1J8/lTOKFVx+8LumbAajZSvflW2m+hlO+Wggsdm0B57WHQ8Vra15fbVctr9AZPjnOp4dzRiU8U/OSx8RZmmJ0C61zRYXT7CKrMBVpuVBdXKMvVr2+mH0xm0UIehDq3KiSaWB6mTSeR9qAuV4A9H60SGwkgqj4b3CLdHgK5GZ4CUQ79A0XdTCkPON1MjFF7iTIc9v241fC4dJHZWbOUVL4Uua3YZ5KHH3fgR8EPrF63iSPprlRJ5wlD/zJDyp9WYlTjVs/Yf5LaS4feLrzVqY5HrqY2ab07JJUUm/yZt+tPRVH3XNZAtPys0T3E0Q1L3G9/nAlQgzk/6UiKx/x89KDpy3cvTq2XBw5eJPEwyTD+D0XgKfcpi52PkPwbINKTTxtDXtE9h/j2/Tqd46u9mNRQGLs/awYqhx7BDePpCPM3ipzyJk59qC0QhnSxAGORC8Nw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB6593.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(2906002)(2616005)(6506007)(6512007)(107886003)(26005)(4326008)(8676002)(38100700002)(66556008)(66476007)(66946007)(186003)(36756003)(316002)(6486002)(86362001)(6666004)(38350700002)(83380400001)(52116002)(508600001)(8936002)(5660300002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S+dUWDIRaHrlzyGHz6YMHQPduK2+oUZ8Uhmfkq1aPf2usLOMKtbTkt2OO105WArA667aFd62wJ3GYU3HA156ldiyqK+jiLAzCT+3v29R9oCnIrS/Qoi2FxiALRlBHnsV3waFqr8QAL7Xewr+38V/g9yiE89JP3YfmET3vUxMX8w1NweKYBKfmoLZfJcmiQxptr1niHZj5u6w5lN6sQS03PNP3FYvdiG8zxai1SXithpHd9cuSgjkt5iH0IpFECLityr6Ee6Lg1kDl71u0CKvjMckbbSmMGnn1b4ykjuIvkJbK/lkDUmYJVNMOQJovuPRrQQaLq9NoZSXv5UfwN9Dem6FpicTbxqbP/ozEoHnTo6DbXD3UEr8B/eUXMzAjSWMFBEi31w9It5sfAo/jEbWR+tGiRS71Pjz+yRUnUdNJi+OynOvJQxaecryk5wYrJ8eor7ylVK5YaVoAPT1+ScCbNAy/2APamFipqsFgZPQ0sqZd1nRlPEHUyiH+JgFl94rhWcsNQIwfwP5dgrWns1xHgYCmo0wOMOr4uHW7et7N/Cfx926wsdSQUVW1hto6gG8ZVhcD7WMA4oimvFlbeHyNUsm7At/x3VVWS7wHAuwu0tr1SVFrdD3rLspCFVD4X9DANPJFEFAvQ1Jr4znFE7XCOPtAZlP0V7nzPtGrKwbe4vDppZK1Oani8Df9BvF0eYK/wuMAvzKG76ZVViIT8BFp0a3m9aNSmSQniEFkMfX1iFk/Q6gnCyVuRF+STf35rTD6v+koTSd87N88caJUo9lQYp93r+hl7ydtYmTPRxoaMTm7Y+6yPe7KqNAoWxPIakREU18cgfjbilSIkkDwYzXYWYVkjBxpgMSb7ZQ67mglrVt4TY55QFUWY38EEVNTWrjKzPX8avf9SAs/U3wrS3Gneqz1gCowDQtyQSUnCdqtdeGhq2jsKx9yYNf/2pY25oeaXorS0NqHR49WNAbDxv24cRwEeTOijfh4hzUpjdwRlNg5W6g5MhIt1bhPb9eonqZVbvEu0baacHh1VLgYPo4ThaAyFvlCODAFPDmijvtgMizXIc7B+amwOyJw/Dugr+2445yeTANWYU79a0UBhNkFYwQpdm4rp0wvS2ExHpQqS+C/xpv8mC8N5gMegmSe66op+Wr/Rp4CpHA4Jz6RZlQbFCTStigRMTsjXRt9CfZkjZj6wCmE2C1PvIeUQl22skBtZPj7HTSCJMJ9RcFL4LqRKSLPsl/qveVBbmAI4Wk19gISDuAwe3liaBTd9O2eMc6r7GbB1MtjHhqQRUelh6WUjEW+eDQEAESSdW5BbrVp9CSfmDA3v1l80I1Dkxs9lq2zCcRMXazCXGV3zw0XosH4HOmf+Q7TYJejl56ZvPhjY5YeDG0zMkuXFs65ITAcnKUET+eTiS9RH9QgqdwiaAqDfR57IkahaWK4u+bz9Uh/S42hUgldffQJfOBKI/Su7mcmh5bgMXo057obJ0RSiXPIJ856lvyOb12Ciy9hw0bDaJxItja1hTtp3WEJuNsTnlX9p58RiKmZ8rs9Uy8EUdMAzyBqBTu8ypmb7g35C2msvtKujaNNbvbL/f9R0gEUHIgqYKjLUekQ7jZEYGy0AfOImYnDYh3X0XOYcd4BcRgQZqews2vuM1rHCtjpNoMyrJyjo81FwjenEPIj0e7F4AIDbQgU16oHoVtcJ0mIhEeny+0Rcq2rAB0hdxC/X46ppntu2/C3JM4CSFE7L1dQND+ffpBxdLQfa89Uz5gs+S9UFM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 462001d4-4fb7-4805-3311-08da335a1f04 X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB6593.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2022 14:25:38.8975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ULQU00eg4wLJUpfOVfwYYhjmCxDA2u+CEEgvzo9p0P9d30mhDSGjeOHOsVYAnOLEmjSkdhZ1qQgE1fWLAmhYlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB9545 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org suggested by Jakub Kicinski Signed-off-by: Min Li --- drivers/ptp/ptp_clockmatrix.c | 69 +++++++++++++------------------------------ 1 file changed, 20 insertions(+), 49 deletions(-) diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c index ea87487..4461635 100644 --- a/drivers/ptp/ptp_clockmatrix.c +++ b/drivers/ptp/ptp_clockmatrix.c @@ -261,17 +261,13 @@ static int arm_tod_read_trig_sel_refclk(struct idtcm_channel *channel, u8 ref) if (err) dev_err(idtcm->dev, "%s: err = %d", __func__, err); - return err; } static bool is_single_shot(u8 mask) { /* Treat single bit ToD masks as continuous trigger */ - if ((mask == 1) || (mask == 2) || (mask == 4) || (mask == 8)) - return false; - else - return true; + return mask <= 8 && is_power_of_2(mask); } static int idtcm_extts_enable(struct idtcm_channel *channel, @@ -418,13 +414,10 @@ static int _idtcm_gettime_triggered(struct idtcm_channel *channel, err = idtcm_read(idtcm, channel->tod_read_secondary, TOD_READ_SECONDARY_BASE, buf, sizeof(buf)); - if (err) return err; - err = char_array_to_timespec(buf, sizeof(buf), ts); - - return err; + return char_array_to_timespec(buf, sizeof(buf), ts); } static int _idtcm_gettime(struct idtcm_channel *channel, @@ -456,9 +449,7 @@ static int _idtcm_gettime(struct idtcm_channel *channel, if (err) return err; - err = char_array_to_timespec(buf, sizeof(buf), ts); - - return err; + return char_array_to_timespec(buf, sizeof(buf), ts); } static int idtcm_extts_check_channel(struct idtcm *idtcm, u8 todn) @@ -500,13 +491,10 @@ static int _idtcm_gettime_immediate(struct idtcm_channel *channel, err = idtcm_write(idtcm, channel->tod_read_primary, tod_read_cmd, &val, sizeof(val)); - if (err) return err; - err = _idtcm_gettime(channel, ts, 10); - - return err; + return _idtcm_gettime(channel, ts, 10); } static int _sync_pll_output(struct idtcm *idtcm, @@ -631,9 +619,7 @@ static int _sync_pll_output(struct idtcm *idtcm, /* Place master sync out of reset */ val &= ~(SYNCTRL1_MASTER_SYNC_RST); - err = idtcm_write(idtcm, 0, sync_ctrl1, &val, sizeof(val)); - - return err; + return idtcm_write(idtcm, 0, sync_ctrl1, &val, sizeof(val)); } static int idtcm_sync_pps_output(struct idtcm_channel *channel) @@ -917,7 +903,6 @@ static int _idtcm_settime(struct idtcm_channel *channel, static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel, s32 offset_ns) { - int err; int i; struct idtcm *idtcm = channel->idtcm; u8 buf[4]; @@ -927,16 +912,13 @@ static int idtcm_set_phase_pull_in_offset(struct idtcm_channel *channel, offset_ns >>= 8; } - err = idtcm_write(idtcm, channel->dpll_phase_pull_in, PULL_IN_OFFSET, - buf, sizeof(buf)); - - return err; + return idtcm_write(idtcm, channel->dpll_phase_pull_in, PULL_IN_OFFSET, + buf, sizeof(buf)); } static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel, u32 max_ffo_ppb) { - int err; u8 i; struct idtcm *idtcm = channel->idtcm; u8 buf[3]; @@ -949,10 +931,8 @@ static int idtcm_set_phase_pull_in_slope_limit(struct idtcm_channel *channel, max_ffo_ppb >>= 8; } - err = idtcm_write(idtcm, channel->dpll_phase_pull_in, - PULL_IN_SLOPE_LIMIT, buf, sizeof(buf)); - - return err; + return idtcm_write(idtcm, channel->dpll_phase_pull_in, + PULL_IN_SLOPE_LIMIT, buf, sizeof(buf)); } static int idtcm_start_phase_pull_in(struct idtcm_channel *channel) @@ -991,9 +971,7 @@ static int do_phase_pull_in_fw(struct idtcm_channel *channel, if (err) return err; - err = idtcm_start_phase_pull_in(channel); - - return err; + return idtcm_start_phase_pull_in(channel); } static int set_tod_write_overhead(struct idtcm_channel *channel) @@ -1417,10 +1395,9 @@ static int idtcm_set_pll_mode(struct idtcm_channel *channel, dpll_mode |= (mode << PLL_MODE_SHIFT); - err = idtcm_write(idtcm, channel->dpll_n, - IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_MODE), - &dpll_mode, sizeof(dpll_mode)); - return err; + return idtcm_write(idtcm, channel->dpll_n, + IDTCM_FW_REG(idtcm->fw_ver, V520, DPLL_MODE), + &dpll_mode, sizeof(dpll_mode)); } static int idtcm_get_manual_reference(struct idtcm_channel *channel, @@ -1460,11 +1437,9 @@ static int idtcm_set_manual_reference(struct idtcm_channel *channel, dpll_manu_ref_cfg |= (ref << MANUAL_REFERENCE_SHIFT); - err = idtcm_write(idtcm, channel->dpll_ctrl_n, - DPLL_CTRL_DPLL_MANU_REF_CFG, - &dpll_manu_ref_cfg, sizeof(dpll_manu_ref_cfg)); - - return err; + return idtcm_write(idtcm, channel->dpll_ctrl_n, + DPLL_CTRL_DPLL_MANU_REF_CFG, + &dpll_manu_ref_cfg, sizeof(dpll_manu_ref_cfg)); } static int configure_dpll_mode_write_frequency(struct idtcm_channel *channel) @@ -1746,10 +1721,8 @@ static int _idtcm_adjphase(struct idtcm_channel *channel, s32 delta_ns) phase_50ps >>= 8; } - err = idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE, - buf, sizeof(buf)); - - return err; + return idtcm_write(idtcm, channel->dpll_phase, DPLL_WR_PHASE, + buf, sizeof(buf)); } static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm) @@ -1790,10 +1763,8 @@ static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm) fcw >>= 8; } - err = idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ, - buf, sizeof(buf)); - - return err; + return idtcm_write(idtcm, channel->dpll_freq, DPLL_WR_FREQ, + buf, sizeof(buf)); } static int idtcm_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)