Skip to contentSkip to conversation

omap irda problem

DISCUSSION andrzej zaborowski 1 participant 1 message Sep 14, 2006 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Zgembo,
I'm attaching a diff containing the bulk of IrDA related changes from my hd against current git. In some places you will find machine_is_omap_palmte() calls because "palmte" is the machine I have, but I suspect the code may be generic to 15xx machines.

I suggest you don't use kernels as old as 2.6.8 for development. Hope this helps.

CCing the mailing list for reference.

Cheers

Quoted 40 lines · Zgembo Adislic

Hi Andrzej,

I hope you had a nice time on your holiday. I do not know if you remember
but you wrote me an e-mail, explaning me how to configure irda on my omap5910. Sadly I am still strugguling with this irda configuration. In your e-mail you explaned me which registers I need to configure in order for this irda to work. And I also noticed that you have a patch for this, so I would be really thankful if you could send this patch to me.
( I am using kernel 2.6.8.1 )

Tnx,
Zgembo

Hi,

Quoted 2 lines · Zgembo Adislic

Hello all,
I am using omap5910 and kernel 2.6.8.1. I am supposed to make IrDa

operational so I can communicate with other devices (for example:
desktop PC using some terminal emulation program).

Quoted 1 line

Is there any open sorce avaible for that? Could anyone give some

advice how to start dealing with this issue (I am beginning from zero)

There's the OMAP IrDA driver in drivers/net/irda/omap-ir.c that supports 16xx and some other CPUs, but not any of 15xx out of the box. I don't know if it's as old as 2.6.8.1 but you'll probably want to upgrade your tree anyway if you want to start modifying it.

Now I have a OMAP 311 (which is 15xx) and I have been playing with this driver and I eventually got it to work (or it seems like it), with a couple of rather simple changes so it's possible that it will also work on your processor. Here are the main changes I had to make in omap-ir.c (writing from memory, I don't have the code here):

Quoted 7 lines

1) In the irq handler the driver accesses a DMA register directly to check how many bytes were received. The register is called something like CPDC and it turns out that 15xx have a different register at this address so wrong data is returned. This is because 15xx has only one CPC register per channel and 16xx and the other CPUs have separate registers for source addresses and destination addresses called CPSC and CPDC respectively (or similar). So, either change the irda driver

I really meant CSAC and CDAC but I messed up the names, sorry :-P

Quoted 51 lines

to use CPSC, cause 15xx's CPC has the same offset, or better add proper register names for 15xx in include/asm/arch/dma.h and use these. (The 15xx and 16xx DMAs also differ in other places which causes many accesses to non-existent registers in dma.c. I have patches for this)

Another idea is to use the IrDA (UART3) registers to retrieve last frame length instead of DMA registers.

2) It seems that the DMA receives always (frame length + 1) bytes instead of (frame length + 2) on my device so replace the "w - 2" with "w - 1" in the driver. However, this is strange because the documentation says that two bytes of CRC are written in the buffer with each frame.

3) I don't receive the TX Underrun interrupt, so I placed the netif_queue_wake() call in the TX dma callback. This, however, makes the driver start sending some frames too early and they overwrite endings of previous frames, at high traffic. I prevent it by polling the registers until the TX fifo drains, maybe I can find a better way later.

4) The driver leaves the OSC_12M_SEL register untouched so I zero it at init. You can skip this if you're sure that no other OS was running before Linux after machine reset. Or set OSC_12M_SEL and divide baud rate appropriately.

I also changed the driver to use the clk_* api instead of writing to clock registers.

I can't show you any code because I'm away from my computer (call it holidays...). I didn't manage to get irlan/ircomm/obex to work but it's likely that my other device was responsible, to which I was trying to connect. I just don't know which end is more broken now. Maybe it was an irda-utils version mismatch or something.

I tested rx and tx with some generated frames and they were usually transmitted correctly. I hacked up a fake tty driver on top of omap-ir.c and it works for a remote console.

Hope this helps.

Quoted 2 lines

Thanx :-)

________________________________
All-new Yahoo! Mail - Fire up a more powerful email and get things done
faster.

Signature · 1 line
balrog 2oo6
arch/arm/plat-omap/dma.c +35 -9
@@ -115,8 +115,21 @@ static void clear_lch_regs(int lch)
 	int i;
 	u32 lch_base = OMAP_DMA_BASE + lch * 0x40;
 
