Project

General

Profile

Feature #3582 » os3582-20201001.patch

falconia, 10/01/2020 08:29 AM

View differences:

src/target/firmware/Makefile
43 43
# OpenMoko GTA0x
44 44
BOARD_gta0x_OBJS=$(calypso_COMMON_OBJS) board/gta0x/init.o \
45 45
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_power.o \
46
	board/gta0x/afcparams.o \
46 47
	battery/dummy.o $(FB_dummy_OBJS)
47 48
BOARD_gta0x_ENVIRONMENTS=highram
48 49

  
49 50
# Huawei GTM900-B
50 51
BOARD_gtm900b_OBJS=$(calypso_COMMON_OBJS) board/gtm900b/init.o \
51 52
	board/gtm900b/rffe_gtm900b.o board/gtm900b/rf_power.o \
53
	board/gtm900b/afcparams.o \
52 54
	battery/dummy.o $(FB_dummy_OBJS)
53 55
BOARD_gtm900b_ENVIRONMENTS=highram
54 56

  
55 57
# FreeCalypso FCDEV3B
56 58
BOARD_fcdev3b_OBJS=$(calypso_COMMON_OBJS) board/fcdev3b/init.o \
57 59
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_power.o \
60
	board/gta0x/afcparams.o \
58 61
	battery/dummy.o $(FB_dummy_OBJS)
59 62
BOARD_fcdev3b_ENVIRONMENTS=highram
60 63

  
61 64
# Pirelli DP-L10
62 65
BOARD_pirelli_dpl10_OBJS=$(calypso_COMMON_OBJS) board/pirelli_dpl10/init.o \
63 66
	board/pirelli_dpl10/rffe_dpl10_triband.o board/pirelli_dpl10/rf_power.o \
67
	board/pirelli_dpl10/afcparams.o \
64 68
	battery/dummy.o $(FB_dpl10_OBJS)
65 69
BOARD_pirelli_dpl10_ENVIRONMENTS=highram
66 70

  
67 71
# Compal Generic
68 72
compal_COMMON_OBJS=$(calypso_COMMON_OBJS) \
69
	board/compal/rffe_dualband.o board/compal/rf_power.o
73
	board/compal/rffe_dualband.o board/compal/afcparams.o \
74
	board/compal/rf_power.o
70 75
compal_COMMON_ENVIRONMENTS=compalram highram
71 76

  
72 77
# Compal E88
......
77 82
# Compal E86 (has a different RFFE configuration)
78 83
BOARD_compal_e86_OBJS=$(calypso_COMMON_OBJS) board/compal_e86/init.o \
79 84
	board/compal_e86/rffe_dualband_e86.o board/compal/rf_power.o \
85
	board/compal/afcparams.o \
80 86
	battery/dummy.o $(FB_e86_OBJS)
81 87
BOARD_compal_e86_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
82 88

  
src/target/firmware/board/compal/afcparams.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 *
20
 */
21

  
22
#include <stdint.h>
23
#include <rf/vcxocal.h>
24

  
25
/*
26
 * The following AFC initial DAC value and AFC slope settings are unchanged
27
 * from the old OsmocomBB code in which they were hard-coded in layer1/afc.c.
28
 * This AFC slope setting corresponds very closely to the original Leonardo
29
 * Psi values which are used by Motorola's official fw at least on the C139,
30
 * hence I have good reason to believe that they are indeed correct for the
31
 * Mot C1xx hardware target family.
32
 */
33
int16_t afc_initial_dac_value = -700;
34
int16_t afc_slope = 287;
src/target/firmware/board/gta0x/afcparams.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdint.h>
25
#include <rf/vcxocal.h>
26

  
27
/*
28
 * Here is a typical set of AFC Psi parameters for an FCDEV3B modem board,
29
 * computed by FreeCalypso fc-rfcal-vcxo calibration tool from frequency
30
 * offset measurements made with a CMU200 RF tester:
31
 *
32
 * Psi_sta_inv: 3462
33
 * Psi_st: 15
34
 * Psi_st_32: 992326
35
 * Psi_st_inv: 4328
36
 *
37
 * The following AFC slope number is the closest OsmocomBB-style afc_slope
38
 * integer corresponding to these Psi numbers; the true value is somewhere
39
 * between 454 and 455.
40
 *
41
 * This AFC slope setting is expected to be correct for both Openmoko and
42
 * FreeCalypso hardware as we use the same VCXO components as were used
43
 * by Openmoko.
44
 */
45
int16_t afc_slope = 454;
46

  
47
/*
48
 * The compiled-in AFC initial DAC value below is the same as was used by
49
 * the old OsmocomBB code written for Mot C1xx phones, but it will normally
50
 * be overridden by the per-unit factory calibration value read from the
51
 * /gsm/rf/afcdac file in FFS.
52
 */
53
int16_t afc_initial_dac_value = -700;
src/target/firmware/board/gtm900b/afcparams.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 *
20
 */
21

  
22
#include <stdint.h>
23
#include <rf/vcxocal.h>
24

  
25
/*
26
 * Here is a representative set of AFC Psi parameters that has been
27
 * calibrated by Huawei on a GTM900-B MGC2GSMT module, as recorded
28
 * in the /gsm/rf/afcparams file:
29
 *
30
 * Psi_sta_inv: 13626
31
 * Psi_st: 4
32
 * Psi_st_32: 252168
33
 * Psi_st_inv: 17032
34
 *
35
 * The following AFC slope number is the closest OsmocomBB-style afc_slope
36
 * integer corresponding to these Psi numbers; the true value is somewhere
37
 * between 115 and 116.
38
 */
39
int16_t afc_slope = 115;
40

  
41
/*
42
 * The compiled-in AFC initial DAC value below is the same as was used by
43
 * the old OsmocomBB code written for Mot C1xx phones, but it will normally
44
 * be overridden by the per-unit factory calibration value read from the
45
 * /gsm/rf/afcdac file in FFS.
46
 */
47
int16_t afc_initial_dac_value = -700;
src/target/firmware/board/pirelli_dpl10/afcparams.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 *
20
 */
21

  
22
#include <stdint.h>
23
#include <rf/vcxocal.h>
24

  
25
/*
26
 * Pirelli's official fw runs with the following Psi parameters, as read out
27
 * of a running fw via rftr 9 Test Mode command:
28
 *
29
 * Psi_sta_inv: 6974
30
 * Psi_st: 8
31
 * Psi_st_32: 492713
32
 * Psi_st_inv: 8717
33
 *
34
 * The following AFC slope number is the closest OsmocomBB-style afc_slope
35
 * integer corresponding to these Psi numbers; the true value is somewhere
36
 * between 225 and 226.
37
 */
38
int16_t afc_slope = 226;
39

  
40
/*
41
 * The compiled-in AFC initial DAC value below is the same as was used by
42
 * the old OsmocomBB code written for Mot C1xx phones, but it will normally
43
 * be overridden by the per-unit factory calibration value read from
44
 * Pirelli's factory data block.
45
 */
46
int16_t afc_initial_dac_value = -700;
src/target/firmware/include/rf/vcxocal.h
1
/*
2
 * Old OsmocomBB fw code used the same fixed and hard-coded numbers for
3
 * the slope of the VCXO and the initial AFC DAC setting for all Calypso
4
 * targets, but this approach is incorrect because different phone/modem
5
 * board designs use different VC(TC)XO components with different properties,
6
 * and some manufacturers have done per-unit calibration of their VC(TC)XO.
7
 *
8
 * We now have global variables in which these configuration or calibration
9
 * values are stored, and this header file provides the extern definitions
10
 * for these global vars.
11
 */
12

  
13
extern int16_t afc_initial_dac_value, afc_slope;
src/target/firmware/layer1/afc.c
30 30
#include <layer1/avg.h>
31 31
#include <calypso/dsp.h>
32 32

  
33
#define AFC_INITIAL_DAC_VALUE	-700
33
#include <rf/vcxocal.h>
34 34

  
35 35
/* Over how many TDMA frames do we want to average? (this may change in dedicated mode) */
36 36
#define AFC_PERIOD		40
......
53 53
		.period = AFC_PERIOD,
54 54
		.min_valid = AFC_MIN_MUN_VALID,
55 55
	},
56
	.dac_value = AFC_INITIAL_DAC_VALUE,
57 56
};
58 57

  
59 58
/* The AFC DAC in the ABB has to be configured as follows:
......
66 65
#define AFC_NORM_FACTOR_GSM	((1<<15) / 947)
67 66
#define AFC_NORM_FACTOR_DCS	((1<<15) / 1894)
68 67

  
69
/* we assume 8.769ppb per LSB, equals 0.008769 * 32768 == 287 */
70
//#define AFC_SLOPE		320
71
#define AFC_SLOPE		287
72

  
73 68
/* The DSP can measure the frequency error in the following ranges:
74 69
 * 	FB_MODE0:	+/- 20 kHz
75 70
 *	FB_MODE1:	+/-  4 kHz
......
92 87
		afc_norm_factor = AFC_NORM_FACTOR_DCS;
93 88
	}
94 89

  
95
	delta = (int16_t) ((afc_norm_factor * (int32_t)freq_error) / AFC_SLOPE);
90
	delta = (int16_t) ((afc_norm_factor * (int32_t)freq_error) / afc_slope);
96 91
	printd("afc_correct(error=%dHz, arfcn=%u): delta=%d, afc_dac(old=%d,new=%d)\n",
97 92
		freq_error, arfcn, delta, afc_state.dac_value, afc_state.dac_value+delta);
98 93
	afc_state.dac_value += delta;
......
106 101

  
107 102
void afc_reset(void)
108 103
{
109
	afc_state.dac_value = AFC_INITIAL_DAC_VALUE;
104
	afc_state.dac_value = afc_initial_dac_value;
110 105
}
111 106

  
112 107
void afc_input(int32_t freq_error, uint16_t arfcn, int valid)
113
- 
src/target/firmware/Makefile
38 38
FB_dummy_OBJS=$(FB_OBJS) fb/fb_dummy.o
39 39

  
40 40
# TI Calypso
41
calypso_COMMON_OBJS=board/common/calypso_uart.o board/common/calypso_pwl.o
41
calypso_COMMON_OBJS=board/common/calypso_uart.o \
42
	board/common/calypso_pwl.o board/common/tx_calchan.o
42 43

  
43 44
# OpenMoko GTA0x
44 45
BOARD_gta0x_OBJS=$(calypso_COMMON_OBJS) board/gta0x/init.o \
45
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_power.o \
46
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_tables.o \
46 47
	board/gta0x/afcparams.o \
47
	battery/dummy.o $(FB_dummy_OBJS)
48
	board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS)
48 49
BOARD_gta0x_ENVIRONMENTS=highram
49 50

  
50 51
# Huawei GTM900-B
51 52
BOARD_gtm900b_OBJS=$(calypso_COMMON_OBJS) board/gtm900b/init.o \
52
	board/gtm900b/rffe_gtm900b.o board/gtm900b/rf_power.o \
53
	board/gtm900b/rffe_gtm900b.o board/gta0x/rf_tables.o \
53 54
	board/gtm900b/afcparams.o \
54
	battery/dummy.o $(FB_dummy_OBJS)
55
	board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS)
55 56
BOARD_gtm900b_ENVIRONMENTS=highram
56 57

  
57 58
# FreeCalypso FCDEV3B
58 59
BOARD_fcdev3b_OBJS=$(calypso_COMMON_OBJS) board/fcdev3b/init.o \
59
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_power.o \
60
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_tables.o \
60 61
	board/gta0x/afcparams.o \
61
	battery/dummy.o $(FB_dummy_OBJS)
62
	board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS)
62 63
BOARD_fcdev3b_ENVIRONMENTS=highram
63 64

  
64 65
# Pirelli DP-L10
65 66
BOARD_pirelli_dpl10_OBJS=$(calypso_COMMON_OBJS) board/pirelli_dpl10/init.o \
66
	board/pirelli_dpl10/rffe_dpl10_triband.o board/pirelli_dpl10/rf_power.o \
67
	board/pirelli_dpl10/rffe_dpl10_triband.o \
68
	board/pirelli_dpl10/rf_tables.o board/pirelli_dpl10/readcal.o \
67 69
	board/pirelli_dpl10/afcparams.o \
68 70
	battery/dummy.o $(FB_dpl10_OBJS)
69 71
BOARD_pirelli_dpl10_ENVIRONMENTS=highram
......
71 73
# Compal Generic
72 74
compal_COMMON_OBJS=$(calypso_COMMON_OBJS) \
73 75
	board/compal/rffe_dualband.o board/compal/afcparams.o \
74
	board/compal/rf_power.o
76
	board/compal/readcal_common.o board/compal/tx_levels.o
75 77
compal_COMMON_ENVIRONMENTS=compalram highram
76 78

  
77 79
# Compal E88
78 80
BOARD_compal_e88_OBJS=$(compal_COMMON_OBJS) board/compal_e88/init.o \
81
	board/compal/readcal_small.o board/compal_e88/tx_ramps.o \
79 82
	battery/compal_e88.o $(FB_e88_OBJS)
80 83
BOARD_compal_e88_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) e88loader e88flash
81 84

  
82 85
# Compal E86 (has a different RFFE configuration)
83 86
BOARD_compal_e86_OBJS=$(calypso_COMMON_OBJS) board/compal_e86/init.o \
84
	board/compal_e86/rffe_dualband_e86.o board/compal/rf_power.o \
85
	board/compal/afcparams.o \
87
	board/compal_e86/rffe_dualband_e86.o board/compal_e86/tx_ramps.o \
88
	board/compal/afcparams.o board/compal/readcal_common.o \
89
	board/compal/readcal_small.o board/compal/tx_levels.o \
86 90
	battery/dummy.o $(FB_e86_OBJS)
87 91
BOARD_compal_e86_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
88 92

  
89 93
# Compal E99
90 94
BOARD_compal_e99_OBJS=$(compal_COMMON_OBJS) board/compal_e99/init.o \
95
	board/compal_e99/readcal.o board/compal_e88/tx_ramps.o \
91 96
	battery/dummy.o $(FB_e99_OBJS)
92 97
BOARD_compal_e99_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
93 98

  
94 99
# Sony Ericsson J100 (made by Compal)
95 100
BOARD_se_j100_OBJS=$(compal_COMMON_OBJS) board/se_j100/init.o \
101
	board/compal/readcal_small.o board/se_j100/tx_ramps.o \
96 102
	battery/dummy.o $(FB_j100_OBJS)
97 103
BOARD_se_j100_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
98 104

  
src/target/firmware/apps/layer1/main.c
33 33

  
34 34
#include <abb/twl3025.h>
35 35
#include <rf/trf6151.h>
36
#include <rf/readcal.h>
36 37

  
37 38
#include <comm/sercomm.h>
38 39
#include <comm/timer.h>
......
106 107
	memset(atr,0,sizeof(atr));
107 108
	atrLength = calypso_sim_powerup(atr);
108 109

  
110
	read_factory_rf_calibration();
109 111
	layer1_init();
110 112

  
111 113
	tpu_frame_irq_en(1, 1);
src/target/firmware/apps/rssi/main.c
34 34
#include <board.h>
35 35
#include <abb/twl3025.h>
36 36
#include <rf/trf6151.h>
37
#include <rf/readcal.h>
37 38
#include <calypso/clock.h>
38 39
#include <calypso/tpu.h>
39 40
#include <calypso/tsp.h>
......
1528 1529
	sercomm_register_rx_cb(SC_DLCI_CONSOLE, console_rx_cb);
1529 1530
	sercomm_register_rx_cb(SC_DLCI_L1A_L23, l1a_l23_rx_cb);
1530 1531

  
1532
	read_factory_rf_calibration();
1531 1533
	layer1_init();
1532 1534
	l1a_l23_tx_cb = l1a_l23_tx;
1533 1535

  
src/target/firmware/board/common/readcal_tiffs.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdio.h>
25
#include <stdint.h>
26
#include <string.h>
27

  
28
#include <rf/readcal.h>
29
#include <rf/txcal.h>
30
#include <tiffs.h>
31

  
32
static const struct calmap {
33
	char	*pathname;
34
	size_t	record_len;
35
	void	*buffer;
36
	void	(*postproc)(void);
37
} rf_cal_list[] = {
38
	{ "/gsm/rf/tx/ramps.850",    512, rf_tx_ramps_850,     NULL },
39
	{ "/gsm/rf/tx/levels.850",   128, rf_tx_levels_850,    NULL },
40
	{ "/gsm/rf/tx/calchan.850",  128, rf_tx_chan_cal_850,  NULL },
41
	{ "/gsm/rf/tx/ramps.900",    512, rf_tx_ramps_900,     NULL },
42
	{ "/gsm/rf/tx/levels.900",   128, rf_tx_levels_900,    NULL },
43
	{ "/gsm/rf/tx/calchan.900",  128, rf_tx_chan_cal_900,  NULL },
44
	{ "/gsm/rf/tx/ramps.1800",   512, rf_tx_ramps_1800,    NULL },
45
	{ "/gsm/rf/tx/levels.1800",  128, rf_tx_levels_1800,   NULL },
46
	{ "/gsm/rf/tx/calchan.1800", 128, rf_tx_chan_cal_1800, NULL },
47
	{ "/gsm/rf/tx/ramps.1900",   512, rf_tx_ramps_1900,    NULL },
48
	{ "/gsm/rf/tx/levels.1900",  128, rf_tx_levels_1900,   NULL },
49
	{ "/gsm/rf/tx/calchan.1900", 128, rf_tx_chan_cal_1900, NULL },
50
	{ NULL,                      0,   NULL,                NULL }
51
};
52

  
53
void read_factory_rf_calibration(void)
54
{
55
	const struct calmap *tp;
56
	uint8_t buf[512];
57
	int rc;
58

  
59
	puts("Checking TIFFS for the RF calibration records\n");
60
	for (tp = rf_cal_list; tp->pathname; tp++) {
61
		rc = tiffs_read_file_fixedlen(tp->pathname, buf,
62
					      tp->record_len);
63
		if (rc <= 0)
64
			continue;
65
		printf("Found '%s', applying\n", tp->pathname);
66
		memcpy(tp->buffer, buf, tp->record_len);
67
		if (tp->postproc)
68
			tp->postproc();
69
	}
70
}
src/target/firmware/board/common/tx_calchan.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdint.h>
25
#include <rf/txcal.h>
26

  
27
/*
28
 * On the better FreeCalypso, Openmoko and Pirelli targets, the following
29
 * Tx channel correction tables are placeholders to be overridden by
30
 * per-unit calibration, but Compal did their Tx channel calibration
31
 * in some different way which we haven't been able to grok, hence on
32
 * these targets we currently always run with these dummy tables,
33
 * and no channel-dependent corrections are applied.
34
 */
