Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343649
b: refs/heads/master
c: b15d5d7
h: refs/heads/master
i:
  343647: 03c054a
v: v3
  • Loading branch information
Jason Gunthorpe authored and Grant Likely committed Dec 6, 2012
1 parent 1289524 commit 53a0da9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 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: 746aeffdd97263d8356870a5dfbbdb5f927378e2
refs/heads/master: b15d5d7004e25716c8b8dfe4e322a64551e2e6cc
25 changes: 24 additions & 1 deletion trunk/drivers/spi/spi-orion.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
#define ORION_SPI_DATA_IN_REG 0x0c
#define ORION_SPI_INT_CAUSE_REG 0x10

#define ORION_SPI_MODE_CPOL (1 << 11)
#define ORION_SPI_MODE_CPHA (1 << 12)
#define ORION_SPI_IF_8_16_BIT_MODE (1 << 5)
#define ORION_SPI_CLK_PRESCALE_MASK 0x1F
#define ORION_SPI_MODE_MASK (ORION_SPI_MODE_CPOL | \
ORION_SPI_MODE_CPHA)

struct orion_spi {
struct spi_master *master;
Expand Down Expand Up @@ -123,6 +127,23 @@ static int orion_spi_baudrate_set(struct spi_device *spi, unsigned int speed)
return 0;
}

static void
orion_spi_mode_set(struct spi_device *spi)
{
u32 reg;
struct orion_spi *orion_spi;

orion_spi = spi_master_get_devdata(spi->master);

reg = readl(spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG));
reg &= ~ORION_SPI_MODE_MASK;
if (spi->mode & SPI_CPOL)
reg |= ORION_SPI_MODE_CPOL;
if (spi->mode & SPI_CPHA)
reg |= ORION_SPI_MODE_CPHA;
writel(reg, spi_reg(orion_spi, ORION_SPI_IF_CONFIG_REG));
}

/*
* called only when no transfer is active on the bus
*/
Expand All @@ -142,6 +163,8 @@ orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
if ((t != NULL) && t->bits_per_word)
bits_per_word = t->bits_per_word;

orion_spi_mode_set(spi);

rc = orion_spi_baudrate_set(spi, speed);
if (rc)
return rc;
Expand Down Expand Up @@ -399,7 +422,7 @@ static int __init orion_spi_probe(struct platform_device *pdev)
}

/* we support only mode 0, and no options */
master->mode_bits = 0;
master->mode_bits = SPI_CPHA | SPI_CPOL;

master->setup = orion_spi_setup;
master->transfer_one_message = orion_spi_transfer_one_message;
Expand Down

0 comments on commit 53a0da9

Please sign in to comment.