1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
* Copyright (C) 2014 Samsung Electronics Co.Ltd
* http://www.samsung.com
*
* MCU IPC driver
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef MCU_IPC_H
#define MCU_IPC_H
#define MCU_IPC_INT0 (0)
#define MCU_IPC_INT1 (1)
#define MCU_IPC_INT2 (2)
#define MCU_IPC_INT3 (3)
#define MCU_IPC_INT4 (4)
#define MCU_IPC_INT5 (5)
#define MCU_IPC_INT6 (6)
#define MCU_IPC_INT7 (7)
#define MCU_IPC_INT8 (8)
#define MCU_IPC_INT9 (9)
#define MCU_IPC_INT10 (10)
#define MCU_IPC_INT11 (11)
#define MCU_IPC_INT12 (12)
#define MCU_IPC_INT13 (13)
#define MCU_IPC_INT14 (14)
#define MCU_IPC_INT15 (15)
extern int mbox_request_irq(u32 int_num,
void (*handler)(void *), void *data);
extern int mcu_ipc_unregister_handler(u32 int_num,
void (*handler)(void *));
extern void mbox_set_interrupt(u32 int_num);
extern void mcu_ipc_send_command(u32 int_num, u16 cmd);
extern u32 mbox_get_value(u32 mbx_num);
extern void mbox_set_value(u32 mbx_num, u32 msg);
struct mcu_ipc_ipc_handler {
void *data;
void (*handler)(void *);
};
struct mcu_ipc_drv_data {
char *name;
void __iomem *ioaddr;
u32 registered_irq;
struct device *mcu_ipc_dev;
struct mcu_ipc_ipc_handler hd[16];
};
static struct mcu_ipc_drv_data mcu_dat;
static inline void mcu_ipc_writel(u32 val, long reg)
{
writel(val, mcu_dat.ioaddr + reg);
}
static inline u32 mcu_ipc_readl(long reg)
{
return readl(mcu_dat.ioaddr + reg);
}
#define mcu_dt_read_enum(np, prop, dest) \
do { \
u32 val; \
if (of_property_read_u32(np, prop, &val)) \
return -EINVAL; \
dest = (__typeof__(dest))(val); \
} while (0)
#define mcu_dt_read_bool(np, prop, dest) \
do { \
u32 val; \
if (of_property_read_u32(np, prop, &val)) \
return -EINVAL; \
dest = val ? true : false; \
} while (0)
#define mcu_dt_read_string(np, prop, dest) \
do { \
if (of_property_read_string(np, prop, \
(const char **)&dest)) \
return -EINVAL; \
} while (0)
#define mcu_dt_read_u32(np, prop, dest) \
do { \
u32 val; \
if (of_property_read_u32(np, prop, &val)) \
return -EINVAL; \
dest = val; \
} while (0)
#endif
|