Commit 0ee70712 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

sh-sci: allow single port platform devices

Allow registration of single port sh-sci platform devices.
Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent a5660ada
...@@ -1221,43 +1221,23 @@ static int __devexit sci_remove(struct platform_device *dev) ...@@ -1221,43 +1221,23 @@ static int __devexit sci_remove(struct platform_device *dev)
return 0; return 0;
} }
/* static int __devinit sci_probe_single(struct platform_device *dev,
* Register a set of serial devices attached to a platform device. The unsigned int index,
* list is terminated with a zero flags entry, which means we expect struct plat_sci_port *p,
* all entries to have at least UPF_BOOT_AUTOCONF set. Platforms that need struct sci_port *sciport)
* remapping (such as sh64) should also set UPF_IOREMAP.
*/
static int __devinit sci_probe(struct platform_device *dev)
{ {
struct plat_sci_port *p = dev->dev.platform_data; struct sh_sci_priv *priv = platform_get_drvdata(dev);
struct sh_sci_priv *priv;
int i, ret = -EINVAL;
unsigned long flags; unsigned long flags;
int ret;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
INIT_LIST_HEAD(&priv->ports);
spin_lock_init(&priv->lock);
platform_set_drvdata(dev, priv);
#ifdef CONFIG_HAVE_CLK
priv->clk_nb.notifier_call = sci_notifier;
cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER);
#endif
for (i = 0; p && p->flags != 0; p++, i++) {
struct sci_port *sciport = &sci_ports[i];
/* Sanity check */ /* Sanity check */
if (unlikely(i == SCI_NPORTS)) { if (unlikely(index >= SCI_NPORTS)) {
dev_notice(&dev->dev, "Attempting to register port " dev_notice(&dev->dev, "Attempting to register port "
"%d when only %d are available.\n", "%d when only %d are available.\n",
i+1, SCI_NPORTS); index+1, SCI_NPORTS);
dev_notice(&dev->dev, "Consider bumping " dev_notice(&dev->dev, "Consider bumping "
"CONFIG_SERIAL_SH_SCI_NR_UARTS!\n"); "CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
break; return 0;
} }
sciport->port.mapbase = p->mapbase; sciport->port.mapbase = p->mapbase;
...@@ -1265,10 +1245,8 @@ static int __devinit sci_probe(struct platform_device *dev) ...@@ -1265,10 +1245,8 @@ static int __devinit sci_probe(struct platform_device *dev)
if (p->mapbase && !p->membase) { if (p->mapbase && !p->membase) {
if (p->flags & UPF_IOREMAP) { if (p->flags & UPF_IOREMAP) {
p->membase = ioremap_nocache(p->mapbase, 0x40); p->membase = ioremap_nocache(p->mapbase, 0x40);
if (IS_ERR(p->membase)) { if (IS_ERR(p->membase))
ret = PTR_ERR(p->membase); return PTR_ERR(p->membase);
goto err_unreg;
}
} else { } else {
/* /*
* For the simple (and majority of) cases * For the simple (and majority of) cases
...@@ -1291,9 +1269,11 @@ static int __devinit sci_probe(struct platform_device *dev) ...@@ -1291,9 +1269,11 @@ static int __devinit sci_probe(struct platform_device *dev)
ret = uart_add_one_port(&sci_uart_driver, &sciport->port); ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
if (ret && (p->flags & UPF_IOREMAP)) { if (ret) {
if (p->flags & UPF_IOREMAP)
iounmap(p->membase); iounmap(p->membase);
goto err_unreg;
return ret;
} }
INIT_LIST_HEAD(&sciport->node); INIT_LIST_HEAD(&sciport->node);
...@@ -1301,6 +1281,45 @@ static int __devinit sci_probe(struct platform_device *dev) ...@@ -1301,6 +1281,45 @@ static int __devinit sci_probe(struct platform_device *dev)
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
list_add(&sciport->node, &priv->ports); list_add(&sciport->node, &priv->ports);
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
/*
* Register a set of serial devices attached to a platform device. The
* list is terminated with a zero flags entry, which means we expect
* all entries to have at least UPF_BOOT_AUTOCONF set. Platforms that need
* remapping (such as sh64) should also set UPF_IOREMAP.
*/
static int __devinit sci_probe(struct platform_device *dev)
{
struct plat_sci_port *p = dev->dev.platform_data;
struct sh_sci_priv *priv;
int i, ret = -EINVAL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
INIT_LIST_HEAD(&priv->ports);
spin_lock_init(&priv->lock);
platform_set_drvdata(dev, priv);
#ifdef CONFIG_HAVE_CLK
priv->clk_nb.notifier_call = sci_notifier;
cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER);
#endif
if (dev->id != -1) {
ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]);
if (ret)
goto err_unreg;
} else {
for (i = 0; p && p->flags != 0; p++, i++) {
ret = sci_probe_single(dev, i, p, &sci_ports[i]);
if (ret)
goto err_unreg;
}
} }
#ifdef CONFIG_SH_STANDARD_BIOS #ifdef CONFIG_SH_STANDARD_BIOS
......
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