soc: arm: replace DT_CPU_CLOCK_FREQUENCY with new dt macros

Replace DT_CPU_CLOCK_FREQUENCY with a PATH based reference to cpu@0
(DT_PATH(cpus, cpu_0)) and than getting the clock_frequency property:

DT_CPU_CLOCK_FREQUENCY -> DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)

This lets us remove DT_CPU_CLOCK_FREQUENCY from dts_fixup.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-04-22 07:06:40 -05:00 committed by Kumar Gala
commit 8b6acb5e91
13 changed files with 14 additions and 36 deletions

View file

@ -241,6 +241,7 @@ static int i2c_cc13xx_cc26xx_transfer(struct device *dev, struct i2c_msg *msgs,
return ret; return ret;
} }
#define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
static int i2c_cc13xx_cc26xx_configure(struct device *dev, u32_t dev_config) static int i2c_cc13xx_cc26xx_configure(struct device *dev, u32_t dev_config)
{ {
bool fast; bool fast;
@ -270,8 +271,7 @@ static int i2c_cc13xx_cc26xx_configure(struct device *dev, u32_t dev_config)
} }
/* Enables and configures I2C master */ /* Enables and configures I2C master */
I2CMasterInitExpClk(get_dev_config(dev)->base, I2CMasterInitExpClk(get_dev_config(dev)->base, CPU_FREQ, fast);
DT_CPU_CLOCK_FREQUENCY, fast);
#ifdef CONFIG_SYS_POWER_MANAGEMENT #ifdef CONFIG_SYS_POWER_MANAGEMENT
get_dev_data(dev)->dev_config = dev_config; get_dev_data(dev)->dev_config = dev_config;

View file

@ -37,6 +37,8 @@ struct spi_cc13xx_cc26xx_data {
#endif #endif
}; };
#define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
static inline struct spi_cc13xx_cc26xx_data *get_dev_data(struct device *dev) static inline struct spi_cc13xx_cc26xx_data *get_dev_data(struct device *dev)
{ {
return dev->driver_data; return dev->driver_data;
@ -91,7 +93,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev,
return -EINVAL; return -EINVAL;
} }
if (2 * config->frequency > DT_CPU_CLOCK_FREQUENCY) { if (2 * config->frequency > CPU_FREQ) {
LOG_ERR("Frequency greater than supported in master mode"); LOG_ERR("Frequency greater than supported in master mode");
return -EINVAL; return -EINVAL;
} }
@ -121,7 +123,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev,
SSIDisable(cfg->base); SSIDisable(cfg->base);
/* Configure SSI */ /* Configure SSI */
SSIConfigSetExpClk(cfg->base, DT_CPU_CLOCK_FREQUENCY, prot, SSIConfigSetExpClk(cfg->base, CPU_FREQ, prot,
SSI_MODE_MASTER, config->frequency, 8); SSI_MODE_MASTER, config->frequency, 8);
if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) { if (SPI_MODE_GET(config->operation) & SPI_MODE_LOOP) {

View file

@ -8,8 +8,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M7_0_CLOCK_FREQUENCY
#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS #define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL #define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0 #define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0

View file

@ -12,8 +12,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M7_0_CLOCK_FREQUENCY
#define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS #define DT_SPI_0_BASE_ADDRESS DT_ATMEL_SAM_SPI_40008000_BASE_ADDRESS
#define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL #define DT_SPI_0_NAME DT_ATMEL_SAM_SPI_40008000_LABEL
#define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0 #define DT_SPI_0_IRQ DT_ATMEL_SAM_SPI_40008000_IRQ_0

View file

@ -8,8 +8,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M0PLUS_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_LABEL

View file

@ -6,8 +6,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL

View file

@ -6,8 +6,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL

View file

@ -8,8 +8,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400C0000_LABEL

View file

@ -12,8 +12,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL

View file

@ -8,8 +8,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL

View file

@ -8,8 +8,6 @@
/* SoC level DTS fixup file */ /* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4F_0_CLOCK_FREQUENCY
#define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS #define DT_FLASH_DEV_BASE_ADDRESS DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_BASE_ADDRESS
#define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL #define DT_FLASH_DEV_NAME DT_SILABS_GECKO_FLASH_CONTROLLER_400E0000_LABEL

View file

@ -1,11 +0,0 @@
/*
* Copyright (c) 2019 Brett Witherspoon
*
* SPDX-License-Identifier: Apache-2.0
*/
/* SoC level DTS fixup file */
#define DT_CPU_CLOCK_FREQUENCY DT_ARM_CORTEX_M4_0_CLOCK_FREQUENCY
/* End of SoC Level DTS fixup file */

View file

@ -18,8 +18,8 @@
* this frequency should much the one set by the SWO viewer program. * this frequency should much the one set by the SWO viewer program.
* *
* The initialization code assumes that SWO core frequency is equal to HCLK * The initialization code assumes that SWO core frequency is equal to HCLK
* as defined by DT_CPU_CLOCK_FREQUENCY. This may require additional, * as defined by the clock-frequency property in the CPU node. This may require
* vendor specific configuration. * additional, vendor specific configuration.
*/ */
#include <logging/log_backend.h> #include <logging/log_backend.h>
@ -36,7 +36,12 @@
#if CONFIG_LOG_BACKEND_SWO_FREQ_HZ == 0 #if CONFIG_LOG_BACKEND_SWO_FREQ_HZ == 0
#define SWO_FREQ_DIV 1 #define SWO_FREQ_DIV 1
#else #else
#define SWO_FREQ (DT_CPU_CLOCK_FREQUENCY + (CONFIG_LOG_BACKEND_SWO_FREQ_HZ / 2)) #if DT_NODE_HAS_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
#define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
#else
#error "Missing DT 'clock-frequency' property on cpu@0 node"
#endif
#define SWO_FREQ (CPU_FREQ + (CONFIG_LOG_BACKEND_SWO_FREQ_HZ / 2))
#define SWO_FREQ_DIV (SWO_FREQ / CONFIG_LOG_BACKEND_SWO_FREQ_HZ) #define SWO_FREQ_DIV (SWO_FREQ / CONFIG_LOG_BACKEND_SWO_FREQ_HZ)
#if SWO_FREQ_DIV > 0xFFFF #if SWO_FREQ_DIV > 0xFFFF
#error CONFIG_LOG_BACKEND_SWO_FREQ_HZ is too low. SWO clock divider is 16-bit. \ #error CONFIG_LOG_BACKEND_SWO_FREQ_HZ is too low. SWO clock divider is 16-bit. \