diff options
author | Steve Markgraf <steve@steve-m.de> | 2022-11-07 22:14:33 +0100 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2022-12-09 12:30:55 +0000 |
commit | d78f88c25adbe087e57324b9837d181d7a5f7368 (patch) | |
tree | c7385785f09c0d22b0b07a6b140d128df8df0314 | |
parent | 10eeb3cac98dea485cbb87abe313abe62d7c1b84 (diff) |
fw: Add initial support for Sony Ericsson K200i/K220i phones
Includes RF frontend configuration, TIFFS config, keymap.
Currently still using the rf_tables and afcparams from gta0x.
No display driver yet.
Make sure to run osmocon with -m romload -i 10
Change-Id: I711702862b1cec5a8089dac071f8a171ca026003
-rw-r--r-- | src/target/firmware/Makefile | 8 | ||||
-rw-r--r-- | src/target/firmware/board/se_k2x0/init.c | 129 | ||||
-rw-r--r-- | src/target/firmware/board/se_k2x0/keymap.h | 28 | ||||
-rw-r--r-- | src/target/firmware/board/se_k2x0/rffe_k2x0.c | 122 |
4 files changed, 286 insertions, 1 deletions
diff --git a/src/target/firmware/Makefile b/src/target/firmware/Makefile index d1ab0c6e..af50d45e 100644 --- a/src/target/firmware/Makefile +++ b/src/target/firmware/Makefile @@ -24,7 +24,7 @@ ENV_e88flash_OBJS=board/compal/start.rom.o board/compal/header.o board/compal/ex # # List of all supported boards (meant to be overridden on command line) -BOARDS?=compal_e88 compal_e86 compal_e99 se_j100 gta0x gtm900b fcdev3b pirelli_dpl10 +BOARDS?=compal_e88 compal_e86 compal_e99 se_j100 se_k2x0 gta0x gtm900b fcdev3b pirelli_dpl10 # Framebuffer support, board specific drivers FB_OBJS=fb/framebuffer.o fb/font.o fb/helvR08.o fb/helvB14.o fb/c64.o \ @@ -100,6 +100,12 @@ BOARD_se_j100_OBJS=$(compal_COMMON_OBJS) board/se_j100/init.o \ battery/dummy.o $(FB_j100_OBJS) BOARD_se_j100_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) +# Sony Ericsson K200i/K220i +BOARD_se_k2x0_OBJS=$(calypso_COMMON_OBJS) board/se_k2x0/init.o \ + board/se_k2x0/rffe_k2x0.o \ + board/gta0x/rf_tables.o board/gta0x/afcparams.o \ + board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS) +BOARD_se_k2x0_ENVIRONMENTS=highram # # Applications diff --git a/src/target/firmware/board/se_k2x0/init.c b/src/target/firmware/board/se_k2x0/init.c new file mode 100644 index 00000000..ebd32a72 --- /dev/null +++ b/src/target/firmware/board/se_k2x0/init.c @@ -0,0 +1,129 @@ +/* Initialization for the Sony Ericsson K200i/K220i */ + +/* (C) 2010 by Harald Welte <laforge@gnumonks.org> + * (C) 2010-22 by Steve Markgraf <steve@steve-m.de> + * + * 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. + * + */ + +#include <stdint.h> +#include <stdio.h> + +#include <debug.h> +#include <ctors.h> +#include <memory.h> +#include <board.h> +#include <keypad.h> +#include <console.h> +#include <flash/cfi_flash.h> + +#include <calypso/irq.h> +#include <calypso/clock.h> +#include <calypso/dma.h> +#include <calypso/rtc.h> +#include <calypso/timer.h> +#include <uart.h> +#include <calypso/backlight.h> + +#include <comm/sercomm.h> +#include <comm/timer.h> + +#include <abb/twl3025.h> +#include <rf/trf6151.h> + +#include <fb/framebuffer.h> +#include "keymap.h" + +#define ASIC_CONF_REG 0xfffef008 + +static void board_io_init(void) +{ + uint16_t reg; + + reg = readw(ASIC_CONF_REG); + /* TWL3025: Set SPI+RIF RX clock to rising edge */ + reg |= (1 << 13) | (1 << 14); + writew(reg, ASIC_CONF_REG); +} + +void board_init(int with_irq) +{ + /* Disable watchdog (compal loader leaves it enabled) */ + wdog_enable(0); + + /* Configure the memory interface - TODO: adapt for K2x0i, right now just + * copied from Pirelli DP-L10 */ + calypso_mem_cfg(CALYPSO_nCS0, 4, CALYPSO_MEM_16bit, 1); + calypso_mem_cfg(CALYPSO_nCS1, 4, CALYPSO_MEM_16bit, 1); + calypso_mem_cfg(CALYPSO_nCS2, 5, CALYPSO_MEM_16bit, 1); + calypso_mem_cfg(CALYPSO_nCS3, 4, CALYPSO_MEM_16bit, 1); + calypso_mem_cfg(CALYPSO_CS4, 7, CALYPSO_MEM_16bit, 1); + calypso_mem_cfg(CALYPSO_nCS6, 0, CALYPSO_MEM_32bit, 1); + calypso_mem_cfg(CALYPSO_nCS7, 0, CALYPSO_MEM_32bit, 0); + + /* Set VTCXO_DIV2 = 1, configure PLL for 104 MHz and give ARM half of that */ + calypso_clock_set(2, CALYPSO_PLL13_104_MHZ, ARM_MCLK_DIV_2); + + /* Configure the RHEA bridge with some sane default values */ + calypso_rhea_cfg(0, 0, 0xff, 0, 1, 0, 0); + + /* Initialize board-specific GPIO */ + board_io_init(); + + /* Enable bootrom mapping to route exception vectors to RAM */ + calypso_bootrom(with_irq); + calypso_exceptions_install(); + + /* Initialize interrupt controller */ + if (with_irq) + irq_init(); + + sercomm_bind_uart(UART_MODEM); + cons_bind_uart(UART_IRDA); + + /* initialize MODEM UART to be used for sercomm */ + uart_init(UART_MODEM, with_irq); + uart_baudrate(UART_MODEM, UART_115200); + + /* initialize IRDA UART to be used for old-school console code. + * note: IRDA uart only accessible on C115 and C117 PCB */ + uart_init(UART_IRDA, with_irq); + uart_baudrate(UART_IRDA, UART_115200); + + /* Initialize hardware timers */ + hwtimer_init(); + + /* Initialize DMA controller */ + dma_init(); + + /* Initialize real time clock */ + rtc_init(); + + /* Initialize system timers (uses hwtimer 2) */ + timer_init(); + + /* Initialize LCD driver and backlight */ + fb_init(); + bl_mode_pwl(1); + bl_level(50); + + /* Initialize keypad driver */ + keypad_init(keymap, with_irq); + + /* Initialize ABB driver (uses SPI) */ + twl3025_init(); + + /* Initialize TIFFS reader (13 sectors of 256 KiB each) */ + tiffs_init(0x01800000, 0x40000, 13); +} diff --git a/src/target/firmware/board/se_k2x0/keymap.h b/src/target/firmware/board/se_k2x0/keymap.h new file mode 100644 index 00000000..aa2d8a56 --- /dev/null +++ b/src/target/firmware/board/se_k2x0/keymap.h @@ -0,0 +1,28 @@ +/* Keymap for SE K200i/K220i */ +static const uint8_t keymap[] = { + [KEY_0] = 9, + [KEY_1] = 1, + [KEY_2] = 6, + [KEY_3] = 11, + [KEY_4] = 2, + [KEY_5] = 7, + [KEY_6] = 12, + [KEY_7] = 3, + [KEY_8] = 8, + [KEY_9] = 13, + [KEY_STAR] = 4, + [KEY_HASH] = 14, + [KEY_MENU] = 21, /* not existent */ + [KEY_LEFT_SB] = 0, + [KEY_RIGHT_SB] = 5, + [KEY_UP] = 16, + [KEY_DOWN] = 15, + [KEY_LEFT] = 17, + [KEY_RIGHT] = 18, + [KEY_OK] = 10, +/* power button is not connected to keypad scan matrix but to TWL3025 */ + [KEY_POWER] = 31, + [KEY_MINUS] = 22, /* not existent */ + [KEY_PLUS] = 23, /* not existent */ + [KEY_CAMERA] = 24, /* not existent */ +}; diff --git a/src/target/firmware/board/se_k2x0/rffe_k2x0.c b/src/target/firmware/board/se_k2x0/rffe_k2x0.c new file mode 100644 index 00000000..f9965acd --- /dev/null +++ b/src/target/firmware/board/se_k2x0/rffe_k2x0.c @@ -0,0 +1,122 @@ +/* RF frontend driver for Sony Ericsson K200i/K220i */ + +/* (C) 2022 by Steve Markgraf <steve@steve-m.de> + * + * 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, see <http://www.gnu.org/licenses/>. + * + */ + +#include <stdint.h> +#include <stdio.h> + +#include <debug.h> +#include <memory.h> +#include <rffe.h> +#include <calypso/tsp.h> +#include <rf/trf6151.h> + +/* This is a value that has been measured on the C123 by Harald: 71dBm, + it is the difference between the input level at the antenna and what + the DSP reports, subtracted by the total gain of the TRF6151 */ +#define SYSTEM_INHERENT_GAIN 71 + +/* describe how the RF frontend is wired on the SE K200i/K220i */ +#define RITA_RESET TSPACT(0) /* Reset of the Rita TRF6151, correct for K200i */ +#define PA_ENABLE TSPACT(9) /* Enable the Power Amplifier */ +#define DCS_TXEN TSPACT(3) /* DCS (as opposed to GSM) Transmit */ + +#define ASM_VC1 TSPACT(1) /* GSM1800 TX at antenna switch, inverted */ +#define ASM_VC2 TSPACT(2) /* GSM900 TX at antenna switch, inverted */ + +#define IOTA_STROBE TSPEN(1) /* Strobe for the Iota TSP */ +#define RITA_STROBE TSPEN(2) /* Strobe for the Rita TSP */ + +/* switch RF Frontend Mode */ +void rffe_mode(enum gsm_band band, int tx) +{ + uint16_t tspact = tsp_act_state(); + + /* First we mask off all bits from the state cache */ + tspact &= ~(PA_ENABLE | DCS_TXEN); + tspact |= ASM_VC1 | ASM_VC2; + +#ifdef CONFIG_TX_ENABLE + /* Then we selectively set the bits on, if required */ + if (tx) { + if ((band == GSM_BAND_1800) || band == (GSM_BAND_1900)) { + tspact |= DCS_TXEN; + tspact &= ~ASM_VC1; + } else + tspact &= ~ASM_VC2; + + tspact |= PA_ENABLE; + } +#endif /* TRANSMIT_SUPPORT */ + + tsp_act_update(tspact); +} + +uint32_t rffe_get_rx_ports(void) +{ + return (1 << PORT_LO) | (1 << PORT_DCS1800) | (1 << PORT_PCS1900); +} + +uint32_t rffe_get_tx_ports(void) +{ + return (1 << PORT_LO) | (1 << PORT_HI); +} + +/* Returns need for IQ swap */ +int rffe_iq_swapped(uint16_t band_arfcn, int tx) +{ + return trf6151_iq_swapped(band_arfcn, tx); +} + +#define MCU_SW_TRACE 0xfffef00e +#define ARM_CONF_REG 0xfffef006 +#define ASIC_CONF_REG 0xfffef008 + +void rffe_init(void) +{ + /* Configure the TSPEN which is connected to the TWL3025 */ + tsp_setup(IOTA_STROBE, 1, 0, 0); + + trf6151_init(RITA_STROBE, RITA_RESET); +} + +uint8_t rffe_get_gain(void) +{ + return trf6151_get_gain(); +} + +void rffe_set_gain(uint8_t dbm) +{ + trf6151_set_gain(dbm); +} + +const uint8_t system_inherent_gain = SYSTEM_INHERENT_GAIN; + +/* Given the expected input level of exp_inp dBm/8 and the target of target_bb + * dBm8, configure the RF Frontend with the respective gain */ +void rffe_compute_gain(int16_t exp_inp, int16_t target_bb) +{ + trf6151_compute_gain(exp_inp, target_bb); +} + +void rffe_rx_win_ctrl(int16_t exp_inp, int16_t target_bb) +{ + /* FIXME */ +} |