From 4f59d504411c9a89cde29bc1321eceac0f25ff3e Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Tue, 7 Mar 2023 19:43:12 +0100 Subject: [PATCH] drivers: spi: sam: Update to use clock control This update Atmel SAM spi driver to use clock control driver. Signed-off-by: Gerson Fernando Budke --- drivers/spi/spi_sam.c | 10 +++++++--- dts/arm/atmel/sam4e.dtsi | 2 +- dts/arm/atmel/sam4l.dtsi | 2 +- dts/arm/atmel/sam4s.dtsi | 2 +- dts/arm/atmel/same70.dtsi | 4 ++-- dts/bindings/spi/atmel,sam-spi.yaml | 4 +--- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi_sam.c b/drivers/spi/spi_sam.c index 4e5bc7140d..23ad86910b 100644 --- a/drivers/spi/spi_sam.c +++ b/drivers/spi/spi_sam.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2017 Google LLC. * Copyright (c) 2018 qianfan Zhao. + * Copyright (c) 2023 Gerson Fernando Budke. * * SPDX-License-Identifier: Apache-2.0 */ @@ -17,6 +18,7 @@ LOG_MODULE_REGISTER(spi_sam); #include #include #include +#include #include #define SAM_SPI_CHIP_SELECT_COUNT 4 @@ -27,7 +29,7 @@ LOG_MODULE_REGISTER(spi_sam); /* Device constant configuration parameters */ struct spi_sam_config { Spi *regs; - uint32_t periph_id; + const struct atmel_sam_pmc_config clock_cfg; const struct pinctrl_dev_config *pcfg; bool loopback; @@ -680,7 +682,9 @@ static int spi_sam_init(const struct device *dev) const struct spi_sam_config *cfg = dev->config; struct spi_sam_data *data = dev->data; - soc_pmc_peripheral_enable(cfg->periph_id); + /* Enable SPI clock in PMC */ + (void)clock_control_on(SAM_DT_PMC_CONTROLLER, + (clock_control_subsys_t *)&cfg->clock_cfg); err = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); if (err < 0) { @@ -729,7 +733,7 @@ static const struct spi_driver_api spi_sam_driver_api = { #define SPI_SAM_DEFINE_CONFIG(n) \ static const struct spi_sam_config spi_sam_config_##n = { \ .regs = (Spi *)DT_INST_REG_ADDR(n), \ - .periph_id = DT_INST_PROP(n, peripheral_id), \ + .clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(n), \ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ .loopback = DT_INST_PROP(n, loopback), \ COND_CODE_1(SPI_SAM_USE_DMA(n), (SPI_DMA_INIT(n)), ()) \ diff --git a/dts/arm/atmel/sam4e.dtsi b/dts/arm/atmel/sam4e.dtsi index 0d7db87560..1febdd9fba 100644 --- a/dts/arm/atmel/sam4e.dtsi +++ b/dts/arm/atmel/sam4e.dtsi @@ -102,7 +102,7 @@ #size-cells = <0>; reg = <0x40088000 0x4000>; interrupts = <19 0>; - peripheral-id = <19>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 19>; status = "disabled"; }; diff --git a/dts/arm/atmel/sam4l.dtsi b/dts/arm/atmel/sam4l.dtsi index 213ec57a87..cca4ddd41d 100644 --- a/dts/arm/atmel/sam4l.dtsi +++ b/dts/arm/atmel/sam4l.dtsi @@ -124,7 +124,7 @@ compatible = "atmel,sam-spi"; reg = <0x40008000 0x4000>; interrupts = <54 0>; - peripheral-id = <1>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 1>; status = "disabled"; #address-cells = <1>; #size-cells = <0>; diff --git a/dts/arm/atmel/sam4s.dtsi b/dts/arm/atmel/sam4s.dtsi index e043c12ac8..8dfca46821 100644 --- a/dts/arm/atmel/sam4s.dtsi +++ b/dts/arm/atmel/sam4s.dtsi @@ -104,7 +104,7 @@ #size-cells = <0>; reg = <0x40008000 0x4000>; interrupts = <21 0>; - peripheral-id = <21>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 21>; status = "disabled"; }; diff --git a/dts/arm/atmel/same70.dtsi b/dts/arm/atmel/same70.dtsi index bfb282f70e..a4605d541c 100644 --- a/dts/arm/atmel/same70.dtsi +++ b/dts/arm/atmel/same70.dtsi @@ -121,7 +121,7 @@ #size-cells = <0>; reg = <0x40008000 0x4000>; interrupts = <21 0>; - peripheral-id = <21>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 21>; status = "disabled"; }; @@ -131,7 +131,7 @@ #size-cells = <0>; reg = <0x40058000 0x4000>; interrupts = <42 0>; - peripheral-id = <42>; + clocks = <&pmc PMC_TYPE_PERIPHERAL 42>; status = "disabled"; }; diff --git a/dts/bindings/spi/atmel,sam-spi.yaml b/dts/bindings/spi/atmel,sam-spi.yaml index fc5e3bc7e3..d97b59fa09 100644 --- a/dts/bindings/spi/atmel,sam-spi.yaml +++ b/dts/bindings/spi/atmel,sam-spi.yaml @@ -16,9 +16,7 @@ properties: interrupts: required: true - peripheral-id: - type: int - description: peripheral ID + clocks: required: true loopback: