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 <nandojve@gmail.com>
This commit is contained in:
parent
91e219c644
commit
4f59d50441
|
@ -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 <zephyr/drivers/spi.h>
|
||||
#include <zephyr/drivers/dma.h>
|
||||
#include <zephyr/drivers/pinctrl.h>
|
||||
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
|
||||
#include <soc.h>
|
||||
|
||||
#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)), ()) \
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
#size-cells = <0>;
|
||||
reg = <0x40088000 0x4000>;
|
||||
interrupts = <19 0>;
|
||||
peripheral-id = <19>;
|
||||
clocks = <&pmc PMC_TYPE_PERIPHERAL 19>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
|
|
@ -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>;
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
#size-cells = <0>;
|
||||
reg = <0x40008000 0x4000>;
|
||||
interrupts = <21 0>;
|
||||
peripheral-id = <21>;
|
||||
clocks = <&pmc PMC_TYPE_PERIPHERAL 21>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
|
|
|
@ -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";
|
||||
};
|
||||
|
||||
|
|
|
@ -16,9 +16,7 @@ properties:
|
|||
interrupts:
|
||||
required: true
|
||||
|
||||
peripheral-id:
|
||||
type: int
|
||||
description: peripheral ID
|
||||
clocks:
|
||||
required: true
|
||||
|
||||
loopback:
|
||||
|
|
Loading…
Reference in a new issue