Lines Matching full:iface
80 #define ACBSDA (iface->base + 0)
81 #define ACBST (iface->base + 1)
87 #define ACBCST (iface->base + 2)
89 #define ACBCTL1 (iface->base + 3)
95 #define ACBADDR (iface->base + 4)
96 #define ACBCTL2 (iface->base + 5)
101 static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) in scx200_acb_machine() argument
105 dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n", in scx200_acb_machine()
106 scx200_acb_state_name[iface->state], status); in scx200_acb_machine()
117 dev_dbg(&iface->adapter.dev, "negative ack in state %s\n", in scx200_acb_machine()
118 scx200_acb_state_name[iface->state]); in scx200_acb_machine()
120 iface->state = state_idle; in scx200_acb_machine()
121 iface->result = -ENXIO; in scx200_acb_machine()
131 switch (iface->state) { in scx200_acb_machine()
133 dev_warn(&iface->adapter.dev, "interrupt in idle state\n"); in scx200_acb_machine()
138 outb(iface->address_byte & ~1, ACBSDA); in scx200_acb_machine()
140 iface->state = state_command; in scx200_acb_machine()
144 outb(iface->command, ACBSDA); in scx200_acb_machine()
146 if (iface->address_byte & 1) in scx200_acb_machine()
147 iface->state = state_repeat_start; in scx200_acb_machine()
149 iface->state = state_write; in scx200_acb_machine()
157 if (iface->address_byte & 1) { in scx200_acb_machine()
158 if (iface->len == 1) in scx200_acb_machine()
162 outb(iface->address_byte, ACBSDA); in scx200_acb_machine()
164 iface->state = state_read; in scx200_acb_machine()
166 outb(iface->address_byte, ACBSDA); in scx200_acb_machine()
168 iface->state = state_write; in scx200_acb_machine()
174 if (iface->len == 2) in scx200_acb_machine()
179 if (iface->len == 1) { in scx200_acb_machine()
180 iface->result = 0; in scx200_acb_machine()
181 iface->state = state_idle; in scx200_acb_machine()
185 *iface->ptr++ = inb(ACBSDA); in scx200_acb_machine()
186 --iface->len; in scx200_acb_machine()
191 if (iface->len == 0) { in scx200_acb_machine()
192 iface->result = 0; in scx200_acb_machine()
193 iface->state = state_idle; in scx200_acb_machine()
198 outb(*iface->ptr++, ACBSDA); in scx200_acb_machine()
199 --iface->len; in scx200_acb_machine()
207 dev_err(&iface->adapter.dev, in scx200_acb_machine()
209 scx200_acb_state_name[iface->state], iface->address_byte, in scx200_acb_machine()
210 iface->len, status); in scx200_acb_machine()
212 iface->state = state_idle; in scx200_acb_machine()
213 iface->result = -EIO; in scx200_acb_machine()
214 iface->needs_reset = 1; in scx200_acb_machine()
217 static void scx200_acb_poll(struct scx200_acb_iface *iface) in scx200_acb_poll() argument
230 scx200_acb_machine(iface, status); in scx200_acb_poll()
239 dev_err(&iface->adapter.dev, "timeout in state %s\n", in scx200_acb_poll()
240 scx200_acb_state_name[iface->state]); in scx200_acb_poll()
242 iface->state = state_idle; in scx200_acb_poll()
243 iface->result = -EIO; in scx200_acb_poll()
244 iface->needs_reset = 1; in scx200_acb_poll()
247 static void scx200_acb_reset(struct scx200_acb_iface *iface) in scx200_acb_reset() argument
273 struct scx200_acb_iface *iface = i2c_get_adapdata(adapter); in scx200_acb_smbus_xfer() local
321 mutex_lock(&iface->mutex); in scx200_acb_smbus_xfer()
323 iface->address_byte = (address << 1) | rw; in scx200_acb_smbus_xfer()
324 iface->command = command; in scx200_acb_smbus_xfer()
325 iface->ptr = buffer; in scx200_acb_smbus_xfer()
326 iface->len = len; in scx200_acb_smbus_xfer()
327 iface->result = -EINVAL; in scx200_acb_smbus_xfer()
328 iface->needs_reset = 0; in scx200_acb_smbus_xfer()
333 iface->state = state_quick; in scx200_acb_smbus_xfer()
335 iface->state = state_address; in scx200_acb_smbus_xfer()
337 while (iface->state != state_idle) in scx200_acb_smbus_xfer()
338 scx200_acb_poll(iface); in scx200_acb_smbus_xfer()
340 if (iface->needs_reset) in scx200_acb_smbus_xfer()
341 scx200_acb_reset(iface); in scx200_acb_smbus_xfer()
343 rc = iface->result; in scx200_acb_smbus_xfer()
345 mutex_unlock(&iface->mutex); in scx200_acb_smbus_xfer()
380 static int scx200_acb_probe(struct scx200_acb_iface *iface) in scx200_acb_probe() argument
418 struct scx200_acb_iface *iface; in scx200_create_iface() local
421 iface = kzalloc(sizeof(*iface), GFP_KERNEL); in scx200_create_iface()
422 if (!iface) in scx200_create_iface()
425 adapter = &iface->adapter; in scx200_create_iface()
426 i2c_set_adapdata(adapter, iface); in scx200_create_iface()
433 mutex_init(&iface->mutex); in scx200_create_iface()
435 return iface; in scx200_create_iface()
438 static int scx200_acb_create(struct scx200_acb_iface *iface) in scx200_acb_create() argument
443 adapter = &iface->adapter; in scx200_acb_create()
445 rc = scx200_acb_probe(iface); in scx200_acb_create()
451 scx200_acb_reset(iface); in scx200_acb_create()
461 iface->next = scx200_acb_list; in scx200_acb_create()
462 scx200_acb_list = iface; in scx200_acb_create()
472 struct scx200_acb_iface *iface; in scx200_create_dev() local
475 iface = scx200_create_iface(text, dev, index); in scx200_create_dev()
477 if (iface == NULL) in scx200_create_dev()
480 if (!request_region(base, 8, iface->adapter.name)) { in scx200_create_dev()
485 iface->base = base; in scx200_create_dev()
486 rc = scx200_acb_create(iface); in scx200_create_dev()
489 return iface; in scx200_create_dev()
493 kfree(iface); in scx200_create_dev()
499 struct scx200_acb_iface *iface; in scx200_probe() local
508 iface = scx200_create_dev("CS5535", res->start, 0, &pdev->dev); in scx200_probe()
509 if (!iface) in scx200_probe()
513 iface->adapter.name); in scx200_probe()
514 platform_set_drvdata(pdev, iface); in scx200_probe()
519 static void scx200_cleanup_iface(struct scx200_acb_iface *iface) in scx200_cleanup_iface() argument
521 i2c_del_adapter(&iface->adapter); in scx200_cleanup_iface()
522 release_region(iface->base, 8); in scx200_cleanup_iface()
523 kfree(iface); in scx200_cleanup_iface()
528 struct scx200_acb_iface *iface; in scx200_remove() local
530 iface = platform_get_drvdata(pdev); in scx200_remove()
531 scx200_cleanup_iface(iface); in scx200_remove()
583 struct scx200_acb_iface *iface; in scx200_acb_cleanup() local
588 while ((iface = scx200_acb_list) != NULL) { in scx200_acb_cleanup()
589 scx200_acb_list = iface->next; in scx200_acb_cleanup()
592 scx200_cleanup_iface(iface); in scx200_acb_cleanup()