summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNĂ©lio Laranjeiro2012-06-14 10:34:43 +0200
committerCyril Jourdan2012-09-20 17:00:13 +0200
commit136c2c2ce6f38124876495e245e20f99753589a8 (patch)
tree9737f6bec93a99597b7648f91031d9febe38c907 /cesar
parentc0cf8a066bcacddd422d1e4cd1c8101a1e18c232 (diff)
cesar/hal/phy: initialise pamela board for DINI platform, closes #3147
Defined if CONFIG_PHY_PLATFORM_DINI_PAMELA is set, otherwise the function is not compiled.
Diffstat (limited to 'cesar')
-rw-r--r--cesar/hal/phy/Module4
-rw-r--r--cesar/hal/phy/inc/dini_pamela.h35
-rw-r--r--cesar/hal/phy/src/dini_pamela.c60
-rw-r--r--cesar/hal/phy/src/phy.c3
4 files changed, 102 insertions, 0 deletions
diff --git a/cesar/hal/phy/Module b/cesar/hal/phy/Module
index ca2adc288e..df621b8db7 100644
--- a/cesar/hal/phy/Module
+++ b/cesar/hal/phy/Module
@@ -6,6 +6,10 @@ ifeq ($(CONFIG_TRACE),y)
SOURCES += trace.c
endif
+ifeq ($(CONFIG_PHY_PLATFORM_DINI_PAMELA),y)
+SOURCES += dini_pamela.c
+endif
+
ifndef $(MODULE_VAR)_ONCE
$(MODULE_VAR)_ONCE = 1
diff --git a/cesar/hal/phy/inc/dini_pamela.h b/cesar/hal/phy/inc/dini_pamela.h
new file mode 100644
index 0000000000..d30a3c8f7e
--- /dev/null
+++ b/cesar/hal/phy/inc/dini_pamela.h
@@ -0,0 +1,35 @@
+#ifndef hal_phy_inc_dini_pamela_h
+#define hal_phy_inc_dini_pamela_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/inc/dini_pamela.h
+ * \brief Initialise the Pamela board on Platform DINI.
+ * \ingroup hal_phy
+ */
+#include "config/phy/platform/dini/pamela.h"
+
+BEGIN_DECLS
+
+#if CONFIG_PHY_PLATFORM_DINI_PAMELA
+
+/**
+ * Initialise the Pamela board on the DINI prototype.
+ */
+void
+phy_init_proto_pamela (void);
+
+#else /* !CONFIG_PHY_PLATFORM_DINI_PAMELA */
+
+#define phy_init_proto_pamela() ((void) 0)
+
+#endif /* !CONFIG_PHY_PLATFORM_DINI_PAMELA */
+
+END_DECLS
+
+#endif /* hal_phy_inc_dini_pamela_h */
diff --git a/cesar/hal/phy/src/dini_pamela.c b/cesar/hal/phy/src/dini_pamela.c
new file mode 100644
index 0000000000..0fd461757d
--- /dev/null
+++ b/cesar/hal/phy/src/dini_pamela.c
@@ -0,0 +1,60 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2012 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal/phy/src/dini_pamela.c
+ * \brief Initialise the Pamela board on Platform DINI.
+ * \ingroup hal_phy
+ */
+#include "common/std.h"
+#include "mac/common/timings.h"
+#include "hal/phy/phy.h"
+
+/** Pamela Specific AFE configuration */
+#define PHY_RB_DINI_SPARE0 (*(volatile u32 *) 0xC8040900)
+#define PHY_RB_DINI_SPARE0__ARM_UART 0, 0
+
+#define PHY_RB_DINI_SPARE1 (*(volatile u32 *) 0xC8040904)
+#define PHY_RB_DINI_SPARE1__DEBUG_TX_ENABLE_MODE 0, 0
+#define PHY_RB_DINI_SPARE1__DEBUG_TX_ENABLE_VALUE 1, 1
+#define PHY_RB_DINI_SPARE1__RESET_ADC 4, 4
+#define PHY_RB_DINI_SPARE1__DEBUG_RX_ENABLE_MODE 5, 5
+#define PHY_RB_DINI_SPARE1__DEBUG_RX_ENABLE_VALUE 6, 6
+
+#define PHY_RB_DINI_SPARE2 (*(volatile u32 *) 0xC8040908)
+#define PHY_RB_DINI_SPARE2__SPI_DATA 15, 0
+#define PHY_RB_DINI_SPARE2__SPI_CONTROL_SWITCH 16, 16
+#define PHY_RB_DINI_SPARE2__PGA_FORCE_MODE 17, 17
+#define PHY_RB_DINI_SPARE2__SPI_CONTROL_PGA 18, 18
+
+#define SWITCH_HIGH_BAND_N 4, 4
+#define SWITCH_LOW_BAND_N 5, 5
+#define SWITCH_HIGH_BAND_P 6, 6
+#define SWITCH_LOW_BAND_P 7, 7
+
+void
+phy_init_proto_pamela (void)
+{
+ u32 date;
+ PHY_RB_DINI_SPARE0 =
+ BF_SET (PHY_RB_DINI_SPARE0, PHY_RB_DINI_SPARE0__ARM_UART, false);
+ /* Release Pamela ADC. */
+ PHY_RB_DINI_SPARE1 = BF_MASK (PHY_RB_DINI_SPARE1__RESET_ADC);
+ /* Sleep 200ms. */
+ date = phy_date () + MAC_MS_TO_TCK (200);
+ while (less_mod2p32 (phy_date (), date))
+ ;
+ /* Configure switch for low band. */
+ PHY_RB_DINI_SPARE2 =
+ BF_MASK (PHY_RB_DINI_SPARE2__SPI_CONTROL_SWITCH)
+ | BF_MASK (SWITCH_LOW_BAND_N)
+ | BF_MASK (SWITCH_LOW_BAND_P);
+ /* Configure PGA to be controlled by MAGIC. */
+ PHY_RB_DINI_SPARE2 = BF_MASK (PHY_RB_DINI_SPARE2__SPI_CONTROL_PGA);
+ PHY_RB_DINI_SPARE0 =
+ BF_SET (PHY_RB_DINI_SPARE0, PHY_RB_DINI_SPARE0__ARM_UART, true);
+}
diff --git a/cesar/hal/phy/src/phy.c b/cesar/hal/phy/src/phy.c
index 80375398bb..be8bd8eb45 100644
--- a/cesar/hal/phy/src/phy.c
+++ b/cesar/hal/phy/src/phy.c
@@ -18,6 +18,7 @@
#include "inc/regs.h"
#include "inc/resys.h"
#include "inc/hlut.h"
+#include "inc/dini_pamela.h"
#include "hal/phy/spoc/spoc.h"
@@ -677,6 +678,8 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
phy_init_tunable_param (ctx);
/* Initialise the HLUT. */
phy_hlut_init ();
+ /* Initialise pamela board on DINI platform. */
+ phy_init_proto_pamela ();
/* Done. */
return ctx;
}