Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'PTP_CLK-pin-configuration-for-SJA1105-DSA-driver'

Vladimir Oltean says:

====================
PTP_CLK pin configuration for SJA1105 DSA driver

This series adds support for the PTP_CLK pin on SJA1105 to be configured
via the PTP subsystem, in the "periodic output" and "external timestamp
input" modes.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+355 -68
+5
drivers/net/dsa/sja1105/sja1105.h
··· 38 38 u64 config; 39 39 u64 sgmii; 40 40 u64 rmii_pll1; 41 + u64 ptppinst; 42 + u64 ptppindur; 41 43 u64 ptp_control; 42 44 u64 ptpclkval; 43 45 u64 ptpclkrate; 44 46 u64 ptpclkcorp; 47 + u64 ptpsyncts; 45 48 u64 ptpschtm; 46 49 u64 ptpegr_ts[SJA1105_NUM_PORTS]; 47 50 u64 pad_mii_tx[SJA1105_NUM_PORTS]; ··· 216 213 size_t sja1105_vlan_lookup_entry_packing(void *buf, void *entry_ptr, 217 214 enum packing_op op); 218 215 size_t sja1105pqrs_mac_config_entry_packing(void *buf, void *entry_ptr, 216 + enum packing_op op); 217 + size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr, 219 218 enum packing_op op); 220 219 221 220 #endif
+23 -1
drivers/net/dsa/sja1105/sja1105_dynamic_config.c
··· 124 124 #define SJA1105ET_SIZE_GENERAL_PARAMS_DYN_CMD \ 125 125 SJA1105_SIZE_DYN_CMD 126 126 127 + #define SJA1105PQRS_SIZE_AVB_PARAMS_DYN_CMD \ 128 + (SJA1105_SIZE_DYN_CMD + SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY) 129 + 127 130 #define SJA1105_MAX_DYN_CMD_SIZE \ 128 131 SJA1105PQRS_SIZE_MAC_CONFIG_DYN_CMD 129 132 ··· 484 481 return 0; 485 482 } 486 483 484 + static void 485 + sja1105pqrs_avb_params_cmd_packing(void *buf, struct sja1105_dyn_cmd *cmd, 486 + enum packing_op op) 487 + { 488 + u8 *p = buf + SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY; 489 + const int size = SJA1105_SIZE_DYN_CMD; 490 + 491 + sja1105_packing(p, &cmd->valid, 31, 31, size, op); 492 + sja1105_packing(p, &cmd->errors, 30, 30, size, op); 493 + sja1105_packing(p, &cmd->rdwrset, 29, 29, size, op); 494 + } 495 + 487 496 #define OP_READ BIT(0) 488 497 #define OP_WRITE BIT(1) 489 498 #define OP_DEL BIT(2) ··· 625 610 .addr = 0x38, 626 611 }, 627 612 [BLK_IDX_L2_FORWARDING_PARAMS] = {0}, 628 - [BLK_IDX_AVB_PARAMS] = {0}, 613 + [BLK_IDX_AVB_PARAMS] = { 614 + .entry_packing = sja1105pqrs_avb_params_entry_packing, 615 + .cmd_packing = sja1105pqrs_avb_params_cmd_packing, 616 + .max_entry_count = SJA1105_MAX_AVB_PARAMS_COUNT, 617 + .access = (OP_READ | OP_WRITE), 618 + .packed_size = SJA1105PQRS_SIZE_AVB_PARAMS_DYN_CMD, 619 + .addr = 0x8003, 620 + }, 629 621 [BLK_IDX_GENERAL_PARAMS] = { 630 622 .entry_packing = sja1105et_general_params_entry_packing, 631 623 .cmd_packing = sja1105et_general_params_cmd_packing,
+40
drivers/net/dsa/sja1105/sja1105_main.c
··· 479 479 return 0; 480 480 } 481 481 482 + static int sja1105_init_avb_params(struct sja1105_private *priv) 483 + { 484 + struct sja1105_avb_params_entry *avb; 485 + struct sja1105_table *table; 486 + 487 + table = &priv->static_config.tables[BLK_IDX_AVB_PARAMS]; 488 + 489 + /* Discard previous AVB Parameters Table */ 490 + if (table->entry_count) { 491 + kfree(table->entries); 492 + table->entry_count = 0; 493 + } 494 + 495 + table->entries = kcalloc(SJA1105_MAX_AVB_PARAMS_COUNT, 496 + table->ops->unpacked_entry_size, GFP_KERNEL); 497 + if (!table->entries) 498 + return -ENOMEM; 499 + 500 + table->entry_count = SJA1105_MAX_AVB_PARAMS_COUNT; 501 + 502 + avb = table->entries; 503 + 504 + /* Configure the MAC addresses for meta frames */ 505 + avb->destmeta = SJA1105_META_DMAC; 506 + avb->srcmeta = SJA1105_META_SMAC; 507 + /* On P/Q/R/S, configure the direction of the PTP_CLK pin as input by 508 + * default. This is because there might be boards with a hardware 509 + * layout where enabling the pin as output might cause an electrical 510 + * clash. On E/T the pin is always an output, which the board designers 511 + * probably already knew, so even if there are going to be electrical 512 + * issues, there's nothing we can do. 513 + */ 514 + avb->cas_master = false; 515 + 516 + return 0; 517 + } 518 + 482 519 #define SJA1105_RATE_MBPS(speed) (((speed) * 64000) / 1000) 483 520 484 521 static void sja1105_setup_policer(struct sja1105_l2_policing_entry *policing, ··· 604 567 if (rc < 0) 605 568 return rc; 606 569 rc = sja1105_init_general_params(priv); 570 + if (rc < 0) 571 + return rc; 572 + rc = sja1105_init_avb_params(priv); 607 573 if (rc < 0) 608 574 return rc; 609 575
+247 -38
drivers/net/dsa/sja1105/sja1105_ptp.c
··· 14 14 #define SJA1105_MAX_ADJ_PPB 32000000 15 15 #define SJA1105_SIZE_PTP_CMD 4 16 16 17 + /* PTPSYNCTS has no interrupt or update mechanism, because the intended 18 + * hardware use case is for the timestamp to be collected synchronously, 19 + * immediately after the CAS_MASTER SJA1105 switch has triggered a CASSYNC 20 + * pulse on the PTP_CLK pin. When used as a generic extts source, it needs 21 + * polling and a comparison with the old value. The polling interval is just 22 + * the Nyquist rate of a canonical PPS input (e.g. from a GPS module). 23 + * Anything of higher frequency than 1 Hz will be lost, since there is no 24 + * timestamp FIFO. 25 + */ 26 + #define SJA1105_EXTTS_INTERVAL (HZ / 2) 27 + 17 28 /* This range is actually +/- SJA1105_MAX_ADJ_PPB 18 29 * divided by 1000 (ppb -> ppm) and with a 16-bit 19 30 * "fractional" part (actually fixed point). ··· 50 39 PTP_SET_MODE = 0, 51 40 }; 52 41 42 + #define extts_to_data(d) \ 43 + container_of((d), struct sja1105_ptp_data, extts_work) 53 44 #define ptp_caps_to_data(d) \ 54 45 container_of((d), struct sja1105_ptp_data, caps) 55 46 #define ptp_data_to_sja1105(d) \ 56 47 container_of((d), struct sja1105_private, ptp_data) 57 - 58 - static int sja1105_init_avb_params(struct sja1105_private *priv, 59 - bool on) 60 - { 61 - struct sja1105_avb_params_entry *avb; 62 - struct sja1105_table *table; 63 - 64 - table = &priv->static_config.tables[BLK_IDX_AVB_PARAMS]; 65 - 66 - /* Discard previous AVB Parameters Table */ 67 - if (table->entry_count) { 68 - kfree(table->entries); 69 - table->entry_count = 0; 70 - } 71 - 72 - /* Configure the reception of meta frames only if requested */ 73 - if (!on) 74 - return 0; 75 - 76 - table->entries = kcalloc(SJA1105_MAX_AVB_PARAMS_COUNT, 77 - table->ops->unpacked_entry_size, GFP_KERNEL); 78 - if (!table->entries) 79 - return -ENOMEM; 80 - 81 - table->entry_count = SJA1105_MAX_AVB_PARAMS_COUNT; 82 - 83 - avb = table->entries; 84 - 85 - avb->destmeta = SJA1105_META_DMAC; 86 - avb->srcmeta = SJA1105_META_SMAC; 87 - 88 - return 0; 89 - } 90 48 91 49 /* Must be called only with priv->tagger_data.state bit 92 50 * SJA1105_HWTS_RX_EN cleared ··· 66 86 struct sja1105_ptp_data *ptp_data = &priv->ptp_data; 67 87 struct sja1105_general_params_entry *general_params; 68 88 struct sja1105_table *table; 69 - int rc; 70 89 71 90 table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS]; 72 91 general_params = table->entries; 73 92 general_params->send_meta1 = on; 74 93 general_params->send_meta0 = on; 75 - 76 - rc = sja1105_init_avb_params(priv, on); 77 - if (rc < 0) 78 - return rc; 79 94 80 95 /* Initialize the meta state machine to a known state */ 81 96 if (priv->tagger_data.stampable_skb) { ··· 181 206 sja1105_packing(buf, &valid, 31, 31, size, op); 182 207 sja1105_packing(buf, &cmd->ptpstrtsch, 30, 30, size, op); 183 208 sja1105_packing(buf, &cmd->ptpstopsch, 29, 29, size, op); 209 + sja1105_packing(buf, &cmd->startptpcp, 28, 28, size, op); 210 + sja1105_packing(buf, &cmd->stopptpcp, 27, 27, size, op); 184 211 sja1105_packing(buf, &cmd->resptp, 2, 2, size, op); 185 212 sja1105_packing(buf, &cmd->corrclk4ts, 1, 1, size, op); 186 213 sja1105_packing(buf, &cmd->ptpclkadd, 0, 0, size, op); ··· 198 221 sja1105_packing(buf, &valid, 31, 31, size, op); 199 222 sja1105_packing(buf, &cmd->ptpstrtsch, 30, 30, size, op); 200 223 sja1105_packing(buf, &cmd->ptpstopsch, 29, 29, size, op); 224 + sja1105_packing(buf, &cmd->startptpcp, 28, 28, size, op); 225 + sja1105_packing(buf, &cmd->stopptpcp, 27, 27, size, op); 201 226 sja1105_packing(buf, &cmd->resptp, 3, 3, size, op); 202 227 sja1105_packing(buf, &cmd->corrclk4ts, 2, 2, size, op); 203 228 sja1105_packing(buf, &cmd->ptpclkadd, 0, 0, size, op); ··· 594 615 return rc; 595 616 } 596 617 618 + static void sja1105_ptp_extts_work(struct work_struct *work) 619 + { 620 + struct delayed_work *dw = to_delayed_work(work); 621 + struct sja1105_ptp_data *ptp_data = extts_to_data(dw); 622 + struct sja1105_private *priv = ptp_data_to_sja1105(ptp_data); 623 + const struct sja1105_regs *regs = priv->info->regs; 624 + struct ptp_clock_event event; 625 + u64 ptpsyncts = 0; 626 + int rc; 627 + 628 + mutex_lock(&ptp_data->lock); 629 + 630 + rc = sja1105_xfer_u64(priv, SPI_READ, regs->ptpsyncts, &ptpsyncts, 631 + NULL); 632 + if (rc < 0) 633 + dev_err_ratelimited(priv->ds->dev, 634 + "Failed to read PTPSYNCTS: %d\n", rc); 635 + 636 + if (ptpsyncts && ptp_data->ptpsyncts != ptpsyncts) { 637 + event.index = 0; 638 + event.type = PTP_CLOCK_EXTTS; 639 + event.timestamp = ns_to_ktime(sja1105_ticks_to_ns(ptpsyncts)); 640 + ptp_clock_event(ptp_data->clock, &event); 641 + 642 + ptp_data->ptpsyncts = ptpsyncts; 643 + } 644 + 645 + mutex_unlock(&ptp_data->lock); 646 + 647 + schedule_delayed_work(&ptp_data->extts_work, SJA1105_EXTTS_INTERVAL); 648 + } 649 + 650 + static int sja1105_change_ptp_clk_pin_func(struct sja1105_private *priv, 651 + enum ptp_pin_function func) 652 + { 653 + struct sja1105_avb_params_entry *avb; 654 + enum ptp_pin_function old_func; 655 + 656 + avb = priv->static_config.tables[BLK_IDX_AVB_PARAMS].entries; 657 + 658 + if (priv->info->device_id == SJA1105E_DEVICE_ID || 659 + priv->info->device_id == SJA1105T_DEVICE_ID || 660 + avb->cas_master) 661 + old_func = PTP_PF_PEROUT; 662 + else 663 + old_func = PTP_PF_EXTTS; 664 + 665 + if (func == old_func) 666 + return 0; 667 + 668 + avb->cas_master = (func == PTP_PF_PEROUT); 669 + 670 + return sja1105_dynamic_config_write(priv, BLK_IDX_AVB_PARAMS, 0, avb, 671 + true); 672 + } 673 + 674 + /* The PTP_CLK pin may be configured to toggle with a 50% duty cycle and a 675 + * frequency f: 676 + * 677 + * NSEC_PER_SEC 678 + * f = ---------------------- 679 + * (PTPPINDUR * 8 ns) * 2 680 + */ 681 + static int sja1105_per_out_enable(struct sja1105_private *priv, 682 + struct ptp_perout_request *perout, 683 + bool on) 684 + { 685 + struct sja1105_ptp_data *ptp_data = &priv->ptp_data; 686 + const struct sja1105_regs *regs = priv->info->regs; 687 + struct sja1105_ptp_cmd cmd = ptp_data->cmd; 688 + int rc; 689 + 690 + /* We only support one channel */ 691 + if (perout->index != 0) 692 + return -EOPNOTSUPP; 693 + 694 + /* Reject requests with unsupported flags */ 695 + if (perout->flags) 696 + return -EOPNOTSUPP; 697 + 698 + mutex_lock(&ptp_data->lock); 699 + 700 + rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT); 701 + if (rc) 702 + goto out; 703 + 704 + if (on) { 705 + struct timespec64 pin_duration_ts = { 706 + .tv_sec = perout->period.sec, 707 + .tv_nsec = perout->period.nsec, 708 + }; 709 + struct timespec64 pin_start_ts = { 710 + .tv_sec = perout->start.sec, 711 + .tv_nsec = perout->start.nsec, 712 + }; 713 + u64 pin_duration = timespec64_to_ns(&pin_duration_ts); 714 + u64 pin_start = timespec64_to_ns(&pin_start_ts); 715 + u32 pin_duration32; 716 + u64 now; 717 + 718 + /* ptppindur: 32 bit register which holds the interval between 719 + * 2 edges on PTP_CLK. So check for truncation which happens 720 + * at periods larger than around 68.7 seconds. 721 + */ 722 + pin_duration = ns_to_sja1105_ticks(pin_duration / 2); 723 + if (pin_duration > U32_MAX) { 724 + rc = -ERANGE; 725 + goto out; 726 + } 727 + pin_duration32 = pin_duration; 728 + 729 + /* ptppins: 64 bit register which needs to hold a PTP time 730 + * larger than the current time, otherwise the startptpcp 731 + * command won't do anything. So advance the current time 732 + * by a number of periods in a way that won't alter the 733 + * phase offset. 734 + */ 735 + rc = __sja1105_ptp_gettimex(priv->ds, &now, NULL); 736 + if (rc < 0) 737 + goto out; 738 + 739 + pin_start = future_base_time(pin_start, pin_duration, 740 + now + 1ull * NSEC_PER_SEC); 741 + pin_start = ns_to_sja1105_ticks(pin_start); 742 + 743 + rc = sja1105_xfer_u64(priv, SPI_WRITE, regs->ptppinst, 744 + &pin_start, NULL); 745 + if (rc < 0) 746 + goto out; 747 + 748 + rc = sja1105_xfer_u32(priv, SPI_WRITE, regs->ptppindur, 749 + &pin_duration32, NULL); 750 + if (rc < 0) 751 + goto out; 752 + } 753 + 754 + if (on) 755 + cmd.startptpcp = true; 756 + else 757 + cmd.stopptpcp = true; 758 + 759 + rc = sja1105_ptp_commit(priv->ds, &cmd, SPI_WRITE); 760 + 761 + out: 762 + mutex_unlock(&ptp_data->lock); 763 + 764 + return rc; 765 + } 766 + 767 + static int sja1105_extts_enable(struct sja1105_private *priv, 768 + struct ptp_extts_request *extts, 769 + bool on) 770 + { 771 + int rc; 772 + 773 + /* We only support one channel */ 774 + if (extts->index != 0) 775 + return -EOPNOTSUPP; 776 + 777 + /* Reject requests with unsupported flags */ 778 + if (extts->flags) 779 + return -EOPNOTSUPP; 780 + 781 + rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS); 782 + if (rc) 783 + return rc; 784 + 785 + if (on) 786 + schedule_delayed_work(&priv->ptp_data.extts_work, 787 + SJA1105_EXTTS_INTERVAL); 788 + else 789 + cancel_delayed_work_sync(&priv->ptp_data.extts_work); 790 + 791 + return 0; 792 + } 793 + 794 + static int sja1105_ptp_enable(struct ptp_clock_info *ptp, 795 + struct ptp_clock_request *req, int on) 796 + { 797 + struct sja1105_ptp_data *ptp_data = ptp_caps_to_data(ptp); 798 + struct sja1105_private *priv = ptp_data_to_sja1105(ptp_data); 799 + int rc = -EOPNOTSUPP; 800 + 801 + if (req->type == PTP_CLK_REQ_PEROUT) 802 + rc = sja1105_per_out_enable(priv, &req->perout, on); 803 + else if (req->type == PTP_CLK_REQ_EXTTS) 804 + rc = sja1105_extts_enable(priv, &req->extts, on); 805 + 806 + return rc; 807 + } 808 + 809 + static int sja1105_ptp_verify_pin(struct ptp_clock_info *ptp, unsigned int pin, 810 + enum ptp_pin_function func, unsigned int chan) 811 + { 812 + struct sja1105_ptp_data *ptp_data = ptp_caps_to_data(ptp); 813 + struct sja1105_private *priv = ptp_data_to_sja1105(ptp_data); 814 + 815 + if (chan != 0 || pin != 0) 816 + return -1; 817 + 818 + switch (func) { 819 + case PTP_PF_NONE: 820 + case PTP_PF_PEROUT: 821 + break; 822 + case PTP_PF_EXTTS: 823 + if (priv->info->device_id == SJA1105E_DEVICE_ID || 824 + priv->info->device_id == SJA1105T_DEVICE_ID) 825 + return -1; 826 + break; 827 + default: 828 + return -1; 829 + } 830 + return 0; 831 + } 832 + 833 + static struct ptp_pin_desc sja1105_ptp_pin = { 834 + .name = "ptp_clk", 835 + .index = 0, 836 + .func = PTP_PF_NONE, 837 + }; 838 + 597 839 int sja1105_ptp_clock_register(struct dsa_switch *ds) 598 840 { 599 841 struct sja1105_private *priv = ds->priv; ··· 828 628 .adjtime = sja1105_ptp_adjtime, 829 629 .gettimex64 = sja1105_ptp_gettimex, 830 630 .settime64 = sja1105_ptp_settime, 631 + .enable = sja1105_ptp_enable, 632 + .verify = sja1105_ptp_verify_pin, 831 633 .do_aux_work = sja1105_rxtstamp_work, 832 634 .max_adj = SJA1105_MAX_ADJ_PPB, 635 + .pin_config = &sja1105_ptp_pin, 636 + .n_pins = 1, 637 + .n_ext_ts = 1, 638 + .n_per_out = 1, 833 639 }; 834 640 835 641 skb_queue_head_init(&ptp_data->skb_rxtstamp_queue); ··· 848 642 ptp_data->cmd.corrclk4ts = true; 849 643 ptp_data->cmd.ptpclkadd = PTP_SET_MODE; 850 644 645 + INIT_DELAYED_WORK(&ptp_data->extts_work, sja1105_ptp_extts_work); 646 + 851 647 return sja1105_ptp_reset(ds); 852 648 } 853 649 ··· 861 653 if (IS_ERR_OR_NULL(ptp_data->clock)) 862 654 return; 863 655 656 + cancel_delayed_work_sync(&ptp_data->extts_work); 864 657 ptp_cancel_worker_sync(ptp_data->clock); 865 658 skb_queue_purge(&ptp_data->skb_rxtstamp_queue); 866 659 ptp_clock_unregister(ptp_data->clock);
+31
drivers/net/dsa/sja1105/sja1105_ptp.h
··· 21 21 return ticks * SJA1105_TICK_NS; 22 22 } 23 23 24 + /* Calculate the first base_time in the future that satisfies this 25 + * relationship: 26 + * 27 + * future_base_time = base_time + N x cycle_time >= now, or 28 + * 29 + * now - base_time 30 + * N >= --------------- 31 + * cycle_time 32 + * 33 + * Because N is an integer, the ceiling value of the above "a / b" ratio 34 + * is in fact precisely the floor value of "(a + b - 1) / b", which is 35 + * easier to calculate only having integer division tools. 36 + */ 37 + static inline s64 future_base_time(s64 base_time, s64 cycle_time, s64 now) 38 + { 39 + s64 a, b, n; 40 + 41 + if (base_time >= now) 42 + return base_time; 43 + 44 + a = now - base_time; 45 + b = cycle_time; 46 + n = div_s64(a + b - 1, b); 47 + 48 + return base_time + n * cycle_time; 49 + } 50 + 24 51 struct sja1105_ptp_cmd { 52 + u64 startptpcp; /* start toggling PTP_CLK pin */ 53 + u64 stopptpcp; /* stop toggling PTP_CLK pin */ 25 54 u64 ptpstrtsch; /* start schedule */ 26 55 u64 ptpstopsch; /* stop schedule */ 27 56 u64 resptp; /* reset */ ··· 59 30 }; 60 31 61 32 struct sja1105_ptp_data { 33 + struct delayed_work extts_work; 62 34 struct sk_buff_head skb_rxtstamp_queue; 63 35 struct ptp_clock_info caps; 64 36 struct ptp_clock *clock; 65 37 struct sja1105_ptp_cmd cmd; 66 38 /* Serializes all operations on the PTP hardware clock */ 67 39 struct mutex lock; 40 + u64 ptpsyncts; 68 41 }; 69 42 70 43 int sja1105_ptp_clock_register(struct dsa_switch *ds);
+5
drivers/net/dsa/sja1105/sja1105_spi.c
··· 458 458 .rmii_ext_tx_clk = {0x100018, 0x10001F, 0x100026, 0x10002D, 0x100034}, 459 459 .ptpegr_ts = {0xC0, 0xC2, 0xC4, 0xC6, 0xC8}, 460 460 .ptpschtm = 0x12, /* Spans 0x12 to 0x13 */ 461 + .ptppinst = 0x14, 462 + .ptppindur = 0x16, 461 463 .ptp_control = 0x17, 462 464 .ptpclkval = 0x18, /* Spans 0x18 to 0x19 */ 463 465 .ptpclkrate = 0x1A, ··· 493 491 .qlevel = {0x604, 0x614, 0x624, 0x634, 0x644}, 494 492 .ptpegr_ts = {0xC0, 0xC4, 0xC8, 0xCC, 0xD0}, 495 493 .ptpschtm = 0x13, /* Spans 0x13 to 0x14 */ 494 + .ptppinst = 0x15, 495 + .ptppindur = 0x17, 496 496 .ptp_control = 0x18, 497 497 .ptpclkval = 0x19, 498 498 .ptpclkrate = 0x1B, 499 499 .ptpclkcorp = 0x1E, 500 + .ptpsyncts = 0x1F, 500 501 }; 501 502 502 503 struct sja1105_info sja1105e_info = {
+3 -2
drivers/net/dsa/sja1105/sja1105_static_config.c
··· 102 102 return size; 103 103 } 104 104 105 - static size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr, 106 - enum packing_op op) 105 + size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr, 106 + enum packing_op op) 107 107 { 108 108 const size_t size = SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY; 109 109 struct sja1105_avb_params_entry *entry = entry_ptr; 110 110 111 + sja1105_packing(buf, &entry->cas_master, 126, 126, size, op); 111 112 sja1105_packing(buf, &entry->destmeta, 125, 78, size, op); 112 113 sja1105_packing(buf, &entry->srcmeta, 77, 30, size, op); 113 114 return size;
+1
drivers/net/dsa/sja1105/sja1105_static_config.h
··· 230 230 }; 231 231 232 232 struct sja1105_avb_params_entry { 233 + u64 cas_master; 233 234 u64 destmeta; 234 235 u64 srcmeta; 235 236 };
-27
drivers/net/dsa/sja1105/sja1105_tas.c
··· 28 28 return delta * 200; 29 29 } 30 30 31 - /* Calculate the first base_time in the future that satisfies this 32 - * relationship: 33 - * 34 - * future_base_time = base_time + N x cycle_time >= now, or 35 - * 36 - * now - base_time 37 - * N >= --------------- 38 - * cycle_time 39 - * 40 - * Because N is an integer, the ceiling value of the above "a / b" ratio 41 - * is in fact precisely the floor value of "(a + b - 1) / b", which is 42 - * easier to calculate only having integer division tools. 43 - */ 44 - static s64 future_base_time(s64 base_time, s64 cycle_time, s64 now) 45 - { 46 - s64 a, b, n; 47 - 48 - if (base_time >= now) 49 - return base_time; 50 - 51 - a = now - base_time; 52 - b = cycle_time; 53 - n = div_s64(a + b - 1, b); 54 - 55 - return base_time + n * cycle_time; 56 - } 57 - 58 31 static int sja1105_tas_set_runtime_params(struct sja1105_private *priv) 59 32 { 60 33 struct sja1105_tas_data *tas_data = &priv->tas_data;