aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorRichard Zhu <r65037@freescale.com>2014-04-11 03:11:14 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:58:21 -0400
commit39e6a62bc0f89d34c7b62294aef343eac38ce982 (patch)
tree3f407d7b81ef9ef1787bddc6bca719601a63aa69 /include/linux
parentd9bc7e358e1494e29da5acc4c33c1144cdbd31f2 (diff)
ENGR00308060-3 mcc: add sema4 driver required by mcc
- add linux sema4 driver, that mandatory required by mcc. - use volatile types in sema4 structure - align the port definiton a9 is 1, m4 is 2. Signed-off-by: Richard Zhu <r65037@freescale.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/imx_sema4.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/include/linux/imx_sema4.h b/include/linux/imx_sema4.h
new file mode 100644
index 000000000000..51a25e1b51bc
--- /dev/null
+++ b/include/linux/imx_sema4.h
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2014 Freescale Semiconductor, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __LINUX_IMX_SEMA4_H__
10#define __LINUX_IMX_SEMA4_H__
11
12/* semaphore number */
13#define MCC_SHMEM_SEMAPHORE_NUMBER (1)
14#define MCC_PRINTF_SEMAPHORE_NUMBER (2)
15#define MCC_I2C_SEMAPHORE_NUMBER (3)
16#define MCC_RESERVED1_SEMAPHORE_NUMBER (4)
17#define MCC_RESERVED2_SEMAPHORE_NUMBER (5)
18
19#define SEMA4_NUM_DEVICES 1
20#define SEMA4_NUM_GATES 16
21
22#define SEMA4_UNLOCK 0x00
23#define SEMA4_A9_LOCK 0x01
24#define SEMA4_GATE_MASK 0x03
25
26#define CORE_MUTEX_VALID (('c'<<24)|('m'<<24)|('t'<<24)|'x')
27
28/*
29 * The enumerates
30 */
31enum {
32 /* sema4 registers offset */
33 SEMA4_CP0INE = 0x40,
34 SEMA4_CP1INE = 0x48,
35 SEMA4_CP0NTF = 0x80,
36 SEMA4_CP1NTF = 0x88,
37};
38
39static const unsigned int idx_sema4[16] = {
40 1 << 7, 1 << 6, 1 << 5, 1 << 4,
41 1 << 3, 1 << 2, 1 << 1, 1 << 0,
42 1 << 15, 1 << 14, 1 << 13, 1 << 12,
43 1 << 11, 1 << 10, 1 << 9, 1 << 8,
44};
45
46struct imx_sema4_mutex {
47 u32 valid;
48 u32 gate_num;
49 unsigned char gate_val;
50 wait_queue_head_t wait_q;
51};
52
53struct imx_sema4_mutex_device {
54 struct device *dev;
55 u16 cpntf_val;
56 u16 cpine_val;
57 void __iomem *ioaddr; /* Mapped address */
58 spinlock_t lock; /* Mutex */
59 int irq;
60
61 u16 alloced;
62 struct imx_sema4_mutex *mutex_ptr[16];
63};
64
65struct imx_sema4_mutex *
66 imx_sema4_mutex_create(u32 dev_num, u32 mutex_num);
67int imx_sema4_mutex_destroy(struct imx_sema4_mutex *mutex_ptr);
68int imx_sema4_mutex_trylock(struct imx_sema4_mutex *mutex_ptr);
69int imx_sema4_mutex_lock(struct imx_sema4_mutex *mutex_ptr);
70int imx_sema4_mutex_unlock(struct imx_sema4_mutex *mutex_ptr);
71#endif /* __LINUX_IMX_SEMA4_H__ */