can: mcp251x: Allow tuning SPI mode and limit maximal SPI speed
authorAlexander Shiyan <shc_work@mail.ru>
Mon, 19 Aug 2013 11:39:21 +0000 (15:39 +0400)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 21 Aug 2013 07:28:29 +0000 (09:28 +0200)
Patch allow to use different mode settings for SPI (MODE3 for example)
and limit maximal speed according to IC datasheet.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/mcp251x.c

index ec84ce163608d1baacc840f52fc35890a6ffce37..fe7dd696957ea3d8c4f7e34b21baa866bb797b55 100644 (file)
@@ -1082,7 +1082,11 @@ static int mcp251x_can_probe(struct spi_device *spi)
        SET_NETDEV_DEV(net, &spi->dev);
 
        /* Configure the SPI bus */
-       spi->mode = SPI_MODE_0;
+       spi->mode = spi->mode ? : SPI_MODE_0;
+       if (mcp251x_is_2510(spi))
+               spi->max_speed_hz = spi->max_speed_hz ? : 5 * 1000 * 1000;
+       else
+               spi->max_speed_hz = spi->max_speed_hz ? : 10 * 1000 * 1000;
        spi->bits_per_word = 8;
        spi_setup(spi);