static int spi_qmsi_init(struct device *dev) { struct spi_qmsi_config *spi_config = dev->config->config_info; struct spi_qmsi_runtime *context = dev->driver_data; dev->driver_api = &spi_qmsi_api; switch (spi_config->spi) { case QM_SPI_MST_0: IRQ_CONNECT(CONFIG_SPI_QMSI_PORT_0_IRQ, CONFIG_SPI_QMSI_PORT_0_PRI, qm_spi_master_0_isr, 0, IOAPIC_LEVEL | IOAPIC_HIGH); irq_enable(CONFIG_SPI_QMSI_PORT_0_IRQ); clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_SPI_M0_REGISTER); QM_SCSS_INT->int_spi_mst_0_mask &= ~BIT(0); break; case QM_SPI_MST_1: IRQ_CONNECT(CONFIG_SPI_QMSI_PORT_1_IRQ, CONFIG_SPI_QMSI_PORT_1_PRI, qm_spi_master_1_isr, 0, IOAPIC_LEVEL | IOAPIC_HIGH); irq_enable(CONFIG_SPI_QMSI_PORT_1_IRQ); clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_SPI_M1_REGISTER); QM_SCSS_INT->int_spi_mst_1_mask &= ~BIT(0); break; default: return DEV_FAIL; } context->gpio_cs = gpio_cs_init(spi_config); device_sync_call_init(&context->sync); return DEV_OK; }
static int spi_qmsi_init(struct device *dev) { const struct spi_qmsi_config *spi_config = dev->config->config_info; struct spi_qmsi_runtime *context = dev->driver_data; switch (spi_config->spi) { case QM_SPI_MST_0: IRQ_CONNECT(IRQ_GET_NUMBER(QM_IRQ_SPI_MASTER_0_INT), CONFIG_SPI_0_IRQ_PRI, qm_spi_master_0_isr, 0, IOAPIC_LEVEL | IOAPIC_HIGH); irq_enable(IRQ_GET_NUMBER(QM_IRQ_SPI_MASTER_0_INT)); clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_SPI_M0_REGISTER); QM_IR_UNMASK_INTERRUPTS( QM_INTERRUPT_ROUTER->spi_master_0_int_mask); break; #ifdef CONFIG_SPI_1 case QM_SPI_MST_1: IRQ_CONNECT(IRQ_GET_NUMBER(QM_IRQ_SPI_MASTER_1_INT), CONFIG_SPI_1_IRQ_PRI, qm_spi_master_1_isr, 0, IOAPIC_LEVEL | IOAPIC_HIGH); irq_enable(IRQ_GET_NUMBER(QM_IRQ_SPI_MASTER_1_INT)); clk_periph_enable(CLK_PERIPH_CLK | CLK_PERIPH_SPI_M1_REGISTER); QM_IR_UNMASK_INTERRUPTS( QM_INTERRUPT_ROUTER->spi_master_1_int_mask); break; #endif /* CONFIG_SPI_1 */ default: return -EIO; } context->gpio_cs = gpio_cs_init(spi_config); k_sem_init(&context->device_sync_sem, 0, UINT_MAX); k_sem_init(&context->sem, 1, UINT_MAX); spi_master_set_power_state(dev, DEVICE_PM_ACTIVE_STATE); dev->driver_api = &spi_qmsi_api; return 0; }