summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-05-14 07:11:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-05-14 07:11:20 +0200
commitc10b20dc83ac25b1d81c39eaad4529d9911813b1 (patch)
tree6558720fa869c01d7093b3df721dedaaec06cb5f /drivers
parent9b01acf90f04aaf3f6f41875e91272cbeac51171 (diff)
parent2c42da39a91238cc16f87c2867c8a5ea7847f99c (diff)
downloadbarebox-master.tar.gz
Merge branch 'for-next/stm32'HEADmaster
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mci/stm32_sdmmc2.c18
-rw-r--r--drivers/mfd/stpmic1.c2
-rw-r--r--drivers/nvmem/bsec.c44
-rw-r--r--drivers/regulator/stpmic1_regulator.c2
4 files changed, 44 insertions, 22 deletions
diff --git a/drivers/mci/stm32_sdmmc2.c b/drivers/mci/stm32_sdmmc2.c
index 0c26869..3ce3bb0 100644
--- a/drivers/mci/stm32_sdmmc2.c
+++ b/drivers/mci/stm32_sdmmc2.c
@@ -367,7 +367,7 @@ static int stm32_sdmmc2_end_cmd(struct stm32_sdmmc2_priv *priv,
/* Check status */
if (status & SDMMC_STA_CTIMEOUT) {
- dev_err(priv->dev, "%s: error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
+ dev_dbg(priv->dev, "%s: error SDMMC_STA_CTIMEOUT (0x%x) for cmd %d\n",
__func__, status, cmd->cmdidx);
return -ETIMEDOUT;
}
@@ -481,11 +481,8 @@ static int stm32_sdmmc2_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
{
struct stm32_sdmmc2_priv *priv = to_mci_host(mci);
u32 cmdat = data ? SDMMC_CMD_CMDTRANS : 0;
- u32 data_length;
- int ret, retry = 3;
-
-retry_cmd:
- data_length = 0;
+ u32 data_length = 0;
+ int ret;
if (data) {
data_length = data->blocks * data->blocksize;
@@ -530,15 +527,6 @@ retry_cmd:
writel(SDMMC_ICR_STATIC_FLAGS, priv->base + SDMMC_ICR);
}
- if (ret && retry) {
- dev_warn(priv->dev, "%s: cmd %d failed, retrying ...\n",
- __func__, cmd->cmdidx);
-
- retry--;
-
- goto retry_cmd;
- }
-
dev_dbg(priv->dev, "%s: end for CMD %d, ret = %d\n", __func__,
cmd->cmdidx, ret);
diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c
index ab13ded..d22758b 100644
--- a/drivers/mfd/stpmic1.c
+++ b/drivers/mfd/stpmic1.c
@@ -94,4 +94,4 @@ static struct driver_d stpmic1_i2c_driver = {
.of_compatible = DRV_OF_COMPAT(stpmic1_dt_ids),
};
-device_i2c_driver(stpmic1_i2c_driver);
+coredevice_i2c_driver(stpmic1_i2c_driver);
diff --git a/drivers/nvmem/bsec.c b/drivers/nvmem/bsec.c
index d772d0b..836e62e 100644
--- a/drivers/nvmem/bsec.c
+++ b/drivers/nvmem/bsec.c
@@ -33,7 +33,7 @@ struct stm32_bsec_data {
int num_regs;
};
-static int bsec_smc(struct bsec_priv *priv, u8 op, enum bsec_field field,
+static int bsec_smc(struct bsec_priv *priv, enum bsec_op op, u32 field,
unsigned data2, unsigned *val)
{
enum bsec_smc ret = stm32mp_smc(priv->svc_id, op, field / 4, data2, val);
@@ -77,15 +77,49 @@ static int stm32_bsec_write(struct device_d *dev, int offset,
{
struct bsec_priv *priv = dev->parent->priv;
+ /* Allow only writing complete 32-bits aligned words */
+ if ((bytes % 4) || (offset % 4))
+ return -EINVAL;
+
return regmap_bulk_write(priv->map, offset, val, bytes);
}
static int stm32_bsec_read(struct device_d *dev, int offset,
- void *val, int bytes)
+ void *buf, int bytes)
{
struct bsec_priv *priv = dev->parent->priv;
+ u32 roffset, rbytes, val;
+ u8 *buf8 = buf, *val8 = (u8 *)&val;
+ int i, j = 0, ret, skip_bytes, size;
+
+ /* Round unaligned access to 32-bits */
+ roffset = rounddown(offset, 4);
+ skip_bytes = offset & 0x3;
+ rbytes = roundup(bytes + skip_bytes, 4);
+
+ if (roffset + rbytes > priv->config.size)
+ return -EINVAL;
+
+ for (i = roffset; i < roffset + rbytes; i += 4) {
+ ret = regmap_bulk_read(priv->map, i, &val, 4);
+ if (ret) {
+ dev_err(dev, "Can't read data%d (%d)\n", i, ret);
+ return ret;
+ }
+
+ /* skip first bytes in case of unaligned read */
+ if (skip_bytes)
+ size = min(bytes, 4 - skip_bytes);
+ else
+ size = min(bytes, 4);
+
+ memcpy(&buf8[j], &val8[skip_bytes], size);
+ bytes -= size;
+ j += size;
+ skip_bytes = 0;
+ }
- return regmap_bulk_read(priv->map, offset, val, bytes);
+ return 0;
}
static const struct nvmem_bus stm32_bsec_nvmem_bus = {
@@ -185,8 +219,8 @@ static int stm32_bsec_probe(struct device_d *dev)
priv->config.name = "stm32-bsec";
priv->config.dev = dev;
- priv->config.stride = 4;
- priv->config.word_size = 4;
+ priv->config.stride = 1;
+ priv->config.word_size = 1;
priv->config.size = data->num_regs;
priv->config.bus = &stm32_bsec_nvmem_bus;
dev->priv = priv;
diff --git a/drivers/regulator/stpmic1_regulator.c b/drivers/regulator/stpmic1_regulator.c
index aaaba09..71a4ae8 100644
--- a/drivers/regulator/stpmic1_regulator.c
+++ b/drivers/regulator/stpmic1_regulator.c
@@ -433,4 +433,4 @@ static struct driver_d stpmic1_regulator_driver = {
.probe = stpmic1_regulator_probe,
.of_compatible = DRV_OF_COMPAT(stpmic1_regulator_of_match),
};
-device_platform_driver(stpmic1_regulator_driver);
+coredevice_platform_driver(stpmic1_regulator_driver);