xref: /linux/drivers/media/platform/renesas/vsp1/vsp1.h (revision 0526b56cbc3c489642bd6a5fe4b718dea7ef0ee8)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * vsp1.h  --  R-Car VSP1 Driver
4  *
5  * Copyright (C) 2013-2014 Renesas Electronics Corporation
6  *
7  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8  */
9 #ifndef __VSP1_H__
10 #define __VSP1_H__
11 
12 #include <linux/io.h>
13 #include <linux/list.h>
14 #include <linux/mutex.h>
15 
16 #include <media/media-device.h>
17 #include <media/v4l2-device.h>
18 #include <media/v4l2-subdev.h>
19 
20 #include "vsp1_regs.h"
21 
22 struct clk;
23 struct device;
24 struct rcar_fcp_device;
25 struct reset_control;
26 
27 struct vsp1_drm;
28 struct vsp1_entity;
29 struct vsp1_platform_data;
30 struct vsp1_brx;
31 struct vsp1_clu;
32 struct vsp1_hgo;
33 struct vsp1_hgt;
34 struct vsp1_hsit;
35 struct vsp1_lif;
36 struct vsp1_lut;
37 struct vsp1_rwpf;
38 struct vsp1_sru;
39 struct vsp1_uds;
40 struct vsp1_uif;
41 
42 #define VSP1_MAX_LIF		2
43 #define VSP1_MAX_RPF		5
44 #define VSP1_MAX_UDS		3
45 #define VSP1_MAX_UIF		2
46 #define VSP1_MAX_WPF		4
47 
48 #define VSP1_HAS_LUT		BIT(1)
49 #define VSP1_HAS_SRU		BIT(2)
50 #define VSP1_HAS_BRU		BIT(3)
51 #define VSP1_HAS_CLU		BIT(4)
52 #define VSP1_HAS_WPF_VFLIP	BIT(5)
53 #define VSP1_HAS_WPF_HFLIP	BIT(6)
54 #define VSP1_HAS_HGO		BIT(7)
55 #define VSP1_HAS_HGT		BIT(8)
56 #define VSP1_HAS_BRS		BIT(9)
57 #define VSP1_HAS_EXT_DL		BIT(10)
58 #define VSP1_HAS_NON_ZERO_LBA	BIT(11)
59 
60 struct vsp1_device_info {
61 	u32 version;
62 	const char *model;
63 	unsigned int gen;
64 	unsigned int features;
65 	unsigned int lif_count;
66 	unsigned int rpf_count;
67 	unsigned int uds_count;
68 	unsigned int uif_count;
69 	unsigned int wpf_count;
70 	unsigned int num_bru_inputs;
71 	u8 soc;
72 	bool uapi;
73 };
74 
75 #define vsp1_feature(vsp1, f) ((vsp1)->info->features & (f))
76 
77 struct vsp1_device {
78 	struct device *dev;
79 	const struct vsp1_device_info *info;
80 	u32 version;
81 
82 	void __iomem *mmio;
83 	struct rcar_fcp_device *fcp;
84 	struct device *bus_master;
85 	struct reset_control *rstc;
86 
87 	struct vsp1_brx *brs;
88 	struct vsp1_brx *bru;
89 	struct vsp1_clu *clu;
90 	struct vsp1_hgo *hgo;
91 	struct vsp1_hgt *hgt;
92 	struct vsp1_hsit *hsi;
93 	struct vsp1_hsit *hst;
94 	struct vsp1_lif *lif[VSP1_MAX_LIF];
95 	struct vsp1_lut *lut;
96 	struct vsp1_rwpf *rpf[VSP1_MAX_RPF];
97 	struct vsp1_sru *sru;
98 	struct vsp1_uds *uds[VSP1_MAX_UDS];
99 	struct vsp1_uif *uif[VSP1_MAX_UIF];
100 	struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
101 
102 	struct list_head entities;
103 	struct list_head videos;
104 
105 	struct v4l2_device v4l2_dev;
106 	struct media_device media_dev;
107 	struct media_entity_operations media_ops;
108 
109 	struct vsp1_drm *drm;
110 };
111 
112 int vsp1_device_get(struct vsp1_device *vsp1);
113 void vsp1_device_put(struct vsp1_device *vsp1);
114 
115 int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index);
116 
117 static inline u32 vsp1_read(struct vsp1_device *vsp1, u32 reg)
118 {
119 	return ioread32(vsp1->mmio + reg);
120 }
121 
122 static inline void vsp1_write(struct vsp1_device *vsp1, u32 reg, u32 data)
123 {
124 	iowrite32(data, vsp1->mmio + reg);
125 }
126 
127 #endif /* __VSP1_H__ */
128