Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269376
b: refs/heads/master
c: 9514a56
h: refs/heads/master
v: v3
  • Loading branch information
Grant Likely committed Oct 5, 2011
1 parent 1f9a88c commit d1b3259
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6add6967a4a57e2156b96e62f28bcbe1901d16c1
refs/heads/master: 9514a56753a8d379db36bed424588e1842f2bfcc
40 changes: 40 additions & 0 deletions trunk/Documentation/devicetree/bindings/vendor-prefixes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Device tree binding vendor prefix registry. Keep list in alphabetical order.

This isn't an exhaustive list, but you should add new prefixes to it before
using them to avoid name-space collisions.

adi Analog Devices, Inc.
amcc Applied Micro Circuits Corporation (APM, formally AMCC)
apm Applied Micro Circuits Corporation (APM)
arm ARM Ltd.
atmel Atmel Corporation
chrp Common Hardware Reference Platform
dallas Maxim Integrated Products (formerly Dallas Semiconductor)
denx Denx Software Engineering
epson Seiko Epson Corp.
est ESTeem Wireless Modems
fsl Freescale Semiconductor
GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
hp Hewlett Packard
ibm International Business Machines (IBM)
idt Integrated Device Technologies, Inc.
intercontrol Inter Control Group
linux Linux-specific binding
marvell Marvell Technology Group Ltd.
maxim Maxim Integrated Products
mosaixtech Mosaix Technologies, Inc.
national National Semiconductor
nintendo Nintendo
nvidia NVIDIA
nxp NXP Semiconductors
powervr Imagination Technologies
qcom Qualcomm, Inc.
ramtron Ramtron International
samsung Samsung Semiconductor
schindler Schindler
simtek
sirf SiRF Technology, Inc.
stericsson ST-Ericsson
ti Texas Instruments
xlnx Xilinx
150 changes: 150 additions & 0 deletions trunk/drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,39 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/ctype.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>

/**
* struct alias_prop - Alias property in 'aliases' node
* @link: List node to link the structure in aliases_lookup list
* @alias: Alias property name
* @np: Pointer to device_node that the alias stands for
* @id: Index value from end of alias name
* @stem: Alias string without the index
*
* The structure represents one alias property of 'aliases' node as
* an entry in aliases_lookup list.
*/
struct alias_prop {
struct list_head link;
const char *alias;
struct device_node *np;
int id;
char stem[0];
};

static LIST_HEAD(aliases_lookup);

struct device_node *allnodes;
struct device_node *of_chosen;
struct device_node *of_aliases;

static DEFINE_MUTEX(of_aliases_mutex);

/* use when traversing tree through the allnext, child, sibling,
* or parent members of struct device_node.
Expand Down Expand Up @@ -631,6 +656,35 @@ int of_property_read_u32_array(const struct device_node *np,
}
EXPORT_SYMBOL_GPL(of_property_read_u32_array);

/**
* of_property_read_u64 - Find and read a 64 bit integer from a property
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
* @out_value: pointer to return value, modified only if return value is 0.
*
* Search for a property in a device node and read a 64-bit value from
* it. Returns 0 on success, -EINVAL if the property does not exist,
* -ENODATA if property does not have a value, and -EOVERFLOW if the
* property data isn't large enough.
*
* The out_value is modified only if a valid u64 value can be decoded.
*/
int of_property_read_u64(const struct device_node *np, const char *propname,
u64 *out_value)
{
struct property *prop = of_find_property(np, propname, NULL);

if (!prop)
return -EINVAL;
if (!prop->value)
return -ENODATA;
if (sizeof(*out_value) > prop->length)
return -EOVERFLOW;
*out_value = of_read_number(prop->value, 2);
return 0;
}
EXPORT_SYMBOL_GPL(of_property_read_u64);

/**
* of_property_read_string - Find and read a string from a property
* @np: device node from which the property value is to be read.
Expand Down Expand Up @@ -988,3 +1042,99 @@ void of_detach_node(struct device_node *np)
}
#endif /* defined(CONFIG_OF_DYNAMIC) */

static void of_alias_add(struct alias_prop *ap, struct device_node *np,
int id, const char *stem, int stem_len)
{
ap->np = np;
ap->id = id;
strncpy(ap->stem, stem, stem_len);
ap->stem[stem_len] = 0;
list_add_tail(&ap->link, &aliases_lookup);
pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n",
ap->alias, ap->stem, ap->id, np ? np->full_name : NULL);
}

/**
* of_alias_scan - Scan all properties of 'aliases' node
*
* The function scans all the properties of 'aliases' node and populate
* the the global lookup table with the properties. It returns the
* number of alias_prop found, or error code in error case.
*
* @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree
*/
void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
{
struct property *pp;

of_chosen = of_find_node_by_path("/chosen");
if (of_chosen == NULL)
of_chosen = of_find_node_by_path("/chosen@0");
of_aliases = of_find_node_by_path("/aliases");
if (!of_aliases)
return;

for_each_property(pp, of_aliases->properties) {
const char *start = pp->name;
const char *end = start + strlen(start);
struct device_node *np;
struct alias_prop *ap;
int id, len;

/* Skip those we do not want to proceed */
if (!strcmp(pp->name, "name") ||
!strcmp(pp->name, "phandle") ||
!strcmp(pp->name, "linux,phandle"))
continue;

np = of_find_node_by_path(pp->value);
if (!np)
continue;

/* walk the alias backwards to extract the id and work out
* the 'stem' string */
while (isdigit(*(end-1)) && end > start)
end--;
len = end - start;

if (kstrtoint(end, 10, &id) < 0)
continue;

/* Allocate an alias_prop with enough space for the stem */
ap = dt_alloc(sizeof(*ap) + len + 1, 4);
if (!ap)
continue;
ap->alias = start;
of_alias_add(ap, np, id, start, len);
}
}

