spi: tegra20: Add support for mode selection
Subsystems (2)
PATCH 1/1 spi: tegra20: Add support for mode selection
From: Mirza Krak <[email protected]>
Respect the mode passed in claim_bus call.
--- drivers/spi/tegra20_slink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/spi/tegra20_slink.c +17 -0
@@ -36,6 +36,11 @@ DECLARE_GLOBAL_DATA_PTR;#define SLINK_CMD_ENB (1 << 31)#define SLINK_CMD_GO (1 << 30)#define SLINK_CMD_M_S (1 << 28) +#define SLINK_CMD_IDLE_SCLK_DRIVE_LOW (0 << 24) +#define SLINK_CMD_IDLE_SCLK_DRIVE_HIGH (1 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_LOW (2 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_HIGH (3 << 24) +#define SLINK_CMD_IDLE_SCLK_MASK (3 << 24)#define SLINK_CMD_CK_SDA (1 << 21)#define SLINK_CMD_CS_POL (1 << 13)#define SLINK_CMD_CS_VAL (1 << 12)
@@ -146,6 +151,7 @@ static int tegra30_spi_claim_bus(struct udevice *dev)struct udevice *bus = dev->parent;struct tegra30_spi_priv *priv =dev_get_priv (bus);struct spi_regs *regs = priv->regs; +unsigned int mode = priv->mode;u32 reg;/* Change SPI clock to correct frequency, PLLP_OUT0 source */
@@ -161,6 +167,17 @@ static int tegra30_spi_claim_bus(struct udevice *dev)/* Set master mode and sw controlled CS */ reg =readl (®s->command); reg |=SLINK_CMD_M_S |SLINK_CMD_CS_SOFT ; + +/* Set CPOL and CPHA */ + reg &= ~SLINK_CMD_IDLE_SCLK_MASK & ~SLINK_CMD_CK_SDA ; +if (mode &SPI_CPHA ) + reg |=SLINK_CMD_CK_SDA ; + +if (mode &SPI_CPOL ) + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_HIGH ; +else + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_LOW ; +writel (reg, ®s->command);debug ("%s: COMMAND = %08x\n" , __func__,readl (®s->command));
Signature · 1 line
2.1.0
PATCH 1/1 spi: tegra20: Add support for mode selection
ping
2015-07-20 13:56 GMT+02:00 Mirza Krak <[email protected]>:
Quoted 55 lines
From: Mirza Krak <[email protected]>
Respect the mode passed in
claim_buscall.Signed-off-by Mirza Krak <[email protected]>--- drivers/spi/tegra20_slink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/spi/tegra20_slink.c +17
-1@@ -36,6 +36,11 @@ DECLARE_GLOBAL_DATA_PTR;#define SLINK_CMD_ENB (1 << 31)#define SLINK_CMD_GO (1 << 30)#define SLINK_CMD_M_S (1 << 28) +#define SLINK_CMD_IDLE_SCLK_DRIVE_LOW (0 << 24) +#define SLINK_CMD_IDLE_SCLK_DRIVE_HIGH (1 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_LOW (2 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_HIGH (3 << 24) +#define SLINK_CMD_IDLE_SCLK_MASK (3 << 24)#define SLINK_CMD_CK_SDA (1 << 21)#define SLINK_CMD_CS_POL (1 << 13)#define SLINK_CMD_CS_VAL (1 << 12)@@ -146,6 +151,7 @@ static int tegra30_spi_claim_bus(struct udevice *dev)struct udevice *bus = dev->parent;struct tegra30_spi_priv *priv =dev_get_priv (bus);struct spi_regs *regs = priv->regs; +unsigned int mode = priv->mode;u32 reg;/* Change SPI clock to correct frequency, PLLP_OUT0 source */ @@ -161,6 +167,17 @@ static int tegra30_spi_claim_bus(struct udevice *dev)/* Set master mode and sw controlled CS */ reg =readl (®s->command); reg |=SLINK_CMD_M_S |SLINK_CMD_CS_SOFT ; + +/* Set CPOL and CPHA */ + reg &= ~SLINK_CMD_IDLE_SCLK_MASK & ~SLINK_CMD_CK_SDA ; +if (mode &SPI_CPHA ) + reg |=SLINK_CMD_CK_SDA ; + +if (mode &SPI_CPOL ) + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_HIGH ; +else + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_LOW ; +writel (reg, ®s->command);debug ("%s: COMMAND = %08x\n" , __func__,readl (®s->command)); --2.1.0
Signature · 14 lines
Med V?nliga H?lsningar / Best Regards ******************************************************************* Mirza Krak Host Mobility AB mirza.krak at hostmobility.com Anders Personsgatan 12, 416 64 G?teborg Sweden http://www.hostmobility.com Direct: +46 31 31 32 704 Phone: +46 31 31 32 700 Fax: +46 31 80 67 51 Mobile: +46 730 28 06 22 *******************************************************************
PATCH 1/1 spi: tegra20: Add support for mode selection
In reply to Mirza KrakQuoted 34 lines · Mirza Krak
From: Mirza Krak <[email protected]>
Respect the mode passed in
claim_buscall.Signed-off-by Mirza Krak <[email protected]>--- drivers/spi/tegra20_slink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/spi/tegra20_slink.c +6
-0@@ -36,6 +36,11 @@ DECLARE_GLOBAL_DATA_PTR;#define SLINK_CMD_ENB (1 << 31)#define SLINK_CMD_GO (1 << 30)#define SLINK_CMD_M_S (1 << 28) +#define SLINK_CMD_IDLE_SCLK_DRIVE_LOW (0 << 24) +#define SLINK_CMD_IDLE_SCLK_DRIVE_HIGH (1 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_LOW (2 << 24) +#define SLINK_CMD_IDLE_SCLK_PULL_HIGH (3 << 24) +#define SLINK_CMD_IDLE_SCLK_MASK (3 << 24)#define SLINK_CMD_CK_SDA (1 << 21)#define SLINK_CMD_CS_POL (1 << 13)#define SLINK_CMD_CS_VAL (1 << 12)@@ -146,6 +151,7 @@ static int tegra30_spi_claim_bus(struct udevice *dev)struct udevice *bus = dev->parent;struct tegra30_spi_priv *priv =dev_get_priv (bus);struct spi_regs *regs = priv->regs; +unsigned int mode = priv->mode;u32 reg;/* Change SPI clock to correct frequency, PLLP_OUT0 source */
drivers/spi/tegra20_slink.c static int tegra30_spi_claim_bus(struct udevice *dev) · line 172
Quoted 6 lines
drivers/spi/tegra20_slink.c +3
-0@@ -161,6 +167,17 @@ static int tegra30_spi_claim_bus(struct udevice *dev)/* Set master mode and sw controlled CS */ reg =readl (®s->command); reg |=SLINK_CMD_M_S |SLINK_CMD_CS_SOFT ; + +/* Set CPOL and CPHA */ + reg &= ~SLINK_CMD_IDLE_SCLK_MASK & ~SLINK_CMD_CK_SDA ;
I think we need to or CPOL and CPHA
what about this
reg &= ~(SLINK_CMD_IDLE_SCLK_MASK | SLINK_CMD_CK_SDA);
Quoted 12 lines
drivers/spi/tegra20_slink.c +8
-1+if (mode &SPI_CPHA ) + reg |=SLINK_CMD_CK_SDA ; + +if (mode &SPI_CPOL ) + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_HIGH ; +else + reg |=SLINK_CMD_IDLE_SCLK_DRIVE_LOW ; +writel (reg, ®s->command);debug ("%s: COMMAND = %08x\n" , __func__,readl (®s->command)); --
Quoted 2 lines
2.1.0
thanks!
Signature · 1 line
Jagan | openedev.
PATCH 1/1 spi: tegra20: Add support for mode selection
2015-09-04 13:35 GMT+02:00 Jagan Teki <[email protected]>:
Quoted 6 lines
I think we need to or CPOL and CPHA
what about this
reg &= ~(SLINK_CMD_IDLE_SCLK_MASK | SLINK_CMD_CK_SDA);
The end result should be the same as
reg &= ~SLINK_CMD_IDLE_SCLK_MASK & ~SLINK_CMD_CK_SDA;
or am I wrong?
But I can agree that it is easier to read/follow your suggestion.
Signature · 14 lines
Med V?nliga H?lsningar / Best Regards ******************************************************************* Mirza Krak Host Mobility AB mirza.krak at hostmobility.com Anders Personsgatan 12, 416 64 G?teborg Sweden http://www.hostmobility.com Direct: +46 31 31 32 704 Phone: +46 31 31 32 700 Fax: +46 31 80 67 51 Mobile: +46 730 28 06 22 *******************************************************************
PATCH 1/1 spi: tegra20: Add support for mode selection
Quoted 4 lines · Mirza Krak
2015-09-04 13:35 GMT+02:00 Jagan Teki <[email protected]>:
Quoted 3 lines
I think we need to or CPOL and CPHA
Quoted 8 lines
Quoted 3 lines
what about this
reg &= ~(SLINK_CMD_IDLE_SCLK_MASK | SLINK_CMD_CK_SDA);The end result should be the same as
reg &= ~SLINK_CMD_IDLE_SCLK_MASK & ~SLINK_CMD_CK_SDA;or am I wrong?
Yes, true.
Quoted 2 lines
But I can agree that it is easier to read/follow your suggestion.
Please make this change and send.
thanks!
Signature · 1 line
Jagan | openedev.