Subject: kern/33496: uslsa(4)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <jakllsch@kollasch.net>
List: netbsd-bugs
Date: 05/16/2006 15:40:01
>Number:         33496
>Category:       kern
>Synopsis:       driver for Silicon Labs CP2101
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue May 16 15:40:01 +0000 2006
>Originator:     Jonathan A. Kollasch
>Release:        NetBSD 3.99.19
>Organization:
	
>Environment:
System: NetBSD kirkkit.kollasch.net 3.0 NetBSD 3.0 (GENERIC) #0: Mon Dec 19 01:04:02 UTC 2005 builds@works.netbsd.org:/home/builds/ab/netbsd-3-0-RELEASE/i386/200512182024Z-obj/home/builds/ab/netbsd-3-0-RELEASE/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
NetBSD doesn't have a ucom(9) driver for the CP210x
>Fix:

begin 644 uslsa.c.bz2
M0EIH.3%!629361VQ-LP`!II?@$XP^_________[_____8!3\`)+XN.0ZK[U.
M^^YRNY\\>[[N'3VQIH#T+[NR+'WWOKRLSY[AWJC7VW?=TO(UUZ!0[=W<"4U"
M`)H"8"8@TU/*>31HIM$\C1/4T:-&$T#U#$`2A-`@T4\IM"49`]-09#)@0::`
M&@T``::-`E-"),4:GJ9E#)H#U&F@`&(`T'J:,@```T$FI"$-3(F%333]%/9-
M29'DC`:3S0FH,@#(&33(TP(I$R(,353_53]3-)L11H-`>D:9#30&@``&0-`$
MB()H(`(":J>39*>IZ:GZH])ZFU!D`T#T@!Z0`-T!I`#.0/GC-`6)!B=<\1^E
M\?D]_VOAK"^BW;:[MD#<K(H044$19%*J?[2PK%DF^I.FT*=\5VF=#%8:N]/A
MWUKC"%67XE9VGC.,MQ2`?RA4)0$9!@@K(P08R"@J)P&F)%@"`@D8P4B68U)*
M5(`H3VYW?6)C+N?9:Q+X2%'VY$,T89%[:,FC,2I0)<+,H2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R!
MAJ\`A-,&T$VLNZA.0VB\)X<-$:-+<<:G.:N4\;1;=G<%_*AUF;`<$&VVM&E;
MOD&@AI:]A5L:+$GTR7\W!:^N*X,FI$ZTJQ%F<=O+35Z_7,U.D%]Y!\&/NV2K
MMJ8@^\EK)M#Z7HD<%;?\(578]&82BR-4CN5V1*+RD,CT7%:5A`[M.-TQ%21F
M'D)N!(.D7<`DU:,#T$IL&*D!2P<FN:\-QNVJR7?H&DO,X(JKDQNS&(\R%`F%
MN,%KK_=:-L%>1(KVU,^JVX::R#;]@:'Q&LDLVT4/I%QS-F..6-+B+EUYJ71B
MN"@2E"$)+U0)PA=5BL!.B=RBB8,XCK?7%,]2LSBEBH'-:N:C@U:908QMIE3V
M2KOXM[X)4BXBM*,'MQ9,#M+W=D1)C7+!2DX54$Q1A"XF2KA6SCY<<,(M$392
MA")0(/MY%*/A^`>7G7+0QSD,MT7RJ1)HYBF%^.&3Q.J-:1NH*`,26"$S"]<"
MB&LT45N\2!=[3%9,`4<4S5,5J+;@'$@\LIGO@WYYSLG`;-2@UR#%F#XJ9Q2^
MC/'=,>XWZ0D^TJAW-(HML47)P.!""O@\''VY;<C>/H%,CI/-:I_Q=R13A0D*
$M<]Q<.XW
`
end

I've only tested the device with the product ID hard-coded
in the driver.  Other device IDs can be found in OpenBSD
for their uslcom(4) (added in rev 1.196 of their usbdevs file),
or in Linux's drivers/usb/serial/cp2101.c.

I'm not quite sure how to copyright this stuff, so, I pretty much
left the notices that were in the "templates" (uplcom.4 and
ugensa.c) I used.  Other ucom(9) drivers were also used for
examples.  The reverse-engineered driver from Linux was used
as hardware documentation.

This was developed on 3.0 i386, but has been ported to 3.99.19.
It was then sucessfully compiled for sparc64, however, due to
some "device problem", I was unable to actually test that.

I'm concerned about possible endianess issues in uslsa_set_flow(),
which due to my device being a cell phone data cable, I was unable
to properly test anyway.

This is the first time I've worked heavily with kernel code, and
I've had no courses in C.  So it would probably be a good idea to
look this code over carefully.