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

clk: qcom: gcc-ipq6018: rework nss_port5 clock to multiple conf

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

In OpenWrt, this patch avoids intermittent dmesg errors of the form
nss_port5_rx_clk_src: rcg didn't update its configuration.

This is a mechanical, straightforward port of
commit e88f03230dc07aa3293b6aeb078bd27370bb2594
("clk: qcom: gcc-ipq8074: rework nss_port5/6 clock to multiple conf")
to gcc-ipq6018, with two conflicts resolved: different frequency of the
P_XO clock source, and only 5 Ethernet ports.

This was originally developed by JiaY-shi <shi05275@163.com>.

Link: https://lore.kernel.org/all/20231220221724.3822-4-ansuelsmth@gmail.com/
Signed-off-by: Marko Mäkelä <marko.makela@iki.fi>
Tested-by: Marko Mäkelä <marko.makela@iki.fi>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250802095546.295448-1-marko.makela@iki.fi
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Marko Mäkelä and committed by
Bjorn Andersson
2f7b1683 6ef38b0c

+38 -22
+38 -22
drivers/clk/qcom/gcc-ipq6018.c
··· 511 511 }, 512 512 }; 513 513 514 - static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = { 515 - F(24000000, P_XO, 1, 0, 0), 516 - F(25000000, P_UNIPHY1_RX, 12.5, 0, 0), 517 - F(25000000, P_UNIPHY0_RX, 5, 0, 0), 518 - F(78125000, P_UNIPHY1_RX, 4, 0, 0), 519 - F(125000000, P_UNIPHY1_RX, 2.5, 0, 0), 520 - F(125000000, P_UNIPHY0_RX, 1, 0, 0), 521 - F(156250000, P_UNIPHY1_RX, 2, 0, 0), 522 - F(312500000, P_UNIPHY1_RX, 1, 0, 0), 514 + static const struct freq_conf ftbl_nss_port5_rx_clk_src_25[] = { 515 + C(P_UNIPHY1_RX, 12.5, 0, 0), 516 + C(P_UNIPHY0_RX, 5, 0, 0), 517 + }; 518 + 519 + static const struct freq_conf ftbl_nss_port5_rx_clk_src_125[] = { 520 + C(P_UNIPHY1_RX, 2.5, 0, 0), 521 + C(P_UNIPHY0_RX, 1, 0, 0), 522 + }; 523 + 524 + static const struct freq_multi_tbl ftbl_nss_port5_rx_clk_src[] = { 525 + FMS(24000000, P_XO, 1, 0, 0), 526 + FM(25000000, ftbl_nss_port5_rx_clk_src_25), 527 + FMS(78125000, P_UNIPHY1_RX, 4, 0, 0), 528 + FM(125000000, ftbl_nss_port5_rx_clk_src_125), 529 + FMS(156250000, P_UNIPHY1_RX, 2, 0, 0), 530 + FMS(312500000, P_UNIPHY1_RX, 1, 0, 0), 523 531 { } 524 532 }; 525 533 ··· 555 547 556 548 static struct clk_rcg2 nss_port5_rx_clk_src = { 557 549 .cmd_rcgr = 0x68060, 558 - .freq_tbl = ftbl_nss_port5_rx_clk_src, 550 + .freq_multi_tbl = ftbl_nss_port5_rx_clk_src, 559 551 .hid_width = 5, 560 552 .parent_map = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias_map, 561 553 .clkr.hw.init = &(struct clk_init_data){ 562 554 .name = "nss_port5_rx_clk_src", 563 555 .parent_data = gcc_xo_uniphy0_rx_tx_uniphy1_rx_tx_ubi32_bias, 564 556 .num_parents = 7, 565 - .ops = &clk_rcg2_ops, 557 + .ops = &clk_rcg2_fm_ops, 566 558 }, 567 559 }; 568 560 569 - static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = { 570 - F(24000000, P_XO, 1, 0, 0), 571 - F(25000000, P_UNIPHY1_TX, 12.5, 0, 0), 572 - F(25000000, P_UNIPHY0_TX, 5, 0, 0), 573 - F(78125000, P_UNIPHY1_TX, 4, 0, 0), 574 - F(125000000, P_UNIPHY1_TX, 2.5, 0, 0), 575 - F(125000000, P_UNIPHY0_TX, 1, 0, 0), 576 - F(156250000, P_UNIPHY1_TX, 2, 0, 0), 577 - F(312500000, P_UNIPHY1_TX, 1, 0, 0), 561 + static const struct freq_conf ftbl_nss_port5_tx_clk_src_25[] = { 562 + C(P_UNIPHY1_TX, 12.5, 0, 0), 563 + C(P_UNIPHY0_TX, 5, 0, 0), 564 + }; 565 + 566 + static const struct freq_conf ftbl_nss_port5_tx_clk_src_125[] = { 567 + C(P_UNIPHY1_TX, 2.5, 0, 0), 568 + C(P_UNIPHY0_TX, 1, 0, 0), 569 + }; 570 + 571 + static const struct freq_multi_tbl ftbl_nss_port5_tx_clk_src[] = { 572 + FMS(24000000, P_XO, 1, 0, 0), 573 + FM(25000000, ftbl_nss_port5_tx_clk_src_25), 574 + FMS(78125000, P_UNIPHY1_TX, 4, 0, 0), 575 + FM(125000000, ftbl_nss_port5_tx_clk_src_125), 576 + FMS(156250000, P_UNIPHY1_TX, 2, 0, 0), 577 + FMS(312500000, P_UNIPHY1_TX, 1, 0, 0), 578 578 { } 579 579 }; 580 580 ··· 610 594 611 595 static struct clk_rcg2 nss_port5_tx_clk_src = { 612 596 .cmd_rcgr = 0x68068, 613 - .freq_tbl = ftbl_nss_port5_tx_clk_src, 597 + .freq_multi_tbl = ftbl_nss_port5_tx_clk_src, 614 598 .hid_width = 5, 615 599 .parent_map = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias_map, 616 600 .clkr.hw.init = &(struct clk_init_data){ 617 601 .name = "nss_port5_tx_clk_src", 618 602 .parent_data = gcc_xo_uniphy0_tx_rx_uniphy1_tx_rx_ubi32_bias, 619 603 .num_parents = 7, 620 - .ops = &clk_rcg2_ops, 604 + .ops = &clk_rcg2_fm_ops, 621 605 }, 622 606 }; 623 607