Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) # Copyright (c) NXP 2019
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) import gdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) import sys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) from linux import utils, lists, constants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) clk_core_type = utils.CachedType("struct clk_core")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) def clk_core_for_each_child(hlist_head):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)     return lists.hlist_for_each_entry(hlist_head,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)             clk_core_type.get_type().pointer(), "child_node")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) class LxClkSummary(gdb.Command):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)     """Print clk tree summary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) Output is a subset of /sys/kernel/debug/clk/clk_summary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) No calls are made during printing, instead a (c) if printed after values which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) are cached and potentially out of date"""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)     def __init__(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)         super(LxClkSummary, self).__init__("lx-clk-summary", gdb.COMMAND_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)     def show_subtree(self, clk, level):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)         gdb.write("%*s%-*s %7d %8d %8d %11lu%s\n" % (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)                 level * 3 + 1, "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)                 30 - level * 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)                 clk['name'].string(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)                 clk['enable_count'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)                 clk['prepare_count'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)                 clk['protect_count'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)                 clk['rate'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)                 '(c)' if clk['flags'] & constants.LX_CLK_GET_RATE_NOCACHE else '   '))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)         for child in clk_core_for_each_child(clk['children']):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)             self.show_subtree(child, level + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)     def invoke(self, arg, from_tty):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)         gdb.write("                                 enable  prepare  protect               \n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)         gdb.write("   clock                          count    count    count        rate   \n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)         gdb.write("------------------------------------------------------------------------\n")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)         for clk in clk_core_for_each_child(gdb.parse_and_eval("clk_root_list")):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)             self.show_subtree(clk, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)         for clk in clk_core_for_each_child(gdb.parse_and_eval("clk_orphan_list")):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)             self.show_subtree(clk, 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) LxClkSummary()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) class LxClkCoreLookup(gdb.Function):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)     """Find struct clk_core by name"""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)     def __init__(self):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)         super(LxClkCoreLookup, self).__init__("lx_clk_core_lookup")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)     def lookup_hlist(self, hlist_head, name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)         for child in clk_core_for_each_child(hlist_head):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)             if child['name'].string() == name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)                 return child
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)             result = self.lookup_hlist(child['children'], name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)             if result:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)                 return result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)     def invoke(self, name):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)         name = name.string()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)         return (self.lookup_hlist(gdb.parse_and_eval("clk_root_list"), name) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)                 self.lookup_hlist(gdb.parse_and_eval("clk_orphan_list"), name))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) LxClkCoreLookup()