This source file includes following definitions.
- nv04_i2c_bus_drive_scl
- nv04_i2c_bus_drive_sda
- nv04_i2c_bus_sense_scl
- nv04_i2c_bus_sense_sda
- nv04_i2c_bus_new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #define nv04_i2c_bus(p) container_of((p), struct nv04_i2c_bus, base)
25 #include "bus.h"
26
27 #include <subdev/vga.h>
28
29 struct nv04_i2c_bus {
30 struct nvkm_i2c_bus base;
31 u8 drive;
32 u8 sense;
33 };
34
35 static void
36 nv04_i2c_bus_drive_scl(struct nvkm_i2c_bus *base, int state)
37 {
38 struct nv04_i2c_bus *bus = nv04_i2c_bus(base);
39 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
40 u8 val = nvkm_rdvgac(device, 0, bus->drive);
41 if (state) val |= 0x20;
42 else val &= 0xdf;
43 nvkm_wrvgac(device, 0, bus->drive, val | 0x01);
44 }
45
46 static void
47 nv04_i2c_bus_drive_sda(struct nvkm_i2c_bus *base, int state)
48 {
49 struct nv04_i2c_bus *bus = nv04_i2c_bus(base);
50 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
51 u8 val = nvkm_rdvgac(device, 0, bus->drive);
52 if (state) val |= 0x10;
53 else val &= 0xef;
54 nvkm_wrvgac(device, 0, bus->drive, val | 0x01);
55 }
56
57 static int
58 nv04_i2c_bus_sense_scl(struct nvkm_i2c_bus *base)
59 {
60 struct nv04_i2c_bus *bus = nv04_i2c_bus(base);
61 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
62 return !!(nvkm_rdvgac(device, 0, bus->sense) & 0x04);
63 }
64
65 static int
66 nv04_i2c_bus_sense_sda(struct nvkm_i2c_bus *base)
67 {
68 struct nv04_i2c_bus *bus = nv04_i2c_bus(base);
69 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
70 return !!(nvkm_rdvgac(device, 0, bus->sense) & 0x08);
71 }
72
73 static const struct nvkm_i2c_bus_func
74 nv04_i2c_bus_func = {
75 .drive_scl = nv04_i2c_bus_drive_scl,
76 .drive_sda = nv04_i2c_bus_drive_sda,
77 .sense_scl = nv04_i2c_bus_sense_scl,
78 .sense_sda = nv04_i2c_bus_sense_sda,
79 .xfer = nvkm_i2c_bit_xfer,
80 };
81
82 int
83 nv04_i2c_bus_new(struct nvkm_i2c_pad *pad, int id, u8 drive, u8 sense,
84 struct nvkm_i2c_bus **pbus)
85 {
86 struct nv04_i2c_bus *bus;
87
88 if (!(bus = kzalloc(sizeof(*bus), GFP_KERNEL)))
89 return -ENOMEM;
90 *pbus = &bus->base;
91
92 nvkm_i2c_bus_ctor(&nv04_i2c_bus_func, pad, id, &bus->base);
93 bus->drive = drive;
94 bus->sense = sense;
95 return 0;
96 }