treewide: remove FSF address
[osmocom-bb.git] / src / target / firmware / board / gta0x / init.c
blob49279d18150338177dfafbdf6537b5e577339928
1 /* Initialization for the Openmoko Freerunner modem */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
5 * All Rights Reserved
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #include <stdint.h>
20 #include <stdio.h>
22 #include <debug.h>
23 #include <ctors.h>
24 #include <memory.h>
25 #include <board.h>
26 #include <keypad.h>
27 #include <console.h>
28 #include <flash/cfi_flash.h>
29 #include <tiffs.h>
31 #include <calypso/irq.h>
32 #include <calypso/clock.h>
33 #include <calypso/dma.h>
34 #include <calypso/rtc.h>
35 #include <calypso/timer.h>
36 #include <uart.h>
37 #include <calypso/backlight.h>
39 #include <comm/sercomm.h>
40 #include <comm/timer.h>
42 #include <abb/twl3025.h>
43 #include <rf/trf6151.h>
44 #include "../compal/keymap.h"
46 #define ARMIO_LATCH_OUT 0xfffe4802
47 #define IO_CNTL_REG 0xfffe4804
48 #define ASIC_CONF_REG 0xfffef008
49 #define IO_CONF_REG 0xfffef00a
51 static void board_io_init(void)
53 uint16_t reg;
55 reg = readw(ASIC_CONF_REG);
56 /* TWL3025: Set SPI+RIF RX clock to rising edge */
57 reg |= (1 << 13) | (1 << 14);
58 writew(reg, ASIC_CONF_REG);
61 * Most Calypso peripheral interface signals are unconnected
62 * on this modem. We configure them to be GPIOs in IO_CONF_REG,
63 * then configure them to be outputs in IO_CNTL_REG, then set
64 * the outputs to 0 in ARMIO_LATCH_OUT.
66 writew(0x03F5, IO_CONF_REG);
67 writew(0xC000, IO_CNTL_REG);
68 writew(0x0000, ARMIO_LATCH_OUT);
71 void board_init(int with_irq)
73 /* Configure the memory interface */
74 calypso_mem_cfg(CALYPSO_nCS0, 3, CALYPSO_MEM_16bit, 1);
75 calypso_mem_cfg(CALYPSO_nCS1, 3, CALYPSO_MEM_16bit, 1);
76 calypso_mem_cfg(CALYPSO_nCS2, 5, CALYPSO_MEM_16bit, 1);
77 calypso_mem_cfg(CALYPSO_nCS3, 5, CALYPSO_MEM_16bit, 1);
78 calypso_mem_cfg(CALYPSO_CS4, 0, CALYPSO_MEM_8bit, 1);
79 calypso_mem_cfg(CALYPSO_nCS6, 0, CALYPSO_MEM_32bit, 1);
80 calypso_mem_cfg(CALYPSO_nCS7, 0, CALYPSO_MEM_32bit, 0);
82 /* Set VTCXO_DIV2 = 1, configure PLL for 104 MHz and give ARM half of that */
83 calypso_clock_set(2, CALYPSO_PLL13_104_MHZ, ARM_MCLK_DIV_2);
85 /* Configure the RHEA bridge with some sane default values */
86 calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0);
88 /* Initialize board-specific GPIO */
89 board_io_init();
91 /* Enable bootrom mapping to route exception vectors to RAM */
92 calypso_bootrom(with_irq);
93 calypso_exceptions_install();
95 /* Initialize interrupt controller */
96 if (with_irq)
97 irq_init();
99 sercomm_bind_uart(UART_MODEM);
100 cons_bind_uart(UART_IRDA);
102 /* initialize MODEM UART to be used for sercomm */
103 uart_init(UART_MODEM, with_irq);
104 uart_baudrate(UART_MODEM, UART_115200);
106 /* Initialize IRDA UART to be used for old-school console code.
107 * note: IRDA uart only accessible on C115 and C117 PCB */
108 uart_init(UART_IRDA, with_irq);
109 uart_baudrate(UART_IRDA, UART_115200);
111 /* Initialize hardware timers */
112 hwtimer_init();
114 /* Initialize DMA controller */
115 dma_init();
117 /* Initialize real time clock */
118 rtc_init();
120 /* Initialize system timers (uses hwtimer 2) */
121 timer_init();
123 /* Initialize LCD driver (uses I2C) and backlight */
124 bl_mode_pwl(1);
125 bl_level(50);
127 /* Initialize keypad driver */
128 keypad_init(keymap, with_irq);
130 /* Initialize ABB driver (uses SPI) */
131 twl3025_init();
133 /* Initialize TIFFS reader (7 sectors of 64 KiB each) */
134 tiffs_init(0x380000, 0x10000, 7);