Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Clock drivers for Qualcomm IPQ40xx |
| 4 | * |
| 5 | * Copyright (c) 2020 Sartura Ltd. |
| 6 | * |
| 7 | * Author: Robert Marko <robert.marko@sartura.hr> |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #include <clk-uclass.h> |
Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 12 | #include <dm.h> |
| 13 | #include <errno.h> |
Konrad Dybcio | 6c0b844 | 2023-11-07 12:41:01 +0000 | [diff] [blame] | 14 | #include <dt-bindings/clock/qcom,gcc-ipq4019.h> |
Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 15 | |
| 16 | #include "clock-qcom.h" |
| 17 | |
Caleb Connolly | 10a0abb | 2023-11-07 12:41:03 +0000 | [diff] [blame] | 18 | static ulong ipq4019_clk_set_rate(struct clk *clk, ulong rate) |
Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 19 | { |
| 20 | switch (clk->id) { |
| 21 | case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/ |
| 22 | /* This clock is already initialized by SBL1 */ |
Caleb Connolly | c3b5b1b | 2024-04-15 16:03:39 +0100 | [diff] [blame] | 23 | return 1843200; |
Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 24 | default: |
| 25 | return -EINVAL; |
| 26 | } |
| 27 | } |
| 28 | |
Caleb Connolly | 10a0abb | 2023-11-07 12:41:03 +0000 | [diff] [blame] | 29 | static int ipq4019_clk_enable(struct clk *clk) |
Caleb Connolly | 90c4464 | 2023-11-07 12:41:00 +0000 | [diff] [blame] | 30 | { |
| 31 | switch (clk->id) { |
| 32 | case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/ |
| 33 | /* This clock is already initialized by SBL1 */ |
| 34 | return 0; |
| 35 | case GCC_PRNG_AHB_CLK: /*PRNG*/ |
| 36 | /* This clock is already initialized by SBL1 */ |
| 37 | return 0; |
| 38 | case GCC_USB3_MASTER_CLK: |
| 39 | case GCC_USB3_SLEEP_CLK: |
| 40 | case GCC_USB3_MOCK_UTMI_CLK: |
| 41 | case GCC_USB2_MASTER_CLK: |
| 42 | case GCC_USB2_SLEEP_CLK: |
| 43 | case GCC_USB2_MOCK_UTMI_CLK: |
| 44 | /* These clocks is already initialized by SBL1 */ |
| 45 | return 0; |
| 46 | default: |
| 47 | return -EINVAL; |
| 48 | } |
| 49 | } |
| 50 | |
Konrad Dybcio | 6c0b844 | 2023-11-07 12:41:01 +0000 | [diff] [blame] | 51 | static const struct qcom_reset_map gcc_ipq4019_resets[] = { |
| 52 | [WIFI0_CPU_INIT_RESET] = { 0x1f008, 5 }, |
| 53 | [WIFI0_RADIO_SRIF_RESET] = { 0x1f008, 4 }, |
| 54 | [WIFI0_RADIO_WARM_RESET] = { 0x1f008, 3 }, |
| 55 | [WIFI0_RADIO_COLD_RESET] = { 0x1f008, 2 }, |
| 56 | [WIFI0_CORE_WARM_RESET] = { 0x1f008, 1 }, |
| 57 | [WIFI0_CORE_COLD_RESET] = { 0x1f008, 0 }, |
| 58 | [WIFI1_CPU_INIT_RESET] = { 0x20008, 5 }, |
| 59 | [WIFI1_RADIO_SRIF_RESET] = { 0x20008, 4 }, |
| 60 | [WIFI1_RADIO_WARM_RESET] = { 0x20008, 3 }, |
| 61 | [WIFI1_RADIO_COLD_RESET] = { 0x20008, 2 }, |
| 62 | [WIFI1_CORE_WARM_RESET] = { 0x20008, 1 }, |
| 63 | [WIFI1_CORE_COLD_RESET] = { 0x20008, 0 }, |
| 64 | [USB3_UNIPHY_PHY_ARES] = { 0x1e038, 5 }, |
| 65 | [USB3_HSPHY_POR_ARES] = { 0x1e038, 4 }, |
| 66 | [USB3_HSPHY_S_ARES] = { 0x1e038, 2 }, |
| 67 | [USB2_HSPHY_POR_ARES] = { 0x1e01c, 4 }, |
| 68 | [USB2_HSPHY_S_ARES] = { 0x1e01c, 2 }, |
| 69 | [PCIE_PHY_AHB_ARES] = { 0x1d010, 11 }, |
| 70 | [PCIE_AHB_ARES] = { 0x1d010, 10 }, |
| 71 | [PCIE_PWR_ARES] = { 0x1d010, 9 }, |
| 72 | [PCIE_PIPE_STICKY_ARES] = { 0x1d010, 8 }, |
| 73 | [PCIE_AXI_M_STICKY_ARES] = { 0x1d010, 7 }, |
| 74 | [PCIE_PHY_ARES] = { 0x1d010, 6 }, |
| 75 | [PCIE_PARF_XPU_ARES] = { 0x1d010, 5 }, |
| 76 | [PCIE_AXI_S_XPU_ARES] = { 0x1d010, 4 }, |
| 77 | [PCIE_AXI_M_VMIDMT_ARES] = { 0x1d010, 3 }, |
| 78 | [PCIE_PIPE_ARES] = { 0x1d010, 2 }, |
| 79 | [PCIE_AXI_S_ARES] = { 0x1d010, 1 }, |
| 80 | [PCIE_AXI_M_ARES] = { 0x1d010, 0 }, |
| 81 | [ESS_RESET] = { 0x12008, 0}, |
| 82 | [GCC_BLSP1_BCR] = {0x01000, 0}, |
| 83 | [GCC_BLSP1_QUP1_BCR] = {0x02000, 0}, |
| 84 | [GCC_BLSP1_UART1_BCR] = {0x02038, 0}, |
| 85 | [GCC_BLSP1_QUP2_BCR] = {0x03008, 0}, |
| 86 | [GCC_BLSP1_UART2_BCR] = {0x03028, 0}, |
| 87 | [GCC_BIMC_BCR] = {0x04000, 0}, |
| 88 | [GCC_TLMM_BCR] = {0x05000, 0}, |
| 89 | [GCC_IMEM_BCR] = {0x0E000, 0}, |
| 90 | [GCC_ESS_BCR] = {0x12008, 0}, |
| 91 | [GCC_PRNG_BCR] = {0x13000, 0}, |
| 92 | [GCC_BOOT_ROM_BCR] = {0x13008, 0}, |
| 93 | [GCC_CRYPTO_BCR] = {0x16000, 0}, |
| 94 | [GCC_SDCC1_BCR] = {0x18000, 0}, |
| 95 | [GCC_SEC_CTRL_BCR] = {0x1A000, 0}, |
| 96 | [GCC_AUDIO_BCR] = {0x1B008, 0}, |
| 97 | [GCC_QPIC_BCR] = {0x1C000, 0}, |
| 98 | [GCC_PCIE_BCR] = {0x1D000, 0}, |
| 99 | [GCC_USB2_BCR] = {0x1E008, 0}, |
| 100 | [GCC_USB2_PHY_BCR] = {0x1E018, 0}, |
| 101 | [GCC_USB3_BCR] = {0x1E024, 0}, |
| 102 | [GCC_USB3_PHY_BCR] = {0x1E034, 0}, |
| 103 | [GCC_SYSTEM_NOC_BCR] = {0x21000, 0}, |
| 104 | [GCC_PCNOC_BCR] = {0x2102C, 0}, |
| 105 | [GCC_DCD_BCR] = {0x21038, 0}, |
| 106 | [GCC_SNOC_BUS_TIMEOUT0_BCR] = {0x21064, 0}, |
| 107 | [GCC_SNOC_BUS_TIMEOUT1_BCR] = {0x2106C, 0}, |
| 108 | [GCC_SNOC_BUS_TIMEOUT2_BCR] = {0x21074, 0}, |
| 109 | [GCC_SNOC_BUS_TIMEOUT3_BCR] = {0x2107C, 0}, |
| 110 | [GCC_PCNOC_BUS_TIMEOUT0_BCR] = {0x21084, 0}, |
| 111 | [GCC_PCNOC_BUS_TIMEOUT1_BCR] = {0x2108C, 0}, |
| 112 | [GCC_PCNOC_BUS_TIMEOUT2_BCR] = {0x21094, 0}, |
| 113 | [GCC_PCNOC_BUS_TIMEOUT3_BCR] = {0x2109C, 0}, |
| 114 | [GCC_PCNOC_BUS_TIMEOUT4_BCR] = {0x210A4, 0}, |
| 115 | [GCC_PCNOC_BUS_TIMEOUT5_BCR] = {0x210AC, 0}, |
| 116 | [GCC_PCNOC_BUS_TIMEOUT6_BCR] = {0x210B4, 0}, |
| 117 | [GCC_PCNOC_BUS_TIMEOUT7_BCR] = {0x210BC, 0}, |
| 118 | [GCC_PCNOC_BUS_TIMEOUT8_BCR] = {0x210C4, 0}, |
| 119 | [GCC_PCNOC_BUS_TIMEOUT9_BCR] = {0x210CC, 0}, |
| 120 | [GCC_TCSR_BCR] = {0x22000, 0}, |
| 121 | [GCC_MPM_BCR] = {0x24000, 0}, |
| 122 | [GCC_SPDM_BCR] = {0x25000, 0}, |
| 123 | }; |
| 124 | |
Caleb Connolly | 10a0abb | 2023-11-07 12:41:03 +0000 | [diff] [blame] | 125 | static struct msm_clk_data ipq4019_clk_data = { |
| 126 | .enable = ipq4019_clk_enable, |
| 127 | .set_rate = ipq4019_clk_set_rate, |
Konrad Dybcio | 6c0b844 | 2023-11-07 12:41:01 +0000 | [diff] [blame] | 128 | .resets = gcc_ipq4019_resets, |
| 129 | .num_resets = ARRAY_SIZE(gcc_ipq4019_resets), |
| 130 | }; |
| 131 | |
| 132 | static const struct udevice_id gcc_ipq4019_of_match[] = { |
| 133 | { |
| 134 | .compatible = "qcom,gcc-ipq4019", |
Caleb Connolly | 10a0abb | 2023-11-07 12:41:03 +0000 | [diff] [blame] | 135 | .data = (ulong)&ipq4019_clk_data, |
Konrad Dybcio | 6c0b844 | 2023-11-07 12:41:01 +0000 | [diff] [blame] | 136 | }, |
| 137 | { } |
| 138 | }; |
| 139 | |
| 140 | U_BOOT_DRIVER(gcc_ipq4019) = { |
| 141 | .name = "gcc_ipq4019", |
| 142 | .id = UCLASS_NOP, |
| 143 | .of_match = gcc_ipq4019_of_match, |
| 144 | .bind = qcom_cc_bind, |
| 145 | .flags = DM_FLAG_PRE_RELOC, |
| 146 | }; |