Commit d882cbce authored by Komal Shah's avatar Komal Shah Committed by Tony Lindgren

[PATCH] ARM: OMAP: 24xx Irda update

Attached the updated IrDA patch (integrated workqueue) with 24xx
support.
Signed-off-by: default avatarKomal Shah <komal_shah802003@yahoo.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 2ef51b0a
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <asm/arch/gpio.h> #include <asm/arch/gpio.h>
#include <asm/arch/mux.h> #include <asm/arch/mux.h>
#include <asm/arch/tc.h> #include <asm/arch/tc.h>
#include <asm/arch/irda.h>
#include <asm/arch/usb.h> #include <asm/arch/usb.h>
#include <asm/arch/common.h> #include <asm/arch/common.h>
...@@ -171,10 +172,44 @@ static struct platform_device h2_smc91x_device = { ...@@ -171,10 +172,44 @@ static struct platform_device h2_smc91x_device = {
.resource = h2_smc91x_resources, .resource = h2_smc91x_resources,
}; };
#define H2_IRDA_FIRSEL_GPIO_PIN 17
static int h2_transceiver_mode(struct device *dev, int state)
{
if (state & IR_SIRMODE)
omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 0);
else /* MIR/FIR */
omap_set_gpio_dataout(H2_IRDA_FIRSEL_GPIO_PIN, 1);
return 0;
}
static struct omap_irda_config h2_irda_data = {
.transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
};
static struct resource h2_irda_resources[] = {
[0] = {
.start = INT_UART3,
.end = INT_UART3,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device h2_irda_device = {
.name = "omapirda",
.id = 0,
.dev = {
.platform_data = &h2_irda_data,
},
.num_resources = ARRAY_SIZE(h2_irda_resources),
.resource = h2_irda_resources,
};
static struct platform_device *h2_devices[] __initdata = { static struct platform_device *h2_devices[] __initdata = {
&h2_nor_device, &h2_nor_device,
&h2_nand_device, &h2_nand_device,
&h2_smc91x_device, &h2_smc91x_device,
&h2_irda_device,
}; };
static void __init h2_init_smc91x(void) static void __init h2_init_smc91x(void)
...@@ -267,6 +302,15 @@ static void __init h2_init(void) ...@@ -267,6 +302,15 @@ static void __init h2_init(void)
// omap_cfg_reg(U19_ARMIO1); /* CD */ // omap_cfg_reg(U19_ARMIO1); /* CD */
omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */ omap_cfg_reg(BALLOUT_V8_ARMIO3); /* WP */
/* Irda */
#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7, FUNC_MUX_CTRL_A);
if (!(omap_request_gpio(H2_IRDA_FIRSEL_GPIO_PIN))) {
omap_set_gpio_direction(H2_IRDA_FIRSEL_GPIO_PIN, 0);
h2_irda_data.transceiver_mode = h2_transceiver_mode;
}
#endif
platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices)); platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
omap_board_config = h2_config; omap_board_config = h2_config;
omap_board_config_size = ARRAY_SIZE(h2_config); omap_board_config_size = ARRAY_SIZE(h2_config);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/workqueue.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
...@@ -34,9 +35,11 @@ ...@@ -34,9 +35,11 @@
#include <asm/mach/map.h> #include <asm/mach/map.h>
#include <asm/arch/gpio.h> #include <asm/arch/gpio.h>
#include <asm/arch/gpioexpander.h>
#include <asm/arch/irqs.h> #include <asm/arch/irqs.h>
#include <asm/arch/mux.h> #include <asm/arch/mux.h>
#include <asm/arch/tc.h> #include <asm/arch/tc.h>
#include <asm/arch/irda.h>
#include <asm/arch/usb.h> #include <asm/arch/usb.h>
#include <asm/arch/common.h> #include <asm/arch/common.h>
...@@ -193,11 +196,96 @@ static struct platform_device intlat_device = { ...@@ -193,11 +196,96 @@ static struct platform_device intlat_device = {
.resource = intlat_resources, .resource = intlat_resources,
}; };
/* Select between the IrDA and aGPS module
*/
static int h3_select_irda(struct device *dev, int state)
{
unsigned char expa;
int err = 0;
if ((err = read_gpio_expa(&expa, 0x26))) {
printk(KERN_ERR "Error reading from I/O EXPANDER \n");
return err;
}
/* 'P6' enable/disable IRDA_TX and IRDA_RX */
if (state & IR_SEL) { /* IrDA */
if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
printk(KERN_ERR "Error writing to I/O EXPANDER \n");
return err;
}
} else {
if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
printk(KERN_ERR "Error writing to I/O EXPANDER \n");
return err;
}
}
return err;
}
static void set_trans_mode(void *data)
{
int *mode = data;
unsigned char expa;
int err = 0;
if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
printk(KERN_ERR "Error reading from I/O expander\n");
}
expa &= ~0x03;
if (*mode & IR_SIRMODE) {
expa |= 0x01;
} else { /* MIR/FIR */
expa |= 0x03;
}
if ((err = write_gpio_expa(expa, 0x27)) != 0) {
printk(KERN_ERR "Error writing to I/O expander\n");
}
}
static int h3_transceiver_mode(struct device *dev, int mode)
{
struct omap_irda_config *irda_config = dev->platform_data;
cancel_delayed_work(irda_config->gpio_expa);
PREPARE_WORK(irda_config->gpio_expa, set_trans_mode, &mode);
schedule_work(irda_config->gpio_expa);
return 0;
}
static struct omap_irda_config h3_irda_data = {
.transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
.transceiver_mode = h3_transceiver_mode,
.select_irda = h3_select_irda,
};
static struct resource h3_irda_resources[] = {
[0] = {
.start = INT_UART3,
.end = INT_UART3,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device h3_irda_device = {
.name = "omapirda",
.id = 0,
.dev = {
.platform_data = &h3_irda_data,
},
.num_resources = ARRAY_SIZE(h3_irda_resources),
.resource = h3_irda_resources,
};
static struct platform_device *devices[] __initdata = { static struct platform_device *devices[] __initdata = {
&nor_device, &nor_device,
&nand_device, &nand_device,
&smc91x_device, &smc91x_device,
&intlat_device, &intlat_device,
&h3_irda_device,
}; };
static struct omap_usb_config h3_usb_config __initdata = { static struct omap_usb_config h3_usb_config __initdata = {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/workqueue.h>
#include <asm/hardware.h> #include <asm/hardware.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
...@@ -25,8 +26,10 @@ ...@@ -25,8 +26,10 @@
#include <asm/mach/flash.h> #include <asm/mach/flash.h>
#include <asm/arch/gpio.h> #include <asm/arch/gpio.h>
#include <asm/arch/gpioexpander.h>
#include <asm/arch/mux.h> #include <asm/arch/mux.h>
#include <asm/arch/usb.h> #include <asm/arch/usb.h>
#include <asm/arch/irda.h>
#include <asm/arch/board.h> #include <asm/arch/board.h>
#include <asm/arch/common.h> #include <asm/arch/common.h>
#include "prcm-regs.h" #include "prcm-regs.h"
...@@ -108,9 +111,93 @@ static struct platform_device h4_smc91x_device = { ...@@ -108,9 +111,93 @@ static struct platform_device h4_smc91x_device = {
.resource = h4_smc91x_resources, .resource = h4_smc91x_resources,
}; };
/* Select between the IrDA and aGPS module
*/
static int h4_select_irda(struct device *dev, int state)
{
unsigned char expa;
int err = 0;
if ((err = read_gpio_expa(&expa, 0x21))) {
printk(KERN_ERR "Error reading from I/O expander\n");
return err;
}
/* 'P6' enable/disable IRDA_TX and IRDA_RX */
if (state & IR_SEL) { /* IrDa */
if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
printk(KERN_ERR "Error writing to I/O expander\n");
return err;
}
} else {
if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
printk(KERN_ERR "Error writing to I/O expander\n");
return err;
}
}
return err;
}
static void set_trans_mode(void *data)
{
int *mode = data;
unsigned char expa;
int err = 0;
if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
printk(KERN_ERR "Error reading from I/O expander\n");
}
expa &= ~0x01;
if (!(*mode & IR_SIRMODE)) { /* MIR/FIR */
expa |= 0x01;
}
if ((err = write_gpio_expa(expa, 0x20)) != 0) {
printk(KERN_ERR "Error writing to I/O expander\n");
}
}
static int h4_transceiver_mode(struct device *dev, int mode)
{
struct omap_irda_config *irda_config = dev->platform_data;
cancel_delayed_work(&irda_config->gpio_expa);
PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
schedule_work(&irda_config->gpio_expa);
return 0;
}
static struct omap_irda_config h4_irda_data = {
.transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
.transceiver_mode = h4_transceiver_mode,
.select_irda = h4_select_irda,
};
static struct resource h4_irda_resources[] = {
[0] = {
.start = INT_24XX_UART3_IRQ,
.end = INT_24XX_UART3_IRQ,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device h4_irda_device = {
.name = "omapirda",
.id = -1,
.dev = {
.platform_data = &h4_irda_data,
},
.num_resources = 1,
.resource = h4_irda_resources,
};
static struct platform_device *h4_devices[] __initdata = { static struct platform_device *h4_devices[] __initdata = {
&h4_smc91x_device, &h4_smc91x_device,
&h4_flash_device, &h4_flash_device,
&h4_irda_device,
}; };
static inline void __init h4_init_smc91x(void) static inline void __init h4_init_smc91x(void)
...@@ -174,6 +261,10 @@ static void __init omap_h4_init(void) ...@@ -174,6 +261,10 @@ static void __init omap_h4_init(void)
* You have to mux them off in device drivers later on * You have to mux them off in device drivers later on
* if not needed. * if not needed.
*/ */
#if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
omap_cfg_reg(K15_24XX_UART3_TX);
omap_cfg_reg(K14_24XX_UART3_RX);
#endif
platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
omap_board_config = h4_config; omap_board_config = h4_config;
omap_board_config_size = ARRAY_SIZE(h4_config); omap_board_config_size = ARRAY_SIZE(h4_config);
......
...@@ -54,6 +54,10 @@ MUX_CFG_24XX("W19_24XX_SYS_NIRQ", 0x12c, 0, 1, 1, 1) ...@@ -54,6 +54,10 @@ MUX_CFG_24XX("W19_24XX_SYS_NIRQ", 0x12c, 0, 1, 1, 1)
MUX_CFG_24XX("Y20_24XX_GPIO60", 0x12c, 3, 0, 0, 1) MUX_CFG_24XX("Y20_24XX_GPIO60", 0x12c, 3, 0, 0, 1)
MUX_CFG_24XX("M15_24XX_GPIO92", 0x10a, 3, 0, 0, 1) MUX_CFG_24XX("M15_24XX_GPIO92", 0x10a, 3, 0, 0, 1)
/* UART3 */
MUX_CFG_24XX("K15_24XX_UART3_TX", 0x118, 0, 0, 0, 1)
MUX_CFG_24XX("K14_24XX_UART3_RX", 0x119, 0, 0, 0, 1)
}; };
int __init omap2_mux_init(void) int __init omap2_mux_init(void)
......
...@@ -341,12 +341,12 @@ config TOSHIBA_FIR ...@@ -341,12 +341,12 @@ config TOSHIBA_FIR
To compile it as a module, choose M here: the module will be called To compile it as a module, choose M here: the module will be called
donauboe. donauboe.
config OMAP1610_IR config OMAP_IR
tristate "OMAP1610 IrDA(SIR/MIR/FIR)" tristate "OMAP IrDA(SIR/MIR/FIR)"
depends on IRDA && ARCH_OMAP depends on IRDA && (ARCH_OMAP1 || ARCH_OMAP2)
select GPIOEXPANDER_OMAP if MACH_OMAP_H3 select GPIOEXPANDER_OMAP if (MACH_OMAP_H3 || MACH_OMAP_H4)
help help
Say Y here if you want to build support for the Omap1610 IR. Say Y here if you want to build support for the OMAP IR.
config AU1000_FIR config AU1000_FIR
tristate "Alchemy Au1000 SIR/FIR" tristate "Alchemy Au1000 SIR/FIR"
......
...@@ -43,7 +43,7 @@ obj-$(CONFIG_OLD_BELKIN_DONGLE) += old_belkin-sir.o ...@@ -43,7 +43,7 @@ obj-$(CONFIG_OLD_BELKIN_DONGLE) += old_belkin-sir.o
obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o
obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o
obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o
obj-$(CONFIG_OMAP1610_IR) += omap1610-ir.o obj-$(CONFIG_OMAP_IR) += omap-ir.o
# The SIR helper module # The SIR helper module
......
This diff is collapsed.
This diff is collapsed.
/*
* linux/include/asm-arm/arch-omap/irda.h
*
* Copyright (C) 2005 Komal Shah <komal_shah802003@yahoo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef ASMARM_ARCH_IRDA_H
#define ASMARM_ARCH_IRDA_H
/* board specific transceiver capabilities */
#define IR_SEL 1 /* Selects IrDA */
#define IR_SIRMODE 2
#define IR_FIRMODE 4
#define IR_MIRMODE 8
struct omap_irda_config {
int transceiver_cap;
int (*transceiver_mode)(struct device *dev, int mode);
int (*select_irda)(struct device *dev, int state);
/* Very specific to the needs of some platforms (h3,h4)
* having calls which can sleep in irda_set_speed.
*/
struct work_struct gpio_expa;
};
#endif
...@@ -242,6 +242,7 @@ ...@@ -242,6 +242,7 @@
#define INT_24XX_GPIO_BANK2 30 #define INT_24XX_GPIO_BANK2 30
#define INT_24XX_GPIO_BANK3 31 #define INT_24XX_GPIO_BANK3 31
#define INT_24XX_GPIO_BANK4 32 #define INT_24XX_GPIO_BANK4 32
#define INT_24XX_UART3_IRQ 74
/* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and /* Max. 128 level 2 IRQs (OMAP1610), 192 GPIOs (OMAP730) and
* 16 MPUIO lines */ * 16 MPUIO lines */
......
...@@ -410,6 +410,11 @@ enum omap24xx_index { ...@@ -410,6 +410,11 @@ enum omap24xx_index {
/* 24xx GPIO */ /* 24xx GPIO */
Y20_24XX_GPIO60, Y20_24XX_GPIO60,
M15_24XX_GPIO92, M15_24XX_GPIO92,
/* UART3 */
K15_24XX_UART3_TX,
K14_24XX_UART3_RX,
}; };
#ifdef CONFIG_OMAP_MUX #ifdef CONFIG_OMAP_MUX
......
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