Skip to content

Commit afefcd1

Browse files
dcpleunggalak
authored andcommitted
neural_net: intel_gna: convert driver to use device-tree
This converts the intel_gna driver to use device tree instead of kconfig for device configuration. Fixes #30872 Signed-off-by: Daniel Leung <[email protected]>
1 parent 7312d36 commit afefcd1

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

drivers/neural_net/Kconfig.intel_gna

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ menuconfig INTEL_GNA
1010

1111
if INTEL_GNA
1212

13-
config INTEL_GNA_NAME
14-
string "GNA device name"
15-
default "GNA0"
16-
help
17-
Name of the GNA device this device driver can use.
18-
1913
config INTEL_GNA_INIT_PRIORITY
2014
int "Init priority"
2115
default 99

drivers/neural_net/intel_gna.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
* Gaussian Mixture Model and Neural Network Accelerator (GNA)
1414
*/
1515

16+
#define DT_DRV_COMPAT intel_gna
17+
1618
#include <kernel.h>
1719
#include <string.h>
1820
#include <device.h>
1921
#include <drivers/gna.h>
2022

23+
#include <memory.h>
2124
#include "intel_gna.h"
2225

2326
#define LOG_LEVEL CONFIG_NEURAL_NET_LOG_LEVEL
@@ -210,7 +213,7 @@ static int intel_gna_initialize(const struct device *dev)
210213
DEV_NAME(dev), &gna_config_desc);
211214

212215
/* register interrupt handler */
213-
IRQ_CONNECT(INTEL_GNA_IRQ_ID, INTEL_GNA_IRQ_PRIORITY,
216+
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
214217
intel_gna_interrupt_handler, DEVICE_GET(gna), 0);
215218
/* enable interrupt */
216219
irq_enable(INTEL_GNA_IRQ_ID);
@@ -222,7 +225,6 @@ static int intel_gna_initialize(const struct device *dev)
222225
static int intel_gna_configure(const struct device *dev,
223226
struct gna_config *cfg)
224227
{
225-
const struct intel_gna_config *const dev_cfg = DEV_CFG(dev);
226228
struct intel_gna_data *const gna = DEV_DATA(dev);
227229
volatile struct intel_gna_regs *regs = gna->regs;
228230

@@ -237,7 +239,7 @@ static int intel_gna_configure(const struct device *dev,
237239
return -EINVAL;
238240
}
239241

240-
dev_cfg->config = *cfg;
242+
gna->config = *cfg;
241243

242244
regs->gnactrl |= GNA_CTRL_OPER_MODEL_XNN |
243245
GNA_CTRL_ERR_INTR_ENABLE | GNA_CTRL_COMPL_INTR_ENABLE;
@@ -283,7 +285,7 @@ static int intel_gna_register_model(const struct device *dev,
283285
struct intel_gna_data *const gna = DEV_DATA(dev);
284286
struct intel_gna_model *gna_model;
285287
struct gna_model_header *header;
286-
uint32_t ro_size, rw_size;
288+
uint32_t ro_size, rw_size = 0;
287289
void *virtual_base;
288290
void *ro_region;
289291

@@ -518,12 +520,12 @@ static const struct gna_driver_api gna_driver_api = {
518520
.infer = intel_gna_infer,
519521
};
520522

521-
static struct intel_gna_config intel_gna_config;
522523
static struct intel_gna_data intel_gna_driver_data = {
523-
.regs = (volatile struct intel_gna_regs *)INTEL_GNA_BASE_ADDR,
524+
.regs = (volatile struct intel_gna_regs *)DT_INST_REG_ADDR(0),
524525
};
525526

526-
DEVICE_DEFINE(gna, CONFIG_INTEL_GNA_NAME, intel_gna_initialize,
527-
device_pm_control_nop, (void *)&intel_gna_driver_data,
528-
&intel_gna_config, POST_KERNEL,
529-
CONFIG_INTEL_GNA_INIT_PRIORITY, &gna_driver_api);
527+
DEVICE_DT_INST_DEFINE(0, intel_gna_initialize,
528+
device_pm_control_nop,
529+
(void *)&intel_gna_driver_data, NULL,
530+
POST_KERNEL, CONFIG_INTEL_GNA_INIT_PRIORITY,
531+
&gna_driver_api);

drivers/neural_net/intel_gna.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ struct intel_gna_data {
194194
struct k_msgq response_queue;
195195
struct intel_gna_pending_resp responses[GNA_REQUEST_QUEUE_LEN];
196196
enum gna_state state;
197+
198+
struct gna_config config;
197199
};
198200

199201
#ifdef __cplusplus

0 commit comments

Comments
 (0)