Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93291
b: refs/heads/master
c: 92983c2
h: refs/heads/master
i:
  93289: 3e99c78
  93287: 368049c
v: v3
  • Loading branch information
Mike Isely authored and Greg Kroah-Hartman committed Apr 25, 2008
1 parent cea23b7 commit a8b59d8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 46 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6768306c3d9568bc66dc22f8b863bfbda3e7c4d2
refs/heads/master: 92983c2121fb46f234add1c36b5e596779899d56
104 changes: 59 additions & 45 deletions trunk/drivers/usb/serial/cypress_m8.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,59 @@ static struct usb_serial_driver cypress_ca42v2_device = {
*****************************************************************************/


static int analyze_baud_rate(struct usb_serial_port *port, unsigned baud_mask)
{
int new_rate;
struct cypress_private *priv;
priv = usb_get_serial_port_data(port);

/*
* The general purpose firmware for the Cypress M8 allows for
* a maximum speed of 57600bps (I have no idea whether DeLorme
* chose to use the general purpose firmware or not), if you
* need to modify this speed setting for your own project
* please add your own chiptype and modify the code likewise.
* The Cypress HID->COM device will work successfully up to
* 115200bps (but the actual throughput is around 3kBps).
*/
new_rate = mask_to_rate(baud_mask);
if (new_rate < 0) {
dbg("%s - failed setting baud rate, untranslatable speed",
__func__);
return -1;
}
if (port->serial->dev->speed == USB_SPEED_LOW) {
/*
* Mike Isely <isely@pobox.com> 2-Feb-2008: The
* Cypress app note that describes this mechanism
* states the the low-speed part can't handle more
* than 800 bytes/sec, in which case 4800 baud is the
* safest speed for a part like that.
*/
if (new_rate > 4800) {
dbg("%s - failed setting baud rate, device incapable "
"speed %d", __func__, new_rate);
return -1;
}
}
switch (priv->chiptype) {
case CT_EARTHMATE:
if (new_rate <= 600) {
/* 300 and 600 baud rates are supported under
* the generic firmware, but are not used with
* NMEA and SiRF protocols */
dbg("%s - failed setting baud rate, unsupported speed "
"of %d on Earthmate GPS", __func__, new_rate);
return -1;
}
break;
default:
break;
}
return new_rate;
}


/* This function can either set or retrieve the current serial line settings */
static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
int parity_enable, int parity_type, int reset, int cypress_request_type)
Expand All @@ -309,54 +362,15 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m

switch(cypress_request_type) {
case CYPRESS_SET_CONFIG:

/*
* The general purpose firmware for the Cypress M8 allows for a maximum speed
* of 57600bps (I have no idea whether DeLorme chose to use the general purpose
* firmware or not), if you need to modify this speed setting for your own
* project please add your own chiptype and modify the code likewise. The
* Cypress HID->COM device will work successfully up to 115200bps (but the
* actual throughput is around 3kBps).
*/
new_baudrate = priv->baud_rate;
if (baud_mask != priv->cbr_mask) {
dbg("%s - baud rate is changing", __FUNCTION__);
if ( priv->chiptype == CT_EARTHMATE ) {
/* 300 and 600 baud rates are supported under the generic firmware,
* but are not used with NMEA and SiRF protocols */

if ( (baud_mask == B300) || (baud_mask == B600) ) {
err("%s - failed setting baud rate, unsupported speed",
__FUNCTION__);
new_baudrate = priv->baud_rate;
} else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
err("%s - failed setting baud rate, unsupported speed",
__FUNCTION__);
new_baudrate = priv->baud_rate;
}
} else if (priv->chiptype == CT_CYPHIDCOM) {
if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
err("%s - failed setting baud rate, unsupported speed",
__FUNCTION__);
new_baudrate = priv->baud_rate;
}
} else if (priv->chiptype == CT_CA42V2) {
if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
err("%s - failed setting baud rate, unsupported speed",
__FUNCTION__);
new_baudrate = priv->baud_rate;
}
} else if (priv->chiptype == CT_GENERIC) {
if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
err("%s - failed setting baud rate, unsupported speed",
__FUNCTION__);
new_baudrate = priv->baud_rate;
}
} else {
info("%s - please define your chiptype", __FUNCTION__);
new_baudrate = priv->baud_rate;
retval = analyze_baud_rate(port, baud_mask);
if (retval >= 0) {
new_baudrate = retval;
dbg("%s - New baud rate set to %d",
__func__, new_baudrate);
}
} else { /* baud rate not changing, keep the old */
new_baudrate = priv->baud_rate;
}
dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);

Expand Down

0 comments on commit a8b59d8

Please sign in to comment.