Skip to content

Commit 12a2a12

Browse files
committed
Missed merge updates.
1 parent 3e0ab90 commit 12a2a12

File tree

5 files changed

+69
-12
lines changed

5 files changed

+69
-12
lines changed

Lab24 TFTP/boards/peripherals/uart/16C650.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*...................................................................*/
22
/* */
3-
/* Module: uart0.c */
3+
/* Module: 16C650.c */
44
/* Version: 2015.0 */
55
/* Purpose: uart0 system interface for 16C650 UART */
66
/* */

Lab24 TFTP/boards/rpi/board.c

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,15 @@ void BoardInit(void)
8585
select = REG32(GPFSEL4);
8686
select &= ~(7 << 6);
8787
#elif RPI == 3
88-
/* GPIO 29 is select register 2, number 9. 3 bits per GPIO so 9 */
89-
/* Clear the 3 bit range (7) starting at bit 21 */
88+
/* GPIO 29 is select register 2, number 9. 9 * 3 bits is bit 27 */
89+
/* Clear the 3 bit range (7) starting at bit 27 */
9090
select = REG32(GPFSEL2);
9191
select &= ~(7 << 27);
92+
#elif RPI == 0
93+
/* GPIO 16 is select register 1, number 6. 6 * 3 bits is bit 18 */
94+
/* Clear the 3 bit range (7) starting at bit 18 */
95+
select = REG32(GPFSEL1);
96+
select &= ~(7 << 18);
9297
#else
9398
/* GPIO 47 is 7th register in GPFSEL4, so 7 * 3 bits or bit 21. */
9499
/* Clear the 3 bit range (7) starting at bit 21 */
@@ -107,12 +112,22 @@ void BoardInit(void)
107112
/* Configure LED (GPIO 29) starting at bit 27, as output (1). */
108113
select |= (GPIO_OUTPUT << 27);
109114
REG32(GPFSEL2) = select;
115+
#elif RPI == 0
116+
/* Configure LED (GPIO 16) starting at bit 18, as output (1). */
117+
select |= (GPIO_OUTPUT << 18);
118+
REG32(GPFSEL1) = select;
110119
#else
111120
/* Configure the LED (GPIO 47) starting at bit 21, as output (1). */
112121
select |= (GPIO_OUTPUT << 21);
113122
REG32(GPFSEL4) = select;
114123
#endif
115124

125+
#if RPI == 4
126+
/* GPIO 42, 2 bits per PUP GPIO */
127+
select = REG32(GPIO_PUP_PDN_CNTRL_REG2);
128+
select &= ~(3 << ((42 - 32) * 2)); // clear old value
129+
REG32(GPIO_PUP_PDN_CNTRL_REG2) = select | (GPPUP_PULL_UP) << ((42 - 32) * 2);
130+
#else
116131
/* GPPUD - GPio Pin Up Down configuration */
117132
/* (0) disable pull up and pull down to float the GPIO */
118133
/* (1 << 0) enable pull down (low) */
@@ -124,10 +139,7 @@ void BoardInit(void)
124139
/* Sleep for one hundred of a second to activate last command. */
125140
usleep(MICROS_PER_SECOND / 100);
126141

127-
#if RPI == 4
128-
/* Push GPPUD settings to GPPUDCLK1 GPIO 42. */
129-
REG32(GPPUDCLK1) = (1 << (42 - 32)); /* GPIO 42 */
130-
#elif RPI == 3
142+
#if RPI == 3
131143
/* Push GPPUD settings to GPPUDCLK0 GPIO 29. */
132144
REG32(GPPUDCLK0) = (1 << 29); /* GPIO 29 */
133145
#else
@@ -137,8 +149,21 @@ void BoardInit(void)
137149

138150
/* Sleep for one hundred of a second to activate last command. */
139151
usleep(MICROS_PER_SECOND / 100);
152+
#endif /* RPI == 4 */
153+
140154

