2009-01-29 02:32:08 +07:00
|
|
|
/*
|
|
|
|
* omap iommu: simple virtual address space management
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2009 Nokia Corporation
|
|
|
|
*
|
|
|
|
* Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IOMMU_MMAP_H
|
|
|
|
#define __IOMMU_MMAP_H
|
|
|
|
|
2011-06-02 05:46:12 +07:00
|
|
|
#include <linux/iommu.h>
|
|
|
|
|
2009-01-29 02:32:08 +07:00
|
|
|
struct iovm_struct {
|
2011-08-18 02:57:56 +07:00
|
|
|
struct omap_iommu *iommu; /* iommu object which this belongs to */
|
2009-01-29 02:32:08 +07:00
|
|
|
u32 da_start; /* area definition */
|
|
|
|
u32 da_end;
|
|
|
|
u32 flags; /* IOVMF_: see below */
|
|
|
|
struct list_head list; /* linked in ascending order */
|
|
|
|
const struct sg_table *sgt; /* keep 'page' <-> 'da' mapping */
|
|
|
|
void *va; /* mpu side mapped address */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IOVMF_FLAGS: attribute for iommu virtual memory area(iovma)
|
|
|
|
*
|
|
|
|
* lower 16 bit is used for h/w and upper 16 bit is for s/w.
|
|
|
|
*/
|
|
|
|
#define IOVMF_SW_SHIFT 16
|
|
|
|
|
|
|
|
/*
|
|
|
|
* iovma: h/w flags derived from cam and ram attribute
|
|
|
|
*/
|
|
|
|
#define IOVMF_CAM_MASK (~((1 << 10) - 1))
|
|
|
|
#define IOVMF_RAM_MASK (~IOVMF_CAM_MASK)
|
|
|
|
|
|
|
|
#define IOVMF_PGSZ_MASK (3 << 0)
|
|
|
|
#define IOVMF_PGSZ_1M MMU_CAM_PGSZ_1M
|
|
|
|
#define IOVMF_PGSZ_64K MMU_CAM_PGSZ_64K
|
|
|
|
#define IOVMF_PGSZ_4K MMU_CAM_PGSZ_4K
|
|
|
|
#define IOVMF_PGSZ_16M MMU_CAM_PGSZ_16M
|
|
|
|
|
|
|
|
#define IOVMF_ENDIAN_MASK (1 << 9)
|
|
|
|
#define IOVMF_ENDIAN_BIG MMU_RAM_ENDIAN_BIG
|
|
|
|
#define IOVMF_ENDIAN_LITTLE MMU_RAM_ENDIAN_LITTLE
|
|
|
|
|
|
|
|
#define IOVMF_ELSZ_MASK (3 << 7)
|
|
|
|
#define IOVMF_ELSZ_8 MMU_RAM_ELSZ_8
|
|
|
|
#define IOVMF_ELSZ_16 MMU_RAM_ELSZ_16
|
|
|
|
#define IOVMF_ELSZ_32 MMU_RAM_ELSZ_32
|
|
|
|
#define IOVMF_ELSZ_NONE MMU_RAM_ELSZ_NONE
|
|
|
|
|
|
|
|
#define IOVMF_MIXED_MASK (1 << 6)
|
|
|
|
#define IOVMF_MIXED MMU_RAM_MIXED
|
|
|
|
|
|
|
|
/*
|
|
|
|
* iovma: s/w flags, used for mapping and umapping internally.
|
|
|
|
*/
|
|
|
|
#define IOVMF_MMIO (1 << IOVMF_SW_SHIFT)
|
|
|
|
#define IOVMF_ALLOC (2 << IOVMF_SW_SHIFT)
|
|
|
|
#define IOVMF_ALLOC_MASK (3 << IOVMF_SW_SHIFT)
|
|
|
|
|
|
|
|
/* "superpages" is supported just with physically linear pages */
|
|
|
|
#define IOVMF_DISCONT (1 << (2 + IOVMF_SW_SHIFT))
|
|
|
|
#define IOVMF_LINEAR (2 << (2 + IOVMF_SW_SHIFT))
|
|
|
|
#define IOVMF_LINEAR_MASK (3 << (2 + IOVMF_SW_SHIFT))
|
|
|
|
|
|
|
|
#define IOVMF_DA_FIXED (1 << (4 + IOVMF_SW_SHIFT))
|
|
|
|
|
|
|
|
|
2011-10-11 05:18:33 +07:00
|
|
|
extern struct iovm_struct *omap_find_iovm_area(struct device *dev, u32 da);
|
2011-08-18 02:57:56 +07:00
|
|
|
extern u32
|
2011-10-11 05:18:33 +07:00
|
|
|
omap_iommu_vmap(struct iommu_domain *domain, struct device *dev, u32 da,
|
2009-01-29 02:32:08 +07:00
|
|
|
const struct sg_table *sgt, u32 flags);
|
2011-08-18 02:57:56 +07:00
|
|
|
extern struct sg_table *omap_iommu_vunmap(struct iommu_domain *domain,
|
2011-10-11 05:18:33 +07:00
|
|
|
struct device *dev, u32 da);
|
2011-08-18 02:57:56 +07:00
|
|
|
extern u32
|
2011-10-11 05:18:33 +07:00
|
|
|
omap_iommu_vmalloc(struct iommu_domain *domain, struct device *dev,
|
2011-06-02 05:46:12 +07:00
|
|
|
u32 da, size_t bytes, u32 flags);
|
2011-08-18 02:57:56 +07:00
|
|
|
extern void
|
2011-10-11 05:18:33 +07:00
|
|
|
omap_iommu_vfree(struct iommu_domain *domain, struct device *dev,
|
2011-06-02 05:46:12 +07:00
|
|
|
const u32 da);
|
2011-10-11 05:18:33 +07:00
|
|
|
extern void *omap_da_to_va(struct device *dev, u32 da);
|
2009-01-29 02:32:08 +07:00
|
|
|
|
|
|
|
#endif /* __IOMMU_MMAP_H */
|