MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ofw_count_of_clk

Function rt_ofw_count_of_clk

components/drivers/clk/clk.c:1385–1451  ·  view source on GitHub ↗

* @brief Count number of clocks in ofw * * @param clk_ofw_np point to ofw node * * @return rt_ssize_t number of clocks */

Source from the content-addressed store, hash-verified

1383 * @return rt_ssize_t number of clocks
1384 */
1385rt_ssize_t rt_ofw_count_of_clk(struct rt_ofw_node *clk_ofw_np)
1386{
1387 if (clk_ofw_np)
1388 {
1389 struct rt_clk_node *clk_np = rt_ofw_data(clk_ofw_np);
1390
1391 if (clk_np && clk_np->multi_clk)
1392 {
1393 return clk_np->multi_clk;
1394 }
1395 else
1396 {
1397 const fdt32_t *cell;
1398 rt_uint32_t count = 0;
1399 struct rt_ofw_prop *prop;
1400
1401 prop = rt_ofw_get_prop(clk_ofw_np, "clock-indices", RT_NULL);
1402
1403 if (prop)
1404 {
1405 rt_uint32_t max_idx = 0, idx;
1406
1407 for (cell = rt_ofw_prop_next_u32(prop, RT_NULL, &idx);
1408 cell;
1409 cell = rt_ofw_prop_next_u32(prop, cell, &idx))
1410 {
1411 if (idx > max_idx)
1412 {
1413 max_idx = idx;
1414 }
1415 }
1416
1417 count = max_idx + 1;
1418 }
1419 else
1420 {
1421 rt_ssize_t len;
1422
1423 if ((prop = rt_ofw_get_prop(clk_ofw_np, "clock-output-names", &len)))
1424 {
1425 char *value = prop->value;
1426
1427 for (int i = 0; i < len; ++i, ++value)
1428 {
1429 if (*value == '\0')
1430 {
1431 ++count;
1432 }
1433 }
1434 }
1435 else
1436 {
1437 count = 1;
1438 }
1439 }
1440
1441 if (clk_np)
1442 {

Callers 1

ofw_get_clk_no_lockFunction · 0.85

Calls 2

rt_ofw_get_propFunction · 0.85
rt_ofw_prop_next_u32Function · 0.85

Tested by

no test coverage detected