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

clk: qcom: gcc-ipq8074: rework nss_port5/6 clock to multiple conf

Rework nss_port5/6 to use the new multiple configuration implementation
and correctly fix the clocks for these port under some corner case.

This is particularly relevant for device that have 2.5G or 10G port
connected to port5 or port 6 on ipq8074. As the parent are shared
across multiple port it may be required to select the correct
configuration to accomplish the desired clock. Without this patch such
port doesn't work in some specific ethernet speed as the clock will be
set to the wrong frequency as we just select the first configuration for
the related frequency instead of selecting the best one.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20231220221724.3822-4-ansuelsmth@gmail.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Christian Marangi and committed by
Bjorn Andersson
e88f0323 89da2245

+76 -44
+76 -44
drivers/clk/qcom/gcc-ipq8074.c
··· 1677 1677 }, 1678 1678 }; 1679 1679 1680 - static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = { 1681 - F(19200000, P_XO, 1, 0, 0), 1682 - F(25000000, P_UNIPHY1_RX, 12.5, 0, 0), 1683 - F(25000000, P_UNIPHY0_RX, 5, 0, 0), 1684 - F(78125000, P_UNIPHY1_RX, 4, 0, 0), 1685 - F(125000000, P_UNIPHY1_RX, 2.5, 0, 0), 1686 - F(125000000, P_UNIPHY0_RX, 1, 0, 0), 1687 - F(156250000, P_UNIPHY1_RX, 2, 0, 0), 1688 - F(312500000, P_UNIPHY1_RX, 1, 0, 0), 1680 + static const struct freq_conf ftbl_nss_port5_rx_clk_src_25[] = { 1681 + C(P_UNIPHY1_RX, 12.5, 0, 0), 1682 + C(P_UNIPHY0_RX, 5, 0, 0), 1683 + }; 1684 + 1685 + static const struct freq_conf ftbl_nss_port5_rx_clk_src_125[] = { 1686 + C(P_UNIPHY1_RX, 2.5, 0, 0), 1687 + C(P_UNIPHY0_RX, 1, 0, 0), 1688 + }; 1689 + 1690 + static const struct freq_multi_tbl ftbl_nss_port5_rx_clk_src[] = { 1691 + FMS(19200000, P_XO, 1, 0, 0), 1692 + FM(25000000, ftbl_nss_port5_rx_clk_src_25), 1693 + FMS(78125000, P_UNIPHY1_RX, 4, 0, 0), 1694 + FM(125000000, ftbl_nss_port5_rx_clk_src_125), 1695 + FMS(156250000, P_UNIPHY1_RX, 2, 0, 0), 1696 + FMS(312500000, P_UNIPHY1_RX, 1, 0, 0), 1689 1697 { } 1690 1698 }; 1691 1699 ··· 1720 1712 1721 1713 static struct clk_rcg2 nss_port5_rx_clk_src = { 1722 1714 .cmd_rcgr = 0x68060, 1723 - .freq_tbl = ftbl_nss_port5_rx_clk_src, 1715 + .freq_multi_tbl = ftbl_nss_port5_rx_clk_src, 1724 1716 .hid_width = 5, 1725 1717 .parent_map = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias_map, 1726 1718 .clkr.hw.init = &(struct clk_init_data){ 1727 1719 .name = "nss_port5_rx_clk_src", 1728 1720 .parent_data = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias, 1729 1721 .num_parents = ARRAY_SIZE(gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias), 1730 - .ops = &clk_rcg2_ops, 1722 + .ops = &clk_rcg2_fm_ops, 1731 1723 }, 1732 1724 }; 1733 1725 ··· 1747 1739 }, 1748 1740 }; 1749 1741 1750 - static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = { 1751 - F(19200000, P_XO, 1, 0, 0), 1752 - F(25000000, P_UNIPHY1_TX, 12.5, 0, 0), 1753 - F(25000000, P_UNIPHY0_TX, 5, 0, 0), 1754 - F(78125000, P_UNIPHY1_TX, 4, 0, 0), 1755 - F(125000000, P_UNIPHY1_TX, 2.5, 0, 0), 1756 - F(125000000, P_UNIPHY0_TX, 1, 0, 0), 1757 - F(156250000, P_UNIPHY1_TX, 2, 0, 0), 1758 - F(312500000, P_UNIPHY1_TX, 1, 0, 0), 1742 + static const struct freq_conf ftbl_nss_port5_tx_clk_src_25[] = { 1743 + C(P_UNIPHY1_TX, 12.5, 0, 0), 1744 + C(P_UNIPHY0_TX, 5, 0, 0), 1745 + }; 1746 + 1747 + static const struct freq_conf ftbl_nss_port5_tx_clk_src_125[] = { 1748 + C(P_UNIPHY1_TX, 2.5, 0, 0), 1749 + C(P_UNIPHY0_TX, 1, 0, 0), 1750 + }; 1751 + 1752 + static const struct freq_multi_tbl ftbl_nss_port5_tx_clk_src[] = { 1753 + FMS(19200000, P_XO, 1, 0, 0), 1754 + FM(25000000, ftbl_nss_port5_tx_clk_src_25), 1755 + FMS(78125000, P_UNIPHY1_TX, 4, 0, 0), 1756 + FM(125000000, ftbl_nss_port5_tx_clk_src_125), 1757 + FMS(156250000, P_UNIPHY1_TX, 2, 0, 0), 1758 + FMS(312500000, P_UNIPHY1_TX, 1, 0, 0), 1759 1759 { } 1760 1760 }; 1761 1761 ··· 1790 1774 1791 1775 static struct clk_rcg2 nss_port5_tx_clk_src = { 1792 1776 .cmd_rcgr = 0x68068, 1793 - .freq_tbl = ftbl_nss_port5_tx_clk_src, 1777 + .freq_multi_tbl = ftbl_nss_port5_tx_clk_src, 1794 1778 .hid_width = 5, 1795 1779 .parent_map = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias_map, 1796 1780 .clkr.hw.init = &(struct clk_init_data){ 1797 1781 .name = "nss_port5_tx_clk_src", 1798 1782 .parent_data = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias, 1799 1783 .num_parents = ARRAY_SIZE(gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias), 1800 - .ops = &clk_rcg2_ops, 1784 + .ops = &clk_rcg2_fm_ops, 1801 1785 }, 1802 1786 }; 1803 1787 ··· 1817 1801 }, 1818 1802 }; 1819 1803 1820 - static const struct freq_tbl ftbl_nss_port6_rx_clk_src[] = { 1821 - F(19200000, P_XO, 1, 0, 0), 1822 - F(25000000, P_UNIPHY2_RX, 5, 0, 0), 1823 - F(25000000, P_UNIPHY2_RX, 12.5, 0, 0), 1824 - F(78125000, P_UNIPHY2_RX, 4, 0, 0), 1825 - F(125000000, P_UNIPHY2_RX, 1, 0, 0), 1826 - F(125000000, P_UNIPHY2_RX, 2.5, 0, 0), 1827 - F(156250000, P_UNIPHY2_RX, 2, 0, 0), 1828 - F(312500000, P_UNIPHY2_RX, 1, 0, 0), 1804 + static const struct freq_conf ftbl_nss_port6_rx_clk_src_25[] = { 1805 + C(P_UNIPHY2_RX, 5, 0, 0), 1806 + C(P_UNIPHY2_RX, 12.5, 0, 0), 1807 + }; 1808 + 1809 + static const struct freq_conf ftbl_nss_port6_rx_clk_src_125[] = { 1810 + C(P_UNIPHY2_RX, 1, 0, 0), 1811 + C(P_UNIPHY2_RX, 2.5, 0, 0), 1812 + }; 1813 + 1814 + static const struct freq_multi_tbl ftbl_nss_port6_rx_clk_src[] = { 1815 + FMS(19200000, P_XO, 1, 0, 0), 1816 + FM(25000000, ftbl_nss_port6_rx_clk_src_25), 1817 + FMS(78125000, P_UNIPHY2_RX, 4, 0, 0), 1818 + FM(125000000, ftbl_nss_port6_rx_clk_src_125), 1819 + FMS(156250000, P_UNIPHY2_RX, 2, 0, 0), 1820 + FMS(312500000, P_UNIPHY2_RX, 1, 0, 0), 1829 1821 { } 1830 1822 }; 1831 1823 ··· 1855 1831 1856 1832 static struct clk_rcg2 nss_port6_rx_clk_src = { 1857 1833 .cmd_rcgr = 0x68070, 1858 - .freq_tbl = ftbl_nss_port6_rx_clk_src, 1834 + .freq_multi_tbl = ftbl_nss_port6_rx_clk_src, 1859 1835 .hid_width = 5, 1860 1836 .parent_map = gcc_xo_uniphy2_rx_tx_ubi32_bias_map, 1861 1837 .clkr.hw.init = &(struct clk_init_data){ 1862 1838 .name = "nss_port6_rx_clk_src", 1863 1839 .parent_data = gcc_xo_uniphy2_rx_tx_ubi32_bias, 1864 1840 .num_parents = ARRAY_SIZE(gcc_xo_uniphy2_rx_tx_ubi32_bias), 1865 - .ops = &clk_rcg2_ops, 1841 + .ops = &clk_rcg2_fm_ops, 1866 1842 }, 1867 1843 }; 1868 1844 ··· 1882 1858 }, 1883 1859 }; 1884 1860 1885 - static const struct freq_tbl ftbl_nss_port6_tx_clk_src[] = { 1886 - F(19200000, P_XO, 1, 0, 0), 1887 - F(25000000, P_UNIPHY2_TX, 5, 0, 0), 1888 - F(25000000, P_UNIPHY2_TX, 12.5, 0, 0), 1889 - F(78125000, P_UNIPHY2_TX, 4, 0, 0), 1890 - F(125000000, P_UNIPHY2_TX, 1, 0, 0), 1891 - F(125000000, P_UNIPHY2_TX, 2.5, 0, 0), 1892 - F(156250000, P_UNIPHY2_TX, 2, 0, 0), 1893 - F(312500000, P_UNIPHY2_TX, 1, 0, 0), 1861 + static const struct freq_conf ftbl_nss_port6_tx_clk_src_25[] = { 1862 + C(P_UNIPHY2_TX, 5, 0, 0), 1863 + C(P_UNIPHY2_TX, 12.5, 0, 0), 1864 + }; 1865 + 1866 + static const struct freq_conf ftbl_nss_port6_tx_clk_src_125[] = { 1867 + C(P_UNIPHY2_TX, 1, 0, 0), 1868 + C(P_UNIPHY2_TX, 2.5, 0, 0), 1869 + }; 1870 + 1871 + static const struct freq_multi_tbl ftbl_nss_port6_tx_clk_src[] = { 1872 + FMS(19200000, P_XO, 1, 0, 0), 1873 + FM(25000000, ftbl_nss_port6_tx_clk_src_25), 1874 + FMS(78125000, P_UNIPHY1_RX, 4, 0, 0), 1875 + FM(125000000, ftbl_nss_port6_tx_clk_src_125), 1876 + FMS(156250000, P_UNIPHY1_RX, 2, 0, 0), 1877 + FMS(312500000, P_UNIPHY1_RX, 1, 0, 0), 1894 1878 { } 1895 1879 }; 1896 1880 ··· 1920 1888 1921 1889 static struct clk_rcg2 nss_port6_tx_clk_src = { 1922 1890 .cmd_rcgr = 0x68078, 1923 - .freq_tbl = ftbl_nss_port6_tx_clk_src, 1891 + .freq_multi_tbl = ftbl_nss_port6_tx_clk_src, 1924 1892 .hid_width = 5, 1925 1893 .parent_map = gcc_xo_uniphy2_tx_rx_ubi32_bias_map, 1926 1894 .clkr.hw.init = &(struct clk_init_data){ 1927 1895 .name = "nss_port6_tx_clk_src", 1928 1896 .parent_data = gcc_xo_uniphy2_tx_rx_ubi32_bias, 1929 1897 .num_parents = ARRAY_SIZE(gcc_xo_uniphy2_tx_rx_ubi32_bias), 1930 - .ops = &clk_rcg2_ops, 1898 + .ops = &clk_rcg2_fm_ops, 1931 1899 }, 1932 1900 }; 1933 1901