pw_clock_tree: Generic clock tree management

This change introduces a module to implement clock
management of individual clock tree elements, such as clocks,
clock selectors or clock dividers.

The `ClockManager` controls the state of individual clock
tree elements and ensures that access to them is serialized.

Four main abstract class templates implement the different clock
tree elements to represent the clock tree of an embedded system.

The `Element` abstract class implements the reference counting
to ensure that a clock tree element can only get
enabled when all its dependent clock tree elements have been enabled.
Similarly, the different clock tree elements ensure that a clock
tree element gets disabled before the clock tree element it
was depending on can get disabled.

If enabling or disabling a clock tree element might require the
operation to block, the `ElementBlocking` class needs to be
used. Otherwise, the `ElementNonBlockingCannotFail` or
`ElementNonBlockingMightFail` class should be used depening on
whether enabling and disabling will always succeed, or whether it might
fail.

Change-Id: Ic4205ba8eb552b2558983c2b19b1b9e47a5d9687
Bug: 331672574
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/204310
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Christoph Klee <chklee@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
Reviewed-by: Austin Foxley <afoxley@google.com>
14 files changed
tree: 28fc77b13100215f2983b170ec8bb24408743c07
  1. .allstar/
  2. .github/
  3. .vscode/
  4. build_overrides/
  5. docker/
  6. docs/
  7. kudzu/
  8. pw_alignment/
  9. pw_allocator/
  10. pw_analog/
  11. pw_android_toolchain/
  12. pw_arduino_build/
  13. pw_assert/
  14. pw_assert_basic/
  15. pw_assert_log/
  16. pw_assert_tokenized/
  17. pw_assert_zephyr/
  18. pw_async/
  19. pw_async2/
  20. pw_async2_basic/
  21. pw_async2_epoll/
  22. pw_async_basic/
  23. pw_base64/
  24. pw_bloat/
  25. pw_blob_store/
  26. pw_bluetooth/
  27. pw_bluetooth_hci/
  28. pw_bluetooth_profiles/
  29. pw_bluetooth_proxy/
  30. pw_bluetooth_sapphire/
  31. pw_boot/
  32. pw_boot_cortex_m/
  33. pw_build/
  34. pw_build_android/
  35. pw_build_info/
  36. pw_build_mcuxpresso/
  37. pw_bytes/
  38. pw_channel/
  39. pw_checksum/
  40. pw_chre/
  41. pw_chrono/
  42. pw_chrono_embos/
  43. pw_chrono_freertos/
  44. pw_chrono_rp2040/
  45. pw_chrono_stl/
  46. pw_chrono_threadx/
  47. pw_chrono_zephyr/
  48. pw_cli/
  49. pw_clock_tree/
  50. pw_compilation_testing/
  51. pw_config_loader/
  52. pw_console/
  53. pw_containers/
  54. pw_cpu_exception/
  55. pw_cpu_exception_cortex_m/
  56. pw_cpu_exception_risc_v/
  57. pw_crypto/
  58. pw_digital_io/
  59. pw_digital_io_linux/
  60. pw_digital_io_mcuxpresso/
  61. pw_digital_io_rp2040/
  62. pw_dma_mcuxpresso/
  63. pw_docgen/
  64. pw_doctor/
  65. pw_emu/
  66. pw_env_setup/
  67. pw_env_setup_zephyr/
  68. pw_file/
  69. pw_format/
  70. pw_function/
  71. pw_fuzzer/
  72. pw_grpc/
  73. pw_hdlc/
  74. pw_hex_dump/
  75. pw_i2c/
  76. pw_i2c_linux/
  77. pw_i2c_mcuxpresso/
  78. pw_i2c_rp2040/
  79. pw_ide/
  80. pw_interrupt/
  81. pw_interrupt_cortex_m/
  82. pw_interrupt_xtensa/
  83. pw_interrupt_zephyr/
  84. pw_intrusive_ptr/
  85. pw_json/
  86. pw_kvs/
  87. pw_libc/
  88. pw_libcxx/
  89. pw_log/
  90. pw_log_android/
  91. pw_log_basic/
  92. pw_log_null/
  93. pw_log_rpc/
  94. pw_log_string/
  95. pw_log_tokenized/
  96. pw_log_zephyr/
  97. pw_malloc/
  98. pw_malloc_freelist/
  99. pw_malloc_freertos/
  100. pw_metric/
  101. pw_minimal_cpp_stdlib/
  102. pw_module/
  103. pw_multibuf/
  104. pw_multisink/
  105. pw_package/
  106. pw_perf_test/
  107. pw_persistent_ram/
  108. pw_polyfill/
  109. pw_preprocessor/
  110. pw_presubmit/
  111. pw_protobuf/
  112. pw_protobuf_compiler/
  113. pw_random/
  114. pw_result/
  115. pw_ring_buffer/
  116. pw_router/
  117. pw_rpc/
  118. pw_rpc_transport/
  119. pw_rust/
  120. pw_sensor/
  121. pw_snapshot/
  122. pw_software_update/
  123. pw_span/
  124. pw_spi/
  125. pw_spi_linux/
  126. pw_spi_mcuxpresso/
  127. pw_spi_rp2040/
  128. pw_status/
  129. pw_stm32cube_build/
  130. pw_stream/
  131. pw_stream_shmem_mcuxpresso/
  132. pw_stream_uart_linux/
  133. pw_stream_uart_mcuxpresso/
  134. pw_string/
  135. pw_symbolizer/
  136. pw_sync/
  137. pw_sync_baremetal/
  138. pw_sync_embos/
  139. pw_sync_freertos/
  140. pw_sync_stl/
  141. pw_sync_threadx/
  142. pw_sync_zephyr/
  143. pw_sys_io/
  144. pw_sys_io_ambiq_sdk/
  145. pw_sys_io_arduino/
  146. pw_sys_io_baremetal_lm3s6965evb/
  147. pw_sys_io_baremetal_stm32f429/
  148. pw_sys_io_emcraft_sf2/
  149. pw_sys_io_mcuxpresso/
  150. pw_sys_io_rp2040/
  151. pw_sys_io_stdio/
  152. pw_sys_io_stm32cube/
  153. pw_sys_io_zephyr/
  154. pw_system/
  155. pw_target_runner/
  156. pw_thread/
  157. pw_thread_embos/
  158. pw_thread_freertos/
  159. pw_thread_stl/
  160. pw_thread_threadx/
  161. pw_thread_zephyr/
  162. pw_tls_client/
  163. pw_tls_client_boringssl/
  164. pw_tls_client_mbedtls/
  165. pw_tokenizer/
  166. pw_toolchain/
  167. pw_toolchain_bazel/
  168. pw_trace/
  169. pw_trace_tokenized/
  170. pw_transfer/
  171. pw_uart/
  172. pw_unit_test/
  173. pw_unit_test_zephyr/
  174. pw_varint/
  175. pw_watch/
  176. pw_web/
  177. pw_work_queue/
  178. seed/
  179. targets/
  180. third_party/
  181. ts/
  182. zephyr/
  183. .bazelignore
  184. .bazelrc
  185. .bazelversion
  186. .black.toml
  187. .clang-format
  188. .clang-tidy
  189. .eslintrc.cjs
  190. .git-blame-ignore-revs
  191. .gitattributes
  192. .gitignore
  193. .gn
  194. .mypy.ini
  195. .prettierignore
  196. .prettierrc.cjs
  197. .pw_ide.yaml
  198. .pylintrc
  199. activate.bat
  200. Android.bp
  201. AUTHORS
  202. bootstrap.bat
  203. bootstrap.sh
  204. BUILD.bazel
  205. BUILD.gn
  206. BUILDCONFIG.gn
  207. CMakeLists.txt
  208. jest.config.ts
  209. Kconfig.zephyr
  210. LICENSE
  211. modules.gni
  212. OWNERS
  213. package-lock.json
  214. package.json
  215. pigweed.json
  216. PIGWEED_MODULES
  217. README.md
  218. rollup.config.js
  219. tsconfig.json
  220. WORKSPACE
  221. WORKSPACE_OWNERS
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links