Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c750fc06 authored by Gilad Avidov's avatar Gilad Avidov
Browse files

msm: emac: Compensate the fractional ns inaccuracy



Compensate the loss of accurucy of fractional ns per clock cycle and
support the grandmaster mode.

Change-Id: I1fa073436c48c9cafe3992d39ba85b8e15467dbb
Acked-by: default avatarJie Luo <jluo@qti.qualcomm.com>
Signed-off-by: default avatarGilad Avidov <gavidov@codeaurora.org>
parent ccc80175
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -49,7 +49,16 @@ Optional properties:
- qcom,no-external-phy : Indicates there is no external PHY connected to EMAC.
			 Include this only if the EMAC is directly connected to
			 the peer end without EPHY.

- qcom,emac-ptp-grandmaster : Enable the PTP (1588) grandmaster mode.
			      Include this only if PTP (1588) is configured as
			      grandmaster.
- qcom,emac-ptp-frac-ns-adj : The vector table to adjust the fractional ns per
			      RTC clock cycle.
			     Include this only if there is accuracy loss of
			     fractional ns per RTC clock cycle. For individual
			     table entry, the first field indicates the RTC
			     reference clock rate. The second field indicates
			     the number of adjustment in 2 ^ -26 ns.
Example:
	emac0: qcom,emac@feb20000 {
		cell-index = <0>;
+5 −1
Original line number Diff line number Diff line
@@ -223,10 +223,14 @@ struct emac_hw {

	/* 1588 parameter */
	enum emac_ptp_clk_mode  ptp_clk_mode;
	u32                     rtc_ref_clkrate;
	enum emac_ptp_mode      ptp_mode;
	u32                     ptp_intr_mask;
	spinlock_t              ptp_lock;
	u32                     tstamp_rx_offset;
	u32                     tstamp_tx_offset;
	void                    *frac_ns_adj_tbl;
	u32                     frac_ns_adj_tbl_sz;
	s32                     frac_ns_adj;

	u32                 irq_mod;
	u32                 preamble;
+8 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@

/* EMAC_INT_STATUS */
#define DIS_INT                                              0x80000000
#define PTP_INT                                              0x40000000
#define RFD4_UR_INT                                          0x20000000
#define TX_PKT_INT3                                           0x4000000
#define TX_PKT_INT2                                           0x2000000
@@ -370,6 +371,9 @@
#define REAL_TIME_1_BMSK                                         0xffff
#define REAL_TIME_1_SHFT                                              0

/* EMAC_P1588_EXPANDED_INT_STATUS */
#define PPS_IN                                                     0x20

/* EMAC_P1588_RTC_EXPANDED_CONFIG */
#define RTC_READ_MODE                                              0x20
#define RTC_SNAPSHOT                                               0x10
@@ -387,6 +391,10 @@
/* EMAC_P1588_RTC_PRELOADED_1 */
#define RTC_PRELOADED_1_BMSK                                     0xffff

/* EMAC_P1588_GRAND_MASTER_CONFIG_0 */
#define GRANDMASTER_MODE                                           0x40
#define GM_PPS_SYNC                                                0x20

/* EMAC_QSERDES_COM_SYS_CLK_CTRL */
#define SYSCLK_CM                                                  0x10
#define SYSCLK_AC_COUPLE                                           0x08
+4 −0
Original line number Diff line number Diff line
@@ -887,6 +887,10 @@ void emac_hw_enable_intr(struct emac_hw *hw)
		emac_reg_w32(hw, EMAC_SGMII_PHY, irq_info->mask_reg,
			     irq_info->mask);
	}

	if (adpt->tstamp_en)
		emac_reg_w32(hw, EMAC_1588, EMAC_P1588_PTP_EXPANDED_INT_MASK,
			     hw->ptp_intr_mask);
	wmb();
}

+3 −3
Original line number Diff line number Diff line
@@ -1082,6 +1082,8 @@ static irqreturn_t emac_interrupt(int irq, void *data)
			break;
		}

		if (status & PTP_INT)
			emac_ptp_intr(hw);
	} while (--max_ints > 0);

	/* enable the interrupt */
@@ -2752,10 +2754,8 @@ static int emac_probe(struct platform_device *pdev)
	adpt->tpdesc_size = EMAC_TPDESC_SIZE;
	adpt->rfdesc_size = EMAC_RFDESC_SIZE;

	if (adpt->tstamp_en) {
		hw->rtc_ref_clkrate = DEFAULT_RTC_REF_CLKRATE;
	if (adpt->tstamp_en)
		SET_HW_FLAG(PTP_CAP);
	}

	/* init netdev */
	netdev->netdev_ops = &emac_netdev_ops;
Loading