Re: [irda-users] [PATCH] OMAP IrDA driver

2008-12-22 Thread Trilok Soni
Hi Tony,


 +
 +/*
 + * Set the IrDA communications speed.
 + * Interrupt have to be disabled here.
 + */
 +static int omap_irda_startup(struct net_device *dev)
 +{
 + struct omap_irda *omap_ir = netdev_priv(dev);
 +
 + /* FIXME: use clk_* apis for UART3 clock*/
 + /* Enable UART3 clock and set UART3 to IrDA mode */
 + if (machine_is_omap_h2() || machine_is_omap_h3())
 + omap_writel(omap_readl(MOD_CONF_CTRL_0) | (1  31) | (1  
 15),
 + MOD_CONF_CTRL_0);

This looks like muxing on H3.

 +
 + /* Only for H2?
 +  */
 + if (omap_ir-pdata-transceiver_mode  machine_is_omap_h2()) {
 + /* Is it select_irda on H2 ? */
 + omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7,
 + FUNC_MUX_CTRL_A);
 + omap_ir-pdata-transceiver_mode(omap_ir-dev, IR_SIRMODE);
 + }
 +


I can move this to board-h3.c file instead with platform data flag probably.


-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [irda-users] [PATCH] OMAP IrDA driver

2008-12-05 Thread samuel

Hi,



On Fri, 5 Dec 2008 12:04:29 +0530, Trilok Soni [EMAIL PROTECTED]

wrote:

 This time adding LKML too.

Could you please inline the patch so that we can have an easier review ?



Cheers,

Samuel.
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [irda-users] [PATCH] OMAP IrDA driver

2008-12-05 Thread Trilok Soni
Hi Samuel,

On Fri, Dec 5, 2008 at 2:58 PM,  [EMAIL PROTECTED] wrote:

 Hi,

 On Fri, 5 Dec 2008 12:04:29 +0530, Trilok Soni [EMAIL PROTECTED]
 wrote:
 This time adding LKML too.
 Could you please inline the patch so that we can have an easier review ?

I don't have proper git-send-email integration with gmail, so I am
going to copy/paste this patch here:

From e218cd5b2f29fa3ca342a5f4074a9e3cd3cacdad Mon Sep 17 00:00:00 2001
From: Trilok Soni [EMAIL PROTECTED]
Date: Fri, 28 Nov 2008 16:49:44 +0530
Subject: [PATCH] OMAP IrDA driver

Add Texas Instruments OMAP IrDA device driver, which supports
SIR/MIR and FIR.

Signed-off-by: Trilok Soni [EMAIL PROTECTED]
---
 drivers/net/irda/Kconfig   |9 +
 drivers/net/irda/Makefile  |1 +
 drivers/net/irda/omap-ir.c |  893 
 3 files changed, 903 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/irda/omap-ir.c

diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index e631755..6af0c15 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -342,5 +342,14 @@ config MCS_FIR
  To compile it as a module, choose M here: the module will be called
  mcs7780.

+config OMAP_IR
+   tristate OMAP IrDA(SIR/MIR/FIR)
+   depends on IRDA  ARCH_OMAP
+help
+ Say Y here if you want to build support for the Texas Instruments
+ OMAP IrDA device driver, which supports SIR/MIR/FIR. This driver
+ relies on platform specific helper routines so available capabilities
+ may vary from one OMAP target to another.
+
 endmenu

diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 5d20fde..72bbc2a 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_VIA_FIR) += via-ircc.o
 obj-$(CONFIG_PXA_FICP) += pxaficp_ir.o
 obj-$(CONFIG_MCS_FIR)  += mcs7780.o
 obj-$(CONFIG_AU1000_FIR)   += au1k_ir.o
+obj-$(CONFIG_OMAP_IR)  += omap-ir.o
 # SIR drivers
 obj-$(CONFIG_IRTTY_SIR)+= irtty-sir.o  sir-dev.o
 # dongle drivers for SIR drivers