35

  
36
struct txcal_chan_cal rf_tx_chan_cal_850[RF_TX_CHAN_CAL_TABLE_SIZE]
37
					[RF_TX_NUM_SUB_BANDS] = {
38
	{
39
		{ 134, 128 },
40
		{ 150, 128 },
41
		{ 166, 128 },
42
		{ 182, 128 },
43
		{ 197, 128 },
44
		{ 213, 128 },
45
		{ 229, 128 },
46
		{ 251, 128 },
47
	},
48
	{
49
		{ 134, 128 },
50
		{ 150, 128 },
51
		{ 166, 128 },
52
		{ 182, 128 },
53
		{ 197, 128 },
54
		{ 213, 128 },
55
		{ 229, 128 },
56
		{ 251, 128 },
57
	},
58
	{
59
		{ 134, 128 },
60
		{ 150, 128 },
61
		{ 166, 128 },
62
		{ 182, 128 },
63
		{ 197, 128 },
64
		{ 213, 128 },
65
		{ 229, 128 },
66
		{ 251, 128 },
67
	},
68
	{
69
		{ 134, 128 },
70
		{ 150, 128 },
71
		{ 166, 128 },
72
		{ 182, 128 },
73
		{ 197, 128 },
74
		{ 213, 128 },
75
		{ 229, 128 },
76
		{ 251, 128 },
77
	},
78
};
79

  
80
struct txcal_chan_cal rf_tx_chan_cal_900[RF_TX_CHAN_CAL_TABLE_SIZE]
81
					[RF_TX_NUM_SUB_BANDS] = {
82
	{
83
		{   27, 128 },
84
		{   47, 128 },
85
		{   66, 128 },
86
		{   85, 128 },
87
		{  104, 128 },
88
		{  124, 128 },
89
		{  994, 128 },
90
		{ 1023, 128 },
91
	},
92
	{
93
		{   27, 128 },
94
		{   47, 128 },
95
		{   66, 128 },
96
		{   85, 128 },
97
		{  104, 128 },
98
		{  124, 128 },
99
		{  994, 128 },
100
		{ 1023, 128 },
101
	},
102
	{
103
		{   27, 128 },
104
		{   47, 128 },
105
		{   66, 128 },
106
		{   85, 128 },
107
		{  104, 128 },
108
		{  124, 128 },
109
		{  994, 128 },
110
		{ 1023, 128 },
111
	},
112
	{
113
		{   27, 128 },
114
		{   47, 128 },
115
		{   66, 128 },
116
		{   85, 128 },
117
		{  104, 128 },
118
		{  124, 128 },
119
		{  994, 128 },
120
		{ 1023, 128 },
121
	},
122
};
123

  
124
struct txcal_chan_cal rf_tx_chan_cal_1800[RF_TX_CHAN_CAL_TABLE_SIZE]
125
					 [RF_TX_NUM_SUB_BANDS] = {
126
	{
127
		{ 553, 128 },
128
		{ 594, 128 },
129
		{ 636, 128 },
130
		{ 677, 128 },
131
		{ 720, 128 },
132
		{ 760, 128 },
133
		{ 802, 128 },
134
		{ 885, 128 },
135
	},
136
	{
137
		{ 553, 128 },
138
		{ 594, 128 },
139
		{ 636, 128 },
140
		{ 677, 128 },
141
		{ 720, 128 },
142
		{ 760, 128 },
143
		{ 802, 128 },
144
		{ 885, 128 },
145
	},
146
	{
147
		{ 553, 128 },
148
		{ 594, 128 },
149
		{ 636, 128 },
150
		{ 677, 128 },
151
		{ 720, 128 },
152
		{ 760, 128 },
153
		{ 802, 128 },
154
		{ 885, 128 },
155
	},
156
	{
157
		{ 553, 128 },
158
		{ 594, 128 },
159
		{ 636, 128 },
160
		{ 677, 128 },
161
		{ 720, 128 },
162
		{ 760, 128 },
163
		{ 802, 128 },
164
		{ 885, 128 },
165
	},
166
};
167

  
168
struct txcal_chan_cal rf_tx_chan_cal_1900[RF_TX_CHAN_CAL_TABLE_SIZE]
169
					 [RF_TX_NUM_SUB_BANDS] = {
170
	{
171
		{ 549, 128 },
172
		{ 586, 128 },
173
		{ 623, 128 },
174
		{ 697, 128 },
175
		{ 726, 128 },
176
		{ 754, 128 },
177
		{ 782, 128 },
178
		{ 810, 128 },
179
	},
180
	{
181
		{ 549, 128 },
182
		{ 586, 128 },
183
		{ 623, 128 },
184
		{ 697, 128 },
185
		{ 726, 128 },
186
		{ 754, 128 },
187
		{ 782, 128 },
188
		{ 810, 128 },
189
	},
190
	{
191
		{ 549, 128 },
192
		{ 586, 128 },
193
		{ 623, 128 },
194
		{ 697, 128 },
195
		{ 726, 128 },
196
		{ 754, 128 },
197
		{ 782, 128 },
198
		{ 810, 128 },
199
	},
200
	{
201
		{ 549, 128 },
202
		{ 586, 128 },
203
		{ 623, 128 },
204
		{ 697, 128 },
205
		{ 726, 128 },
206
		{ 754, 128 },
207
		{ 782, 128 },
208
		{ 810, 128 },
209
	},
210
};
src/target/firmware/board/compal/readcal_common.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdio.h>
25
#include <stdint.h>
26
#include <string.h>
27
#include <inttypes.h>
28

  
29
#include <rf/txcal.h>
30

  
31
struct record_hdr {
32
	uint16_t valid_flag;
33
	uint16_t type;
34
	uint16_t native_len;
35
	uint16_t rounded_len;
36
};
37

  
38
static void apply_levels(struct txcal_tx_level *levels_table,
39
			 uint16_t *compal_data, unsigned start_level,
40
			 unsigned num_levels)
