Hi,
I'm attaching the patch that implements the OSM for the mcp2515.
Unfortunately right now I have just a mcp2510 available for testing
which doesn't support OSM, so if someone acknowledges it's OK I'll
send a proper patch. I should have an mcp2515 on a new hardware on mid
January to test it myself, but, you know, never trust the deadlines
that the hardware guy has told you ;-).
BTW it's a pity that OSM is implemented only on the mcp2515 and not on
the mcp2510. Perhaps it could be a best default mode of operation
because it gives more control to the software to account for the bus
state.
---8<----- against SVN trunk ------
--- kernel/2.6/drivers/net/can/mcp251x.c (revision 1095)
+++ kernel/2.6/drivers/net/can/mcp251x.c (working copy)
@@ -539,6 +539,7 @@
static void mcp251x_set_normal_mode(struct spi_device *spi)
{
+ struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
unsigned long timeout;
@@ -553,7 +554,10 @@
mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK);
} else {
/* Put device into normal mode */
- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL);
+ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL |
+ ((pdata->model == CAN_MCP251X_MCP2515 &&
+ priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
?
+ CANCTRL_OSM : 0));
/* Wait for the device to enter normal mode */
timeout = jiffies + HZ;
---8<----- against 2.6.33-rc1 ------
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index 9c5a153..68ec171 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -531,6 +531,7 @@ static int mcp251x_do_set_mode(struct net_device
*net, enum can_mode mode)
static void mcp251x_set_normal_mode(struct spi_device *spi)
{
+ struct mcp251x_platform_data *pdata = spi->dev.platform_data;
struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
unsigned long timeout;
@@ -545,7 +546,10 @@ static void mcp251x_set_normal_mode(struct spi_device *spi)
mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK);
} else {
/* Put device into normal mode */
- mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL);
+ mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL |
+ ((pdata->model == CAN_MCP251X_MCP2515 &&
+ priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
?
+ CANCTRL_OSM : 0));
/* Wait for the device to enter normal mode */
timeout = jiffies + HZ;
--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core