blob: f0dc715cbcb6b755352a664e8cccfa19e7e7a0d1 [file] [log] [blame]
Alan Coxf5e39802009-08-06 20:45:07 +01001#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 Intel Corporation. All rights reserved.
9 * Copyright(c) 2009 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; either version 2 of the License, or (at your option)
14 * any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * this program; if not, write to the Free Software Foundation, Inc., 59
23 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 *
25 * CONTACTS:
26 *
27 * Alan Cox alan@linux.intel.com
28 *
29 */
30
31struct sep_device {
32 /* pointer to pci dev */
Alan Cox904290c2009-08-07 19:24:18 +010033 struct pci_dev *pdev;
Alan Coxf5e39802009-08-06 20:45:07 +010034
Alan Cox904290c2009-08-07 19:24:18 +010035 unsigned long io_bus;
36 unsigned long io_end_bus;
Alan Coxf5e39802009-08-06 20:45:07 +010037 unsigned long io_memory_size;
Alan Cox904290c2009-08-07 19:24:18 +010038 void __iomem *io_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010039
40 /* restricted access region */
Alan Cox790cf1b2009-08-07 19:25:16 +010041 dma_addr_t rar_bus;
Alan Cox904290c2009-08-07 19:24:18 +010042 void *rar_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010043
44 /* shared memory region */
Alan Cox790cf1b2009-08-07 19:25:16 +010045 dma_addr_t shared_bus;
Alan Cox904290c2009-08-07 19:24:18 +010046 void *shared_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010047
48 /* firmware regions */
Alan Cox790cf1b2009-08-07 19:25:16 +010049 dma_addr_t cache_bus;
Alan Coxf5e39802009-08-06 20:45:07 +010050 unsigned long cache_size;
Alan Cox904290c2009-08-07 19:24:18 +010051 void *cache_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010052
Alan Cox790cf1b2009-08-07 19:25:16 +010053 dma_addr_t resident_bus;
Alan Coxf5e39802009-08-06 20:45:07 +010054 unsigned long resident_size;
Alan Cox904290c2009-08-07 19:24:18 +010055 void *resident_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010056
Alan Cox6f13ea32009-08-14 15:41:50 +010057 void *rar_region_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010058
59 /* start address of the access to the SEP registers from driver */
Alan Cox904290c2009-08-07 19:24:18 +010060 void __iomem *reg_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010061 /* transaction counter that coordinates the transactions between SEP and HOST */
Alan Cox904290c2009-08-07 19:24:18 +010062 unsigned long send_ct;
Alan Coxf5e39802009-08-06 20:45:07 +010063 /* counter for the messages from sep */
Alan Cox904290c2009-08-07 19:24:18 +010064 unsigned long reply_ct;
Alan Coxf5e39802009-08-06 20:45:07 +010065 /* counter for the number of bytes allocated in the pool for the current
Alan Coxd19cf322009-08-06 20:45:57 +010066 transaction */
Alan Coxf5e39802009-08-06 20:45:07 +010067 unsigned long data_pool_bytes_allocated;
68
69 /* array of pointers to the pages that represent input data for the synchronic
Alan Coxd19cf322009-08-06 20:45:57 +010070 DMA action */
Alan Coxf5e39802009-08-06 20:45:07 +010071 struct page **in_page_array;
72
73 /* array of pointers to the pages that represent out data for the synchronic
Alan Coxd19cf322009-08-06 20:45:57 +010074 DMA action */
Alan Coxf5e39802009-08-06 20:45:07 +010075 struct page **out_page_array;
76
77 /* number of pages in the sep_in_page_array */
78 unsigned long in_num_pages;
79
80 /* number of pages in the sep_out_page_array */
81 unsigned long out_num_pages;
82
83 /* global data for every flow */
Alan Cox904290c2009-08-07 19:24:18 +010084 struct sep_flow_context_t flows[SEP_DRIVER_NUM_FLOWS];
Alan Coxf5e39802009-08-06 20:45:07 +010085
Alan Coxf5e39802009-08-06 20:45:07 +010086 /* pointer to the workqueue that handles the flow done interrupts */
Alan Cox904290c2009-08-07 19:24:18 +010087 struct workqueue_struct *flow_wq;
Alan Coxf5e39802009-08-06 20:45:07 +010088
89 /* address of the shared memory allocated during init for SEP driver */
Alan Cox790cf1b2009-08-07 19:25:16 +010090 void *shared_area;
Alan Coxf5e39802009-08-06 20:45:07 +010091 /* the physical address of the shared area */
Alan Cox790cf1b2009-08-07 19:25:16 +010092 dma_addr_t shared_area_bus;
Alan Coxf5e39802009-08-06 20:45:07 +010093
94 /* Message Shared Area start address - will be allocated during init */
Alan Cox790cf1b2009-08-07 19:25:16 +010095 void *message_shared_area_addr;
Alan Coxf5e39802009-08-06 20:45:07 +010096};
97
Alan Coxb10b4832009-08-07 19:23:26 +010098static struct sep_device *sep_dev;
Alan Coxf5e39802009-08-06 20:45:07 +010099
Alan Cox79de99e82009-08-06 20:45:24 +0100100static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
Alan Coxf5e39802009-08-06 20:45:07 +0100101{
Alan Cox904290c2009-08-07 19:24:18 +0100102 void __iomem *addr = dev->reg_addr + reg;
Alan Cox79de99e82009-08-06 20:45:24 +0100103 writel(value, addr);
Alan Coxf5e39802009-08-06 20:45:07 +0100104}
105
Alan Cox79de99e82009-08-06 20:45:24 +0100106static inline u32 sep_read_reg(struct sep_device *dev, int reg)
Alan Coxf5e39802009-08-06 20:45:07 +0100107{
Alan Cox904290c2009-08-07 19:24:18 +0100108 void __iomem *addr = dev->reg_addr + reg;
Alan Cox79de99e82009-08-06 20:45:24 +0100109 return readl(addr);
Alan Coxf5e39802009-08-06 20:45:07 +0100110}
111
Alan Cox79de99e82009-08-06 20:45:24 +0100112/* wait for SRAM write complete(indirect write */
113static inline void sep_wait_sram_write(struct sep_device *dev)
114{
115 u32 reg_val;
116 do
117 reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
Alan Coxd19cf322009-08-06 20:45:57 +0100118 while (!(reg_val & 1));
Alan Cox79de99e82009-08-06 20:45:24 +0100119}
120
121
Alan Coxf5e39802009-08-06 20:45:07 +0100122#endif