2015-11-13 06:00:47 +08:00
|
|
|
/* ipm_quark_se.h - Quark SE mailbox driver */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-11-13 06:00:47 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_DRIVERS_IPM_IPM_QUARK_SE_H_
|
|
|
|
#define ZEPHYR_DRIVERS_IPM_IPM_QUARK_SE_H_
|
2015-11-13 06:00:47 +08:00
|
|
|
|
2016-12-05 04:59:37 +08:00
|
|
|
#include <kernel.h>
|
2018-11-01 01:44:45 +08:00
|
|
|
#include <soc.h> /* for SCSS_REGISTER_BASE */
|
2015-11-13 06:00:47 +08:00
|
|
|
#include <ipm.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-05-03 20:51:18 +08:00
|
|
|
#define QUARK_SE_IPM_OUTBOUND 0
|
2015-11-13 06:00:47 +08:00
|
|
|
#define QUARK_SE_IPM_INBOUND 1
|
|
|
|
|
2016-08-30 20:41:04 +08:00
|
|
|
#if defined(CONFIG_SOC_QUARK_SE_C1000)
|
2015-11-13 06:00:47 +08:00
|
|
|
/* First byte of the QUARK_SE_IPM_MASK register is for the Lakemont */
|
|
|
|
#define QUARK_SE_IPM_MASK_START_BIT 0
|
2017-05-03 20:51:18 +08:00
|
|
|
#define QUARK_SE_IPM_INTERRUPT 21
|
2015-11-13 06:00:47 +08:00
|
|
|
#define QUARK_SE_IPM_ARC_LMT_DIR QUARK_SE_IPM_INBOUND
|
|
|
|
#define QUARK_SE_IPM_LMT_ARC_DIR QUARK_SE_IPM_OUTBOUND
|
|
|
|
|
2016-08-30 20:27:26 +08:00
|
|
|
#elif defined(CONFIG_SOC_QUARK_SE_C1000_SS)
|
2015-11-13 06:00:47 +08:00
|
|
|
/* Second byte is for ARC */
|
|
|
|
#define QUARK_SE_IPM_MASK_START_BIT 8
|
2017-05-03 20:51:18 +08:00
|
|
|
#define QUARK_SE_IPM_INTERRUPT 57
|
2015-11-13 06:00:47 +08:00
|
|
|
#define QUARK_SE_IPM_ARC_LMT_DIR QUARK_SE_IPM_OUTBOUND
|
|
|
|
#define QUARK_SE_IPM_LMT_ARC_DIR QUARK_SE_IPM_INBOUND
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error "Unsupported platform for ipm_quark_se driver"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define QUARK_SE_IPM_CHANNELS 8
|
2017-05-30 19:16:39 +08:00
|
|
|
#define QUARK_SE_IPM_DATA_REGS 4
|
2015-11-13 06:00:47 +08:00
|
|
|
#define QUARK_SE_IPM_MAX_ID_VAL 0x7FFFFFFF
|
|
|
|
|
|
|
|
/* QUARK_SE EAS section 28.5.1.123 */
|
2017-05-30 19:16:39 +08:00
|
|
|
#define QUARK_SE_IPM_CTRL_CTRL_MASK BIT_MASK(31)
|
|
|
|
#define QUARK_SE_IPM_CTRL_IRQ_BIT BIT(31)
|
2015-11-13 06:00:47 +08:00
|
|
|
|
2017-05-30 19:16:39 +08:00
|
|
|
#define QUARK_SE_IPM_STS_STS_BIT BIT(0)
|
|
|
|
#define QUARK_SE_IPM_STS_IRQ_BIT BIT(1)
|
2015-11-13 06:00:47 +08:00
|
|
|
|
|
|
|
struct __packed quark_se_ipm {
|
2017-05-30 19:16:39 +08:00
|
|
|
u32_t ctrl;
|
|
|
|
u32_t data[QUARK_SE_IPM_DATA_REGS]; /* contiguous 32-bit registers */
|
|
|
|
u32_t sts;
|
2015-11-13 06:00:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Base address for mailboxes
|
|
|
|
*
|
|
|
|
* Layout:
|
|
|
|
*
|
|
|
|
* quark_se_ipm[8]
|
|
|
|
* QUARK_SE_IPM_CHALL_STS
|
|
|
|
*/
|
|
|
|
#define QUARK_SE_IPM_BASE (SCSS_REGISTER_BASE + 0xa00)
|
|
|
|
|
|
|
|
/* 28.5.1.73 Host processor Interrupt routing mask 21
|
|
|
|
*
|
|
|
|
* Bits Description
|
|
|
|
* 31:24 Mailbox SS Halt interrupt maskIUL
|
|
|
|
* 23:16 Mailbox Host Halt interrupt mask
|
|
|
|
* 15:8 Mailbox SS interrupt mask
|
|
|
|
* 7:0 Mailbox Host interrupt mask
|
|
|
|
*/
|
|
|
|
#define QUARK_SE_IPM_MASK (SCSS_REGISTER_BASE + 0x4a0)
|
|
|
|
|
|
|
|
/* All status bits of the mailboxes
|
|
|
|
*
|
|
|
|
* Bits Description
|
|
|
|
* 31:16 Reserved
|
|
|
|
* 15:0 CHn_STS bits (sts/irq) for all channels
|
|
|
|
*/
|
|
|
|
#define QUARK_SE_IPM_CHALL_STS (SCSS_REGISTER_BASE + 0x0AC0)
|
|
|
|
|
|
|
|
#define QUARK_SE_IPM(channel) ((volatile struct quark_se_ipm *)(QUARK_SE_IPM_BASE + \
|
|
|
|
((channel) * sizeof(struct quark_se_ipm))))
|
|
|
|
|
|
|
|
struct quark_se_ipm_controller_config_info {
|
|
|
|
int (*controller_init)(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct quark_se_ipm_config_info {
|
|
|
|
int channel;
|
|
|
|
int direction;
|
|
|
|
volatile struct quark_se_ipm *ipm;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct quark_se_ipm_driver_data {
|
|
|
|
ipm_callback_t callback;
|
|
|
|
void *callback_ctx;
|
|
|
|
};
|
|
|
|
|
2018-11-27 16:32:45 +08:00
|
|
|
extern const struct ipm_driver_api ipm_quark_se_api_funcs;
|
2016-04-15 00:28:35 +08:00
|
|
|
|
2015-11-13 06:00:47 +08:00
|
|
|
void quark_se_ipm_isr(void *param);
|
|
|
|
|
|
|
|
int quark_se_ipm_initialize(struct device *d);
|
|
|
|
int quark_se_ipm_controller_initialize(struct device *d);
|
|
|
|
|
|
|
|
#define QUARK_SE_IPM_DEFINE(name, ch, dir) \
|
|
|
|
struct quark_se_ipm_config_info quark_se_ipm_config_##name = { \
|
|
|
|
.ipm = QUARK_SE_IPM(ch), \
|
|
|
|
.channel = ch, \
|
|
|
|
.direction = dir \
|
|
|
|
}; \
|
|
|
|
struct quark_se_ipm_driver_data quark_se_ipm_runtime_##name; \
|
2019-03-09 05:19:05 +08:00
|
|
|
DEVICE_AND_API_INIT(name, Z_STRINGIFY(name), quark_se_ipm_initialize, \
|
2016-04-15 00:28:35 +08:00
|
|
|
&quark_se_ipm_runtime_##name, \
|
|
|
|
&quark_se_ipm_config_##name, \
|
2016-11-09 03:06:55 +08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
2016-04-15 00:28:35 +08:00
|
|
|
&ipm_quark_se_api_funcs)
|
2015-11-13 06:00:47 +08:00
|
|
|
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2015-11-13 06:00:47 +08:00
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_DRIVERS_IPM_IPM_QUARK_SE_H_ */
|