1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License, version 2, as
4  * published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14  *
15  * Copyright (C) 2013 Freescale Semiconductor, Inc.
16  *
17  */
18 
19 #ifndef __FSL_PAMU_DOMAIN_H
20 #define __FSL_PAMU_DOMAIN_H
21 
22 #include "fsl_pamu.h"
23 
24 const struct iommu_ops fsl_pamu_ops;
25 
26 struct dma_window {
27 	phys_addr_t paddr;
28 	u64 size;
29 	int valid;
30 	int prot;
31 };
32 
33 struct fsl_dma_domain {
34 	/*
35 	 * Indicates the geometry size for the domain.
36 	 * This would be set when the geometry is
37 	 * configured for the domain.
38 	 */
39 	dma_addr_t			geom_size;
40 	/*
41 	 * Number of windows assocaited with this domain.
42 	 * During domain initialization, it is set to the
43 	 * the maximum number of subwindows allowed for a LIODN.
44 	 * Minimum value for this is 1 indicating a single PAMU
45 	 * window, without any sub windows. Value can be set/
46 	 * queried by set_attr/get_attr API for DOMAIN_ATTR_WINDOWS.
47 	 * Value can only be set once the geometry has been configured.
48 	 */
49 	u32				win_cnt;
50 	/*
51 	 * win_arr contains information of the configured
52 	 * windows for a domain. This is allocated only
53 	 * when the number of windows for the domain are
54 	 * set.
55 	 */
56 	struct dma_window		*win_arr;
57 	/* list of devices associated with the domain */
58 	struct list_head		devices;
59 	/* dma_domain states:
60 	 * mapped - A particular mapping has been created
61 	 * within the configured geometry.
62 	 * enabled - DMA has been enabled for the given
63 	 * domain. This translates to setting of the
64 	 * valid bit for the primary PAACE in the PAMU
65 	 * PAACT table. Domain geometry should be set and
66 	 * it must have a valid mapping before DMA can be
67 	 * enabled for it.
68 	 *
69 	 */
70 	int				mapped;
71 	int				enabled;
72 	/* stash_id obtained from the stash attribute details */
73 	u32				stash_id;
74 	struct pamu_stash_attribute	dma_stash;
75 	u32				snoop_id;
76 	struct iommu_domain		iommu_domain;
77 	spinlock_t			domain_lock;
78 };
79 
80 /* domain-device relationship */
81 struct device_domain_info {
82 	struct list_head link;	/* link to domain siblings */
83 	struct device *dev;
84 	u32 liodn;
85 	struct fsl_dma_domain *domain; /* pointer to domain */
86 };
87 #endif  /* __FSL_PAMU_DOMAIN_H */
88