static void rb532_led_set(struct led_classdev *cdev, enum led_brightness brightness) { if (brightness) set_latch_u5(LO_ULED, 0); else set_latch_u5(0, LO_ULED); }
/* The S1 button state is provided by GPIO pin 1. But as this * pin is also used for uart input as alternate function, the * operational modes must be switched first: * 1) disable uart using set_latch_u5() * 2) turn off alternate function implicitly through * gpio_direction_input() * 3) read the GPIO's current value * 4) undo step 2 by enabling alternate function (in this * mode the GPIO direction is fixed, so no change needed) * 5) turn on uart again * The GPIO value occurs to be inverted, so pin high means * button is not pressed. */ static bool rb532_button_pressed(void) { int val; set_latch_u5(0, LO_FOFF); gpio_direction_input(GPIO_BTN_S1); val = gpio_get_value(GPIO_BTN_S1); rb532_gpio_set_func(GPIO_BTN_S1); set_latch_u5(LO_FOFF, 0); return !val; }
static void rb532_cmd_ctrl(struct nand_chip *chip, int cmd, unsigned int ctrl) { unsigned char orbits, nandbits; if (ctrl & NAND_CTRL_CHANGE) { orbits = (ctrl & NAND_CLE) << 1; orbits |= (ctrl & NAND_ALE) >> 1; nandbits = (~ctrl & NAND_CLE) << 1; nandbits |= (~ctrl & NAND_ALE) >> 1; set_latch_u5(orbits, nandbits); }