This source file includes following definitions.
- nv4e_i2c_bus_drive_scl
- nv4e_i2c_bus_drive_sda
- nv4e_i2c_bus_sense_scl
- nv4e_i2c_bus_sense_sda
- nv4e_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 nv4e_i2c_bus(p) container_of((p), struct nv4e_i2c_bus, base)
25 #include "bus.h"
26
27 struct nv4e_i2c_bus {
28 struct nvkm_i2c_bus base;
29 u32 addr;
30 };
31
32 static void
33 nv4e_i2c_bus_drive_scl(struct nvkm_i2c_bus *base, int state)
34 {
35 struct nv4e_i2c_bus *bus = nv4e_i2c_bus(base);
36 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
37 nvkm_mask(device, bus->addr, 0x2f, state ? 0x21 : 0x01);
38 }
39
40 static void
41 nv4e_i2c_bus_drive_sda(struct nvkm_i2c_bus *base, int state)
42 {
43 struct nv4e_i2c_bus *bus = nv4e_i2c_bus(base);
44 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
45 nvkm_mask(device, bus->addr, 0x1f, state ? 0x11 : 0x01);
46 }
47
48 static int
49 nv4e_i2c_bus_sense_scl(struct nvkm_i2c_bus *base)
50 {
51 struct nv4e_i2c_bus *bus = nv4e_i2c_bus(base);
52 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
53 return !!(nvkm_rd32(device, bus->addr) & 0x00040000);
54 }
55
56 static int
57 nv4e_i2c_bus_sense_sda(struct nvkm_i2c_bus *base)
58 {
59 struct nv4e_i2c_bus *bus = nv4e_i2c_bus(base);
60 struct nvkm_device *device = bus->base.pad->i2c->subdev.device;
61 return !!(nvkm_rd32(device, bus->addr) & 0x00080000);
62 }
63
64 static const struct nvkm_i2c_bus_func
65 nv4e_i2c_bus_func = {
66 .drive_scl = nv4e_i2c_bus_drive_scl,
67 .drive_sda = nv4e_i2c_bus_drive_sda,
68 .sense_scl = nv4e_i2c_bus_sense_scl,
69 .sense_sda = nv4e_i2c_bus_sense_sda,
70 .xfer = nvkm_i2c_bit_xfer,
71 };
72
73 int
74 nv4e_i2c_bus_new(struct nvkm_i2c_pad *pad, int id, u8 drive,
75 struct nvkm_i2c_bus **pbus)
76 {
77 struct nv4e_i2c_bus *bus;
78
79 if (!(bus = kzalloc(sizeof(*bus), GFP_KERNEL)))
80 return -ENOMEM;
81 *pbus = &bus->base;
82
83 nvkm_i2c_bus_ctor(&nv4e_i2c_bus_func, pad, id, &bus->base);
84 bus->addr = 0x600800 + drive;
85 return 0;
86 }