From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755506AbcECIO2 (ORCPT ); Tue, 3 May 2016 04:14:28 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:35601 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbcECIOY (ORCPT ); Tue, 3 May 2016 04:14:24 -0400 Date: Tue, 3 May 2016 10:14:22 +0200 From: Johan Hovold To: Mathieu OTHACEHE Cc: johan@kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: serial: ti_usb_3410_5052: add MOXA UPORT 11x0 support Message-ID: <20160503081422.GC25025@localhost> References: <20160502180407.GA4330@gmail.com> <20160502183715.GA4453@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160502183715.GA4453@gmail.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 02, 2016 at 08:37:15PM +0200, Mathieu OTHACEHE wrote: > Hi Johan, > > Thanks for your review. > > > Looks like this code could use a few vid/pid temporaries. > > > I'm not sure it makes sense to try to load a "ti_usb-v110a-p1150.fw" > > firmware before requesting the moxa firmware. Avoids a confusing: > > > usb 1-2.2: Direct firmware load for ti_usb-v110a-p1150.fw failed with error -2 > > > message too. > > I'm not sure to get your point here, shall I rename moxa firmwares in > linux-firmware repo to be compliant with ti_usb-v%04x-p%04x.fw format ? No, I was trying to say that the we should not attempt to load a firmware on the "ti_usb-v%04x-p%04x.fw" format before loading the moxa firmware. I guess the moxa firmware names have been chosen by Moxa and it might be confusing if we renamed them, but that could be an option too. > > I did a quick test of the patch using a Moxa 1150-device. Works at > > 115200, but communication appeared broken at 9600. Looks like the baud > > rate calculations are similar but not identical to what the Moxa driver > > does. Is this something you have looked into? > > Well, on my moxa 1110 communication is working at 9600, 115200 and > other baud rates. I must have messed something up in my test, as now 9600 seems to work. > However, I think baud rate calculation may be wrong for TI3410 chips. > > According to table 5-13 in datasheet http://www.ti.com/lit/ds/symlink/tusb3410.pdf > the baud rate calculation formula, is : > > baud_rate = 923077 / (desired_baud_rate) > > So, we get : > > desired_baud = 9600 -> baud_rate = 923077 / 9600 = 96 > desired_baud = 115200 -> baud_rate = 923077 / 115200 = 8 > ... > > In ti_usb_3410_5052 driver, the formula used for 3410 is : > > baud_rate = (923077 + desired_baud_rate/2) / desired_baud_rate > > so, > > desired_baud = 9600 -> baud_rate = (923077 + 9600/2) / 9600 = 97 (!= 96) > desired_baud = 115200 -> baud_rate = (923077 + 115200/2) / 115200 = 9 (!= 8) > > It seems the formula is wrong but some firmware deal with it anyway. > Should I correct the formula or use a quirk for moxa devices ? No, that's just integer-division with rounding. Remember that the divisions above are integer divisions so the results are actually 96 and 8 as expected. Thanks, Johan