summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@libc.org>2016-07-20 00:39:15 +0000
committerRich Felker <dalias@libc.org>2016-07-20 00:39:15 +0000
commit0455f4adc08a38b84953b1c73735769a4a32ba8a (patch)
tree0d96d67eac1cf83b1cafcccc9b4d6e533dc06c33
parent04f5ea8c3f07d35d6ba30ea95cce7da37057c16e (diff)
downloadlinux-sh-0455f4adc08a38b84953b1c73735769a4a32ba8a.tar.gz
jcore spi changes
-rw-r--r--drivers/spi/spi-jcore.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/spi/spi-jcore.c b/drivers/spi/spi-jcore.c
index 7e7b3b38710c..522fcfd322ec 100644
--- a/drivers/spi/spi-jcore.c
+++ b/drivers/spi/spi-jcore.c
@@ -19,8 +19,6 @@
#define DRV_NAME "jcore_spi"
-#define MAX_SPI_SPEED 12500000 /* 12.5 MHz */
-
#define CTRL_REG 0x0
#define DATA_REG 0x4
@@ -44,6 +42,7 @@ struct jcore_spi {
unsigned int csReg;
unsigned int speedReg;
unsigned int speed_hz;
+ unsigned int clock_freq;
};
static void jcore_spi_wait_till_ready(struct jcore_spi *hw, int timeout)
@@ -82,7 +81,10 @@ static void jcore_spi_baudrate(struct jcore_spi *hw, int speed)
{
if (speed == hw->speed_hz) return;
hw->speed_hz = speed;
- hw->speedReg = ((MAX_SPI_SPEED / speed) - 1) << 27;
+ if (speed >= hw->clock_freq/2)
+ hw->speedReg = 0;
+ else
+ hw->speedReg = ((hw->clock_freq / 2 / speed) - 1) << 27;
jcore_spi_program(hw);
dev_dbg(hw->master->dev.parent, "%s: speed=%d pre=0x%x\n",
__func__, speed, hw->speedReg);
@@ -145,6 +147,7 @@ static int jcore_spi_probe(struct platform_device *pdev)
struct jcore_spi *hw;
struct spi_master *master;
struct resource *res;
+ u32 clock_freq;
int err = -ENODEV;
master = spi_alloc_master(&pdev->dev, sizeof(struct jcore_spi));
@@ -174,6 +177,10 @@ static int jcore_spi_probe(struct platform_device *pdev)
if (!hw->base)
goto exit_busy;
+ clock_freq = 50000000;
+ of_property_read_u32(node, "clock-frequency", &clock_freq);
+ hw->clock_freq = clock_freq;
+
/* Initialize all CS bits to high. */
hw->csReg = JCORE_SPI_CTRL_CS_BITS;
jcore_spi_baudrate(hw, 400000);