Skip to content

Commit 37ce081

Browse files
authored
Merge pull request zephyrproject-rtos#7 from ccli8/nvt_m467_patch_v3.2.0_upgrade
NuMaker: Update following v3.2.0 upgrade
2 parents 4863c1c + ecea3ab commit 37ce081

File tree

5 files changed

+49
-48
lines changed

5 files changed

+49
-48
lines changed

drivers/can/can_numaker.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ static int can_numaker_init(const struct device *dev)
176176
}
177177

178178
static const struct can_driver_api can_numaker_driver_api = {
179+
.get_capabilities = can_mcan_get_capabilities,
180+
.start = can_mcan_start,
181+
.stop = can_mcan_stop,
179182
.set_mode = can_mcan_set_mode,
180183
.set_timing = can_mcan_set_timing,
181184
.send = can_mcan_send,
@@ -192,7 +195,7 @@ static const struct can_driver_api can_numaker_driver_api = {
192195
/* Nominal bit timing limits
193196
*
194197
* NUMAKER MCAN timing limits are specified in the "Nominal bit timing and
195-
* prescaler register (NBTP)" table in the SoC reference manual.
198+
* prescaler register (NBTP)" table in the SoC reference manual.
196199
*
197200
* NOTE: The values here are the "physical" timing limits, whereas the register
198201
* field limits are physical values minus 1 (which is handled by the
@@ -217,7 +220,7 @@ static const struct can_driver_api can_numaker_driver_api = {
217220
/* Data bit timing limits
218221
*
219222
* NUMAKER MCAN timing limits are specified in the "Data bit timing and
220-
* prescaler register (DBTP)" table in the SoC reference manual.
223+
* prescaler register (DBTP)" table in the SoC reference manual.
221224
*
222225
* NOTE: Same "minus one" concern as above.
223226
*/

drivers/i2c/i2c_numaker.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static int nu_int_i2c_poll_tran_heatbeat_timeout(const struct device *dev, uint3
5959
static int nu_int_i2c_is_trsn_done(const struct device *dev);
6060
static int nu_int_i2c_is_tran_started(const struct device *dev);
6161
static int nu_int_i2c_addr2data(int address, int read);
62-
#ifdef CONFIG_I2C_SLAVE
62+
#ifdef CONFIG_I2C_TARGET
6363
/* Convert zephyr address to BSP address. */
6464
static int nu_int_i2c_addr2bspaddr(int address);
6565
static void nu_int_i2c_enable_slave_if_registered(const struct device *dev);
@@ -76,7 +76,7 @@ static int nu_int_i2c_set_int(const struct device *dev, int inten);
7676
#define TRANCTRL_LASTDATANAKED (1 << 2) // Last data NACKed
7777
#define TRANCTRL_RECVDATA (1 << 3) // Receive data available
7878

79-
#ifdef CONFIG_I2C_SLAVE
79+
#ifdef CONFIG_I2C_TARGET
8080
#define NoData 0 // the slave has not been addressed
8181
#define ReadAddressed 1 // the master has requested a read from this slave (slave = transmitter)
8282
#define WriteGeneral 2 // the master is writing to all slave
@@ -110,8 +110,8 @@ struct i2c_numaker_data {
110110
struct k_sem lock;
111111
struct k_sem xfer_sync;
112112
uint32_t dev_config;
113-
#ifdef CONFIG_I2C_SLAVE
114-
struct i2c_slave_config * slave_config;
113+
#ifdef CONFIG_I2C_TARGET
114+
struct i2c_target_config * slave_config;
115115
#endif
116116

117117
struct {
@@ -120,7 +120,7 @@ struct i2c_numaker_data {
120120
char * tran_pos;
121121
char * tran_end;
122122
int inten;
123-
#ifdef CONFIG_I2C_SLAVE
123+
#ifdef CONFIG_I2C_TARGET
124124
int slaveaddr_state;
125125
#endif
126126
} i2c;
@@ -165,7 +165,7 @@ static int i2c_numaker_configure(const struct device *dev,
165165
k_sem_take(&data->lock, K_FOREVER);
166166
nu_int_i2c_disable_int(dev);
167167

168-
#ifdef CONFIG_I2C_SLAVE
168+
#ifdef CONFIG_I2C_TARGET
169169
if (nu_int_i2c_is_slave_busy(dev)) {
170170
LOG_ERR("Reconfigure with slave being busy");
171171
err = -EBUSY;
@@ -286,7 +286,7 @@ static int i2c_numaker_transfer(const struct device *dev, struct i2c_msg *msgs,
286286
/* Do I2C stop to release bus ownership */
287287
nu_int_i2c_stop(dev);
288288

289-
#ifdef CONFIG_I2C_SLAVE
289+
#ifdef CONFIG_I2C_TARGET
290290
/* Enable slave mode if any slave registered */
291291
nu_int_i2c_enable_slave_if_registered(dev);
292292
#endif
@@ -299,15 +299,15 @@ static int i2c_numaker_transfer(const struct device *dev, struct i2c_msg *msgs,
299299
return err;
300300
}
301301

302-
#ifdef CONFIG_I2C_SLAVE
302+
#ifdef CONFIG_I2C_TARGET
303303
static int i2c_numaker_slave_register(const struct device *dev,
304-
struct i2c_slave_config *slave_config)
304+
struct i2c_target_config *slave_config)
305305
{
306306
if (!slave_config) {
307307
return -EINVAL;
308308
}
309309

310-
if (slave_config->flags & I2C_SLAVE_FLAGS_ADDR_10_BITS) {
310+
if (slave_config->flags & I2C_ADDR_10_BITS) {
311311
LOG_ERR("10-bits address not supported");
312312
return -ENOTSUP;
313313
}
@@ -347,7 +347,7 @@ static int i2c_numaker_slave_register(const struct device *dev,
347347
}
348348

349349
static int i2c_numaker_slave_unregister(const struct device *dev,
350-
struct i2c_slave_config *slave_config)
350+
struct i2c_target_config *slave_config)
351351
{
352352
if (!slave_config) {
353353
return -EINVAL;
@@ -411,9 +411,9 @@ static void i2c_numaker_isr(const struct device *dev)
411411
const struct i2c_numaker_config *config = dev->config;
412412
struct i2c_numaker_data *data = dev->data;
413413
I2C_T *i2c_base = config->i2c_base;
414-
#ifdef CONFIG_I2C_SLAVE
415-
struct i2c_slave_config *slave_config = data->slave_config;
416-
const struct i2c_slave_callbacks *slave_callbacks = slave_config ? slave_config->callbacks : NULL;
414+
#ifdef CONFIG_I2C_TARGET
415+
struct i2c_target_config *slave_config = data->slave_config;
416+
const struct i2c_target_callbacks *slave_callbacks = slave_config ? slave_config->callbacks : NULL;
417417
int err = 0;
418418
uint8_t data_tran;
419419
#endif
@@ -501,7 +501,7 @@ static void i2c_numaker_isr(const struct device *dev)
501501

502502
//case 0x00: // Bus error
503503

504-
#ifdef CONFIG_I2C_SLAVE
504+
#ifdef CONFIG_I2C_TARGET
505505
// Slave Transmit
506506
case 0xB8: // Slave Transmit Data ACK
507507
case 0xA8: // Slave Transmit Address ACK
@@ -671,7 +671,7 @@ static void i2c_numaker_isr(const struct device *dev)
671671
nu_int_i2c_disable_int(dev);
672672
}
673673
break;
674-
#endif /* CONFIG_I2C_SLAVE */
674+
#endif /* CONFIG_I2C_TARGET */
675675

676676
case 0xF8: // Bus Released
677677
break;
@@ -739,7 +739,7 @@ static int i2c_numaker_init(const struct device *dev)
739739

740740
SYS_ResetModule(config->id_rst);
741741

742-
err = i2c_numaker_configure(dev, I2C_MODE_MASTER | i2c_map_dt_bitrate(config->bitrate));
742+
err = i2c_numaker_configure(dev, I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(config->bitrate));
743743
if (err != 0) {
744744
goto cleanup;
745745
}
@@ -756,9 +756,9 @@ static const struct i2c_driver_api i2c_numaker_driver_api = {
756756
.configure = i2c_numaker_configure,
757757
.get_config = i2c_numaker_get_config,
758758
.transfer = i2c_numaker_transfer,
759-
#ifdef CONFIG_I2C_SLAVE
760-
.slave_register = i2c_numaker_slave_register,
761-
.slave_unregister = i2c_numaker_slave_unregister,
759+
#ifdef CONFIG_I2C_TARGET
760+
.target_register = i2c_numaker_slave_register,
761+
.target_unregister = i2c_numaker_slave_unregister,
762762
#endif
763763
.recover_bus = i2c_numaker_recover_bus,
764764
};
@@ -831,7 +831,7 @@ static void nu_int_i2c_fsm_reset(const struct device *dev, uint32_t i2c_ctl)
831831
data->i2c.tran_ctrl = 0;
832832

833833
I2C_SET_CONTROL_REG(i2c_base, i2c_ctl);
834-
#ifdef CONFIG_I2C_SLAVE
834+
#ifdef CONFIG_I2C_TARGET
835835
data->i2c.slaveaddr_state = NoData;
836836
#endif
837837
}
@@ -1014,7 +1014,7 @@ static int nu_int_i2c_addr2data(int address, int read)
10141014
return read ? ((address << 1) | 1) : (address << 1);
10151015
}
10161016

1017-
#ifdef CONFIG_I2C_SLAVE
1017+
#ifdef CONFIG_I2C_TARGET
10181018
static int nu_int_i2c_addr2bspaddr(int address)
10191019
{
10201020
return address;

drivers/usb/device/usb_dc_numaker.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ struct nu_usb_dc_ep {
162162
uint32_t usbd_hw_ep_cfg; // Saved for easy control with BSP driver
163163
#endif
164164

165-
bool FIFO_need_own; // For USBD, FIFO cannot access simultaneously by CPU and H/W, and needs ownership management
165+
bool fifo_need_own; // For USBD, FIFO cannot access simultaneously by CPU and H/W, and needs ownership management
166166

167167
usb_dc_ep_callback cb; // Endpoint callback function
168168

169169
uint32_t zero_end; // Mark the end of fields which can initialize to zero
170170

171-
bool FIFO_own_sem_valid; // FIFO ownership semaphore valid
172-
struct k_sem FIFO_own_sem; // FIFO ownership semaphore
171+
bool fifo_own_sem_valid; // FIFO ownership semaphore valid
172+
struct k_sem fifo_own_sem; // FIFO ownership semaphore
173173
};
174174

175175
/* Endpoint management context */
@@ -695,8 +695,8 @@ int usb_dc_ep_write(const uint8_t ep_addr, const uint8_t *const data_buf,
695695
}
696696

697697
/* Try to acquire EP DMA buffer ownership on behalf of H/W */
698-
if (ep_cur->FIFO_need_own) {
699-
rc = k_sem_take(&ep_cur->FIFO_own_sem, K_NO_WAIT);
698+
if (ep_cur->fifo_need_own) {
699+
rc = k_sem_take(&ep_cur->fifo_own_sem, K_NO_WAIT);
700700
if (rc < 0) {
701701
LOG_WRN("ep_addr 0x%02x busy", ep_addr);
702702
rc = -EAGAIN;
@@ -824,8 +824,8 @@ int usb_dc_ep_read_wait(uint8_t ep_addr, uint8_t *data_buf, uint32_t max_data_le
824824
}
825825

826826
/* We cannot read on FIFO being owned by H/W */
827-
if (ep_cur->FIFO_need_own) {
828-
if (!k_sem_count_get(&ep_cur->FIFO_own_sem)) {
827+
if (ep_cur->fifo_need_own) {
828+
if (!k_sem_count_get(&ep_cur->fifo_own_sem)) {
829829
LOG_WRN("ep_addr 0x%02x busy", ep_addr);
830830
rc = -EAGAIN;
831831
goto cleanup;
@@ -891,8 +891,8 @@ int usb_dc_ep_read_continue(uint8_t ep_addr)
891891
}
892892

893893
/* Try to acquire EP FIFO ownership on behalf of H/W */
894-
if (ep_cur->FIFO_need_own) {
895-
rc = k_sem_take(&ep_cur->FIFO_own_sem, K_NO_WAIT);
894+
if (ep_cur->fifo_need_own) {
895+
rc = k_sem_take(&ep_cur->fifo_own_sem, K_NO_WAIT);
896896
if (rc < 0) {
897897
LOG_DBG("ep_addr 0x%02x has triggered", ep_addr);
898898
rc = 0;
@@ -1602,15 +1602,15 @@ static void nu_usb_dc_ep_mgmt_init(struct usb_dc_numaker_device *dev)
16021602

16031603
/* FIFO needs ownership or not */
16041604
#if DT_HAS_COMPAT_STATUS_OKAY(nuvoton_numaker_usbd) && defined(CONFIG_USB_DC_NUMAKER_USBD)
1605-
ep_cur->FIFO_need_own = true;
1605+
ep_cur->fifo_need_own = true;
16061606
#endif
16071607

16081608
/* Initialize FIFO ownership semaphore if not yet, and signal H/W doesn't own it */
1609-
if (!ep_cur->FIFO_own_sem_valid) {
1610-
k_sem_init(&ep_cur->FIFO_own_sem, 1, 1);
1611-
ep_cur->FIFO_own_sem_valid = true;
1609+
if (!ep_cur->fifo_own_sem_valid) {
1610+
k_sem_init(&ep_cur->fifo_own_sem, 1, 1);
1611+
ep_cur->fifo_own_sem_valid = true;
16121612
} else {
1613-
k_sem_give(&ep_cur->FIFO_own_sem);
1613+
k_sem_give(&ep_cur->fifo_own_sem);
16141614
}
16151615
}
16161616

@@ -1821,8 +1821,8 @@ static void nu_usb_dc_ep_bh(struct nu_usb_dc_ep *ep_cur, enum usb_dc_ep_cb_statu
18211821
nu_usb_dc_ep_fifo_update(ep_cur);
18221822

18231823
/* Relinquish EP FIFO ownership on behalf of H/W */
1824-
if (ep_cur->FIFO_need_own) {
1825-
k_sem_give(&ep_cur->FIFO_own_sem);
1824+
if (ep_cur->fifo_need_own) {
1825+
k_sem_give(&ep_cur->fifo_own_sem);
18261826
}
18271827
} else if (status_code == USB_DC_EP_DATA_IN) {
18281828
__ASSERT_NO_MSG(USB_EP_DIR_IS_IN(ep_cur->ep_addr));
@@ -1831,8 +1831,8 @@ static void nu_usb_dc_ep_bh(struct nu_usb_dc_ep *ep_cur, enum usb_dc_ep_cb_statu
18311831
nu_usb_dc_ep_fifo_update(ep_cur);
18321832

18331833
/* Relinquish EP FIFO ownership on behalf of H/W */
1834-
if (ep_cur->FIFO_need_own) {
1835-
k_sem_give(&ep_cur->FIFO_own_sem);
1834+
if (ep_cur->fifo_need_own) {
1835+
k_sem_give(&ep_cur->fifo_own_sem);
18361836
}
18371837
}
18381838
}
@@ -2180,9 +2180,9 @@ static void nu_usb_dc_ep_abort(struct nu_usb_dc_ep *ep_cur)
21802180
#endif
21812181

21822182
/* Relinquish EP FIFO ownership on behalf of H/W */
2183-
if (ep_cur->FIFO_need_own) {
2184-
if (ep_cur->FIFO_own_sem_valid) {
2185-
k_sem_give(&ep_cur->FIFO_own_sem);
2183+
if (ep_cur->fifo_need_own) {
2184+
if (ep_cur->fifo_own_sem_valid) {
2185+
k_sem_give(&ep_cur->fifo_own_sem);
21862186
}
21872187
}
21882188
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
CONFIG_I2C=y
2-
CONFIG_I2C_SLAVE=y
2+
CONFIG_I2C_TARGET=y

tests/drivers/i2c/i2c_target_api/boards/numaker_pfm_m467.overlay

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
eeprom0: eeprom@54 {
2121
compatible = "atmel,at24";
2222
reg = <0x54>;
23-
label = "EEPROM_0";
2423
size = <1024>;
2524
pagesize = <16>;
2625
address-width = <8>;
@@ -36,7 +35,6 @@
3635
eeprom1: eeprom@56 {
3736
compatible = "atmel,at24";
3837
reg = <0x56>;
39-
label = "EEPROM_1";
4038
size = <1024>;
4139
pagesize = <16>;
4240
address-width = <8>;

0 commit comments

Comments
 (0)