Skip to content

Conversation

@benpicco
Copy link
Contributor

@benpicco benpicco commented Mar 19, 2019

The Atmel SAME54 is a Cortex M4F with Ethernet that shares it's peripherals with the sam0 family. (This seems to be true for all new Atmel parts, it certainly is for the new SAML1x Cortex M23 parts).

The MCU is part of the SAMD5x/SAME5x family - the E parts are identical to the D ones, but come with an additional GMAC Ethernet peripheral.

This adds support for the MCU and the SAM E54 Xplained Pro development board.

I ported all existing sam0 peripherals use the new clock setup if available.

What works:

requires zephyrproject-rtos/hal_atmel#1

@zephyrbot
Copy link

zephyrbot commented Mar 19, 2019

Found the following issues, please fix and resubmit:

Identity/Emails issues

9b3747865efa9f07bffc0742228ca0a8dbfaee70: author email (Benjamin Valentin [email protected]) needs to match one of the signed-off-by entries.

8841465af732dc80cf4179cd59f1bd8346ebf87a: author email (Benjamin Valentin [email protected]) needs to match one of the signed-off-by entries.

License issues

In most cases you do not need to do anything here, especially if the files
reported below are going into ext/ and if license was approved for inclusion
into ext/ already. Fix any missing license/copyright issues. The license
exception if a JFYI for the maintainers and can be overriden when merging the
pull request.

  • ext/hal/atmel/asf/sam0/include/samd51/component/can.h is not apache-2.0 licensed: bsd-new
  • ext/hal/atmel/asf/sam0/include/samd51/instance/can0.h is not apache-2.0 licensed: bsd-new
  • ext/hal/atmel/asf/sam0/include/samd51/instance/can1.h is not apache-2.0 licensed: bsd-new
  • ext/hal/atmel/asf/sam0/include/same51/instance/sdhc1.h is not apache-2.0 licensed: bsd-new
  • ext/hal/atmel/asf/sam0/include/same54/component/picop.h is not apache-2.0 licensed: bsd-new
  • ext/hal/atmel/asf/sam0/include/same54/instance/picop.h is not apache-2.0 licensed: bsd-new

@benpicco benpicco force-pushed the same54 branch 2 times, most recently from d3ed798 to 165dced Compare March 20, 2019 16:50
Copy link
Contributor

@Sizurka Sizurka left a comment

Choose a reason for hiding this comment

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

The parenthesis trick is very neat and I'm going to use it :) But it might be better to put it with the other macro voodoo in the shared header so it can be reused:

include/misc/util.h:387

#define UTIL_IS_PARENTHESIZED(x) UTIL_CHECK(UTIL_IS_PARENTHESIZED_ x, 0)
#define UTIL_IS_PARENTHESIZED_(...) 1, 1

You can also use some of the other macros in there to simply the usage later. For example, I'm planning on changing the GPIO handling to something like:

#define SAM0_EIC_IRQ_CONNECT(n, _)					\
COND_CODE_1(UTIL_IS_PARENTHESIZED(DT_EIC_SAM0_IRQ(n)), ( {		\
	IRQ_CONNECT(DT_EIC_SAM0_IRQ(n), DT_EIC_SAM0_IRQ_PRIORITY(n),	\
		    sam0_eic_isr, DEVICE_GET(sam0_eic), 0);		\
	irq_enable(DT_EIC_SAM0_IRQ(n));					\
} ), () )

...

UTIL_LISTIFY(16, SAM0_EIC_IRQ_CONNECT, _);

So if you don't mind I'd like to add the DTS changing and however you decide to handle the macro definitions to the GPIO PR and I can just drop it if yours gets merged first. Alternatively, I can just strip my current multi IRQ handling out and you can add something like the above to your changes for the EIC, whichever way you prefer.

@benpicco
Copy link
Contributor Author

benpicco commented Mar 21, 2019

Nice! I suppose it takes a super worm moon for this kind of macro magic to come forth.
Maybe it's easier to get this included as a separate pull request.

edit: making a separate pull request revealed that the change to extract_dts_includes.py breaks the macro magic performed by nrf52, e.g. zephyr/samples/boards/bbc_microbit/sound that depends on there being no parenthesis.

A solution is to enclose all variables in parenthesizes in dts_fixup.h, but that's a lot less elegant :/

edit2: @galak suggested not to do anything weird with dts_fixup.h as that file should be removed entirely at some point. But having all the interrupt setup code capsuled in SAM0_UART_IRQ_CONNECT already saves a lot of the ugliness.

@Sizurka
Copy link
Contributor

Sizurka commented Mar 21, 2019

Oh well, it was a nice dream. I'll pull the parametric macros for the EIC out of dts_fixup.h as well, since that probably qualifies as "something weird". Since the EIC only has once instance (i.e. it won't re reordered or anything), it's probably safe to use the DT_ATMEL_SAM0_EIC_0_ macros directly, so it shouldn't need anything fixups for any of the variants.

