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