summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/layer1/init.c
blob: c00d09fb8b06153011dd4be41880571e4953e305 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* OsmocomBB Layer1 initialization */

/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
 *
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */


#include <stdint.h>
#include <stdio.h>

#include <rffe.h>
#include <rf/trf6151.h>
#include <abb/twl3025.h>
#include <calypso/tpu.h>
#include <calypso/tsp.h>
#include <calypso/dsp.h>
#include <calypso/irq.h>

#include <layer1/sync.h>
#include <layer1/async.h>
#include <layer1/l23_api.h>

void layer1_init(void)
{
	struct msgb *msg;
	struct l1ctl_reset *res;

#ifndef CONFIG_TX_ENABLE
	printf("\n\nTHIS FIRMWARE WAS COMPILED WITHOUT TX SUPPORT!!!\n\n");
#endif

	/* initialize asynchronous part of L1 */
	l1a_init();
	/* initialize TDMA Frame IRQ driven synchronous L1 */
	l1s_init();
	/* power up the DSP */
	dsp_power_on();

	/* Initialize TPU, TSP and TRF drivers */
	tpu_init();
	tsp_init();
	trf6151_init();

	rffe_init();

#if 0 /* only if RX TPU window is disabled! */
	/* Put TWL3025 in downlink mode (includes calibration) */
	twl3025_downlink(1, 1000);
#endif

	/* issue the TRF and TWL initialization sequence */
	tpu_enq_sleep();
	tpu_enable(1);
	tpu_wait_idle();

	/* Disable RTC interrupt as it causes lost TDMA frames */
	irq_disable(IRQ_RTC_TIMER);

	/* inform l2 and upwards that we are ready for orders */
	msg = l1_create_l2_msg(L1CTL_RESET_IND, 0, 0, 0);
	res = msgb_put(msg, sizeof(*res));
	res->type = L1CTL_RES_T_BOOT;
	l1_queue_for_l2(msg);
}