41
{
42
	unsigned n;
43

  
44
	for (n = 0; n < num_levels; n++)
45
		levels_table[start_level + n].apc = *compal_data++;
46
}
47

  
48
void read_compal_factory_records(uint32_t flash_addr)
49
{
50
	struct record_hdr *hdr;
51
	void *p, *sector_end;
52
	unsigned p_incr;
53
	void *payload;
54

  
55
	printf("Analyzing factory records sector "
56
		"at 0x%" PRIx32 "\n", flash_addr);
57

  
58
	p = (void *) flash_addr;
59
	sector_end = p + 0x2000;
60
	for (; p < sector_end; p += p_incr) {
61
		if ((sector_end - p) < 12)
62
			break;
63
		hdr = (struct record_hdr *)p;
64
		if (hdr->valid_flag == 0xFFFF)	/* blank flash */
65
			break;
66
		if (hdr->native_len > hdr->rounded_len) {
67
			printf("Bad record at 0x%" PRIx32 ": native length "
68
				"> rounded length\n", (uint32_t) p);
69
			return;
70
		}
71
		if (hdr->rounded_len & 3) {
72
			printf("Bad record at 0x%" PRIx32 ": rounded length "
73
				"is not aligned to 4\n", (uint32_t) p);
74
			return;
75
		}
76
		p_incr = hdr->rounded_len + 8;
77
		if (p_incr > (sector_end - p)) {
78
			printf("Bad record at 0x%" PRIx32 ": rounded length "
79
				"spills past the end of the sector\n", (uint32_t) p);
80
			return;
81
		}
82
		if (hdr->valid_flag != 0x000C)
83
			continue;
84
		payload = (void *)(hdr + 1);
85
		switch (hdr->type) {
86
		case 0x0000:
87
			if (hdr->native_len != 0x94)
88
				break;
89
			if (*(uint32_t *)(payload + 0x5C) != 0xAA)
90
				break;
91
			printf("Found 900 MHz band calibration record at "
92
				"0x%" PRIx32 ", applying\n", (uint32_t) p);
93
			apply_levels(rf_tx_levels_900, payload + 0x60, 5, 15);
94
			break;
95
		case 0x0001:
96
			if (hdr->native_len != 0xC8)
97
				break;
98
			if (*(uint32_t *)(payload + 0x7C) != 0xAA)
99
				break;
100
			printf("Found 1800 MHz band calibration record at "
101
				"0x%" PRIx32 ", applying\n", (uint32_t) p);
102
			apply_levels(rf_tx_levels_1800, payload + 0x80, 0, 16);
103
			break;
104
		case 0x0002:
105
			if (hdr->native_len != 0xB4)
106
				break;
107
			if (*(uint32_t *)(payload + 0x70) != 0xAA)
108
				break;
109
			printf("Found 1900 MHz band calibration record at "
110
				"0x%" PRIx32 ", applying\n", (uint32_t) p);
111
			apply_levels(rf_tx_levels_1900, payload + 0x74, 0, 16);
112
			break;
113
		case 0x0018:
114
			if (hdr->native_len != 0x88)
115
				break;
116
			if (*(uint32_t *)(payload + 0x54) != 0xAA)
117
				break;
118
			printf("Found 850 MHz band calibration record at "
119
				"0x%" PRIx32 ", applying\n", (uint32_t) p);
120
			apply_levels(rf_tx_levels_850, payload + 0x58, 5, 15);
121
			break;
122
		}
123
	}
124
}
src/target/firmware/board/compal/readcal_small.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 *
20
 */
21

  
22
#include <stdint.h>
23
#include <rf/readcal.h>
24

  
25
extern void read_compal_factory_records(uint32_t flash_addr);
26

  
27
void read_factory_rf_calibration(void)
28
{
29
	read_compal_factory_records(0x3FC000);
30
}
src/target/firmware/board/compal/rf_power.c
1
/* Tx RF power calibration for the Compal/Motorola dualband phones */
2

  
3
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
4
 *
5
 * All Rights Reserved
6
 *
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.
11
 *
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.
16
 *
17
 * You should have received a copy of the GNU General Public License along
18
 * with this program; if not, write to the Free Software Foundation, Inc.,
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
 *
21
 */
