Skip to content

Commit

Permalink
Merge remote-tracking branches 'spi/topic/rspi', 'spi/topic/sc18is602…
Browse files Browse the repository at this point in the history
…', 'spi/topic/sh-msiof', 'spi/topic/spidev-test' and 'spi/topic/st-ssc4' into spi-next
  • Loading branch information
broonie committed Sep 30, 2016
6 parents 66b5a33 + aeb8f8c + 76cce7e + 6ffc84d + 8736f80 + 4253168 commit 3424ff2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11124,6 +11124,7 @@ F: Documentation/spi/
F: drivers/spi/
F: include/linux/spi/
F: include/uapi/linux/spi/
F: tools/spi/

SPIDERNET NETWORK DRIVER for CELL
M: Ishizaki Kou <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ config SPI_SC18IS602
config SPI_SH_MSIOF
tristate "SuperH MSIOF SPI controller"
depends on HAVE_CLK && HAS_DMA
depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
depends on ARCH_SHMOBILE || ARCH_RENESAS || COMPILE_TEST
help
SPI driver for SuperH and SH Mobile MSIOF blocks.

Expand Down
14 changes: 12 additions & 2 deletions drivers/spi/spi-rspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,24 @@ static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
{
int spbr;
int div = 0;
unsigned long clksrc;

/* Sets output mode, MOSI signal, and (optionally) loopback */
rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);

clksrc = clk_get_rate(rspi->clk);
while (div < 3) {
if (rspi->max_speed_hz >= clksrc/4) /* 4=(CLK/2)/2 */
break;
div++;
clksrc /= 2;
}

/* Sets transfer bit rate */
spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk),
2 * rspi->max_speed_hz) - 1;
spbr = DIV_ROUND_UP(clksrc, 2 * rspi->max_speed_hz) - 1;
rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
rspi->spcmd |= div << 2;

/* Disable dummy transmission, set byte access */
rspi_write8(rspi, SPDCR_SPLBYTE, RSPI_SPDCR);
Expand Down
9 changes: 9 additions & 0 deletions drivers/spi/spi-sc18is602.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/platform_data/sc18is602.h>
#include <linux/gpio/consumer.h>

enum chips { sc18is602, sc18is602b, sc18is603 };

Expand Down Expand Up @@ -50,6 +51,8 @@ struct sc18is602 {
u8 buffer[SC18IS602_BUFSIZ + 1];
int tlen; /* Data queued for tx in buffer */
int rindex; /* Receive data index in buffer */

struct gpio_desc *reset;
};

static int sc18is602_wait_ready(struct sc18is602 *hw, int len)
Expand Down Expand Up @@ -257,6 +260,12 @@ static int sc18is602_probe(struct i2c_client *client,
hw = spi_master_get_devdata(master);
i2c_set_clientdata(client, hw);

/* assert reset and then release */
hw->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(hw->reset))
return PTR_ERR(hw->reset);
gpiod_set_value_cansleep(hw->reset, 0);

hw->master = master;
hw->client = client;
hw->dev = dev;
Expand Down
19 changes: 11 additions & 8 deletions drivers/spi/spi-st-ssc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ static int spi_st_transfer_one(struct spi_master *master,

static void spi_st_cleanup(struct spi_device *spi)
{
int cs = spi->cs_gpio;

if (gpio_is_valid(cs))
devm_gpio_free(&spi->dev, cs);
gpio_free(spi->cs_gpio);
}

/* the spi->mode bits understood by this driver: */
Expand All @@ -201,14 +198,15 @@ static int spi_st_setup(struct spi_device *spi)
return -EINVAL;
}

if (devm_gpio_request(&spi->dev, cs, dev_name(&spi->dev))) {
ret = gpio_request(cs, dev_name(&spi->dev));
if (ret) {
dev_err(&spi->dev, "could not request gpio:%d\n", cs);
return -EINVAL;
return ret;
}

ret = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
if (ret)
return ret;
goto out_free_gpio;

spi_st_clk = clk_get_rate(spi_st->clk);

Expand All @@ -217,7 +215,8 @@ static int spi_st_setup(struct spi_device *spi)
if (sscbrg < 0x07 || sscbrg > BIT(16)) {
dev_err(&spi->dev,
"baudrate %d outside valid range %d\n", sscbrg, hz);
return -EINVAL;
ret = -EINVAL;
goto out_free_gpio;
}

spi_st->baud = spi_st_clk / (2 * sscbrg);
Expand Down Expand Up @@ -266,6 +265,10 @@ static int spi_st_setup(struct spi_device *spi)
readl_relaxed(spi_st->base + SSC_RBUF);

return 0;

out_free_gpio:
gpio_free(cs);
return ret;
}

/* Interrupt fired when TX shift register becomes empty */
Expand Down
1 change: 1 addition & 0 deletions tools/spi/spidev_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/ioctl.h>
#include <sys/stat.h>
#include <linux/types.h>
#include <linux/spi/spidev.h>
Expand Down

0 comments on commit 3424ff2

Please sign in to comment.