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

Configure Feed

Select the types of activity you want to include in your feed.

phy: zynqmp: Store instance instead of type

The phy "type" is just the combination of protocol and instance, and is
never used apart from that. Store the instance directly, instead of
converting to a type first. No functional change intended.

Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
Link: https://lore.kernel.org/r/20240628205540.3098010-3-sean.anderson@linux.dev
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Sean Anderson and committed by
Vinod Koul
6959d236 687d6bcc

+31 -84
+31 -84
drivers/phy/xilinx/phy-zynqmp.c
··· 147 147 /* Total number of controllers */ 148 148 #define CONTROLLERS_PER_LANE 5 149 149 150 - /* Protocol Type parameters */ 151 - #define XPSGTR_TYPE_USB0 0 /* USB controller 0 */ 152 - #define XPSGTR_TYPE_USB1 1 /* USB controller 1 */ 153 - #define XPSGTR_TYPE_SATA_0 2 /* SATA controller lane 0 */ 154 - #define XPSGTR_TYPE_SATA_1 3 /* SATA controller lane 1 */ 155 - #define XPSGTR_TYPE_PCIE_0 4 /* PCIe controller lane 0 */ 156 - #define XPSGTR_TYPE_PCIE_1 5 /* PCIe controller lane 1 */ 157 - #define XPSGTR_TYPE_PCIE_2 6 /* PCIe controller lane 2 */ 158 - #define XPSGTR_TYPE_PCIE_3 7 /* PCIe controller lane 3 */ 159 - #define XPSGTR_TYPE_DP_0 8 /* Display Port controller lane 0 */ 160 - #define XPSGTR_TYPE_DP_1 9 /* Display Port controller lane 1 */ 161 - #define XPSGTR_TYPE_SGMII0 10 /* Ethernet SGMII controller 0 */ 162 - #define XPSGTR_TYPE_SGMII1 11 /* Ethernet SGMII controller 1 */ 163 - #define XPSGTR_TYPE_SGMII2 12 /* Ethernet SGMII controller 2 */ 164 - #define XPSGTR_TYPE_SGMII3 13 /* Ethernet SGMII controller 3 */ 165 - 166 150 /* Timeout values */ 167 151 #define TIMEOUT_US 1000 168 152 ··· 169 185 /** 170 186 * struct xpsgtr_phy - representation of a lane 171 187 * @phy: pointer to the kernel PHY device 172 - * @type: controller which uses this lane 188 + * @instance: instance of the protocol type (such as the lane within a 189 + * protocol, or the USB/Ethernet controller) 173 190 * @lane: lane number 174 191 * @protocol: protocol in which the lane operates 175 192 * @skip_phy_init: skip phy_init() if true ··· 179 194 */ 180 195 struct xpsgtr_phy { 181 196 struct phy *phy; 182 - u8 type; 197 + u8 instance; 183 198 u8 lane; 184 199 u8 protocol; 185 200 bool skip_phy_init; ··· 316 331 317 332 if (ret == -ETIMEDOUT) 318 333 dev_err(gtr_dev->dev, 319 - "lane %u (type %u, protocol %u): PLL lock timeout\n", 320 - gtr_phy->lane, gtr_phy->type, gtr_phy->protocol); 334 + "lane %u (protocol %u, instance %u): PLL lock timeout\n", 335 + gtr_phy->lane, gtr_phy->protocol, gtr_phy->instance); 321 336 322 337 return ret; 323 338 } ··· 630 645 * cumulating waits for both lanes. The user is expected to initialize 631 646 * lane 0 last. 632 647 */ 633 - if (gtr_phy->protocol != ICM_PROTOCOL_DP || 634 - gtr_phy->type == XPSGTR_TYPE_DP_0) 648 + if (gtr_phy->protocol != ICM_PROTOCOL_DP || !gtr_phy->instance) 635 649 ret = xpsgtr_wait_pll_lock(phy); 636 650 637 651 return ret; ··· 660 676 * OF Xlate Support 661 677 */ 662 678 663 - /* Set the lane type and protocol based on the PHY type and instance number. */ 679 + /* Set the lane protocol and instance based on the PHY type and instance number. */ 664 680 static int xpsgtr_set_lane_type(struct xpsgtr_phy *gtr_phy, u8 phy_type, 665 681 unsigned int phy_instance) 666 682 { 667 683 unsigned int num_phy_types; 668 - const int *phy_types; 669 684 670 685 switch (phy_type) { 671 - case PHY_TYPE_SATA: { 672 - static const int types[] = { 673 - XPSGTR_TYPE_SATA_0, 674 - XPSGTR_TYPE_SATA_1, 675 - }; 676 - 677 - phy_types = types; 678 - num_phy_types = ARRAY_SIZE(types); 686 + case PHY_TYPE_SATA: 687 + num_phy_types = 2; 679 688 gtr_phy->protocol = ICM_PROTOCOL_SATA; 680 689 break; 681 - } 682 - case PHY_TYPE_USB3: { 683 - static const int types[] = { 684 - XPSGTR_TYPE_USB0, 685 - XPSGTR_TYPE_USB1, 686 - }; 687 - 688 - phy_types = types; 689 - num_phy_types = ARRAY_SIZE(types); 690 + case PHY_TYPE_USB3: 691 + num_phy_types = 2; 690 692 gtr_phy->protocol = ICM_PROTOCOL_USB; 691 693 break; 692 - } 693 - case PHY_TYPE_DP: { 694 - static const int types[] = { 695 - XPSGTR_TYPE_DP_0, 696 - XPSGTR_TYPE_DP_1, 697 - }; 698 - 699 - phy_types = types; 700 - num_phy_types = ARRAY_SIZE(types); 694 + case PHY_TYPE_DP: 695 + num_phy_types = 2; 701 696 gtr_phy->protocol = ICM_PROTOCOL_DP; 702 697 break; 703 - } 704 - case PHY_TYPE_PCIE: { 705 - static const int types[] = { 706 - XPSGTR_TYPE_PCIE_0, 707 - XPSGTR_TYPE_PCIE_1, 708 - XPSGTR_TYPE_PCIE_2, 709 - XPSGTR_TYPE_PCIE_3, 710 - }; 711 - 712 - phy_types = types; 713 - num_phy_types = ARRAY_SIZE(types); 698 + case PHY_TYPE_PCIE: 699 + num_phy_types = 4; 714 700 gtr_phy->protocol = ICM_PROTOCOL_PCIE; 715 701 break; 716 - } 717 - case PHY_TYPE_SGMII: { 718 - static const int types[] = { 719 - XPSGTR_TYPE_SGMII0, 720 - XPSGTR_TYPE_SGMII1, 721 - XPSGTR_TYPE_SGMII2, 722 - XPSGTR_TYPE_SGMII3, 723 - }; 724 - 725 - phy_types = types; 726 - num_phy_types = ARRAY_SIZE(types); 702 + case PHY_TYPE_SGMII: 703 + num_phy_types = 4; 727 704 gtr_phy->protocol = ICM_PROTOCOL_SGMII; 728 705 break; 729 - } 730 706 default: 731 707 return -EINVAL; 732 708 } ··· 694 750 if (phy_instance >= num_phy_types) 695 751 return -EINVAL; 696 752 697 - gtr_phy->type = phy_types[phy_instance]; 753 + gtr_phy->instance = phy_instance; 698 754 return 0; 699 755 } 700 756 701 757 /* 702 - * Valid combinations of controllers and lanes (Interconnect Matrix). 758 + * Valid combinations of controllers and lanes (Interconnect Matrix). Each 759 + * "instance" represents one controller for a lane. For PCIe and DP, the 760 + * "instance" is the logical lane in the link. For SATA, USB, and SGMII, 761 + * the instance is the index of the controller. 762 + * 763 + * This information is only used to validate the devicetree reference, and is 764 + * not used when programming the hardware. 703 765 */ 704 766 static const unsigned int icm_matrix[NUM_LANES][CONTROLLERS_PER_LANE] = { 705 - { XPSGTR_TYPE_PCIE_0, XPSGTR_TYPE_SATA_0, XPSGTR_TYPE_USB0, 706 - XPSGTR_TYPE_DP_1, XPSGTR_TYPE_SGMII0 }, 707 - { XPSGTR_TYPE_PCIE_1, XPSGTR_TYPE_SATA_1, XPSGTR_TYPE_USB0, 708 - XPSGTR_TYPE_DP_0, XPSGTR_TYPE_SGMII1 }, 709 - { XPSGTR_TYPE_PCIE_2, XPSGTR_TYPE_SATA_0, XPSGTR_TYPE_USB0, 710 - XPSGTR_TYPE_DP_1, XPSGTR_TYPE_SGMII2 }, 711 - { XPSGTR_TYPE_PCIE_3, XPSGTR_TYPE_SATA_1, XPSGTR_TYPE_USB1, 712 - XPSGTR_TYPE_DP_0, XPSGTR_TYPE_SGMII3 } 767 + /* PCIe, SATA, USB, DP, SGMII */ 768 + { 0, 0, 0, 1, 0 }, /* Lane 0 */ 769 + { 1, 1, 0, 0, 1 }, /* Lane 1 */ 770 + { 2, 0, 0, 1, 2 }, /* Lane 2 */ 771 + { 3, 1, 1, 0, 3 }, /* Lane 3 */ 713 772 }; 714 773 715 774 /* Translate OF phandle and args to PHY instance. */ ··· 767 820 * is allowed to operate on the lane. 768 821 */ 769 822 for (i = 0; i < CONTROLLERS_PER_LANE; i++) { 770 - if (icm_matrix[phy_lane][i] == gtr_phy->type) 823 + if (icm_matrix[phy_lane][i] == gtr_phy->instance) 771 824 return gtr_phy->phy; 772 825 } 773 826