diff --git a/drivers/net/irda/omap-ir.c b/drivers/net/irda/omap-ir.c
new file mode 100644
index 000..bf29585
--- /dev/null
+++ b/drivers/net/irda/omap-ir.c
@@ -0,0 +1,893 @@
+/*
+ * BRIEF MODULE DESCRIPTION
+ *
+ * Infra-red driver for the OMAP1610-H2 and OMAP1710-H3 and H4 Platforms
+ *   (SIR/MIR/FIR modes)
+ *   (based on omap-sir.c)
+ *
+ * Copyright 2003 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *[EMAIL PROTECTED]
+ *
+ * Copyright 2004 Texas Instruments.
+ *
+ *  This program is free software; you can redistribute it and/or 
modify it
+ *  under  the terms of the GNU General  Public License as published 
by the
+ *  Free Software Foundation;  either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED  ``AS  IS'' AND   ANY  EXPRESS OR 
IMPLIED
+ *  WARRANTIES,  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED 
WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO EVENT  SHALL   THE AUTHOR  BELIABLE FOR ANY   DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED  TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; 
LOSS OF
+ *  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include linux/module.h
+#include linux/types.h
+#include linux/init.h
+#include linux/errno.h
+#include linux/netdevice.h
+#include linux/slab.h
+#include linux/rtnetlink.h
+#include linux/interrupt.h
+#include linux/delay.h
+#include linux/ioport.h
+#include linux/dma-mapping.h
+#include linux/platform_device.h
+#include linux/workqueue.h
+#include linux/io.h
+#include linux/serial.h
+
+#include net/irda/irda.h
+#include net/irda/irmod.h
+#include net/irda/wrapper.h
+#include net/irda/irda_device.h
+
+#include asm/irq.h
+#include asm/mach-types.h
+#include asm/dma.h
+
+#include mach/hardware.h
+#include mach/mux.h
+#include mach/gpio.h
+#include mach/irda.h
+
+#define UART3_EFR_EN   (1  4)
+#define UART3_MCR_EN_TCR_TLR   (1  6)
+
+#define UART3_LCR_WL_8 (3  0)
+#define UART3_LCR_SP2  (1  2)
+#define UART3_LCR_DIVEN(1  7)
+
+#define UART3_FCR_FIFO_EN  (1  0)
+#define UART3_FCR_FIFO_RX  (1  1)
+#define UART3_FCR_FIFO_TX

Re: [irda-users] [PATCH] OMAP IrDA driver

2008-12-05 Thread Tony Lindgren
Hi,

Just one comment below.

* Trilok Soni [EMAIL PROTECTED] [081205 01:48]:
 Hi Samuel,
 
 On Fri, Dec 5, 2008 at 2:58 PM,  [EMAIL PROTECTED] wrote:
 
  Hi,
 
  On Fri, 5 Dec 2008 12:04:29 +0530, Trilok Soni [EMAIL PROTECTED]
  wrote:
  This time adding LKML too.
  Could you please inline the patch so that we can have an easier review ?
 
 I don't have proper git-send-email integration with gmail, so I am
 going to copy/paste this patch here:

snip

 diff --git a/drivers/net/irda/omap-ir.c b/drivers/net/irda/omap-ir.c
 new file mode 100644
 index 000..bf29585
 --- /dev/null
 +++ b/drivers/net/irda/omap-ir.c
 @@ -0,0 +1,893 @@

snip

 +
 +/*
 + * Set the IrDA communications speed.
 + * Interrupt have to be disabled here.
 + */
 +static int omap_irda_startup(struct net_device *dev)
 +{
 + struct omap_irda *omap_ir = netdev_priv(dev);
 +
 + /* FIXME: use clk_* apis for UART3 clock*/
 + /* Enable UART3 clock and set UART3 to IrDA mode */
 + if (machine_is_omap_h2() || machine_is_omap_h3())
 + omap_writel(omap_readl(MOD_CONF_CTRL_0) | (1  31) | (1  15),
 + MOD_CONF_CTRL_0);
 +
 + /* Only for H2?
 +  */
 + if (omap_ir-pdata-transceiver_mode  machine_is_omap_h2()) {
 + /* Is it select_irda on H2 ? */
 + omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7,
 + FUNC_MUX_CTRL_A);
 + omap_ir-pdata-transceiver_mode(omap_ir-dev, IR_SIRMODE);
 + }
 +

