Commit bd1f7936 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt

Merge commit 'gcl/gcl-next' into next

parents 30aae739 ff82c587
...@@ -56,12 +56,12 @@ static struct clk *mpc5121_clk_get(struct device *dev, const char *id) ...@@ -56,12 +56,12 @@ static struct clk *mpc5121_clk_get(struct device *dev, const char *id)
int dev_match = 0; int dev_match = 0;
int id_match = 0; int id_match = 0;
if (dev == NULL && id == NULL) if (dev == NULL || id == NULL)
return NULL; return NULL;
mutex_lock(&clocks_mutex); mutex_lock(&clocks_mutex);
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
if (dev && dev == p->dev) if (dev == p->dev)
dev_match++; dev_match++;
if (strcmp(id, p->name) == 0) if (strcmp(id, p->name) == 0)
id_match++; id_match++;
......
...@@ -363,11 +363,8 @@ static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio) ...@@ -363,11 +363,8 @@ static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio)
{ {
struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
struct mpc52xx_gpt __iomem *regs = mm_gc->regs; struct mpc52xx_gpt __iomem *regs = mm_gc->regs;
unsigned int ret;
return (in_be32(&regs->status) & (1 << (31 - 23))) ? 1 : 0; return (in_be32(&regs->status) & (1 << (31 - 23))) ? 1 : 0;
return ret;
} }
static void static void
......
...@@ -196,6 +196,7 @@ static void mpc52xx_extirq_ack(unsigned int virq) ...@@ -196,6 +196,7 @@ static void mpc52xx_extirq_ack(unsigned int virq)
static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type) static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type)
{ {
struct irq_desc *desc = get_irq_desc(virq);
u32 ctrl_reg, type; u32 ctrl_reg, type;
int irq; int irq;
int l2irq; int l2irq;
...@@ -222,6 +223,11 @@ static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type) ...@@ -222,6 +223,11 @@ static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type)
type = 0; type = 0;
} }
desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
if (flow_type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW))
desc->status |= IRQ_LEVEL;
ctrl_reg = in_be32(&intr->ctrl); ctrl_reg = in_be32(&intr->ctrl);
ctrl_reg &= ~(0x3 << (22 - (l2irq * 2))); ctrl_reg &= ~(0x3 << (22 - (l2irq * 2)));
ctrl_reg |= (type << (22 - (l2irq * 2))); ctrl_reg |= (type << (22 - (l2irq * 2)));
...@@ -231,7 +237,7 @@ static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type) ...@@ -231,7 +237,7 @@ static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type)
} }
static struct irq_chip mpc52xx_extirq_irqchip = { static struct irq_chip mpc52xx_extirq_irqchip = {
.typename = " MPC52xx IRQ[0-3] ", .typename = "MPC52xx External",
.mask = mpc52xx_extirq_mask, .mask = mpc52xx_extirq_mask,
.unmask = mpc52xx_extirq_unmask, .unmask = mpc52xx_extirq_unmask,
.ack = mpc52xx_extirq_ack, .ack = mpc52xx_extirq_ack,
......
...@@ -1206,6 +1206,7 @@ static struct of_device_id ace_of_match[] __devinitdata = { ...@@ -1206,6 +1206,7 @@ static struct of_device_id ace_of_match[] __devinitdata = {
{ .compatible = "xlnx,opb-sysace-1.00.b", }, { .compatible = "xlnx,opb-sysace-1.00.b", },
{ .compatible = "xlnx,opb-sysace-1.00.c", }, { .compatible = "xlnx,opb-sysace-1.00.c", },
{ .compatible = "xlnx,xps-sysace-1.00.a", }, { .compatible = "xlnx,xps-sysace-1.00.a", },
{ .compatible = "xlnx,sysace", },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, ace_of_match); MODULE_DEVICE_TABLE(of, ace_of_match);
......
...@@ -66,4 +66,23 @@ void of_register_i2c_devices(struct i2c_adapter *adap, ...@@ -66,4 +66,23 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
} }
EXPORT_SYMBOL(of_register_i2c_devices); EXPORT_SYMBOL(of_register_i2c_devices);
static int of_dev_node_match(struct device *dev, void *data)
{
return dev_archdata_get_node(&dev->archdata) == data;
}
/* must call put_device() when done with returned i2c_client device */
struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
{
struct device *dev;
dev = bus_find_device(&i2c_bus_type, NULL, node,
of_dev_node_match);
if (!dev)
return NULL;
return to_i2c_client(dev);
}
EXPORT_SYMBOL(of_find_i2c_device_by_node);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/of_platform.h>
#include <linux/of_device.h>
#include <linux/of_spi.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h> #include <linux/spi/spi_bitbang.h>
#include <linux/io.h> #include <linux/io.h>
#include <syslib/virtex_devices.h>
#define XILINX_SPI_NAME "xilinx_spi" #define XILINX_SPI_NAME "xilinx_spi"
/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) /* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
...@@ -144,23 +147,14 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi, ...@@ -144,23 +147,14 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
struct spi_transfer *t) struct spi_transfer *t)
{ {
u8 bits_per_word; u8 bits_per_word;
u32 hz;
struct xilinx_spi *xspi = spi_master_get_devdata(spi->master);
bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
hz = (t) ? t->speed_hz : spi->max_speed_hz;
if (bits_per_word != 8) { if (bits_per_word != 8) {
dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
__func__, bits_per_word); __func__, bits_per_word);
return -EINVAL; return -EINVAL;
} }
if (hz && xspi->speed_hz > hz) {
dev_err(&spi->dev, "%s, unsupported clock rate %uHz\n",
__func__, hz);
return -EINVAL;
}
return 0; return 0;
} }
...@@ -304,32 +298,38 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id) ...@@ -304,32 +298,38 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int __init xilinx_spi_probe(struct platform_device *dev) static int __init xilinx_spi_of_probe(struct of_device *ofdev,
const struct of_device_id *match)
{ {
int ret = 0;
struct spi_master *master; struct spi_master *master;
struct xilinx_spi *xspi; struct xilinx_spi *xspi;
struct xspi_platform_data *pdata; struct resource r_irq_struct;
struct resource *r; struct resource r_mem_struct;
struct resource *r_irq = &r_irq_struct;
struct resource *r_mem = &r_mem_struct;
int rc = 0;
const u32 *prop;
int len;
/* Get resources(memory, IRQ) associated with the device */ /* Get resources(memory, IRQ) associated with the device */
master = spi_alloc_master(&dev->dev, sizeof(struct xilinx_spi)); master = spi_alloc_master(&ofdev->dev, sizeof(struct xilinx_spi));
if (master == NULL) { if (master == NULL) {
return -ENOMEM; return -ENOMEM;
} }
platform_set_drvdata(dev, master); dev_set_drvdata(&ofdev->dev, master);
pdata = dev->dev.platform_data;
if (pdata == NULL) { rc = of_address_to_resource(ofdev->node, 0, r_mem);
ret = -ENODEV; if (rc) {
dev_warn(&ofdev->dev, "invalid address\n");
goto put_master; goto put_master;
} }
r = platform_get_resource(dev, IORESOURCE_MEM, 0); rc = of_irq_to_resource(ofdev->node, 0, r_irq);
if (r == NULL) { if (rc == NO_IRQ) {
ret = -ENODEV; dev_warn(&ofdev->dev, "no IRQ found\n");
goto put_master; goto put_master;
} }
...@@ -341,47 +341,57 @@ static int __init xilinx_spi_probe(struct platform_device *dev) ...@@ -341,47 +341,57 @@ static int __init xilinx_spi_probe(struct platform_device *dev)
xspi->bitbang.master->setup = xilinx_spi_setup; xspi->bitbang.master->setup = xilinx_spi_setup;
init_completion(&xspi->done); init_completion(&xspi->done);
if (!request_mem_region(r->start, xspi->irq = r_irq->start;
r->end - r->start + 1, XILINX_SPI_NAME)) {
ret = -ENXIO; if (!request_mem_region(r_mem->start,
r_mem->end - r_mem->start + 1, XILINX_SPI_NAME)) {
rc = -ENXIO;
dev_warn(&ofdev->dev, "memory request failure\n");
goto put_master; goto put_master;
} }
xspi->regs = ioremap(r->start, r->end - r->start + 1); xspi->regs = ioremap(r_mem->start, r_mem->end - r_mem->start + 1);
if (xspi->regs == NULL) { if (xspi->regs == NULL) {
ret = -ENOMEM; rc = -ENOMEM;
dev_warn(&ofdev->dev, "ioremap failure\n");
goto put_master; goto put_master;
} }
xspi->irq = r_irq->start;
ret = platform_get_irq(dev, 0); /* dynamic bus assignment */
if (ret < 0) { master->bus_num = -1;
ret = -ENXIO;
goto unmap_io;
}
xspi->irq = ret;
master->bus_num = pdata->bus_num; /* number of slave select bits is required */
master->num_chipselect = pdata->num_chipselect; prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len);
xspi->speed_hz = pdata->speed_hz; if (!prop || len < sizeof(*prop)) {
dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
goto put_master;
}
master->num_chipselect = *prop;
/* SPI controller initializations */ /* SPI controller initializations */
xspi_init_hw(xspi->regs); xspi_init_hw(xspi->regs);
/* Register for SPI Interrupt */ /* Register for SPI Interrupt */
ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); rc = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
if (ret != 0) if (rc != 0) {
dev_warn(&ofdev->dev, "irq request failure: %d\n", xspi->irq);
goto unmap_io; goto unmap_io;
}
ret = spi_bitbang_start(&xspi->bitbang); rc = spi_bitbang_start(&xspi->bitbang);
if (ret != 0) { if (rc != 0) {
dev_err(&dev->dev, "spi_bitbang_start FAILED\n"); dev_err(&ofdev->dev, "spi_bitbang_start FAILED\n");
goto free_irq; goto free_irq;
} }
dev_info(&dev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n", dev_info(&ofdev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n",
r->start, (u32)xspi->regs, xspi->irq); (unsigned int)r_mem->start, (u32)xspi->regs, xspi->irq);
return ret; /* Add any subnodes on the SPI bus */
of_register_spi_devices(master, ofdev->node);
return rc;
free_irq: free_irq:
free_irq(xspi->irq, xspi); free_irq(xspi->irq, xspi);
...@@ -389,21 +399,21 @@ unmap_io: ...@@ -389,21 +399,21 @@ unmap_io:
iounmap(xspi->regs); iounmap(xspi->regs);
put_master: put_master:
spi_master_put(master); spi_master_put(master);
return ret; return rc;
} }
static int __devexit xilinx_spi_remove(struct platform_device *dev) static int __devexit xilinx_spi_remove(struct of_device *ofdev)
{ {
struct xilinx_spi *xspi; struct xilinx_spi *xspi;
struct spi_master *master; struct spi_master *master;
master = platform_get_drvdata(dev); master = platform_get_drvdata(ofdev);
xspi = spi_master_get_devdata(master); xspi = spi_master_get_devdata(master);
spi_bitbang_stop(&xspi->bitbang); spi_bitbang_stop(&xspi->bitbang);
free_irq(xspi->irq, xspi); free_irq(xspi->irq, xspi);
iounmap(xspi->regs); iounmap(xspi->regs);
platform_set_drvdata(dev, 0); dev_set_drvdata(&ofdev->dev, 0);
spi_master_put(xspi->bitbang.master); spi_master_put(xspi->bitbang.master);
return 0; return 0;
...@@ -412,27 +422,42 @@ static int __devexit xilinx_spi_remove(struct platform_device *dev) ...@@ -412,27 +422,42 @@ static int __devexit xilinx_spi_remove(struct platform_device *dev)
/* work with hotplug and coldplug */ /* work with hotplug and coldplug */
MODULE_ALIAS("platform:" XILINX_SPI_NAME); MODULE_ALIAS("platform:" XILINX_SPI_NAME);
static struct platform_driver xilinx_spi_driver = { static int __exit xilinx_spi_of_remove(struct of_device *op)
.probe = xilinx_spi_probe, {
.remove = __devexit_p(xilinx_spi_remove), return xilinx_spi_remove(op);
}
static struct of_device_id xilinx_spi_of_match[] = {
{ .compatible = "xlnx,xps-spi-2.00.a", },
{ .compatible = "xlnx,xps-spi-2.00.b", },
{}
};
MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
static struct of_platform_driver xilinx_spi_of_driver = {
.owner = THIS_MODULE,
.name = "xilinx-xps-spi",
.match_table = xilinx_spi_of_match,
.probe = xilinx_spi_of_probe,
.remove = __exit_p(xilinx_spi_of_remove),
.driver = { .driver = {
.name = XILINX_SPI_NAME, .name = "xilinx-xps-spi",
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
}; };
static int __init xilinx_spi_init(void) static int __init xilinx_spi_init(void)
{ {
return platform_driver_register(&xilinx_spi_driver); return of_register_platform_driver(&xilinx_spi_of_driver);
} }
module_init(xilinx_spi_init); module_init(xilinx_spi_init);
static void __exit xilinx_spi_exit(void) static void __exit xilinx_spi_exit(void)
{ {
platform_driver_unregister(&xilinx_spi_driver); of_unregister_platform_driver(&xilinx_spi_of_driver);
} }
module_exit(xilinx_spi_exit); module_exit(xilinx_spi_exit);
MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
MODULE_DESCRIPTION("Xilinx SPI driver"); MODULE_DESCRIPTION("Xilinx SPI driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -17,4 +17,7 @@ ...@@ -17,4 +17,7 @@
void of_register_i2c_devices(struct i2c_adapter *adap, void of_register_i2c_devices(struct i2c_adapter *adap,
struct device_node *adap_node); struct device_node *adap_node);
/* must call put_device() when done with returned i2c_client device */
struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
#endif /* __LINUX_OF_I2C_H */ #endif /* __LINUX_OF_I2C_H */
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