amba: add oftree probe support
move ARM_AMBA Kconfig to drivers/amba/Kconfig Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
afab6ac783
commit
8428a8c6e3
|
@ -7,9 +7,6 @@ config ARM
|
||||||
select HAVE_IMAGE_COMPRESSION
|
select HAVE_IMAGE_COMPRESSION
|
||||||
default y
|
default y
|
||||||
|
|
||||||
config ARM_AMBA
|
|
||||||
bool
|
|
||||||
|
|
||||||
config ARM_LINUX
|
config ARM_LINUX
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
menu "Drivers"
|
menu "Drivers"
|
||||||
|
|
||||||
|
source "drivers/amba/Kconfig"
|
||||||
source "drivers/serial/Kconfig"
|
source "drivers/serial/Kconfig"
|
||||||
source "drivers/net/Kconfig"
|
source "drivers/net/Kconfig"
|
||||||
source "drivers/spi/Kconfig"
|
source "drivers/spi/Kconfig"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
config ARM_AMBA
|
||||||
|
bool
|
|
@ -212,6 +212,7 @@ struct amba_device *amba_device_alloc(const char *name, int id, resource_size_t
|
||||||
dev->res.start = base;
|
dev->res.start = base;
|
||||||
dev->res.end = base + size - 1;
|
dev->res.end = base + size - 1;
|
||||||
dev->res.flags = IORESOURCE_MEM;
|
dev->res.flags = IORESOURCE_MEM;
|
||||||
|
dev->dev.resource = &dev->res;
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <sizes.h>
|
#include <sizes.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
|
#include <linux/amba/bus.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct alias_prop - Alias property in 'aliases' node
|
* struct alias_prop - Alias property in 'aliases' node
|
||||||
|
@ -641,18 +642,44 @@ void of_delete_property(struct property *pp)
|
||||||
free(pp);
|
free(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct device_d *add_of_device(struct device_node *node)
|
static struct device_d *add_of_amba_device(struct device_node *node)
|
||||||
|
{
|
||||||
|
struct amba_device *dev;
|
||||||
|
char *name, *at;
|
||||||
|
|
||||||
|
dev = xzalloc(sizeof(*dev));
|
||||||
|
|
||||||
|
name = xstrdup(node->name);
|
||||||
|
at = strchr(name, '@');
|
||||||
|
if (at) {
|
||||||
|
*at = 0;
|
||||||
|
snprintf(dev->dev.name, MAX_DRIVER_NAME, "%s.%s", at + 1, name);
|
||||||
|
} else {
|
||||||
|
strncpy(dev->dev.name, node->name, MAX_DRIVER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->dev.id = DEVICE_ID_SINGLE;
|
||||||
|
memcpy(&dev->res, &node->resource[0], sizeof(struct resource));
|
||||||
|
dev->dev.resource = node->resource;
|
||||||
|
dev->dev.num_resources = 1;
|
||||||
|
dev->dev.device_node = node;
|
||||||
|
node->device = &dev->dev;
|
||||||
|
|
||||||
|
of_property_read_u32(node, "arm,primecell-periphid", &dev->periphid);
|
||||||
|
|
||||||
|
debug("register device 0x%08x\n", node->resource[0].start);
|
||||||
|
|
||||||
|
amba_device_add(dev);
|
||||||
|
|
||||||
|
free(name);
|
||||||
|
|
||||||
|
return &dev->dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct device_d *add_of_platform_device(struct device_node *node)
|
||||||
{
|
{
|
||||||
struct device_d *dev;
|
struct device_d *dev;
|
||||||
char *name, *at;
|
char *name, *at;
|
||||||
const struct property *cp;
|
|
||||||
|
|
||||||
if (of_node_disabled(node))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
cp = of_get_property(node, "compatible", NULL);
|
|
||||||
if (!cp)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
dev = xzalloc(sizeof(*dev));
|
dev = xzalloc(sizeof(*dev));
|
||||||
|
|
||||||
|
@ -679,6 +706,24 @@ static struct device_d *add_of_device(struct device_node *node)
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct device_d *add_of_device(struct device_node *node)
|
||||||
|
{
|
||||||
|
const struct property *cp;
|
||||||
|
|
||||||
|
if (of_node_disabled(node))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cp = of_get_property(node, "compatible", NULL);
|
||||||
|
if (!cp)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (IS_ENABLED(CONFIG_ARM_AMBA) &&
|
||||||
|
of_device_is_compatible(node, "arm,primecell") == 1)
|
||||||
|
return add_of_amba_device(node);
|
||||||
|
else
|
||||||
|
return add_of_platform_device(node);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(add_of_device);
|
EXPORT_SYMBOL(add_of_device);
|
||||||
|
|
||||||
u64 dt_mem_next_cell(int s, const __be32 **cellp)
|
u64 dt_mem_next_cell(int s, const __be32 **cellp)
|
||||||
|
|
Loading…
Reference in New Issue