It would be best to get rid of the machine_is this or that code in the
drivers, and pass the necessary flags in the platform_data.

Regards,

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [irda-users] [PATCH] OMAP IrDA driver

2008-12-05 Thread Felipe Balbi
On Fri, Dec 05, 2008 at 03:18:10PM +0530, Trilok Soni wrote:
 +struct omap_irda {
 + unsigned char open;
 + int speed;  /* Current IrDA speed */
 + int newspeed;
 +
 + struct net_device_stats stats;
 + struct irlap_cb *irlap;
 + struct qos_info qos;
 +
 + int rx_dma_channel;
 + int tx_dma_channel;
 +
 + dma_addr_t rx_buf_dma_phys; /* Physical address of RX DMA buffer */
 + dma_addr_t tx_buf_dma_phys; /* Physical address of TX DMA buffer */
 +
 + void *rx_buf_dma_virt;  /* Virtual address of RX DMA buffer */
 + void *tx_buf_dma_virt;  /* Virtual address of TX DMA buffer */

should these two be void __iomem * ?

 +
 + struct device *dev;
 + struct omap_irda_config *pdata;
 +};
 +
 +static inline void uart_reg_out(int idx, u8 val)
 +{
 + omap_writeb(val, idx);

__raw_writeb(), pass a reference to struct omap_irda here so you'd have
access to a void __iomem *base (read below).

 +}
 +
 +static inline u8 uart_reg_in(int idx)
 +{
 + u8 b = omap_readb(idx);

ditto.

 + return b;
 +}
 +
 +/* forward declarations */
 +static int omap_irda_set_speed(struct net_device *dev, int speed);
 +
 +static void omap_irda_start_rx_dma(struct omap_irda *omap_ir)
 +{
 + /* Configure DMA */
 + omap_set_dma_src_params(omap_ir-rx_dma_channel, 0x3, 0x0,
 + omap_ir-pdata-src_start,
 + 0, 0);
 +
 + omap_enable_dma_irq(omap_ir-rx_dma_channel, 0x01);
 +
 + omap_set_dma_dest_params(omap_ir-rx_dma_channel, 0x0, 0x1,
 + omap_ir-rx_buf_dma_phys,
 + 0, 0);
 +
 + omap_set_dma_transfer_params(omap_ir-rx_dma_channel, 0x0,
 + IRDA_SKB_MAX_MTU, 0x1,
 + 0x0, omap_ir-pdata-rx_trigger, 0);
 +
 + omap_start_dma(omap_ir-rx_dma_channel);
 +}
 +
 +static void omap_start_tx_dma(struct omap_irda *omap_ir, int size)
 +{
 + /* Configure DMA */
 + omap_set_dma_dest_params(omap_ir-tx_dma_channel, 0x03, 0x0,
 + omap_ir-pdata-dest_start, 0, 0);
 +
 + omap_enable_dma_irq(omap_ir-tx_dma_channel, 0x01);
 +
 + omap_set_dma_src_params(omap_ir-tx_dma_channel, 0x0, 0x1,
 + omap_ir-tx_buf_dma_phys,
 + 0, 0);
 +
 + omap_set_dma_transfer_params(omap_ir-tx_dma_channel, 0x0, size, 0x1,
 + 0x0, omap_ir-pdata-tx_trigger, 0);
 +
 + /* Start DMA */
 + omap_start_dma(omap_ir-tx_dma_channel);
 +}
 +
 +/* DMA RX callback - normally, we should not go here,
 + * it calls only if something is going wrong
 + */
 +static void omap_irda_rx_dma_callback(int lch, u16 ch_status, void *data)
 +{
 + struct net_device *dev = data;
 + struct omap_irda *omap_ir = netdev_priv(dev);
 +
 + printk(KERN_ERR RX Transfer error or very big frame\n);

you have a device pointer in omap_ir, use it and convert these to
dev_dbg() calls.

ditto to all below.

 +static int omap_irda_startup(struct net_device *dev)
 +{
 + struct omap_irda *omap_ir = netdev_priv(dev);
 +
 + /* FIXME: use clk_* apis for UART3 clock*/
 + /* Enable UART3 clock and set UART3 to IrDA mode */
 + if (machine_is_omap_h2() || machine_is_omap_h3())
 + omap_writel(omap_readl(MOD_CONF_CTRL_0) | (1  31) | (1  15),
 + MOD_CONF_CTRL_0);
 +
 + /* Only for H2?
 +  */
 + if (omap_ir-pdata-transceiver_mode  machine_is_omap_h2()) {
 + /* Is it select_irda on H2 ? */
 + omap_writel(omap_readl(FUNC_MUX_CTRL_A) | 7,
 + FUNC_MUX_CTRL_A);

__raw_writel/__raw_readl.

 +static int omap_irda_probe(struct platform_device *pdev)
 +{
 + struct net_device *dev;
 + struct omap_irda *omap_ir;
 + struct omap_irda_config *pdata = pdev-dev.platform_data;
 + unsigned int baudrate_mask;
 + int err = 0;
 + int irq = NO_IRQ;

you should probably have a struct resource *res = platform_get_resource(pdev, 
IORESOURCE_MEM, 0);

and use it to ioremap() the base address. Then you can stop using the
omap_read[bsl]/omap_write[bsl] calls and switch over to standard
__raw_read[bsl]/__raw_write[bsl] ones.

 +
 + if (!pdata) {
 + printk(KERN_ERR IrDA Platform data not supplied\n);

dev_dbg(pdev-dev, ..);

 + return -ENOENT;
 + }
 +
 + if (!pdata-rx_channel || !pdata-tx_channel) {
 + printk(KERN_ERR IrDA invalid rx/tx channel value\n);
dev_dbg(pdev-dev, ..);
 + return -ENOENT;
 + }
 +
 + irq = platform_get_irq(pdev, 0);
 + if (irq = 0) {
 + printk(KERN_WARNING no irq for IrDA\n);

dev_dbg(pdev-dev, ..);

 + return -ENOENT;
 + }
 +
 + dev = alloc_irdadev(sizeof(struct omap_irda));
 + if (!dev)
 + goto err_mem_1;
 +
 +

one 

Re: [PATCH] OMAP IrDA driver

2008-12-04 Thread Trilok Soni
Hi Samuel,

Any updates on when you can review this OMAP IrDA patch?

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] OMAP IrDA driver

2008-12-04 Thread Trilok Soni
This time adding LKML too.

-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni


0001-OMAP-IrDA-driver.patch
Description: Binary data


[PATCH] OMAP IrDA driver

2008-11-28 Thread Trilok Soni
-- 
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
From e218cd5b2f29fa3ca342a5f4074a9e3cd3cacdad Mon Sep 17 00:00:00 2001
From: Trilok Soni [EMAIL PROTECTED]
Date: Fri, 28 Nov 2008 16:49:44 +0530
Subject: [PATCH] OMAP IrDA driver

Add Texas Instruments OMAP IrDA device driver, which supports
SIR/MIR and FIR.

Signed-off-by: Trilok Soni [EMAIL PROTECTED]
---
 drivers/net/irda/Kconfig   |9 +
 drivers/net/irda/Makefile  |1 +
 drivers/net/irda/omap-ir.c |  893 
 3 files changed, 903 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/irda/omap-ir.c

diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index e631755..6af0c15 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -342,5 +342,14 @@ config MCS_FIR
 	  To compile it as a module, choose M here: the module will be called
 	  mcs7780.
 
+config OMAP_IR
+	tristate OMAP IrDA(SIR/MIR/FIR)
+	depends on IRDA  ARCH_OMAP
+help
+	  Say Y here if you want to build support for the Texas Instruments
+	  OMAP IrDA device driver, which supports SIR/MIR/FIR. This driver
+	  relies on platform specific helper routines so available capabilities
+	  may vary from one OMAP target to another.
+
 endmenu
 
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 5d20fde..72bbc2a 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_VIA_FIR)		+= via-ircc.o
 obj-$(CONFIG_PXA_FICP)	+= pxaficp_ir.o
 obj-$(CONFIG_MCS_FIR)	+= mcs7780.o
 obj-$(CONFIG_AU1000_FIR)	+= au1k_ir.o
+obj-$(CONFIG_OMAP_IR)		+= omap-ir.o
 # SIR drivers
 obj-$(CONFIG_IRTTY_SIR)		+= irtty-sir.o	sir-dev.o
 # dongle drivers for SIR drivers
diff --git a/drivers/net/irda/omap-ir.c b/drivers/net/irda/omap-ir.c
new file mode 100644
index 000..bf29585
--- /dev/null
+++ b/drivers/net/irda/omap-ir.c
@@ -0,0 +1,893 @@
+/*
+ * BRIEF MODULE DESCRIPTION
+ *
+ *	Infra-red driver for the OMAP1610-H2 and OMAP1710-H3 and H4 Platforms
+ *	  (SIR/MIR/FIR modes)
+ *	  (based on omap-sir.c)
+ *
+ * Copyright 2003 MontaVista Software Inc.
+ * Author: MontaVista Software, Inc.
+ *	   [EMAIL PROTECTED]
+ *
+ * Copyright 2004 Texas Instruments.
+ *
+ *  This program is free software; you can redistribute	 it and/or modify it
+ *  under  the terms of	 the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the	License, or (at your
+ *  option) any later version.
+ *
+ *  THIS  SOFTWARE  IS PROVIDED	  ``AS	IS'' AND   ANY	EXPRESS OR IMPLIED
+ *  WARRANTIES,	  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
+ *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ *  NO	EVENT  SHALL   THE AUTHOR  BE	 LIABLE FOR ANY	  DIRECT, INDIRECT,
+ *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *  NOT LIMITED	  TO, PROCUREMENT OF  SUBSTITUTE GOODS	OR SERVICES; LOSS OF
+ *  USE, DATA,	OR PROFITS; OR	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ *  ANY THEORY OF LIABILITY, WHETHER IN	 CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *  You should have received a copy of the  GNU General Public License along
+ *  with this program; if not, write  to the Free Software Foundation, Inc.,
+ *  675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include linux/module.h
+#include linux/types.h
+#include linux/init.h
+#include linux/errno.h
+#include linux/netdevice.h
+#include linux/slab.h
+#include linux/rtnetlink.h
+#include linux/interrupt.h
+#include linux/delay.h
+#include linux/ioport.h
+#include linux/dma-mapping.h
+#include linux/platform_device.h
+#include linux/workqueue.h
+#include linux/io.h
+#include linux/serial.h
+
+#include net/irda/irda.h
+#include net/irda/irmod.h
+#include net/irda/wrapper.h
+#include net/irda/irda_device.h
+
+#include asm/irq.h
+#include asm/mach-types.h
+#include asm/dma.h
+
+#include mach/hardware.h
+#include mach/mux.h
+#include mach/gpio.h
+#include mach/irda.h
+
+#define UART3_EFR_EN			(1  4)
+#define UART3_MCR_EN_TCR_TLR		(1  6)
+
+#define UART3_LCR_WL_8			(3  0)
+#define UART3_LCR_SP2			(1  2)
+#define UART3_LCR_DIVEN			(1  7)
+
+#define UART3_FCR_FIFO_EN		(1  0)
+#define UART3_FCR_FIFO_RX		(1  1)
+#define UART3_FCR_FIFO_TX		(1  2)
+#define UART3_FCR_FIFO_DMA1		(1  3)
+#define UART3_FCR_FIFO_TX_TRIG16	(1  4)
+#define UART3_FCR_FIFO_RX_TRIG16	(1  6)
+#define UART3_FCR_CONFIG	(\
+		UART3_FCR_FIFO_EN | UART3_FCR_FIFO_RX	|\
+		UART3_FCR_FIFO_TX | UART3_FCR_FIFO_DMA1 |\
+		UART3_FCR_FIFO_TX_TRIG16		|\
+		UART3_FCR_FIFO_RX_TRIG16)
+
+#define UART3_SCR_TX_TRIG1		(1  6)
+#define UART3_SCR_RX_TRIG1		(1  7)
+
+#define UART3_MDR1_RESET		(0x07)
+#define UART3_MDR1_SIR			(1  0)
+#define UART3_MDR1_MIR			(4  0)
+#define UART3_MDR1_FIR			(5  0)
+#define