gpio: init pin after export 62/214162/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20191031.025744 accepted/tizen/5.5/unified/mobile/hotfix/20201027.064158 accepted/tizen/5.5/unified/wearable/hotfix/20201027.120549 accepted/tizen/unified/20190923.225255 submit/tizen/20190923.102122 submit/tizen/20190923.125435 submit/tizen_5.5/20191031.000002 submit/tizen_5.5_mobile_hotfix/20201026.185102 submit/tizen_5.5_wearable_hotfix/20201026.184302 tizen_5.5.m2_release
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Wed, 18 Sep 2019 11:58:46 +0000 (13:58 +0200)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Wed, 18 Sep 2019 11:59:41 +0000 (13:59 +0200)
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 <k.kuchciak@samsung.com>
src/interface/peripheral_interface_gpio.c

index c1e966f..ce9be7f 100644 (file)
@@ -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;
                }
        }