Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62ED5C433DF for ; Mon, 13 Jul 2020 14:27:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D912205CB for ; Mon, 13 Jul 2020 14:27:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=aruba.it header.i=@aruba.it header.b="g5wR0zIG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729893AbgGMO1h (ORCPT ); Mon, 13 Jul 2020 10:27:37 -0400 Received: from smtpcmd02101.aruba.it ([62.149.158.101]:40833 "EHLO smtpcmd02101.aruba.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729784AbgGMO1h (ORCPT ); Mon, 13 Jul 2020 10:27:37 -0400 X-Greylist: delayed 427 seconds by postgrey-1.27 at vger.kernel.org; Mon, 13 Jul 2020 10:27:36 EDT Received: from [192.168.1.129] ([93.146.66.165]) by smtpcmd02.ad.aruba.it with bizsmtp id 2eLN230113Zw7e501eLPZ4; Mon, 13 Jul 2020 16:20:27 +0200 Subject: Re: [RFC] GPIO lines [was: GPIO User I/O] To: Linus Walleij Cc: Geert Uytterhoeven , Geert Uytterhoeven , "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski , Rob Herring , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" References: <01afcac0-bd34-3fd0-b991-a8b40d4b4561@enneenne.com> <1c4f1a83-835a-9317-3647-b55f6f39c0ba@enneenne.com> <87efe96c-3679-14d5-4d79-569b6c047b00@enneenne.com> <070fa558-6e20-0fbf-d3e4-0a0eca4fe82c@enneenne.com> From: Rodolfo Giometti Message-ID: Date: Mon, 13 Jul 2020 16:20:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1594650027; bh=htV99MPbzwj4JWvKbJWvdYMsckXanjJlxRhiqpDyOD0=; h=Subject:To:From:Date:MIME-Version:Content-Type; b=g5wR0zIG3iO0Xj/NjCc4RWlVwTb4BTE1PzRK9fwEzWeCY2pyFGE2VztebYSgXAsjZ Vh6ei6C3yAOKF+xlvPqWKNKCFIKao0nUMJ7CI1KsBBmMKXRqdYzApq94XSW6J5QZOS fAWI8X9IctbQe0JxCWWLX/WYo8OikFfUQBixY9is/OL5nKAaiEPtfFytV13CtRTQBf ueEpbCDaHpwJ8k0tsL7RkD/iC7aQYM57hwaWCp8SVep8d6N4xTJ7UwhpJ1eqlfKx6p czsx5Y2f9cLsOG2aC0F21VGZDre5j/+Ya+yQUKdsri4OGiGqCOxKIXbX/qSn6fYzCz Xorg+Nfz0/V4A== Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On 11/07/2020 17:21, Linus Walleij wrote: > On Thu, Jul 9, 2020 at 4:11 PM Rodolfo Giometti wrote: > >> gpio_lines { >> compatible = "gpio-line"; >> >> bypass0 { >> gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>; >> mode = "out-low"; >> }; >> >> bypass1 { >> gpios = <&gpiosb 11 GPIO_ACTIVE_HIGH>; >> mode = "out-low"; >> }; >> >> key { >> gpios = <&gpionb 4 GPIO_ACTIVE_HIGH>; >> mode = "input"; >> }; >> >> motor { >> gpios = <&gpionb 8 GPIO_ACTIVE_HIGH>; >> mode = "out-high-open-drain"; >> }; > > These mode = ... strings are really just a big confusion for me since > they reinvent several of the flags you can already give to the gpios, > see include/dt-bindings/gpio/gpio.h: > > /* Bit 0 express polarity */ > #define GPIO_ACTIVE_HIGH 0 > #define GPIO_ACTIVE_LOW 1 > > /* Bit 1 express single-endedness */ > #define GPIO_PUSH_PULL 0 > #define GPIO_SINGLE_ENDED 2 > > /* Bit 2 express Open drain or open source */ > #define GPIO_LINE_OPEN_SOURCE 0 > #define GPIO_LINE_OPEN_DRAIN 4 > > /* > * Open Drain/Collector is the combination of single-ended open drain interface. > * Open Source/Emitter is the combination of single-ended open source interface. > */ > #define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_DRAIN) > #define GPIO_OPEN_SOURCE (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_SOURCE) These modes came from include/linux/gpio/consumer.h: /** * Optional flags that can be passed to one of gpiod_* to configure direction * and output value. These values cannot be OR'd. */ enum gpiod_flags { GPIOD_ASIS = 0, GPIOD_IN = GPIOD_FLAGS_BIT_DIR_SET, GPIOD_OUT_LOW = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT, GPIOD_OUT_HIGH = GPIOD_FLAGS_BIT_DIR_SET | GPIOD_FLAGS_BIT_DIR_OUT | GPIOD_FLAGS_BIT_DIR_VAL, GPIOD_OUT_LOW_OPEN_DRAIN = GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_OPEN_DRAIN, GPIOD_OUT_HIGH_OPEN_DRAIN = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_OPEN_DRAIN, }; So a setting like the following should set at boot gpio10 as output to 0: bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_HIGH>; mode = "out-low"; }; While the next one should set gpio10 as output to 1: bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_LOW>; mode = "out-low"; }; Maybe I can do something similar to hog-gpio as below, if you prefer... bypass0 { gpios = <&gpionb 10 GPIO_ACTIVE_LOW>; output-low; }; Ciao, Rodolfo -- GNU/Linux Solutions e-mail: giometti@enneenne.com Linux Device Driver giometti@linux.it Embedded Systems phone: +39 349 2432127 UNIX programming skype: rodolfo.giometti