summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/pbdma.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/hal/phy/src/pbdma.c')
-rw-r--r--cesar/hal/phy/src/pbdma.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/cesar/hal/phy/src/pbdma.c b/cesar/hal/phy/src/pbdma.c
new file mode 100644
index 0000000000..c536d97fcc
--- /dev/null
+++ b/cesar/hal/phy/src/pbdma.c
@@ -0,0 +1,89 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/pbdma.c
+ * \brief HAL Phy PB DMA functions.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+
+#include "inc/context.h"
+#include "inc/regs.h"
+
+void
+phy_pbdma_start (phy_t *ctx, bool bypass_aes, const u32 iv[3],
+ const u32 nek[4], uint nb_total, uint nb_ready,
+ uint nb_pb_it, phy_pb_t *first_pb)
+{
+ dbg_assert (ctx);
+ dbg_assert ((bypass_aes == true)
+ || (bypass_aes == false && iv && nek));
+ dbg_assert (nb_total > 0 && nb_total < 255
+ && nb_total >= nb_ready
+ && nb_total >= nb_pb_it);
+ dbg_assert_ptr (first_pb);
+ PHY_PBDMA_PTR_PB_DESC = (u32) first_pb;
+ PHY_PBDMA_CONFIG_PB = BF_FILL (PHY_PBDMA_CONFIG_PB,
+ (PB_NB_TOTAL, nb_total),
+ (PB_NB_READY, nb_ready),
+ (PB_NB_IT, nb_pb_it));
+ if (!bypass_aes)
+ {
+ PHY_PBDMA_IV_0 = iv[0];
+ PHY_PBDMA_IV_1 = iv[1];
+ PHY_PBDMA_IV_2 = iv[2];
+ PHY_PBDMA_KEY_0 = nek[0];
+ PHY_PBDMA_KEY_1 = nek[1];
+ PHY_PBDMA_KEY_2 = nek[2];
+ PHY_PBDMA_KEY_3 = nek[3];
+ }
+ u32 conf = PHY_PBDMA_CTRL_CONFIG;
+ if (bypass_aes)
+ conf |= BF_MASK (PHY_PBDMA_CTRL_CONFIG__AES_BYPASS);
+ else
+ conf &= ~BF_MASK (PHY_PBDMA_CTRL_CONFIG__AES_BYPASS);
+ PHY_PBDMA_CTRL_CONFIG = conf | PHY_PBDMA_CTRL_CONFIG__START_DATA;
+}
+
+void
+phy_pbdma_update (phy_t *ctx, uint nb_ready, uint nb_pb_it)
+{
+ dbg_assert (ctx);
+ uint nb_total = BF_GET (PHY_PBDMA_CONFIG_PB__PB_NB_TOTAL,
+ PHY_PBDMA_CONFIG_PB);
+ dbg_assert (nb_total > 0 && nb_total < 255
+ && nb_total >= nb_ready
+ && nb_total >= nb_pb_it);
+ PHY_PBDMA_CONFIG_PB = BF_FILL (PHY_PBDMA_CONFIG_PB,
+ (PB_NB_TOTAL, nb_total),
+ (PB_NB_READY, nb_ready),
+ (PB_NB_IT, nb_pb_it));
+}
+
+phy_pb_t *
+phy_pbdma_get_tail (phy_t *ctx)
+{
+ return (phy_pb_t *) PHY_PBDMA_PTR_PB_DESC;
+}
+
+volatile const u32 *
+phy_pbdma_get_crc_bitmap (phy_t *ctx)
+{
+ return &PHY_PBDMA_SACKI_BITMAP_0;
+}
+
+void
+phy_pbdma_start_chandata (phy_t *ctx, phy_chandata_t *first_chandata)
+{
+ dbg_assert (ctx);
+ dbg_assert_ptr (first_chandata);
+ PHY_PBDMA_PTR_CHANDATA = (u32) first_chandata;
+ PHY_PBDMA_CTRL_CONFIG = PHY_PBDMA_CTRL_CONFIG
+ | PHY_PBDMA_CTRL_CONFIG__START_CHANDATA;
+}
+