Skip to content

Commit e6fff4a

Browse files
committed
gpu: host1x: Add Tegra124 support
Tegra124 has 192 syncpoints whereas its predecessors had 32 syncpoints. This required changes to the hardware register layout. Signed-off-by: Arto Merilainen <amerilainen@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
1 parent 23a0e27 commit e6fff4a

8 files changed

Lines changed: 768 additions & 1 deletion

File tree

‎drivers/gpu/host1x/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ host1x-y = \
99
debug.o \
1010
mipi.o \
1111
hw/host1x01.o \
12-
hw/host1x02.o
12+
hw/host1x02.o \
13+
hw/host1x04.o
1314

1415
obj-$(CONFIG_TEGRA_HOST1X) += host1x.o

‎drivers/gpu/host1x/dev.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "debug.h"
3535
#include "hw/host1x01.h"
3636
#include "hw/host1x02.h"
37+
#include "hw/host1x04.h"
3738

3839
void host1x_sync_writel(struct host1x *host1x, u32 v, u32 r)
3940
{
@@ -77,7 +78,17 @@ static const struct host1x_info host1x02_info = {
7778
.sync_offset = 0x3000,
7879
};
7980

81+
static const struct host1x_info host1x04_info = {
82+
.nb_channels = 12,
83+
.nb_pts = 192,
84+
.nb_mlocks = 16,
85+
.nb_bases = 64,
86+
.init = host1x04_init,
87+
.sync_offset = 0x2100,
88+
};
89+
8090
static struct of_device_id host1x_of_match[] = {
91+
{ .compatible = "nvidia,tegra124-host1x", .data = &host1x04_info, },
8192
{ .compatible = "nvidia,tegra114-host1x", .data = &host1x02_info, },
8293
{ .compatible = "nvidia,tegra30-host1x", .data = &host1x01_info, },
8394
{ .compatible = "nvidia,tegra20-host1x", .data = &host1x01_info, },

‎drivers/gpu/host1x/hw/host1x04.c‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Host1x init for Tegra124 SoCs
3+
*
4+
* Copyright (c) 2013 NVIDIA Corporation.
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
9+
*
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
/* include hw specification */
20+
#include "host1x04.h"
21+
#include "host1x04_hardware.h"
22+
23+
/* include code */
24+
#include "cdma_hw.c"
25+
#include "channel_hw.c"
26+
#include "debug_hw.c"
27+
#include "intr_hw.c"
28+
#include "syncpt_hw.c"
29+
30+
#include "../dev.h"
31+
32+
int host1x04_init(struct host1x *host)
33+
{
34+
host->channel_op = &host1x_channel_ops;
35+
host->cdma_op = &host1x_cdma_ops;
36+
host->cdma_pb_op = &host1x_pushbuffer_ops;
37+
host->syncpt_op = &host1x_syncpt_ops;
38+
host->intr_op = &host1x_intr_ops;
39+
host->debug_op = &host1x_debug_ops;
40+
41+
return 0;
42+
}

‎drivers/gpu/host1x/hw/host1x04.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Host1x init for Tegra124 SoCs
3+
*
4+
* Copyright (c) 2013 NVIDIA Corporation.
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
9+
*
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#ifndef HOST1X_HOST1X04_H
20+
#define HOST1X_HOST1X04_H
21+
22+
struct host1x;
23+
24+
int host1x04_init(struct host1x *host);
25+
26+
#endif
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Tegra host1x Register Offsets for Tegra124
3+
*
4+
* Copyright (c) 2010-2013 NVIDIA Corporation.
5+
*
6+
* This program is free software; you can redistribute it and/or modify it
7+
* under the terms and conditions of the GNU General Public License,
8+
* version 2, as published by the Free Software Foundation.
9+
*
10+
* This program is distributed in the hope it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13+
* more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#ifndef __HOST1X_HOST1X04_HARDWARE_H
20+
#define __HOST1X_HOST1X04_HARDWARE_H
21+
22+
#include <linux/types.h>
23+
#include <linux/bitops.h>
24+
25+
#include "hw_host1x04_channel.h"
26+
#include "hw_host1x04_sync.h"
27+
#include "hw_host1x04_uclass.h"
28+
29+
static inline u32 host1x_class_host_wait_syncpt(
30+
unsigned indx, unsigned threshold)
31+
{
32+
return host1x_uclass_wait_syncpt_indx_f(indx)
33+
| host1x_uclass_wait_syncpt_thresh_f(threshold);
34+
}
35+
36+
static inline u32 host1x_class_host_load_syncpt_base(
37+
unsigned indx, unsigned threshold)
38+
{
39+
return host1x_uclass_load_syncpt_base_base_indx_f(indx)
40+
| host1x_uclass_load_syncpt_base_value_f(threshold);
41+
}
42+
43+
static inline u32 host1x_class_host_wait_syncpt_base(
44+
unsigned indx, unsigned base_indx, unsigned offset)
45+
{
46+
return host1x_uclass_wait_syncpt_base_indx_f(indx)
47+
| host1x_uclass_wait_syncpt_base_base_indx_f(base_indx)
48+
| host1x_uclass_wait_syncpt_base_offset_f(offset);
49+
}
50+
51+
static inline u32 host1x_class_host_incr_syncpt_base(
52+
unsigned base_indx, unsigned offset)
53+
{
54+
return host1x_uclass_incr_syncpt_base_base_indx_f(base_indx)
55+
| host1x_uclass_incr_syncpt_base_offset_f(offset);
56+
}
57+
58+
static inline u32 host1x_class_host_incr_syncpt(
59+
unsigned cond, unsigned indx)
60+
{
61+
return host1x_uclass_incr_syncpt_cond_f(cond)
62+
| host1x_uclass_incr_syncpt_indx_f(indx);
63+
}
64+
65+
static inline u32 host1x_class_host_indoff_reg_write(
66+
unsigned mod_id, unsigned offset, bool auto_inc)
67+
{
68+
u32 v = host1x_uclass_indoff_indbe_f(0xf)
69+
| host1x_uclass_indoff_indmodid_f(mod_id)
70+
| host1x_uclass_indoff_indroffset_f(offset);
71+
if (auto_inc)
72+
v |= host1x_uclass_indoff_autoinc_f(1);
73+
return v;
74+
}
75+
76+
static inline u32 host1x_class_host_indoff_reg_read(
77+
unsigned mod_id, unsigned offset, bool auto_inc)
78+
{
79+
u32 v = host1x_uclass_indoff_indmodid_f(mod_id)
80+
| host1x_uclass_indoff_indroffset_f(offset)
81+
| host1x_uclass_indoff_rwn_read_v();
82+
if (auto_inc)
83+
v |= host1x_uclass_indoff_autoinc_f(1);
84+
return v;
85+
}
86+
87+
/* cdma opcodes */
88+
static inline u32 host1x_opcode_setclass(
89+
unsigned class_id, unsigned offset, unsigned mask)
90+
{
91+
return (0 << 28) | (offset << 16) | (class_id << 6) | mask;
92+
}
93+
94+
static inline u32 host1x_opcode_incr(unsigned offset, unsigned count)
95+
{
96+
return (1 << 28) | (offset << 16) | count;
97+
}
98+
99+
static inline u32 host1x_opcode_nonincr(unsigned offset, unsigned count)
100+
{
101+
return (2 << 28) | (offset << 16) | count;
102+
}
103+
104+
static inline u32 host1x_opcode_mask(unsigned offset, unsigned mask)
105+
{
106+
return (3 << 28) | (offset << 16) | mask;
107+
}
108+
109+
static inline u32 host1x_opcode_imm(unsigned offset, unsigned value)
110+
{
111+
return (4 << 28) | (offset << 16) | value;
112+
}
113+
114+
static inline u32 host1x_opcode_imm_incr_syncpt(unsigned cond, unsigned indx)
115+
{
116+
return host1x_opcode_imm(host1x_uclass_incr_syncpt_r(),
117+
host1x_class_host_incr_syncpt(cond, indx));
118+
}
119+
120+
static inline u32 host1x_opcode_restart(unsigned address)
121+
{
122+
return (5 << 28) | (address >> 4);
123+
}
124+
125+
static inline u32 host1x_opcode_gather(unsigned count)
126+
{
127+
return (6 << 28) | count;
128+
}
129+
130+
static inline u32 host1x_opcode_gather_nonincr(unsigned offset, unsigned count)
131+
{
132+
return (6 << 28) | (offset << 16) | BIT(15) | count;
133+
}
134+
135+
static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count)
136+
{
137+
return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count;
138+
}
139+
140+
#define HOST1X_OPCODE_NOP host1x_opcode_nonincr(0, 0)
141+
142+
#endif
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright (c) 2013 NVIDIA Corporation.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it
5+
* under the terms and conditions of the GNU General Public License,
6+
* version 2, as published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope it will be useful, but WITHOUT
9+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11+
* more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
*
16+
*/
17+
18+
/*
19+
* Function naming determines intended use:
20+
*
21+
* <x>_r(void) : Returns the offset for register <x>.
22+
*
23+
* <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24+
*
25+
* <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26+
*
27+
* <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28+
* and masked to place it at field <y> of register <x>. This value
29+
* can be |'d with others to produce a full register value for
30+
* register <x>.
31+
*
32+
* <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33+
* value can be ~'d and then &'d to clear the value of field <y> for
34+
* register <x>.
35+
*
36+
* <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37+
* to place it at field <y> of register <x>. This value can be |'d
38+
* with others to produce a full register value for <x>.
39+
*
40+
* <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41+
* <x> value 'r' after being shifted to place its LSB at bit 0.
42+
* This value is suitable for direct comparison with other unshifted
43+
* values appropriate for use in field <y> of register <x>.
44+
*
45+
* <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46+
* field <y> of register <x>. This value is suitable for direct
47+
* comparison with unshifted values appropriate for use in field <y>
48+
* of register <x>.
49+
*/
50+
51+
#ifndef HOST1X_HW_HOST1X04_CHANNEL_H
52+
#define HOST1X_HW_HOST1X04_CHANNEL_H
53+
54+
static inline u32 host1x_channel_fifostat_r(void)
55+
{
56+
return 0x0;
57+
}
58+
#define HOST1X_CHANNEL_FIFOSTAT \
59+
host1x_channel_fifostat_r()
60+
static inline u32 host1x_channel_fifostat_cfempty_v(u32 r)
61+
{
62+
return (r >> 11) & 0x1;
63+
}
64+
#define HOST1X_CHANNEL_FIFOSTAT_CFEMPTY_V(r) \
65+
host1x_channel_fifostat_cfempty_v(r)
66+
static inline u32 host1x_channel_dmastart_r(void)
67+
{
68+
return 0x14;
69+
}
70+
#define HOST1X_CHANNEL_DMASTART \
71+
host1x_channel_dmastart_r()
72+
static inline u32 host1x_channel_dmaput_r(void)
73+
{
74+
return 0x18;
75+
}
76+
#define HOST1X_CHANNEL_DMAPUT \
77+
host1x_channel_dmaput_r()
78+
static inline u32 host1x_channel_dmaget_r(void)
79+
{
80+
return 0x1c;
81+
}
82+
#define HOST1X_CHANNEL_DMAGET \
83+
host1x_channel_dmaget_r()
84+
static inline u32 host1x_channel_dmaend_r(void)
85+
{
86+
return 0x20;
87+
}
88+
#define HOST1X_CHANNEL_DMAEND \
89+
host1x_channel_dmaend_r()
90+
static inline u32 host1x_channel_dmactrl_r(void)
91+
{
92+
return 0x24;
93+
}
94+
#define HOST1X_CHANNEL_DMACTRL \
95+
host1x_channel_dmactrl_r()
96+
static inline u32 host1x_channel_dmactrl_dmastop(void)
97+
{
98+
return 1 << 0;
99+
}
100+
#define HOST1X_CHANNEL_DMACTRL_DMASTOP \
101+
host1x_channel_dmactrl_dmastop()
102+
static inline u32 host1x_channel_dmactrl_dmastop_v(u32 r)
103+
{
104+
return (r >> 0) & 0x1;
105+
}
106+
#define HOST1X_CHANNEL_DMACTRL_DMASTOP_V(r) \
107+
host1x_channel_dmactrl_dmastop_v(r)
108+
static inline u32 host1x_channel_dmactrl_dmagetrst(void)
109+
{
110+
return 1 << 1;
111+
}
112+
#define HOST1X_CHANNEL_DMACTRL_DMAGETRST \
113+
host1x_channel_dmactrl_dmagetrst()
114+
static inline u32 host1x_channel_dmactrl_dmainitget(void)
115+
{
116+
return 1 << 2;
117+
}
118+
#define HOST1X_CHANNEL_DMACTRL_DMAINITGET \
119+
host1x_channel_dmactrl_dmainitget()
120+
121+
#endif

0 commit comments

Comments
 (0)