Lines Matching full:bus

25 static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus,
34 static int snd_i2c_bus_free(struct snd_i2c_bus *bus) in snd_i2c_bus_free() argument
39 if (snd_BUG_ON(!bus)) in snd_i2c_bus_free()
41 while (!list_empty(&bus->devices)) { in snd_i2c_bus_free()
42 device = snd_i2c_device(bus->devices.next); in snd_i2c_bus_free()
45 if (bus->master) in snd_i2c_bus_free()
46 list_del(&bus->buses); in snd_i2c_bus_free()
48 while (!list_empty(&bus->buses)) { in snd_i2c_bus_free()
49 slave = snd_i2c_slave_bus(bus->buses.next); in snd_i2c_bus_free()
50 snd_device_free(bus->card, slave); in snd_i2c_bus_free()
53 if (bus->private_free) in snd_i2c_bus_free()
54 bus->private_free(bus); in snd_i2c_bus_free()
55 kfree(bus); in snd_i2c_bus_free()
61 struct snd_i2c_bus *bus = device->device_data; in snd_i2c_bus_dev_free() local
62 return snd_i2c_bus_free(bus); in snd_i2c_bus_dev_free()
68 struct snd_i2c_bus *bus; in snd_i2c_bus_create() local
75 bus = kzalloc(sizeof(*bus), GFP_KERNEL); in snd_i2c_bus_create()
76 if (bus == NULL) in snd_i2c_bus_create()
78 mutex_init(&bus->lock_mutex); in snd_i2c_bus_create()
79 INIT_LIST_HEAD(&bus->devices); in snd_i2c_bus_create()
80 INIT_LIST_HEAD(&bus->buses); in snd_i2c_bus_create()
81 bus->card = card; in snd_i2c_bus_create()
82 bus->ops = &snd_i2c_bit_ops; in snd_i2c_bus_create()
84 list_add_tail(&bus->buses, &master->buses); in snd_i2c_bus_create()
85 bus->master = master; in snd_i2c_bus_create()
87 strscpy(bus->name, name, sizeof(bus->name)); in snd_i2c_bus_create()
88 err = snd_device_new(card, SNDRV_DEV_BUS, bus, &ops); in snd_i2c_bus_create()
90 snd_i2c_bus_free(bus); in snd_i2c_bus_create()
93 *ri2c = bus; in snd_i2c_bus_create()
99 int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name, in snd_i2c_device_create() argument
105 if (snd_BUG_ON(!bus)) in snd_i2c_device_create()
112 list_add_tail(&device->list, &bus->devices); in snd_i2c_device_create()
113 device->bus = bus; in snd_i2c_device_create()
122 if (device->bus) in snd_i2c_device_free()
134 return device->bus->ops->sendbytes(device, bytes, count); in snd_i2c_sendbytes()
141 return device->bus->ops->readbytes(device, bytes, count); in snd_i2c_readbytes()
146 int snd_i2c_probeaddr(struct snd_i2c_bus *bus, unsigned short addr) in snd_i2c_probeaddr() argument
148 return bus->ops->probeaddr(bus, addr); in snd_i2c_probeaddr()
157 static inline void snd_i2c_bit_hw_start(struct snd_i2c_bus *bus) in snd_i2c_bit_hw_start() argument
159 if (bus->hw_ops.bit->start) in snd_i2c_bit_hw_start()
160 bus->hw_ops.bit->start(bus); in snd_i2c_bit_hw_start()
163 static inline void snd_i2c_bit_hw_stop(struct snd_i2c_bus *bus) in snd_i2c_bit_hw_stop() argument
165 if (bus->hw_ops.bit->stop) in snd_i2c_bit_hw_stop()
166 bus->hw_ops.bit->stop(bus); in snd_i2c_bit_hw_stop()
169 static void snd_i2c_bit_direction(struct snd_i2c_bus *bus, int clock, int data) in snd_i2c_bit_direction() argument
171 if (bus->hw_ops.bit->direction) in snd_i2c_bit_direction()
172 bus->hw_ops.bit->direction(bus, clock, data); in snd_i2c_bit_direction()
175 static void snd_i2c_bit_set(struct snd_i2c_bus *bus, int clock, int data) in snd_i2c_bit_set() argument
177 bus->hw_ops.bit->setlines(bus, clock, data); in snd_i2c_bit_set()
181 static int snd_i2c_bit_clock(struct snd_i2c_bus *bus)
183 if (bus->hw_ops.bit->getclock)
184 return bus->hw_ops.bit->getclock(bus);
189 static int snd_i2c_bit_data(struct snd_i2c_bus *bus, int ack) in snd_i2c_bit_data() argument
191 return bus->hw_ops.bit->getdata(bus, ack); in snd_i2c_bit_data()
194 static void snd_i2c_bit_start(struct snd_i2c_bus *bus) in snd_i2c_bit_start() argument
196 snd_i2c_bit_hw_start(bus); in snd_i2c_bit_start()
197 snd_i2c_bit_direction(bus, 1, 1); /* SCL - wr, SDA - wr */ in snd_i2c_bit_start()
198 snd_i2c_bit_set(bus, 1, 1); in snd_i2c_bit_start()
199 snd_i2c_bit_set(bus, 1, 0); in snd_i2c_bit_start()
200 snd_i2c_bit_set(bus, 0, 0); in snd_i2c_bit_start()
203 static void snd_i2c_bit_stop(struct snd_i2c_bus *bus) in snd_i2c_bit_stop() argument
205 snd_i2c_bit_set(bus, 0, 0); in snd_i2c_bit_stop()
206 snd_i2c_bit_set(bus, 1, 0); in snd_i2c_bit_stop()
207 snd_i2c_bit_set(bus, 1, 1); in snd_i2c_bit_stop()
208 snd_i2c_bit_hw_stop(bus); in snd_i2c_bit_stop()
211 static void snd_i2c_bit_send(struct snd_i2c_bus *bus, int data) in snd_i2c_bit_send() argument
213 snd_i2c_bit_set(bus, 0, data); in snd_i2c_bit_send()
214 snd_i2c_bit_set(bus, 1, data); in snd_i2c_bit_send()
215 snd_i2c_bit_set(bus, 0, data); in snd_i2c_bit_send()
218 static int snd_i2c_bit_ack(struct snd_i2c_bus *bus) in snd_i2c_bit_ack() argument
222 snd_i2c_bit_set(bus, 0, 1); in snd_i2c_bit_ack()
223 snd_i2c_bit_set(bus, 1, 1); in snd_i2c_bit_ack()
224 snd_i2c_bit_direction(bus, 1, 0); /* SCL - wr, SDA - rd */ in snd_i2c_bit_ack()
225 ack = snd_i2c_bit_data(bus, 1); in snd_i2c_bit_ack()
226 snd_i2c_bit_direction(bus, 1, 1); /* SCL - wr, SDA - wr */ in snd_i2c_bit_ack()
227 snd_i2c_bit_set(bus, 0, 1); in snd_i2c_bit_ack()
231 static int snd_i2c_bit_sendbyte(struct snd_i2c_bus *bus, unsigned char data) in snd_i2c_bit_sendbyte() argument
236 snd_i2c_bit_send(bus, !!(data & (1 << i))); in snd_i2c_bit_sendbyte()
237 err = snd_i2c_bit_ack(bus); in snd_i2c_bit_sendbyte()
243 static int snd_i2c_bit_readbyte(struct snd_i2c_bus *bus, int last) in snd_i2c_bit_readbyte() argument
248 snd_i2c_bit_set(bus, 0, 1); in snd_i2c_bit_readbyte()
249 snd_i2c_bit_direction(bus, 1, 0); /* SCL - wr, SDA - rd */ in snd_i2c_bit_readbyte()
251 snd_i2c_bit_set(bus, 1, 1); in snd_i2c_bit_readbyte()
252 if (snd_i2c_bit_data(bus, 0)) in snd_i2c_bit_readbyte()
254 snd_i2c_bit_set(bus, 0, 1); in snd_i2c_bit_readbyte()
256 snd_i2c_bit_direction(bus, 1, 1); /* SCL - wr, SDA - wr */ in snd_i2c_bit_readbyte()
257 snd_i2c_bit_send(bus, !!last); in snd_i2c_bit_readbyte()
264 struct snd_i2c_bus *bus = device->bus; in snd_i2c_bit_sendbytes() local
269 snd_i2c_bit_start(bus); in snd_i2c_bit_sendbytes()
270 err = snd_i2c_bit_sendbyte(bus, device->addr << 1); in snd_i2c_bit_sendbytes()
272 snd_i2c_bit_hw_stop(bus); in snd_i2c_bit_sendbytes()
276 err = snd_i2c_bit_sendbyte(bus, *bytes++); in snd_i2c_bit_sendbytes()
278 snd_i2c_bit_hw_stop(bus); in snd_i2c_bit_sendbytes()
283 snd_i2c_bit_stop(bus); in snd_i2c_bit_sendbytes()
290 struct snd_i2c_bus *bus = device->bus; in snd_i2c_bit_readbytes() local
295 snd_i2c_bit_start(bus); in snd_i2c_bit_readbytes()
296 err = snd_i2c_bit_sendbyte(bus, (device->addr << 1) | 1); in snd_i2c_bit_readbytes()
298 snd_i2c_bit_hw_stop(bus); in snd_i2c_bit_readbytes()
302 err = snd_i2c_bit_readbyte(bus, count == 0); in snd_i2c_bit_readbytes()
304 snd_i2c_bit_hw_stop(bus); in snd_i2c_bit_readbytes()
310 snd_i2c_bit_stop(bus); in snd_i2c_bit_readbytes()
314 static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus, unsigned short addr) in snd_i2c_bit_probeaddr() argument
322 snd_i2c_bit_start(bus); in snd_i2c_bit_probeaddr()
323 err = snd_i2c_bit_sendbyte(bus, addr << 1); in snd_i2c_bit_probeaddr()
324 snd_i2c_bit_stop(bus); in snd_i2c_bit_probeaddr()