Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 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 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 | |
| 31 | struct sep_device { |
| 32 | /* pointer to pci dev */ |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 33 | struct pci_dev *pdev; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 34 | |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 35 | unsigned long io_bus; |
| 36 | unsigned long io_end_bus; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 37 | unsigned long io_memory_size; |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 38 | void __iomem *io_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 39 | |
| 40 | /* restricted access region */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 41 | dma_addr_t rar_bus; |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 42 | void *rar_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 43 | |
| 44 | /* shared memory region */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 45 | dma_addr_t shared_bus; |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 46 | void *shared_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 47 | |
| 48 | /* firmware regions */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 49 | dma_addr_t cache_bus; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 50 | unsigned long cache_size; |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 51 | void *cache_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 52 | |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 53 | dma_addr_t resident_bus; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 54 | unsigned long resident_size; |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 55 | void *resident_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 56 | |
Alan Cox | 6f13ea3 | 2009-08-14 15:41:50 +0100 | [diff] [blame^] | 57 | void *rar_region_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 58 | |
| 59 | /* start address of the access to the SEP registers from driver */ |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 60 | void __iomem *reg_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 61 | /* transaction counter that coordinates the transactions between SEP and HOST */ |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 62 | unsigned long send_ct; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 63 | /* counter for the messages from sep */ |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 64 | unsigned long reply_ct; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 65 | /* counter for the number of bytes allocated in the pool for the current |
Alan Cox | d19cf32 | 2009-08-06 20:45:57 +0100 | [diff] [blame] | 66 | transaction */ |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 67 | unsigned long data_pool_bytes_allocated; |
| 68 | |
| 69 | /* array of pointers to the pages that represent input data for the synchronic |
Alan Cox | d19cf32 | 2009-08-06 20:45:57 +0100 | [diff] [blame] | 70 | DMA action */ |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 71 | struct page **in_page_array; |
| 72 | |
| 73 | /* array of pointers to the pages that represent out data for the synchronic |
Alan Cox | d19cf32 | 2009-08-06 20:45:57 +0100 | [diff] [blame] | 74 | DMA action */ |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 75 | 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 Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 84 | struct sep_flow_context_t flows[SEP_DRIVER_NUM_FLOWS]; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 85 | |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 86 | /* pointer to the workqueue that handles the flow done interrupts */ |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 87 | struct workqueue_struct *flow_wq; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 88 | |
| 89 | /* address of the shared memory allocated during init for SEP driver */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 90 | void *shared_area; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 91 | /* the physical address of the shared area */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 92 | dma_addr_t shared_area_bus; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 93 | |
| 94 | /* Message Shared Area start address - will be allocated during init */ |
Alan Cox | 790cf1b | 2009-08-07 19:25:16 +0100 | [diff] [blame] | 95 | void *message_shared_area_addr; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 96 | }; |
| 97 | |
Alan Cox | b10b483 | 2009-08-07 19:23:26 +0100 | [diff] [blame] | 98 | static struct sep_device *sep_dev; |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 99 | |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 100 | static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value) |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 101 | { |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 102 | void __iomem *addr = dev->reg_addr + reg; |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 103 | writel(value, addr); |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 104 | } |
| 105 | |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 106 | static inline u32 sep_read_reg(struct sep_device *dev, int reg) |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 107 | { |
Alan Cox | 904290c | 2009-08-07 19:24:18 +0100 | [diff] [blame] | 108 | void __iomem *addr = dev->reg_addr + reg; |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 109 | return readl(addr); |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 110 | } |
| 111 | |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 112 | /* wait for SRAM write complete(indirect write */ |
| 113 | static 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 Cox | d19cf32 | 2009-08-06 20:45:57 +0100 | [diff] [blame] | 118 | while (!(reg_val & 1)); |
Alan Cox | 79de99e8 | 2009-08-06 20:45:24 +0100 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | |
Alan Cox | f5e3980 | 2009-08-06 20:45:07 +0100 | [diff] [blame] | 122 | #endif |