Project

General

Profile

Feature #3582 » os3582-20190316.patch

falconia, 03/17/2019 12:28 AM

View differences:

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
	battery/dummy.o $(FB_dummy_OBJS)
46
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_tables.o \
47
	board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS)
47 48
BOARD_gta0x_ENVIRONMENTS=highram
48 49

  
49 50
# FreeCalypso FCDEV3B
50 51
BOARD_fcdev3b_OBJS=$(calypso_COMMON_OBJS) board/fcdev3b/init.o \
51
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_power.o \
52
	battery/dummy.o $(FB_dummy_OBJS)
52
	board/gta0x/rffe_gta0x_triband.o board/gta0x/rf_tables.o \
53
	board/common/readcal_tiffs.o battery/dummy.o $(FB_dummy_OBJS)
53 54
BOARD_fcdev3b_ENVIRONMENTS=highram
54 55

  
55 56
# Pirelli DP-L10
56 57
BOARD_pirelli_dpl10_OBJS=$(calypso_COMMON_OBJS) board/pirelli_dpl10/init.o \
57
	board/pirelli_dpl10/rffe_dpl10_triband.o board/pirelli_dpl10/rf_power.o \
58
	board/pirelli_dpl10/rffe_dpl10_triband.o \
59
	board/pirelli_dpl10/rf_tables.o board/pirelli_dpl10/readcal.o \
58 60
	battery/dummy.o $(FB_dpl10_OBJS)
59 61
BOARD_pirelli_dpl10_ENVIRONMENTS=highram
60 62

  
61 63
# Compal Generic
62 64
compal_COMMON_OBJS=$(calypso_COMMON_OBJS) \
63
	board/compal/rffe_dualband.o board/compal/rf_power.o
65
	board/compal/rffe_dualband.o board/compal/rf_tables.o \
66
	board/compal/readcal_common.o
64 67
compal_COMMON_ENVIRONMENTS=compalram highram
65 68

  
66 69
# Compal E88
67 70
BOARD_compal_e88_OBJS=$(compal_COMMON_OBJS) board/compal_e88/init.o \
71
	board/compal/readcal_small.o board/compal_e88/tx_ramps.o \
68 72
	battery/compal_e88.o $(FB_e88_OBJS)
69 73
BOARD_compal_e88_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS) e88loader e88flash
70 74

  
71 75
# Compal E86 (has a different RFFE configuration)
72 76
BOARD_compal_e86_OBJS=$(calypso_COMMON_OBJS) board/compal_e86/init.o \
73
	board/compal_e86/rffe_dualband_e86.o board/compal/rf_power.o \
74
	battery/dummy.o $(FB_e86_OBJS)
77
	board/compal_e86/rffe_dualband_e86.o board/compal/rf_tables.o \
78
	board/compal/readcal_common.o board/compal/readcal_small.o \
79
	board/compal_e86/tx_ramps.o battery/dummy.o $(FB_e86_OBJS)
75 80
BOARD_compal_e86_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
76 81

  
77 82
# Compal E99
78 83
BOARD_compal_e99_OBJS=$(compal_COMMON_OBJS) board/compal_e99/init.o \
84
	board/compal_e99/readcal.o board/compal_e88/tx_ramps.o \
79 85
	battery/dummy.o $(FB_e99_OBJS)
80 86
BOARD_compal_e99_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
81 87

  
82 88
# Sony Ericsson J100 (made by Compal)
83 89
BOARD_se_j100_OBJS=$(compal_COMMON_OBJS) board/se_j100/init.o \
90
	board/compal/readcal_small.o board/se_j100/tx_ramps.o \
84 91
	battery/dummy.o $(FB_j100_OBJS)
