Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e21ee6a authored by Russell King's avatar Russell King
Browse files

ARM: iPAQ: move serial port support functions



No point calling sa1100_register_uart_fns early - these aren't
used until late in the boot sequence.  Also convert to gpiolib
support.

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 9c196f0f
Loading
Loading
Loading
Loading
+38 −26
Original line number Original line Diff line number Diff line
@@ -91,6 +91,9 @@ static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n)
}
}




/*
 * H3xxx flash support
 */
static struct mtd_partition h3xxx_partitions[] = {
static struct mtd_partition h3xxx_partitions[] = {
	{
	{
		.name		= "H3XXX boot firmware",
		.name		= "H3XXX boot firmware",
@@ -122,42 +125,35 @@ static struct resource h3xxx_flash_resource = {
	.flags		= IORESOURCE_MEM,
	.flags		= IORESOURCE_MEM,
};
};


static void h3xxx_mach_init(void)
{
	sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
}


/*
/*
 * low-level UART features
 * H3xxx uart support
 */
 */

static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
static void h3600_uart_set_mctrl(struct uart_port *port, u_int mctrl)
{
{
	if (port->mapbase == _Ser3UTCR0) {
	if (port->mapbase == _Ser3UTCR0) {
		if (mctrl & TIOCM_RTS)
		gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
			GPCR = GPIO_H3600_COM_RTS;
		else
			GPSR = GPIO_H3600_COM_RTS;
	}
	}
}
}


static u_int h3600_uart_get_mctrl(struct uart_port *port)
static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
{
{
	u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
	u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;


	if (port->mapbase == _Ser3UTCR0) {
	if (port->mapbase == _Ser3UTCR0) {
		int gplr = GPLR;
		/*
		/* DCD and CTS bits are inverted in GPLR by RS232 transceiver */
		 * DCD and CTS bits are inverted in GPLR by RS232 transceiver
		if (gplr & GPIO_H3600_COM_DCD)
		 */
		if (gpio_get_value(H3XXX_GPIO_COM_DCD))
			ret &= ~TIOCM_CD;
			ret &= ~TIOCM_CD;
		if (gplr & GPIO_H3600_COM_CTS)
		if (gpio_get_value(H3XXX_GPIO_COM_CTS))
			ret &= ~TIOCM_CTS;
			ret &= ~TIOCM_CTS;
	}
	}


	return ret;
	return ret;
}
}


static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
{
{
	if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */
	if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */
		assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state);
		assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state);
@@ -170,7 +166,7 @@ static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
 * Enable/Disable wake up events for this serial port.
 * Enable/Disable wake up events for this serial port.
 * Obviously, we only support this on the normal COM port.
 * Obviously, we only support this on the normal COM port.
 */
 */
static int h3600_uart_set_wake(struct uart_port *port, u_int enable)
static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
{
{
	int err = -EINVAL;
	int err = -EINVAL;


@@ -184,13 +180,20 @@ static int h3600_uart_set_wake(struct uart_port *port, u_int enable)
	return err;
	return err;
}
}


static struct sa1100_port_fns h3600_port_fns __initdata = {
static struct sa1100_port_fns h3xxx_port_fns __initdata = {
	.set_mctrl	= h3600_uart_set_mctrl,
	.set_mctrl	= h3xxx_uart_set_mctrl,
	.get_mctrl	= h3600_uart_get_mctrl,
	.get_mctrl	= h3xxx_uart_get_mctrl,
	.pm		= h3600_uart_pm,
	.pm		= h3xxx_uart_pm,
	.set_wake	= h3600_uart_set_wake,
	.set_wake	= h3xxx_uart_set_wake,
};
};



static void h3xxx_mach_init(void)
{
	sa1100_register_uart_fns(&h3xxx_port_fns);
	sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
}

/*
/*
 * helper for sa1100fb
 * helper for sa1100fb
 */
 */
@@ -227,7 +230,6 @@ static void __init h3xxx_map_io(void)
	sa1100_map_io();
	sa1100_map_io();
	iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
	iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));


	sa1100_register_uart_fns(&h3600_port_fns);
	sa1100_register_uart(0, 3); /* Common serial port */
	sa1100_register_uart(0, 3); /* Common serial port */
//	sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
//	sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */


@@ -329,7 +331,7 @@ static void __init h3100_map_io(void)