/**
* of_alias_get_id - Get alias id for the given device_node
* @np: Pointer to the given device_node
* @stem: Alias stem of the given device_node
*
* The function travels the lookup table to get alias id for the given
* device_node and alias stem. It returns the alias id if find it.
*/
int of_alias_get_id(struct device_node *np, const char *stem)
{
struct alias_prop *app;
int id = -ENODEV;

mutex_lock(&of_aliases_mutex);
list_for_each_entry(app, &aliases_lookup, link) {
if (strcmp(app->stem, stem) != 0)
continue;

if (np == app->np) {
id = app->id;
break;
}
}
mutex_unlock(&of_aliases_mutex);

return id;
}
EXPORT_SYMBOL_GPL(of_alias_get_id);
6 changes: 2 additions & 4 deletions trunk/drivers/of/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,10 +707,8 @@ void __init unflatten_device_tree(void)
__unflatten_device_tree(initial_boot_params, &allnodes,
early_init_dt_alloc_memory_arch);

/* Get pointer to OF "/chosen" node for use everywhere */
of_chosen = of_find_node_by_path("/chosen");
if (of_chosen == NULL)
of_chosen = of_find_node_by_path("/chosen@0");
/* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */
of_alias_scan(early_init_dt_alloc_memory_arch);
}

#endif /* CONFIG_OF_EARLY_FLATTREE */
8 changes: 8 additions & 0 deletions trunk/drivers/of/pdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
return ret;
}

static void *kernel_tree_alloc(u64 size, u64 align)
{
return prom_early_alloc(size);
}

void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops)
{
struct device_node **nextp;
Expand All @@ -245,4 +250,7 @@ void __init of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops)
nextp = &allnodes->allnext;
allnodes->child = of_pdt_build_tree(allnodes,
of_pdt_prom_ops->getchild(allnodes->phandle), &nextp);

/* Get pointer to "/chosen" and "/aliasas" nodes for use everywhere */
of_alias_scan(kernel_tree_alloc);
}
4 changes: 1 addition & 3 deletions trunk/drivers/tty/serial/altera_jtaguart.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,6 @@ static struct of_device_id altera_jtaguart_match[] = {
{},
};
MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
#else
#define altera_jtaguart_match NULL
#endif /* CONFIG_OF */

static struct platform_driver altera_jtaguart_platform_driver = {
Expand All @@ -482,7 +480,7 @@ static struct platform_driver altera_jtaguart_platform_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = altera_jtaguart_match,
.of_match_table = of_match_ptr(altera_jtaguart_match),
},
};

Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/tty/serial/altera_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,6 @@ static struct of_device_id altera_uart_match[] = {
{},
};
MODULE_DEVICE_TABLE(of, altera_uart_match);
#else
#define altera_uart_match NULL
#endif /* CONFIG_OF */

static struct platform_driver altera_uart_platform_driver = {
Expand All @@ -626,7 +624,7 @@ static struct platform_driver altera_uart_platform_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = altera_uart_match,
.of_match_table = of_match_ptr(altera_uart_match),
},
};

Expand Down
11 changes: 7 additions & 4 deletions trunk/drivers/tty/serial/imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,17 +1286,20 @@ static int serial_imx_resume(struct platform_device *dev)
static int serial_imx_probe_dt(struct imx_port *sport,
struct platform_device *pdev)
{
static int portnum = 0;
struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_id =
of_match_device(imx_uart_dt_ids, &pdev->dev);
int ret;

if (!np)
return -ENODEV;

sport->port.line = portnum++;
if (sport->port.line >= UART_NR)
return -EINVAL;
ret = of_alias_get_id(np, "serial");
if (ret < 0) {
dev_err(&pdev->dev, "failed to get alias id, errno %d\n", ret);
return -ENODEV;
}
sport->port.line = ret;

if (of_get_property(np, "fsl,uart-has-rtscts", NULL))
sport->have_rtscts = 1;
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/tty/serial/uartlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,6 @@ static struct of_device_id ulite_of_match[] __devinitdata = {
{}
};
MODULE_DEVICE_TABLE(of, ulite_of_match);
#else /* CONFIG_OF */
#define ulite_of_match NULL
#endif /* CONFIG_OF */

static int __devinit ulite_probe(struct platform_device *pdev)
Expand Down Expand Up @@ -609,7 +607,7 @@ static struct platform_driver ulite_platform_driver = {
.driver = {
.owner = THIS_MODULE,
.name = "uartlite",
.of_match_table = ulite_of_match,
.of_match_table = of_match_ptr(ulite_of_match),
},
};

Expand Down
Loading

0 comments on commit d1b3259

Please sign in to comment.