Skip to content

Conversation

@pdgendt
Copy link
Contributor

@pdgendt pdgendt commented Feb 11, 2022

Add support for the ATSAM4SA16C variant and add a driver for the Atmel SMC/EBI module.

Tested on a custom board

@github-actions github-actions bot added area: Devicetree area: Devicetree Binding PR modifies or adds a Device Tree binding labels Feb 11, 2022
@pdgendt pdgendt added the platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) label Feb 11, 2022
@pdgendt pdgendt requested a review from nandojve February 11, 2022 15:24
@nandojve nandojve requested review from mnkp and stephanosio February 13, 2022 19:53
@nandojve nandojve added this to the v3.1.0 milestone Feb 13, 2022
@nandojve
Copy link
Member

Hi @pdgendt ,

Thank you for this contribution. It seems a very clean implementation. I hope can review soon when merge window is open again.
I'm missing few things:

  • It is required a board in tree be configured with this driver to allow CI tests. Is it possible enable IS66WV51216DALL support at SAM4S, or even SAM4E? Please, let us know at least what is your use case.
  • It is necessary create a test. It doesn't need to be so elaborated but without it won't be possible build the driver at CI with a valid config. My suggestion is add as a sample at samples/drivers/smc_<use case> where use case can be sram, sdram etc.
  • It will be necessary add an entry as smc at board yaml file to enable twister tests. Be aware that smc will be the filter entry in the test case.
    supported:
    - gpio
    - spi
    - watchdog
    - xplained_gpio
    - xplained_i2c
    - xplained_serial
    - xplained_spi
  • I think SAM4S and SAM4E have same SMC IP, could you confirm? If yes, could you add SMC node for SAM4E too.
  • How users will mapped memory?

@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2022

Codecov Report

Merging #42739 (655b0d2) into main (32c4bd3) will increase coverage by 0.30%.
The diff coverage is 36.84%.

❗ Current head 655b0d2 differs from pull request most recent head c1e1d8d. Consider uploading reports for the commit c1e1d8d to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #42739      +/-   ##
==========================================
+ Coverage   50.10%   50.41%   +0.30%     
==========================================
  Files         632      632              
  Lines       77529    77530       +1     
  Branches    18102    18101       -1     
