Browse Source

spi: sam0: use Device Tree for configuration.

Switch the SoC device tree to define a single entry per SERCOM instead
of one per mode.

Define a Device Tree binding for the SAM0 SPI and use it instead of
Kconfig for enabling / disabaling instances

Switch the Arduino Zero, Adafruit Feather M0 Basic Proto, and
Trinket M0 to use the new defintion.

Add the APA102 LED that's on the Trinket as a test.

Signed-off-by: Michael Hope <mlhx@google.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
pull/6552/head
Michael Hope 8 years ago committed by Kumar Gala
parent
commit
a8a36a23fc
  1. 18
      arch/arm/soc/atmel_sam0/samd21/dts.fixup
  2. 6
      boards/arm/adafruit_feather_m0_basic_proto/adafruit_feather_m0_basic_proto.dts
  3. 2
      boards/arm/adafruit_feather_m0_basic_proto/adafruit_feather_m0_basic_proto_defconfig
  4. 14
      boards/arm/adafruit_trinket_m0/adafruit_trinket_m0.dts
  5. 2
      boards/arm/adafruit_trinket_m0/adafruit_trinket_m0_defconfig
  6. 12
      boards/arm/arduino_zero/arduino_zero.dts
  7. 1
      boards/arm/arduino_zero/arduino_zero_defconfig
  8. 1
      drivers/spi/Kconfig.sam0
  9. 17
      drivers/spi/spi_sam0.c
  10. 66
      dts/arm/atmel/samd21.dtsi
  11. 27
      dts/bindings/arm/atmel,sam0-sercom.yaml
  12. 29
      dts/bindings/spi/atmel,sam0-spi.yaml

18
arch/arm/soc/atmel_sam0/samd21/dts.fixup

@ -45,6 +45,24 @@ @@ -45,6 +45,24 @@
#define CONFIG_UART_SAM0_SERCOM5_LABEL ATMEL_SAM0_UART_42001C00_LABEL
#define CONFIG_UART_SAM0_SERCOM5_BASE_ADDRESS ATMEL_SAM0_UART_42001C00_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM0_LABEL ATMEL_SAM0_SPI_42000800_LABEL
#define CONFIG_SPI_SAM0_SERCOM0_BASE_ADDRESS ATMEL_SAM0_SPI_42000800_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM1_LABEL ATMEL_SAM0_SPI_42000C00_LABEL
#define CONFIG_SPI_SAM0_SERCOM1_BASE_ADDRESS ATMEL_SAM0_SPI_42000C00_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM2_LABEL ATMEL_SAM0_SPI_42001000_LABEL
#define CONFIG_SPI_SAM0_SERCOM2_BASE_ADDRESS ATMEL_SAM0_SPI_42001000_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM3_LABEL ATMEL_SAM0_SPI_42001400_LABEL
#define CONFIG_SPI_SAM0_SERCOM3_BASE_ADDRESS ATMEL_SAM0_SPI_42001400_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM4_LABEL ATMEL_SAM0_SPI_42001800_LABEL
#define CONFIG_SPI_SAM0_SERCOM4_BASE_ADDRESS ATMEL_SAM0_SPI_42001800_BASE_ADDRESS
#define CONFIG_SPI_SAM0_SERCOM5_LABEL ATMEL_SAM0_SPI_42001C00_LABEL
#define CONFIG_SPI_SAM0_SERCOM5_BASE_ADDRESS ATMEL_SAM0_SPI_42001C00_BASE_ADDRESS
#define CONFIG_WDT_SAM0_IRQ ATMEL_SAM0_WATCHDOG_40001000_IRQ_0
#define CONFIG_WDT_SAM0_IRQ_PRIORITY ATMEL_SAM0_WATCHDOG_40001000_IRQ_0_PRIORITY
#define CONFIG_WDT_SAM0_LABEL ATMEL_SAM0_WATCHDOG_40001000_LABEL

6
boards/arm/adafruit_feather_m0_basic_proto/adafruit_feather_m0_basic_proto.dts

