
#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- linux/arch/arm/mach-sa1100/collie.c~collie_uart
+++ linux/arch/arm/mach-sa1100/collie.c
@@ -11,7 +11,7 @@
  * published by the Free Software Foundation.
  *
  * ChangeLog:
- *  03-06-2004 John Lenz <jelenz@wisc.edu>
+ *  03-06-2004 John Lenz <lenz@cs.wisc.edu>
  *  06-04-2002 Chris Larson <kergoth@digitalnemesis.net>
  *  04-16-2001 Lineo Japan,Inc. ...
  */
@@ -68,6 +68,91 @@
 
 }
 
+#ifdef CONFIG_SHARP_LOCOMO
+/*
+ * low-level UART features.
+ */
+static struct locomo_dev *uart_dev = NULL;
+
+static void collie_uart_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+	unsigned int r;
+	if (!uart_dev) return;
+	
+	r = locomo_readl(uart_dev->mapbase + LOCOMO_GPO);
+	if (mctrl & TIOCM_RTS)
+		r &= LOCOMO_GPIO_RTS;
+	else
+		r |= LOCOMO_GPIO_RTS;
+	locomo_writel(r, uart_dev->mapbase + LOCOMO_GPO);
+
+	r = locomo_readl(uart_dev->mapbase + LOCOMO_GPO);
+	if (mctrl & TIOCM_DTR)
+		r &= LOCOMO_GPIO_DTR;
+	else
+		r |= LOCOMO_GPIO_DTR;
+	locomo_writel(r, uart_dev->mapbase + LOCOMO_GPO);
+}
+
+static u_int collie_uart_get_mctrl(struct uart_port *port)
+{
+	int ret = TIOCM_CD;
+	unsigned int r;
+	if (!uart_dev) return ret;
+
+	r = locomo_readl(uart_dev->mapbase + LOCOMO_GPO);
+	if (r & LOCOMO_GPIO_CTS)
+		ret |= TIOCM_CTS;
+	if (r & LOCOMO_GPIO_DSR)
+		ret |= TIOCM_DSR;
+
+	return ret;
+}
+
+static struct sa1100_port_fns collie_port_fns __initdata = {
+	.set_mctrl	= collie_uart_set_mctrl,
+	.get_mctrl	= collie_uart_get_mctrl,
+};
+
+static int collie_uart_probe(struct locomo_dev *dev) {
+	uart_dev = dev;
+	return 0;
+}
+
+static int collie_uart_remove(struct locomo_dev *dev) {
+	uart_dev = NULL;
+	return 0;
+}
+
+static struct locomo_driver collie_uart_driver = {
+	.drv = {
+		.name = "collie_uart",
+	},
+	.devid	= LOCOMO_DEVID_UART,
+	.probe	= collie_uart_probe,
+	.remove	= collie_uart_remove,
+}; 
+
+/* base LCD drivers */
+static void collie_lcd_power(int on) {
+	/* read comadj */
+	int comadj;
+	if (FLASH_DATA(FLASH_COMADJ_MAGIC_ADR) == FLASH_COMADJ_MAJIC) {
+		comadj = FLASH_DATA(FLASH_COMADJ_DATA_ADR);
+	} else {
+		comadj = 128;
+	}
+	locomo_lcd_power(uart_dev, on, comadj);
+}
+
+static int __init collie_uart_init(void) {
+	sa1100fb_lcd_power = collie_lcd_power;
+	return locomo_driver_register(&collie_uart_driver);
+}
+device_initcall(collie_uart_init);
+
+#endif
+
 static struct resource locomo_resources[] = {
 	[0] = {
 		.start		= 0x40000000,
@@ -182,6 +267,12 @@
 {
 	sa1100_map_io();
 	iotable_init(collie_io_desc, ARRAY_SIZE(collie_io_desc));
+
+#ifdef CONFIG_SHARP_LOCOMO
+	sa1100_register_uart_fns(&collie_port_fns);
+#endif
+	sa1100_register_uart(0, 3);
+	sa1100_register_uart(1, 1);
 }
 
 MACHINE_START(COLLIE, "Sharp-Collie")

