From: Jagan Teki <jteki@openedev.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 03/27] spi: Use mode for rx mode flags
Date: Thu, 11 Aug 2016 13:37:25 +0530 [thread overview]
Message-ID: <1470902869-22570-3-git-send-email-jteki@openedev.com> (raw)
In-Reply-To: <1470902869-22570-1-git-send-email-jteki@openedev.com>
Make rx mode flags as generic to spi, earlier mode_rx is
maintained separately because of some flash specific code.
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Cc: Vignesh R <vigneshr@ti.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
---
drivers/mtd/spi/spi_flash.c | 6 +++---
drivers/spi/cadence_qspi.c | 2 +-
drivers/spi/ich.c | 6 ++----
drivers/spi/spi-uclass.c | 11 ++++-------
drivers/spi/ti_qspi.c | 6 +++---
include/spi.h | 14 ++++----------
6 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 5fd408c..041b64f 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -1172,11 +1172,11 @@ int spi_flash_scan(struct spi_flash *flash)
/* Look for read commands */
flash->read_cmd = CMD_READ_ARRAY_FAST;
- if (spi->mode_rx & SPI_RX_SLOW)
+ if (spi->mode & SPI_RX_SLOW)
flash->read_cmd = CMD_READ_ARRAY_SLOW;
- else if (spi->mode_rx & SPI_RX_QUAD && params->flags & RD_QUAD)
+ else if (spi->mode & SPI_RX_QUAD && params->flags & RD_QUAD)
flash->read_cmd = CMD_READ_QUAD_OUTPUT_FAST;
- else if (spi->mode_rx & SPI_RX_DUAL && params->flags & RD_DUAL)
+ else if (spi->mode & SPI_RX_DUAL && params->flags & RD_DUAL)
flash->read_cmd = CMD_READ_DUAL_OUTPUT_FAST;
/* Look for write commands */
diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c
index a5244ff..1d50f13 100644
--- a/drivers/spi/cadence_qspi.c
+++ b/drivers/spi/cadence_qspi.c
@@ -251,7 +251,7 @@ static int cadence_spi_xfer(struct udevice *dev, unsigned int bitlen,
break;
case CQSPI_INDIRECT_READ:
err = cadence_qspi_apb_indirect_read_setup(plat,
- priv->cmd_len, dm_plat->mode_rx, cmd_buf);
+ priv->cmd_len, dm_plat->mode, cmd_buf);
if (!err) {
err = cadence_qspi_apb_indirect_read_execute
(plat, data_bytes, din);
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 00b2fed..caf0103 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -649,10 +649,8 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
* ICH 7 SPI controller only supports array read command
* and byte program command for SST flash
*/
- if (plat->ich_version == ICHV_7) {
- slave->mode_rx = SPI_RX_SLOW;
- slave->mode = SPI_TX_BYTE;
- }
+ if (plat->ich_version == ICHV_7)
+ slave->mode = SPI_RX_SLOW | SPI_TX_BYTE;
return 0;
}
diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index 247abfa..d9c49e4 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -164,7 +164,6 @@ static int spi_child_pre_probe(struct udevice *dev)
slave->max_hz = plat->max_hz;
slave->mode = plat->mode;
- slave->mode_rx = plat->mode_rx;
slave->wordlen = SPI_DEFAULT_WORDLEN;
return 0;
@@ -381,7 +380,7 @@ void spi_free_slave(struct spi_slave *slave)
int spi_slave_ofdata_to_platdata(const void *blob, int node,
struct dm_spi_slave_platdata *plat)
{
- int mode = 0, mode_rx = 0;
+ int mode = 0;
int value;
plat->cs = fdtdec_get_int(blob, node, "reg", -1);
@@ -413,24 +412,22 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node,
break;
}
- plat->mode = mode;
-
value = fdtdec_get_uint(blob, node, "spi-rx-bus-width", 1);
switch (value) {
case 1:
break;
case 2:
- mode_rx |= SPI_RX_DUAL;
+ mode |= SPI_RX_DUAL;
break;
case 4:
- mode_rx |= SPI_RX_QUAD;
+ mode |= SPI_RX_QUAD;
break;
default:
error("spi-rx-bus-width %d not supported\n", value);
break;
}
- plat->mode_rx = mode_rx;
+ plat->mode = mode;
return 0;
}
diff --git a/drivers/spi/ti_qspi.c b/drivers/spi/ti_qspi.c
index bb72cb0..e51cbd0 100644
--- a/drivers/spi/ti_qspi.c
+++ b/drivers/spi/ti_qspi.c
@@ -336,7 +336,7 @@ static void ti_spi_setup_spi_register(struct ti_qspi_priv *priv)
QSPI_SETUP0_NUM_D_BYTES_8_BITS |
QSPI_SETUP0_READ_QUAD | QSPI_CMD_WRITE |
QSPI_NUM_DUMMY_BITS);
- slave->mode_rx = SPI_RX_QUAD;
+ slave->mode |= SPI_RX_QUAD;
#else
memval |= QSPI_CMD_READ | QSPI_SETUP0_NUM_A_BYTES |
QSPI_SETUP0_NUM_D_BYTES_NO_BITS |
@@ -422,7 +422,7 @@ static void __ti_qspi_setup_memorymap(struct ti_qspi_priv *priv,
bool enable)
{
u32 memval;
- u32 mode = slave->mode_rx & (SPI_RX_QUAD | SPI_RX_DUAL);
+ u32 mode = slave->mode & (SPI_RX_QUAD | SPI_RX_DUAL);
if (!enable) {
writel(0, &priv->base->setup0);
@@ -436,7 +436,7 @@ static void __ti_qspi_setup_memorymap(struct ti_qspi_priv *priv,
memval |= QSPI_CMD_READ_QUAD;
memval |= QSPI_SETUP0_NUM_D_BYTES_8_BITS;
memval |= QSPI_SETUP0_READ_QUAD;
- slave->mode_rx = SPI_RX_QUAD;
+ slave->mode |= SPI_RX_QUAD;
break;
case SPI_RX_DUAL:
memval |= QSPI_CMD_READ_DUAL;
diff --git a/include/spi.h b/include/spi.h
index ca96fa4..b262e06 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -26,12 +26,10 @@
#define SPI_TX_BYTE BIT(8) /* transmit with 1 wire byte */
#define SPI_TX_DUAL BIT(9) /* transmit with 2 wires */
#define SPI_TX_QUAD BIT(10) /* transmit with 4 wires */
-
-/* SPI mode_rx flags */
-#define SPI_RX_SLOW BIT(0) /* receive with 1 wire slow */
-#define SPI_RX_FAST BIT(1) /* receive with 1 wire fast */
-#define SPI_RX_DUAL BIT(2) /* receive with 2 wires */
-#define SPI_RX_QUAD BIT(3) /* receive with 4 wires */
+#define SPI_RX_SLOW BIT(11) /* receive with 1 wire slow */
+#define SPI_RX_FAST BIT(12) /* receive with 1 wire fast */
+#define SPI_RX_DUAL BIT(13) /* receive with 2 wires */
+#define SPI_RX_QUAD BIT(14) /* receive with 4 wires */
/* SPI bus connection options - see enum spi_dual_flash */
#define SPI_CONN_DUAL_SHARED (1 << 0)
@@ -61,13 +59,11 @@ struct dm_spi_bus {
* @cs: Chip select number (0..n-1)
* @max_hz: Maximum bus speed that this slave can tolerate
* @mode: SPI mode to use for this device (see SPI mode flags)
- * @mode_rx: SPI RX mode to use for this slave (see SPI mode_rx flags)
*/
struct dm_spi_slave_platdata {
unsigned int cs;
uint max_hz;
uint mode;
- u8 mode_rx;
};
#endif /* CONFIG_DM_SPI */
@@ -94,7 +90,6 @@ struct dm_spi_slave_platdata {
* bus (bus->seq) so does not need to be stored
* @cs: ID of the chip select connected to the slave.
* @mode: SPI mode to use for this slave (see SPI mode flags)
- * @mode_rx: SPI RX mode to use for this slave (see SPI mode_rx flags)
* @wordlen: Size of SPI word in number of bits
* @max_write_size: If non-zero, the maximum number of bytes which can
* be written at once, excluding command bytes.
@@ -112,7 +107,6 @@ struct spi_slave {
unsigned int cs;
#endif
uint mode;
- u8 mode_rx;
unsigned int wordlen;
unsigned int max_write_size;
void *memory_map;
--
2.7.4
next prev parent reply other threads:[~2016-08-11 8:07 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 8:07 [U-Boot] [PATCH v3 01/27] sf: Simplify fastest read cmd code Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 02/27] sf: Remove e_rd_cmd from param table Jagan Teki
2016-08-11 8:07 ` Jagan Teki [this message]
2016-08-11 8:07 ` [U-Boot] [PATCH v3 04/27] spi: Remove SPI_RX_FAST Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 05/27] sf: Remove SECT_32K Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 06/27] sf: Add CONFIG_SPI_FLASH_USE_4K_SECTORS in spi_flash Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 07/27] sf: Move flags macro's to spi_flash_params{} members Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 08/27] sf: Adopt flash table INFO macro from Linux Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 09/27] sf: Add JEDEC_ID and JEDEC_EXT macro Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 10/27] sf: Rename spi_flash_params => spi_flash_info Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 11/27] sf: Add JEDEC_MFR Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 12/27] sf: Simplify lock ops detection code Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 13/27] sf: sandbox: Fix ID exctract from spi_flash_info Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 14/27] sf: Cleanup spi_flash_info{} Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 15/27] sf: Cleanup sf_params Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 16/27] sf: nr_sectors -> n_sectors Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 17/27] sf: Add SPI_FLASH_MAX_ID_LEN Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 18/27] sf: Increase max id length by 1 byte Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 19/27] sf: Add INFO6 flash_info macro Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 20/27] sf: params: Add S25FS256S_64K spi flash support Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 21/27] sf: Remove legacy idcode detection code Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 22/27] sf: Remove non-meaningful comments Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 23/27] sf: Rename sf_params.c to spi_flash_ids Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 24/27] sf: ids: Use small letter's with flash name Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 25/27] sf: ids: Use small letter in ext_jedec Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 26/27] sf: Rename few local functions Jagan Teki
2016-08-11 8:07 ` [U-Boot] [PATCH v3 27/27] spi: Remove dual flash code Jagan Teki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470902869-22570-3-git-send-email-jteki@openedev.com \
--to=jteki@openedev.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox