1# Copyright (c) 2019 ML!PA Consulting GmbH
2# Copyright (c) 2024-2025 Gerson Fernando Budke <nandojve@gmail.com>
3# SPDX-License-Identifier: Apache-2.0
4
5if SOC_SERIES_SAMD51 || SOC_SERIES_SAME51 || SOC_SERIES_SAME53 || SOC_SERIES_SAME54
6
7config SOC_ATMEL_SAMD5X_XOSC32K
8	bool "The external 32 kHz crystal oscillator"
9	help
10	  Say y to enable the external 32 kHZ crystal oscillator at
11	  startup.  This can then be selected as the main clock source
12	  for the SOC.
13
14config SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
15	depends on SOC_ATMEL_SAMD5X_XOSC32K
16	hex "Startup time external 32 kHz crystal oscillator"
17	range 0x0 0x6
18	default 0x1
19	help
20	  Selects the startup time for the external 32 kHz crystal oscillator.
21
22config SOC_ATMEL_SAMD5X_XOSC32K_CRYSTAL
23	bool "External 32.768 kHz clock is a crystal oscillator"
24	depends on SOC_ATMEL_SAMD5X_XOSC32K
25	default y
26	help
27	  Enable the crystal oscillator (if disabled, expect a clock
28	  signal on XIN32).
29
30config SOC_ATMEL_SAMD5X_XOSC32K_GAIN_HS
31	bool "XOSC32 High Speed gain"
32	depends on SOC_ATMEL_SAMD5X_XOSC32K
33	help
34	  When this option is selected the gain is set High Speed
35	  instead standard.
36
37DT_ATMEL_RTC := $(dt_nodelabel_path,rtc)
38DT_ATMEL_RTC_COUNTER_CLOCK_MODE := $(dt_node_str_prop_equals,$(DT_ATMEL_RTC),counter-mode,clock)
39
40config SOC_ATMEL_SAMD5X_OSC32K_PRESCALER
41	int "XOSC32 Generic Clock Prescaler"
42	range 1 512
43	default 32 if "$(DT_ATMEL_RTC_COUNTER_CLOCK_MODE)"
44	default 1
45	help
46	  Configure the prescaler for the generic clock output connected on the
47	  xosc32 or osculp32k. When using RTC in calendar mode the GCLK should
48	  be divided by 32 to RTC receive the 1024 Hz reference clock.
49
50choice
51	prompt "Main clock source"
52	default SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN
53	help
54	  Selects the clock that the main clocks, such as the CPU
55	  clock and AHB clock, will be derived from.
56
57config SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN
58	bool "DEFAULT"
59	help
60	  This choice will leave all clocks to their current state.
61	  This can be the default reset state or a state set by a bootloader.
62
63config SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN
64	depends on SOC_ATMEL_SAMD5X_XOSC32K
65	bool "XOSC32K"
66
67config SOC_ATMEL_SAMD5X_OSCULP32K_AS_MAIN
68	bool "OSCULP32K"
69
70endchoice
71
72endif
73