	/* Initialize h3100-specific values here */
	/* Initialize h3100-specific values here */
	GPCR = 0x0fffffff;	 /* All outputs are set low by default */
	GPCR = 0x0fffffff;	 /* All outputs are set low by default */
	GPDR = GPIO_H3600_COM_RTS  | GPIO_H3600_L3_CLOCK |
	GPDR = GPIO_H3600_L3_CLOCK |
	       GPIO_H3600_L3_MODE  | GPIO_H3600_L3_DATA  |
	       GPIO_H3600_L3_MODE  | GPIO_H3600_L3_DATA  |
	       GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
	       GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
	       H3100_DIRECT_EGPIO;
	       H3100_DIRECT_EGPIO;
@@ -364,6 +366,9 @@ static struct irda_platform_data h3100_irda_data = {
static struct gpio_default_state h3100_default_gpio[] = {
static struct gpio_default_state h3100_default_gpio[] = {
	{ H3100_GPIO_IR_ON,	GPIO_MODE_OUT0, "IrDA power" },
	{ H3100_GPIO_IR_ON,	GPIO_MODE_OUT0, "IrDA power" },
	{ H3100_GPIO_IR_FSEL,	GPIO_MODE_OUT0, "IrDA fsel" },
	{ H3100_GPIO_IR_FSEL,	GPIO_MODE_OUT0, "IrDA fsel" },
	{ H3XXX_GPIO_COM_DCD,	GPIO_MODE_IN,	"COM DCD" },
	{ H3XXX_GPIO_COM_CTS,	GPIO_MODE_IN,	"COM CTS" },
	{ H3XXX_GPIO_COM_RTS,	GPIO_MODE_OUT0,	"COM RTS" },
};
};


static void h3100_mach_init(void)
static void h3100_mach_init(void)
@@ -460,7 +465,7 @@ static void __init h3600_map_io(void)
	/* Initialize h3600-specific values here */
	/* Initialize h3600-specific values here */


	GPCR = 0x0fffffff;	 /* All outputs are set low by default */
	GPCR = 0x0fffffff;	 /* All outputs are set low by default */
	GPDR = GPIO_H3600_COM_RTS  | GPIO_H3600_L3_CLOCK |
	GPDR = GPIO_H3600_L3_CLOCK |
	       GPIO_H3600_L3_MODE  | GPIO_H3600_L3_DATA  |
	       GPIO_H3600_L3_MODE  | GPIO_H3600_L3_DATA  |
	       GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
	       GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
	       GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |
	       GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |
@@ -489,8 +494,15 @@ static struct irda_platform_data h3600_irda_data = {
	.set_speed	= h3600_irda_set_speed,
	.set_speed	= h3600_irda_set_speed,
};
};


static struct gpio_default_state h3600_default_gpio[] = {
	{ H3XXX_GPIO_COM_DCD,	GPIO_MODE_IN,	"COM DCD" },
	{ H3XXX_GPIO_COM_CTS,	GPIO_MODE_IN,	"COM CTS" },
	{ H3XXX_GPIO_COM_RTS,	GPIO_MODE_OUT0,	"COM RTS" },
};

static void h3600_mach_init(void)
static void h3600_mach_init(void)
{
{
	h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
	h3xxx_mach_init();
	h3xxx_mach_init();
	sa11x0_register_irda(&h3600_irda_data);
	sa11x0_register_irda(&h3600_irda_data);
}
}
+14 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,20 @@
#ifndef _INCLUDE_H3600_GPIO_H_
#ifndef _INCLUDE_H3600_GPIO_H_
#define _INCLUDE_H3600_GPIO_H_
#define _INCLUDE_H3600_GPIO_H_


/*
 * gpiolib numbers for all iPAQs
 */
#define H3XXX_GPIO_PWR_BUTTON		0
#define H3XXX_GPIO_PCMCIA_CD1		10
#define H3XXX_GPIO_PCMCIA_IRQ1		11
#define H3XXX_GPIO_PCMCIA_CD0		17
#define H3XXX_GPIO_SYS_CLK		19
#define H3XXX_GPIO_PCMCIA_IRQ0		21
#define H3XXX_GPIO_COM_DCD		23
#define H3XXX_GPIO_OPTION		24
#define H3XXX_GPIO_COM_CTS		25
#define H3XXX_GPIO_COM_RTS		26

/*
/*
 * GPIO lines that are common across ALL iPAQ models are in "h3600.h"
 * GPIO lines that are common across ALL iPAQ models are in "h3600.h"
 * This file contains machine-specific definitions
 * This file contains machine-specific definitions