1 #ifndef __SEP_DEV_H__
2 #define __SEP_DEV_H__
3
4 /*
5 *
6 * sep_dev.h - Security Processor Device Structures
7 *
8 * Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
9 * Contributions(c) 2009,2010 Discretix. All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program; if not, write to the Free Software Foundation, Inc., 59
22 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 * CONTACTS:
25 *
26 * Mark Allyn mark.a.allyn@intel.com
27 * Jayant Mangalampalli jayant.mangalampalli@intel.com
28 *
29 * CHANGES
30 * 2010.09.14 upgrade to Medfield
31 */
32
33 struct sep_device {
34 /* pointer to pci dev */
35 struct pci_dev *pdev;
36
37 /* character device file */
38 struct cdev sep_cdev;
39 struct cdev sep_daemon_cdev;
40 struct cdev sep_singleton_cdev;
41
42 /* devices (using misc dev) */
43 struct miscdevice miscdev_sep;
44 struct miscdevice miscdev_singleton;
45 struct miscdevice miscdev_daemon;
46
47 /* major / minor numbers of device */
48 dev_t sep_devno;
49 dev_t sep_daemon_devno;
50 dev_t sep_singleton_devno;
51
52 struct mutex sep_mutex;
53 struct mutex ioctl_mutex;
54 spinlock_t snd_rply_lck;
55
56 /* flags to indicate use and lock status of sep */
57 u32 pid_doing_transaction;
58 unsigned long in_use_flags;
59
60 /* request daemon alread open */
61 unsigned long request_daemon_open;
62
63 /* 1 = Moorestown; 0 = Medfield */
64 int mrst;
65
66 /* address of the shared memory allocated during init for SEP driver
67 (coherent alloc) */
68 dma_addr_t shared_bus;
69 size_t shared_size;
70 void *shared_addr;
71
72 /* start address of the access to the SEP registers from driver */
73 dma_addr_t reg_physical_addr;
74 dma_addr_t reg_physical_end;
75 void __iomem *reg_addr;
76
77 /* wait queue head (event) of the driver */
78 wait_queue_head_t event;
79 wait_queue_head_t event_request_daemon;
80 wait_queue_head_t event_mmap;
81
82 struct sep_caller_id_entry
83 caller_id_table[SEP_CALLER_ID_TABLE_NUM_ENTRIES];
84
85 /* access flag for singleton device */
86 unsigned long singleton_access_flag;
87
88 /* transaction counter that coordinates the
89 transactions between SEP and HOST */
90 unsigned long send_ct;
91 /* counter for the messages from sep */
92 unsigned long reply_ct;
93 /* counter for the number of bytes allocated in the pool for the
94 current transaction */
95 long data_pool_bytes_allocated;
96
97 u32 num_of_data_allocations;
98
99 /* number of the lli tables created in the current transaction */
100 u32 num_lli_tables_created;
101
102 /* number of data control blocks */
103 u32 nr_dcb_creat;
104
105 struct sep_dma_resource dma_res_arr[SEP_MAX_NUM_SYNC_DMA_OPS];
106
107 };
108
sep_write_reg(struct sep_device * dev,int reg,u32 value)109 static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
110 {
111 void __iomem *addr = dev->reg_addr + reg;
112 writel(value, addr);
113 }
114
sep_read_reg(struct sep_device * dev,int reg)115 static inline u32 sep_read_reg(struct sep_device *dev, int reg)
116 {
117 void __iomem *addr = dev->reg_addr + reg;
118 return readl(addr);
119 }
120
121 /* wait for SRAM write complete(indirect write */
sep_wait_sram_write(struct sep_device * dev)122 static inline void sep_wait_sram_write(struct sep_device *dev)
123 {
124 u32 reg_val;
125 do {
126 reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
127 } while (!(reg_val & 1));
128 }
129
130
131 #endif
132