[Armadeus-commitlog] armadeus/u-boot branch, opos6ul-2018.05, updated. 979806a06266e394d6c837163d1
Brought to you by:
sszy
|
From: sszy <ss...@us...> - 2022-12-13 08:21:41
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus/u-boot".
The branch, opos6ul-2018.05 has been updated
via 979806a06266e394d6c837163d1fb489659d0c69 (commit)
via 64a0e05613ae3fa87e9dfdd8cfe51b9af397163b (commit)
via a159764c2ac0e8fbf2e6880ceb25058140483ae6 (commit)
from 1c14d7f084088e86d5cc274bd7daed1c859c2f2c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 979806a06266e394d6c837163d1fb489659d0c69
Author: Sébastien Szymanski <seb...@ar...>
Date: Mon Dec 12 16:25:03 2022 +0100
spi: soft_spi: add dcx GPIO (optional)
commit 64a0e05613ae3fa87e9dfdd8cfe51b9af397163b
Author: Christophe Kerello <chr...@st...>
Date: Fri Aug 2 15:46:29 2019 +0200
spi: soft_spi: Fix data abort if slave is not probed
In case spi_get_bus_and_cs callback is used, spi bus is first probed
then slave devices are probed. To avoid a data abort in soft_spi probe
function, we need to check that (slave != NULL).
If slave is NULL, cs_flags and clk_flags will be initialized with
respectively GPIOD_ACTIVE_LOW and 0.
Signed-off-by: Christophe Kerello <chr...@st...>
Signed-off-by: Patrice Chotard <pat...@st...>
Reviewed-by: Jagan Teki <ja...@am...>
commit a159764c2ac0e8fbf2e6880ceb25058140483ae6
Author: Johannes Holland <joh...@in...>
Date: Mon May 11 15:22:26 2020 +0200
spi: add support for all spi modes with soft spi
The spi bitbanging driver did not implement all spi modes properly. Add
code to support all spi modes, honoring soft_spi_set_mode() and
defaulting to spi mode 0. Previously, CPHA was implemented inversely
(defaulting to CPHA=1) and CPOL=1 was hardcoded.
Signed-off-by: Johannes Holland <joh...@in...>
Reviewed-by: Jagan Teki <ja...@am...>
-----------------------------------------------------------------------
Summary of changes:
drivers/spi/soft_spi.c | 73 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 60 insertions(+), 13 deletions(-)
diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c
index b06883f9d0..6d14dcd09a 100644
--- a/drivers/spi/soft_spi.c
+++ b/drivers/spi/soft_spi.c
@@ -24,6 +24,7 @@ struct soft_spi_platdata {
struct gpio_desc sclk;
struct gpio_desc mosi;
struct gpio_desc miso;
+ struct gpio_desc dcx;
int spi_delay_us;
int flags;
};
@@ -45,6 +46,17 @@ static int soft_spi_scl(struct udevice *dev, int bit)
return 0;
}
+static int soft_spi_dcx(struct udevice *dev, int bit)
+{
+ struct udevice *bus = dev_get_parent(dev);
+ struct soft_spi_platdata *plat = dev_get_platdata(bus);
+
+ if (dm_gpio_is_valid(&plat->dcx))
+ dm_gpio_set_value(&plat->dcx, bit);
+
+ return 0;
+}
+
static int soft_spi_sda(struct udevice *dev, int bit)
{
struct udevice *bus = dev_get_parent(dev);
@@ -58,10 +70,12 @@ static int soft_spi_sda(struct udevice *dev, int bit)
static int soft_spi_cs_activate(struct udevice *dev)
{
struct udevice *bus = dev_get_parent(dev);
+ struct soft_spi_priv *priv = dev_get_priv(bus);
struct soft_spi_platdata *plat = dev_get_platdata(bus);
+ int cidle = !!(priv->mode & SPI_CPOL);
dm_gpio_set_value(&plat->cs, 0);
- dm_gpio_set_value(&plat->sclk, 0);
+ dm_gpio_set_value(&plat->sclk, cidle); /* to idle */
dm_gpio_set_value(&plat->cs, 1);
return 0;
@@ -79,11 +93,14 @@ static int soft_spi_cs_deactivate(struct udevice *dev)
static int soft_spi_claim_bus(struct udevice *dev)
{
+ struct udevice *bus = dev_get_parent(dev);
+ struct soft_spi_priv *priv = dev_get_priv(bus);
+ int cidle = !!(priv->mode & SPI_CPOL);
/*
* Make sure the SPI clock is in idle state as defined for
* this slave.
*/
- return soft_spi_scl(dev, 0);
+ return soft_spi_scl(dev, cidle);
}
static int soft_spi_release_bus(struct udevice *dev)
@@ -114,7 +131,8 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
uchar tmpdout = 0;
const u8 *txd = dout;
u8 *rxd = din;
- int cpha = priv->mode & SPI_CPHA;
+ int cpha = !!(priv->mode & SPI_CPHA);
+ int cidle = !!(priv->mode & SPI_CPOL);
unsigned int j;
debug("spi_xfer: slave %s:%s dout %08X din %08X bitlen %u\n",
@@ -140,22 +158,48 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
tmpdin = 0;
}
- if (!cpha)
- soft_spi_scl(dev, 0);
+ /*
+ * dcx
+ *
+ */
+ soft_spi_dcx(dev, (j == 0) ? 1 : 0);
+
+ /*
+ * CPOL 0: idle is low (0), active is high (1)
+ * CPOL 1: idle is high (1), active is low (0)
+ */
+
+ /*
+ * drive bit
+ * CPHA 1: CLK from idle to active
+ */
+ if (cpha)
+ soft_spi_scl(dev, !cidle);
if ((plat->flags & SPI_MASTER_NO_TX) == 0)
soft_spi_sda(dev, !!(tmpdout & 0x80));
udelay(plat->spi_delay_us);
- if (cpha)
- soft_spi_scl(dev, 0);
+
+ /*
+ * sample bit
+ * CPHA 0: CLK from idle to active
+ * CPHA 1: CLK from active to idle
+ */
+ if (!cpha)
+ soft_spi_scl(dev, !cidle);
else
- soft_spi_scl(dev, 1);
+ soft_spi_scl(dev, cidle);
tmpdin <<= 1;
if ((plat->flags & SPI_MASTER_NO_RX) == 0)
tmpdin |= dm_gpio_get_value(&plat->miso);
tmpdout <<= 1;
udelay(plat->spi_delay_us);
- if (cpha)
- soft_spi_scl(dev, 1);
+
+ /*
+ * drive bit
+ * CPHA 0: CLK from active to idle
+ */
+ if (!cpha)
+ soft_spi_scl(dev, cidle);
}
/*
* If the number of bits isn't a multiple of 8, shift the last
@@ -176,7 +220,7 @@ static int soft_spi_xfer(struct udevice *dev, unsigned int bitlen,
static int soft_spi_set_speed(struct udevice *dev, unsigned int speed)
{
- /* Accept any speed */
+ /* Ignore any speed settings. Speed is implemented via "spi-delay-us" */
return 0;
}
@@ -215,8 +259,8 @@ static int soft_spi_probe(struct udevice *dev)
int cs_flags, clk_flags;
int ret;
- cs_flags = (slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW;
- clk_flags = (slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0;
+ cs_flags = (slave && slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW;
+ clk_flags = (slave && slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0;
if (gpio_request_by_name(dev, "cs-gpios", 0, &plat->cs,
GPIOD_IS_OUT | cs_flags) ||
@@ -238,6 +282,9 @@ static int soft_spi_probe(struct udevice *dev)
(SPI_MASTER_NO_RX | SPI_MASTER_NO_TX))
return -EINVAL;
+ gpio_request_by_name(dev, "gpio-dcx", 0, &plat->dcx,
+ GPIOD_IS_OUT | GPIOD_ACTIVE_LOW);
+
return 0;
}
hooks/post-receive
--
armadeus/u-boot
|