General Layout:
Port A: D* Data Lines
Port B: Fixed 0x3F, used for chip select, power button LED and likely audio
Port C: Usually 0x7F or 0x3F(less common), needs to be investigated further
Port D: Hardware buttons
Port E: Always 0x5E or 0x5C, only bit 1 seems used, needs to be investigated further
Port F: Always 0x9D or 0x9C, only bit 0 seems used, needs to be investigated further
Port G: 0x15 when backlight is off, 0x17 when its on, bit 1 is a read back of SED1376 GPIO 0 pin 4
Port J: Fixed 0xB0, needs to be investigated further
Port K: Fixed 0x04 in testing, used to select Port Ds active matrix line, bit 4 enables the vibrator motor
Port M: Fixed 0x23, needs to be investigated further

Pin Mapping(all pins are accounted for, documented or not):

Port A Pin 0: Data Line 0(can only be used as a GPIO in 8 bit mode)
Port A Pin 1: Data Line 1(can only be used as a GPIO in 8 bit mode)
Port A Pin 2: Data Line 2(can only be used as a GPIO in 8 bit mode)
Port A Pin 3: Data Line 3(can only be used as a GPIO in 8 bit mode)
Port A Pin 4: Data Line 4(can only be used as a GPIO in 8 bit mode)
Port A Pin 5: Data Line 5(can only be used as a GPIO in 8 bit mode)
Port A Pin 6: Data Line 6(can only be used as a GPIO in 8 bit mode)
Port A Pin 7: Data Line 7(can only be used as a GPIO in 8 bit mode)

Port B Pin 0: CSB0(chip select line)
Port B Pin 1: CSB1/SDWE(chip select line)
Port B Pin 2: CSC0/RAS0(chip select line)
Port B Pin 3: CSC1/RAS1(chip select line)
Port B Pin 4: CSD0/CAS0(chip select line)
Port B Pin 5: Unknown(GPIO)(OUTPUT)(not used as a chip select line)
Port B Pin 6: Alarm LED(xored with the charging state, set high to enable LED when not docked, set low to enable LED when docked)
Port B Pin 7: Audio Out(untested)(PWMO1)

Port C Pin 0: Unknown(GPIO)(INPUT)
Port C Pin 1: Unknown(GPIO)(INPUT)
Port C Pin 2: Unknown(GPIO)(INPUT)
Port C Pin 3: Unknown(GPIO)(INPUT)
Port C Pin 4: Unknown(GPIO)(INPUT)
Port C Pin 5: Unknown(GPIO)(INPUT)
Port C Pin 6: Unknown(GPIO)(INPUT)
Port C Pin 7: Unknown(GPIO)(INPUT)

Port D Pin 0: Button Matrix Input Line 0(INT0)(low when button pressed)
Port D Pin 1: Button Matrix Input Line 1(INT1)(low when button pressed)
Port D Pin 2: Button Matrix Input Line 2(INT2)(low when button pressed)
Port D Pin 3: Button Matrix Input Line 3(INT3)(low when button pressed)
Port D Pin 4: HotSync Cable Button(IRQ1)(low when button pressed)
Port D Pin 5: SD Card Status(IRQ2)(low when card is inserted)
Port D Pin 6: Unknown(SPECIAL)(IRQ3)(INPUT)
Port D Pin 7: Battery Critical Interrupt(IRQ6)(low when critical)

Port E Pin 0: SPITXD(used for ADS7846)
Port E Pin 1: SPIRXD(used for ADS7846)
Port E Pin 2: SPICLK2(used for ADS7846)
Port E Pin 3: Unknown(GPIO)(OUTPUT)
Port E Pin 4: Unknown(RXD1)(SPECIAL)
Port E Pin 5: Unknown(TXD1)(SPECIAL)
Port E Pin 6: Unknown(GPIO)(INPUT)
Port E Pin 7: Unknown(GPIO)(OUTPUT)

Port F Pin 0: Unknown(GPIO)(INPUT)(looks like ADS7846 BUSY)
Port F Pin 1: ADS7846 PENIRQ(low when screen is touched)(IRQ5)
Port F Pin 2: Clock Output(required for SED1376 operation, reads and writes do nothing)
Port F Pin 3: Address Line 20
Port F Pin 4: Address Line 21
Port F Pin 5: Unknown(GPIO)(OUTPUT)(may be a software controlled address line)
Port F Pin 6: Unknown(GPIO)(INPUT)
Port F Pin 7: Unknown(GPIO)(INPUT)

Port G Pin 0: Unknown(BUSW/DTACK)(SPECIAL)
Port G Pin 1: Backlight State Read Back(high when backlight on)
Port G Pin 2: ADS7846 Chip Select(GPIO)(OUTPUT)
Port G Pin 3: Unknown(GPIO)(OUTPUT)
Port G Pin 4: Unknown(EMUCS)(SPECIAL)//why is this enabled on a release device?
Port G Pin 5: Unknown(GPIO)(OUTPUT)

Port J Pin 0: Unknown(SPECIAL when SD card is being accessed, otherwise GPIO)
Port J Pin 1: Unknown(SPECIAL when SD card is being accessed, otherwise GPIO)
Port J Pin 2: Unknown(SPECIAL when SD card is being accessed, otherwise GPIO)
Port J Pin 3: Unknown(GPIO)(OUTPUT)
Port J Pin 4: Unknown(RXD2)(SPECIAL)
Port J Pin 5: Unknown(TXD2)(SPECIAL)
Port J Pin 6: Unknown(RTS2)(SPECIAL)
Port J Pin 7: Unknown(CTS2)(SPECIAL)

Port K Pin 0: Unknown(GPIO)(OUTPUT)
Port K Pin 1: Double Backlight Power(set high to put the backlight in "bright mode", does nothing when backlight is off)
Port K Pin 2: Battery Charging/Docked(low when charging)
Port K Pin 3: Unknown(GPIO)(OUTPUT)
Port K Pin 4: Enable Vibrator Motor(set high to enable)
Port K Pin 5: Button Matrix Line Select 0(set low to enable line, multiple lines can be enabled at once)
Port K Pin 6: Button Matrix Line Select 1(set low to enable line, multiple lines can be enabled at once)
Port K Pin 7: Button Matrix Line Select 2(set low to enable line, multiple lines can be enabled at once)

Port M Pin 0: Unknown(SDCLK)(SPECIAL)
Port M Pin 1: Unknown(SDCE)(SPECIAL)
Port M Pin 2: Unknown(DQMH)(SPECIAL)
Port M Pin 3: Unknown(DQML)(SPECIAL)
Port M Pin 4: Unknown(SDA10)(SPECIAL)
Port M Pin 5: Unknown(GPIO)(OUTPUT)