141155
#if ENABLE_JTAG
156+
#if RPI == 4
157+
/* 2 bits per PUP GPIO */
158+
select = REG32(GPIO_PUP_PDN_CNTRL_REG1);
159+
select &= ~(3 << ((22 - 16) * 2)); // Clear old GPIO 22 value
160+
select &= ~(3 << ((23 - 16) * 2)); // Clear old GPIO 23 value
161+
select &= ~(3 << ((24 - 16) * 2)); // Clear old GPIO 24 value
162+
select &= ~(3 << ((25 - 16) * 2)); // Clear old GPIO 25 value
163+
select &= ~(3 << ((26 - 16) * 2)); // Clear old GPIO 26 value
164+
select &= ~(3 << ((27 - 16) * 2)); // Clear old GPIO 27 value
165+
REG32(GPIO_PUP_PDN_CNTRL_REG1) = select; /* commit changes */
166+
#else
142167
/* Disable pull up/down for the next configured GPIO. */
143168
REG32(GPPUD) = GPPUD_OFF;
144169
usleep(MICROS_PER_MILLISECOND); /* 1ms hold time */
@@ -147,6 +172,7 @@ void BoardInit(void)
147172
REG32(GPPUDCLK0) = (1 << 22) | (1 << 23) | (1 << 24) | (1 << 25) |
148173
(1 << 26) | (1 << 27);
149174
usleep(MICROS_PER_MILLISECOND); /* 1ms hold time */
175+
#endif
150176

151177
// Select level alternate 4 to enable JTAG
152178
select = REG32(GPFSEL2);
@@ -174,13 +200,21 @@ void BoardInit(void)
174200
select |= GPIO_ALT0 << 15; //set gpio15 to alt0
175201
REG32(GPFSEL1) = select;
176202

203+
#if RPI == 4
204+
/* UART is GPIO 14 and 15 with 2 bits per PUP GPIO */
205+
select = REG32(GPIO_PUP_PDN_CNTRL_REG0);
206+
select &= ~(3 << (14 * 2)); // Clear GPIO 14 value
207+
select &= ~(3 << (15 * 2)); // Clear GPIO 15 value
208+
REG32(GPIO_PUP_PDN_CNTRL_REG0) = select; /* commit changes */
209+
#else
177210
/* Disable pull up/down for the next configured GPIO. */
178211
REG32(GPPUD) = GPPUD_OFF;
179212
usleep(MICROS_PER_MILLISECOND); /* 1ms hold time */
180213

181214
/* Configure no pull up/down for Rx and Tx GPIOs. */
182215
REG32(GPPUDCLK0) = (1 << 14) | (1 << 15); /* GPIO 14 and 15 */
183216
usleep(MICROS_PER_MILLISECOND); /* hold time */
217+
#endif
184218

185219
/* Initialize the primary UART. */
186220
Uart0Init();
@@ -223,13 +257,21 @@ void BoardInit(void)
223257
select |= GPIO_ALT5 << 15; //set gpio15 to alt5
224258
REG32(GPFSEL1) = select;
225259

260+
#if RPI == 4
261+
/* UART is GPIO 14 and 15 with 2 bits per PUP GPIO */
262+
select = REG32(GPIO_PUP_PDN_CNTRL_REG0);
263+
select &= ~(3 << (14 * 2)); // Clear old GPIO 14 value
264+
select &= ~(3 << (15 * 2)); // Clear old GPIO 15 value
265+
REG32(GPIO_PUP_PDN_CNTRL_REG0) = select; /* commit changes */
266+
#else
226267
/* Disable pull up/down clock. */
227268
REG32(GPPUD) = GPPUD_OFF;
228269
usleep(MICROS_PER_MILLISECOND);
229270

230271
/* Commit pull up/down disable for Rx and Tx GPIOs. */
231272
REG32(GPPUDCLK0) = (1 << 14) | (1 << 15);
232273
usleep(MICROS_PER_MILLISECOND); // 1ms hold time
274+
#endif
233275

