/* initially setup the 2 copies of the gpio data registers. This function must be called by the platform setup code. */ void __init rdc321x_gpio_setup() { /* this might not be, what others (BIOS, bootloader, etc.) wrote to these registers before, but it's a good guess. Still better than just using 0xffffffff. */ gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1); gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2); }
/* initially setup the 2 copies of the gpio data registers. This function is called before the platform setup code. */ static int __init rdc321x_gpio_setup(void) { /* this might not be, what others (BIOS, bootloader, etc.) wrote to these registers before, but it's a good guess. Still better than just using 0xffffffff. */ gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1); gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2); printk(KERN_INFO "rdc321x: registering %d GPIOs\n", rdc321x_gpio_chip.ngpio); return gpiochip_add(&rdc321x_gpio_chip); }
/* read GPIO pin */ int rdc_gpio_get_value(unsigned gpio) { u32 reg; unsigned long flags; spin_lock_irqsave(&gpio_lock, flags); reg = rdc321x_conf_read(gpio < 32 ? RDC321X_GPIO_DATA_REG1 : RDC321X_GPIO_DATA_REG2); spin_unlock_irqrestore(&gpio_lock, flags); return (1 << (gpio & 0x1f)) & reg ? 1 : 0; }