ARM64: dts: rockchip: rk3399: set dummy_cpll and dummy_vpll as fixed clk
[firefly-linux-kernel-4.4.55.git] / drivers / platform / goldfish / goldfish_pipe.h
1 /*
2  * Copyright (C) 2016 Google, Inc.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  */
14 #ifndef GOLDFISH_PIPE_H
15 #define GOLDFISH_PIPE_H
16
17 #include <linux/module.h>
18 #include <linux/interrupt.h>
19 #include <linux/kernel.h>
20 #include <linux/spinlock.h>
21 #include <linux/miscdevice.h>
22 #include <linux/platform_device.h>
23 #include <linux/poll.h>
24 #include <linux/sched.h>
25 #include <linux/bitops.h>
26 #include <linux/slab.h>
27 #include <linux/io.h>
28 #include <linux/goldfish.h>
29 #include <linux/mm.h>
30 #include <linux/acpi.h>
31
32
33 /* Initialize the legacy version of the pipe device driver */
34 int goldfish_pipe_device_init_v1(struct platform_device *pdev);
35
36 /* Deinitialize the legacy version of the pipe device driver */
37 void goldfish_pipe_device_deinit_v1(struct platform_device *pdev);
38
39 /* Forward declarations for the device struct */
40 struct goldfish_pipe;
41 struct goldfish_pipe_device_buffers;
42
43 /* The global driver data. Holds a reference to the i/o page used to
44  * communicate with the emulator, and a wake queue for blocked tasks
45  * waiting to be awoken.
46  */
47 struct goldfish_pipe_dev {
48         /*
49          * Global device spinlock. Protects the following members:
50          *  - pipes, pipes_capacity
51          *  - [*pipes, *pipes + pipes_capacity) - array data
52          *  - first_signalled_pipe,
53          *      goldfish_pipe::prev_signalled,
54          *      goldfish_pipe::next_signalled,
55          *      goldfish_pipe::signalled_flags - all singnalled-related fields,
56          *                                       in all allocated pipes
57          *  - open_command_params - PIPE_CMD_OPEN-related buffers
58          *
59          * It looks like a lot of different fields, but the trick is that the only
60          * operation that happens often is the signalled pipes array manipulation.
61          * That's why it's OK for now to keep the rest of the fields under the same
62          * lock. If we notice too much contention because of PIPE_CMD_OPEN,
63          * then we should add a separate lock there.
64          */
65         spinlock_t lock;
66
67         /*
68          * Array of the pipes of |pipes_capacity| elements,
69          * indexed by goldfish_pipe::id
70          */
71         struct goldfish_pipe **pipes;
72         u32 pipes_capacity;
73
74         /* Pointers to the buffers host uses for interaction with this driver */
75         struct goldfish_pipe_dev_buffers *buffers;
76
77         /* Head of a doubly linked list of signalled pipes */
78         struct goldfish_pipe *first_signalled_pipe;
79
80         /* Some device-specific data */
81         int irq;
82         int version;
83         unsigned char __iomem *base;
84
85         /* v1-specific access parameters */
86         struct access_params *aps;
87 };
88
89 extern struct goldfish_pipe_dev pipe_dev[1];
90
91 #endif /* GOLDFISH_PIPE_H */