General Purpose Input/Output

All pins of the Jz4730 can be used as GPIO; most of them also have alternate functions. In the trendtac, some devices are connected directly to the GPIO pins, and they should be controlled through them. There are 128 pins, divided in 4 ports of 32 pins each. Each port has 12 registers, spanning 0x30 bytes of memory. The memory for the ports is at physical addresses 0x10010000, 0x10010030, 0x10010060, 0x10010090, so 0x30 bytes apart. For each port, the following registers are present:

  • base + 0x00: DR = Data Register. Read and write the data on the pins.
  • base + 0x04: DIR = DIrection Register(?) 0 means the pin is input, 1 means it is output. Disable interrupts before changing this.
  • base + 0x08: ODR = ?
  • base + 0x0c: PUR = Pull-Up Register. Setting this enables a pull-up on the pin, resulting in a 1 input if it is unconnected.
  • base + 0x10: ALR = Alternate function Lower Register. Used to set pins to their alternate function. This register controls the lower 16 bits of the port, with 2 bits per pin.
  • base + 0x14: AUR = Alternate function Upper Register. Same as ALR, but for the upper 16 pins.
  • base + 0x18: IDLR = Interrupt Detect(?) Lower Register. Set the interrupt behaviour for the lower 16 pins, with 2 bits per pin.
  • base + 0x1c: IDUR = Interrupt Detect(?) Upper Register. Same as IDLR, but for the upper 16 pins.
  • base + 0x20: IER = Interrupt Enable Register. Setting this bit enables the interrupt on the pin (in the way specified by IDLR/IDUR).
  • base + 0x24: IMR = ?
  • base + 0x28: FR = Flag Register. This bit is set when an interrupt occurs. The driver must clear it by writing a 0.
  • base + 0x2c: ?

For the IDLR and IDUR registers, 00 means interrupt on low level; 01 means interrupt on high level; 10 means interrupt on falling edge; 11 means interrupt on raising edge.

Note that reading a pin which is set for input reads the external signal, while writing the pin will write to the value that will be output when it is set to output, but it will not change anything as long as that doesn't happen. This means in particular, that read-modify-write operations can change unrelated pin outputs, if the pins are currently set to input. For example, when pin 0 of port 0 is set to input, with data 0, but the input is 1, doing GPIO_GPDR (0) |= 0x10 will read the bit as 1 and write it back as such, thus changing the original value of the output. Setting it to output again will then change the value. The lesson to learn from this is that output values of pins which are set as input can change at any time when the port data is written.

A list of all GPIO pins and their functions in the Trendtac:

Port 0:

Port 1:

Port 2:

  • 0: LcdPixels: SP enable and(?) SdCardReader? card inserted/detect
  • 1: LcdPixels: SP clock
  • 2: LcdPixels: SP data and(?) SdCardReader? write protect and(?) power output: setting to 0 shuts down machine
  • 3: LcdPixels: Somehow used for LCD reset, according to Linux source
  • 4: I2S? CLK (output) (SoundCard? , not sure which is used) and(?) touch screen irq pin
  • 5: ACRESET_N (output) / AK4642 PDN
  • 6: I2S? DIN (SoundCard? , not sure which is used) / SDATA_OUT (output)
  • 7: I2S? DOUT (SoundCard? , not sure which is used) / SDATA_IN (input)
  • 8:
  • 9:
  • 10:
  • 11:
  • 12:
  • 13: I2S? BITCLK_IN (input) (SoundCard? , not sure which is used)
  • 14: I2S? LRCIN (input) (SoundCard? , not sure which is used) / SYNC_IN
  • 15: EMC FRE_N (output)
  • 16: EMC FWE_N (output)
  • 17: EMC FWB_N (input)
  • 18: EMC DCS1_N (output) / SD_WP
  • 19: EMC CS1_N (output) / JACK_PLUG
  • 20: EMC CS2_N (output) / DC_DETE : set as input without pull-up and read to see if AC is connected (1 means yes).
  • 21: EMC CS3_N (output) / NAND CS#
  • 22: EMC CS4_N (output) and(?) Num lock / PULL_OFF
  • 23: EMC CS5_N (output) / IR_SD
  • 24: INPACK_N (input)
  • 25: BVD2 (input)
  • 26: PCE1_N (output) / SD_CD_N
  • 27: PSKTSEL_N (output) / SD_VCC_3V_EN_N
  • 28: LED_EN (input) / Led enable. Connected to a LED on some other boards. Not connected on the Trendtac.
  • 29: PCE2_N (output) / LCD_DISP_OFF_N / Named GPIO_DISP_OFF_N in Linux. Initialized but otherwise unused.
  • 30: PWM0 (output) / pwm0 enable (LcdBacklight? )
  • 31: PWM1 (output) / pwm1 enable

Port 3:

  • 0: KeyBoard and(?) rtc irq pin. The alarm can wake the machine from sleep; it is used in the power management code in Linux.
  • 1: KeyBoard and(?) GPIO_PW_I, the "power input" key. It is somehow possible to read the PowerButton? state from this. Can wake the device through an interrupt.
  • 2: KeyBoard
  • 3: KeyBoard
  • 4: KeyBoard
  • 5: KeyBoard
  • 6: KeyBoard
  • 7: KeyBoard
  • 8: KeyBoard
  • 9: KeyBoard
  • 10: KeyBoard
  • 11: KeyBoard
  • 12: KeyBoard
  • 13: KeyBoard
  • 14: KeyBoard
  • 15: KeyBoard
  • 16: NetworkAdapter? / MII_TX_EN (output)
  • 17: NetworkAdapter? / MII_RX_DV (input)
  • 18: NetworkAdapter? / MII_RX_ER (input)
  • 19: NetworkAdapter? / MII_COL (input)
  • 20: NetworkAdapter? / MII_CRS (input)
  • 21: NetworkAdapter? / MII_TXD0 (output)
  • 22: NetworkAdapter? / MII_TXD1 (output)
  • 23: NetworkAdapter? / MII_TXD2 (output)
  • 24: NetworkAdapter? / MII_TXD3 (output)
  • 25: NetworkAdapter? / MII_RXD0 (input)
  • 26: NetworkAdapter? / MII_RXD1 (input)
  • 27: NetworkAdapter? / MII_RXD2 (input)
  • 28: NetworkAdapter? / MII_RXD3 (input)
  • 29: KeyBoard and(?) GPIO_CHARG_STAT: set as input and read without pull-up to see battery state with connected AC: 1 is charging; 0 is charged. If it is 0 with a pull-up, the battery is absent.
  • 30: SerialPort? RXD (input)
  • 31: SerialPort? TXD (output)

-- BasWijnen - 23 Jun 2009

Topic revision: r6 - 15 Sep 2009 - 09:37:19 - BasWijnen
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback