162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Microchip KSZ PTP register definitions 362306a36Sopenharmony_ci * Copyright (C) 2022 Microchip Technology Inc. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef __KSZ_PTP_REGS_H 762306a36Sopenharmony_ci#define __KSZ_PTP_REGS_H 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define REG_SW_GLOBAL_LED_OVR__4 0x0120 1062306a36Sopenharmony_ci#define LED_OVR_2 BIT(1) 1162306a36Sopenharmony_ci#define LED_OVR_1 BIT(0) 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define REG_SW_GLOBAL_LED_SRC__4 0x0128 1462306a36Sopenharmony_ci#define LED_SRC_PTP_GPIO_1 BIT(3) 1562306a36Sopenharmony_ci#define LED_SRC_PTP_GPIO_2 BIT(2) 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* 5 - PTP Clock */ 1862306a36Sopenharmony_ci#define REG_PTP_CLK_CTRL 0x0500 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define PTP_STEP_ADJ BIT(6) 2162306a36Sopenharmony_ci#define PTP_STEP_DIR BIT(5) 2262306a36Sopenharmony_ci#define PTP_READ_TIME BIT(4) 2362306a36Sopenharmony_ci#define PTP_LOAD_TIME BIT(3) 2462306a36Sopenharmony_ci#define PTP_CLK_ADJ_ENABLE BIT(2) 2562306a36Sopenharmony_ci#define PTP_CLK_ENABLE BIT(1) 2662306a36Sopenharmony_ci#define PTP_CLK_RESET BIT(0) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define REG_PTP_RTC_SUB_NANOSEC__2 0x0502 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define PTP_RTC_SUB_NANOSEC_M 0x0007 3162306a36Sopenharmony_ci#define PTP_RTC_0NS 0x00 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define REG_PTP_RTC_NANOSEC 0x0504 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define REG_PTP_RTC_SEC 0x0508 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define REG_PTP_SUBNANOSEC_RATE 0x050C 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define PTP_SUBNANOSEC_M 0x3FFFFFFF 4062306a36Sopenharmony_ci#define PTP_RATE_DIR BIT(31) 4162306a36Sopenharmony_ci#define PTP_TMP_RATE_ENABLE BIT(30) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define REG_PTP_SUBNANOSEC_RATE_L 0x050E 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define REG_PTP_RATE_DURATION 0x0510 4662306a36Sopenharmony_ci#define REG_PTP_RATE_DURATION_H 0x0510 4762306a36Sopenharmony_ci#define REG_PTP_RATE_DURATION_L 0x0512 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define REG_PTP_MSG_CONF1 0x0514 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define PTP_802_1AS BIT(7) 5262306a36Sopenharmony_ci#define PTP_ENABLE BIT(6) 5362306a36Sopenharmony_ci#define PTP_ETH_ENABLE BIT(5) 5462306a36Sopenharmony_ci#define PTP_IPV4_UDP_ENABLE BIT(4) 5562306a36Sopenharmony_ci#define PTP_IPV6_UDP_ENABLE BIT(3) 5662306a36Sopenharmony_ci#define PTP_TC_P2P BIT(2) 5762306a36Sopenharmony_ci#define PTP_MASTER BIT(1) 5862306a36Sopenharmony_ci#define PTP_1STEP BIT(0) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define REG_PTP_UNIT_INDEX__4 0x0520 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define PTP_GPIO_INDEX GENMASK(19, 16) 6362306a36Sopenharmony_ci#define PTP_TSI_INDEX BIT(8) 6462306a36Sopenharmony_ci#define PTP_TOU_INDEX GENMASK(1, 0) 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define REG_PTP_TRIG_STATUS__4 0x0524 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define TRIG_ERROR_M GENMASK(18, 16) 6962306a36Sopenharmony_ci#define TRIG_DONE_M GENMASK(2, 0) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define REG_PTP_INT_STATUS__4 0x0528 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define TRIG_INT_M GENMASK(18, 16) 7462306a36Sopenharmony_ci#define TS_INT_M GENMASK(1, 0) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define REG_PTP_CTRL_STAT__4 0x052C 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define GPIO_IN BIT(7) 7962306a36Sopenharmony_ci#define GPIO_OUT BIT(6) 8062306a36Sopenharmony_ci#define TS_INT_ENABLE BIT(5) 8162306a36Sopenharmony_ci#define TRIG_ACTIVE BIT(4) 8262306a36Sopenharmony_ci#define TRIG_ENABLE BIT(3) 8362306a36Sopenharmony_ci#define TRIG_RESET BIT(2) 8462306a36Sopenharmony_ci#define TS_ENABLE BIT(1) 8562306a36Sopenharmony_ci#define TS_RESET BIT(0) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define REG_TRIG_TARGET_NANOSEC 0x0530 8862306a36Sopenharmony_ci#define REG_TRIG_TARGET_SEC 0x0534 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define REG_TRIG_CTRL__4 0x0538 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define TRIG_CASCADE_ENABLE BIT(31) 9362306a36Sopenharmony_ci#define TRIG_CASCADE_TAIL BIT(30) 9462306a36Sopenharmony_ci#define TRIG_CASCADE_UPS_M GENMASK(29, 26) 9562306a36Sopenharmony_ci#define TRIG_NOW BIT(25) 9662306a36Sopenharmony_ci#define TRIG_NOTIFY BIT(24) 9762306a36Sopenharmony_ci#define TRIG_EDGE BIT(23) 9862306a36Sopenharmony_ci#define TRIG_PATTERN_M GENMASK(22, 20) 9962306a36Sopenharmony_ci#define TRIG_NEG_EDGE 0 10062306a36Sopenharmony_ci#define TRIG_POS_EDGE 1 10162306a36Sopenharmony_ci#define TRIG_NEG_PULSE 2 10262306a36Sopenharmony_ci#define TRIG_POS_PULSE 3 10362306a36Sopenharmony_ci#define TRIG_NEG_PERIOD 4 10462306a36Sopenharmony_ci#define TRIG_POS_PERIOD 5 10562306a36Sopenharmony_ci#define TRIG_REG_OUTPUT 6 10662306a36Sopenharmony_ci#define TRIG_GPO_M GENMASK(19, 16) 10762306a36Sopenharmony_ci#define TRIG_CASCADE_ITERATE_CNT_M GENMASK(15, 0) 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define REG_TRIG_CYCLE_WIDTH 0x053C 11062306a36Sopenharmony_ci#define TRIG_CYCLE_WIDTH_M GENMASK(31, 0) 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#define REG_TRIG_CYCLE_CNT 0x0540 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define TRIG_CYCLE_CNT_M GENMASK(31, 16) 11562306a36Sopenharmony_ci#define TRIG_BIT_PATTERN_M GENMASK(15, 0) 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci#define REG_TRIG_ITERATE_TIME 0x0544 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define REG_TRIG_PULSE_WIDTH__4 0x0548 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci#define TRIG_PULSE_WIDTH_M GENMASK(23, 0) 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci/* Port PTP Register */ 12462306a36Sopenharmony_ci#define REG_PTP_PORT_RX_DELAY__2 0x0C00 12562306a36Sopenharmony_ci#define REG_PTP_PORT_TX_DELAY__2 0x0C02 12662306a36Sopenharmony_ci#define REG_PTP_PORT_ASYM_DELAY__2 0x0C04 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci#define REG_PTP_PORT_XDELAY_TS 0x0C08 12962306a36Sopenharmony_ci#define REG_PTP_PORT_SYNC_TS 0x0C0C 13062306a36Sopenharmony_ci#define REG_PTP_PORT_PDRESP_TS 0x0C10 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci#define REG_PTP_PORT_TX_INT_STATUS__2 0x0C14 13362306a36Sopenharmony_ci#define REG_PTP_PORT_TX_INT_ENABLE__2 0x0C16 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci#define PTP_PORT_SYNC_INT BIT(15) 13662306a36Sopenharmony_ci#define PTP_PORT_XDELAY_REQ_INT BIT(14) 13762306a36Sopenharmony_ci#define PTP_PORT_PDELAY_RESP_INT BIT(13) 13862306a36Sopenharmony_ci#define KSZ_SYNC_MSG 2 13962306a36Sopenharmony_ci#define KSZ_XDREQ_MSG 1 14062306a36Sopenharmony_ci#define KSZ_PDRES_MSG 0 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci#endif 143