soc: esp32xx: refactor clock and RTC subsystems

The RTC subsystem in espressif's SOCs, among other tasks
is responsible for clock selection for CPU and for low
power domain clocks such as RTC_SLOW and RTC_FAST.

This commit allows for proper clock source and rate
selection for CPU, using the espressif,riscv and
espressif,xtensa-lx6/7 bindings.

It also enables clock selection for RTC_FAST and RTC_SLOW,
that impacts some peripherals, such as rtc_timer.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
This commit is contained in:
Lucas Tamborrino 2024-05-02 16:39:17 -03:00 committed by Carles Cufí
commit e282b0ea84
79 changed files with 629 additions and 996 deletions

View file

@ -11,14 +11,32 @@ properties:
reg:
required: true
xtal-freq:
fast-clk-src:
type: int
required: true
description: Value of the external XTAL connected to ESP32.
description: |
RTC fast clock source.
- 0: ESP32_RTC_FAST_CLK_SRC_XTAL_D2 - Main XTAL divided by 2 (C3/S3)
ESP32_RTC_FAST_CLK_SRC_XTAL_D4 Main XTAL divided by 4 (ESP32/S2)
- 1: ESP32_RTC_FAST_CLK_SRC_RC_FAST - 8 MHz
enum:
- 0
- 1
xtal-div:
slow-clk-src:
type: int
description: Divisor value for XTAL Clock, CPU_CLK = XTAL_FREQ / xtal-div
required: true
description: |
RTC slow clock source. Default to
- 0: ESP32_RTC_SLOW_CLK_SRC_RC_SLOW - 136 KHz (C3/S3) - 90 kHz (S2) - 150 kHz (ESP32)
- 1: ESP32_RTC_SLOW_CLK_SRC_XTAL32K - 32,768U KHz
- 2: ESP32_RTC_SLOW_CLK_SRC_RC_FAST_D256 - 17,5 MHz
- 9: ESP32_RTC_SLOW_CLK_32K_EXT_OSC - External 32k oscillator connected to 32K_XP pin
enum:
- 0
- 1
- 2
- 9
"#clock-cells":
const: 1

View file

@ -15,11 +15,4 @@ description: |
include: base.yaml
properties:
slow-clk-freq:
description: |
The slow clock input frequency for the RTC Timer.
type: int
required: true
compatible: "espressif,esp32-rtc-timer"

View file

@ -9,5 +9,24 @@ include: riscv,cpus.yaml
properties:
clock-source:
required: true
type: int
description: cpu clock source
description: |
Defines the CPU clock source, each corresponding to different frequencies:
- 0: ESP32_CPU_CLK_SRC_XTAL - Uses the external crystal clock typically at 40 MHz.
- 1: ESP32_CPU_CLK_SRC_PLL - Utilizes an internal PLL which operates at either
320 MHz or 480 MHz.
- 2: ESP32_CPU_CLK_SRC_RC_FAST - Employs an internal fast RC oscillator with
frequency of 17.5 MHz.
enum:
- 0
- 1
- 2
xtal-freq:
required: true
type: int
description: Value of the external XTAL connected to ESP32. This is typically 40 MHz.
enum:
- 40000000
- 32000000

View file

@ -0,0 +1,34 @@
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0
description: Espressif Xtensa CPU
compatible: "espressif,xtensa-lx6"
include: cdns,tensilica-xtensa-lx6.yaml
properties:
clock-source:
required: true
type: int
description: |
Defines the CPU clock source, each corresponding to different frequencies:
- 0: ESP32_CPU_CLK_SRC_XTAL - Uses the external crystal clock typically at 40 MHz.
- 1: ESP32_CPU_CLK_SRC_PLL - Utilizes an internal PLL which operates at either
320 MHz or 480 MHz.
- 2: ESP32_CPU_CLK_SRC_RC_FAST - Employs an internal fast RC oscillator with
frequency of 17.5 MHz. 8 MHz for ESP32S2.
- 3: APLL_CLK - 16 Mhz ~ 128 MHz
enum:
- 0
- 1
- 2
- 3
xtal-freq:
type: int
required: true
description: Value of the external XTAL connected to ESP32.
enum:
- 40000000
- 32000000

View file

@ -0,0 +1,34 @@
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0
description: Espressif Xtensa CPU
compatible: "espressif,xtensa-lx7"
include: cdns,tensilica-xtensa-lx7.yaml
properties:
clock-source:
type: int
required: true
description: |
Defines the CPU clock source, each corresponding to different frequencies:
- 0: ESP32_CPU_CLK_SRC_XTAL - Uses the external crystal clock typically at 40 MHz.
- 1: ESP32_CPU_CLK_SRC_PLL - Utilizes an internal PLL which operates at either
320 MHz or 480 MHz.
- 2: ESP32_CPU_CLK_SRC_RC_FAST - Employs an internal fast RC oscillator with
frequency of 17.5 MHz. 8 MHz for ESP32S2.
- 3: APLL_CLK - 16 Mhz ~ 128 MHz (ESP32S2 Only)
enum:
- 0
- 1
- 2
- 3
xtal-freq:
type: int
required: true
description: Value of the external XTAL connected to ESP32.
enum:
- 40000000
- 32000000