1 /* $NetBSD: nouveau_nvkm_subdev_ibus_gp10b.c,v 1.2 2021/12/18 23:45:40 riastradh Exp $ */
2
3 /*
4 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24 #include <sys/cdefs.h>
25 __KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_subdev_ibus_gp10b.c,v 1.2 2021/12/18 23:45:40 riastradh Exp $");
26
27 #include <subdev/ibus.h>
28
29 #include "priv.h"
30
31 static int
gp10b_ibus_init(struct nvkm_subdev * ibus)32 gp10b_ibus_init(struct nvkm_subdev *ibus)
33 {
34 struct nvkm_device *device = ibus->device;
35
36 nvkm_wr32(device, 0x1200a8, 0x0);
37
38 /* init ring */
39 nvkm_wr32(device, 0x12004c, 0x4);
40 nvkm_wr32(device, 0x122204, 0x2);
41 nvkm_rd32(device, 0x122204);
42
43 /* timeout configuration */
44 nvkm_wr32(device, 0x009080, 0x800186a0);
45
46 return 0;
47 }
48
49 static const struct nvkm_subdev_func
50 gp10b_ibus = {
51 .init = gp10b_ibus_init,
52 .intr = gk104_ibus_intr,
53 };
54
55 int
gp10b_ibus_new(struct nvkm_device * device,int index,struct nvkm_subdev ** pibus)56 gp10b_ibus_new(struct nvkm_device *device, int index,
57 struct nvkm_subdev **pibus)
58 {
59 struct nvkm_subdev *ibus;
60 if (!(ibus = *pibus = kzalloc(sizeof(*ibus), GFP_KERNEL)))
61 return -ENOMEM;
62 nvkm_subdev_ctor(&gp10b_ibus, device, index, ibus);
63 return 0;
64 }
65