Openwrt/target/linux/layerscape/patches-5.4/701-net-0395-LF-183-sdk_fman-add-an-option-for-RTC-1588-timer-ini.patch
Yangbo Lu cddd459140 layerscape: add patches-5.4
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release
which was tagged LSDK-20.04-V5.4.
https://source.codeaurora.org/external/qoriq/qoriq-components/linux/

For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in
LSDK, port the dts patches from 4.14.

The patches are sorted into the following categories:
  301-arch-xxxx
  302-dts-xxxx
  303-core-xxxx
  701-net-xxxx
  801-audio-xxxx
  802-can-xxxx
  803-clock-xxxx
  804-crypto-xxxx
  805-display-xxxx
  806-dma-xxxx
  807-gpio-xxxx
  808-i2c-xxxx
  809-jailhouse-xxxx
  810-keys-xxxx
  811-kvm-xxxx
  812-pcie-xxxx
  813-pm-xxxx
  814-qe-xxxx
  815-sata-xxxx
  816-sdhc-xxxx
  817-spi-xxxx
  818-thermal-xxxx
  819-uart-xxxx
  820-usb-xxxx
  821-vfio-xxxx

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2020-05-07 12:53:06 +02:00

216 lines
7.8 KiB
Diff

From f7ed64503d5e27571833b76acee721d00448fdec Mon Sep 17 00:00:00 2001
From: Yangbo Lu <yangbo.lu@nxp.com>
Date: Mon, 2 Sep 2019 15:33:16 +0800
Subject: [PATCH] LF-183 sdk_fman: add an option for RTC (1588 timer)
initialization and APIs
The RTC (1588 timer) could be managed by either ptp_qoriq driver
or sdk_fman RTC driver. So add an option for sdk_fman RTC
(1588 timer) initialization and APIs, so that user could select
it or not.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
drivers/net/ethernet/freescale/sdk_fman/Kconfig | 9 +++++++++
.../freescale/sdk_fman/Peripherals/FM/Makefile | 3 ++-
.../freescale/sdk_fman/Peripherals/FM/fm.c | 4 ++++
.../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 22 ++++++++++++++++++++++
.../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c | 18 +++++++++++++-----
5 files changed, 50 insertions(+), 6 deletions(-)
--- a/drivers/net/ethernet/freescale/sdk_fman/Kconfig
+++ b/drivers/net/ethernet/freescale/sdk_fman/Kconfig
@@ -49,6 +49,15 @@ config FMAN_V3L
endchoice
endmenu
+config FSL_SDK_FMAN_RTC_API
+ bool "FMan RTC (1588 timer) APIs"
+ default n
+ help
+ This option enables RTC (1588 timer) initialization and
+ APIs support. The ptp_qoriq driver is not available if
+ it is selected for RTC (1588 timer). Neither of them
+ were not able to be used together.
+
config FMAN_MIB_CNT_OVF_IRQ_EN
bool "Enable the dTSEC MIB counters overflow interrupt"
default n
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
@@ -19,5 +19,6 @@ obj-y += Pcd/
obj-y += SP/
obj-y += Port/
obj-y += HC/
-obj-y += Rtc/
obj-y += MACSEC/
+
+obj-$(CONFIG_FSL_SDK_FMAN_RTC_API) += Rtc/
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
@@ -602,8 +602,10 @@ do {
FM_G_CALL_10G_MAC_ISR(0);
if (pending & INTR_EN_10G_MAC1)
FM_G_CALL_10G_MAC_ISR(1);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (pending & INTR_EN_TMR)
p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
+#endif
}
#if (DPAA_VERSION >= 11)
@@ -4318,8 +4320,10 @@ void FM_EventIsr(t_Handle h_Fm)
p_Fm->intrMng[e_FM_EV_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_PRS].h_SrcHandle);
if (pending & INTR_EN_PLCR)
p_Fm->intrMng[e_FM_EV_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_PLCR].h_SrcHandle);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (pending & INTR_EN_TMR)
p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
+#endif
/* MAC events may belong to different partitions */
if (pending & INTR_EN_1G_MAC0)
--- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
@@ -802,6 +802,7 @@ int fm_mac_set_rx_pause_frames(
int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev,
bool en);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
int fm_rtc_enable(struct fm *fm_dev);
int fm_rtc_disable(struct fm *fm_dev);
@@ -819,6 +820,27 @@ int fm_rtc_set_alarm(struct fm *fm_dev,
int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
uint64_t fiper);
+#else
+static inline int fm_rtc_enable(struct fm *fm_dev) { return 0; }
+
+static inline int fm_rtc_disable(struct fm *fm_dev) { return 0; }
+
+static inline int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts) { return 0; }
+
+static inline int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts) { return 0; }
+
+static inline int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift)
+{ return 0; }
+
+static inline int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift)
+{ return 0; }
+
+static inline int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id,
+ uint64_t time) { return 0; }
+
+static inline int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
+ uint64_t fiper) { return 0; }
+#endif
int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev,
bool en);
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
@@ -695,11 +695,7 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode
}
}
-/* DPAA PTP timer was managed by ptp_qoriq driver in drivers/ptp/.
- * We will no longer manage it in sdk_fman driver and use related
- * APIs.
- */
-#if 0
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
/* Get the RTC base address and size */
memset(ids, 0, sizeof(ids));
if (WARN_ON(strlen("ptp-timer") >= sizeof(ids[0].name)))
@@ -941,6 +937,7 @@ static t_Error ConfigureFmDev(t_LnxWrpFm
if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmMuramBaseAddr, (uint64_t)p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM MURAM memory map"));
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (p_LnxWrpFmDev->fmRtcPhysBaseAddr)
{
dev_res = __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize, "fman-ptp-timer");
@@ -954,6 +951,7 @@ static t_Error ConfigureFmDev(t_LnxWrpFm
if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmRtcBaseAddr, (uint64_t)p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC memory map"));
}
+#endif
#if (DPAA_VERSION >= 11)
if (p_LnxWrpFmDev->fmVspPhysBaseAddr) {
@@ -1187,6 +1185,7 @@ static t_Error InitFmDev(t_LnxWrpFmDev
* FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_MURAM_ECC,FALSE);*/
}
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (p_LnxWrpFmDev->fmRtcBaseAddr)
{
t_FmRtcParams fmRtcParam;
@@ -1205,6 +1204,7 @@ static t_Error InitFmDev(t_LnxWrpFmDev
if (FM_RTC_Init(p_LnxWrpFmDev->h_RtcDev) != E_OK)
RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC"));
}
+#endif
return E_OK;
}
@@ -1219,8 +1219,10 @@ static void FreeFmDev(t_LnxWrpFmDev *p_
FreeFmPcdDev(p_LnxWrpFmDev);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (p_LnxWrpFmDev->h_RtcDev)
FM_RTC_Free(p_LnxWrpFmDev->h_RtcDev);
+#endif
if (p_LnxWrpFmDev->h_Dev)
FM_Free(p_LnxWrpFmDev->h_Dev);
@@ -1228,12 +1230,14 @@ static void FreeFmDev(t_LnxWrpFmDev *p_
if (p_LnxWrpFmDev->h_MuramDev)
FM_MURAM_Free(p_LnxWrpFmDev->h_MuramDev);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
if (p_LnxWrpFmDev->fmRtcBaseAddr)
{
SYS_UnregisterIoMap(p_LnxWrpFmDev->fmRtcBaseAddr);
devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmRtcBaseAddr));
__devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize);
}
+#endif
SYS_UnregisterIoMap(p_LnxWrpFmDev->fmMuramBaseAddr);
devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmMuramBaseAddr));
__devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize);
@@ -1463,6 +1467,7 @@ void * fm_get_handle(struct fm *fm)
}
EXPORT_SYMBOL(fm_get_handle);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
void * fm_get_rtc_handle(struct fm *fm)
{
t_LnxWrpFmDev *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
@@ -1470,6 +1475,7 @@ void * fm_get_rtc_handle(struct fm *fm)
return (void *)p_LnxWrpFmDev->h_RtcDev;
}
EXPORT_SYMBOL(fm_get_rtc_handle);
+#endif
struct fm_port * fm_port_bind (struct device *fm_port_dev)
{
@@ -2053,6 +2059,7 @@ int fm_mac_set_tx_pause_frames(struct fm
#endif
EXPORT_SYMBOL(fm_mac_set_tx_pause_frames);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
int fm_rtc_enable(struct fm *fm_dev)
{
int _errno;
@@ -2209,6 +2216,7 @@ int fm_rtc_disable_interrupt(struct fm *
}
EXPORT_SYMBOL(fm_rtc_disable_interrupt);
#endif
+#endif /* CONFIG_FSL_SDK_FMAN_RTC_API */
int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev, bool en)
{