Commit 33e8a4f8 authored by Ian Campbell's avatar Ian Campbell Committed by Russell King

[ARM PATCH] 1933/1: Convert PXA serial driver to device model and implement suspend and resume

Patch from Ian Campbell

Patch 1848/1 removed the hack for preserving FFUART over sleep.

This patch adds back that support in the correct place by converting
the PXA serial driver to use the driver model and hooking up the 
suspend and resume methods.
parent 694b677f
...@@ -198,10 +198,26 @@ static struct platform_device pxafb_device = { ...@@ -198,10 +198,26 @@ static struct platform_device pxafb_device = {
.resource = pxafb_resources, .resource = pxafb_resources,
}; };
static struct platform_device ffuart_device = {
.name = "pxa2xx-uart",
.id = 0,
};
static struct platform_device btuart_device = {
.name = "pxa2xx-uart",
.id = 1,
};
static struct platform_device stuart_device = {
.name = "pxa2xx-uart",
.id = 2,
};
static struct platform_device *devices[] __initdata = { static struct platform_device *devices[] __initdata = {
&pxamci_device, &pxamci_device,
&udc_device, &udc_device,
&pxafb_device, &pxafb_device,
&ffuart_device,
&btuart_device,
&stuart_device,
}; };
static int __init pxa_init(void) static int __init pxa_init(void)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/circ_buf.h> #include <linux/circ_buf.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/device.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/hardware.h> #include <asm/hardware.h>
...@@ -804,26 +805,76 @@ static struct uart_driver serial_pxa_reg = { ...@@ -804,26 +805,76 @@ static struct uart_driver serial_pxa_reg = {
.cons = PXA_CONSOLE, .cons = PXA_CONSOLE,
}; };
static int __init serial_pxa_init(void) static int serial_pxa_suspend(struct device *_dev, u32 state, u32 level)
{ {
int i, ret; struct uart_pxa_port *sport = dev_get_drvdata(_dev);
ret = uart_register_driver(&serial_pxa_reg); if (sport && level == SUSPEND_DISABLE)
if (ret) uart_suspend_port(&serial_pxa_reg, &sport->port);
return ret;
return 0;
}
for (i = 0; i < ARRAY_SIZE(serial_pxa_ports); i++) static int serial_pxa_resume(struct device *_dev, u32 level)
uart_add_one_port(&serial_pxa_reg, &serial_pxa_ports[i].port); {
struct uart_pxa_port *sport = dev_get_drvdata(_dev);
if (sport && level == RESUME_ENABLE)
uart_resume_port(&serial_pxa_reg, &sport->port);
return 0;
}
static int serial_pxa_probe(struct device *_dev)
{
struct platform_device *dev = to_platform_device(_dev);
serial_pxa_ports[dev->id].port.dev = _dev;
uart_add_one_port(&serial_pxa_reg, &serial_pxa_ports[dev->id].port);
dev_set_drvdata(_dev, &serial_pxa_ports[dev->id]);
return 0; return 0;
} }
static void __exit serial_pxa_exit(void) static int serial_pxa_remove(struct device *_dev)
{ {
int i; struct uart_pxa_port *sport = dev_get_drvdata(_dev);
dev_set_drvdata(_dev, NULL);
for (i = 0; i < ARRAY_SIZE(serial_pxa_ports); i++) if (sport)
uart_remove_one_port(&serial_pxa_reg, &serial_pxa_ports[i].port); uart_remove_one_port(&serial_pxa_reg, &sport->port);
return 0;
}
static struct device_driver serial_pxa_driver = {
.name = "pxa2xx-uart",
.bus = &platform_bus_type,
.probe = serial_pxa_probe,
.remove = serial_pxa_remove,
.suspend = serial_pxa_suspend,
.resume = serial_pxa_resume,
};
int __init serial_pxa_init(void)
{
int ret;
ret = uart_register_driver(&serial_pxa_reg);
if (ret != 0)
return ret;
ret = driver_register(&serial_pxa_driver);
if (ret != 0)
uart_unregister_driver(&serial_pxa_reg);
return ret;
}
void __exit serial_pxa_exit(void)
{
driver_unregister(&serial_pxa_driver);
uart_unregister_driver(&serial_pxa_reg); uart_unregister_driver(&serial_pxa_reg);
} }
......
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