summaryrefslogtreecommitdiff
path: root/cesar/hal/phy/src/dini_pamela.c
blob: 0fd461757d4b9016b993b73e43689de4dff8cdea (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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);
}