From: Konrad Kuchciak Date: Wed, 18 Sep 2019 11:58:46 +0000 (+0200) Subject: gpio: init pin after export X-Git-Tag: submit/tizen/20190923.102122^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70dcc13c092288d06b6bb6255756f26ffd07b0fb;p=platform%2Fcore%2Fapi%2Fperipheral-io.git gpio: init pin after export This will fully initialize the pin. The problem is that edge attribute cannot be modified without explicitly defining pin's direction after boot. It seems like a kernel issue. This is just a workaround. Change-Id: I6c9a2c8d20757c3f9d04779a820015c839b8ea5c Signed-off-by: Konrad Kuchciak --- diff --git a/src/interface/peripheral_interface_gpio.c b/src/interface/peripheral_interface_gpio.c index c1e966f..ce9be7f 100644 --- a/src/interface/peripheral_interface_gpio.c +++ b/src/interface/peripheral_interface_gpio.c @@ -37,6 +37,15 @@ int peripheral_interface_gpio_set_initial_direction_into_handle(peripheral_gpio_ if (!strncmp(gpio_buf, types[index].type, types[index].len)) { // PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_HIGH and PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW : out type gpio->direction = (peripheral_gpio_direction_e)index; + + /* + * Also write to direction for the very first time after boot + * to ensure that the pin is fully initialized. + * Without this, writing to 'edge' is not possible. + */ + ret = write(gpio->fd_direction, types[index].type, types[index].len); + CHECK_ERROR(ret != types[index].len); + return PERIPHERAL_ERROR_NONE; } }