Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions arch/arm/src/stm32h7/stm32_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <crypto/cryptodev.h>
#include <crypto/xform.h>
#include <nuttx/crypto/crypto.h>
#include <nuttx/kmalloc.h>

#include "arm_internal.h"
#include "hardware/stm32h7x3xx_rcc.h"
Expand Down Expand Up @@ -342,6 +343,7 @@ static int stm32_wait_for_clr(uintptr_t regaddr, uint32_t bitmask,
uint32_t timeout)
{
uint32_t regval;

while (timeout--)
{
regval = stm32crypto_getreg32(regaddr);
Expand All @@ -366,6 +368,7 @@ static int stm32_wait_for_set(uintptr_t regaddr, uint32_t bitmask,
uint32_t timeout)
{
uint32_t regval;

while (timeout--)
{
regval = stm32crypto_getreg32(regaddr);
Expand Down Expand Up @@ -547,7 +550,7 @@ static int hash_init(struct stm32_crypto_data *sw)
case CRYPTO_SHA2_224_HMAC:
regval = HASH_CR_ALGO_SHA2_224;
sw->u.hash.dsize = 28;
break;
break;
case CRYPTO_SHA2_256:
case CRYPTO_SHA2_256_HMAC:
regval = HASH_CR_ALGO_SHA2_256;
Expand All @@ -561,14 +564,14 @@ static int hash_init(struct stm32_crypto_data *sw)
/* If HMAC set mode, and key is large set HASH_CR_LKEY bit */

if (sw->u.hash.hmac)
{
regval |= HASH_CR_MODE_HMAC;
stm32cryptoinfo("klen %" PRIx32 "", sw->u.hash.klen);
if (sw->u.hash.klen > 64)
{
regval |= HASH_CR_LKEY_GT_64;
regval |= HASH_CR_MODE_HMAC;
stm32cryptoinfo("klen %" PRIx32 "", sw->u.hash.klen);
if (sw->u.hash.klen > 64)
{
regval |= HASH_CR_LKEY_GT_64;
}
}
}

regval |= HASH_CR_INIT; /* set init to configure HASH algorithm */
regval |= HASH_CR_DATATYPE_8; /* 8-bit data... */
Expand Down Expand Up @@ -786,10 +789,10 @@ static int stm32_freesession(uint64_t tid)
case CRYPTO_SHA2_224_HMAC:
case CRYPTO_SHA2_256_HMAC:
if (sw->u.hash.key)
{
explicit_bzero(sw->u.hash.key, sw->u.hash.klen);
kmm_free(sw->u.hash.key);
}
{
explicit_bzero(sw->u.hash.key, sw->u.hash.klen);
kmm_free(sw->u.hash.key);
}
break;

case CRYPTO_CRC32:
Expand Down Expand Up @@ -911,9 +914,9 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri)
sw->u.hash.klen = cri->cri_klen / 8;
sw->u.hash.key = kmm_malloc(sw->u.hash.klen);
if (sw->u.hash.key == NULL)
{
return -ENOBUFS;
}
{
return -ENOBUFS;
}

bcopy(cri->cri_key, sw->u.hash.key, sw->u.hash.klen);

Expand Down Expand Up @@ -949,9 +952,9 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri)
sw->u.hash.hmac = false;
ret = hash_init(sw);
if (ret < 0)
{
return ret;
}
{
return ret;
}
break;

case CRYPTO_CRC32:
Expand All @@ -964,11 +967,11 @@ static int stm32_newsession(uint32_t *sid, struct cryptoini *cri)
case CRYPTO_AES_CTR:
klen = cri->cri_klen / 8 - 4;
if ((klen != 16) && (klen != 24) && (klen != 32))
{
/* stm32h7 aes-ctr key bits support 128, 192, or 256 */
{
/* stm32h7 aes-ctr key bits support 128, 192, or 256 */

return -EINVAL;
}
return -EINVAL;
}

break;

Expand Down Expand Up @@ -1108,13 +1111,13 @@ static int stm32_process(struct cryptop *crp)

case CRYPTO_CRC32:
if (crd->crd_flags & CRD_F_UPDATE)
{
return crc32_update(sw, crp->crp_buf, crd->crd_len);
}
{
return crc32_update(sw, crp->crp_buf, crd->crd_len);
}
else
{
return crc32_final(sw, crp->crp_mac);
}
{
return crc32_final(sw, crp->crp_mac);
}
break;
case CRYPTO_AES_CBC:
return aes_cypher(crp->crp_dst, crp->crp_buf, crd->crd_len,
Expand Down
58 changes: 30 additions & 28 deletions arch/arm/src/xmc4/xmc4_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <nuttx/debug.h>

#include <arch/board/board.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/irq.h>

Expand Down Expand Up @@ -958,64 +959,65 @@ struct i2c_master_s *xmc4_i2cbus_initialize(int port)
{
#ifdef CONFIG_XMC4_I2C0
case 0:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c0;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c0;
break;
}
#endif

#ifdef CONFIG_XMC4_I2C1
case 1:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c1;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c1;
break;
}
#endif

#ifdef CONFIG_XMC4_I2C2
case 2:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c2;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c2;
break;
}
#endif

#ifdef CONFIG_XMC4_I2C3
case 3:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c3;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c3;
break;
}
#endif

