LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 08-14-2006, 10:28 AM   #1
drasko
LQ Newbie
 
Registered: Aug 2006
Posts: 1

Rep: Reputation: 0
AMBA device registering


Hi all.
can anybody explain me these lines:

for (pid = 0, i = 0; i < 4; i++)
pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
for (cid = 0, i = 0; i < 4; i++)
cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);

iounmap(tmp);

if (cid == 0xb105f00d)
dev->periphid = pid;

if (dev->periphid)
ret = device_register(&dev->dev);
else
ret = -ENODEV;

in amba.c, in /arc/arm/common. I pasted the whole
amba_device_register() fnc. below.

I need to register my i2c_device as an amba_device, so I have question
about .periphid member od amba_device struct. What number does it
represent? Is it connected to above lines found in amba.c and how?
Looks like it is, but I can decypher these...

I have UARTS defined as amba_device:
static struct amba_device uart0_device = {
.dev = {
.bus_id = "dev:00",
},
.res = {
.start = UART0_BASE,
.end = UART0_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
.irq = { UARTINTR0_VECTOR, NO_IRQ },
.periphid = 0x0041010,
};

Here stands .periphid = 0x0041010. Why? Is this number something
specific to AMBA or to UART? I can find this nuber figure in several
more files, like arch/arm/mach-integrator/core.c, but also for uart
device...

Also, can anybody describe me .bus_id part of .dev structure (why is it
initialized to "dev:00" and what are possible initializers)? In
arch/arm/mach-integrator/core.c there stands "mb:15", "mb:16"... for
devices. In mine core.c they start from "dev:00". Still I can not
understand what this value means...

-----------------

/**
* amba_device_register - register an AMBA device
* @dev: AMBA device to register
* @parent: parent memory resource
*
* Setup the AMBA device, reading the cell ID if present.
* Claim the resource, and register the AMBA device with
* the Linux device manager.
*/
int amba_device_register(struct amba_device *dev, struct resource
*parent)
{
u32 pid, cid;
void __iomem *tmp;
int i, ret;

dev->dev.release = amba_device_release;
dev->dev.bus = &amba_bustype;
dev->dev.dma_mask = &dev->dma_mask;
dev->res.name = dev->dev.bus_id;

if (!dev->dev.coherent_dma_mask && dev->dma_mask)
dev_warn(&dev->dev, "coherent dma mask is unset\n");

ret = request_resource(parent, &dev->res);
if (ret == 0) {
tmp = ioremap(dev->res.start, SZ_4K);
if (!tmp) {
ret = -ENOMEM;
goto out;
}

for (pid = 0, i = 0; i < 4; i++)
pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8);
for (cid = 0, i = 0; i < 4; i++)
cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8);

iounmap(tmp);

if (cid == 0xb105f00d)
dev->periphid = pid;

if (dev->periphid)
ret = device_register(&dev->dev);
else
ret = -ENODEV;

if (ret == 0) {
device_create_file(&dev->dev, &dev_attr_id);
if (dev->irq[0] != NO_IRQ)
device_create_file(&dev->dev, &dev_attr_irq0);
if (dev->irq[1] != NO_IRQ)
device_create_file(&dev->dev, &dev_attr_irq1);
device_create_file(&dev->dev, &dev_attr_resource);
} else {
out:
release_resource(&dev->res);
}
}

return ret;

}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2.6 kernel device registering Michael_S Linux - Hardware 0 07-13-2006 01:06 PM
Question about registering a monkey LQ Suggestions & Feedback 2 02-26-2005 07:22 AM
Suse 9.1 pro access amba Peterx Linux - Networking 1 11-09-2004 09:03 PM
.Xdefaults not registering changes miss crump Debian 2 06-25-2004 09:08 AM
Registering nameservers Polaris2203 Linux - Networking 7 09-15-2003 08:13 PM


All times are GMT -5. The time now is 11:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration