Skip to content

Commit 4b69d87

Browse files
committed
Merge branch 'gianfar-ls1021a-ptp'
Yangbo Lu says: ==================== gianfar: Add PTP support for ls1021a platform This patchset is to enable ptp support for ls1021a platform. The endianness issue in gianfar driver and gianfar ptp driver must be fixed, and a 1588 timer node must be added into dts. Changes for v2: - Modified commit message - Added more reviewers ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 407353e + f54af12 commit 4b69d87

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

arch/arm/boot/dts/ls1021a.dtsi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@
457457
reg = <0x0 0x2d24000 0x0 0x4000>;
458458
};
459459

460+
ptp_clock@2d10e00 {
461+
compatible = "fsl,etsec-ptp";
462+
reg = <0x0 0x2d10e00 0x0 0xb0>;
463+
interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
464+
fsl,tclk-period = <5>;
465+
fsl,tmr-prsc = <2>;
466+
fsl,tmr-add = <0xaaaaaaab>;
467+
fsl,tmr-fiper1 = <999999990>;
468+
fsl,tmr-fiper2 = <99990>;
469+
fsl,max-adj = <499999999>;
470+
};
471+
460472
enet0: ethernet@2d10000 {
461473
compatible = "fsl,etsec2";
462474
device_type = "network";

drivers/net/ethernet/freescale/gianfar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
27062706
~0x7UL);
27072707

27082708
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
2709-
shhwtstamps.hwtstamp = ns_to_ktime(*ns);
2709+
shhwtstamps.hwtstamp = ns_to_ktime(be64_to_cpu(*ns));
27102710
skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);
27112711
skb_tstamp_tx(skb, &shhwtstamps);
27122712
gfar_clear_txbd_status(bdp);
@@ -3035,7 +3035,7 @@ static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
30353035
u64 *ns = (u64 *) skb->data;
30363036

30373037
memset(shhwtstamps, 0, sizeof(*shhwtstamps));
3038-
shhwtstamps->hwtstamp = ns_to_ktime(*ns);
3038+
shhwtstamps->hwtstamp = ns_to_ktime(be64_to_cpu(*ns));
30393039
}
30403040

30413041
if (priv->padding)

drivers/net/ethernet/freescale/gianfar_ptp.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,6 @@ static struct ptp_clock_info ptp_gianfar_caps = {
422422
.enable = ptp_gianfar_enable,
423423
};
424424

425-
/* OF device tree */
426-
427-
static int get_of_u32(struct device_node *node, char *str, u32 *val)
428-
{
429-
int plen;
430-
const u32 *prop = of_get_property(node, str, &plen);
431-
432-
if (!prop || plen != sizeof(*prop))
433-
return -1;
434-
*val = *prop;
435-
return 0;
436-
}
437-
438425
static int gianfar_ptp_probe(struct platform_device *dev)
439426
{
440427
struct device_node *node = dev->dev.of_node;
@@ -452,15 +439,21 @@ static int gianfar_ptp_probe(struct platform_device *dev)
452439

453440
etsects->caps = ptp_gianfar_caps;
454441

455-
if (get_of_u32(node, "fsl,cksel", &etsects->cksel))
442+
if (of_property_read_u32(node, "fsl,cksel", &etsects->cksel))
456443
etsects->cksel = DEFAULT_CKSEL;
457444

458-
if (get_of_u32(node, "fsl,tclk-period", &etsects->tclk_period) ||
459-
get_of_u32(node, "fsl,tmr-prsc", &etsects->tmr_prsc) ||
460-
get_of_u32(node, "fsl,tmr-add", &etsects->tmr_add) ||
461-
get_of_u32(node, "fsl,tmr-fiper1", &etsects->tmr_fiper1) ||
462-
get_of_u32(node, "fsl,tmr-fiper2", &etsects->tmr_fiper2) ||
463-
get_of_u32(node, "fsl,max-adj", &etsects->caps.max_adj)) {
445+
if (of_property_read_u32(node,
446+
"fsl,tclk-period", &etsects->tclk_period) ||
447+
of_property_read_u32(node,
448+
"fsl,tmr-prsc", &etsects->tmr_prsc) ||
449+
of_property_read_u32(node,
450+
"fsl,tmr-add", &etsects->tmr_add) ||
451+
of_property_read_u32(node,
452+
"fsl,tmr-fiper1", &etsects->tmr_fiper1) ||
453+
of_property_read_u32(node,
454+
"fsl,tmr-fiper2", &etsects->tmr_fiper2) ||
455+
of_property_read_u32(node,
456+
"fsl,max-adj", &etsects->caps.max_adj)) {
464457
pr_err("device tree node missing required elements\n");
465458
goto no_node;
466459
}

0 commit comments

Comments
 (0)