Lines Matching refs:iface

88 #define ACBSDA		(iface->base + 0)
89 #define ACBST (iface->base + 1)
95 #define ACBCST (iface->base + 2)
97 #define ACBCTL1 (iface->base + 3)
103 #define ACBADDR (iface->base + 4)
104 #define ACBCTL2 (iface->base + 5)
109 static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) in scx200_acb_machine() argument
113 dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", in scx200_acb_machine()
114 scx200_acb_state_name[iface->state], status); in scx200_acb_machine()
125 dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", in scx200_acb_machine()
126 scx200_acb_state_name[iface->state]); in scx200_acb_machine()
128 iface->state = state_idle; in scx200_acb_machine()
129 iface->result = -ENXIO; in scx200_acb_machine()
139 switch (iface->state) { in scx200_acb_machine()
141 dev_warn(&iface->adapter.dev, "interrupt in idle state\n"); in scx200_acb_machine()
146 outb(iface->address_byte & ~1, ACBSDA); in scx200_acb_machine()
148 iface->state = state_command; in scx200_acb_machine()
152 outb(iface->command, ACBSDA); in scx200_acb_machine()
154 if (iface->address_byte & 1) in scx200_acb_machine()
155 iface->state = state_repeat_start; in scx200_acb_machine()
157 iface->state = state_write; in scx200_acb_machine()
165 if (iface->address_byte & 1) { in scx200_acb_machine()
166 if (iface->len == 1) in scx200_acb_machine()
170 outb(iface->address_byte, ACBSDA); in scx200_acb_machine()
172 iface->state = state_read; in scx200_acb_machine()
174 outb(iface->address_byte, ACBSDA); in scx200_acb_machine()
176 iface->state = state_write; in scx200_acb_machine()
182 if (iface->len == 2) in scx200_acb_machine()
187 if (iface->len == 1) { in scx200_acb_machine()
188 iface->result = 0; in scx200_acb_machine()
189 iface->state = state_idle; in scx200_acb_machine()
193 *iface->ptr++ = inb(ACBSDA); in scx200_acb_machine()
194 --iface->len; in scx200_acb_machine()
199 if (iface->len == 0) { in scx200_acb_machine()
200 iface->result = 0; in scx200_acb_machine()
201 iface->state = state_idle; in scx200_acb_machine()
206 outb(*iface->ptr++, ACBSDA); in scx200_acb_machine()
207 --iface->len; in scx200_acb_machine()
215 dev_err(&iface->adapter.dev, in scx200_acb_machine()
217 scx200_acb_state_name[iface->state], iface->address_byte, in scx200_acb_machine()
218 iface->len, status); in scx200_acb_machine()
220 iface->state = state_idle; in scx200_acb_machine()
221 iface->result = -EIO; in scx200_acb_machine()
222 iface->needs_reset = 1; in scx200_acb_machine()
225 static void scx200_acb_poll(struct scx200_acb_iface *iface) in scx200_acb_poll() argument
238 scx200_acb_machine(iface, status); in scx200_acb_poll()
247 dev_err(&iface->adapter.dev, "timeout in state %s\n", in scx200_acb_poll()
248 scx200_acb_state_name[iface->state]); in scx200_acb_poll()
250 iface->state = state_idle; in scx200_acb_poll()
251 iface->result = -EIO; in scx200_acb_poll()
252 iface->needs_reset = 1; in scx200_acb_poll()
255 static void scx200_acb_reset(struct scx200_acb_iface *iface) in scx200_acb_reset() argument
281 struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); in scx200_acb_smbus_xfer() local
329 mutex_lock(&iface->mutex); in scx200_acb_smbus_xfer()
331 iface->address_byte = (address << 1) | rw; in scx200_acb_smbus_xfer()
332 iface->command = command; in scx200_acb_smbus_xfer()
333 iface->ptr = buffer; in scx200_acb_smbus_xfer()
334 iface->len = len; in scx200_acb_smbus_xfer()
335 iface->result = -EINVAL; in scx200_acb_smbus_xfer()
336 iface->needs_reset = 0; in scx200_acb_smbus_xfer()
341 iface->state = state_quick; in scx200_acb_smbus_xfer()
343 iface->state = state_address; in scx200_acb_smbus_xfer()
345 while (iface->state != state_idle) in scx200_acb_smbus_xfer()
346 scx200_acb_poll(iface); in scx200_acb_smbus_xfer()
348 if (iface->needs_reset) in scx200_acb_smbus_xfer()
349 scx200_acb_reset(iface); in scx200_acb_smbus_xfer()
351 rc = iface->result; in scx200_acb_smbus_xfer()
353 mutex_unlock(&iface->mutex); in scx200_acb_smbus_xfer()
388 static int scx200_acb_probe(struct scx200_acb_iface *iface) in scx200_acb_probe() argument
426 struct scx200_acb_iface *iface; in scx200_create_iface() local
429 iface = kzalloc(sizeof(*iface), GFP_KERNEL); in scx200_create_iface()
430 if (!iface) in scx200_create_iface()
433 adapter = &iface->adapter; in scx200_create_iface()
434 i2c_set_adapdata(adapter, iface); in scx200_create_iface()
441 mutex_init(&iface->mutex); in scx200_create_iface()
443 return iface; in scx200_create_iface()
446 static int scx200_acb_create(struct scx200_acb_iface *iface) in scx200_acb_create() argument
451 adapter = &iface->adapter; in scx200_acb_create()
453 rc = scx200_acb_probe(iface); in scx200_acb_create()
459 scx200_acb_reset(iface); in scx200_acb_create()
469 iface->next = scx200_acb_list; in scx200_acb_create()
470 scx200_acb_list = iface; in scx200_acb_create()
480 struct scx200_acb_iface *iface; in scx200_create_dev() local
483 iface = scx200_create_iface(text, dev, index); in scx200_create_dev()
485 if (iface == NULL) in scx200_create_dev()
488 if (!request_region(base, 8, iface->adapter.name)) { in scx200_create_dev()
493 iface->base = base; in scx200_create_dev()
494 rc = scx200_acb_create(iface); in scx200_create_dev()
497 return iface; in scx200_create_dev()
501 kfree(iface); in scx200_create_dev()
507 struct scx200_acb_iface *iface; in scx200_probe() local
516 iface = scx200_create_dev("CS5535", res->start, 0, &pdev->dev); in scx200_probe()
517 if (!iface) in scx200_probe()
521 iface->adapter.name); in scx200_probe()
522 platform_set_drvdata(pdev, iface); in scx200_probe()
527 static void scx200_cleanup_iface(struct scx200_acb_iface *iface) in scx200_cleanup_iface() argument
529 i2c_del_adapter(&iface->adapter); in scx200_cleanup_iface()
530 release_region(iface->base, 8); in scx200_cleanup_iface()
531 kfree(iface); in scx200_cleanup_iface()
536 struct scx200_acb_iface *iface; in scx200_remove() local
538 iface = platform_get_drvdata(pdev); in scx200_remove()
539 scx200_cleanup_iface(iface); in scx200_remove()
591 struct scx200_acb_iface *iface; in scx200_acb_cleanup() local
596 while ((iface = scx200_acb_list) != NULL) { in scx200_acb_cleanup()
597 scx200_acb_list = iface->next; in scx200_acb_cleanup()
600 scx200_cleanup_iface(iface); in scx200_acb_cleanup()