// SPDX-License-Identifier: GPL-2.0
 
 /*
- * Copyright 2016-2021 HabanaLabs, Ltd.
+ * Copyright 2016-2022 HabanaLabs, Ltd.
  * All Rights Reserved.
  */
 
                        goto out_err;
                }
 
-               hl_set_max_power(hdev);
+               hl_fw_set_max_power(hdev);
        } else {
                rc = hdev->asic_funcs->non_hard_reset_late_init(hdev);
                if (rc) {
        /* Need to call this again because the max power might change,
         * depending on card type for certain ASICs
         */
-       hl_set_max_power(hdev);
+       hl_fw_set_max_power(hdev);
 
        /*
         * hl_hwmon_init() must be called after device_late_init(), because only
 
 
 void hl_fw_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq)
 {
-       hl_set_frequency(hdev, hdev->asic_prop.clk_pll_index,
+       hl_fw_set_frequency(hdev, hdev->asic_prop.clk_pll_index,
                                hdev->asic_prop.max_freq_value);
 }
 
                return 0;
        }
 
-       value = hl_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false);
+       value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false);
 
        if (value < 0) {
                dev_err(hdev->dev, "Failed to retrieve device max clock %ld\n", value);
 
        *max_clk = (value / 1000 / 1000);
 
-       value = hl_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true);
+       value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true);
 
        if (value < 0) {
                dev_err(hdev->dev, "Failed to retrieve device current clock %ld\n", value);
 
        return 0;
 }
+
+long hl_fw_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
+{
+       struct cpucp_packet pkt;
+       u32 used_pll_idx;
+       u64 result;
+       int rc;
+
+       rc = get_used_pll_index(hdev, pll_index, &used_pll_idx);
+       if (rc)
+               return rc;
+
+       memset(&pkt, 0, sizeof(pkt));
+
+       if (curr)
+               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_CURR_GET <<
+                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
+       else
+               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_GET << CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+       pkt.pll_index = cpu_to_le32((u32)used_pll_idx);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result);
+
+       if (rc) {
+               dev_err(hdev->dev, "Failed to get frequency of PLL %d, error %d\n",
+                       used_pll_idx, rc);
+               return rc;
+       }
+
+       return (long) result;
+}
+
+void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
+{
+       struct cpucp_packet pkt;
+       u32 used_pll_idx;
+       int rc;
+
+       rc = get_used_pll_index(hdev, pll_index, &used_pll_idx);
+       if (rc)
+               return;
+
+       memset(&pkt, 0, sizeof(pkt));
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_SET << CPUCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.pll_index = cpu_to_le32((u32)used_pll_idx);
+       pkt.value = cpu_to_le64(freq);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL);
+
+       if (rc)
+               dev_err(hdev->dev, "Failed to set frequency to PLL %d, error %d\n",
+                       used_pll_idx, rc);
+}
+
+u64 hl_fw_get_max_power(struct hl_device *hdev)
+{
+       struct cpucp_packet pkt;
+       u64 result;
+       int rc;
+
+       memset(&pkt, 0, sizeof(pkt));
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_GET << CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, &result);
+
+       if (rc) {
+               dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
+               return (u64) rc;
+       }
+
+       return result;
+}
+
+void hl_fw_set_max_power(struct hl_device *hdev)
+{
+       struct cpucp_packet pkt;
+       int rc;
+
+       /* TODO: remove this after simulator supports this packet */
+       if (!hdev->pdev)
+               return;
+
+       memset(&pkt, 0, sizeof(pkt));
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_SET << CPUCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.value = cpu_to_le64(hdev->max_power);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL);
+
+       if (rc)
+               dev_err(hdev->dev, "Failed to set max power, error %d\n", rc);
+}
 
 int hl_pci_init(struct hl_device *hdev);
 void hl_pci_fini(struct hl_device *hdev);
 