Really, it'd be nice if scripts/dts/extract_dts_includes.py (extract/default.py ?) generated kconfig style defines for the presence of all properties in the device, so there'd be a #define DT_ATMEL_SAM0_UART_42001000_IRQ_0_PRESENT 1 or something. That's probably too specialized to the SAM0 code generation needs, though.

@benpicco
Copy link
Contributor Author

Yes, I will indeed try to reduce the use of dts_fixup.h and switch to DT_ATMEL_SAM0_UART_0_IRQ_0 et al. Since any re-ordering would be consistent when sticking to the defines from generated_dts_board_unfixed.h, I don't see how it would be a problem.

The parametric macros then can stay in the corresponding .c file

@Sizurka
Copy link
Contributor

Sizurka commented Mar 21, 2019

Yeah I think it should be fine as long as you only reference devices by the label, it's just a bit odd when "SERCOM3" ends up as DT_ATMEL_SAM0_UART_0 (since it was the first UART instance) while "SERCOM1" is also DT_ATMEL_SAM0_SPI_0. As long as it's consistent everything should be assigned correctly. So I'll change the I2C code as well.

@codecov-io
Copy link

codecov-io commented Mar 25, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@56c4004). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #14685   +/-   ##
=========================================
  Coverage          ?   52.92%           
=========================================
  Files             ?      309           
  Lines             ?    45268           
  Branches          ?    10451           
=========================================
  Hits              ?    23956           
  Misses            ?    16544           
  Partials          ?     4768

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 56c4004...e24d9cb. Read the comment docs.

@benpicco benpicco force-pushed the same54 branch 3 times, most recently from 8f09e97 to fdc1a5b Compare March 25, 2019 16:51
Copy link
Contributor

@dbkinder dbkinder left a comment

Choose a reason for hiding this comment

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

+1 for docs

@benpicco benpicco force-pushed the same54 branch 4 times, most recently from d3887de to d08c678 Compare April 29, 2019 15:43
@benpicco benpicco added the platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) label May 2, 2019
benpicco and others added 10 commits October 23, 2019 12:20
It shares the same peripheral with other sam0 parts while differing
in the clock config.

Signed-off-by: Benjamin Valentin <[email protected]>
The RTC peripheral found in the SAMD5x/SAME5x MCUs is very
simmilar to the one found in existing sam0 devices with only
a few changes to register names and the clock source selection.

Signed-off-by: Benjamin Valentin <[email protected]>
This adds a driver for the True Random Number Generator found in some
Atmel SAM0 SoCs.
The Code is based on the driver for the SAM TRNG, but uses different
register and clock definitions.

Signed-off-by: Benjamin Valentin <[email protected]>
This adds supoprt for the Atmel SAMD51 SoC.

The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals
with the sam0 Cortex-M0+ and saml1x Cortex-M23 parts.

Signed-off-by: Benjamin Valentin <[email protected]>
This adds supoprt for the Atmel SAME51 SoC.

The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals
with the sam0 Cortex-M0+ and saml1x Cortex-M23 parts.

Signed-off-by: Benjamin Valentin <[email protected]>
This adds supoprt for the Atmel SAME53 SoC.

The SAME5x/SAMD5x is a line of Cortex-M4F MCUs that share peripherals
with the sam0 Cortex-M0+ and saml1x Cortex-M23 parts.

Signed-off-by: Benjamin Valentin <[email protected]>
We need to select TRIGACT_BLOCK for DMA to peripheral to work.

Signed-off-by: Benjamin Valentin <[email protected]>
The amount of lock regions differs between different sam0 MCUs.

	saml10:  2
	saml11:  4
	samd2x:	16
	saml2x: 16
	samd5x: 32

ASF does not provide a definition for this, so create a new one
in dts.

Signed-off-by: Benjamin Valentin <[email protected]>
SAMD5x/SAME5x header files do not provide this define anymore.
On SAMD2x it was 0, this is still valid.

Signed-off-by: Benjamin Valentin <[email protected]>
This adds support for the Atmel SAM E54 Xplained Pro Evaluation Kit.

Only basic functionality has been tested so far.

Signed-off-by: Benjamin Valentin <[email protected]>
@benpicco
Copy link
Contributor Author

@galak I've split it into individual PRs as requested.

@stephanosio
Copy link
Member

stephanosio commented Nov 22, 2019

Ethernet GMAC driver not implemented/ported yet

@benpicco Do you plan to/are you already working on this?

@benpicco
Copy link
Contributor Author

@stephanosio no i don't have any concrete plans for that.

@stephanosio
Copy link
Member

@stephanosio no i don't have any concrete plans for that.

Ok, I will look into it then. At first glance, it seems to be using the same GMAC core as SAM7.

@benpicco benpicco closed this Dec 21, 2019
@benpicco benpicco deleted the same54 branch February 21, 2020 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards area: Devicetree area: Drivers area: I2C area: Modules area: SPI SPI bus area: Tests Issues related to a particular existing or missing test area: Timer Timer area: Watchdog Watchdog platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants