From bb8dddfa99544b2a61f0698490b6480a149152d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Fri, 24 May 2019 11:37:07 +0200 Subject: [PATCH] scripts: dts: Add extraction of clock frequency for fixed clock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds generation of `*_FIXED_CLOCK_FREQUENCY` macros for clock consuming nodes that are provided with a fixed rate clock. Signed-off-by: Andrzej Głąbek --- scripts/dts/extract/clocks.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/dts/extract/clocks.py b/scripts/dts/extract/clocks.py index ef551ca2b1..20498f7f75 100644 --- a/scripts/dts/extract/clocks.py +++ b/scripts/dts/extract/clocks.py @@ -150,6 +150,39 @@ class DTClocks(DTDirective): clock_label, prop_alias) + # If the provided clock has a fixed rate, extract its frequency + # as a macro generated for the clock consumer. + if clock_provider['props']['compatible'] == 'fixed-clock': + clock_prop_name = 'clock-frequency' + clock_prop_label = 'CLOCKS_CLOCK_FREQUENCY' + if clock_index == 0 and \ + len(clocks) == (len(clock_cells) + 1): + index = '' + else: + index = str(clock_index) + clock_frequency_label = \ + self.get_label_string([clock_consumer_label, + clock_prop_label, + index]) + + prop_def[clock_frequency_label] = \ + clock_provider['props'][clock_prop_name] + add_compat_alias( + node_path, + self.get_label_string([clock_prop_label, index]), + clock_frequency_label, + prop_alias) + if node_path in aliases: + add_prop_aliases( + node_path, + lambda alias: + self.get_label_string([ + alias, + clock_prop_label, + index]), + clock_frequency_label, + prop_alias) + insert_defs(node_path, prop_def, prop_alias) clock_cell_index = 0