234276
/* Initialize the secondary UART. */
235277
Uart1Init();
@@ -295,6 +337,9 @@ void LedOn(void)
295337
#elif RPI == 3
296338
/* RPI 3 has LED at GPIO 29, so set GPIO 29. */
297339
REG32(GPSET0) = 1 << 29;
340+
#elif RPI == 0
341+
/* RPI 1A and B have LED at GPIO 16, so set GPIO 16. */
342+
REG32(GPSET0) = 1 << 16;
298343
#else
299344
/* Other RPIs have LED at GPIO 47, so set GPIO 47. */
300345
REG32(GPSET1) = 1 << (47 - 32);
@@ -314,6 +359,9 @@ void LedOff(void)
314359
#elif RPI == 3
315360
/* RPI 3 has LED at GPIO 29, so clear GPIO 29. */
316361
REG32(GPCLR0) = 1 << 29;
362+
#elif RPI == 0
363+
/* RPI 1A and B have LED at GPIO 16, so clear GPIO 16. */
364+
REG32(GPCLR0) = 1 << 16;
317365
#else
318366
/* Other RPIs have LED at GPIO 47, so clear GPIO 47. */
319367
REG32(GPCLR1) = 1 << (47 - 32);

Lab24 TFTP/boards/rpi/board.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
/*
4747
* SoC peripheral base addresses
4848
*/
49-
#if RPI == 1
50-
#define PERIPHERAL_BASE 0x20000000 /* RPi B+ */
49+
#if RPI <= 1
50+
#define PERIPHERAL_BASE 0x20000000 /* RPi 1A through B+ */
5151
#elif RPI == 4
5252
#define PERIPHERAL_BASE 0xFE000000 /* RPi 4 */
5353
#else
@@ -91,6 +91,15 @@
9191
#define GPPUDCLK0 (GPIO_BASE | 0x98)
9292
#define GPPUDCLK1 (GPIO_BASE | 0x9C)
9393

94+
// GPIO Pull Up and Down registers (RPI 4)
95+
#define GPIO_PUP_PDN_CNTRL_REG0 (GPIO_BASE | 0xE4)
96+
#define GPIO_PUP_PDN_CNTRL_REG1 (GPIO_BASE | 0xE8)
97+
#define GPIO_PUP_PDN_CNTRL_REG2 (GPIO_BASE | 0xEC)
98+
#define GPIO_PUP_PDN_CNTRL_REG3 (GPIO_BASE | 0xF0)
99+
#define GPPUP_OFF (0 << 0)
100+
#define GPPUP_PULL_UP (1 << 0)
101+
#define GPPUP_PULL_DOWN (1 << 1)
102+
94103
/*
95104
* Timer registers
96105
*/
@@ -122,7 +131,7 @@
122131
#endif /* ENABLE_MALLOC */
123132

124133
// GPU memory configuration
125-
#if RPI == 1
134+
#if RPI <= 1
126135
#define GPU_MEM_BASE 0x40000000 // L2 cache enabled
127136
#else
128137
#define GPU_MEM_BASE 0xC0000000 // L2 cache disabled

Lab24 TFTP/boards/rpi/openocd_rpi_jtag.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
interface bcm2835gpio
66

7-
# FPI 1 (700 MHz clock)
7+
# RPI 1 (700 MHz clock)
88
#bcm2835gpio_peripheral_base 0x20000000
99
#bcm2835gpio_speed_coeffs 113714 28
1010

Lab24 TFTP/boards/rpi/openocd_sipeed_jtag.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# http://www.hs-augsburg.de/~hhoegl/proj/usbjtag/usbjtag.html
1111
#
1212

13-
interface ftdi
13+
adapter driver ftdi
1414
ftdi_device_desc "Dual RS232"
1515
ftdi_vid_pid 0x0403 0x6010
1616

0 commit comments

Comments
 (0)