-	for (i = 0; i < 0x2c; i += 2)
-		omap_writew(0, lch_base + i);
+	if (cpu_is_omap15xx()) {
+		OMAP_DMA_CSDP_REG(lch) = 0;
+		OMAP_DMA_CCR_REG(lch) = 0;
+		OMAP_DMA_CICR_REG(lch) = 0;
+		OMAP_DMA_CEN_REG(lch) = 0;
+		OMAP_DMA_CFN_REG(lch) = 0;
+		OMAP_DMA_CFI_REG(lch) = 0;
+		OMAP_DMA_CEI_REG(lch) = 0;
+		OMAP1_DMA_CSSA_L_REG(lch) = 0;
+		OMAP1_DMA_CSSA_U_REG(lch) = 0;
+		OMAP1_DMA_CDSA_L_REG(lch) = 0;
+		OMAP1_DMA_CDSA_U_REG(lch) = 0;
+	} else
+		for (i = 0; i < 0x2c; i += 2)
+			omap_writew(0, lch_base + i);
 }
 
 void omap_set_dma_priority(int lch, int dst_port, int priority)
@@ -168,9 +181,11 @@ void omap_set_dma_transfer_params(int lc
 		if (sync_mode == OMAP_DMA_SYNC_FRAME)
 			OMAP_DMA_CCR_REG(lch) |= 1 << 5;
 
-		OMAP1_DMA_CCR2_REG(lch) &= ~(1 << 2);
-		if (sync_mode == OMAP_DMA_SYNC_BLOCK)
-			OMAP1_DMA_CCR2_REG(lch) |= 1 << 2;
+		if (!cpu_is_omap15xx()) {
+			OMAP1_DMA_CCR2_REG(lch) &= ~(1 << 2);
+			if (sync_mode == OMAP_DMA_SYNC_BLOCK)
+				OMAP1_DMA_CCR2_REG(lch) |= 1 << 2;
+		}
 	}
 
 	if (cpu_is_omap24xx() && dma_trigger) {
@@ -366,8 +381,13 @@ void omap_set_dma_dest_params(int lch, i
 	if (cpu_is_omap24xx())
 		OMAP2_DMA_CDSA_REG(lch) = dest_start;
 
-	OMAP_DMA_CDEI_REG(lch) = dst_ei;
-	OMAP_DMA_CDFI_REG(lch) = dst_fi;
+	if (!cpu_is_omap15xx()) {
+		OMAP_DMA_CDEI_REG(lch) = dst_ei;
+		OMAP_DMA_CDFI_REG(lch) = dst_fi;
+	} else {
+		OMAP_DMA_CEI_REG(lch) = dst_ei;
+		OMAP_DMA_CFI_REG(lch) = dst_fi;
+	}
 }
 
 void omap_set_dma_dest_index(int lch, int eidx, int fidx)
@@ -376,8 +396,14 @@ void omap_set_dma_dest_index(int lch, in
 		REVISIT_24XX();
 		return;
 	}
-	OMAP_DMA_CDEI_REG(lch) = eidx;
-	OMAP_DMA_CDFI_REG(lch) = fidx;
+
+	if (!cpu_is_omap15xx()) {
+		OMAP_DMA_CDEI_REG(lch) = eidx;
+		OMAP_DMA_CDFI_REG(lch) = fidx;
+	} else {
+		OMAP_DMA_CEI_REG(lch) = eidx;
+		OMAP_DMA_CFI_REG(lch) = fidx;
+	}
 }
 
 void omap_set_dma_dest_data_pack(int lch, int enable)
drivers/net/irda/omap-ir.c +90 -28

305 lines not on this page · raw message

include/asm-arm/arch-omap/dma.h +3 -0
@@ -73,8 +73,11 @@
 #define OMAP_DMA_CSR_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x06)
 #define OMAP_DMA_CEN_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x10)
 #define OMAP_DMA_CFN_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x12)
+#define OMAP_DMA_CFI_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x14)
+#define OMAP_DMA_CEI_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x16)
 #define OMAP_DMA_CSFI_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x14)
 #define OMAP_DMA_CSEI_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x16)
+#define OMAP_DMA_CPC_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x18)
 #define OMAP_DMA_CSAC_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x18)
 #define OMAP_DMA_CDAC_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x1a)
 #define OMAP_DMA_CDEI_REG(n)		__REG16(OMAP_DMA_BASE + 0x40 * (n) + 0x1c)
include/net/irda/irda_device.h +1 -1
@@ -215,7 +215,7 @@ struct irlap_cb *irlap_open(struct net_d
 			    const char *hw_name);
 void irlap_close(struct irlap_cb *self);
 
-/* Interface to be uses by IrLAP */
+/* Interface to be used by IrLAP */
 void irda_device_set_media_busy(struct net_device *dev, int status);
 int  irda_device_is_media_busy(struct net_device *dev);
 int  irda_device_is_receiving(struct net_device *dev);
net/irda/ircomm/ircomm_core.c +3 -3
@@ -74,7 +74,7 @@ static int __init ircomm_init(void)
 		IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	
+
 #ifdef CONFIG_PROC_FS
 	{ struct proc_dir_entry *ent;
 	ent = create_proc_entry("ircomm", 0, proc_irda);
@@ -82,9 +82,9 @@ static int __init ircomm_init(void)
 		ent->proc_fops = &ircomm_proc_fops;
 	}
 #endif /* CONFIG_PROC_FS */
-	
+
 	IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n");
-		
+
 	return 0;
 }
 
net/irda/irlap_event.c +1 -1
@@ -590,7 +590,7 @@ static int irlap_state_query(struct irla
 		if (!self->discovery_log) {
 			IRDA_WARNING("%s: discovery log is gone! "
 				     "maybe the discovery timeout has been set"
-				     " to short?\n", __FUNCTION__);
+				     " too short?\n", __FUNCTION__);
 			break;
 		}
 		hashbin_insert(self->discovery_log,
net/irda/irlap_frame.c +7 -7
@@ -406,7 +406,7 @@ static void irlap_recv_discovery_xid_rsp
 	IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
 	if (!pskb_may_pull(skb, sizeof(struct xid_frame))) {
-		IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
+		IRDA_ERROR("%s: frame too short!\n", __FUNCTION__);
 		return;
 	}
 		
@@ -477,7 +477,7 @@ static void irlap_recv_discovery_xid_cmd
 	char *text;
 
 	if (!pskb_may_pull(skb, sizeof(struct xid_frame))) {
-		IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
+		IRDA_ERROR("%s: frame too short!\n", __FUNCTION__);
 		return;
 	}
 	
@@ -521,7 +521,7 @@ static void irlap_recv_discovery_xid_cmd
 		/* Check if things are sane at this point... */
 		if((discovery_info == NULL) || 
 		   !pskb_may_pull(skb, 3)) {
-			IRDA_ERROR("%s: discovery frame to short!\n",
+			IRDA_ERROR("%s: discovery frame too short!\n",
 				   __FUNCTION__);
 			return;
 		}
@@ -1166,7 +1166,7 @@ static void irlap_recv_frmr_frame(struct
 	IRDA_ASSERT(info != NULL, return;);
 
 	if (!pskb_may_pull(skb, 4)) {
-		IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
+		IRDA_ERROR("%s: frame too short!\n", __FUNCTION__);
 		return;
 	}
 
@@ -1255,7 +1255,7 @@ static void irlap_recv_test_frame(struct
 	IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
 	if (!pskb_may_pull(skb, sizeof(*frame))) {
-		IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
+		IRDA_ERROR("%s: frame too short!\n", __FUNCTION__);
 		return;
 	}
 	frame = (struct test_frame *) skb->data;
@@ -1263,7 +1263,7 @@ static void irlap_recv_test_frame(struct
 	/* Broadcast frames must carry saddr and daddr fields */
 	if (info->caddr == CBROADCAST) {
 		if (skb->len < sizeof(struct test_frame)) {
-			IRDA_DEBUG(0, "%s() test frame to short!\n",
+			IRDA_DEBUG(0, "%s() test frame too short!\n",
 				   __FUNCTION__);
 			return;
 		}
@@ -1329,7 +1329,7 @@ int irlap_driver_rcv(struct sk_buff *skb
 
 	/* Check if frame is large enough for parsing */
 	if (!pskb_may_pull(skb, 2)) {
-		IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
+		IRDA_ERROR("%s: frame too short!\n", __FUNCTION__);
 		dev_kfree_skb(skb);
 		return -1;
 	}
net/irda/parameters.c +4 -4
@@ -160,7 +160,7 @@ static int irda_insert_integer(void *sel
 	}
 	/* Check if buffer is long enough for insertion */
 	if (len < (2+p.pl)) {
-		IRDA_WARNING("%s: buffer to short for insertion!\n",
+		IRDA_WARNING("%s: buffer too short for insertion!\n",
 			     __FUNCTION__);
 		return -1;
 	}
@@ -216,7 +216,7 @@ static int irda_extract_integer(void *se
 
 	/* Check if buffer is long enough for parsing */
 	if (len < (2+p.pl)) {
-		IRDA_WARNING("%s: buffer to short for parsing! "
+		IRDA_WARNING("%s: buffer too short for parsing! "
 			     "Need %d bytes, but len is only %d\n",
 			     __FUNCTION__, p.pl, len);
 		return -1;
@@ -304,7 +304,7 @@ static int irda_extract_string(void *sel
 
 	/* Check if buffer is long enough for parsing */
 	if (len < (2+p.pl)) {
-		IRDA_WARNING("%s: buffer to short for parsing! "
+		IRDA_WARNING("%s: buffer too short for parsing! "
 			     "Need %d bytes, but len is only %d\n",
 			     __FUNCTION__, p.pl, len);
 		return -1;
@@ -343,7 +343,7 @@ static int irda_extract_octseq(void *sel
 
 	/* Check if buffer is long enough for parsing */
 	if (len < (2+p.pl)) {
-		IRDA_WARNING("%s: buffer to short for parsing! "
+		IRDA_WARNING("%s: buffer too short for parsing! "
 			     "Need %d bytes, but len is only %d\n",
 			     __FUNCTION__, p.pl, len);
 		return -1;