Skip to contentSkip to conversation

spi: mxs: Configure chipselect after block reset

PATCH Superseded Marek Vasut 3 participants 10 messages Aug 26, 2013 – Aug 27, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>
---
 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +3 -9
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 				  unsigned int max_hz, unsigned int mode)
 {
 	struct mxs_spi_slave *mxs_slave;
-	struct mxs_ssp_regs *ssp_regs;
-	int reg;
 
 	if (!spi_cs_is_valid(bus, cs)) {
 		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	mxs_slave->max_khz = max_hz / 1000;
 	mxs_slave->mode = mode;
 	mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
-	ssp_regs = mxs_slave->regs;
 
-	reg = readl(&ssp_regs->hw_ssp_ctrl0);
-	reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-	reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-	writel(reg, &ssp_regs->hw_ssp_ctrl0);
 	return &mxs_slave->slave;
 
 err_init:
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
 	mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-	writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+	writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+	       SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+	       &ssp_regs->hw_ssp_ctrl0);
 
 	reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
 	reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Quoted 43 lines · Marek Vasut

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>
---
 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 				  unsigned int max_hz, unsigned int mode)
 {
 	struct mxs_spi_slave *mxs_slave;
-	struct mxs_ssp_regs *ssp_regs;
-	int reg;
 
 	if (!spi_cs_is_valid(bus, cs)) {
 		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	mxs_slave->max_khz = max_hz / 1000;
 	mxs_slave->mode = mode;
 	mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
-	ssp_regs = mxs_slave->regs;
 
-	reg = readl(&ssp_regs->hw_ssp_ctrl0);
-	reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-	reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-	writel(reg, &ssp_regs->hw_ssp_ctrl0);
 	return &mxs_slave->slave;
 
 err_init:

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 10 lines
drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
 	mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-	writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+	writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+	       SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+	       &ssp_regs->hw_ssp_ctrl0);
 
 	reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
 	reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#2 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Dear Stefano Babic,

Quoted 63 lines · Marek Vasut
Quoted 62 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
 				  unsigned int max_hz, unsigned int mode)
 
 {
 
 	struct mxs_spi_slave *mxs_slave;
 
-	struct mxs_ssp_regs *ssp_regs;
-	int reg;
 
 	if (!spi_cs_is_valid(bus, cs)) {
 
 		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
 	mxs_slave->max_khz = max_hz / 1000;
 	mxs_slave->mode = mode;
 	mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-	ssp_regs = mxs_slave->regs;
 
-	reg = readl(&ssp_regs->hw_ssp_ctrl0);
-	reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-	reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-	writel(reg, &ssp_regs->hw_ssp_ctrl0);
drivers/spi/mxs_spi.c +3 -1
 	return &mxs_slave->slave;
 
 err_init:
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
 	mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-	writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+	writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+	       SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+	       &ssp_regs->hw_ssp_ctrl0);
 
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
 	reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
 	reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

Best regards,
Marek Vasut

#3 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Hi,

Quoted 65 lines · Marek Vasut

Dear Stefano Babic,

Quoted 63 lines · Marek Vasut
Quoted 62 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
                              unsigned int max_hz, unsigned int mode)
 
 {
 
    struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
    if (!spi_cs_is_valid(bus, cs)) {
 
            printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
    mxs_slave->max_khz = max_hz / 1000;
    mxs_slave->mode = mode;
    mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
    return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
    mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 6 lines
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
    reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
    reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

I have a simple concern about commit head msg.
spi: mxs:
spi: mxs_spi:

I preferred the second one as rest are follow the same, just for unification. Please send the v2, if your OK. then I will push it on my tree.

--
Thanks,
Jagan.

#4 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Dear Jagan Teki,

Quoted 76 lines

Hi,

Quoted 66 lines · Marek Vasut

Dear Stefano Babic,

Quoted 64 lines · Marek Vasut
Quoted 63 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
                              unsigned int max_hz, unsigned int mode)
 
 {
 
    struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
    if (!spi_cs_is_valid(bus, cs)) {
 
            printf("mxs_spi: invalid bus %d / chip select %d\n", bus,
            cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
    mxs_slave->max_khz = max_hz / 1000;
    mxs_slave->mode = mode;
    mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
    return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
    mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 6 lines
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
    reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
    reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

Quoted 7 lines

I have a simple concern about commit head msg.
spi: mxs:
spi: mxs_spi:

I preferred the second one as rest are follow the same, just for unification. Please send the v2, if your OK. then I will push it on my tree.

Can you fix that before pushing? I am fine either way.

Best regards,
Marek Vasut

#5 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Hi

Quoted 82 lines · Marek Vasut

Dear Jagan Teki,

Quoted 80 lines

Hi,

Quoted 66 lines · Marek Vasut

Dear Stefano Babic,

Quoted 64 lines · Marek Vasut
Quoted 63 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
                              unsigned int max_hz, unsigned int mode)
 
 {
 
    struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
    if (!spi_cs_is_valid(bus, cs)) {
 
            printf("mxs_spi: invalid bus %d / chip select %d\n", bus,
            cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
    mxs_slave->max_khz = max_hz / 1000;
    mxs_slave->mode = mode;
    mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
    return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
    mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 6 lines
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
    reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
    reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

I have a simple concern about commit head msg.
spi: mxs:
spi: mxs_spi:

Quoted 5 lines
Quoted 3 lines

I preferred the second one as rest are follow the same, just for unification. Please send the v2, if your OK. then I will push it on my tree.

Can you fix that before pushing? I am fine either way.

OK, sure I will do that.

--
Thanks,
Jagan.

#6 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Dear Jagan Teki,

Quoted 88 lines

Hi

Quoted 85 lines · Marek Vasut

Dear Jagan Teki,

Quoted 83 lines

Hi,

Quoted 68 lines · Marek Vasut

Dear Stefano Babic,

Quoted 66 lines · Marek Vasut
Quoted 65 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int
 bus, unsigned int cs,
 
                              unsigned int max_hz, unsigned int
                              mode)
 
 {
 
    struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
    if (!spi_cs_is_valid(bus, cs)) {
 
            printf("mxs_spi: invalid bus %d / chip select %d\n",
            bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int
 bus, unsigned int cs,
 
    mxs_slave->max_khz = max_hz / 1000;
    mxs_slave->mode = mode;
    mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
    return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
    mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
drivers/spi/mxs_spi.c +0 -0
    reg = SSP_CTRL1_SSP_MODE_SPI |
    SSP_CTRL1_WORD_LENGTH_EIGHT_BITS; reg |= (mxs_slave->mode &
    SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

I have a simple concern about commit head msg.
spi: mxs:
spi: mxs_spi:

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I preferred the second one as rest are follow the same, just for unification. Please send the v2, if your OK. then I will push it on my tree.

Can you fix that before pushing? I am fine either way.

OK, sure I will do that.

Thanks a lot!

Best regards,
Marek Vasut

#7 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Quoted 94 lines · Marek Vasut

Dear Jagan Teki,

Quoted 92 lines

Hi

Quoted 89 lines · Marek Vasut

Dear Jagan Teki,

Quoted 86 lines

Hi,

Quoted 68 lines · Marek Vasut

Dear Stefano Babic,

Quoted 66 lines · Marek Vasut
Quoted 65 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

  drivers/spi/mxs_spi.c |   12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int
 bus, unsigned int cs,
 
                               unsigned int max_hz, unsigned int
                               mode)
 
  {
 
     struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
     if (!spi_cs_is_valid(bus, cs)) {
 
             printf("mxs_spi: invalid bus %d / chip select %d\n",
             bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int
 bus, unsigned int cs,
 
     mxs_slave->max_khz = max_hz / 1000;
     mxs_slave->mode = mode;
     mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
     return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
     mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
drivers/spi/mxs_spi.c +0 -0
     reg = SSP_CTRL1_SSP_MODE_SPI |
     SSP_CTRL1_WORD_LENGTH_EIGHT_BITS; reg |= (mxs_slave->mode &
     SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

I have a simple concern about commit head msg.
spi: mxs:
spi: mxs_spi:

I preferred the second one as rest are follow the same, just for unification. Please send the v2, if your OK. then I will push it on my tree.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Can you fix that before pushing? I am fine either way.

OK, sure I will do that.

Thanks a lot!

Best regards,
Marek Vasut

Applied to u-boot-spi/master

--
Thanks,
Jagan.

#8 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

In reply to Marek Vasut
Quoted 65 lines · Marek Vasut

Dear Stefano Babic,

Quoted 63 lines · Marek Vasut
Quoted 62 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
 				  unsigned int max_hz, unsigned int mode)
 
 {
 
 	struct mxs_spi_slave *mxs_slave;
 
-	struct mxs_ssp_regs *ssp_regs;
-	int reg;
 
 	if (!spi_cs_is_valid(bus, cs)) {
 
 		printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
 	mxs_slave->max_khz = max_hz / 1000;
 	mxs_slave->mode = mode;
 	mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-	ssp_regs = mxs_slave->regs;
 
-	reg = readl(&ssp_regs->hw_ssp_ctrl0);
-	reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-	reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-	writel(reg, &ssp_regs->hw_ssp_ctrl0);
drivers/spi/mxs_spi.c +3 -1
 	return &mxs_slave->slave;
 
 err_init:
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
 	mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-	writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+	writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+	       SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+	       &ssp_regs->hw_ssp_ctrl0);
 
Quoted 6 lines
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
 	reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
 	reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

Maybe, but correctly this should be push via u-boot-spi.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#9 lore raw

PATCH v2 1/1 spi: mxs: Configure chipselect after block reset

Quoted 66 lines · Stefano Babic
Quoted 65 lines · Marek Vasut

Dear Stefano Babic,

Quoted 63 lines · Marek Vasut
Quoted 62 lines

The chipselect must be written into the CTRL0 register after the SSP block is reset, otherwise the block will always use ChipSelect #0.

Cc Fabio Estevam <[email protected]>
Cc Jagannadha Sutradharudu Teki <[email protected]>
Cc Otavio Salvador <[email protected]>
Cc Stefano Babic <[email protected]>

---

 drivers/spi/mxs_spi.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

V2: Clean up a warning that "ssp_regs" are not used

drivers/spi/mxs_spi.c +0 -8
index 3cf7142..2b9f395 100644
@@ -56,8 +56,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
                              unsigned int max_hz, unsigned int mode)
 
 {
 
    struct mxs_spi_slave *mxs_slave;
 
-   struct mxs_ssp_regs *ssp_regs;
-   int reg;
 
    if (!spi_cs_is_valid(bus, cs)) {
 
            printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
@@ -74,13 +72,7 @@ struct spi_slave *spi_setup_slave(unsigned int bus,
 unsigned int cs,
 
    mxs_slave->max_khz = max_hz / 1000;
    mxs_slave->mode = mode;
    mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
 
-   ssp_regs = mxs_slave->regs;
 
-   reg = readl(&ssp_regs->hw_ssp_ctrl0);
-   reg &= ~(MXS_SSP_CHIPSELECT_MASK);
-   reg |= cs << MXS_SSP_CHIPSELECT_SHIFT;
-
-   writel(reg, &ssp_regs->hw_ssp_ctrl0);
    return &mxs_slave->slave;

err_init:

drivers/spi/mxs_spi.c +3 -1
@@ -102,7 +94,9 @@ int spi_claim_bus(struct spi_slave *slave)
 
    mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
 
-   writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
+   writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
+          SSP_CTRL0_BUS_WIDTH_ONE_BIT,
+          &ssp_regs->hw_ssp_ctrl0);
 
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

drivers/spi/mxs_spi.c int spi_claim_bus(struct spi_slave *slave) · line 102

Quoted 2 lines
drivers/spi/mxs_spi.c +0 -0
    reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
    reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;

Can we push this via IMX tree ?

Maybe, but correctly this should be push via u-boot-spi.

Yes, I sent a comment regarding commit head msg.
Will push it on my repo once i got the response.

--
Thanks,
Jagan.