==========================================
+ Hits        38844    39084     +240     
+ Misses      32257    31981     -276     
- Partials     6428     6465      +37     
Impacted Files Coverage Δ
drivers/ethernet/eth_native_posix.c 35.13% <ø> (ø)
include/drivers/ptp_clock.h 100.00% <ø> (ø)
include/net/buf.h 98.75% <ø> (ø)
subsys/bluetooth/host/gatt.c 8.65% <0.00%> (-0.01%) ⬇️
subsys/net/ip/tcp.c 52.98% <33.33%> (-0.12%) ⬇️
lib/os/fdtable.c 60.97% <100.00%> (+2.71%) ⬆️
lib/posix/pthread_cond.c 75.00% <100.00%> (-5.00%) ⬇️
lib/posix/pthread_mutex.c 64.00% <0.00%> (-13.34%) ⬇️
subsys/fs/littlefs_fs.c 70.47% <0.00%> (+0.49%) ⬆️
subsys/settings/src/settings.c 66.08% <0.00%> (+1.73%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a17eeb2...c1e1d8d. Read the comment docs.

@pdgendt
Copy link
Contributor Author

pdgendt commented Feb 14, 2022

Hi @nandojve, thank you for the response. I've update the PR, please check my responses below.

It is required a board in tree be configured with this driver to allow CI tests. Is it possible enable IS66WV51216DALL support at SAM4S, or even SAM4E? Please, let us know at least what is your use case.

I've added the IS66WV51216DALL to the sam4s_xplained board, however I don't have access to this HW, can you/someone test the changes made? I've taken IDs/addresses/timings from datasheets and example projects.

It is necessary create a test. It doesn't need to be so elaborated but without it won't be possible build the driver at CI with a valid config. My suggestion is add as a sample at samples/drivers/smc_<use case> where use case can be sram, sdram etc.

Is this still required if it is added to an existing board where other tests will probably already cover this?

It will be necessary add an entry as smc at board yaml file to enable twister tests. Be aware that smc will be the filter entry in the test case.

supported:
- gpio
- spi
- watchdog
- xplained_gpio
- xplained_i2c
- xplained_serial
- xplained_spi

Added.

I think SAM4S and SAM4E have same SMC IP, could you confirm? If yes, could you add SMC node for SAM4E too.

Added based on the SAM4E datasheet, unable to test due to lack of HW.

How users will mapped memory?

I've updated the yaml file on how to add the memory to the dts.

@pdgendt pdgendt force-pushed the atmel-smc branch 2 times, most recently from 76e1960 to d3587e7 Compare February 14, 2022 09:30
@pdgendt
Copy link
Contributor Author

pdgendt commented Feb 14, 2022

Rebased on main

Copy link
Member

@nandojve nandojve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdgendt ,

It will be necessary add a test at tests/drivers/memc. My suggestion is do something simple like write a pattern, read back and compare. This could be a generic test that may be used for any future memc_sram driver inclusive.

@pdgendt
Copy link
Contributor Author

pdgendt commented Feb 18, 2022

It will be necessary add a test at tests/drivers/memc. My suggestion is do something simple like write a pattern, read back and compare. This could be a generic test that may be used for any future memc_sram driver inclusive.

Hey @nandojve,

I was looking into this, and there's a test for stm32_sdram which could be reused. However this requires some more effort for the linker sections to be more generic.

Looking at #42008 and #40422 we could rework that existing test once those PRs are merged.

@nandojve nandojve changed the title sam4s: Introduce SMC driver Atmel SAM: Introduce SMC driver Feb 19, 2022
Copy link
Member

@nandojve nandojve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking into this, and there's a test for stm32_sdram which could be reused. However this requires some more effort for the linker sections to be more generic.

If it is possible, better! Project prefers reuse instead add new ones.

Looking at #42008 and #40422 we could rework that existing test once those PRs are merged.

Your PR will be conditioned to be merged after those.

I was looking this controller and my initial thought was that SMC should handle SDRAM too. After looking datasheets I noted that SAM uses a dedicated controller for SDRAM. So, in this case, we have two distinct drivers and those are independently.

On that research I noted that SAMS7/E7/V7 uses same SMC ip. It is up to you add that nodes like SAM4E. There is a minimal change in the driver that could be added which will allow SAMS7/E7/V7 have 16 bit access instead only 8. If you don't mind add this, you can upstream the whole feature set. This is a plus not a block from my side.

@pdgendt
Copy link
Contributor Author

pdgendt commented Feb 21, 2022

Looking at #42008 and #40422 we could rework that existing test once those PRs are merged.

Your PR will be conditioned to be merged after those.

So we wait a bit, or?

I was looking this controller and my initial thought was that SMC should handle SDRAM too. After looking datasheets I noted that SAM uses a dedicated controller for SDRAM. So, in this case, we have two distinct drivers and those are independently.

Do you mean on the SMC module as well?

On that research I noted that SAMS7/E7/V7 uses same SMC ip. It is up to you add that nodes like SAM4E. There is a minimal change in the driver that could be added which will allow SAMS7/E7/V7 have 16 bit access instead only 8. If you don't mind add this, you can upstream the whole feature set. This is a plus not a block from my side.

I currently have limited time to add these additional SoCs, and no hardware to test. The SAM4E looked easy, but I also have no way to test this. I guess if someone needs them, it should be easy to test and upstream.

@pdgendt pdgendt requested a review from nandojve February 21, 2022 10:13
@nandojve
Copy link
Member

Your PR will be conditioned to be merged after those.

So we wait a bit, or?

Yes, to reuse.

Do you mean on the SMC module as well?

As far I understood SMC not support SDRAM. SDRAM is handled by a dedicated controller. At end, EBI is a set of one or two controllers (SMC + SDRAM).

@pdgendt pdgendt requested a review from nandojve July 26, 2022 08:50
Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still keeping a -1 on for now because it's not clear to me if this is a correct use of default.

Copy link
Member

@nandojve nandojve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdgendt ,

I think it is better but still missing important information. I tried highlight few points to you.

Copy link
Member

@nandojve nandojve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdgendt ,

It still not clear. Please, see my suggestions and adapt as you wish.

@pdgendt
Copy link
Contributor Author

pdgendt commented Aug 2, 2022

Thanks @nandojve, for all your efforts to help out!

I updated the suggestions you made, but adjusted the example timings to the datasheet specifications.
A minimum setup time of 5ns and puls time of 45ns where swapped in your description?

@nandojve
Copy link
Member

nandojve commented Aug 4, 2022

Hi @pdgendt ,

Im OK with changes. Lets ask to @mbolivar-nordic to check if fits.

BTW, we need fix flash stuff

@nandojve
Copy link
Member

nandojve commented Aug 7, 2022

BTW, we need fix flash stuff

Fixed by #48762

Add soc support for sam4sa16c variant

Signed-off-by: Pieter De Gendt <[email protected]>
Add a driver to support external memory connected to the SMC port
for Atmel SAM devices.

Signed-off-by: Pieter De Gendt <[email protected]>
Add pinctrl definitions for the SMC peripheral and add the module
to the sam4s soc.

Signed-off-by: Pieter De Gendt <[email protected]>
Add pinctrl definitions for the SMC peripheral (8) and add the
module to the sam4e soc.

IDs and addresses are taken from the datasheet.

Signed-off-by: Pieter De Gendt <[email protected]>
This commit enables the SRAM controller is66wv51216dbll connected
to the SMC/EBI bus. Half of the memory is made available (512KB)
on chip select 0, the other part is (512KB) on chip select 1.

The SMC timings are taken from the Microchip studio example
SMC_SRAM_EXAMPLE for the sam4s_xplained board.

Signed-off-by: Pieter De Gendt <[email protected]>
* Reworked the stm32 SDRAM test to be more generic
* Added SRAM entries
* Moved to new ztest API

Signed-off-by: Pieter De Gendt <[email protected]>
@nandojve
Copy link
Member

Hi @mbolivar-nordic ,

No more CI erros and @pdgendt made few changes. I was wondering if you can revisit this PR.

Copy link
Contributor

@mbolivar-nordic mbolivar-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdgendt thanks for the big improvements. I'm glad to see the properties go to required. The default feature has its uses, but it is easy to abuse and I'm glad for your and @nandojve figuring out a better way forward.

@carlescufi carlescufi merged commit 1dc69c0 into zephyrproject-rtos:main Aug 16, 2022
@pdgendt pdgendt deleted the atmel-smc branch August 16, 2022 11:06
@talih0
Copy link
Contributor

talih0 commented Jan 6, 2024

@pdgendt, @nandojve, I'm working on a similar driver for Infineon XMC4xxx.
A problem I've come across is that it's not possible to use zephyr_code_relocate() to move data, bss to external RAM with these type of drivers.

The driver set up happens with POST_KERNEL priority, but
bss_zeroing_relocation(); and data_copy_xip_relocation() are called very early at boot up. This driver should have the same problem.

Did you come across something like this?

@pdgendt
Copy link
Contributor Author

pdgendt commented Jan 22, 2024

@pdgendt, @nandojve, I'm working on a similar driver for Infineon XMC4xxx. A problem I've come across is that it's not possible to use zephyr_code_relocate() to move data, bss to external RAM with these type of drivers.

The driver set up happens with POST_KERNEL priority, but bss_zeroing_relocation(); and data_copy_xip_relocation() are called very early at boot up. This driver should have the same problem.

Did you come across something like this?

Hey @talih0, I did not need relocating to external RAM, so I can't really share my experience there. If this is something you want to be looked at, I would suggest creating a new issue. Comments on merged PRs are easily overlooked :)

@talih0
Copy link
Contributor

talih0 commented Jan 23, 2024

thanks @pdgendt for following up, I'll create an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: Documentation platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants