summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/hlut.c
diff options
context:
space:
mode:
authorNĂ©lio Laranjeiro2012-06-07 11:42:29 +0200
committerCyril Jourdan2012-09-20 17:00:11 +0200
commit61388538a8086598a375311258d54cb1be62b8d7 (patch)
tree52b95eaade1058fced1d906c59a515808be556c5 /cesar/hal/phy/src/hlut.c
parent35e2697799d2635954e433141d4fe2a4fd2aa292 (diff)
cesar/hal/phy: Add HLUT support for MSE500, refs #3147
Diffstat (limited to 'cesar/hal/phy/src/hlut.c')
-rw-r--r--cesar/hal/phy/src/hlut.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/cesar/hal/phy/src/hlut.c b/cesar/hal/phy/src/hlut.c
new file mode 100644
index 0000000000..da3a3b78ef
--- /dev/null
+++ b/cesar/hal/phy/src/hlut.c
@@ -0,0 +1,95 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/hlut.c
+ * \brief Table parameters and registers for HLUT.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+#include "lib/stats.h"
+#include "hal/arch/platform.h"
+#include "hal/phy/inc/regs.h"
+#include "hal/phy/inc/hlut.h"
+
+/** HLUT tunable parameters. */
+struct hlut_tunable_parameters_t
+{
+ /** HLUT span variable. */
+ u32 span;
+ /** HLUT offset variable. */
+ u32 offset;
+ /** HLUT threshold variable. */
+ u32 threshold;
+};
+typedef struct hlut_tunable_parameters_t hlut_tunable_parameters_t;
+
+/** Global tunable parameters. */
+static hlut_tunable_parameters_t hlut_tunable_params = {
+ PHY_HLUT_SPAN_DEFAULT,
+ PHY_HLUT_THRESHOLD_DEFAULT,
+ PHY_HLUT_OFFSET_DEFAULT,
+};
+
+/**
+ * Initialise the tunable parameters settable by the lib stats.
+ */
+static inline void
+phy_hlut_stats_init (void)
+{
+#if CONFIG_STATS
+ lib_stats_set_stat_value_notype ("HLUT_SPAN",
+ &hlut_tunable_params.span,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("HLUT_OFFSET",
+ &hlut_tunable_params.offset,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
+ lib_stats_set_stat_value_notype ("HLUT_THRESHOLD",
+ &hlut_tunable_params.threshold,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
+#endif /* CONFIG_STATS */
+}
+
+void
+phy_hlut_init (void)
+{
+ /* This is not valid on SPC300. */
+ if (arch_is_mse500 ())
+ {
+ /** HLUT table parameters for the gain function. */
+ static const u32 phy_hlut_table[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 41, 41, 41, 41, 41, 41,
+ 41, 41, 41, 41, 41, 41, 41, 41,
+ 41, 41, 41, 41, 41, 41, 41, 41
+ };
+ uint i;
+ /* Set the MAGIC HLUT parameters. */
+ for (i = 0; i < COUNT (phy_hlut_table); i++)
+ PHY_DSPSS_MAGIC_HLUT_TABLE_n[i] = phy_hlut_table[i];
+ phy_hlut_stats_init ();
+ }
+}
+
+void
+phy_hlut_set_tunable (void)
+{
+ /* This is not valid on SPC300. */
+ if (arch_is_mse500 ())
+ {
+ PHY_DSPSS_MAGIC_HLUT_SPAN = hlut_tunable_params.span;
+ PHY_DSPSS_MAGIC_HLUT_OFFSET = hlut_tunable_params.offset;
+ PHY_DSPSS_MAGIC_HLUT_THRESHOLD = hlut_tunable_params.threshold;
+ }
+}