kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: joshc@eso.teric.us (Josh Cartwright)
To: kernelnewbies@lists.kernelnewbies.org
Subject: SOC: Zedboard: Driver question
Date: Fri, 13 Jun 2014 08:13:16 -0500	[thread overview]
Message-ID: <20140613131316.GB7289@kryptos> (raw)
In-Reply-To: <CAOUxTKO2wsTzKpeHGg3yUBAOjNNU3tztyUPJEk-f+kSx_OMHng@mail.gmail.com>

On Thu, Jun 12, 2014 at 04:39:25PM +0300, amit mehta 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:
>
[..]

It wasn't clear what your problem was, or if you were just asking for
advice, but I will add one comment that will hopefully save you some
debugging time:

> #include <linux/kernel.h> 
> #include <linux/module.h>
> #include <asm/uaccess.h> 		/*Needed for copy_from_user */
> #include <asm/io.h>	 		/*Needed for IO Read/Write Functions */
> #include <linux/proc_fs.h>		/*Needed for Proc File System Functions */
> #include <linux/seq_file.h>		/*Needed for Sequence File Operations */
> #include <linux/platform_device.h>	/*Needed for Platform Driver Functions */
>
> /* Define Driver Name */
> #define DRIVER_NAME "myiir"
>
> unsigned long *base_addr;	/* Vitual Base Address */
> struct resource *res;		/* Device Resource Structure */
> unsigned long remap_size;	/* Device Memory Size */

The way this driver is written, you will actually be probed three times,
once per node in the device tree.  The drivers' use of global state here
is going to bite you.

[..]
> static int __devinit myiir_probe(struct platform_device *pdev)
> {
> 	struct proc_dir_entry *myiir_proc_entry[3];
> 	int ret = 0;
> 
> 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> 	if (!res) {
> 		dev_err(&pdev->dev, "No memory resource\n");
> 		return -ENODEV;
> 	}
> 	remap_size = res->end - res->start + 1;
> 
> 	if (!request_mem_region(res->start, remap_size, pdev->name)) {
> 		dev_err(&pdev->dev, "Cannot request IO\n");
> 		return -ENXIO;
> 	}
> 
> 	base_addr = ioremap(res->start, remap_size);
> 	if (base_addr == NULL) {
> 		dev_err(&pdev->dev, "Couldn't ioremap memory at 0x%08lx\n",
> 		(unsigned long)res->start);
> 		ret = -ENOMEM;
> 		goto err_release_region;
> 	}
[..]
> 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"},
> 	{},
> };

Are these really separate IP blocks entirely, or just multiple instances
of the same IP block (perhaps with different parameters used during
synthesis)?  If the latter, then they should really share a compatible
string that reflects the name/version of the IP block; handling which
block is which channel should be done at a higher level.

Good luck,

  Josh

  parent reply	other threads:[~2014-06-13 13:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 13:39 SOC: Zedboard: Driver question amit mehta
2014-06-12 13:52 ` priyaranjan
2014-06-12 14:43   ` amit mehta
2014-06-12 16:10     ` priyaranjan
2014-06-13 13:13 ` Josh Cartwright [this message]
2014-06-18  6:01   ` sanjeev sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140613131316.GB7289@kryptos \
    --to=joshc@eso.teric.us \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).