new file mode 100644
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: MIT
+/* Copyright(c) 2019-2021, Celeno Communications Ltd. */
+
+#include "phy_common_lut.h"
+#include "phy_athos_lut.h"
+#include "phy_olympus_lut.h"
+
+const struct common_lut_line *cl_phy_oly_get_lut_index(const struct common_lut_line *lut_table,
+ const u16 lut_table_size, u16 freq)
+{
+ u16 frequency_idx;
+
+ /* Fine highest frequency in lut table that is lower or equal freq */
+ for (frequency_idx = 0;
+ frequency_idx < lut_table_size && lut_table[frequency_idx].frequency_q2 <= freq;
+ ++frequency_idx)
+ ;
+
+ if (frequency_idx)
+ frequency_idx--;
+
+ return &lut_table[frequency_idx];
+}
+
+void cl_phy_lut_2_lines_update(u16 freq,
+ const struct common_lut_line *lut_table_60m,
+ const u16 lut_table_60m_size,
+ const struct common_lut_line *lut_table_40m,
+ const u16 lut_table_40m_size,
+ struct mm_mac_api_lut_line *api_lut_line)
+{
+ /* 1. configure the 40M xco lut table */
+ const struct common_lut_line *data_line =
+ cl_phy_oly_get_lut_index(lut_table_40m, lut_table_40m_size, freq);
+
+ api_lut_line->rfic_specific.olympus_2_lines.xco_40M.freqmeastarg =
+ cpu_to_le32(data_line->freqmeastarg);
+ api_lut_line->rfic_specific.olympus_2_lines.xco_40M.nfrac =
+ cpu_to_le32(data_line->nfrac);
+ api_lut_line->rfic_specific.olympus_2_lines.xco_40M.nint =
+ data_line->nint;
+ api_lut_line->rfic_specific.olympus_2_lines.xco_40M.vcocalsel =
+ data_line->vcocalsel;
+
+ /* 2. configure the 60M xco lut table */
+ data_line = cl_phy_oly_get_lut_index(lut_table_60m, lut_table_60m_size, freq);
+ api_lut_line->rfic_specific.olympus_2_lines.xco_60M.freqmeastarg =
+ cpu_to_le32(data_line->freqmeastarg);
+ api_lut_line->rfic_specific.olympus_2_lines.xco_60M.nfrac =
+ cpu_to_le32(data_line->nfrac);
+ api_lut_line->rfic_specific.olympus_2_lines.xco_60M.nint =
+ data_line->nint;
+ api_lut_line->rfic_specific.olympus_2_lines.xco_60M.vcocalsel =
+ data_line->vcocalsel;
+
+ /* 3. set frequency */
+ api_lut_line->frequency_q2 = cpu_to_le16(freq);
+}
+
+void cl_phy_lut_3_lines_update(u16 freq,
+ const struct common_lut_line *lut_table_60m_s1,
+ const u16 lut_table_60m_s1_size,
+ const struct common_lut_line *lut_table_60m_s0,
+ const u16 lut_table_60m_s0_size,
+ const struct common_lut_line *lut_table_40m,
+ const u16 lut_table_40m_size,
+ struct mm_mac_api_lut_line *api_lut_line)
+{
+ /* 1. configure the 40M xco lut table */
+ const struct common_lut_line *data_line =
+ cl_phy_oly_get_lut_index(lut_table_40m, lut_table_40m_size, freq);
+
+ api_lut_line->rfic_specific.olympus_3_lines.xco_40M.freqmeastarg =
+ cpu_to_le32(data_line->freqmeastarg);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_40M.nfrac =
+ cpu_to_le32(data_line->nfrac);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_40M.nint =
+ data_line->nint;
+ api_lut_line->rfic_specific.olympus_3_lines.xco_40M.vcocalsel =
+ data_line->vcocalsel;
+
+ /* 2. configure the 60M xco lut table , sxpfddesel=1*/
+ data_line = cl_phy_oly_get_lut_index(lut_table_60m_s1, lut_table_60m_s1_size, freq);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s1.freqmeastarg =
+ cpu_to_le32(data_line->freqmeastarg);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s1.nfrac =
+ cpu_to_le32(data_line->nfrac);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s1.nint =
+ data_line->nint;
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s1.vcocalsel =
+ data_line->vcocalsel;
+
+ /* 3. configure the 60M xco lut table , sxpfddesel=0*/
+ data_line = cl_phy_oly_get_lut_index(lut_table_60m_s0, lut_table_60m_s0_size, freq);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s0.freqmeastarg =
+ cpu_to_le32(data_line->freqmeastarg);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s0.nfrac =
+ cpu_to_le32(data_line->nfrac);
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s0.nint =
+ data_line->nint;
+ api_lut_line->rfic_specific.olympus_3_lines.xco_60M_s0.vcocalsel =
+ data_line->vcocalsel;
+
+ /* 4. set frequency */
+ api_lut_line->frequency_q2 = cpu_to_le16(freq);
+}
+
+void cl_phy_oly_lut_update(u8 nl_band, u16 freq,
+ struct mm_mac_api_lut_line *api_lut_line)
+{
+ switch (nl_band) {
+ case NL80211_BAND_2GHZ:
+ cl_phy_lut_3_lines_update(freq,
+ olympus_lut_24g_60_mhz_s1,
+ OLYMPUS_LUT_CHAN_24G_MAX,
+ olympus_lut_24g_60_mhz_s0,
+ OLYMPUS_LUT_CHAN_24G_MAX,
+ olympus_lut_24g_40_mhz,
+ OLYMPUS_LUT_CHAN_24G_MAX,
+ api_lut_line);
+ break;
+ case NL80211_BAND_5GHZ:
+ cl_phy_lut_3_lines_update(freq,
+ olympus_lut_5g_60_mhz_s1,
+ OLYMPUS_LUT_CHAN_5G_MAX,
+ olympus_lut_5g_60_mhz_s0,
+ OLYMPUS_LUT_CHAN_5G_MAX,
+ olympus_lut_5g_40_mhz,
+ OLYMPUS_LUT_CHAN_5G_MAX,
+ api_lut_line);
+ break;
+ case NL80211_BAND_6GHZ:
+ cl_phy_lut_2_lines_update(freq,
+ athos_lut_6g_60_mhz, ATHOS_LUT_CHAN_6G_MAX,
+ athos_lut_6g_40_mhz, ATHOS_LUT_CHAN_6G_MAX,
+ api_lut_line);
+ break;
+ default:
+ /* If nl_band is not supported return zero's */
+ memset(api_lut_line, 0, sizeof(struct mm_mac_api_lut_line));
+ api_lut_line->frequency_q2 = cpu_to_le16(freq);
+ }
+}