summaryrefslogtreecommitdiffstats
path: root/src/soc
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-04-19 19:27:28 -0700
committerMartin Roth <martinroth@google.com>2017-05-05 23:42:19 +0200
commitde705fa1f470683b9ea4ad91c1a9ae5a98942612 (patch)
tree60873b2b6772bf459cd8db2f171ae7711d507b02 /src/soc
parentf1db5fdb4d03b4766cf23e4b04a05b0fc05586a0 (diff)
downloadcoreboot-de705fa1f470683b9ea4ad91c1a9ae5a98942612.tar.gz
coreboot-de705fa1f470683b9ea4ad91c1a9ae5a98942612.tar.bz2
coreboot-de705fa1f470683b9ea4ad91c1a9ae5a98942612.zip
drivers/spi: Re-factor spi_crop_chunk
spi_crop_chunk is a property of the SPI controller since it depends upon the maximum transfer size that is supported by the controller. Also, it is possible to implement this within spi-generic layer by obtaining following parameters from the controller: 1. max_xfer_size: Maximum transfer size supported by the controller (Size of 0 indicates invalid size, and unlimited transfer size is indicated by UINT32_MAX.) 2. deduct_cmd_len: Whether cmd_len needs to be deducted from the max_xfer_size to determine max data size that can be transferred. (This is used by the amd boards.) Change-Id: I81c199413f879c664682088e93bfa3f91c6a46e5 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19386 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Tested-by: coreboot org <coreboot.org@gmail.com>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/broadcom/cygnus/spi.c6
-rw-r--r--src/soc/imgtec/pistachio/spi.c6
-rw-r--r--src/soc/intel/baytrail/spi.c7
-rw-r--r--src/soc/intel/braswell/spi.c7
-rw-r--r--src/soc/intel/broadwell/spi.c7
-rw-r--r--src/soc/intel/common/block/fast_spi/fast_spi_flash.c1
-rw-r--r--src/soc/intel/common/block/gspi/gspi.c1
-rw-r--r--src/soc/intel/fsp_baytrail/spi.c7
-rw-r--r--src/soc/intel/fsp_broadwell_de/spi.c7
-rw-r--r--src/soc/marvell/armada38x/spi.c6
-rw-r--r--src/soc/marvell/bg4cd/spi.c5
-rw-r--r--src/soc/mediatek/mt8173/flash_controller.c5
-rw-r--r--src/soc/mediatek/mt8173/spi.c1
-rw-r--r--src/soc/nvidia/tegra124/spi.c6
-rw-r--r--src/soc/nvidia/tegra210/spi.c6
-rw-r--r--src/soc/qualcomm/ipq40xx/spi.c6
-rw-r--r--src/soc/qualcomm/ipq806x/spi.c6
-rw-r--r--src/soc/rockchip/common/spi.c6
-rw-r--r--src/soc/samsung/exynos5420/spi.c1
19 files changed, 22 insertions, 75 deletions
diff --git a/src/soc/broadcom/cygnus/spi.c b/src/soc/broadcom/cygnus/spi.c
index f03d453307f3..fde21ba20298 100644
--- a/src/soc/broadcom/cygnus/spi.c
+++ b/src/soc/broadcom/cygnus/spi.c
@@ -280,6 +280,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = 65535,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
@@ -318,8 +319,3 @@ int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
return 0;
}
-
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(65535, buf_len);
-}
diff --git a/src/soc/imgtec/pistachio/spi.c b/src/soc/imgtec/pistachio/spi.c
index 2b706f0980ad..30e14fab10a6 100644
--- a/src/soc/imgtec/pistachio/spi.c
+++ b/src/soc/imgtec/pistachio/spi.c
@@ -538,6 +538,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = IMGTEC_SPI_MAX_TRANSFER_SIZE,
};
/* Set up communications parameters for a SPI slave. */
@@ -585,8 +586,3 @@ int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
return 0;
}
-
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(IMGTEC_SPI_MAX_TRANSFER_SIZE, buf_len);
-}
diff --git a/src/soc/intel/baytrail/spi.c b/src/soc/intel/baytrail/spi.c
index 639954bcfec3..36b542f1811f 100644
--- a/src/soc/intel/baytrail/spi.c
+++ b/src/soc/intel/baytrail/spi.c
@@ -19,6 +19,7 @@
#include <bootstate.h>
#include <delay.h>
#include <arch/io.h>
+#include <commonlib/helpers.h>
#include <console/console.h>
#include <device/pci_ids.h>
#include <spi_flash.h>
@@ -457,11 +458,6 @@ static int ich_status_poll(u16 bitmask, int wait_til_set)
return -1;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(cntlr.databytes, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytesout, void *din, size_t bytesin)
{
@@ -613,6 +609,7 @@ static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
static const struct spi_ctrlr spi_ctrlr = {
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = member_size(ich9_spi_regs, fdata),
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/intel/braswell/spi.c b/src/soc/intel/braswell/spi.c
index 5121be016b2e..12bf7d5c80bf 100644
--- a/src/soc/intel/braswell/spi.c
+++ b/src/soc/intel/braswell/spi.c
@@ -16,6 +16,7 @@
/* This file is derived from the flashrom project. */
#include <arch/io.h>
#include <bootstate.h>
+#include <commonlib/helpers.h>
#include <console/console.h>
#include <delay.h>
#include <device/pci_ids.h>
@@ -438,11 +439,6 @@ static int ich_status_poll(u16 bitmask, int wait_til_set)
return -1;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(cntlr.databytes, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytesout, void *din, size_t bytesin)
{
@@ -597,6 +593,7 @@ static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
static const struct spi_ctrlr spi_ctrlr = {
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = member_size(ich9_spi_regs, fdata),
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/intel/broadwell/spi.c b/src/soc/intel/broadwell/spi.c
index aaf3b85b5a96..40969bc40480 100644
--- a/src/soc/intel/broadwell/spi.c
+++ b/src/soc/intel/broadwell/spi.c
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include <bootstate.h>
+#include <commonlib/helpers.h>
#include <delay.h>
#include <arch/io.h>
#include <console/console.h>
@@ -454,11 +455,6 @@ static int ich_status_poll(u16 bitmask, int wait_til_set)
return -1;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(cntlr.databytes, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytesout, void *din, size_t bytesin)
{
@@ -654,6 +650,7 @@ int spi_flash_protect(u32 start, u32 size)
static const struct spi_ctrlr spi_ctrlr = {
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = member_size(ich9_spi_regs, fdata),
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
index 27a4bb78862e..d56b33fa1552 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
@@ -364,4 +364,5 @@ static int fast_spi_flash_ctrlr_setup(const struct spi_slave *dev)
const struct spi_ctrlr fast_spi_flash_ctrlr = {
.setup = fast_spi_flash_ctrlr_setup,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
diff --git a/src/soc/intel/common/block/gspi/gspi.c b/src/soc/intel/common/block/gspi/gspi.c
index 51e8ef54e102..8e527ed0b108 100644
--- a/src/soc/intel/common/block/gspi/gspi.c
+++ b/src/soc/intel/common/block/gspi/gspi.c
@@ -611,4 +611,5 @@ const struct spi_ctrlr gspi_ctrlr = {
.release_bus = gspi_cs_deassert,
.setup = gspi_ctrlr_setup,
.xfer = gspi_ctrlr_xfer,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
diff --git a/src/soc/intel/fsp_baytrail/spi.c b/src/soc/intel/fsp_baytrail/spi.c
index 409e796dafc7..236ff741fc4c 100644
--- a/src/soc/intel/fsp_baytrail/spi.c
+++ b/src/soc/intel/fsp_baytrail/spi.c
@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
+#include <commonlib/helpers.h>
#include <delay.h>
#include <arch/io.h>
#include <console/console.h>
@@ -438,11 +439,6 @@ static int ich_status_poll(uint16_t bitmask, int wait_til_set)
return -1;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(cntlr.databytes, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytesout, void *din, size_t bytesin)
{
@@ -594,6 +590,7 @@ spi_xfer_exit:
static const struct spi_ctrlr spi_ctrlr = {
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = member_size(ich9_spi_regs, fdata),
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/intel/fsp_broadwell_de/spi.c b/src/soc/intel/fsp_broadwell_de/spi.c
index a6b6f3541a26..01cb281fe0a3 100644
--- a/src/soc/intel/fsp_broadwell_de/spi.c
+++ b/src/soc/intel/fsp_broadwell_de/spi.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <delay.h>
+#include <commonlib/helpers.h>
#include <arch/io.h>
#include <console/console.h>
#include <device/pci_ids.h>
@@ -452,11 +453,6 @@ static int ich_status_poll(uint16_t bitmask, int wait_til_set)
return -1;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(cntlr.databytes, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytesout, void *din, size_t bytesin)
{
@@ -610,6 +606,7 @@ spi_xfer_exit:
static const struct spi_ctrlr spi_ctrlr = {
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = member_size(ich9_spi_regs, fdata),
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/marvell/armada38x/spi.c b/src/soc/marvell/armada38x/spi.c
index 25480e49fffa..47631f4c6968 100644
--- a/src/soc/marvell/armada38x/spi.c
+++ b/src/soc/marvell/armada38x/spi.c
@@ -454,11 +454,6 @@ static void spi_ctrlr_release_bus(const struct spi_slave *slave)
mv_spi_cs_deassert(slave->bus);
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return buf_len;
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave,
const void *dout,
size_t out_bytes,
@@ -480,6 +475,7 @@ static const spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/marvell/bg4cd/spi.c b/src/soc/marvell/bg4cd/spi.c
index f9faf9504a79..188a6bd48372 100644
--- a/src/soc/marvell/bg4cd/spi.c
+++ b/src/soc/marvell/bg4cd/spi.c
@@ -19,8 +19,3 @@ int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
{
return -1;
}
-
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return buf_len;
-}
diff --git a/src/soc/mediatek/mt8173/flash_controller.c b/src/soc/mediatek/mt8173/flash_controller.c
index f6f6e2a6c795..09df1a47f71e 100644
--- a/src/soc/mediatek/mt8173/flash_controller.c
+++ b/src/soc/mediatek/mt8173/flash_controller.c
@@ -108,11 +108,6 @@ static int sector_erase(int offset)
return 0;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(65535, buf_len);
-}
-
static int dma_read(u32 addr, u8 *buf, u32 len, uintptr_t dma_buf,
size_t dma_buf_len)
{
diff --git a/src/soc/mediatek/mt8173/spi.c b/src/soc/mediatek/mt8173/spi.c
index 415764a1b6ed..188bdc288103 100644
--- a/src/soc/mediatek/mt8173/spi.c
+++ b/src/soc/mediatek/mt8173/spi.c
@@ -294,6 +294,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = 65535,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/nvidia/tegra124/spi.c b/src/soc/nvidia/tegra124/spi.c
index 5d8084fbdf0e..4ecd67a8a4fb 100644
--- a/src/soc/nvidia/tegra124/spi.c
+++ b/src/soc/nvidia/tegra124/spi.c
@@ -714,11 +714,6 @@ static int xfer_finish(struct tegra_spi_channel *spi)
return ret;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return buf_len;
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t out_bytes, void *din, size_t in_bytes)
{
@@ -802,6 +797,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/nvidia/tegra210/spi.c b/src/soc/nvidia/tegra210/spi.c
index 292135542a27..0987ddb53ad5 100644
--- a/src/soc/nvidia/tegra210/spi.c
+++ b/src/soc/nvidia/tegra210/spi.c
@@ -750,11 +750,6 @@ static int xfer_finish(struct tegra_spi_channel *spi)
return ret;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return buf_len;
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t out_bytes, void *din, size_t in_bytes)
{
@@ -838,6 +833,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/qualcomm/ipq40xx/spi.c b/src/soc/qualcomm/ipq40xx/spi.c
index 68c2dd0b72a2..b5c1f6699a6c 100644
--- a/src/soc/qualcomm/ipq40xx/spi.c
+++ b/src/soc/qualcomm/ipq40xx/spi.c
@@ -410,11 +410,6 @@ static void enable_io_config(struct ipq_spi_slave *ds,
return;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(MAX_PACKET_COUNT, buf_len);
-}
-
/*
* Function to read bytes number of data from the Input FIFO
*/
@@ -657,6 +652,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
.xfer_vector = spi_xfer_two_vectors,
+ .max_xfer_size = MAX_PACKET_COUNT,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/qualcomm/ipq806x/spi.c b/src/soc/qualcomm/ipq806x/spi.c
index e907729a1347..9a34f7a948ea 100644
--- a/src/soc/qualcomm/ipq806x/spi.c
+++ b/src/soc/qualcomm/ipq806x/spi.c
@@ -683,11 +683,6 @@ static int spi_xfer_rx_packet(struct ipq_spi_slave *ds,
return config_spi_state(ds, SPI_RESET_STATE);
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(MAX_PACKET_COUNT, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t out_bytes, void *din, size_t in_bytes)
{
@@ -761,6 +756,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = MAX_PACKET_COUNT,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/rockchip/common/spi.c b/src/soc/rockchip/common/spi.c
index 16143b5ac8bc..0e7376945b47 100644
--- a/src/soc/rockchip/common/spi.c
+++ b/src/soc/rockchip/common/spi.c
@@ -251,11 +251,6 @@ static int do_xfer(struct rockchip_spi *regs, bool use_16bit, const void *dout,
return 0;
}
-unsigned int spi_crop_chunk(unsigned int cmd_len, unsigned int buf_len)
-{
- return min(65535, buf_len);
-}
-
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout,
size_t bytes_out, void *din, size_t bytes_in)
{
@@ -332,6 +327,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = 65535,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)
diff --git a/src/soc/samsung/exynos5420/spi.c b/src/soc/samsung/exynos5420/spi.c
index f17566e2c572..c2a5828f14ab 100644
--- a/src/soc/samsung/exynos5420/spi.c
+++ b/src/soc/samsung/exynos5420/spi.c
@@ -212,6 +212,7 @@ static const struct spi_ctrlr spi_ctrlr = {
.claim_bus = spi_ctrlr_claim_bus,
.release_bus = spi_ctrlr_release_bus,
.xfer = spi_ctrlr_xfer,
+ .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE,
};
int spi_setup_slave(unsigned int bus, unsigned int cs, struct spi_slave *slave)