Lines Matching +full:data +full:- +full:bus

24 #include "bus.h"
30 * i2c-algo-bit
35 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); in nvkm_i2c_bus_pre_xfer() local
36 return nvkm_i2c_bus_acquire(bus); in nvkm_i2c_bus_pre_xfer()
42 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); in nvkm_i2c_bus_post_xfer() local
43 return nvkm_i2c_bus_release(bus); in nvkm_i2c_bus_post_xfer()
47 nvkm_i2c_bus_setscl(void *data, int state) in nvkm_i2c_bus_setscl() argument
49 struct nvkm_i2c_bus *bus = data; in nvkm_i2c_bus_setscl() local
50 bus->func->drive_scl(bus, state); in nvkm_i2c_bus_setscl()
54 nvkm_i2c_bus_setsda(void *data, int state) in nvkm_i2c_bus_setsda() argument
56 struct nvkm_i2c_bus *bus = data; in nvkm_i2c_bus_setsda() local
57 bus->func->drive_sda(bus, state); in nvkm_i2c_bus_setsda()
61 nvkm_i2c_bus_getscl(void *data) in nvkm_i2c_bus_getscl() argument
63 struct nvkm_i2c_bus *bus = data; in nvkm_i2c_bus_getscl() local
64 return bus->func->sense_scl(bus); in nvkm_i2c_bus_getscl()
68 nvkm_i2c_bus_getsda(void *data) in nvkm_i2c_bus_getsda() argument
70 struct nvkm_i2c_bus *bus = data; in nvkm_i2c_bus_getsda() local
71 return bus->func->sense_sda(bus); in nvkm_i2c_bus_getsda()
75 * !i2c-algo-bit (off-chip i2c bus / hw i2c / internal bit-banging algo)
80 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); in nvkm_i2c_bus_xfer() local
83 ret = nvkm_i2c_bus_acquire(bus); in nvkm_i2c_bus_xfer()
87 ret = bus->func->xfer(bus, msgs, num); in nvkm_i2c_bus_xfer()
88 nvkm_i2c_bus_release(bus); in nvkm_i2c_bus_xfer()
108 nvkm_i2c_bus_init(struct nvkm_i2c_bus *bus) in nvkm_i2c_bus_init() argument
110 BUS_TRACE(bus, "init"); in nvkm_i2c_bus_init()
111 if (bus->func->init) in nvkm_i2c_bus_init()
112 bus->func->init(bus); in nvkm_i2c_bus_init()
114 mutex_lock(&bus->mutex); in nvkm_i2c_bus_init()
115 bus->enabled = true; in nvkm_i2c_bus_init()
116 mutex_unlock(&bus->mutex); in nvkm_i2c_bus_init()
120 nvkm_i2c_bus_fini(struct nvkm_i2c_bus *bus) in nvkm_i2c_bus_fini() argument
122 BUS_TRACE(bus, "fini"); in nvkm_i2c_bus_fini()
123 mutex_lock(&bus->mutex); in nvkm_i2c_bus_fini()
124 bus->enabled = false; in nvkm_i2c_bus_fini()
125 mutex_unlock(&bus->mutex); in nvkm_i2c_bus_fini()
129 nvkm_i2c_bus_release(struct nvkm_i2c_bus *bus) in nvkm_i2c_bus_release() argument
131 struct nvkm_i2c_pad *pad = bus->pad; in nvkm_i2c_bus_release()
132 BUS_TRACE(bus, "release"); in nvkm_i2c_bus_release()
134 mutex_unlock(&bus->mutex); in nvkm_i2c_bus_release()
138 nvkm_i2c_bus_acquire(struct nvkm_i2c_bus *bus) in nvkm_i2c_bus_acquire() argument
140 struct nvkm_i2c_pad *pad = bus->pad; in nvkm_i2c_bus_acquire()
143 BUS_TRACE(bus, "acquire"); in nvkm_i2c_bus_acquire()
144 mutex_lock(&bus->mutex); in nvkm_i2c_bus_acquire()
146 if (bus->enabled) in nvkm_i2c_bus_acquire()
149 ret = -EIO; in nvkm_i2c_bus_acquire()
152 mutex_unlock(&bus->mutex); in nvkm_i2c_bus_acquire()
157 nvkm_i2c_bus_probe(struct nvkm_i2c_bus *bus, const char *what, in nvkm_i2c_bus_probe() argument
160 struct i2c_board_info *, void *), void *data) in nvkm_i2c_bus_probe() argument
164 BUS_DBG(bus, "probing %ss", what); in nvkm_i2c_bus_probe()
168 if ((bus->i2c.algo == &i2c_bit_algo) && (info[i].udelay != 0)) { in nvkm_i2c_bus_probe()
169 struct i2c_algo_bit_data *algo = bus->i2c.algo_data; in nvkm_i2c_bus_probe()
170 BUS_DBG(bus, "%dms delay instead of %dms", in nvkm_i2c_bus_probe()
171 info[i].udelay, algo->udelay); in nvkm_i2c_bus_probe()
172 orig_udelay = algo->udelay; in nvkm_i2c_bus_probe()
173 algo->udelay = info[i].udelay; in nvkm_i2c_bus_probe()
176 if (nvkm_probe_i2c(&bus->i2c, info[i].dev.addr) && in nvkm_i2c_bus_probe()
177 (!match || match(bus, &info[i].dev, data))) { in nvkm_i2c_bus_probe()
178 BUS_DBG(bus, "detected %s: %s", in nvkm_i2c_bus_probe()
184 struct i2c_algo_bit_data *algo = bus->i2c.algo_data; in nvkm_i2c_bus_probe()
185 algo->udelay = orig_udelay; in nvkm_i2c_bus_probe()
189 BUS_DBG(bus, "no devices found."); in nvkm_i2c_bus_probe()
190 return -ENODEV; in nvkm_i2c_bus_probe()
196 struct nvkm_i2c_bus *bus = *pbus; in nvkm_i2c_bus_del() local
197 if (bus && !WARN_ON(!bus->func)) { in nvkm_i2c_bus_del()
198 BUS_TRACE(bus, "dtor"); in nvkm_i2c_bus_del()
199 list_del(&bus->head); in nvkm_i2c_bus_del()
200 i2c_del_adapter(&bus->i2c); in nvkm_i2c_bus_del()
201 kfree(bus->i2c.algo_data); in nvkm_i2c_bus_del()
210 struct nvkm_i2c_bus *bus) in nvkm_i2c_bus_ctor() argument
212 struct nvkm_device *device = pad->i2c->subdev.device; in nvkm_i2c_bus_ctor()
221 bus->func = func; in nvkm_i2c_bus_ctor()
222 bus->pad = pad; in nvkm_i2c_bus_ctor()
223 bus->id = id; in nvkm_i2c_bus_ctor()
224 mutex_init(&bus->mutex); in nvkm_i2c_bus_ctor()
225 list_add_tail(&bus->head, &pad->i2c->bus); in nvkm_i2c_bus_ctor()
226 BUS_TRACE(bus, "ctor"); in nvkm_i2c_bus_ctor()
228 snprintf(bus->i2c.name, sizeof(bus->i2c.name), "nvkm-%s-bus-%04x", in nvkm_i2c_bus_ctor()
229 dev_name(device->dev), id); in nvkm_i2c_bus_ctor()
230 bus->i2c.owner = THIS_MODULE; in nvkm_i2c_bus_ctor()
231 bus->i2c.dev.parent = device->dev; in nvkm_i2c_bus_ctor()
233 if ( bus->func->drive_scl && in nvkm_i2c_bus_ctor()
234 !nvkm_boolopt(device->cfgopt, "NvI2C", internal)) { in nvkm_i2c_bus_ctor()
236 return -ENOMEM; in nvkm_i2c_bus_ctor()
237 bit->udelay = 10; in nvkm_i2c_bus_ctor()
238 bit->timeout = usecs_to_jiffies(2200); in nvkm_i2c_bus_ctor()
239 bit->data = bus; in nvkm_i2c_bus_ctor()
240 bit->pre_xfer = nvkm_i2c_bus_pre_xfer; in nvkm_i2c_bus_ctor()
241 bit->post_xfer = nvkm_i2c_bus_post_xfer; in nvkm_i2c_bus_ctor()
242 bit->setscl = nvkm_i2c_bus_setscl; in nvkm_i2c_bus_ctor()
243 bit->setsda = nvkm_i2c_bus_setsda; in nvkm_i2c_bus_ctor()
244 bit->getscl = nvkm_i2c_bus_getscl; in nvkm_i2c_bus_ctor()
245 bit->getsda = nvkm_i2c_bus_getsda; in nvkm_i2c_bus_ctor()
246 bus->i2c.algo_data = bit; in nvkm_i2c_bus_ctor()
247 ret = i2c_bit_add_bus(&bus->i2c); in nvkm_i2c_bus_ctor()
249 bus->i2c.algo = &nvkm_i2c_bus_algo; in nvkm_i2c_bus_ctor()
250 ret = i2c_add_adapter(&bus->i2c); in nvkm_i2c_bus_ctor()
262 return -ENOMEM; in nvkm_i2c_bus_new_()