-long hl_get_frequency(struct hl_device *hdev, u32 pll_index,
-                                                               bool curr);
-void hl_set_frequency(struct hl_device *hdev, u32 pll_index,
-                                                               u64 freq);
-int hl_get_temperature(struct hl_device *hdev,
-                      int sensor_index, u32 attr, long *value);
-int hl_set_temperature(struct hl_device *hdev,
-                      int sensor_index, u32 attr, long value);
-int hl_get_voltage(struct hl_device *hdev,
-                  int sensor_index, u32 attr, long *value);
-int hl_get_current(struct hl_device *hdev,
-                  int sensor_index, u32 attr, long *value);
-int hl_get_fan_speed(struct hl_device *hdev,
-                    int sensor_index, u32 attr, long *value);
-int hl_get_pwm_info(struct hl_device *hdev,
-                   int sensor_index, u32 attr, long *value);
-void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
-                       long value);
-u64 hl_get_max_power(struct hl_device *hdev);
-void hl_set_max_power(struct hl_device *hdev);
-int hl_set_voltage(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_set_current(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_set_power(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long value);
-int hl_get_power(struct hl_device *hdev,
-                       int sensor_index, u32 attr, long *value);
+long hl_fw_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr);
+void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq);
+int hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_set_temperature(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+int hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
+void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+u64 hl_fw_get_max_power(struct hl_device *hdev);
+void hl_fw_set_max_power(struct hl_device *hdev);
+int hl_set_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_set_current(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_set_power(struct hl_device *hdev, int sensor_index, u32 attr, long value);
+int hl_get_power(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
 int hl_fw_get_clk_rate(struct hl_device *hdev, u32 *cur_clk, u32 *max_clk);
 void hl_fw_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq);
 void hl_sysfs_add_dev_clk_attr(struct hl_device *hdev, struct attribute_group *dev_attr_grp);
+
 void hw_sob_get(struct hl_hw_sob *hw_sob);
 void hw_sob_put(struct hl_hw_sob *hw_sob);
 void hl_encaps_handle_do_release(struct kref *ref);
 
 
 #include <linux/pci.h>
 
-long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
-{
-       struct cpucp_packet pkt;
-       u32 used_pll_idx;
-       u64 result;
-       int rc;
-
-       rc = get_used_pll_index(hdev, pll_index, &used_pll_idx);
-       if (rc)
-               return rc;
-
-       memset(&pkt, 0, sizeof(pkt));
-
-       if (curr)
-               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_CURR_GET <<
-                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
-       else
-               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_GET <<
-                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
-       pkt.pll_index = cpu_to_le32((u32)used_pll_idx);
-
-       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                               0, &result);
-
-       if (rc) {
-               dev_err(hdev->dev,
-                       "Failed to get frequency of PLL %d, error %d\n",
-                       used_pll_idx, rc);
-               return rc;
-       }
-
-       return (long) result;
-}
-
-void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
-{
-       struct cpucp_packet pkt;
-       u32 used_pll_idx;
-       int rc;
-
-       rc = get_used_pll_index(hdev, pll_index, &used_pll_idx);
-       if (rc)
-               return;
-
-       memset(&pkt, 0, sizeof(pkt));
-
-       pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_SET <<
-                                       CPUCP_PKT_CTL_OPCODE_SHIFT);
-       pkt.pll_index = cpu_to_le32((u32)used_pll_idx);
-       pkt.value = cpu_to_le64(freq);
-
-       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                               0, NULL);
-
-       if (rc)
-               dev_err(hdev->dev,
-                       "Failed to set frequency to PLL %d, error %d\n",
-                       used_pll_idx, rc);
-}
-
-u64 hl_get_max_power(struct hl_device *hdev)
-{
-       struct cpucp_packet pkt;
-       u64 result;
-       int rc;
-
-       memset(&pkt, 0, sizeof(pkt));
-
-       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_GET <<
-                               CPUCP_PKT_CTL_OPCODE_SHIFT);
-
-       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                               0, &result);
-
-       if (rc) {
-               dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
-               return (u64) rc;
-       }
-
-       return result;
-}
-
-void hl_set_max_power(struct hl_device *hdev)
-{
-       struct cpucp_packet pkt;
-       int rc;
-
-       memset(&pkt, 0, sizeof(pkt));
-
-       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_SET <<
-                               CPUCP_PKT_CTL_OPCODE_SHIFT);
-       pkt.value = cpu_to_le64(hdev->max_power);
-
-       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                               0, NULL);
-
-       if (rc)
-               dev_err(hdev->dev, "Failed to set max power, error %d\n", rc);
-}
-
 static ssize_t clk_max_freq_mhz_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct hl_device *hdev = dev_get_drvdata(dev);
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false);
+       value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, false);
 
        hdev->asic_prop.max_freq_value = value;
 
 
        hdev->asic_prop.max_freq_value = value * 1000 * 1000;
 
-       hl_set_frequency(hdev, hdev->asic_prop.clk_pll_index, hdev->asic_prop.max_freq_value);
+       hl_fw_set_frequency(hdev, hdev->asic_prop.clk_pll_index, hdev->asic_prop.max_freq_value);
 
 fail:
        return count;
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true);
+       value = hl_fw_get_frequency(hdev, hdev->asic_prop.clk_pll_index, true);
 
        return sprintf(buf, "%lu\n", (value / 1000 / 1000));
 }
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       val = hl_get_max_power(hdev);
+       val = hl_fw_get_max_power(hdev);
 
        return sprintf(buf, "%lu\n", val);
 }
        }
 
        hdev->max_power = value;
