[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Allocate resources from dts-node
From:       Manuel =?iso-8859-15?Q?St=FChn?= <freebsdnewbie () freenet ! de>
Date:       2019-04-13 10:19:47
Message-ID: 20190413101947.GA5005 () freebsd-t450 ! fritz ! box
[Download RAW message or body]


Hi,
during the process of preparing a NanoPI NEO2 port i found some bugs in 
allwinners a10_codec implementation i'm now trying to fix.  But i'm 
struggeling with the resource management.

In the codec@1c22c00 section of the sunxi-h3-h5.dtsi there is a xref to 
another node containing a needed register address and width:

codec: codec@1c22c00 {
   [..]
   reg = <0x01c22c00 0x400>;
   allwinner,codec-analog-controls = <&codec_analog>
   [..]
}

codec_analog: codec-analog@1f015c0 {
   compatible = "allwinner,sun8i-h3-codec-analog";
   reg = <0x01f015c0 0x4>;
};

The driver kept crashing until i changed the dts file to something like 
this:

codec: codec@1c22c00 {
   [..]
   reg = <0x01c22c00 0x400 0x01f015c0 0x4>;
   [..]
}

The driver wants to allocate both registers at once with 
bus_alloc_resources() and a struct resource_spec describing two memory 
sections and an interrupt section.

I'm failing in glueing the resource described by "reg" in codec_analog 
into the a10_codec driver. The raw content I managed to retrieve 
correctly by using these OF_* stuff in the drivers attach()-function:

[..]
phandle_t analognode, analogref;
OF_getencprop(node, "allwinner,codec-analog-controls", 
&analogref, sizeof(analogref))

analognode = OF_node_from_xref(analogref);

pcell_t reg[2];
OF_getencprop(analognode, "reg", reg, sizeof(reg))
[..]

The contents of reg[2] are the correct values, but now i do not find how 
to correctly make them available to the driver as resource:

int rid = 2;
struct resource *res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
reg[0], reg[0]+reg[1]-1, reg[1], RF_ACTIVE );

This does not return a valid resource pointer. Is this anyhow the 
correct way to do?


Any help greatly appreciated :)

--
Manuel


_______________________________________________
freebsd-hackers@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic