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