-       hl_set_max_power(hdev);
+       hl_fw_set_max_power(hdev);
 
 out:
        return count;
 
 // SPDX-License-Identifier: GPL-2.0
 
 /*
- * Copyright 2016-2021 HabanaLabs, Ltd.
+ * Copyright 2016-2022 HabanaLabs, Ltd.
  * All Rights Reserved.
  */
 
 
        switch (freq) {
        case PLL_HIGH:
-               hl_set_frequency(hdev, HL_GOYA_MME_PLL, hdev->high_pll);
-               hl_set_frequency(hdev, HL_GOYA_TPC_PLL, hdev->high_pll);
-               hl_set_frequency(hdev, HL_GOYA_IC_PLL, hdev->high_pll);
+               hl_fw_set_frequency(hdev, HL_GOYA_MME_PLL, hdev->high_pll);
+               hl_fw_set_frequency(hdev, HL_GOYA_TPC_PLL, hdev->high_pll);
+               hl_fw_set_frequency(hdev, HL_GOYA_IC_PLL, hdev->high_pll);
                break;
        case PLL_LOW:
-               hl_set_frequency(hdev, HL_GOYA_MME_PLL, GOYA_PLL_FREQ_LOW);
-               hl_set_frequency(hdev, HL_GOYA_TPC_PLL, GOYA_PLL_FREQ_LOW);
-               hl_set_frequency(hdev, HL_GOYA_IC_PLL, GOYA_PLL_FREQ_LOW);
+               hl_fw_set_frequency(hdev, HL_GOYA_MME_PLL, GOYA_PLL_FREQ_LOW);
+               hl_fw_set_frequency(hdev, HL_GOYA_TPC_PLL, GOYA_PLL_FREQ_LOW);
+               hl_fw_set_frequency(hdev, HL_GOYA_IC_PLL, GOYA_PLL_FREQ_LOW);
                break;
        case PLL_LAST:
-               hl_set_frequency(hdev, HL_GOYA_MME_PLL, goya->mme_clk);
-               hl_set_frequency(hdev, HL_GOYA_TPC_PLL, goya->tpc_clk);
-               hl_set_frequency(hdev, HL_GOYA_IC_PLL, goya->ic_clk);
+               hl_fw_set_frequency(hdev, HL_GOYA_MME_PLL, goya->mme_clk);
+               hl_fw_set_frequency(hdev, HL_GOYA_TPC_PLL, goya->tpc_clk);
+               hl_fw_set_frequency(hdev, HL_GOYA_IC_PLL, goya->ic_clk);
                break;
        default:
                dev_err(hdev->dev, "unknown frequency setting\n");
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_MME_PLL, false);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_MME_PLL, false);
 
        if (value < 0)
                return value;
                goto fail;
        }
 
-       hl_set_frequency(hdev, HL_GOYA_MME_PLL, value);
+       hl_fw_set_frequency(hdev, HL_GOYA_MME_PLL, value);
        goya->mme_clk = value;
 
 fail:
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_TPC_PLL, false);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_TPC_PLL, false);
 
        if (value < 0)
                return value;
                goto fail;
        }
 
-       hl_set_frequency(hdev, HL_GOYA_TPC_PLL, value);
+       hl_fw_set_frequency(hdev, HL_GOYA_TPC_PLL, value);
        goya->tpc_clk = value;
 
 fail:
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_IC_PLL, false);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_IC_PLL, false);
 
        if (value < 0)
                return value;
                goto fail;
        }
 
-       hl_set_frequency(hdev, HL_GOYA_IC_PLL, value);
+       hl_fw_set_frequency(hdev, HL_GOYA_IC_PLL, value);
        goya->ic_clk = value;
 
 fail:
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_MME_PLL, true);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_MME_PLL, true);
 
        if (value < 0)
                return value;
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_TPC_PLL, true);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_TPC_PLL, true);
 
        if (value < 0)
                return value;
        if (!hl_device_operational(hdev, NULL))
                return -ENODEV;
 
-       value = hl_get_frequency(hdev, HL_GOYA_IC_PLL, true);
+       value = hl_fw_get_frequency(hdev, HL_GOYA_IC_PLL, true);
 
        if (value < 0)
                return value;