22

  
23
#include <stdint.h>
24
#include <osmocom/core/utils.h>
25

  
26
/* GSM900 ARFCN 33, Measurements by Steve Markgraf / May 2010 */
27
const int16_t dbm2apc_gsm900[] = {
28
	[0]     = 151,
29
	[1]     = 152,
30
	[2]     = 153,
31
	[3]     = 155,
32
	[4]     = 156,
33
	[5]     = 158,
34
	[6]     = 160,
35
	[7]     = 162,
36
	[8]     = 164,
37
	[9]     = 167,
38
	[10]    = 170,
39
	[11]    = 173,
40
	[12]    = 177,
41
	[13]    = 182,
42
	[14]    = 187,
43
	[15]    = 192,
44
	[16]    = 199,
45
	[17]    = 206,
46
	[18]    = 214,
47
	[19]    = 223,
48
	[20]    = 233,
49
	[21]    = 244,
50
	[22]    = 260,
51
	[23]    = 271,
52
	[24]    = 288,
53
	[25]    = 307,
54
	[26]    = 327,
55
	[27]    = 350,
56
	[28]    = 376,
57
	[29]    = 407,
58
	[30]    = 456,
59
	[31]    = 575,
60
};
61

  
62
const int dbm2apc_gsm900_max = ARRAY_SIZE(dbm2apc_gsm900) - 1;
src/target/firmware/board/compal/tx_levels.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdint.h>
25
#include <rf/txcal.h>
26

  
27
/*
28
 * The following Tx levels tables are the ones compiled into Compal's
29
 * firmwares; more specifically, they were originally extracted out
30
 * of the one special Mot C11x fw version for which we got the linker
31
 * map file with symbols and subsequently confirmed to be unchanged in
32
 * Mot C139 and SE J100 firmwares.  In normal operation the APC DAC values
33
 * in these levels tables are replaced with the ones read from the per-unit
34
 * and per-band factory calibration records.
35
 *
36
 * It should be noted that these compiled-in numbers are approximately
37
 * correct for the C11x/12x/155/156 family (SKY77324 RF PA) but are totally
38
 * wrong for the newer C139/140 (SKY77325) and SE J100 (SKY77328) hardware;
39
 * it appears that Compal never bothered with changing these compiled-in
40
 * numbers in their fw for the newer designs because the expectation is
41
 * that these compiled-in numbers are just dummy placeholders to be
42
 * overridden by per-unit calibration.
43
 */
44
struct txcal_tx_level rf_tx_levels_850[RF_TX_LEVELS_TABLE_SIZE] = {
45
	{ 560,  0,  0 }, /* 0 */
46
	{ 560,  0,  0 }, /* 1 */
47
	{ 560,  0,  0 }, /* 2 */
48
	{ 560,  0,  0 }, /* 3 */
49
	{ 560,  0,  0 }, /* 4 */
50
	{ 638,  0,  0 }, /* 5 */
51
	{ 554,  1,  0 }, /* 6 */
52
	{ 467,  2,  0 }, /* 7 */
53
	{ 395,  3,  0 }, /* 8 */
54
	{ 337,  4,  0 }, /* 9 */
55
	{ 290,  5,  0 }, /* 10 */
56
	{ 253,  6,  0 }, /* 11 */
57
	{ 224,  7,  0 }, /* 12 */
58
	{ 201,  8,  0 }, /* 13 */
59
	{ 183,  9,  0 }, /* 14 */
60
	{ 168, 10,  0 }, /* 15 */
61
	{ 157, 11,  0 }, /* 16 */
62
	{ 148, 12,  0 }, /* 17 */
63
	{ 141, 13,  0 }, /* 18 */
64
	{ 136, 14,  0 }, /* 19 */
65
	{  46, 14,  0 }, /* 20 */
66
	{  46, 14,  0 }, /* 21 */
67
	{  46, 14,  0 }, /* 22 */
68
	{  46, 14,  0 }, /* 23 */
69
	{  46, 14,  0 }, /* 24 */
70
	{  46, 14,  0 }, /* 25 */
71
	{  46, 14,  0 }, /* 26 */
72
	{  46, 14,  0 }, /* 27 */
73
	{  46, 14,  0 }, /* 28 */
74
	{  46, 14,  0 }, /* 29 */
75
	{  46, 14,  0 }, /* 30 */
76
	{  46, 14,  0 }, /* 31 */
77
};
78

  
79
struct txcal_tx_level rf_tx_levels_900[RF_TX_LEVELS_TABLE_SIZE] = {
80
	{ 550,  0,  0 }, /* 0 */
81
	{ 550,  0,  0 }, /* 1 */
82
	{ 550,  0,  0 }, /* 2 */
83
	{ 550,  0,  0 }, /* 3 */
84
	{ 550,  0,  0 }, /* 4 */
85
	{ 550,  0,  0 }, /* 5 */
86
	{ 476,  1,  0 }, /* 6 */
87
	{ 402,  2,  0 }, /* 7 */
88
	{ 338,  3,  0 }, /* 8 */
89
	{ 294,  4,  0 }, /* 9 */
90
	{ 260,  5,  0 }, /* 10 */
91
	{ 226,  6,  0 }, /* 11 */
92
	{ 204,  7,  0 }, /* 12 */
93
	{ 186,  8,  0 }, /* 13 */
94
	{ 172,  9,  0 }, /* 14 */
95
	{ 161, 10,  0 }, /* 15 */
96
	{ 153, 11,  0 }, /* 16 */
97
	{ 146, 12,  0 }, /* 17 */
98
	{ 141, 13,  0 }, /* 18 */
99
	{ 137, 14,  0 }, /* 19 */
100
	{  43, 14,  0 }, /* 20 */
101
	{  43, 14,  0 }, /* 21 */
102
	{  43, 14,  0 }, /* 22 */
103
	{  43, 14,  0 }, /* 23 */
104
	{  43, 14,  0 }, /* 24 */
105
	{  43, 14,  0 }, /* 25 */
106
	{  43, 14,  0 }, /* 26 */
107
	{  43, 14,  0 }, /* 27 */
108
	{  43, 14,  0 }, /* 28 */
109
	{  43, 14,  0 }, /* 29 */
110
	{  43, 14,  0 }, /* 30 */
111
	{  43, 14,  0 }, /* 31 */
112
};
113

  
114
struct txcal_tx_level rf_tx_levels_1800[RF_TX_LEVELS_TABLE_SIZE] = {
115
	{ 480,  0,  0 }, /* 0 */
116
	{ 416,  1,  0 }, /* 1 */
117
	{ 352,  2,  0 }, /* 2 */
118
	{ 308,  3,  0 }, /* 3 */
119
	{ 266,  4,  0 }, /* 4 */
120
	{ 242,  5,  0 }, /* 5 */
121
	{ 218,  6,  0 }, /* 6 */
122
	{ 200,  7,  0 }, /* 7 */
123
	{ 186,  8,  0 }, /* 8 */
124
	{ 175,  9,  0 }, /* 9 */
125
	{ 167, 10,  0 }, /* 10 */
126
	{ 160, 11,  0 }, /* 11 */
127
	{ 156, 12,  0 }, /* 12 */
128
	{ 152, 13,  0 }, /* 13 */
129
	{ 145, 14,  0 }, /* 14 */
130
	{ 142, 15,  0 }, /* 15 */
131
	{  61, 15,  0 }, /* 16 */
132
	{  61, 15,  0 }, /* 17 */
133
	{  61, 15,  0 }, /* 18 */
134
	{  61, 15,  0 }, /* 19 */
135
	{  61, 15,  0 }, /* 20 */
136
	{  61, 15,  0 }, /* 21 */
137
	{  61, 15,  0 }, /* 22 */
138
	{  61, 15,  0 }, /* 23 */
139
	{  61, 15,  0 }, /* 24 */
140
	{  61, 15,  0 }, /* 25 */
141
	{  61, 15,  0 }, /* 26 */
142
	{  61, 15,  0 }, /* 27 */
143
	{  61, 15,  0 }, /* 28 */
144
	{ 750,  0,  0 }, /* 29 */
145
	{ 750,  0,  0 }, /* 30 */
146
	{ 750,  0,  0 }, /* 31 */
147
};
148

  
149
struct txcal_tx_level rf_tx_levels_1900[RF_TX_LEVELS_TABLE_SIZE] = {
150
	{ 520,  0,  0 }, /* 0 */
151
	{ 465,  1,  0 }, /* 1 */
152
	{ 390,  2,  0 }, /* 2 */
153
	{ 330,  3,  0 }, /* 3 */
154
	{ 285,  4,  0 }, /* 4 */
155
	{ 250,  5,  0 }, /* 5 */
156
	{ 225,  6,  0 }, /* 6 */
157
	{ 205,  7,  0 }, /* 7 */
158
	{ 190,  8,  0 }, /* 8 */
159
	{ 177,  9,  0 }, /* 9 */
160
	{ 168, 10,  0 }, /* 10 */
161
	{ 161, 11,  0 }, /* 11 */
162
	{ 155, 12,  0 }, /* 12 */
163
	{ 150, 13,  0 }, /* 13 */
164
	{ 147, 14,  0 }, /* 14 */
165
	{ 143, 15,  0 }, /* 15 */
166
	{  62, 15,  0 }, /* 16 */
167
	{  62, 15,  0 }, /* 17 */
168
	{  62, 15,  0 }, /* 18 */
169
	{  62, 15,  0 }, /* 19 */
170
	{  62, 15,  0 }, /* 20 */
171
	{  62, 15,  0 }, /* 21 */
172
	{  62, 15,  0 }, /* 22 */
173
	{  62, 15,  0 }, /* 23 */
174
	{  62, 15,  0 }, /* 24 */
175
	{  62, 15,  0 }, /* 25 */
176
	{  62, 15,  0 }, /* 26 */
177
	{  62, 15,  0 }, /* 27 */
178
	{  62, 15,  0 }, /* 28 */
179
	{ 915,  0,  0 }, /* 29 */
180
	{ 915,  0,  0 }, /* 30 */
181
	{ 915,  0,  0 }, /* 31 */
182
};
src/target/firmware/board/compal_e86/tx_ramps.c
1
/*
2
 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3
 * who refuses to claim copyright on it and has released it as public domain
4
 * instead. NO rights reserved, all rights relinquished.
5
 *
6
 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 2 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License along
19
 * with this program; if not, write to the Free Software Foundation, Inc.,
20
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 *
22
 */
23

  
24
#include <stdint.h>
25
#include <rf/txcal.h>
26

  
27
/*
28
 * Mot C139/140 uses the same APC offset value as C11x, as verified by
29
 * breaking into a running C139 fw with tfc139, running fc-loadtool with
30
 * all ABB register state still intact from the interrupted official fw,
31
 * and reading the APCOFF register with the abbr command.
32
 */
33
uint8_t apc_offset = 32;
34

  
35
/*
36
 * The following tables of Tx ramp templates have been read out of an
37
 * official Mot C139 fw version via tms 1, rfpw 7 and ttr Test Mode commands.
38
 * Please note that these Tx ramp templates for the SKY77325 PA in Mot C139/140
39
 * phones are different from the older C11x/12x/155/156 (SKY77324) ones!
40
 */
41
struct txcal_ramp_def rf_tx_ramps_850[RF_TX_RAMP_SIZE] = {
42
      { /* profile 0 */
43
	/* ramp-up */
44
	{  0,  0,  3,  0,  0,  0,  0,  0,  2, 31, 30, 31, 31,  0,  0,  0},
45
	/* ramp-down */
46
	{ 20, 21, 31, 26, 10, 10, 10,  0,  0,  0,  0,  0,  0,  0,  0,  0},
47
      },
48
      { /* profile 1 */
49
	/* ramp-up */
50
	{  0,  0,  5,  0,  0,  0,  0,  0,  0, 31, 30, 31, 31,  0,  0,  0},
51
	/* ramp-down */
52
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
53
      },
54
      { /* profile 2 */
55
	/* ramp-up */
56
	{  0,  0,  5,  0,  0,  0,  0,  0,  0, 31, 30, 31, 31,  0,  0,  0},
57
	/* ramp-down */
58
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
59
      },
60
      { /* profile 3 */
61
	/* ramp-up */
62
	{  0,  0,  0,  5,  0,  0,  0,  0,  0, 31, 30, 31, 31,  0,  0,  0},
63
	/* ramp-down */
64
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
65
      },
66
      { /* profile 4 */
67
	/* ramp-up */
68
	{  0,  0,  0,  5,  0,  0,  0,  0,  0, 31, 30, 31, 31,  0,  0,  0},
69
	/* ramp-down */
70
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
71
      },
72
      { /* profile 5 */
73
	/* ramp-up */
74
	{  0,  0,  0,  8,  0,  0,  0,  0,  0, 28, 30, 31, 31,  0,  0,  0},
75
	/* ramp-down */
76
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
77
      },
78
      { /* profile 6 */
79
	/* ramp-up */
80
	{  0,  0,  0,  8,  0,  0,  0,  0,  0, 28, 30, 31, 31,  0,  0,  0},
81
	/* ramp-down */
82
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
83
      },
84
      { /* profile 7 */
85
	/* ramp-up */
86
	{  0,  0,  0, 12,  0,  0,  0,  0,  0, 20, 30, 31, 31,  4,  0,  0},
87
	/* ramp-down */
88
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
89
      },
90
      { /* profile 8 */
91
	/* ramp-up */
92
	{  0,  0,  0, 12,  0,  0,  0,  0,  0, 20, 30, 31, 31,  4,  0,  0},
93
	/* ramp-down */
94
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
95
      },
96
      { /* profile 9 */
97
	/* ramp-up */
98
	{  0,  0,  0, 17,  0,  0,  0,  0,  0, 25, 24, 31, 31,  0,  0,  0},
99
	/* ramp-down */
100
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
101
      },
102
      { /* profile 10 */
103
	/* ramp-up */
104
	{  0,  0,  0, 17,  0,  0,  0,  0,  0, 25, 24, 31, 31,  0,  0,  0},
105
	/* ramp-down */
106
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
107
      },
108
      { /* profile 11 */
109
	/* ramp-up */
110
	{  0,  0,  0, 17,  0,  0,  0,  0,  0, 14, 30, 31, 31,  5,  0,  0},
111
	/* ramp-down */
112
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
113
      },
114
      { /* profile 12 */
115
	/* ramp-up */
116
	{  0,  0,  0, 17,  0,  0,  0,  0,  0, 14, 30, 31, 31,  5,  0,  0},
117
	/* ramp-down */
118
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
119
      },
120
      { /* profile 13 */
121
	/* ramp-up */
122
	{  0,  0,  0, 28,  0,  0,  0,  0,  0,  0, 31, 31, 31,  7,  0,  0},
123
	/* ramp-down */
124
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
125
      },
126
      { /* profile 14 */
127
	/* ramp-up */
128
	{  0,  0,  0, 28,  0,  0,  0,  0,  0,  0, 31, 31, 31,  7,  0,  0},
129
	/* ramp-down */
130
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
131
      },
132
      { /* profile 15 */
133
	/* ramp-up */
134
	{  0,  0,  0, 28,  0,  0,  0,  0,  0,  0, 31, 31, 31,  7,  0,  0},
135
	/* ramp-down */
136
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
137
      },
138
};
139

  
140
struct txcal_ramp_def rf_tx_ramps_900[RF_TX_RAMP_SIZE] = {
141
      { /* profile 0 */
142
	/* ramp-up */
143
	{  0,  0,  2,  0,  0,  0,  0,  0, 13, 24, 24, 25, 26, 14,  0,  0},
144
	/* ramp-down */
145
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
146
      },
147
      { /* profile 1 */
148
	/* ramp-up */
149
	{  0,  0,  3,  0,  0,  0,  0,  0, 16, 24, 24, 30, 31,  0,  0,  0},
150
	/* ramp-down */
151
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
152
      },
153
      { /* profile 2 */
154
	/* ramp-up */
155
	{  0,  0,  3,  0,  0,  0,  0,  0, 16, 24, 24, 30, 31,  0,  0,  0},
156
	/* ramp-down */
157
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
158
      },
159
      { /* profile 3 */
160
	/* ramp-up */
161
	{  0,  0,  0,  4,  0,  0,  0,  0,  0, 31, 31, 30, 30,  2,  0,  0},
162
	/* ramp-down */
163
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
164
      },
165
      { /* profile 4 */
166
	/* ramp-up */
167
	{  0,  0,  0,  4,  0,  0,  0,  0,  0, 31, 31, 30, 30,  2,  0,  0},
168
	/* ramp-down */
169
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
170
      },
171
      { /* profile 5 */
172
	/* ramp-up */
173
	{  0,  0,  0,  0, 15,  0,  0,  0,  0,  0, 31, 31, 31, 20,  0,  0},
174
	/* ramp-down */
175
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
176
      },
177
      { /* profile 6 */
178
	/* ramp-up */
179
	{  0,  0,  0,  0, 15,  0,  0,  0,  0,  0, 31, 31, 31, 20,  0,  0},
180
	/* ramp-down */
181
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
182
      },
183
      { /* profile 7 */
184
	/* ramp-up */
185
	{  0,  0,  0,  0, 15,  0,  0,  0,  0,  0, 31, 31, 31, 20,  0,  0},
186
	/* ramp-down */
187
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
188
      },
189
      { /* profile 8 */
190
	/* ramp-up */
191
	{  0,  0,  0,  0, 15,  0,  0,  0,  0,  0, 31, 31, 31, 20,  0,  0},
192
	/* ramp-down */
193
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
194
      },
195
      { /* profile 9 */
196
	/* ramp-up */
197
	{  0,  0,  0,  0, 18,  0,  0,  0,  0,  0, 31, 31, 31, 17,  0,  0},
198
	/* ramp-down */
199
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
200
      },
201
      { /* profile 10 */
202
	/* ramp-up */
203
	{  0,  0,  0,  0, 20,  0,  0,  0,  0,  0, 31, 31, 31, 15,  0,  0},
204
	/* ramp-down */
205
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
206
      },
207
      { /* profile 11 */
208
	/* ramp-up */
209
	{  0,  0,  0,  0, 25,  0,  0,  0,  0,  0, 31, 31, 31, 10,  0,  0},
210
	/* ramp-down */
211
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
212
      },
213
      { /* profile 12 */
214
	/* ramp-up */
215
	{  0,  0,  0,  0, 25,  0,  0,  0,  0,  0, 31, 31, 31, 10,  0,  0},
216
	/* ramp-down */
217
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
... This diff was truncated because it exceeds the maximum size that can be displayed.
(5-5/5)
Add picture from clipboard (Maximum size: 48.8 MB)