@ -22,11 +22,15 @@ @@ -22,11 +22,15 @@
&sercom0 {
status = "ok";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
};
&spi4 {
&sercom4 {
status = "ok";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
};
&flash0 {

2
boards/arm/adafruit_feather_m0_basic_proto/adafruit_feather_m0_basic_proto_defconfig

@ -17,7 +17,5 @@ CONFIG_SOC_ATMEL_SAMD_XOSC32K=y @@ -17,7 +17,5 @@ CONFIG_SOC_ATMEL_SAMD_XOSC32K=y
CONFIG_SOC_ATMEL_SAMD_XOSC32K_AS_MAIN=y
CONFIG_SPI=y
CONFIG_SPI_SAM0=y
CONFIG_SPI_4=y
CONFIG_SPI_LEGACY_API=n
CONFIG_PINMUX=y
CONFIG_PINMUX_SAM0=y

14
boards/arm/adafruit_trinket_m0/adafruit_trinket_m0.dts

@ -21,17 +21,29 @@ @@ -21,17 +21,29 @@
&sercom0 {
status = "ok";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
};
&sercom2 {
status = "ok";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
};
/* Drives the on-board DotStar LED */
&spi1 {
&sercom1 {
status = "ok";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
led1: apa102@0 {
compatible = "apa,apa102";
reg = <0>;
spi-max-frequency = <24000000>;
label = "LED1";
};
};
&flash0 {

2
boards/arm/adafruit_trinket_m0/adafruit_trinket_m0_defconfig

@ -16,8 +16,6 @@ CONFIG_WATCHDOG=y @@ -16,8 +16,6 @@ CONFIG_WATCHDOG=y
CONFIG_WDT_SAM0=y
CONFIG_SPI=y
CONFIG_SPI_SAM0=y
CONFIG_SPI_1=y
CONFIG_SPI_1_IRQ_PRI=0
CONFIG_SPI_LEGACY_API=n
CONFIG_PINMUX=y
CONFIG_PINMUX_SAM0=y

12
boards/arm/arduino_zero/arduino_zero.dts

@ -18,15 +18,23 @@ @@ -18,15 +18,23 @@
};
};
&sercom5 {
&sercom0 {
status = "ok";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
};
&sercom0 {
&sercom5 {
status = "ok";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
};
&sercom4 {
status = "ok";
compatible = "atmel,sam0-spi";
};
&flash0 {
partitions {
compatible = "fixed-partitions";

1
boards/arm/arduino_zero/arduino_zero_defconfig

@ -17,7 +17,6 @@ CONFIG_SOC_ATMEL_SAMD_XOSC32K=y @@ -17,7 +17,6 @@ CONFIG_SOC_ATMEL_SAMD_XOSC32K=y
CONFIG_SOC_ATMEL_SAMD_XOSC32K_AS_MAIN=y
CONFIG_SPI=y
CONFIG_SPI_SAM0=y
CONFIG_SPI_4=y
CONFIG_SPI_LEGACY_API=n
CONFIG_PINMUX=y
CONFIG_PINMUX_SAM0=y

1
drivers/spi/Kconfig.sam0

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
menuconfig SPI_SAM0
bool "Atmel SAM0 series SERCOM SPI driver"
depends on SOC_FAMILY_SAM0
select HAS_DTS_SPI
default n
help
Enable support for the SAM0 SERCOM SPI driver.

17
drivers/spi/spi_sam0.c

@ -436,7 +436,7 @@ static const struct spi_driver_api spi_sam0_driver_api = { @@ -436,7 +436,7 @@ static const struct spi_driver_api spi_sam0_driver_api = {
#define SPI_SAM0_DEFINE_CONFIG(n) \
static const struct spi_sam0_config spi_sam0_config_##n = { \
.regs = &SERCOM##n->SPI, \
.regs = (SercomSpi *)CONFIG_SPI_SAM0_SERCOM##n##_BASE_ADDRESS, \
.pm_apbcmask = PM_APBCMASK_SERCOM##n, \
.gclk_clkctrl_id = GCLK_CLKCTRL_ID_SERCOM##n##_CORE, \
.pads = CONFIG_SPI_SAM0_SERCOM##n##_PADS \
@ -448,31 +448,32 @@ static const struct spi_driver_api spi_sam0_driver_api = { @@ -448,31 +448,32 @@ static const struct spi_driver_api spi_sam0_driver_api = {
SPI_CONTEXT_INIT_LOCK(spi_sam0_dev_data_##n, ctx), \
SPI_CONTEXT_INIT_SYNC(spi_sam0_dev_data_##n, ctx), \
}; \
DEVICE_AND_API_INIT(spi_sam0_##n, CONFIG_SPI_##n##_NAME, \
DEVICE_AND_API_INIT(spi_sam0_##n, \
CONFIG_SPI_SAM0_SERCOM##n##_LABEL, \
&spi_sam0_init, &spi_sam0_dev_data_##n, \
&spi_sam0_config_##n, POST_KERNEL, \
CONFIG_SPI_INIT_PRIORITY, &spi_sam0_driver_api)
#if CONFIG_SPI_0
#if CONFIG_SPI_SAM0_SERCOM0_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(0);
#endif
#if CONFIG_SPI_1
#if CONFIG_SPI_SAM0_SERCOM1_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(1);
#endif
#if CONFIG_SPI_2
#if CONFIG_SPI_SAM0_SERCOM2_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(2);
#endif
#if CONFIG_SPI_3
#if CONFIG_SPI_SAM0_SERCOM3_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(3);
#endif
#if CONFIG_SPI_4
#if CONFIG_SPI_SAM0_SERCOM4_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(4);
#endif
#if CONFIG_SPI_5
#if CONFIG_SPI_SAM0_SERCOM5_BASE_ADDRESS
SPI_SAM0_DEVICE_INIT(5);
#endif

66
dts/arm/atmel/samd21.dtsi

@ -61,96 +61,54 @@ @@ -61,96 +61,54 @@
label = "WATCHDOG_0";
};
sercom0: uart@42000800 {
compatible = "atmel,sam0-uart";
sercom0: sercom@42000800 {
compatible = "atmel,sam0-sercom";
reg = <0x42000800 0x40>;
interrupts = <9 0>;
status = "disabled";
label = "SERCOM0";
};
sercom1: uart@42000c00 {
compatible = "atmel,sam0-uart";
sercom1: sercom@42000c00 {
compatible = "atmel,sam0-sercom";
reg = <0x42000c00 0x40>;
interrupts = <10 0>;
status = "disabled";
label = "SERCOM1";
};
sercom2: uart@42001000 {
compatible = "atmel,sam0-uart";
sercom2: sercom@42001000 {
compatible = "atmel,sam0-sercom";
reg = <0x42001000 0x40>;
interrupts = <11 0>;
status = "disabled";
label = "SERCOM2";
};
sercom3: uart@42001400 {
compatible = "atmel,sam0-uart";
sercom3: sercom@42001400 {
compatible = "atmel,sam0-sercom";
reg = <0x42001400 0x40>;
interrupts = <12 0>;
status = "disabled";
label = "SERCOM3";
};
sercom4: uart@42001800 {
compatible = "atmel,sam0-uart";
sercom4: sercom@42001800 {
compatible = "atmel,sam0-sercom";
reg = <0x42001800 0x40>;
interrupts = <13 0>;
status = "disabled";
label = "SERCOM4";
};
sercom5: uart@42001C00 {
compatible = "atmel,sam0-uart";
sercom5: sercom@42001C00 {
compatible = "atmel,sam0-sercom";
reg = <0x42001C00 0x40>;
interrupts = <14 0>;
status = "disabled";
label = "SERCOM5";
};
spi0: spi@42000800 {
compatible = "atmel,sam0-spi";
reg = <0x42000800 0x40>;
status = "disabled";
label = "SPI0";
};
spi1: spi@42000c00 {
compatible = "atmel,sam0-spi";
reg = <0x42000c00 0x40>;
status = "disabled";
label = "SPI1";
};
spi2: spi@42001000 {
compatible = "atmel,sam0-spi";
reg = <0x42001000 0x40>;
status = "disabled";
label = "SPI2";
};
spi3: spi@42001400 {
compatible = "atmel,sam0-spi";
reg = <0x42001400 0x40>;
status = "disabled";
label = "SPI3";
};
spi4: spi@42001800 {
compatible = "atmel,sam0-spi";
reg = <0x42001800 0x40>;
status = "disabled";
label = "SPI4";
};
spi5: spi@42001C00 {
compatible = "atmel,sam0-spi";
reg = <0x42001C00 0x40>;
status = "disabled";
label = "SPI5";
};
porta: gpio@41004400 {
compatible = "atmel,sam0-gpio";
reg = <0x41004400 0x80>;

27
dts/bindings/arm/atmel,sam0-sercom.yaml

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
---
title: Atmel SERCOM binding
id: atmel,sam0-sercom
version: 0.1
description: >
Binding for the Atmel SAM0 multi-protocol (UART, SPI, I2C) SERCOM unit.
properties:
compatible:
type: string
category: required
description: compatible strings
constraint: "atmel,sam0-sercom"
reg:
type: array
description: mmio register space
generation: define
category: required
interrupts:
type: array
category: required
description: required interrupts
generation: define
...

29
dts/bindings/spi/atmel,sam0-spi.yaml

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
#
# Copyright (c) 2018, Google LLC.
#
# SPDX-License-Identifier: Apache-2.0
#
---
title: Atmel SAM0 SERCOM SPI driver
id: atmel,sam0-spi
version: 0.1
description: >
This binding gives a base representation of the Atmel SAM0 SERCOM SPI controller
inherits:
!include spi.yaml
properties:
compatible:
type: string
category: required
description: compatible strings
constraint: "atmel,sam0-spi"
reg:
type: array
description: mmio register space
generation: define
category: required
...
Loading…
Cancel
Save