85 92
BOARD_se_j100_ENVIRONMENTS=$(compal_COMMON_ENVIRONMENTS)
86 93

  
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/vcxocal.h>
30
#include <rf/txcal.h>
31
#include <tiffs.h>
32

  
33
static int16_t afcdac_shifted;
34

  
35
static void afcdac_postproc(void)
36
{
37
	afc_initial_dac_value = afcdac_shifted >> 3;
38
}
39

  
40
static const struct calmap {
41
	char	*pathname;
42
	size_t	record_len;
43
	void	*buffer;
44
	void	(*postproc)(void);
45
} rf_cal_list[] = {
46
	{ "/gsm/rf/afcdac",          2,   &afcdac_shifted,     afcdac_postproc },
47
	{ "/gsm/rf/tx/ramps.850",    512, rf_tx_ramps_850,     NULL },
48
	{ "/gsm/rf/tx/levels.850",   128, rf_tx_levels_850,    NULL },
49
	{ "/gsm/rf/tx/calchan.850",  128, rf_tx_chan_cal_850,  NULL },
50
	{ "/gsm/rf/tx/ramps.900",    512, rf_tx_ramps_900,     NULL },
51
	{ "/gsm/rf/tx/levels.900",   128, rf_tx_levels_900,    NULL },
52
	{ "/gsm/rf/tx/calchan.900",  128, rf_tx_chan_cal_900,  NULL },
53
	{ "/gsm/rf/tx/ramps.1800",   512, rf_tx_ramps_1800,    NULL },
54
	{ "/gsm/rf/tx/levels.1800",  128, rf_tx_levels_1800,   NULL },
55
	{ "/gsm/rf/tx/calchan.1800", 128, rf_tx_chan_cal_1800, NULL },
56
	{ "/gsm/rf/tx/ramps.1900",   512, rf_tx_ramps_1900,    NULL },
57
	{ "/gsm/rf/tx/levels.1900",  128, rf_tx_levels_1900,   NULL },
58
	{ "/gsm/rf/tx/calchan.1900", 128, rf_tx_chan_cal_1900, NULL },
59
	{ NULL,                      0,   NULL,                NULL }
60
};
61

  
62
void read_factory_rf_calibration(void)
63
{
64
	const struct calmap *tp;
65
	uint8_t buf[512];
66
	int rc;
67

  
68
	puts("Checking TIFFS for the RF calibration records\n");
69
	for (tp = rf_cal_list; tp->pathname; tp++) {
70
		rc = tiffs_read_file_fixedlen(tp->pathname, buf,
71
					      tp->record_len);
72
		if (rc <= 0)
73
			continue;
74
		printf("Found '%s', applying\n", tp->pathname);
75
		memcpy(tp->buffer, buf, tp->record_len);
76
		if (tp->postproc)
77
			tp->postproc();
78
	}
79
}
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/rf_tables.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
#include <rf/vcxocal.h>
27

  
28
/*
29
 * The following AFC initial DAC value and AFC slope settings are unchanged
30
 * from the old OsmocomBB code in which they were hard-coded in layer1/afc.c.
31
 * This AFC slope setting corresponds very closely to the original Leonardo
32
 * Psi values which are used by Motorola's official fw at least on the C139,
33
 * hence I have good reason to believe that they are indeed correct for the
34
 * Mot C1xx hardware target family.
35
 */
36
int16_t afc_initial_dac_value = -700;
37
int16_t afc_slope = 287;
38

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

  
91
struct txcal_tx_level rf_tx_levels_900[RF_TX_LEVELS_TABLE_SIZE] = {
92
	{ 550,  0,  0 }, /* 0 */
93
	{ 550,  0,  0 }, /* 1 */
94
	{ 550,  0,  0 }, /* 2 */
95
	{ 550,  0,  0 }, /* 3 */
96
	{ 550,  0,  0 }, /* 4 */
97
	{ 550,  0,  0 }, /* 5 */
98
	{ 476,  1,  0 }, /* 6 */
99
	{ 402,  2,  0 }, /* 7 */
100
	{ 338,  3,  0 }, /* 8 */
101
	{ 294,  4,  0 }, /* 9 */
102
	{ 260,  5,  0 }, /* 10 */
103
	{ 226,  6,  0 }, /* 11 */
104
	{ 204,  7,  0 }, /* 12 */
105
	{ 186,  8,  0 }, /* 13 */
106
	{ 172,  9,  0 }, /* 14 */
107
	{ 161, 10,  0 }, /* 15 */
108
	{ 153, 11,  0 }, /* 16 */
109
	{ 146, 12,  0 }, /* 17 */
110
	{ 141, 13,  0 }, /* 18 */
111
	{ 137, 14,  0 }, /* 19 */
112
	{  43, 14,  0 }, /* 20 */
113
	{  43, 14,  0 }, /* 21 */
114
	{  43, 14,  0 }, /* 22 */
115
	{  43, 14,  0 }, /* 23 */
116
	{  43, 14,  0 }, /* 24 */
117
	{  43, 14,  0 }, /* 25 */
118
	{  43, 14,  0 }, /* 26 */
119
	{  43, 14,  0 }, /* 27 */
120
	{  43, 14,  0 }, /* 28 */
121
	{  43, 14,  0 }, /* 29 */
122
	{  43, 14,  0 }, /* 30 */
123
	{  43, 14,  0 }, /* 31 */
124
};
125

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

  
161
struct txcal_tx_level rf_tx_levels_1900[RF_TX_LEVELS_TABLE_SIZE] = {
162
	{ 520,  0,  0 }, /* 0 */
163
	{ 465,  1,  0 }, /* 1 */
164
	{ 390,  2,  0 }, /* 2 */
165
	{ 330,  3,  0 }, /* 3 */
166
	{ 285,  4,  0 }, /* 4 */
167
	{ 250,  5,  0 }, /* 5 */
168
	{ 225,  6,  0 }, /* 6 */
169
	{ 205,  7,  0 }, /* 7 */
170
	{ 190,  8,  0 }, /* 8 */
171
	{ 177,  9,  0 }, /* 9 */
172
	{ 168, 10,  0 }, /* 10 */
173
	{ 161, 11,  0 }, /* 11 */
174
	{ 155, 12,  0 }, /* 12 */
175
	{ 150, 13,  0 }, /* 13 */
176
	{ 147, 14,  0 }, /* 14 */
177
	{ 143, 15,  0 }, /* 15 */
178
	{  62, 15,  0 }, /* 16 */
179
	{  62, 15,  0 }, /* 17 */
180
	{  62, 15,  0 }, /* 18 */
181
	{  62, 15,  0 }, /* 19 */
182
	{  62, 15,  0 }, /* 20 */
183
	{  62, 15,  0 }, /* 21 */
184
	{  62, 15,  0 }, /* 22 */
185
	{  62, 15,  0 }, /* 23 */
186
	{  62, 15,  0 }, /* 24 */
187
	{  62, 15,  0 }, /* 25 */
188
	{  62, 15,  0 }, /* 26 */
189
	{  62, 15,  0 }, /* 27 */
190
	{  62, 15,  0 }, /* 28 */
191
	{ 915,  0,  0 }, /* 29 */
192
	{ 915,  0,  0 }, /* 30 */
193
	{ 915,  0,  0 }, /* 31 */
194
};
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},
218
      },
219
      { /* profile 13 */
220
	/* ramp-up */
221
	{  0,  0,  0,  0, 25,  0,  0,  0,  0,  0, 31, 31, 31, 10,  0,  0},
222
	/* ramp-down */
223
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
224
      },
225
      { /* profile 14 */
226
	/* ramp-up */
227
	{  0,  0,  0,  0, 30,  0,  0,  0,  0,  0, 31, 31, 31,  5,  0,  0},
228
	/* ramp-down */
229
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
230
      },
231
      { /* profile 15 */
232
	/* ramp-up */
233
	{  0,  0,  0,  0, 30,  0,  0,  0,  0,  0, 31, 31, 31,  5,  0,  0},
234
	/* ramp-down */
235
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
236
      },
237
};
238

  
239
struct txcal_ramp_def rf_tx_ramps_1800[RF_TX_RAMP_SIZE] = {
240
      { /* profile 0 */
241
	/* ramp-up */
242
	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 26, 26, 30, 30, 10,  0,  0},
243
	/* ramp-down */
244
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
245
      },
246
      { /* profile 1 */
247
	/* ramp-up */
248
	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 26, 26, 30, 30, 10,  0,  0},
249
	/* ramp-down */
250
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
251
      },
252
      { /* profile 2 */
253
	/* ramp-up */
254
	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 26, 26, 30, 30, 10,  0,  0},
255
	/* ramp-down */
256
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
257
      },
258
      { /* profile 3 */
259
	/* ramp-up */
260
	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30,  2,  0,  0},
261
	/* ramp-down */
262
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
263
      },
264
      { /* profile 4 */
265
	/* ramp-up */
266
	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 30,  2,  0,  0},
267
	/* ramp-down */
268
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
269
      },
