linux - Getting the device address by device tree file in C -


i working on linux; when linux starts dts (device tree), file loaded linux kernel.

my question is, there have way device address dts file using c lanugage?

for example:

some part of dts file like:

soc@ffe00000{     .......     i2c@112000{     .......     } } 

i want device name(soc,i2c),and address(ffe00000,112000)...


hi ck vir,

your question isn't clear. i'm assuming looking sort of function takes argument contents of dts file , returns bunch of (device, address) pairs. correct?

also, useful if told sort of device using. raspberry pi? beaglebone black? or full desktop computer? distro , version of linux using?

this might not looking for, while ago, used nice library posted here on github. instance, address device named "ethernet", following.

int err = dtree_open("/proc/device-tree"); if(err != 0) {     printf("failed open device tree\n");     exit(1); }  struct dtree_dev_t *eth = dtree_byname("ethernet"); if(eth == 0) {     printf("failed find device named \"ethernet\"\n");     exit(1); }  //print base address of ethernet hardware printf("base address of ethernet %i\n", eth->base);  dtree_dev_free(eth);  dtree_close(); 

i hope library useful me.

if doesn't help, trivial task implement dts parser in c. "language" dts isn't terribly complex. number of details regarding syntax can found here.

best, john


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -