Skip to contentSkip to conversation

IrDA: Support for Sigmatel STIR421x chip

PATCH Applied Samuel Ortiz 3 participants 3 messages Apr 5, 2006 – Apr 7, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IrDA: Support for Sigmatel STIR421x chip

Hi David,

This patch enables support for the Sigmatel's STIR421x IrDA chip.
Once patched with Sigmatel's firmware, this chip "almost" follows the USB-IrDA spec. Thus this patch is against irda-usb.[ch].

The code has been tested by Nick Fedchik on an STIR4210 chipset based dongle.

drivers/net/irda/irda-usb.h +29 -14
index 4026af4..4e12217 100644
@@ -1,7 +1,7 @@
 /*****************************************************************************
  *
  * Filename:      irda-usb.h
- * Version:       0.9b
+ * Version:       0.10
  * Description:   IrDA-USB Driver
  * Status:        Experimental 
  * Author:        Dag Brattli <[email protected]>
@@ -9,6 +9,9 @@
  *	Copyright (C) 2001, Roman Weissgaerber <[email protected]>
  *      Copyright (C) 2000, Dag Brattli <[email protected]>
  *      Copyright (C) 2001, Jean Tourrilhes <[email protected]>
+ *      Copyright (C) 2004, SigmaTel, Inc. <irquality-0iljnS1bRDtWk0Htik3J/[email protected]>
+ *      Copyright (C) 2005, Milan Beno <[email protected]>
+ *      Copyright (C) 2006, Nick FEdchik <nick-UvdXiu2sajOKBXSJ/[email protected]>
  *          
  *	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
@@ -31,6 +34,9 @@
 #include <net/irda/irda.h>
 #include <net/irda/irda_device.h>      /* struct irlap_cb */
 
+#define PATCH_FILE_SIZE_MAX     65536
+#define PATCH_FILE_SIZE_MIN     80
+
 #define RX_COPY_THRESHOLD 200
 #define IRDA_USB_MAX_MTU 2051
 #define IRDA_USB_SPEED_MTU 64		/* Weird, but work like this */
@@ -79,15 +85,16 @@
 /* Inbound header */
 #define MEDIA_BUSY    0x80
 
-#define SPEED_2400    0x01
-#define SPEED_9600    0x02
-#define SPEED_19200   0x03
-#define SPEED_38400   0x04
-#define SPEED_57600   0x05
-#define SPEED_115200  0x06
-#define SPEED_576000  0x07
-#define SPEED_1152000 0x08
-#define SPEED_4000000 0x09
+#define SPEED_2400     0x01
+#define SPEED_9600     0x02
+#define SPEED_19200    0x03
+#define SPEED_38400    0x04
+#define SPEED_57600    0x05
+#define SPEED_115200   0x06
+#define SPEED_576000   0x07
+#define SPEED_1152000  0x08
+#define SPEED_4000000  0x09
+#define SPEED_16000000 0x0a
 
 /* Basic capabilities */
 #define IUC_DEFAULT	0x00	/* Basic device compliant with 1.0 spec */
@@ -100,11 +107,14 @@
 #define IUC_SMALL_PKT	0x10	/* Device doesn't behave with big Rx packets */
 #define IUC_MAX_WINDOW	0x20	/* Device underestimate the Rx window */
 #define IUC_MAX_XBOFS	0x40	/* Device need more xbofs than advertised */
+#define IUC_STIR_4210	0x80	/* SigmaTel 4210/4220/4116 VFIR */
 
 /* USB class definitions */
-#define USB_IRDA_HEADER   0x01
-#define USB_CLASS_IRDA    0x02 /* USB_CLASS_APP_SPEC subclass */ 
-#define USB_DT_IRDA       0x21
+#define USB_IRDA_HEADER            0x01
+#define USB_CLASS_IRDA             0x02 /* USB_CLASS_APP_SPEC subclass */ 
+#define USB_DT_IRDA                0x21
+#define USB_IRDA_SIGMATEL_HEADER   0x03
+#define IU_SIGMATEL_MAX_RX_URBS    (IU_MAX_ACTIVE_RX_URBS + USB_IRDA_SIGMATEL_HEADER)
 
 struct irda_class_desc {
 	__u8  bLength;
@@ -123,6 +133,7 @@ struct irda_class_desc {
  * (6.2.5, USB-IrDA class spec 1.0) */
 
 #define IU_REQ_GET_CLASS_DESC	0x06
+#define STIR421X_MAX_PATCH_DOWNLOAD_SIZE 1023
 
 struct irda_usb_cb {
 	struct irda_class_desc *irda_desc;
@@ -136,7 +147,8 @@ struct irda_usb_cb {
 	__u16 bulk_out_mtu;		/* Max Tx packet size in bytes */
 	__u8  bulk_int_ep;		/* Interrupt Endpoint assignments */
 
-	struct urb *rx_urb[IU_MAX_RX_URBS];	/* URBs used to receive data frames */
+	__u8  max_rx_urb;
+	struct urb **rx_urb;	        /* URBs used to receive data frames */
 	struct urb *idle_rx_urb;	/* Pointer to idle URB in Rx path */
 	struct urb *tx_urb;		/* URB used to send data frames */
 	struct urb *speed_urb;		/* URB used to send speed commands */
@@ -156,6 +168,9 @@ struct irda_usb_cb {
 	__s16 new_xbofs;		/* xbofs we need to set */
 	__u32 speed;			/* Current speed */
 	__s32 new_speed;		/* speed we need to set */
+	
+	__u8 header_length;             /* USB-IrDA frame header size */
+	int needspatch;        		/* device needs firmware patch */
 
 	struct timer_list rx_defer_timer;	/* Wait for Rx error to clear */
 };
drivers/net/irda/irda-usb.c +345 -22

527 lines not on this page · raw message

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#1 lore raw

From: Samuel Ortiz <[email protected]>
Date: Thu, 6 Apr 2006 02:21:37 +0300

Quoted 6 lines

This patch enables support for the Sigmatel's STIR421x IrDA chip.
Once patched with Sigmatel's firmware, this chip "almost" follows the USB-IrDA spec. Thus this patch is against irda-usb.[ch].

The code has been tested by Nick Fedchik on an STIR4210 chipset based dongle.

Applied, but I had to fix up an enormous amount of trailing white space on this patch too.

Also, functions such as stir421x_upload_patch() were not properly indented using tabs, it's using a 4 space indentation.

Lots of other coding style errors such as:

	if(cond) {

instead of:

	if (cond) {

You may wish to review Documentation/CodingStyle before submitting future IRDA patches.

Thanks a lot.

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

#2 lore raw
In reply to Samuel Ortiz

В сообщении от Thursday 06 April 2006 02:21 Samuel Ortiz написал(a):

Quoted 6 lines

This patch enables support for the Sigmatel's STIR421x IrDA chip. Once patched with Sigmatel's firmware, this chip "almost" follows the USB-IrDA spec. Thus this patch is against irda-usb.[ch].

The code has been tested by Nick Fedchik on an STIR4210 chipset based dongle.

I rewrote the patch agains to 2.6.16 kernel version, so now I testing it. Old problem still present - syncro while firmware loaded, as I guess. That's may be because hotplug subsustem too slow in compare to other kernel operations...

The log below shows hot it happend on my system:

Apr  7 11:23:51 titan kernel: IRDA-USB found at address 3, Vendor: 66f, 
Product: 4210
Apr  7 11:23:51 titan kernel: IrDA: Registered device irda0
Apr  7 11:23:52 titan usb.agent[5666]: ... can't load module irda-usb
Apr  7 11:23:52 titan usb.agent[5666]: missing kernel or user mode driver 
irda-usb
Apr  7 11:23:52 titan kernel: stir421x_patch_device(): No valid firmware found
Apr  7 11:23:52 titan kernel: ------------[ cut here ]------------
Apr  7 11:23:52 titan kernel: kernel BUG at net/core/dev.c:3030!
...
Apr  7 11:23:52 titan kernel: EIP is at free_netdev+0x22/0x43
...
Apr  7 11:23:52 titan kernel:  00000002 dd6c1c00 c16f1400 dea7a9b0 ...
Apr  7 11:23:52 titan firmware_helper[5810]: main: error 
loading '/lib/firmware/42101002.sb' for device '/class/firmware/1-6' with 
driver 'usb'
Apr  7 11:23:52 titan kernel:  dea7aa20 ffffffed dea7aa44 dea2ccd3 ...

--
Nick Fedchik

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642