270
      { /* profile 5 */
271
	/* ramp-up */
272
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
273
	/* ramp-down */
274
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
275
      },
276
      { /* profile 6 */
277
	/* ramp-up */
278
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
279
	/* ramp-down */
280
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
281
      },
282
      { /* profile 7 */
283
	/* ramp-up */
284
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
285
	/* ramp-down */
286
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
287
      },
288
      { /* profile 8 */
289
	/* ramp-up */
290
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
291
	/* ramp-down */
292
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
293
      },
294
      { /* profile 9 */
295
	/* ramp-up */
296
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
297
	/* ramp-down */
298
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
299
      },
300
      { /* profile 10 */
301
	/* ramp-up */
302
	{ 20,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 18,  0,  0},
303
	/* ramp-down */
304
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
305
      },
306
      { /* profile 11 */
307
	/* ramp-up */
308
	{ 20,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 18,  0,  0},
309
	/* ramp-down */
310
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
311
      },
312
      { /* profile 12 */
313
	/* ramp-up */
314
	{ 23,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 15,  0,  0},
315
	/* ramp-down */
316
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
317
      },
318
      { /* profile 13 */
319
	/* ramp-up */
320
	{ 28,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30, 10,  0,  0},
321
	/* ramp-down */
322
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
323
      },
324
      { /* profile 14 */
325
	/* ramp-up */
326
	{ 31,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30,  7,  0,  0},
327
	/* ramp-down */
328
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
329
      },
330
      { /* profile 15 */
331
	/* ramp-up */
332
	{ 31,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 30, 30,  7,  0,  0},
333
	/* ramp-down */
334
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
335
      },
336
};
337

  
338
struct txcal_ramp_def rf_tx_ramps_1900[RF_TX_RAMP_SIZE] = {
339
      { /* profile 0 */
340
	/* ramp-up */
341
	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
342
	/* ramp-down */
343
	{ 31, 31, 27, 27, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
344
      },
345
      { /* profile 1 */
346
	/* ramp-up */
347
	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
348
	/* ramp-down */
349
	{ 31, 31, 27, 27, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
350
      },
351
      { /* profile 2 */
352
	/* ramp-up */
353
	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
354
	/* ramp-down */
355
	{ 31, 31, 27, 27, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
356
      },
357
      { /* profile 3 */
358
	/* ramp-up */
359
	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
360
	/* ramp-down */
361
	{ 31, 31, 27, 27, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
362
      },
363
      { /* profile 4 */
364
	/* ramp-up */
365
	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
366
	/* ramp-down */
367
	{ 31, 31, 27, 27, 12,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
368
      },
369
      { /* profile 5 */
370
	/* ramp-up */
371
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
372
	/* ramp-down */
373
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
374
      },
375
      { /* profile 6 */
376
	/* ramp-up */
377
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
378
	/* ramp-down */
379
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
380
      },
381
      { /* profile 7 */
382
	/* ramp-up */
383
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
384
	/* ramp-down */
385
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
386
      },
387
      { /* profile 8 */
388
	/* ramp-up */
389
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
390
	/* ramp-down */
391
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
392
      },
393
      { /* profile 9 */
394
	/* ramp-up */
395
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
396
	/* ramp-down */
397
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
398
      },
399
      { /* profile 10 */
400
	/* ramp-up */
401
	{ 11,  0,  0,  0,  0,  0,  0,  0,  0, 15, 25, 26, 31, 10,  0,  0},
402
	/* ramp-down */
403
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
404
      },
405
      { /* profile 11 */
406
	/* ramp-up */
407
	{ 16,  0,  0,  0,  0,  0,  0,  0,  0, 10, 30, 31, 31, 10,  0,  0},
408
	/* ramp-down */
409
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
410
      },
411
      { /* profile 12 */
412
	/* ramp-up */
413
	{ 16,  0,  0,  0,  0,  0,  0,  0,  0, 10, 30, 31, 31, 10,  0,  0},
414
	/* ramp-down */
415
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
416
      },
417
      { /* profile 13 */
418
	/* ramp-up */
419
	{ 19,  0,  0,  0,  0,  0,  0,  0,  0,  9, 31, 31, 31,  7,  0,  0},
420
	/* ramp-down */
421
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
422
      },
423
      { /* profile 14 */
424
	/* ramp-up */
425
	{ 23,  0,  0,  0,  0,  0,  0,  0,  0, 25, 31, 31, 31,  7,  0,  0},
426
	/* ramp-down */
427
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
428
      },
429
      { /* profile 15 */
430
	/* ramp-up */
431
	{ 23,  0,  0,  0,  0,  0,  0,  0,  0, 25, 31, 31, 31,  7,  0,  0},
432
	/* ramp-down */
433
	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
434
      },
435
};
src/target/firmware/board/compal_e88/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
 * The following APC offset value and Tx ramp template tables have been
29
 * extracted out of the one special Mot C11x fw version for which we got the
30
 * linker map file with symbols, and they also appear to be correct for the
31
 * closely related C155 hardware, which has exactly the same RF section
32
 * including the old SKY77324 RF PA.
33
 *
34
 * FreeCalypso firmware running with these numbers on both C118 and C155 phones
35
 * (using per-unit factory calibration records for the Tx levels) produces
36
 * correct Tx output levels and ramps as verified with the CMU200 RF test
37
 * instrument.
38
 */
39

  
40
uint8_t apc_offset = 32;
41

  
42
struct txcal_ramp_def rf_tx_ramps_850[RF_TX_RAMP_SIZE] = {
43
      { /* profile 0 */
44
	/* ramp-up */
45
	{ 28,  0,  0,  0,  0,  0,  0,  0,  0,  0,  4, 31, 31, 31,  3,  0},
46
	/* ramp-down */
47
	{ 31, 31, 18, 22,  6, 10,  2,  1,  1,  3,  3,  0,  0,  0,  0,  0},
48
      },
49
      { /* profile 1 */
50
	/* ramp-up */
51
	{ 31,  1,  0,  0,  0,  0,  0,  0,  0,  0,  3, 31, 31, 31,  0,  0},
52
	/* ramp-down */
53
	{ 31, 31, 31,  6,  8,  8,  9,  4,  0,  0,  0,  0,  0,  0,  0,  0},
54
      },
55
      { /* profile 2 */
56
	/* ramp-up */
57
	{ 31,  6,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 31, 29,  0,  0},
58
	/* ramp-down */
59
	{ 31, 25, 21, 20, 13, 14,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0},
60
      },
61
      { /* profile 3 */
62
	/* ramp-up */
63
	{ 31, 13,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 31, 22,  0,  0},
64
	/* ramp-down */
65
	{ 27, 28, 23, 19, 13, 14,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0},
66
      },
67
      { /* profile 4 */
68
	/* ramp-up */
69
	{ 31, 21,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 31, 14,  0,  0},
70
	/* ramp-down */
71
	{ 31, 21, 31,  2, 31,  4,  8,  0,  0,  0,  0,  0,  0,  0,  0,  0},
72
      },
73
      { /* profile 5 */
74
	/* ramp-up */
75
	{ 31, 30,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 31,  5,  0,  0},
76
	/* ramp-down */
77
	{ 21, 31, 31,  2, 31,  4,  8,  0,  0,  0,  0,  0,  0,  0,  0,  0},
78
      },
79
      { /* profile 6 */
80
	/* ramp-up */
81
	{ 31, 31,  7,  0,  0,  0,  0,  0,  0,  0,  0, 31, 28,  0,  0,  0},
82
	/* ramp-down */
83
	{ 31, 31, 28, 14,  3, 21,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
84
      },
85
      { /* profile 7 */
86
	/* ramp-up */
87
	{ 31, 31, 16,  0,  0,  0,  0,  0,  0,  0,  0, 31, 19,  0,  0,  0},
88
	/* ramp-down */
89
	{ 20, 30, 30, 10, 28, 10, 10,  0,  0,  0,  0,  0,  0,  0,  0,  0},
90
      },
91
      { /* profile 8 */
92
	/* ramp-up */
93
	{ 31, 31, 26,  0,  0,  0,  0,  0,  0,  0,  0, 31,  9,  0,  0,  0},
94
	/* ramp-down */
95
	{ 20, 26, 26, 18, 18, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
96
      },
97
      { /* profile 9 */
98
	/* ramp-up */
99
	{ 31, 31, 31,  2,  0,  0,  0,  0,  0,  0,  0, 31,  2,  0,  0,  0},
100
	/* ramp-down */
101
	{ 16, 16, 26, 26, 26,  0,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0},
102
      },
103
      { /* profile 10 */
104
	/* ramp-up */
105
	{ 31, 31, 31, 11,  0,  0,  0,  0,  0,  0,  0,  0, 24,  0,  0,  0},
106
	/* ramp-down */
107
	{ 10, 12, 31, 26, 29, 20,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
108
      },
109
      { /* profile 11 */
110
	/* ramp-up */
111
	{ 31, 31, 31, 18,  0,  0,  0,  0,  0,  0,  0,  0, 17,  0,  0,  0},
112
	/* ramp-down */
113
	{  2, 20, 31, 26, 31,  0,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0},
114
      },
115
      { /* profile 12 */
116
	/* ramp-up */
117
	{ 31, 31, 31, 25,  0,  0,  0,  0,  0,  0,  0,  0, 10,  0,  0,  0},
118
	/* ramp-down */
119
	{  2, 20, 31, 26, 31,  0,  0,  0, 18,  0,  0,  0,  0,  0,  0,  0},
120
      },
121
      { /* profile 13 */
122
	/* ramp-up */
123
	{ 31, 31, 31, 30,  0,  0,  0,  0,  0,  0,  0,  0,  5,  0,  0,  0},
124
	/* ramp-down */
125
	{  1, 16, 31, 31, 31,  0, 18,  0,  0,  0,  0,  0,  0,  0,  0,  0},
126
      },
127
      { /* profile 14 */
128
	/* ramp-up */
129
	{ 31, 31, 31, 31,  0,  0,  0,  0,  0,  0,  0,  4,  0,  0,  0,  0},
130
	/* ramp-down */
131
	{  4,  8, 10, 20, 31, 31, 20,  4,  0,  0,  0,  0,  0,  0,  0,  0},
132
      },
133
      { /* profile 15 */
134
	/* ramp-up */
135
	{ 31, 31, 31, 31,  0,  0,  0,  0,  0,  0,  0,  4,  0,  0,  0,  0},
136
	/* ramp-down */
137
	{  4,  8, 10, 20, 31, 31, 20,  4,  0,  0,  0,  0,  0,  0,  0,  0},
138
      },
139
};
140

  
141
struct txcal_ramp_def rf_tx_ramps_900[RF_TX_RAMP_SIZE] = {
142
      { /* profile 0 */
143
	/* ramp-up */
144
	{ 30,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 31, 31,  5,  0},
145
	/* ramp-down */
146
	{ 31, 31, 28, 15,  2,  0, 19,  2,  0,  0,  0,  0,  0,  0,  0,  0},
147
      },
148
      { /* profile 1 */
149
	/* ramp-up */
150
	{ 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0, 30, 26, 29,  8,  0},
151
	/* ramp-down */
152
	{ 31, 31, 29, 14,  2,  1, 15,  2,  3,  0,  0,  0,  0,  0,  0,  0},
153
      },
154
      { /* profile 2 */
155
	/* ramp-up */
156
	{ 31, 14,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 27, 24,  1,  0},
157
	/* ramp-down */
158
	{ 30, 31, 25, 14,  2,  2, 15,  7,  2,  0,  0,  0,  0,  0,  0,  0},
159
      },
160
      { /* profile 3 */
161
	/* ramp-up */
162
	{ 31, 22,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 14, 29,  1,  0},
163
	/* ramp-down */
164
	{ 31, 29, 31, 13,  2,  2, 15,  2,  3,  0,  0,  0,  0,  0,  0,  0},
165
      },
166
      { /* profile 4 */
167
	/* ramp-up */
168
	{ 31, 30,  0,  0,  0,  0,  0,  0,  0,  0,  0, 31, 17, 19,  0,  0},
169
	/* ramp-down */
170
	{ 31, 30, 30, 15,  1,  2, 17,  2,  0,  0,  0,  0,  0,  0,  0,  0},
171
      },
172
      { /* profile 5 */
173
	/* ramp-up */
174
	{ 31, 31,  7,  0,  0,  0,  0,  0,  0,  0,  0, 31, 19,  7,  2,  0},
175
	/* ramp-down */
... This diff was truncated because it exceeds the maximum size that can be displayed.
(3-3/5)
Add picture from clipboard (Maximum size: 48.8 MB)