[PATCH 5/9] bsp/tms570: Add clock BSP options

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 23 19:15:51 UTC 2024


Update #4982.
---
 bsps/arm/tms570/clock/clock.c               |  4 ++--
 bsps/arm/tms570/console/tms570-sci.c        |  2 +-
 bsps/arm/tms570/cpucounter/cpucounterread.c |  2 +-
 bsps/arm/tms570/include/bsp.h               |  6 ------
 spec/build/bsps/arm/tms570/grp.yml          | 12 ++++++++++++
 spec/build/bsps/arm/tms570/optgclk.yml      | 21 +++++++++++++++++++++
 spec/build/bsps/arm/tms570/opthclk.yml      | 21 +++++++++++++++++++++
 spec/build/bsps/arm/tms570/optrticlk.yml    | 21 +++++++++++++++++++++
 spec/build/bsps/arm/tms570/optvclk.yml      | 21 +++++++++++++++++++++
 spec/build/bsps/arm/tms570/optvclk2.yml     | 21 +++++++++++++++++++++
 spec/build/bsps/arm/tms570/optvclk3.yml     | 21 +++++++++++++++++++++
 11 files changed, 142 insertions(+), 10 deletions(-)
 create mode 100644 spec/build/bsps/arm/tms570/optgclk.yml
 create mode 100644 spec/build/bsps/arm/tms570/opthclk.yml
 create mode 100644 spec/build/bsps/arm/tms570/optrticlk.yml
 create mode 100644 spec/build/bsps/arm/tms570/optvclk.yml
 create mode 100644 spec/build/bsps/arm/tms570/optvclk2.yml
 create mode 100644 spec/build/bsps/arm/tms570/optvclk3.yml

diff --git a/bsps/arm/tms570/clock/clock.c b/bsps/arm/tms570/clock/clock.c
index 2e71440857..a3ea08c967 100644
--- a/bsps/arm/tms570/clock/clock.c
+++ b/bsps/arm/tms570/clock/clock.c
@@ -83,10 +83,10 @@ static void tms570_clock_driver_support_initialize_hardware( void )
   microsec_per_tick = rtems_configuration_get_microseconds_per_tick();
   tc_frequency = TMS570_PREFERRED_TC_FREQUENCY;
 
-  tc_prescaler = (BSP_PLL_OUT_CLOCK + tc_frequency) / (tc_frequency * 2);
+  tc_prescaler = (TMS570_RTICLK_HZ + tc_frequency) / (tc_frequency * 2);
 
   /* Recompute actual most close frequency which can be realized */
-  tc_frequency = (BSP_PLL_OUT_CLOCK + tc_prescaler) / (tc_prescaler * 2);
+  tc_frequency = (TMS570_RTICLK_HZ + tc_prescaler) / (tc_prescaler * 2);
 
   /*
    * Recompute tick period to adjust for configurable or exact
diff --git a/bsps/arm/tms570/console/tms570-sci.c b/bsps/arm/tms570/console/tms570-sci.c
index 63f8e7c8ee..6cb61f2b5d 100644
--- a/bsps/arm/tms570/console/tms570-sci.c
+++ b/bsps/arm/tms570/console/tms570-sci.c
@@ -297,7 +297,7 @@ bool tms570_sci_set_attributes(
 
   /* Apply baudrate to the hardware */
   baudrate *= 2 * 16;
-  bauddiv = (BSP_PLL_OUT_CLOCK + baudrate / 2) / baudrate;
+  bauddiv = (TMS570_VCLK_HZ + baudrate / 2) / baudrate;
   ctx->regs->BRS = bauddiv? bauddiv - 1: 0;
 
   ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST | TMS570_SCI_GCR1_TXENA |
diff --git a/bsps/arm/tms570/cpucounter/cpucounterread.c b/bsps/arm/tms570/cpucounter/cpucounterread.c
index 009a37bec3..8cda09f0c6 100644
--- a/bsps/arm/tms570/cpucounter/cpucounterread.c
+++ b/bsps/arm/tms570/cpucounter/cpucounterread.c
@@ -68,7 +68,7 @@ static void tms570_cpu_counter_initialize(void)
 
 uint32_t _CPU_Counter_frequency(void)
 {
-  return 2 * BSP_PLL_OUT_CLOCK;
+  return TMS570_GCLK_HZ;
 }
 
 CPU_Counter_ticks _CPU_Counter_read(void)
diff --git a/bsps/arm/tms570/include/bsp.h b/bsps/arm/tms570/include/bsp.h
index 287750295f..1f84486ad4 100644
--- a/bsps/arm/tms570/include/bsp.h
+++ b/bsps/arm/tms570/include/bsp.h
@@ -61,12 +61,6 @@
 #include <rtems.h>
 #include <bsp/default-initial-extension.h>
 
-#if TMS570_VARIANT == 4357
-#define BSP_PLL_OUT_CLOCK 150000000
-#else
-#define BSP_PLL_OUT_CLOCK 160000000
-#endif
-
 RTEMS_NO_RETURN void bsp_restart(const void *addr);
 
 #endif /* ASM */
diff --git a/spec/build/bsps/arm/tms570/grp.yml b/spec/build/bsps/arm/tms570/grp.yml
index 5a3d4784be..c6d9f02d14 100644
--- a/spec/build/bsps/arm/tms570/grp.yml
+++ b/spec/build/bsps/arm/tms570/grp.yml
@@ -32,6 +32,18 @@ links:
   uid: optmintskstksz
 - role: build-dependency
   uid: optoscmain
+- role: build-dependency
+  uid: optgclk
+- role: build-dependency
+  uid: opthclk
+- role: build-dependency
+  uid: optvclk
+- role: build-dependency
+  uid: optvclk2
+- role: build-dependency
+  uid: optvclk3
+- role: build-dependency
+  uid: optrticlk
 - role: build-dependency
   uid: optreginit
 - role: build-dependency
diff --git a/spec/build/bsps/arm/tms570/optgclk.yml b/spec/build/bsps/arm/tms570/optgclk.yml
new file mode 100644
index 0000000000..f7ec86a250
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/optgclk.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 300000000
+- enabled-by: true
+  value: 160000000
+description: |
+  The option value shall be the GCLK frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_GCLK_HZ
+type: build
diff --git a/spec/build/bsps/arm/tms570/opthclk.yml b/spec/build/bsps/arm/tms570/opthclk.yml
new file mode 100644
index 0000000000..652c151eec
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/opthclk.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 150000000
+- enabled-by: true
+  value: 160000000
+description: |
+  The option value shall be the HCLK frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_HCLK_HZ
+type: build
diff --git a/spec/build/bsps/arm/tms570/optrticlk.yml b/spec/build/bsps/arm/tms570/optrticlk.yml
new file mode 100644
index 0000000000..24782786c2
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/optrticlk.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 75000000
+- enabled-by: true
+  value: 80000000
+description: |
+  The option value shall be the RTICLK frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_RTICLK_HZ
+type: build
diff --git a/spec/build/bsps/arm/tms570/optvclk.yml b/spec/build/bsps/arm/tms570/optvclk.yml
new file mode 100644
index 0000000000..fd30cf751a
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/optvclk.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 75000000
+- enabled-by: true
+  value: 80000000
+description: |
+  The option value shall be the VCLK frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_VCLK_HZ
+type: build
diff --git a/spec/build/bsps/arm/tms570/optvclk2.yml b/spec/build/bsps/arm/tms570/optvclk2.yml
new file mode 100644
index 0000000000..95a340571f
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/optvclk2.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 75000000
+- enabled-by: true
+  value: 80000000
+description: |
+  The option value shall be the VCLK2 frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_VCLK2_HZ
+type: build
diff --git a/spec/build/bsps/arm/tms570/optvclk3.yml b/spec/build/bsps/arm/tms570/optvclk3.yml
new file mode 100644
index 0000000000..ee1252885d
--- /dev/null
+++ b/spec/build/bsps/arm/tms570/optvclk3.yml
@@ -0,0 +1,21 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+actions:
+- get-integer: null
+- define: null
+build-type: option
+copyrights:
+- Copyright (C) 2024 embedded brains GmbH & Co. KG
+default:
+- enabled-by:
+  - arm/tms570lc4357_hdk
+  - arm/tms570lc4357_hdk_sdram
+  value: 75000000
+- enabled-by: true
+  value: 80000000
+description: |
+  The option value shall be the VCLK3 frequency in Hz.
+enabled-by: true
+format: '{}'
+links: []
+name: TMS570_VCLK3_HZ
+type: build
-- 
2.35.3



More information about the devel mailing list