PP502x: Hacky technique to switch UARTs based on which IRQ was triggered

This lets us have multiple serial ports enabled, which will help with
4th-gen ipods that have a serial port in the HP jack as well in the dock.

Change-Id: I6a00a776020848a6908413e05a6f27bad65b2d8e
This commit is contained in:
Solomon Peachy 2025-07-25 07:56:06 -04:00
parent 85f731c1e0
commit f27de46472
2 changed files with 21 additions and 4 deletions

View file

@ -47,7 +47,7 @@
#if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_USB_MODE)
extern void TIMER1(void);
extern void TIMER2(void);
extern void SERIAL_ISR(void);
extern void SERIAL_ISR(int port);
#if defined(HAVE_ADJUSTABLE_CPU_FREQ) && (NUM_CORES > 1)
static struct corelock cpufreq_cl SHAREDBSS_ATTR;
@ -187,8 +187,11 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void)
/* end PBELL_VIBE500 */
#endif
#ifdef IPOD_ACCESSORY_PROTOCOL
else if (CPU_HI_INT_STAT & (SER0_MASK | SER1_MASK)) {
SERIAL_ISR();
else if (CPU_HI_INT_STAT & SER0_MASK) {
SERIAL_ISR(0);
}
else if (CPU_HI_INT_STAT & SER1_MASK) {
SERIAL_ISR(1);
}
#endif
} else {

View file

@ -188,12 +188,26 @@ static unsigned char rx_readc(void)
return (*base_RBR & 0xFF);
}
void SERIAL_ISR(void)
void SERIAL_ISR(int port)
{
static int badbaud = 0;
static bool newpkt = true;
char temp;
if (port && base_RBR != &SER1_RBR) {
base_RBR = &SER1_RBR;
base_THR = &SER1_THR;
base_LCR = &SER1_LCR;
base_LSR = &SER1_LSR;
base_DLL = &SER1_DLL;
} else if (!port && base_RBR != &SER0_RBR) {
base_RBR = &SER0_RBR;
base_THR = &SER0_THR;
base_LCR = &SER0_LCR;
base_LSR = &SER0_LSR;
base_DLL = &SER0_DLL;
}
while(rx_rdy())
{
temp = rx_readc();