forked from patjak/facetimehd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fthd_hw.h
138 lines (116 loc) · 4.33 KB
/
fthd_hw.h
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Broadcom PCIe 1570 webcam driver
*
* Copyright (C) 2014 Patrik Jakobsson ([email protected])
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation.
*
*/
#ifndef _FTHD_HW_H
#define _FTHD_HW_H
#include <linux/pci.h>
/* Used after most PCI Link IO writes */
static inline void fthd_hw_pci_post(struct fthd_private *dev_priv)
{
pci_write_config_dword(dev_priv->pdev, 0, 0x12345678);
}
#define FTHD_S2_REG_READ(offset) _FTHD_S2_REG_READ(dev_priv, (offset))
#define FTHD_S2_REG_WRITE(val, offset) _FTHD_S2_REG_WRITE(dev_priv, (val), (offset))
#define FTHD_S2_MEM_READ(offset) _FTHD_S2_MEM_READ(dev_priv, (offset))
#define FTHD_S2_MEM_WRITE(val, offset) _FTHD_S2_MEM_WRITE(dev_priv, (val), (offset))
#define FTHD_S2_MEMCPY_TOIO(offset, buf, len) _FTHD_S2_MEMCPY_TOIO(dev_priv, (buf), (offset), (len))
#define FTHD_S2_MEMCPY_FROMIO(buf, offset, len) _FTHD_S2_MEMCPY_FROMIO(dev_priv, (buf), (offset), (len))
#define FTHD_ISP_REG_READ(offset) _FTHD_ISP_REG_READ(dev_priv, (offset))
#define FTHD_ISP_REG_WRITE(val, offset) _FTHD_ISP_REG_WRITE(dev_priv, (val), (offset))
static inline u32 _FTHD_S2_REG_READ(struct fthd_private *dev_priv, u32 offset)
{
if (offset >= dev_priv->s2_io_len) {
dev_err(&dev_priv->pdev->dev,
"S2 IO read out of range at %u\n", offset);
return 0;
}
// dev_info(&dev_priv->pdev->dev, "Link IO read at %u\n", offset);
return ioread32(dev_priv->s2_io + offset);
}
static inline void _FTHD_S2_REG_WRITE(struct fthd_private *dev_priv, u32 val,
u32 offset)
{
if (offset >= dev_priv->s2_io_len) {
dev_err(&dev_priv->pdev->dev,
"S2 IO write out of range at %u\n", offset);
return;
}
// dev_info(&dev_priv->pdev->dev, "S2 IO write at %u\n", offset);
iowrite32(val, dev_priv->s2_io + offset);
fthd_hw_pci_post(dev_priv);
}
static inline u32 _FTHD_S2_MEM_READ(struct fthd_private *dev_priv, u32 offset)
{
if (offset >= dev_priv->s2_mem_len) {
dev_err(&dev_priv->pdev->dev,
"S2 MEM read out of range at %u\n", offset);
return 0;
}
// dev_info(&dev_priv->pdev->dev, "Link IO read at %u\n", offset);
return ioread32(dev_priv->s2_mem + offset);
}
static inline void _FTHD_S2_MEM_WRITE(struct fthd_private *dev_priv, u32 val,
u32 offset)
{
if (offset >= dev_priv->s2_mem_len) {
dev_err(&dev_priv->pdev->dev,
"S2 MEM write out of range at %u\n", offset);
return;
}
// dev_info(&dev_priv->pdev->dev, "S2 IO write at %u\n", offset);
iowrite32(val, dev_priv->s2_mem + offset);
}
static inline void _FTHD_S2_MEMCPY_TOIO(struct fthd_private *dev_priv, const void *buf,
u32 offset, int len)
{
memcpy_toio(dev_priv->s2_mem + offset, buf, len);
}
static inline void _FTHD_S2_MEMCPY_FROMIO(struct fthd_private *dev_priv, void *buf,
u32 offset, int len)
{
memcpy_fromio(buf, dev_priv->s2_mem + offset, len);
}
static inline u32 _FTHD_ISP_REG_READ(struct fthd_private *dev_priv, u32 offset)
{
if (offset >= dev_priv->isp_io_len) {
dev_err(&dev_priv->pdev->dev,
"ISP IO read out of range at %u\n", offset);
return 0;
}
// dev_info(&dev_priv->pdev->dev, "ISP IO read at %u\n", offset);
return ioread32(dev_priv->isp_io + offset);
}
static inline void _FTHD_ISP_REG_WRITE(struct fthd_private *dev_priv, u32 val,
u32 offset)
{
if (offset >= dev_priv->isp_io_len) {
dev_err(&dev_priv->pdev->dev,
"ISP IO write out of range at %u\n", offset);
return;
}
// dev_info(&dev_priv->pdev->dev, "Dev IO write at %u\n", offset);
iowrite32(val, dev_priv->isp_io + offset);
fthd_hw_pci_post(dev_priv);
}
extern int fthd_irq_enable(struct fthd_private *dev_priv);
extern int fthd_irq_disable(struct fthd_private *dev_priv);
extern int fthd_hw_init(struct fthd_private *dev_priv);
extern void fthd_hw_deinit(struct fthd_private *priv);
extern void fthd_ddr_phy_save_regs(struct fthd_private *dev_priv);
extern void fthd_ddr_phy_restore_regs(struct fthd_private *dev_priv);
#endif