<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 12, 2014 at 7:09 PM, amit mehta <span dir="ltr"><<a href="mailto:gmate.amit@gmail.com" target="_blank">gmate.amit@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We are working on a school project in which we are trying to develop a<br>
audio mixer<br>
on Zedboard (Development board from Digilent). We have developed the IP and have<br>
integrated it with the overall hardware using Programmable logic. This<br>
board has ARM<br>
core. We have a Digilent pre-configured Linux source which we cross-compiled<br>
for ARM board, device tree blob and bootloader for Zync(BOOT.BIN). The system<br>
boots fine with Linux, but now to expose the recently added hardware<br>
implementation<br>
of audio mixer, we are trying to develop the driver using the platform<br>
driver API.<br>
Currently, In our reconfigurable hardware, we have 2 channels and a mixer and we<br>
want to access those individually as some file nodes under /proc FS. The sample<br>
code is shown below:<br>
<br>
<snip from myiir.c><br>
/* device match table to match with device node in device tree<br>
* These are the list of devices that we want to expose as platform device<br>
*/<br>
static const struct of_device_id myiir_of_match[] __devinitconst = {<br>
{.compatible = "dglnt,myiir-audio-ch0"},<br>
{.compatible = "dglnt,myiir-audio-ch1"},<br>
{.compatible = "dglnt,myiir-audio-mix0"},<br>
{},<br>
};<br>
<br>
MODULE_DEVICE_TABLE(of, myiir_of_match);<br>
<br>
/* platform driver structure for myiir driver */<br>
static struct platform_driver myiir_driver = {<br>
.driver = {<br>
.name = DRIVER_NAME,<br>
.owner = THIS_MODULE,<br>
.of_match_table = myiir_of_match},<br>
.probe = myiir_probe,<br>
.remove = __devexit_p(myiir_remove),<br>
.shutdown = __devexit_p(myiir_shutdown)<br>
};<br>
<br>
/* Register myiir platform driver */<br>
module_platform_driver(myiir_driver);<br>
<myiir.c><br>
<br>
Now, inside the probe routine (myiir_probe), can we create proc<br>
entries by calling<br>
create_proc for each of these nodes and setting the appropriate read and write<br>
methods(file_operations) ?<br></blockquote><div><br></div><div><br></div><div>Yes, I feel this is fine, the proc entries to be created in probe, Initialize all data structures as required in probe.</div><div><br></div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<snip from the myiir_probe><br>
struct proc_dir_entry *myiir_proc_entry[3];<br>
<br>
myiir_proc_entry[0] = proc_create("myiir-audio-ch0", 0, NULL,<br>
&proc_myiir_ch0_operations);<br>
<br>
myiir_proc_entry[1] = proc_create("myiir-audio-ch1", 0, NULL,<br>
&proc_myiir_ch1_operations);<br>
<br>
myiir_proc_entry[2] = proc_create("myiir-audio-mix0", 0, NULL,<br>
&proc_myiir_mix0_operations);<br>
<br>
<snip from the myiir_probe><br>
<br>
While browsing the Internet, we found some sample driver code, which we are<br>
also using as a template. I've attached the driver that is based on<br>
the same template.<br>
<br>
<snip from device tree file><br>
myiir-aud-ch0 {<br>
compatible = "dglnt,myiir-audio-ch0";<br>
reg = <0x74200000 0x10000>;<br>
};<br>
myiir-aud-ch1 {<br>
compatible = "dglnt,myiir-audio-ch1";<br>
reg = <0x74220000 0x10000>;<br>
};<br>
myiir-aud-mix0 {<br>
compatible = "dglnt,myiir-audio-mix0";<br>
reg = <0x68600000 0x10000>;<br>
};<br>
<snip from device tree file><br>
<br>
The driver is far from complete, but as of now the compilation woks fine.<br>
<snip><br>
user@fpga4v:~/tutorial/IIRdriver$ make ARCH=arm<br>
CROSS_COMPILE=arm-xilinx-linux-gnueabi-<br>
make -C ../linux-digilent-3.6-digilent-13.01/<br>
M=/home/user/tutorial/IIRdriver modules<br>
make[1]: Entering directory<br>
`/home/user/tutorial/linux-digilent-3.6-digilent-13.01'<br>
CC [M] /home/user/tutorial/IIRdriver/myiir.o<br>
Building modules, stage 2.<br>
MODPOST 1 modules<br>
CC /home/user/tutorial/IIRdriver/myiir.mod.o<br>
LD [M] /home/user/tutorial/IIRdriver/myiir.ko<br>
make[1]: Leaving directory<br>
`/home/user/tutorial/linux-digilent-3.6-digilent-13.01'<br>
<snip><br>
<br></blockquote><div><br></div><div>Overall this looks to be a good attempt .Kumar :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
Kumar<br>
<br>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br></blockquote></div><br></div></div>