Project

General

Profile

Bug #4769 ยป os4769-20200928.patch

falconia, 09/28/2020 08:10 PM

View differences:

src/target/firmware/board/gtm900b/init.c
67 67
	writew(reg, ASIC_CONF_REG);
68 68

  
69 69
	/*
70
	 * Most Calypso peripheral interface signals are unconnected
71
	 * on this modem.  We configure them to be GPIOs in IO_CONF_REG,
72
	 * then configure them to be outputs in IO_CNTL_REG, then set
73
	 * the outputs to 0 in ARMIO_LATCH_OUT.
70
	 * Configure Calypso GPIO and multifunction pins the same way
71
	 * how Huawei's official firmware configures them.
74 72
	 */
75 73
	writew(0x03F5, IO_CONF_REG);
76
	writew(0xC000, IO_CNTL_REG);
77
	writew(0x0000, ARMIO_LATCH_OUT);
74
	writew(0xDC58, IO_CNTL_REG);
75
	writew(0x0007, ARMIO_LATCH_OUT);
78 76

  
79 77
	/* Set LPG output permanently on (power LED) */
80 78
	writew(1, LPG_PM_REG);
81
- 
src/target/firmware/board/gtm900b/init.c
50 50

  
51 51
#define ARMIO_LATCH_OUT 0xfffe4802
52 52
#define IO_CNTL_REG	0xfffe4804
53
#define ARM_CONF_REG	0xfffef006
53 54
#define ASIC_CONF_REG	0xfffef008
54 55
#define IO_CONF_REG	0xfffef00a
55 56
#define LPG_LCR_REG	0xfffe7800
......
77 78
	/* Set LPG output permanently on (power LED) */
78 79
	writew(1, LPG_PM_REG);
79 80
	writew((1 << 7), LPG_LCR_REG);
81

  
82
	/* configure ADD(22), needed for second half of flash on MG01GSMT */
83
	reg = readw(ARM_CONF_REG);
84
	reg |= (1 << 3);
85
	writew(reg, ARM_CONF_REG);
80 86
}
81 87

  
82 88
void board_init(int with_irq)
83 89
{
84
	/* Configure the memory interface */
85
	calypso_mem_cfg(CALYPSO_nCS0, 3, CALYPSO_MEM_16bit, 1);
86
	calypso_mem_cfg(CALYPSO_nCS1, 3, CALYPSO_MEM_16bit, 1);
90
	/*
91
	 * Configure the memory interface.
92
	 * Huawei's official fw sets WS=4 for RAM, but not for flash -
93
	 * but let's be consistent and use WS=4 for both.  Please refer
94
	 * to this technical article for the underlying theory:
95
https://www.freecalypso.org/hg/freecalypso-docs/file/tip/MEMIF-wait-states
96
	 */
97
	calypso_mem_cfg(CALYPSO_nCS0, 4, CALYPSO_MEM_16bit, 1);
98
	calypso_mem_cfg(CALYPSO_nCS1, 4, CALYPSO_MEM_16bit, 1);
99
	/*
100
	 * The remaining 3 chip selects are unused on this hw,
101
	 * thus their settings are dummies.
102
	 */
87 103
	calypso_mem_cfg(CALYPSO_nCS2, 5, CALYPSO_MEM_16bit, 1);
88 104
	calypso_mem_cfg(CALYPSO_nCS3, 5, CALYPSO_MEM_16bit, 1);
89 105
	calypso_mem_cfg(CALYPSO_CS4, 0, CALYPSO_MEM_8bit, 1);
90
- 
src/target/firmware/board/gtm900b/init.c
56 56
#define LPG_LCR_REG	0xfffe7800
57 57
#define LPG_PM_REG	0xfffe7801
58 58

  
59
int gtm900_hw_is_mg01gsmt;
60

  
59 61
static void board_io_init(void)
60 62
{
61 63
	uint16_t reg;
......
85 87
	writew(reg, ARM_CONF_REG);
86 88
}
87 89

  
90
/*
91
 * There exist two firmware-incompatible versions of GTM900-B hardware:
92
 * MG01GSMT and MGCxGSMT.  They have different flash chip types (8 MiB
93
 * vs. 4 MiB) with correspondingly different TIFFS configurations
94
 * (and we need TIFFS in order to read factory RF calibration values),
95
 * and they have different (incompatible) RFFE control signals.
96
 *
97
 * We are going to check the flash chip type and use it to decide which
98
 * hw variant we are running on.
99
 */
100
static void board_flash_init(void)
101
{
102
	uint16_t manufacturer_id, device_id[3];
103

  
104
	/* Use an address above the Calypso boot ROM
105
	 * so we don't need to unmap it to access the flash. */
106
	flash_get_id((void *)0x40000, &manufacturer_id, device_id);
107

  
108
	switch (manufacturer_id) {
109
	case CFI_MANUF_SPANSION:
110
		/* is it S71PL064J? */
111
		if (device_id[0] == 0x227E && device_id[1] == 0x2202 &&
112
		    device_id[2] == 0x2201) {
113
			gtm900_hw_is_mg01gsmt = 1;
114
			break;
115
		}
116
		/* is it S71PL032J? */
117
		if (device_id[0] == 0x227E && device_id[1] == 0x220A &&
118
		    device_id[2] == 0x2201) {
119
			gtm900_hw_is_mg01gsmt = 0;
120
			break;
121
		}
122
		goto bad;
123
	case CFI_MANUF_SAMSUNG:
124
		/* is it K5A3281CTM? */
125
		if (device_id[0] == 0x22A0) {
126
			gtm900_hw_is_mg01gsmt = 0;
127
			break;
128
		}
129
		/* is it K5L3316CAM? */
130
		if (device_id[0] == 0x257E && device_id[1] == 0x2503 &&
131
		    device_id[2] == 0x2501) {
132
			gtm900_hw_is_mg01gsmt = 0;
133
			break;
134
		}
135
		/* FALL THRU */
136
	default:
137
	bad:
138
		printf("Unknown module detected, "
139
		       "flash ID 0x%04x 0x%04x 0x%04x 0x%04x\n"
140
		       "Please contact mailing list!\n\n", manufacturer_id,
141
		       device_id[0], device_id[1], device_id[2]);
142
		return;
143
	}
144

  
145
	/* Initialize TIFFS reader */
146
	if (gtm900_hw_is_mg01gsmt)
147
		tiffs_init(0x700000, 0x10000, 15);
148
	else
149
		tiffs_init(0x380000, 0x10000, 7);
150
}
151

  
88 152
void board_init(int with_irq)
89 153
{
90 154
	/*
......
151 215

  
152 216
	/* Initialize ABB driver (uses SPI) */
153 217
	twl3025_init();
218

  
219
	/* Initialize board flash */
220
	board_flash_init();
154 221
}
src/target/firmware/board/gtm900b/rffe_gtm900b.c
1 1
/* RF frontend driver for Huawei GTM900-B modems, supporting both
2
 * MG01GSMT and MG01GSMT hardware variants */
2
 * MG01GSMT and MGCxGSMT hardware variants */
3 3

  
4 4
/* (C) 2019 by Steve Markgraf <steve@steve-m.de>
5 5
 *
......
63 63
 * Tx2: high band PA output
64 64
 */
65 65

  
66
typedef enum rffe_var {
67
	RFFE_MGC2GSMT,
68
	RFFE_MG01GSMT
69
} rffe_var_t;
70

  
71
static rffe_var_t rffe_variant = RFFE_MGC2GSMT;
66
extern int gtm900_hw_is_mg01gsmt;	/* set in init.c */
72 67

  
73 68
static inline void rffe_mode_mgc2gsmt(enum gsm_band band, int tx)
74 69
{
......
139 134
/* switch RF Frontend Mode */
140 135
void rffe_mode(enum gsm_band band, int tx)
141 136
{
142
	if (rffe_variant == RFFE_MGC2GSMT)
143
		rffe_mode_mgc2gsmt(band, tx);
144
	else
137
	if (gtm900_hw_is_mg01gsmt)
145 138
		rffe_mode_mg01gsmt(band, tx);
139
	else
140
		rffe_mode_mgc2gsmt(band, tx);
146 141
}
147 142

  
148 143
uint32_t rffe_get_rx_ports(void)
......
166 161
void rffe_init(void)
167 162
{
168 163
	uint16_t reg;
169
	uint16_t manufacturer_id = 0;
170 164

  
171 165
	reg = readw(ARM_CONF_REG);
172 166
	reg &= ~ (1 << 7);	/* TSPACT4 I/O function, not nRDYMEM */
......
176 170
	tsp_setup(IOTA_STROBE, 1, 0, 0);
177 171

  
178 172
	trf6151_init(RITA_STROBE, RITA_RESET);
179

  
180
	/* Detect the used RFFE variant based on the used flash chip.
181
	 * The MGC2GSMT uses a Samsung flash, whereas the MG01GSMT uses
182
	 * a Spansion flash. We use an address above the Calpso bootrom
183
	 * so we do not need to unmap it to access the flash. */
184
	flash_get_id((void *)0x40000, &manufacturer_id, NULL);
185

  
186
	switch (manufacturer_id) {
187
	case CFI_MANUF_SPANSION:
188
		printf("Detected MG01GSMT module\n\n");
189
		rffe_variant = RFFE_MG01GSMT;
190
		break;
191
	case CFI_MANUF_SAMSUNG:
192
		printf("Detected MGC2GSMT module\n\n");
193
		rffe_variant = RFFE_MGC2GSMT;
194
		break;
195
	default:
196
		printf("Unknown module detected, flash ID 0x%4.4x\n"
197
		       "Please contact mailing list!\n\n", manufacturer_id);
198
		rffe_variant = RFFE_MGC2GSMT;
199
		break;
200
	}
201 173
}
202 174

  
203 175
uint8_t rffe_get_gain(void)
    (1-1/1)
    Add picture from clipboard (Maximum size: 48.8 MB)