Skip to contentSkip to conversation

mx5: Align SPI CS naming with i.MX53 reference manual

PATCH New Fabio Estevam 3 participants 9 messages Nov 15, 2012 – Nov 19, 2012

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/4 mx5: Align SPI CS naming with i.MX53 reference manual

From: Fabio Estevam <[email protected]>

Align SPI chip select naming with i.MX53 reference manual.

---
 arch/arm/include/asm/arch-mx5/mx5x_pins.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-mx5/mx5x_pins.h +3 -3
index 122fbee..3457f6a 100644
@@ -802,22 +802,22 @@ typedef enum iomux_input_select {
 	MX53_CSPI_IPP_CSPI_CLK_IN_SELECT_INPUT,
 	MX53_CSPI_IPP_IND_MISO_SELECT_INPUT,
 	MX53_CSPI_IPP_IND_MOSI_SELECT_INPUT,
+	MX53_CSPI_IPP_IND_SS_B_0_SELECT_INPUT,
 	MX53_CSPI_IPP_IND_SS_B_1_SELECT_INPUT,
 	MX53_CSPI_IPP_IND_SS_B_2_SELECT_INPUT,
 	MX53_CSPI_IPP_IND_SS_B_3_SELECT_INPUT,
-	MX53_CSPI_IPP_IND_SS_B_4_SELECT_INPUT,
 	MX53_ECSPI1_IPP_CSPI_CLK_IN_SELECT_INPUT,
 	MX53_ECSPI1_IPP_IND_MISO_SELECT_INPUT,
 	MX53_ECSPI1_IPP_IND_MOSI_SELECT_INPUT,
+	MX53_ECSPI1_IPP_IND_SS_B_0_SELECT_INPUT,
 	MX53_ECSPI1_IPP_IND_SS_B_1_SELECT_INPUT,
 	MX53_ECSPI1_IPP_IND_SS_B_2_SELECT_INPUT,
 	MX53_ECSPI1_IPP_IND_SS_B_3_SELECT_INPUT,
-	MX53_ECSPI1_IPP_IND_SS_B_4_SELECT_INPUT,
 	MX53_ECSPI2_IPP_CSPI_CLK_IN_SELECT_INPUT,
 	MX53_ECSPI2_IPP_IND_MISO_SELECT_INPUT,
 	MX53_ECSPI2_IPP_IND_MOSI_SELECT_INPUT,
+	MX53_ECSPI2_IPP_IND_SS_B_0_SELECT_INPUT,
 	MX53_ECSPI2_IPP_IND_SS_B_1_SELECT_INPUT,
-	MX53_ECSPI2_IPP_IND_SS_B_2_SELECT_INPUT,
 	MX53_ESAI1_IPP_IND_FSR_SELECT_INPUT,
 	MX53_ESAI1_IPP_IND_FST_SELECT_INPUT,
 	MX53_ESAI1_IPP_IND_HCKR_SELECT_INPUT,
Signature · 1 line
1.7.9.5
author reviewer
#1 lore raw

PATCH 2/4 mx5: Print CSPI clock in 'clock' command

From: Fabio Estevam <[email protected]>

Print CSPI clock in 'clock' command.

---
 arch/arm/cpu/armv7/mx5/clock.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx5/clock.c +3 -1
index 1c9223f..76c2c52 100644
@@ -928,7 +928,9 @@ int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf("IPG        %8d kHz\n", mxc_get_clock(MXC_IPG_CLK) / 1000);
 	printf("IPG PERCLK %8d kHz\n", mxc_get_clock(MXC_IPG_PERCLK) / 1000);
 	printf("DDR        %8d kHz\n", mxc_get_clock(MXC_DDR_CLK) / 1000);
-
+#ifdef CONFIG_MXC_SPI
+	printf("CSPI       %8d kHz\n", mxc_get_clock(MXC_CSPI_CLK) / 1000);
+#endif
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 mx5: Print CSPI clock in 'clock' command

Am 15.11.2012 22:23, schrieb Fabio Estevam:

Quoted 14 lines

From: Fabio Estevam <[email protected]>

Print CSPI clock in 'clock' command.

---
  arch/arm/cpu/armv7/mx5/clock.c |    4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx5/clock.c +0 -0
index 1c9223f..76c2c52 100644

arch/arm/cpu/armv7/mx5/clock.c int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 933

Quoted 7 lines
arch/arm/cpu/armv7/mx5/clock.c +3 -1
@@ -928,7 +928,9 @@ int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  	printf("IPG        %8d kHz\n", mxc_get_clock(MXC_IPG_CLK) / 1000);
  	printf("IPG PERCLK %8d kHz\n", mxc_get_clock(MXC_IPG_PERCLK) / 1000);
  	printf("DDR        %8d kHz\n", mxc_get_clock(MXC_DDR_CLK) / 1000);
-
+#ifdef CONFIG_MXC_SPI
+	printf("CSPI       %8d kHz\n", mxc_get_clock(MXC_CSPI_CLK) / 1000);
+#endif

I wondered if we want something similar for i.MX6, too. And found that we have this on i.MX6, already. But without #ifdef.

http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/clock.c;h=a01d96f48e04377d705b7a587ec7b3ea59aee283;hb=HEAD#l407

Do we want to add the #ifdef for i.MX6, too? Or would it be nicer to drop the #ifdef in this patch to make i.MX6 and i.MX5 equal?

Best regards

Dirk

author reviewer
#3 lore raw

PATCH 2/4 mx5: Print CSPI clock in 'clock' command

Hi Dirk,

Quoted 7 lines · Dirk Behme

I wondered if we want something similar for i.MX6, too. And found that we have this on i.MX6, already. But without #ifdef.

http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/clock.c;h=a01d96f48e04377d705b7a587ec7b3ea59aee283;hb=HEAD#l407

Do we want to add the #ifdef for i.MX6, too? Or would it be nicer to drop the #ifdef in this patch to make i.MX6 and i.MX5 equal?

The reason I added the ifdef was to avoid showing the cspi clock on a board that does not use cspi. This would help
not 'polluting' the clock command output.

Regards,

Fabio Estevam

#4 lore raw

PATCH 2/4 mx5: Print CSPI clock in 'clock' command

Quoted 7 lines · Fabio Estevam

Hi Dirk,

Quoted 3 lines · Dirk Behme

I wondered if we want something similar for i.MX6, too. And found that we have this on i.MX6, already. But without #ifdef.

Quoted 9 lines
Quoted 4 lines

http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=arch/arm/cpu/armv7/mx6/clock.c;h=a01d96f48e04377d705b7a587ec7b3ea59aee283;hb=HEAD#l407

Do we want to add the #ifdef for i.MX6, too? Or would it be nicer to drop the #ifdef in this patch to make i.MX6 and i.MX5 equal?

The reason I added the ifdef was to avoid showing the cspi clock on a board that does not use cspi. This would help
not 'polluting' the clock command output.

Agree. Boards that do not support SPI can have a completely wrong value,.

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
=====================================================================
author reviewer
#5 lore raw

PATCH 3/4 spi: mxc_spi: Fix handling of chip select

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

In decode_cs() function the polarity of the chip select must be taken into account.

Also, for the case of low active chip select, the CS was activated too early.

---
 drivers/spi/mxc_spi.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/spi/mxc_spi.c +3 -2
index 13bebe8..4bed4f0 100644
@@ -387,7 +387,7 @@ static int decode_cs(struct mxc_spi_slave *mxcs, unsigned int cs)
 	if (cs > 3) {
 		mxcs->gpio = cs >> 8;
 		cs &= 3;
-		ret = gpio_direction_output(mxcs->gpio, 0);
+		ret = gpio_direction_output(mxcs->gpio, !(mxcs->ss_pol));
 		if (ret) {
 			printf("mxc_spi: cannot setup gpio %d\n", mxcs->gpio);
 			return -EINVAL;
@@ -414,6 +414,8 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 		return NULL;
 	}
 
+	mxcs->ss_pol = (mode & SPI_CS_HIGH) ? 1 : 0;
+
 	ret = decode_cs(mxcs, cs);
 	if (ret < 0) {
 		free(mxcs);
@@ -425,7 +427,6 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	mxcs->slave.bus = bus;
 	mxcs->slave.cs = cs;
 	mxcs->base = spi_bases[bus];
-	mxcs->ss_pol = (mode & SPI_CS_HIGH) ? 1 : 0;
 
 	ret = spi_cfg_mxc(mxcs, cs, max_hz, mode);
 	if (ret) {
Signature · 1 line
1.7.9.5
author reviewer
#6 lore raw

PATCH 4/4 spi: mxc_spi: Fix spi clock glitch durant reset

In reply to Fabio Estevam

From: Fabio Estevam <[email protected]>

Measuring the spi clock line on a scope shows a 'glitch' during the reset of the spi.

Fix this by toggling only the MXC_CSPICTRL_EN bit, so that the clock line becomes always stable.

---
 drivers/spi/mxc_spi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/mxc_spi.c +2 -2
index 4bed4f0..102fca5 100644
@@ -140,8 +140,8 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs,
 	reg_ctrl = reg_read(&regs->ctrl);
 
 	/* Reset spi */
-	reg_write(&regs->ctrl, 0);
-	reg_write(&regs->ctrl, (reg_ctrl | 0x1));
+	reg_write(&regs->ctrl, (reg_ctrl & ~MXC_CSPICTRL_EN));
+	reg_write(&regs->ctrl, (reg_ctrl | MXC_CSPICTRL_EN));
 
 	/*
 	 * The following computation is taken directly from Freescale's code.
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 4/4 spi: mxc_spi: Fix spi clock glitch durant reset

Quoted 18 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Measuring the spi clock line on a scope shows a 'glitch' during the reset of the spi.

Fix this by toggling only the MXC_CSPICTRL_EN bit, so that the clock line becomes always stable.

---
 drivers/spi/mxc_spi.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/mxc_spi.c +0 -0
index 4bed4f0..102fca5 100644

drivers/spi/mxc_spi.c static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs, · line 145

Quoted 8 lines
drivers/spi/mxc_spi.c +2 -2
@@ -140,8 +140,8 @@ static s32 spi_cfg_mxc(struct mxc_spi_slave *mxcs, unsigned int cs,
 	reg_ctrl = reg_read(&regs->ctrl);
 
 	/* Reset spi */
-	reg_write(&regs->ctrl, 0);
-	reg_write(&regs->ctrl, (reg_ctrl | 0x1));
+	reg_write(&regs->ctrl, (reg_ctrl & ~MXC_CSPICTRL_EN));
+	reg_write(&regs->ctrl, (reg_ctrl | MXC_CSPICTRL_EN));
 

Right - the enabled was set after clearing the register, but before setting it.

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
=====================================================================
#8 lore raw

PATCH 1/4 mx5: Align SPI CS naming with i.MX53 reference manual

In reply to Fabio Estevam
Quoted 6 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Align SPI chip select naming with i.MX53 reference manual.

---

Applied (whole series) to u-boot-imx, thanks.

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
=====================================================================