treewide: remove FSF address
[osmocom-bb.git] / src / target / firmware / board / fcdev3b / init.c
blob03bd6d7321eb44dffee3f5c9172da06c3aab6782
1 /* Initialization for the FreeCalypso FCDEV3B modem */
3 /* Based on board/gta0x/init.c with the following obnoxious legalese:
5 * (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * All Rights Reserved
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
21 #include <stdint.h>
22 #include <stdio.h>
24 #include <debug.h>
25 #include <ctors.h>
26 #include <memory.h>
27 #include <board.h>
28 #include <keypad.h>
29 #include <console.h>
30 #include <flash/cfi_flash.h>
31 #include <tiffs.h>
33 #include <calypso/irq.h>
34 #include <calypso/clock.h>
35 #include <calypso/dma.h>
36 #include <calypso/rtc.h>
37 #include <calypso/timer.h>
38 #include <uart.h>
40 #include <comm/sercomm.h>
41 #include <comm/timer.h>
43 #include <abb/twl3025.h>
44 #include <rf/trf6151.h>
46 #define ARMIO_LATCH_OUT 0xfffe4802
47 #define IO_CNTL_REG 0xfffe4804
48 #define ARM_CONF_REG 0xfffef006
49 #define ASIC_CONF_REG 0xfffef008
50 #define IO_CONF_REG 0xfffef00a
52 static void board_io_init(void)
54 uint16_t reg;
56 reg = readw(ASIC_CONF_REG);
57 /* TWL3025: Set SPI+RIF RX clock to rising edge */
58 reg |= (1 << 13) | (1 << 14);
59 writew(reg, ASIC_CONF_REG);
62 * Most Calypso peripheral interface signals are unconnected
63 * on this modem. We configure them to be GPIOs in IO_CONF_REG,
64 * then configure them to be outputs in IO_CNTL_REG, then set
65 * the outputs to 0 in ARMIO_LATCH_OUT.
67 * Differences from Openmoko GTA0x:
69 * GPIO1 output needs to be 1 to enable the loudspeaker amplifier
70 * GPIO3 needs to be configured as an input
71 * I/O 9-12 are MCSI rather than GPIOs
73 writew(0x0215, IO_CONF_REG);
74 writew(0xDC08, IO_CNTL_REG);
75 writew(0x0002, ARMIO_LATCH_OUT);
77 /* configure ADD(22), needed for second half of flash */
78 reg = readw(ARM_CONF_REG);
79 reg |= (1 << 3);
80 writew(reg, ARM_CONF_REG);
83 void board_init(int with_irq)
85 /* Configure the memory interface */
86 /* Using the same settings as the official FreeCalypso fw */
87 calypso_mem_cfg(CALYPSO_nCS0, 4, CALYPSO_MEM_16bit, 1);
88 calypso_mem_cfg(CALYPSO_nCS1, 4, CALYPSO_MEM_16bit, 1);
89 calypso_mem_cfg(CALYPSO_nCS2, 4, CALYPSO_MEM_16bit, 1);
90 calypso_mem_cfg(CALYPSO_nCS3, 4, CALYPSO_MEM_16bit, 1);
91 calypso_mem_cfg(CALYPSO_CS4, 4, CALYPSO_MEM_16bit, 1);
92 calypso_mem_cfg(CALYPSO_nCS6, 0, CALYPSO_MEM_32bit, 1);
93 calypso_mem_cfg(CALYPSO_nCS7, 0, CALYPSO_MEM_32bit, 0);
95 /* Set VTCXO_DIV2 = 1, configure PLL for 104 MHz and give ARM half of that */
96 calypso_clock_set(2, CALYPSO_PLL13_104_MHZ, ARM_MCLK_DIV_2);
98 /* Configure the RHEA bridge with some sane default values */
99 calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0);
101 /* Initialize board-specific GPIO */
102 board_io_init();
104 /* Enable bootrom mapping to route exception vectors to RAM */
105 calypso_bootrom(with_irq);
106 calypso_exceptions_install();
108 /* Initialize interrupt controller */
109 if (with_irq)
110 irq_init();
112 sercomm_bind_uart(UART_MODEM);
113 cons_bind_uart(UART_IRDA);
115 /* initialize MODEM UART to be used for sercomm */
116 uart_init(UART_MODEM, with_irq);
117 uart_baudrate(UART_MODEM, UART_115200);
119 /* Initialize IRDA UART to be used for old-school console code.
120 * note: IRDA uart only accessible on C115 and C117 PCB */
121 uart_init(UART_IRDA, with_irq);
122 uart_baudrate(UART_IRDA, UART_115200);
124 /* Initialize hardware timers */
125 hwtimer_init();
127 /* Initialize DMA controller */
128 dma_init();
130 /* Initialize real time clock */
131 rtc_init();
133 /* Initialize system timers (uses hwtimer 2) */
134 timer_init();
136 /* Initialize ABB driver (uses SPI) */
137 twl3025_init();
139 /* Initialize TIFFS reader (8 sectors of 256 KiB each) */
140 tiffs_init(0x01800000, 0x40000, 8);