Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert SAM SoC drivers to DT_INST #23107

Closed
61 tasks done
nandojve opened this issue Feb 26, 2020 · 9 comments
Closed
61 tasks done

Convert SAM SoC drivers to DT_INST #23107

nandojve opened this issue Feb 26, 2020 · 9 comments
Assignees
Labels
area: Devicetree area: Drivers Enhancement Changes/Updates/Additions to existing features Meta A collection of features, enhancements or bugs platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)

Comments

@nandojve
Copy link
Member

nandojve commented Feb 26, 2020

Is your enhancement proposal related to a problem? Please describe.

This is to keep tracking of drivers to DT_INST related to Atmel SoCs. The worked started with #22806.

Describe the solution you'd like

Move/Create DT_INST for below driver list:

SoC:

Boards:

Others:

Pinctrl:
Feature #24236 #24319

Issues:
#23281 fixed by #23289
#23415 fixed by #23427
#24399 fixed by #24401

@nandojve nandojve added the Enhancement Changes/Updates/Additions to existing features label Feb 26, 2020
@nandojve
Copy link
Member Author

@galak

nandojve added a commit to nandojve/zephyr that referenced this issue Mar 5, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 5, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
@nandojve
Copy link
Member Author

nandojve commented Mar 5, 2020

@stephanosio stephanosio added area: Devicetree area: Drivers platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) Meta A collection of features, enhancements or bugs labels Mar 5, 2020
@nandojve
Copy link
Member Author

nandojve commented Mar 6, 2020

@jhedberg

nandojve added a commit to nandojve/zephyr that referenced this issue Mar 7, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 7, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 8, 2020
Durant the process to convert Atmel drivers to use DT_INST_ defines
was detected the necessity of a hardware instance identificator.
Some drivers need configure port pins, clocks, DMA etc. This will
track the hw instance on the DT_INST_x_ independent of the 'x' value.

This will keep simple the conversion this add a new non mandatory
property called <id>. The driver that need these feature need add
'required=true' on the dts/binding/driver  and complement any
device tree with proper value.

Examples:

foo0: foo@1000 {
	compatible = "man,foo-drv";
	id = <0>;
	status="disabled";
};
foo1: foo@1001 {
	compatible = "man,foo-drv";
	id = <1>;
};
barn: bar@2001 {
	compatible = "man,bar-drv";
	id = <10>;
};
barm: bar@3001 {
	compatible = "man,bar-drv";
	id = <20>;
};

Will generate:

DT_INST_0_MAN_FOO_DRV_ID=1
DT_INST_0_MAN_BAR_DRV_ID=10
DT_INST_1_MAN_BAR_DRV_ID=20

It is intent to be used as below to propagate the hardware id on all
driver defines.

DRV_FOO_DEVICE_INIT(0, DT_INST_0_MAN_FOO_DRV_ID);

A good driver example that need this definition:

static const struct drv_foo_dev_cfg drv##n##_sam_config = {	\
	.regs = (Drv *)DT_INST_##n##_MAN_DRV_FOO_BASE_ADDRESS,	\
	.pin_rx = PIN_FOO##m##_RXD,				\
	.pin_tx = PIN_FOO##m##_TXD,				\
}

If 'm' isn't defined the driver will invariably configure the wrong
pins and communication won't happen. This can't be derived by node
name for many reasons. For instance. the above DT snip defined 'barn'
and 'barm' that have a name without number and an unusual value. It
represents two instances of bar that shouldn't assume values other
than defined on the id property.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 8, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Mar 9, 2020
Convert driver to use DT_INST_ defines.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
@galak
Copy link
Collaborator

galak commented Mar 31, 2020

@nandojve are you able to get back to look at conversions for SAM now that we have the new DT macro's in place. Here's what I have (the # is count of DT_ references that need modification, or a rough estimate).

     10 drivers/adc/adc_sam_afec.c
      2 drivers/flash/flash_sam.c
     35 drivers/gpio/gpio_sam.c
      2 drivers/hwinfo/hwinfo_sam.c
     12 drivers/i2c/i2c_sam_twi.c
     18 drivers/i2c/i2c_sam_twihs.c
     35 drivers/serial/uart_sam.c
     24 drivers/serial/usart_sam.c
      5 drivers/spi/spi_sam.c
     28 drivers/usb/device/usb_dc_sam.c

     13 drivers/adc/adc_sam0.c
      9 drivers/counter/counter_sam0_tc32.c
     12 drivers/gpio/gpio_sam0.c
     35 drivers/i2c/i2c_sam0.c
     12 drivers/pinmux/pinmux_sam0.c
     46 drivers/serial/uart_sam0.c
     43 drivers/spi/spi_sam0.c

@nandojve
Copy link
Member Author

Hi @galak, I can take look at weekend and try update full list. I saw tons of DT_INST moving and probably lots of SAM related.

@galak
Copy link
Collaborator

galak commented Apr 1, 2020

Hi @galak, I can take look at weekend and try update full list. I saw tons of DT_INST moving and probably lots of SAM related.

Thanks. All the DT_INST conversions should be complete. This work now would be moving away from something like DT_ATMEL_SAM0_SPI_... to DT_INST and DT_NODELABEL (nodelabel form used for cases like pinmux.c that you need to know the specific instance). The idea being that the node label in dts will match the SoC docs naming.

nandojve added a commit to nandojve/zephyr that referenced this issue Apr 12, 2020
Convert driver to use new device tree macros.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Apr 12, 2020
Convert driver to use new device tree macros.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
nandojve added a commit to nandojve/zephyr that referenced this issue Apr 12, 2020
Convert driver to use new device tree macros.

see zephyrproject-rtos#23107

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
@nandojve
Copy link
Member Author

@galak I believe is almost done with Atmel SAM/SAM0.

Drivers converted however not define the global DT_DRV_COMPAT:
drivers/hwinfo/hwinfo_sam.c

Drivers without DT support:
drivers/dma/dma_sam_xdmac.c
drivers/i2s/i2s_sam_ssc.c

@galak
Copy link
Collaborator

galak commented May 8, 2020

@galak I believe is almost done with Atmel SAM/SAM0.

Drivers converted however not define the global DT_DRV_COMPAT:
drivers/hwinfo/hwinfo_sam.c

I'm not sure it makes sense in this case, but ok if you want to submit a PR for it.

Drivers without DT support:
drivers/dma/dma_sam_xdmac.c
drivers/i2s/i2s_sam_ssc.c

Done.

@nandojve
Copy link
Member Author

Atmel SoC DT_INST migration was concluded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree area: Drivers Enhancement Changes/Updates/Additions to existing features Meta A collection of features, enhancements or bugs platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)
Projects
None yet
Development

No branches or pull requests

3 participants