Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to set correctly GPIO flags in dts files?

Featured Replies

Hi,

 

I managed to make w1-GPIO work in Orange Pi Zero v3 for, for example, the DS18B20 sensor.

 

However, I have some doubts about setting the GPIO flags for w1-gpio. Many examples provide flags in the form

 

gpios = <&pio 0 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

 

but in the dts file when I use this form it does not work (syntax error) so I have to provide the flags in digital form.

 

A description of flags and bits is here

 

https://elixir.bootlin.com/linux/v6.6.30/source/include/dt-bindings/gpio/gpio.h

 

If I would like to set GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN then the digital value for these bits will be for set bits: 0110000 =  48

 

because GPIO_OPEN_DRAIN it is (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_DRAIN)

 

Please help me and confirm whether I understood it correctly I wanted to get rid of the message in the logs for w1-gpio

 

[ 4.994183] gpio-74 (onewire@0): enforced open drain please flag it properly in DT/ACPI DSDT/board file

 

which understands that I need to set the GPIO flag GPIO_OPEN_DRAIN in the dts file

 

 

I see one problem with this source https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio.txt

where a number of bits to set is 6 in source https://elixir.bootlin.com/linux/v6.6.30/source/include/dt-bindings/gpio/gpio.h

number of bits to set is 7

 

 

I hope I posted this question in the right section, if not please move it

Edited by TRay

  • Author

Reading many others documents about OPEN DRAIN flag , OZPI v3 and others like Raspberry Pi don't support Open DRAIN, but they should work in emulated mode, switching between input and output-driving-low. So for this reason if we set flag for GPIO with OPEN DARIN it looks not influence and not need setting this flag for w1-gpio for this SBC

 

 

Edited by TRay

/* 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)

/* Bit 3 express GPIO suspend/resume and reset persistence */
#define GPIO_PERSISTENT 0
#define GPIO_TRANSITORY 8

 

when combining add the bits #define GPIO_OPEN_DRAIN (GPIO_SINGLE_ENDED | GPIO_LINE_OPEN_DRAIN)  is 2+4= 6

 

 

gpios = <&pio 0 7 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;  

or

gpios = <&pio 0 7 4>;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.