#ifdef CONFIG_XMC4_I2C4
case 4:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c4;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c4;
break;
}
#endif

#ifdef CONFIG_XMC4_I2C5
case 5:
{
priv = (struct xmc4_i2cdev_s *)&g_i2c5;
break;
}
{
priv = (struct xmc4_i2cdev_s *)&g_i2c5;
break;
}
#endif

default:
{
i2cerr("No such i2c module.\n");
return NULL;
}
{
i2cerr("No such i2c module.\n");
return NULL;
}
}

nxmutex_lock(&priv->lock);

if (priv->refs++ == 0)
{
int ret = i2c_initialize(priv);

if (ret < 0)
{
nxmutex_unlock(&priv->lock);
Expand Down
73 changes: 39 additions & 34 deletions arch/risc-v/src/bl808/bl808_gpadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
#include <nuttx/kmalloc.h>

#include "hardware/bl808_gpadc.h"
#include "riscv_internal.h"
Expand Down Expand Up @@ -197,6 +198,7 @@ uint8_t bl808_gpadc_get_count()
uint32_t status = getreg32(BL808_GPADC_CONFIG);
uint8_t count = (status & GPADC_FIFO_DATA_COUNT_MASK)
>> GPADC_FIFO_DATA_COUNT_SHIFT;

return count;
}

Expand Down Expand Up @@ -231,6 +233,7 @@ static int __gpadc_interrupt(int irq, void *context, void *arg)

int receive_ret =
priv->callback->au_receive(dev, channel, adc_val);

if (receive_ret)
{
aerr("ADC driver upper half receive error");
Expand Down Expand Up @@ -365,6 +368,7 @@ static int bl808_gpadc_setup(struct adc_dev_s *dev)
if (channel < 12)
{
int pin = ch_to_gpio_map[channel];

bl808_configgpio(pin, GPIO_INPUT
| GPIO_FLOAT
| GPIO_FUNC_ANA);
Expand Down Expand Up @@ -449,40 +453,40 @@ static int bl808_gpadc_ioctl(struct adc_dev_s *dev,

switch (cmd)
{
case ANIOC_TRIGGER:
{
modifyreg32(BL808_GPADC_CMD, 0, GPADC_CONV_START);
ret = OK;
break;
}

case ANIOC_GET_NCHANNELS:
{
ret = priv->nchannels;
break;
}

case ANIOC_RESET_FIFO:
{
modifyreg32(BL808_GPADC_CONFIG, 0,
GPADC_FIFO_CLR);
ret = OK;
break;
}

case ANIOC_SAMPLES_ON_READ:
{
ret = bl808_gpadc_get_count();
break;
}

default:
{
/* Other commands not implemented */

ret = -ENOTTY;
break;
}
case ANIOC_TRIGGER:
{
modifyreg32(BL808_GPADC_CMD, 0, GPADC_CONV_START);
ret = OK;
break;
}

case ANIOC_GET_NCHANNELS:
{
ret = priv->nchannels;
break;
}

case ANIOC_RESET_FIFO:
{
modifyreg32(BL808_GPADC_CONFIG, 0,
GPADC_FIFO_CLR);
ret = OK;
break;
}

case ANIOC_SAMPLES_ON_READ:
{
ret = bl808_gpadc_get_count();
break;
}

default:
{
/* Other commands not implemented */

ret = -ENOTTY;
break;
}
}

return ret;
Expand All @@ -495,6 +499,7 @@ static int bl808_gpadc_ioctl(struct adc_dev_s *dev,
int bl808_gpadc_init(void)
{
struct adc_dev_s *dev = kmm_zalloc(sizeof(struct adc_dev_s));

dev->ad_ops = &gpadc_ops;
dev->ad_priv = &gpadc_priv;

Expand Down
1 change: 1 addition & 0 deletions arch/risc-v/src/common/espressif/esp_allocateheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <arch/board/board.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mm/mm.h>

#include "riscv_internal.h"
Expand Down
3 changes: 3 additions & 0 deletions arch/risc-v/src/common/espressif/esp_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <arch/irq.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/kmalloc.h>

/* Arch */

Expand Down Expand Up @@ -190,6 +191,7 @@ int esp_configgpio(int pin, gpio_pinattr_t attr)
if ((attr & DRIVE_MASK) != 0)
{
uint32_t val = ((attr & DRIVE_MASK) >> DRIVE_SHIFT) - 1;

gpio_hal_set_drive_capability(&g_gpio_hal, pin, val);
}
else
Expand All @@ -201,6 +203,7 @@ int esp_configgpio(int pin, gpio_pinattr_t attr)
if ((attr & FUNCTION_MASK) != 0)
{
uint32_t val = ((attr & FUNCTION_MASK) >> FUNCTION_SHIFT) - 1;

gpio_hal_func_sel(&g_gpio_hal, pin, val);
}
else
Expand Down
Loading
Loading