hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/ethernet/microchip/lan743x_ptp.c
....@@ -2,16 +2,18 @@
22 /* Copyright (C) 2018 Microchip Technology Inc. */
33
44 #include <linux/netdevice.h>
5
-#include "lan743x_main.h"
65
76 #include <linux/ptp_clock_kernel.h>
87 #include <linux/module.h>
98 #include <linux/pci.h>
109 #include <linux/net_tstamp.h>
10
+#include "lan743x_main.h"
1111
1212 #include "lan743x_ptp.h"
1313
14
-#define LAN743X_NUMBER_OF_GPIO (12)
14
+#define LAN743X_LED0_ENABLE 20 /* LED0 offset in HW_CFG */
15
+#define LAN743X_LED_ENABLE(pin) BIT(LAN743X_LED0_ENABLE + (pin))
16
+
1517 #define LAN743X_PTP_MAX_FREQ_ADJ_IN_PPB (31249999)
1618 #define LAN743X_PTP_MAX_FINE_ADJ_IN_SCALED_PPM (2047999934)
1719
....@@ -139,19 +141,20 @@
139141 spin_unlock_bh(&ptp->tx_ts_lock);
140142 }
141143
142
-static int lan743x_ptp_reserve_event_ch(struct lan743x_adapter *adapter)
144
+static int lan743x_ptp_reserve_event_ch(struct lan743x_adapter *adapter,
145
+ int event_channel)
143146 {
144147 struct lan743x_ptp *ptp = &adapter->ptp;
145148 int result = -ENODEV;
146
- int index = 0;
147149
148150 mutex_lock(&ptp->command_lock);
149
- for (index = 0; index < LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS; index++) {
150
- if (!(test_bit(index, &ptp->used_event_ch))) {
151
- ptp->used_event_ch |= BIT(index);
152
- result = index;
153
- break;
154
- }
151
+ if (!(test_bit(event_channel, &ptp->used_event_ch))) {
152
+ ptp->used_event_ch |= BIT(event_channel);
153
+ result = event_channel;
154
+ } else {
155
+ netif_warn(adapter, drv, adapter->netdev,
156
+ "attempted to reserved a used event_channel = %d\n",
157
+ event_channel);
155158 }
156159 mutex_unlock(&ptp->command_lock);
157160 return result;
....@@ -179,12 +182,62 @@
179182 static void lan743x_ptp_clock_step(struct lan743x_adapter *adapter,
180183 s64 time_step_ns);
181184
185
+static void lan743x_led_mux_enable(struct lan743x_adapter *adapter,
186
+ int pin, bool enable)
187
+{
188
+ struct lan743x_ptp *ptp = &adapter->ptp;
189
+
190
+ if (ptp->leds_multiplexed &&
191
+ ptp->led_enabled[pin]) {
192
+ u32 val = lan743x_csr_read(adapter, HW_CFG);
193
+
194
+ if (enable)
195
+ val |= LAN743X_LED_ENABLE(pin);
196
+ else
197
+ val &= ~LAN743X_LED_ENABLE(pin);
198
+
199
+ lan743x_csr_write(adapter, HW_CFG, val);
200
+ }
201
+}
202
+
203
+static void lan743x_led_mux_save(struct lan743x_adapter *adapter)
204
+{
205
+ struct lan743x_ptp *ptp = &adapter->ptp;
206
+ u32 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_;
207
+
208
+ if (id_rev == ID_REV_ID_LAN7430_) {
209
+ int i;
210
+ u32 val = lan743x_csr_read(adapter, HW_CFG);
211
+
212
+ for (i = 0; i < LAN7430_N_LED; i++) {
213
+ bool led_enabled = (val & LAN743X_LED_ENABLE(i)) != 0;
214
+
215
+ ptp->led_enabled[i] = led_enabled;
216
+ }
217
+ ptp->leds_multiplexed = true;
218
+ } else {
219
+ ptp->leds_multiplexed = false;
220
+ }
221
+}
222
+
223
+static void lan743x_led_mux_restore(struct lan743x_adapter *adapter)
224
+{
225
+ u32 id_rev = adapter->csr.id_rev & ID_REV_ID_MASK_;
226
+
227
+ if (id_rev == ID_REV_ID_LAN7430_) {
228
+ int i;
229
+
230
+ for (i = 0; i < LAN7430_N_LED; i++)
231
+ lan743x_led_mux_enable(adapter, i, true);
232
+ }
233
+}
234
+
182235 static int lan743x_gpio_rsrv_ptp_out(struct lan743x_adapter *adapter,
183
- int bit, int ptp_channel)
236
+ int pin, int event_channel)
184237 {
185238 struct lan743x_gpio *gpio = &adapter->gpio;
186239 unsigned long irq_flags = 0;
187
- int bit_mask = BIT(bit);
240
+ int bit_mask = BIT(pin);
188241 int ret = -EBUSY;
189242
190243 spin_lock_irqsave(&gpio->gpio_lock, irq_flags);
....@@ -194,41 +247,44 @@
194247 gpio->output_bits |= bit_mask;
195248 gpio->ptp_bits |= bit_mask;
196249
250
+ /* assign pin to GPIO function */
251
+ lan743x_led_mux_enable(adapter, pin, false);
252
+
197253 /* set as output, and zero initial value */
198
- gpio->gpio_cfg0 |= GPIO_CFG0_GPIO_DIR_BIT_(bit);
199
- gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DATA_BIT_(bit);
254
+ gpio->gpio_cfg0 |= GPIO_CFG0_GPIO_DIR_BIT_(pin);
255
+ gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DATA_BIT_(pin);
200256 lan743x_csr_write(adapter, GPIO_CFG0, gpio->gpio_cfg0);
201257
202258 /* enable gpio, and set buffer type to push pull */
203
- gpio->gpio_cfg1 &= ~GPIO_CFG1_GPIOEN_BIT_(bit);
204
- gpio->gpio_cfg1 |= GPIO_CFG1_GPIOBUF_BIT_(bit);
259
+ gpio->gpio_cfg1 &= ~GPIO_CFG1_GPIOEN_BIT_(pin);
260
+ gpio->gpio_cfg1 |= GPIO_CFG1_GPIOBUF_BIT_(pin);
205261 lan743x_csr_write(adapter, GPIO_CFG1, gpio->gpio_cfg1);
206262
207263 /* set 1588 polarity to high */
208
- gpio->gpio_cfg2 |= GPIO_CFG2_1588_POL_BIT_(bit);
264
+ gpio->gpio_cfg2 |= GPIO_CFG2_1588_POL_BIT_(pin);
209265 lan743x_csr_write(adapter, GPIO_CFG2, gpio->gpio_cfg2);
210266
211
- if (!ptp_channel) {
267
+ if (event_channel == 0) {
212268 /* use channel A */
213
- gpio->gpio_cfg3 &= ~GPIO_CFG3_1588_CH_SEL_BIT_(bit);
269
+ gpio->gpio_cfg3 &= ~GPIO_CFG3_1588_CH_SEL_BIT_(pin);
214270 } else {
215271 /* use channel B */
216
- gpio->gpio_cfg3 |= GPIO_CFG3_1588_CH_SEL_BIT_(bit);
272
+ gpio->gpio_cfg3 |= GPIO_CFG3_1588_CH_SEL_BIT_(pin);
217273 }
218
- gpio->gpio_cfg3 |= GPIO_CFG3_1588_OE_BIT_(bit);
274
+ gpio->gpio_cfg3 |= GPIO_CFG3_1588_OE_BIT_(pin);
219275 lan743x_csr_write(adapter, GPIO_CFG3, gpio->gpio_cfg3);
220276
221
- ret = bit;
277
+ ret = pin;
222278 }
223279 spin_unlock_irqrestore(&gpio->gpio_lock, irq_flags);
224280 return ret;
225281 }
226282
227
-static void lan743x_gpio_release(struct lan743x_adapter *adapter, int bit)
283
+static void lan743x_gpio_release(struct lan743x_adapter *adapter, int pin)
228284 {
229285 struct lan743x_gpio *gpio = &adapter->gpio;
230286 unsigned long irq_flags = 0;
231
- int bit_mask = BIT(bit);
287
+ int bit_mask = BIT(pin);
232288
233289 spin_lock_irqsave(&gpio->gpio_lock, irq_flags);
234290 if (gpio->used_bits & bit_mask) {
....@@ -239,21 +295,24 @@
239295 if (gpio->ptp_bits & bit_mask) {
240296 gpio->ptp_bits &= ~bit_mask;
241297 /* disable ptp output */
242
- gpio->gpio_cfg3 &= ~GPIO_CFG3_1588_OE_BIT_(bit);
298
+ gpio->gpio_cfg3 &= ~GPIO_CFG3_1588_OE_BIT_(pin);
243299 lan743x_csr_write(adapter, GPIO_CFG3,
244300 gpio->gpio_cfg3);
245301 }
246302 /* release gpio output */
247303
248304 /* disable gpio */
249
- gpio->gpio_cfg1 |= GPIO_CFG1_GPIOEN_BIT_(bit);
250
- gpio->gpio_cfg1 &= ~GPIO_CFG1_GPIOBUF_BIT_(bit);
305
+ gpio->gpio_cfg1 |= GPIO_CFG1_GPIOEN_BIT_(pin);
306
+ gpio->gpio_cfg1 &= ~GPIO_CFG1_GPIOBUF_BIT_(pin);
251307 lan743x_csr_write(adapter, GPIO_CFG1, gpio->gpio_cfg1);
252308
253309 /* reset back to input */
254
- gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DIR_BIT_(bit);
255
- gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DATA_BIT_(bit);
310
+ gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DIR_BIT_(pin);
311
+ gpio->gpio_cfg0 &= ~GPIO_CFG0_GPIO_DATA_BIT_(pin);
256312 lan743x_csr_write(adapter, GPIO_CFG0, gpio->gpio_cfg0);
313
+
314
+ /* assign pin to original function */
315
+ lan743x_led_mux_enable(adapter, pin, true);
257316 }
258317 }
259318 spin_unlock_irqrestore(&gpio->gpio_lock, irq_flags);
....@@ -391,89 +450,95 @@
391450 return 0;
392451 }
393452
394
-static void lan743x_ptp_perout_off(struct lan743x_adapter *adapter)
453
+static void lan743x_ptp_perout_off(struct lan743x_adapter *adapter,
454
+ unsigned int index)
395455 {
396456 struct lan743x_ptp *ptp = &adapter->ptp;
397457 u32 general_config = 0;
458
+ struct lan743x_ptp_perout *perout = &ptp->perout[index];
398459
399
- if (ptp->perout_gpio_bit >= 0) {
400
- lan743x_gpio_release(adapter, ptp->perout_gpio_bit);
401
- ptp->perout_gpio_bit = -1;
460
+ if (perout->gpio_pin >= 0) {
461
+ lan743x_gpio_release(adapter, perout->gpio_pin);
462
+ perout->gpio_pin = -1;
402463 }
403464
404
- if (ptp->perout_event_ch >= 0) {
465
+ if (perout->event_ch >= 0) {
405466 /* set target to far in the future, effectively disabling it */
406467 lan743x_csr_write(adapter,
407
- PTP_CLOCK_TARGET_SEC_X(ptp->perout_event_ch),
468
+ PTP_CLOCK_TARGET_SEC_X(perout->event_ch),
408469 0xFFFF0000);
409470 lan743x_csr_write(adapter,
410
- PTP_CLOCK_TARGET_NS_X(ptp->perout_event_ch),
471
+ PTP_CLOCK_TARGET_NS_X(perout->event_ch),
411472 0);
412473
413474 general_config = lan743x_csr_read(adapter, PTP_GENERAL_CONFIG);
414475 general_config |= PTP_GENERAL_CONFIG_RELOAD_ADD_X_
415
- (ptp->perout_event_ch);
476
+ (perout->event_ch);
416477 lan743x_csr_write(adapter, PTP_GENERAL_CONFIG, general_config);
417
- lan743x_ptp_release_event_ch(adapter, ptp->perout_event_ch);
418
- ptp->perout_event_ch = -1;
478
+ lan743x_ptp_release_event_ch(adapter, perout->event_ch);
479
+ perout->event_ch = -1;
419480 }
420481 }
421482
422483 static int lan743x_ptp_perout(struct lan743x_adapter *adapter, int on,
423
- struct ptp_perout_request *perout)
484
+ struct ptp_perout_request *perout_request)
424485 {
425486 struct lan743x_ptp *ptp = &adapter->ptp;
426487 u32 period_sec = 0, period_nsec = 0;
427488 u32 start_sec = 0, start_nsec = 0;
428489 u32 general_config = 0;
429490 int pulse_width = 0;
430
- int perout_bit = 0;
491
+ int perout_pin = 0;
492
+ unsigned int index = perout_request->index;
493
+ struct lan743x_ptp_perout *perout = &ptp->perout[index];
431494
432
- if (!on) {
433
- lan743x_ptp_perout_off(adapter);
495
+ /* Reject requests with unsupported flags */
496
+ if (perout_request->flags)
497
+ return -EOPNOTSUPP;
498
+
499
+ if (on) {
500
+ perout_pin = ptp_find_pin(ptp->ptp_clock, PTP_PF_PEROUT,
501
+ perout_request->index);
502
+ if (perout_pin < 0)
503
+ return -EBUSY;
504
+ } else {
505
+ lan743x_ptp_perout_off(adapter, index);
434506 return 0;
435507 }
436508
437
- if (ptp->perout_event_ch >= 0 ||
438
- ptp->perout_gpio_bit >= 0) {
509
+ if (perout->event_ch >= 0 ||
510
+ perout->gpio_pin >= 0) {
439511 /* already on, turn off first */
440
- lan743x_ptp_perout_off(adapter);
512
+ lan743x_ptp_perout_off(adapter, index);
441513 }
442514
443
- ptp->perout_event_ch = lan743x_ptp_reserve_event_ch(adapter);
444
- if (ptp->perout_event_ch < 0) {
515
+ perout->event_ch = lan743x_ptp_reserve_event_ch(adapter, index);
516
+
517
+ if (perout->event_ch < 0) {
445518 netif_warn(adapter, drv, adapter->netdev,
446
- "Failed to reserve event channel for PEROUT\n");
519
+ "Failed to reserve event channel %d for PEROUT\n",
520
+ index);
447521 goto failed;
448522 }
449523
450
- switch (adapter->csr.id_rev & ID_REV_ID_MASK_) {
451
- case ID_REV_ID_LAN7430_:
452
- perout_bit = 2;/* GPIO 2 is preferred on EVB LAN7430 */
453
- break;
454
- case ID_REV_ID_LAN7431_:
455
- perout_bit = 4;/* GPIO 4 is preferred on EVB LAN7431 */
456
- break;
457
- }
524
+ perout->gpio_pin = lan743x_gpio_rsrv_ptp_out(adapter,
525
+ perout_pin,
526
+ perout->event_ch);
458527
459
- ptp->perout_gpio_bit = lan743x_gpio_rsrv_ptp_out(adapter,
460
- perout_bit,
461
- ptp->perout_event_ch);
462
-
463
- if (ptp->perout_gpio_bit < 0) {
528
+ if (perout->gpio_pin < 0) {
464529 netif_warn(adapter, drv, adapter->netdev,
465530 "Failed to reserve gpio %d for PEROUT\n",
466
- perout_bit);
531
+ perout_pin);
467532 goto failed;
468533 }
469534
470
- start_sec = perout->start.sec;
471
- start_sec += perout->start.nsec / 1000000000;
472
- start_nsec = perout->start.nsec % 1000000000;
535
+ start_sec = perout_request->start.sec;
536
+ start_sec += perout_request->start.nsec / 1000000000;
537
+ start_nsec = perout_request->start.nsec % 1000000000;
473538
474
- period_sec = perout->period.sec;
475
- period_sec += perout->period.nsec / 1000000000;
476
- period_nsec = perout->period.nsec % 1000000000;
539
+ period_sec = perout_request->period.sec;
540
+ period_sec += perout_request->period.nsec / 1000000000;
541
+ period_nsec = perout_request->period.nsec % 1000000000;
477542
478543 if (period_sec == 0) {
479544 if (period_nsec >= 400000000) {
....@@ -499,41 +564,41 @@
499564
500565 /* turn off by setting target far in future */
501566 lan743x_csr_write(adapter,
502
- PTP_CLOCK_TARGET_SEC_X(ptp->perout_event_ch),
567
+ PTP_CLOCK_TARGET_SEC_X(perout->event_ch),
503568 0xFFFF0000);
504569 lan743x_csr_write(adapter,
505
- PTP_CLOCK_TARGET_NS_X(ptp->perout_event_ch), 0);
570
+ PTP_CLOCK_TARGET_NS_X(perout->event_ch), 0);
506571
507572 /* Configure to pulse every period */
508573 general_config = lan743x_csr_read(adapter, PTP_GENERAL_CONFIG);
509574 general_config &= ~(PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_
510
- (ptp->perout_event_ch));
575
+ (perout->event_ch));
511576 general_config |= PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_
512
- (ptp->perout_event_ch, pulse_width);
577
+ (perout->event_ch, pulse_width);
513578 general_config &= ~PTP_GENERAL_CONFIG_RELOAD_ADD_X_
514
- (ptp->perout_event_ch);
579
+ (perout->event_ch);
515580 lan743x_csr_write(adapter, PTP_GENERAL_CONFIG, general_config);
516581
517582 /* set the reload to one toggle cycle */
518583 lan743x_csr_write(adapter,
519
- PTP_CLOCK_TARGET_RELOAD_SEC_X(ptp->perout_event_ch),
584
+ PTP_CLOCK_TARGET_RELOAD_SEC_X(perout->event_ch),
520585 period_sec);
521586 lan743x_csr_write(adapter,
522
- PTP_CLOCK_TARGET_RELOAD_NS_X(ptp->perout_event_ch),
587
+ PTP_CLOCK_TARGET_RELOAD_NS_X(perout->event_ch),
523588 period_nsec);
524589
525590 /* set the start time */
526591 lan743x_csr_write(adapter,
527
- PTP_CLOCK_TARGET_SEC_X(ptp->perout_event_ch),
592
+ PTP_CLOCK_TARGET_SEC_X(perout->event_ch),
528593 start_sec);
529594 lan743x_csr_write(adapter,
530
- PTP_CLOCK_TARGET_NS_X(ptp->perout_event_ch),
595
+ PTP_CLOCK_TARGET_NS_X(perout->event_ch),
531596 start_nsec);
532597
533598 return 0;
534599
535600 failed:
536
- lan743x_ptp_perout_off(adapter);
601
+ lan743x_ptp_perout_off(adapter, index);
537602 return -ENODEV;
538603 }
539604
....@@ -550,7 +615,7 @@
550615 case PTP_CLK_REQ_EXTTS:
551616 return -EINVAL;
552617 case PTP_CLK_REQ_PEROUT:
553
- if (request->perout.index == 0)
618
+ if (request->perout.index < ptpci->n_per_out)
554619 return lan743x_ptp_perout(adapter, on,
555620 &request->perout);
556621 return -EINVAL;
....@@ -566,6 +631,29 @@
566631 netif_err(adapter, drv, adapter->netdev, "request == NULL\n");
567632 }
568633 return 0;
634
+}
635
+
636
+static int lan743x_ptpci_verify_pin_config(struct ptp_clock_info *ptp,
637
+ unsigned int pin,
638
+ enum ptp_pin_function func,
639
+ unsigned int chan)
640
+{
641
+ int result = 0;
642
+
643
+ /* Confirm the requested function is supported. Parameter
644
+ * validation is done by the caller.
645
+ */
646
+ switch (func) {
647
+ case PTP_PF_NONE:
648
+ case PTP_PF_PEROUT:
649
+ break;
650
+ case PTP_PF_EXTTS:
651
+ case PTP_PF_PHYSYNC:
652
+ default:
653
+ result = -1;
654
+ break;
655
+ }
656
+ return result;
569657 }
570658
571659 static long lan743x_ptpci_do_aux_work(struct ptp_clock_info *ptpci)
....@@ -861,12 +949,19 @@
861949 int lan743x_ptp_init(struct lan743x_adapter *adapter)
862950 {
863951 struct lan743x_ptp *ptp = &adapter->ptp;
952
+ int i;
864953
865954 mutex_init(&ptp->command_lock);
866955 spin_lock_init(&ptp->tx_ts_lock);
867956 ptp->used_event_ch = 0;
868
- ptp->perout_event_ch = -1;
869
- ptp->perout_gpio_bit = -1;
957
+
958
+ for (i = 0; i < LAN743X_PTP_N_EVENT_CHAN; i++) {
959
+ ptp->perout[i].event_ch = -1;
960
+ ptp->perout[i].gpio_pin = -1;
961
+ }
962
+
963
+ lan743x_led_mux_save(adapter);
964
+
870965 return 0;
871966 }
872967
....@@ -875,6 +970,8 @@
875970 struct lan743x_ptp *ptp = &adapter->ptp;
876971 int ret = -ENODEV;
877972 u32 temp;
973
+ int i;
974
+ int n_pins;
878975
879976 lan743x_ptp_reset(adapter);
880977 lan743x_ptp_sync_to_system_clock(adapter);
....@@ -890,10 +987,32 @@
890987 if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK))
891988 return 0;
892989
893
- snprintf(ptp->pin_config[0].name, 32, "lan743x_ptp_pin_0");
894
- ptp->pin_config[0].index = 0;
895
- ptp->pin_config[0].func = PTP_PF_PEROUT;
896
- ptp->pin_config[0].chan = 0;
990
+ switch (adapter->csr.id_rev & ID_REV_ID_MASK_) {
991
+ case ID_REV_ID_LAN7430_:
992
+ n_pins = LAN7430_N_GPIO;
993
+ break;
994
+ case ID_REV_ID_LAN7431_:
995
+ n_pins = LAN7431_N_GPIO;
996
+ break;
997
+ default:
998
+ netif_warn(adapter, drv, adapter->netdev,
999
+ "Unknown LAN743x (%08x). Assuming no GPIO\n",
1000
+ adapter->csr.id_rev);
1001
+ n_pins = 0;
1002
+ break;
1003
+ }
1004
+
1005
+ if (n_pins > LAN743X_PTP_N_GPIO)
1006
+ n_pins = LAN743X_PTP_N_GPIO;
1007
+
1008
+ for (i = 0; i < n_pins; i++) {
1009
+ struct ptp_pin_desc *ptp_pin = &ptp->pin_config[i];
1010
+
1011
+ snprintf(ptp_pin->name,
1012
+ sizeof(ptp_pin->name), "lan743x_ptp_pin_%02d", i);
1013
+ ptp_pin->index = i;
1014
+ ptp_pin->func = PTP_PF_NONE;
1015
+ }
8971016
8981017 ptp->ptp_clock_info.owner = THIS_MODULE;
8991018 snprintf(ptp->ptp_clock_info.name, 16, "%pm",
....@@ -901,10 +1020,10 @@
9011020 ptp->ptp_clock_info.max_adj = LAN743X_PTP_MAX_FREQ_ADJ_IN_PPB;
9021021 ptp->ptp_clock_info.n_alarm = 0;
9031022 ptp->ptp_clock_info.n_ext_ts = 0;
904
- ptp->ptp_clock_info.n_per_out = 1;
905
- ptp->ptp_clock_info.n_pins = 0;
1023
+ ptp->ptp_clock_info.n_per_out = LAN743X_PTP_N_EVENT_CHAN;
1024
+ ptp->ptp_clock_info.n_pins = n_pins;
9061025 ptp->ptp_clock_info.pps = 0;
907
- ptp->ptp_clock_info.pin_config = NULL;
1026
+ ptp->ptp_clock_info.pin_config = ptp->pin_config;
9081027 ptp->ptp_clock_info.adjfine = lan743x_ptpci_adjfine;
9091028 ptp->ptp_clock_info.adjfreq = lan743x_ptpci_adjfreq;
9101029 ptp->ptp_clock_info.adjtime = lan743x_ptpci_adjtime;
....@@ -913,7 +1032,7 @@
9131032 ptp->ptp_clock_info.settime64 = lan743x_ptpci_settime64;
9141033 ptp->ptp_clock_info.enable = lan743x_ptpci_enable;
9151034 ptp->ptp_clock_info.do_aux_work = lan743x_ptpci_do_aux_work;
916
- ptp->ptp_clock_info.verify = NULL;
1035
+ ptp->ptp_clock_info.verify = lan743x_ptpci_verify_pin_config;
9171036
9181037 ptp->ptp_clock = ptp_clock_register(&ptp->ptp_clock_info,
9191038 &adapter->pdev->dev);
....@@ -939,7 +1058,7 @@
9391058 int index;
9401059
9411060 if (IS_ENABLED(CONFIG_PTP_1588_CLOCK) &&
942
- ptp->flags & PTP_FLAG_PTP_CLOCK_REGISTERED) {
1061
+ (ptp->flags & PTP_FLAG_PTP_CLOCK_REGISTERED)) {
9431062 ptp_clock_unregister(ptp->ptp_clock);
9441063 ptp->ptp_clock = NULL;
9451064 ptp->flags &= ~PTP_FLAG_PTP_CLOCK_REGISTERED;
....@@ -963,8 +1082,7 @@
9631082 index++) {
9641083 struct sk_buff *skb = ptp->tx_ts_skb_queue[index];
9651084
966
- if (skb)
967
- dev_kfree_skb(skb);
1085
+ dev_kfree_skb(skb);
9681086 ptp->tx_ts_skb_queue[index] = NULL;
9691087 ptp->tx_ts_seconds_queue[index] = 0;
9701088 ptp->tx_ts_nseconds_queue[index] = 0;
....@@ -974,11 +1092,13 @@
9741092 ptp->pending_tx_timestamps = 0;
9751093 spin_unlock_bh(&ptp->tx_ts_lock);
9761094
1095
+ lan743x_led_mux_restore(adapter);
1096
+
9771097 lan743x_ptp_disable(adapter);
9781098 }
9791099
980
-void lan743x_ptp_set_sync_ts_insert(struct lan743x_adapter *adapter,
981
- bool ts_insert_enable)
1100
+static void lan743x_ptp_set_sync_ts_insert(struct lan743x_adapter *adapter,
1101
+ bool ts_insert_enable)
9821102 {
9831103 u32 ptp_tx_mod = lan743x_csr_read(adapter, PTP_TX_MOD);
9841104
....@@ -1145,6 +1265,9 @@
11451265
11461266 lan743x_ptp_set_sync_ts_insert(adapter, true);
11471267 break;
1268
+ case HWTSTAMP_TX_ONESTEP_P2P:
1269
+ ret = -ERANGE;
1270
+ break;
11481271 default:
11491272 netif_warn(adapter, drv, adapter->netdev,
11501273 " tx_type = %d, UNKNOWN\n", config.tx_type);