On Fri, Feb 5, 2021 at 12:26 PM Grr <gebbe...@gmail.com> wrote: > > NuttX already support pinctrl and gpio peripheral: > > > > > https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/ioexpander/ioexpander.h > > > > > > > https://github.com/apache/incubator-nuttx/blob/master/include/nuttx/ioexpander/gpio.h > > We can reuse and improve them. > > > > I don't mean IO expander. I mean ability to use uC GPIO in a general way > > For example, how can you define GPIO1 as pin X1 of port Y1 in board Z1 but > pin X2 of port Y2 in board Z2 so any driver can use GPIO1 without being > hardwired to a specific board? > > For that you need a general GPIO system where boards export GPIOs in a > platform-independent way that any driver can use > > We achieve this by:
1. Chip driver implement io expander driver to encapsulate the gpio hardware 2. Generic driver control the gpio through the io expander driver directly e.g.: https://github.com/FishsemiCode/nuttx/blob/song-u1/include/nuttx/lcd/ili9486_lcd.h#L72-L74 int lcd_ili9486_register(FAR const struct lcd_ili9486_config_s *config, FAR struct spi_dev_s *spi, FAR struct ioexpander_dev_s *ioe); Another method is that the generic driver calls the callback provided by the board file to do the custom specific logic. > > Common code shouldn't reference arch or board specific header files, only > > source code under boards/ or arch/ can reference them. > > > > I mean the other way around: board.h referencing common platform header > files, needed for memory definitions > The platform could put the public header files under arch/archx/include/chipy/ and then boards/archx/chipy/boardz can reference these header files.