Commit e264ac8c authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6

* 'devicetree/merge' of git://git.secretlab.ca/git/linux-2.6:
  spi/pl022: Add loopback support for the SPI on 5500
  spi/omap_mcspi: Fix broken last word xfer
  of/flattree: minor cleanups
  dt: eliminate OF_NO_DEEP_PROBE and test for NULL match table
  dt: protect against NULL matches passed to of_match_node()
  dt: Refactor of_platform_bus_probe()
parents 20046006 06fb01fd
...@@ -496,6 +496,9 @@ EXPORT_SYMBOL(of_find_node_with_property); ...@@ -496,6 +496,9 @@ EXPORT_SYMBOL(of_find_node_with_property);
const struct of_device_id *of_match_node(const struct of_device_id *matches, const struct of_device_id *of_match_node(const struct of_device_id *matches,
const struct device_node *node) const struct device_node *node)
{ {
if (!matches)
return NULL;
while (matches->name[0] || matches->type[0] || matches->compatible[0]) { while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1; int match = 1;
if (matches->name[0]) if (matches->name[0])
......
...@@ -139,12 +139,13 @@ static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size, ...@@ -139,12 +139,13 @@ static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
/** /**
* unflatten_dt_node - Alloc and populate a device_node from the flat tree * unflatten_dt_node - Alloc and populate a device_node from the flat tree
* @blob: The parent device tree blob * @blob: The parent device tree blob
* @mem: Memory chunk to use for allocating device nodes and properties
* @p: pointer to node in flat tree * @p: pointer to node in flat tree
* @dad: Parent struct device_node * @dad: Parent struct device_node
* @allnextpp: pointer to ->allnext from last allocated device_node * @allnextpp: pointer to ->allnext from last allocated device_node
* @fpsize: Size of the node path up at the current depth. * @fpsize: Size of the node path up at the current depth.
*/ */
unsigned long unflatten_dt_node(struct boot_param_header *blob, static unsigned long unflatten_dt_node(struct boot_param_header *blob,
unsigned long mem, unsigned long mem,
unsigned long *p, unsigned long *p,
struct device_node *dad, struct device_node *dad,
...@@ -230,6 +231,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob, ...@@ -230,6 +231,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob,
} }
kref_init(&np->kref); kref_init(&np->kref);
} }
/* process properties */
while (1) { while (1) {
u32 sz, noff; u32 sz, noff;
char *pname; char *pname;
...@@ -351,7 +353,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob, ...@@ -351,7 +353,7 @@ unsigned long unflatten_dt_node(struct boot_param_header *blob,
* @dt_alloc: An allocator that provides a virtual address to memory * @dt_alloc: An allocator that provides a virtual address to memory
* for the resulting tree * for the resulting tree
*/ */
void __unflatten_device_tree(struct boot_param_header *blob, static void __unflatten_device_tree(struct boot_param_header *blob,
struct device_node **mynodes, struct device_node **mynodes,
void * (*dt_alloc)(u64 size, u64 align)) void * (*dt_alloc)(u64 size, u64 align))
{ {
......
...@@ -210,13 +210,16 @@ struct platform_device *of_platform_device_create(struct device_node *np, ...@@ -210,13 +210,16 @@ struct platform_device *of_platform_device_create(struct device_node *np,
EXPORT_SYMBOL(of_platform_device_create); EXPORT_SYMBOL(of_platform_device_create);
/** /**
* of_platform_bus_create - Create an OF device for a bus node and all its * of_platform_bus_create() - Create a device for a node and its children.
* children. Optionally recursively instantiate matching busses.
* @bus: device node of the bus to instantiate * @bus: device node of the bus to instantiate
* @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to * @matches: match table for bus nodes
* disallow recursive creation of child busses * disallow recursive creation of child buses
* @parent: parent for new device, or NULL for top level.
*
* Creates a platform_device for the provided device_node, and optionally
* recursively create devices for all the child nodes.
*/ */
static int of_platform_bus_create(const struct device_node *bus, static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches, const struct of_device_id *matches,
struct device *parent) struct device *parent)
{ {
...@@ -224,18 +227,13 @@ static int of_platform_bus_create(const struct device_node *bus, ...@@ -224,18 +227,13 @@ static int of_platform_bus_create(const struct device_node *bus,
struct platform_device *dev; struct platform_device *dev;
int rc = 0; int rc = 0;
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) { for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name); pr_debug(" create child: %s\n", child->full_name);
dev = of_platform_device_create(child, NULL, parent); rc = of_platform_bus_create(child, matches, &dev->dev);
if (dev == NULL)
continue;
if (!of_match_node(matches, child))
continue;
if (rc == 0) {
pr_debug(" and sub busses\n");
rc = of_platform_bus_create(child, matches, &dev->dev);
}
if (rc) { if (rc) {
of_node_put(child); of_node_put(child);
break; break;
...@@ -245,9 +243,9 @@ static int of_platform_bus_create(const struct device_node *bus, ...@@ -245,9 +243,9 @@ static int of_platform_bus_create(const struct device_node *bus,
} }
/** /**
* of_platform_bus_probe - Probe the device-tree for platform busses * of_platform_bus_probe() - Probe the device-tree for platform buses
* @root: parent of the first level to probe or NULL for the root of the tree * @root: parent of the first level to probe or NULL for the root of the tree
* @matches: match table, NULL to use the default * @matches: match table for bus nodes
* @parent: parent to hook devices from, NULL for toplevel * @parent: parent to hook devices from, NULL for toplevel
* *
* Note that children of the provided root are not instantiated as devices * Note that children of the provided root are not instantiated as devices
...@@ -258,50 +256,26 @@ int of_platform_bus_probe(struct device_node *root, ...@@ -258,50 +256,26 @@ int of_platform_bus_probe(struct device_node *root,
struct device *parent) struct device *parent)
{ {
struct device_node *child; struct device_node *child;
struct platform_device *dev;
int rc = 0; int rc = 0;
if (WARN_ON(!matches || matches == OF_NO_DEEP_PROBE)) root = root ? of_node_get(root) : of_find_node_by_path("/");
return -EINVAL; if (!root)
if (root == NULL)
root = of_find_node_by_path("/");
else
of_node_get(root);
if (root == NULL)
return -EINVAL; return -EINVAL;
pr_debug("of_platform_bus_probe()\n"); pr_debug("of_platform_bus_probe()\n");
pr_debug(" starting at: %s\n", root->full_name); pr_debug(" starting at: %s\n", root->full_name);
/* Do a self check of bus type, if there's a match, create /* Do a self check of bus type, if there's a match, create children */
* children
*/
if (of_match_node(matches, root)) { if (of_match_node(matches, root)) {
pr_debug(" root match, create all sub devices\n"); rc = of_platform_bus_create(root, matches, parent);
dev = of_platform_device_create(root, NULL, parent); } else for_each_child_of_node(root, child) {
if (dev == NULL)
goto bail;
pr_debug(" create all sub busses\n");
rc = of_platform_bus_create(root, matches, &dev->dev);
goto bail;
}
for_each_child_of_node(root, child) {
if (!of_match_node(matches, child)) if (!of_match_node(matches, child))
continue; continue;
rc = of_platform_bus_create(child, matches, parent);
pr_debug(" match: %s\n", child->full_name); if (rc)
dev = of_platform_device_create(child, NULL, parent);
if (dev == NULL)
continue;
rc = of_platform_bus_create(child, matches, &dev->dev);
if (rc) {
of_node_put(child);
break; break;
}
} }
bail:
of_node_put(root); of_node_put(root);
return rc; return rc;
} }
......
...@@ -324,6 +324,7 @@ struct vendor_data { ...@@ -324,6 +324,7 @@ struct vendor_data {
bool unidir; bool unidir;
bool extended_cr; bool extended_cr;
bool pl023; bool pl023;
bool loopback;
}; };
/** /**
...@@ -1983,7 +1984,7 @@ static int pl022_setup(struct spi_device *spi) ...@@ -1983,7 +1984,7 @@ static int pl022_setup(struct spi_device *spi)
SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8); SSP_WRITE_BITS(chip->cr0, clk_freq.scr, SSP_CR0_MASK_SCR, 8);
/* Loopback is available on all versions except PL023 */ /* Loopback is available on all versions except PL023 */
if (!pl022->vendor->pl023) { if (pl022->vendor->loopback) {
if (spi->mode & SPI_LOOP) if (spi->mode & SPI_LOOP)
tmp = LOOPBACK_ENABLED; tmp = LOOPBACK_ENABLED;
else else
...@@ -2233,6 +2234,7 @@ static struct vendor_data vendor_arm = { ...@@ -2233,6 +2234,7 @@ static struct vendor_data vendor_arm = {
.unidir = false, .unidir = false,
.extended_cr = false, .extended_cr = false,
.pl023 = false, .pl023 = false,
.loopback = true,
}; };
...@@ -2242,6 +2244,7 @@ static struct vendor_data vendor_st = { ...@@ -2242,6 +2244,7 @@ static struct vendor_data vendor_st = {
.unidir = false, .unidir = false,
.extended_cr = true, .extended_cr = true,
.pl023 = false, .pl023 = false,
.loopback = true,
}; };
static struct vendor_data vendor_st_pl023 = { static struct vendor_data vendor_st_pl023 = {
...@@ -2250,6 +2253,16 @@ static struct vendor_data vendor_st_pl023 = { ...@@ -2250,6 +2253,16 @@ static struct vendor_data vendor_st_pl023 = {
.unidir = false, .unidir = false,
.extended_cr = true, .extended_cr = true,
.pl023 = true, .pl023 = true,
.loopback = false,
};
static struct vendor_data vendor_db5500_pl023 = {
.fifodepth = 32,
.max_bpw = 32,
.unidir = false,
.extended_cr = true,
.pl023 = true,
.loopback = true,
}; };
static struct amba_id pl022_ids[] = { static struct amba_id pl022_ids[] = {
...@@ -2283,6 +2296,11 @@ static struct amba_id pl022_ids[] = { ...@@ -2283,6 +2296,11 @@ static struct amba_id pl022_ids[] = {
.mask = 0xffffffff, .mask = 0xffffffff,
.data = &vendor_st_pl023, .data = &vendor_st_pl023,
}, },
{
.id = 0x10080023,
.mask = 0xffffffff,
.data = &vendor_db5500_pl023,
},
{ 0, 0 }, { 0, 0 },
}; };
......
...@@ -517,7 +517,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -517,7 +517,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %02x\n", dev_vdbg(&spi->dev, "read-%d %02x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
} while (c > (word_len>>3)); } while (c);
} else if (word_len <= 16) { } else if (word_len <= 16) {
u16 *rx; u16 *rx;
const u16 *tx; const u16 *tx;
...@@ -564,7 +564,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -564,7 +564,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %04x\n", dev_vdbg(&spi->dev, "read-%d %04x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
} while (c > (word_len>>3)); } while (c >= 2);
} else if (word_len <= 32) { } else if (word_len <= 32) {
u32 *rx; u32 *rx;
const u32 *tx; const u32 *tx;
...@@ -611,7 +611,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer) ...@@ -611,7 +611,7 @@ omap2_mcspi_txrx_pio(struct spi_device *spi, struct spi_transfer *xfer)
dev_vdbg(&spi->dev, "read-%d %08x\n", dev_vdbg(&spi->dev, "read-%d %08x\n",
word_len, *(rx - 1)); word_len, *(rx - 1));
} }
} while (c > (word_len>>3)); } while (c >= 4);
} }
/* for TX_ONLY mode, be sure all words have shifted out */ /* for TX_ONLY mode, be sure all words have shifted out */
......
...@@ -52,9 +52,6 @@ extern struct platform_device *of_platform_device_create(struct device_node *np, ...@@ -52,9 +52,6 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
const char *bus_id, const char *bus_id,
struct device *parent); struct device *parent);
/* pseudo "matches" value to not do deep probe */
#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
extern int of_platform_bus_probe(struct device_node *root, extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches, const struct of_device_id *matches,
struct device *parent); struct device *parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment