Skip to content

Commit 87a7b8d

Browse files
committed
[dm][core] add new API for DM
1. rt_dm_dev_is_big_endian 2. rt_dm_dev_get_prop_fuzzy_name Signed-off-by: GuEe-GUI <[email protected]>
1 parent bc56649 commit 87a7b8d

File tree

2 files changed

+35
-0
lines changed
  • components/drivers

2 files changed

+35
-0
lines changed

components/drivers/core/dm.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,23 @@ const char *rt_dm_dev_get_name(rt_device_t dev)
306306
#define ofw_api_call_ptr(name, ...) RT_NULL
307307
#endif
308308

309+
rt_bool_t rt_dm_dev_is_big_endian(rt_device_t dev)
310+
{
311+
if (rt_dm_dev_prop_read_bool(dev, "big-endian"))
312+
{
313+
return RT_TRUE;
314+
}
315+
316+
#ifdef ARCH_CPU_BIG_ENDIAN
317+
if (rt_dm_dev_prop_read_bool(dev, "native-endian"))
318+
{
319+
return RT_TRUE;
320+
}
321+
#endif /* ARCH_CPU_BIG_ENDIAN */
322+
323+
return RT_FALSE;
324+
}
325+
309326
int rt_dm_dev_get_address_count(rt_device_t dev)
310327
{
311328
RT_ASSERT(dev != RT_NULL);
@@ -480,6 +497,20 @@ void rt_dm_dev_unbind_fwdata(rt_device_t dev, void *fw_np)
480497
#endif
481498
}
482499

500+
const char *rt_dm_dev_get_prop_fuzzy_name(rt_device_t dev, const char *name)
501+
{
502+
RT_ASSERT(dev != RT_NULL);
503+
504+
#ifdef RT_USING_OFW
505+
if (dev->ofw_node)
506+
{
507+
return ofw_api_call_ptr(get_prop_fuzzy_name, dev->ofw_node, name);
508+
}
509+
#endif
510+
511+
return RT_NULL;
512+
}
513+
483514
int rt_dm_dev_prop_read_u8_array_index(rt_device_t dev, const char *propname,
484515
int index, int nr, rt_uint8_t *out_values)
485516
{

components/drivers/include/drivers/core/dm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ int rt_dm_dev_get_name_id(rt_device_t dev);
7070
int rt_dm_dev_set_name(rt_device_t dev, const char *format, ...);
7171
const char *rt_dm_dev_get_name(rt_device_t dev);
7272

73+
rt_bool_t rt_dm_dev_is_big_endian(rt_device_t dev);
74+
7375
int rt_dm_dev_get_address_count(rt_device_t dev);
7476
rt_err_t rt_dm_dev_get_address(rt_device_t dev, int index,
7577
rt_uint64_t *out_address, rt_uint64_t *out_size);
@@ -87,6 +89,8 @@ int rt_dm_dev_get_irq_by_name(rt_device_t dev, const char *name);
8789
void rt_dm_dev_bind_fwdata(rt_device_t dev, void *fw_np, void *data);
8890
void rt_dm_dev_unbind_fwdata(rt_device_t dev, void *fw_np);
8991

92+
const char *rt_dm_dev_get_prop_fuzzy_name(rt_device_t dev, const char *name);
93+
9094
int rt_dm_dev_prop_read_u8_array_index(rt_device_t dev, const char *propname,
9195
int index, int nr, rt_uint8_t *out_values);
9296
int rt_dm_dev_prop_read_u16_array_index(rt_device_t dev, const char *propname,

0 commit comments

Comments
 (0)