upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / plat-s5p / include / plat / s5p-vcm.h
1 #ifndef __S5P_VCM_H
2 #define __S5P_VCM_H
3
4 #include <linux/vcm-drv.h>
5 #include <plat/sysmmu.h>
6 #include <asm/atomic.h>
7
8 #ifdef CONFIG_VCM_MMU
9
10 /* for physical allocator of frame buffer */
11 enum vcm_dev_id {
12         VCM_DEV_NONE = -1,
13         VCM_DEV_MDMA = 0,
14         VCM_DEV_SSS,
15         VCM_DEV_FIMC0,
16         VCM_DEV_FIMC1,
17         VCM_DEV_FIMC2,
18         VCM_DEV_FIMC3,
19         VCM_DEV_JPEG,
20         VCM_DEV_FIMD0,
21         VCM_DEV_FIMD1,
22         VCM_DEV_PCIe,
23         VCM_DEV_G2D,
24         VCM_DEV_ROTATOR,
25         VCM_DEV_MDMA2,
26         VCM_DEV_TV,
27         VCM_DEV_MFC,
28         VCM_DEV_NUM
29 };
30
31 static inline sysmmu_ips vcmid_to_smmuid(enum vcm_dev_id vcm_id)
32 {
33         BUG_ON((vcm_id < 0) || (vcm_id >= VCM_DEV_NUM));
34         return (sysmmu_ips)vcm_id;
35 }
36
37 static inline enum vcm_dev_id smmuid_to_vcmid(sysmmu_ips ips)
38 {
39         BUG_ON((ips < 0) || (ips > SYSMMU_MFC_R));
40         return (enum vcm_dev_id)ips;
41 }
42
43 enum S5PVCM_RESCHECK {
44         S5PVCM_RES_NOT_IN_VCM = 0,
45         S5PVCM_RES_IN_VCM,
46         S5PVCM_RES_IN_ADDRSPACE
47 };
48
49 struct s5p_vcm_driver {
50         void (*tlb_invalidator)(enum vcm_dev_id id);
51         void (*pgd_base_specifier)(enum vcm_dev_id id, unsigned long base);
52         dma_addr_t (*phys_alloc)(resource_size_t size, unsigned flag);
53         void (*phys_free)(struct vcm_phys *phys);
54 };
55
56 /* Turns on the system MMU of the specified vcm context
57  * If the system MMU is not turned on, TLB invalidation and setting page table
58  * base on the system MMU is not performed.
59  */
60 void s5p_vcm_turn_on(struct vcm *vcm);
61
62 /* Turns off the system MMU of the specified vcm context
63  */
64 void s5p_vcm_turn_off(struct vcm *vcm);
65
66 /* The caller must check the return value of vcm_create_unified with
67  * IS_ERR_OR_NULL() macro defined in err.h
68  */
69 struct vcm *__must_check
70 vcm_create_unified(resource_size_t size, enum vcm_dev_id id,
71                                 const struct s5p_vcm_driver *driver);
72
73 /* vcm : your vcm context.
74  * res : the reservation that you want to know if it is allocated from
75  *       your vcm.
76  */
77 enum S5PVCM_RESCHECK
78 vcm_reservation_in_vcm(struct vcm *vcm, struct vcm_res *res);
79
80 struct vcm *vcm_find_vcm(enum vcm_dev_id id);
81
82 /* Initializes the page table base of the system MMU of the given device
83  * id: device ID defined in enum vcm_dev_id
84  *
85  * No operation performs if the ID is wrong or no callback method is specified
86  * by the device driver.
87  */
88 void vcm_set_pgtable_base(enum vcm_dev_id id);
89
90 #endif /* CONFIG_VCM_MMU */
91
92 #endif /* __S5P_VCM_H */