Skip to content

Commit

Permalink
Staging: sep: Introduce sep driver
Browse files Browse the repository at this point in the history
This driver is for the Security Processor, a dedicated encryption
and decryption driver that is used on the Intel mobile platform.

This has been checked with checkpatch and there are four
warnings for lines over 80 charactors.

There is one compile warning. This is for a function that is
only used if the rar register driver is needed. There is an
ifdef in a header file that stubs out the rar register driver
if the rar register is not configured.

This driver does add a configuration, which is CONFIG_DX_SEP.

Signed-off-by: Mark Allyn <mark.a.allyn@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Mark Allyn authored and Greg Kroah-Hartman committed Nov 20, 2010
1 parent d948d5f commit 4856ab3
Show file tree
Hide file tree
Showing 10 changed files with 5,307 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/staging/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ source "drivers/staging/vme/Kconfig"

source "drivers/staging/memrar/Kconfig"

source "drivers/staging/sep/Kconfig"

source "drivers/staging/iio/Kconfig"

source "drivers/staging/zram/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ obj-$(CONFIG_FB_UDL) += udlfb/
obj-$(CONFIG_HYPERV) += hv/
obj-$(CONFIG_VME_BUS) += vme/
obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/
obj-$(CONFIG_DX_SEP) += sep/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_ZRAM) += zram/
obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/
Expand Down
11 changes: 11 additions & 0 deletions drivers/staging/sep/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config DX_SEP
tristate "Discretix SEP driver"
depends on PCI
default y
help
Discretix SEP driver; used for the security processor subsystem
on bard the Intel Mobile Internet Device.

The driver's name is sep_driver.

If unsure, select N.
2 changes: 2 additions & 0 deletions drivers/staging/sep/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj-$(CONFIG_DX_SEP) := sep_driver.o

12 changes: 12 additions & 0 deletions drivers/staging/sep/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Todo's so far (from Alan Cox)
- Fix firmware loading - Done 09/10 M. Allyn
- Get firmware into firmware git tree - Firmware is non open source
- Review and tidy each algorithm function - Done 09/10 M. Allyn
- Check whether it can be plugged into any of the kernel crypto API
interfaces - Crypto API 'glue' is still not ready to submit
- Do something about the magic shared memory interface and replace it
with something saner (in Linux terms) - Done 09/10 M. Allyn
- Clean up unused ioctls - Needs vendor help
- Clean up unused fields in ioctl structures - Needs vendor help
- 64 bit size to be used for all user space addresses passed
to ioctl - Done 10/10 M. Allyn
156 changes: 156 additions & 0 deletions drivers/staging/sep/sep_dev.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#ifndef __SEP_DEV_H__
#define __SEP_DEV_H__

/*
*
* sep_dev.h - Security Processor Device Structures
*
* Copyright(c) 2009,2010 Intel Corporation. All rights reserved.
* Contributions(c) 2009,2010 Discretix. All rights reserved.
*
* 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; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* CONTACTS:
*
* Mark Allyn mark.a.allyn@intel.com
* Jayant Mangalampalli jayant.mangalampalli@intel.com
*
* CHANGES
* 2010.09.14 upgrade to Medfield
*/

struct sep_device {
/* pointer to pci dev */
struct pci_dev *pdev;

/* character device file */
struct cdev sep_cdev;
struct cdev sep_daemon_cdev;
struct cdev sep_singleton_cdev;

/* devices (using misc dev) */
struct miscdevice miscdev_sep;
struct miscdevice miscdev_singleton;
struct miscdevice miscdev_daemon;

/* major / minor numbers of device */
dev_t sep_devno;
dev_t sep_daemon_devno;
dev_t sep_singleton_devno;

struct mutex sep_mutex;
struct mutex ioctl_mutex;
spinlock_t snd_rply_lck;

/* flags to indicate use and lock status of sep */
u32 pid_doing_transaction;
unsigned long in_use_flags;

/* request daemon alread open */
unsigned long request_daemon_open;

/* 1 = Moorestown; 0 = Medfield */
int mrst;

/* address of the shared memory allocated during init for SEP driver
(coherent alloc) */
dma_addr_t shared_bus;
size_t shared_size;
void *shared_addr;

/* restricted access region (coherent alloc) */
dma_addr_t rar_bus;
size_t rar_size;
void *rar_addr;

/* Firmware regions; cache is at rar for Moorestown and
resident is at rar for Medfield */
dma_addr_t cache_bus;
size_t cache_size;
void *cache_addr;

dma_addr_t resident_bus;
size_t resident_size;
void *resident_addr;

/* sep's scratchpad */
dma_addr_t dcache_bus;
size_t dcache_size;
void *dcache_addr;

/* Only used on Medfield */
dma_addr_t extapp_bus;
size_t extapp_size;
void *extapp_addr;

/* start address of the access to the SEP registers from driver */
dma_addr_t reg_physical_addr;
dma_addr_t reg_physical_end;
void __iomem *reg_addr;

/* wait queue head (event) of the driver */
wait_queue_head_t event;
wait_queue_head_t event_request_daemon;
wait_queue_head_t event_mmap;

struct sep_caller_id_entry
caller_id_table[SEP_CALLER_ID_TABLE_NUM_ENTRIES];

/* access flag for singleton device */
unsigned long singleton_access_flag;

/* transaction counter that coordinates the
transactions between SEP and HOST */
unsigned long send_ct;
/* counter for the messages from sep */
unsigned long reply_ct;
/* counter for the number of bytes allocated in the pool for the
current transaction */
long data_pool_bytes_allocated;

u32 num_of_data_allocations;

/* number of the lli tables created in the current transaction */
u32 num_lli_tables_created;

/* number of data control blocks */
u32 nr_dcb_creat;

struct sep_dma_resource dma_res_arr[SEP_MAX_NUM_SYNC_DMA_OPS];

};

static inline void sep_write_reg(struct sep_device *dev, int reg, u32 value)
{
void __iomem *addr = dev->reg_addr + reg;
writel(value, addr);
}

static inline u32 sep_read_reg(struct sep_device *dev, int reg)
{
void __iomem *addr = dev->reg_addr + reg;
return readl(addr);
}

/* wait for SRAM write complete(indirect write */
static inline void sep_wait_sram_write(struct sep_device *dev)
{
u32 reg_val;
do
reg_val = sep_read_reg(dev, HW_SRAM_DATA_READY_REG_ADDR);
while (!(reg_val & 1));
}


#endif
Loading

0 comments on commit 4856ab3

Please sign in to comment.