summaryrefstree
path: root/kernel/drivers/vision/vpu/include/vpu-exynos.h
blob: ac94c7610097b2e0d6f180d15d7c44c87e925df4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * Samsung Exynos SoC series VPU driver
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd
 *
 * 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 VPU_EXYNOS_H_
#define VPU_EXYNOS_H_

#include <linux/clk.h>
#include <linux/device.h>

struct vpu_exynos;

struct vpu_regblock {
	unsigned int		offset;
	unsigned int		blocks;
	char			*name;
};

enum  regdata_type {
	/* read write */
	RW			= 0,
	/* read only */
	RO			= 1,
	/* write only */
	WO			= 2,
	/* write input */
	WI			= 2,
	/* clear after read */
	RAC			= 3,
	/* write 1 -> clear */
	W1C			= 4,
	/* write read input */
	WRI			= 5,
	/* write input */
	RWI			= 5,
	/* only scaler */
	R_W			= 6,
	/* read & write for clear */
	RWC			= 7,
	/* read & write as dual setting */
	RWS
};

struct vpu_reg {
	unsigned int		offset;
	char			*name;
};

struct vpu_field {
	char			*name;
	unsigned int		bit_start;
	unsigned int		bit_width;
	enum regdata_type	type;
};

struct vpu_clk {
	const char	*name;
	struct clk	*clk;
};

struct vpu_clk_ops {
	int (*clk_cfg)(struct vpu_exynos *exynos);
	int (*clk_on)(struct vpu_exynos *exynos);
	int (*clk_off)(struct vpu_exynos *exynos);
	int (*clk_dump)(struct vpu_exynos *exynos);
};

struct vpu_ctl_ops {
	int (*ctl_reset)(struct vpu_exynos *exynos, bool hold);
	int (*ctl_dump)(struct vpu_exynos *exynos, u32 instance);
	void * (*ctl_remap)(struct vpu_exynos *exynos, u32 instance);
	int (*ctl_unmap)(struct vpu_exynos *exynos, u32 instance, void *base);
	int (*ctl_trigger)(struct vpu_exynos *exynos, u32 chain_id);
	int (*ctl_start)(struct vpu_exynos *exynos, u32 chain_id);
};

struct vpu_exynos {
	struct device			*dev;
	void				*regbase;
	void				*ram0base;
	void				*ram1base;
	struct pinctrl			*pinctrl;
	const struct vpu_clk_ops	*clk_ops;
	const struct vpu_ctl_ops	*ctl_ops;
};

int vpu_exynos_probe(struct vpu_exynos *exynos, struct device *dev,
	void *regs, void *ram0, void *ram1);

void vpu_readl(void __iomem *base_addr, struct vpu_reg *reg, u32 *val);
void vpu_writel(void __iomem *base_addr, struct vpu_reg *reg, u32 val);

#define CLK_OP(exynos, op) (exynos->clk_ops ? exynos->clk_ops->op(exynos) : 0)
#define CTL_OP(exynos, op, ...) (exynos->ctl_ops ? exynos->ctl_ops->op(exynos, ##__VA_ARGS__) : 0)

#endif