Lines Matching +full:i2c +full:- +full:retry +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2003-2005 Ben. Herrenschmidt (benh@kernel.crashing.org)
7 * The linux i2c layer isn't completely suitable for our needs for various
11 * This file thus provides a simple low level unified i2c interface for
12 * powermac that covers the various types of i2c busses used in Apple machines.
19 * as the interrupt is currently used by i2c-keywest. In the long run, we
20 * might want to get rid of those high-level interfaces to linux i2c layer
41 #include <linux/i2c.h>
107 * i2c-keywest */
182 name, __kw_state_names[host->state], isr); \
196 return readb(host->base + (((unsigned int)reg) << host->bsteps)); in __kw_read_reg()
202 writeb(val, host->base + (((unsigned)reg) << host->bsteps)); in __kw_write_reg()
223 if (host->polled) { in kw_i2c_wait_interrupt()
235 host->state = state_stop; in kw_i2c_do_stop()
236 host->result = result; in kw_i2c_do_stop()
245 __kw_state_names[host->state], isr); in kw_i2c_handle_interrupt()
247 if (host->state == state_idle) { in kw_i2c_handle_interrupt()
255 printk(KERN_WARNING "low_i2c: Timeout in i2c transfer" in kw_i2c_handle_interrupt()
257 if (host->state != state_stop) { in kw_i2c_handle_interrupt()
258 kw_i2c_do_stop(host, -EIO); in kw_i2c_handle_interrupt()
264 host->state = state_idle; in kw_i2c_handle_interrupt()
266 if (!host->polled) in kw_i2c_handle_interrupt()
267 complete(&host->complete); in kw_i2c_handle_interrupt()
273 if (host->state != state_addr) { in kw_i2c_handle_interrupt()
275 kw_i2c_do_stop(host, -EIO); in kw_i2c_handle_interrupt()
278 host->result = -ENXIO; in kw_i2c_handle_interrupt()
279 host->state = state_stop; in kw_i2c_handle_interrupt()
282 if (host->len == 0) in kw_i2c_handle_interrupt()
284 else if (host->rw) { in kw_i2c_handle_interrupt()
285 host->state = state_read; in kw_i2c_handle_interrupt()
286 if (host->len > 1) in kw_i2c_handle_interrupt()
290 host->state = state_write; in kw_i2c_handle_interrupt()
291 kw_write_reg(reg_data, *(host->data++)); in kw_i2c_handle_interrupt()
292 host->len--; in kw_i2c_handle_interrupt()
299 if (host->state == state_read) { in kw_i2c_handle_interrupt()
300 *(host->data++) = kw_read_reg(reg_data); in kw_i2c_handle_interrupt()
301 host->len--; in kw_i2c_handle_interrupt()
303 if (host->len == 0) in kw_i2c_handle_interrupt()
304 host->state = state_stop; in kw_i2c_handle_interrupt()
305 else if (host->len == 1) in kw_i2c_handle_interrupt()
307 } else if (host->state == state_write) { in kw_i2c_handle_interrupt()
311 host->result = -EFBIG; in kw_i2c_handle_interrupt()
312 host->state = state_stop; in kw_i2c_handle_interrupt()
313 } else if (host->len) { in kw_i2c_handle_interrupt()
314 kw_write_reg(reg_data, *(host->data++)); in kw_i2c_handle_interrupt()
315 host->len--; in kw_i2c_handle_interrupt()
320 if (host->state != state_stop) in kw_i2c_handle_interrupt()
321 kw_i2c_do_stop(host, -EIO); in kw_i2c_handle_interrupt()
328 if (host->state != state_stop) { in kw_i2c_handle_interrupt()
330 host->result = -EIO; in kw_i2c_handle_interrupt()
332 host->state = state_idle; in kw_i2c_handle_interrupt()
333 if (!host->polled) in kw_i2c_handle_interrupt()
334 complete(&host->complete); in kw_i2c_handle_interrupt()
349 spin_lock_irqsave(&host->lock, flags); in kw_i2c_irq()
350 del_timer(&host->timeout_timer); in kw_i2c_irq()
352 if (host->state != state_idle) { in kw_i2c_irq()
353 host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT; in kw_i2c_irq()
354 add_timer(&host->timeout_timer); in kw_i2c_irq()
356 spin_unlock_irqrestore(&host->lock, flags); in kw_i2c_irq()
365 spin_lock_irqsave(&host->lock, flags); in kw_i2c_timeout()
371 if (timer_pending(&host->timeout_timer)) in kw_i2c_timeout()
375 if (host->state != state_idle) { in kw_i2c_timeout()
376 host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT; in kw_i2c_timeout()
377 add_timer(&host->timeout_timer); in kw_i2c_timeout()
380 spin_unlock_irqrestore(&host->lock, flags); in kw_i2c_timeout()
385 struct pmac_i2c_host_kw *host = bus->hostdata; in kw_i2c_open()
386 mutex_lock(&host->mutex); in kw_i2c_open()
392 struct pmac_i2c_host_kw *host = bus->hostdata; in kw_i2c_close()
393 mutex_unlock(&host->mutex); in kw_i2c_close()
399 struct pmac_i2c_host_kw *host = bus->hostdata; in kw_i2c_xfer()
400 u8 mode_reg = host->speed; in kw_i2c_xfer()
401 int use_irq = host->irq && !bus->polled; in kw_i2c_xfer()
404 switch(bus->mode) { in kw_i2c_xfer()
406 return -EINVAL; in kw_i2c_xfer()
410 return -EINVAL; in kw_i2c_xfer()
415 return -EINVAL; in kw_i2c_xfer()
420 return -EINVAL; in kw_i2c_xfer()
426 kw_write_reg(reg_mode, mode_reg | (bus->channel << 4)); in kw_i2c_xfer()
440 host->data = data; in kw_i2c_xfer()
441 host->len = len; in kw_i2c_xfer()
442 host->state = state_addr; in kw_i2c_xfer()
443 host->result = 0; in kw_i2c_xfer()
444 host->rw = (addrdir & 1); in kw_i2c_xfer()
445 host->polled = bus->polled; in kw_i2c_xfer()
452 reinit_completion(&host->complete); in kw_i2c_xfer()
456 host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT; in kw_i2c_xfer()
457 add_timer(&host->timeout_timer); in kw_i2c_xfer()
467 wait_for_completion(&host->complete); in kw_i2c_xfer()
469 while(host->state != state_idle) { in kw_i2c_xfer()
473 spin_lock_irqsave(&host->lock, flags); in kw_i2c_xfer()
475 spin_unlock_irqrestore(&host->lock, flags); in kw_i2c_xfer()
482 return host->result; in kw_i2c_xfer()
499 * on all i2c keywest nodes so far ... we would have to fallback in kw_i2c_host_init()
509 mutex_init(&host->mutex); in kw_i2c_host_init()
510 init_completion(&host->complete); in kw_i2c_host_init()
511 spin_lock_init(&host->lock); in kw_i2c_host_init()
512 timer_setup(&host->timeout_timer, kw_i2c_timeout, 0); in kw_i2c_host_init()
514 psteps = of_get_property(np, "AAPL,address-step", NULL); in kw_i2c_host_init()
516 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++) in kw_i2c_host_init()
519 host->speed = KW_I2C_MODE_25KHZ; in kw_i2c_host_init()
520 prate = of_get_property(np, "AAPL,i2c-rate", NULL); in kw_i2c_host_init()
523 host->speed = KW_I2C_MODE_100KHZ; in kw_i2c_host_init()
526 host->speed = KW_I2C_MODE_50KHZ; in kw_i2c_host_init()
529 host->speed = KW_I2C_MODE_25KHZ; in kw_i2c_host_init()
532 host->irq = irq_of_parse_and_map(np, 0); in kw_i2c_host_init()
533 if (!host->irq) in kw_i2c_host_init()
538 host->base = ioremap((*addrp), 0x1000); in kw_i2c_host_init()
539 if (host->base == NULL) { in kw_i2c_host_init()
553 if (request_irq(host->irq, kw_i2c_irq, IRQF_NO_SUSPEND, in kw_i2c_host_init()
554 "keywest i2c", host)) in kw_i2c_host_init()
555 host->irq = 0; in kw_i2c_host_init()
557 printk(KERN_INFO "KeyWest i2c @0x%08x irq %d %pOF\n", in kw_i2c_host_init()
558 *addrp, host->irq, np); in kw_i2c_host_init()
575 bus->controller = of_node_get(controller); in kw_i2c_add()
576 bus->busnode = of_node_get(busnode); in kw_i2c_add()
577 bus->type = pmac_i2c_bus_keywest; in kw_i2c_add()
578 bus->hostdata = host; in kw_i2c_add()
579 bus->channel = channel; in kw_i2c_add()
580 bus->mode = pmac_i2c_mode_std; in kw_i2c_add()
581 bus->open = kw_i2c_open; in kw_i2c_add()
582 bus->close = kw_i2c_close; in kw_i2c_add()
583 bus->xfer = kw_i2c_xfer; in kw_i2c_add()
584 mutex_init(&bus->mutex); in kw_i2c_add()
585 lockdep_register_key(&bus->lock_key); in kw_i2c_add()
586 lockdep_set_class(&bus->mutex, &bus->lock_key); in kw_i2c_add()
588 bus->flags = pmac_i2c_multibus; in kw_i2c_add()
589 list_add(&bus->link, &pmac_i2c_busses); in kw_i2c_add()
592 (controller == busnode) ? "<multibus>" : busnode->full_name); in kw_i2c_add()
599 /* Probe keywest-i2c busses */ in kw_i2c_probe()
600 for_each_compatible_node(np, "i2c","keywest-i2c") { in kw_i2c_probe()
612 * kept hidden in the device-tree. In the future, we might in kw_i2c_probe()
617 multibus = !of_node_name_eq(child, "i2c-bus"); in kw_i2c_probe()
620 /* For a multibus setup, we get the bus count based on the in kw_i2c_probe()
629 chans = parent->name[0] == 'u' ? 2 : 1; in kw_i2c_probe()
655 * i2c command block to the PMU
664 u8 count; member
670 complete(req->arg); in pmu_i2c_complete()
676 struct adb_request *req = bus->hostdata; in pmu_i2c_xfer()
677 struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req->data[1]; in pmu_i2c_xfer()
680 int retry; in pmu_i2c_xfer() local
685 return -EINVAL; in pmu_i2c_xfer()
689 for (retry = 0; retry < 16; retry++) { in pmu_i2c_xfer()
691 hdr->bus = bus->channel; in pmu_i2c_xfer()
692 hdr->count = len; in pmu_i2c_xfer()
694 switch(bus->mode) { in pmu_i2c_xfer()
697 return -EINVAL; in pmu_i2c_xfer()
698 hdr->address = addrdir; in pmu_i2c_xfer()
699 hdr->mode = PMU_I2C_MODE_SIMPLE; in pmu_i2c_xfer()
704 return -EINVAL; in pmu_i2c_xfer()
705 hdr->address = addrdir & 0xfe; in pmu_i2c_xfer()
706 hdr->comb_addr = addrdir; in pmu_i2c_xfer()
707 hdr->sub_addr = subaddr; in pmu_i2c_xfer()
708 if (bus->mode == pmac_i2c_mode_stdsub) in pmu_i2c_xfer()
709 hdr->mode = PMU_I2C_MODE_STDSUB; in pmu_i2c_xfer()
711 hdr->mode = PMU_I2C_MODE_COMBINED; in pmu_i2c_xfer()
714 return -EINVAL; in pmu_i2c_xfer()
718 req->data[0] = PMU_I2C_CMD; in pmu_i2c_xfer()
719 req->reply[0] = 0xff; in pmu_i2c_xfer()
720 req->nbytes = sizeof(struct pmu_i2c_hdr) + 1; in pmu_i2c_xfer()
721 req->done = pmu_i2c_complete; in pmu_i2c_xfer()
722 req->arg = ∁ in pmu_i2c_xfer()
724 memcpy(hdr->data, data, len); in pmu_i2c_xfer()
725 req->nbytes += len; in pmu_i2c_xfer()
731 if (req->reply[0] == PMU_I2C_STATUS_OK) in pmu_i2c_xfer()
735 if (req->reply[0] != PMU_I2C_STATUS_OK) in pmu_i2c_xfer()
736 return -EIO; in pmu_i2c_xfer()
738 for (retry = 0; retry < 16; retry++) { in pmu_i2c_xfer()
746 hdr->bus = PMU_I2C_BUS_STATUS; in pmu_i2c_xfer()
749 req->data[0] = PMU_I2C_CMD; in pmu_i2c_xfer()
750 req->reply[0] = 0xff; in pmu_i2c_xfer()
751 req->nbytes = 2; in pmu_i2c_xfer()
752 req->done = pmu_i2c_complete; in pmu_i2c_xfer()
753 req->arg = ∁ in pmu_i2c_xfer()
759 if (req->reply[0] == PMU_I2C_STATUS_OK && !read) in pmu_i2c_xfer()
761 if (req->reply[0] == PMU_I2C_STATUS_DATAREAD && read) { in pmu_i2c_xfer()
762 int rlen = req->reply_len - 1; in pmu_i2c_xfer()
767 return -EIO; in pmu_i2c_xfer()
770 memcpy(data, &req->reply[1], len); in pmu_i2c_xfer()
774 return -EIO; in pmu_i2c_xfer()
786 /* There might or might not be a "pmu-i2c" node, we use that in pmu_i2c_probe()
787 * or via-pmu itself, whatever we find. I haven't seen a machine in pmu_i2c_probe()
790 busnode = of_find_node_by_name(NULL, "pmu-i2c"); in pmu_i2c_probe()
792 busnode = of_find_node_by_name(NULL, "via-pmu"); in pmu_i2c_probe()
796 printk(KERN_INFO "PMU i2c %pOF\n", busnode); in pmu_i2c_probe()
807 bus->controller = busnode; in pmu_i2c_probe()
808 bus->busnode = busnode; in pmu_i2c_probe()
809 bus->type = pmac_i2c_bus_pmu; in pmu_i2c_probe()
810 bus->channel = channel; in pmu_i2c_probe()
811 bus->mode = pmac_i2c_mode_std; in pmu_i2c_probe()
812 bus->hostdata = bus + 1; in pmu_i2c_probe()
813 bus->xfer = pmu_i2c_xfer; in pmu_i2c_probe()
814 mutex_init(&bus->mutex); in pmu_i2c_probe()
815 lockdep_register_key(&bus->lock_key); in pmu_i2c_probe()
816 lockdep_set_class(&bus->mutex, &bus->lock_key); in pmu_i2c_probe()
817 bus->flags = pmac_i2c_multibus; in pmu_i2c_probe()
818 list_add(&bus->link, &pmac_i2c_busses); in pmu_i2c_probe()
843 struct smu_i2c_cmd *cmd = bus->hostdata; in smu_i2c_xfer()
850 return -EINVAL; in smu_i2c_xfer()
853 cmd->info.bus = bus->channel; in smu_i2c_xfer()
854 cmd->info.devaddr = addrdir; in smu_i2c_xfer()
855 cmd->info.datalen = len; in smu_i2c_xfer()
857 switch(bus->mode) { in smu_i2c_xfer()
860 return -EINVAL; in smu_i2c_xfer()
861 cmd->info.type = SMU_I2C_TRANSFER_SIMPLE; in smu_i2c_xfer()
866 return -EINVAL; in smu_i2c_xfer()
867 cmd->info.sublen = subsize; in smu_i2c_xfer()
868 /* that's big-endian only but heh ! */ in smu_i2c_xfer()
869 memcpy(&cmd->info.subaddr, ((char *)&subaddr) + (4 - subsize), in smu_i2c_xfer()
871 if (bus->mode == pmac_i2c_mode_stdsub) in smu_i2c_xfer()
872 cmd->info.type = SMU_I2C_TRANSFER_STDSUB; in smu_i2c_xfer()
874 cmd->info.type = SMU_I2C_TRANSFER_COMBINED; in smu_i2c_xfer()
877 return -EINVAL; in smu_i2c_xfer()
880 memcpy(cmd->info.data, data, len); in smu_i2c_xfer()
883 cmd->done = smu_i2c_complete; in smu_i2c_xfer()
884 cmd->misc = ∁ in smu_i2c_xfer()
889 rc = cmd->status; in smu_i2c_xfer()
892 memcpy(data, cmd->info.data, len); in smu_i2c_xfer()
906 controller = of_find_node_by_name(NULL, "smu-i2c-control"); in smu_i2c_probe()
912 printk(KERN_INFO "SMU i2c %pOF\n", controller); in smu_i2c_probe()
915 * type as older device trees mix i2c busses and other things in smu_i2c_probe()
919 if (!of_node_is_type(busnode, "i2c") && in smu_i2c_probe()
920 !of_node_is_type(busnode, "i2c-bus")) in smu_i2c_probe()
933 bus->controller = controller; in smu_i2c_probe()
934 bus->busnode = of_node_get(busnode); in smu_i2c_probe()
935 bus->type = pmac_i2c_bus_smu; in smu_i2c_probe()
936 bus->channel = *reg; in smu_i2c_probe()
937 bus->mode = pmac_i2c_mode_std; in smu_i2c_probe()
938 bus->hostdata = bus + 1; in smu_i2c_probe()
939 bus->xfer = smu_i2c_xfer; in smu_i2c_probe()
940 mutex_init(&bus->mutex); in smu_i2c_probe()
941 lockdep_register_key(&bus->lock_key); in smu_i2c_probe()
942 lockdep_set_class(&bus->mutex, &bus->lock_key); in smu_i2c_probe()
943 bus->flags = 0; in smu_i2c_probe()
944 list_add(&bus->link, &pmac_i2c_busses); in smu_i2c_probe()
947 bus->channel, busnode); in smu_i2c_probe()
968 if (p == bus->busnode) { in pmac_i2c_find_bus()
969 if (prev && bus->flags & pmac_i2c_multibus) { in pmac_i2c_find_bus()
975 if (((*reg) >> 8) != bus->channel) in pmac_i2c_find_bus()
1004 return bus->controller; in pmac_i2c_get_controller()
1010 return bus->busnode; in pmac_i2c_get_bus_node()
1016 return bus->type; in pmac_i2c_get_type()
1022 return bus->flags; in pmac_i2c_get_flags()
1028 return bus->channel; in pmac_i2c_get_channel()
1035 return &bus->adapter; in pmac_i2c_get_adapter()
1044 if (&bus->adapter == adapter) in pmac_i2c_adapter_to_bus()
1056 return (&bus->adapter == adapter); in pmac_i2c_match_adapter()
1065 if (np == bus->controller) { in pmac_low_i2c_lock()
1071 return -ENODEV; in pmac_low_i2c_lock()
1081 if (np == bus->controller) { in pmac_low_i2c_unlock()
1087 return -ENODEV; in pmac_low_i2c_unlock()
1098 mutex_lock(&bus->mutex); in pmac_i2c_open()
1099 bus->polled = polled || pmac_i2c_force_poll; in pmac_i2c_open()
1100 bus->opened = 1; in pmac_i2c_open()
1101 bus->mode = pmac_i2c_mode_std; in pmac_i2c_open()
1102 if (bus->open && (rc = bus->open(bus)) != 0) { in pmac_i2c_open()
1103 bus->opened = 0; in pmac_i2c_open()
1104 mutex_unlock(&bus->mutex); in pmac_i2c_open()
1113 WARN_ON(!bus->opened); in pmac_i2c_close()
1114 if (bus->close) in pmac_i2c_close()
1115 bus->close(bus); in pmac_i2c_close()
1116 bus->opened = 0; in pmac_i2c_close()
1117 mutex_unlock(&bus->mutex); in pmac_i2c_close()
1123 WARN_ON(!bus->opened); in pmac_i2c_setmode()
1130 " bus %pOF !\n", mode, bus->busnode); in pmac_i2c_setmode()
1131 return -EINVAL; in pmac_i2c_setmode()
1133 bus->mode = mode; in pmac_i2c_setmode()
1144 WARN_ON(!bus->opened); in pmac_i2c_xfer()
1147 " %d bytes, bus %pOF\n", bus->channel, addrdir, bus->mode, subsize, in pmac_i2c_xfer()
1148 subaddr, len, bus->busnode); in pmac_i2c_xfer()
1150 rc = bus->xfer(bus, addrdir, subsize, subaddr, data, len); in pmac_i2c_xfer()
1176 /* XXX Study device-tree's & apple drivers are get the quirks in pmac_i2c_devscan()
1182 * let's make sure i2c-hwclock doesn't match about "imic" in pmac_i2c_devscan()
1186 { "i2c-hwclock", "imic5002", pmac_i2c_quirk_skip }, in pmac_i2c_devscan()
1187 { "i2c-hwclock", "imic5003", pmac_i2c_quirk_skip }, in pmac_i2c_devscan()
1188 { "i2c-hwclock", NULL, pmac_i2c_quirk_invmask }, in pmac_i2c_devscan()
1189 { "i2c-cpu-voltage", NULL, 0}, in pmac_i2c_devscan()
1190 { "temp-monitor", NULL, 0 }, in pmac_i2c_devscan()
1191 { "supply-monitor", NULL, 0 }, in pmac_i2c_devscan()
1196 * here. For now, we have a table. Others, like 9554 i2c GPIOs used in pmac_i2c_devscan()
1201 for_each_child_of_node(bus->busnode, np) { in pmac_i2c_devscan()
1204 if (bus->flags & pmac_i2c_multibus) in pmac_i2c_devscan()
1207 for (p = whitelist; p->name != NULL; p++) { in pmac_i2c_devscan()
1208 if (!of_node_name_eq(np, p->name)) in pmac_i2c_devscan()
1210 if (p->compatible && in pmac_i2c_devscan()
1211 !of_device_is_compatible(np, p->compatible)) in pmac_i2c_devscan()
1213 if (p->quirks & pmac_i2c_quirk_skip) in pmac_i2c_devscan()
1215 callback(np, p->quirks); in pmac_i2c_devscan()
1239 bus = pmac_i2c_find_bus(func->node); in pmac_i2c_do_begin()
1242 func->node); in pmac_i2c_do_begin()
1246 printk(KERN_ERR "low_i2c: Can't open i2c bus for %pOF (pfunc)\n", in pmac_i2c_do_begin()
1247 func->node); in pmac_i2c_do_begin()
1261 inst->bus = bus; in pmac_i2c_do_begin()
1262 inst->addr = pmac_i2c_get_dev_addr(func->node); in pmac_i2c_do_begin()
1263 inst->quirks = (int)(long)func->driver_data; in pmac_i2c_do_begin()
1273 pmac_i2c_close(inst->bus); in pmac_i2c_do_end()
1281 inst->bytes = len; in pmac_i2c_do_read()
1282 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_read, 0, 0, in pmac_i2c_do_read()
1283 inst->buffer, len); in pmac_i2c_do_read()
1290 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 0, 0, in pmac_i2c_do_write()
1305 if (inst->quirks & pmac_i2c_quirk_invmask) { in pmac_i2c_do_apply_rmw()
1307 inst->scratch[i] = (inst->buffer[i] & mask[i]) | val[i]; in pmac_i2c_do_apply_rmw()
1310 inst->scratch[i] = (inst->buffer[i] & ~mask[i]) in pmac_i2c_do_apply_rmw()
1321 if (masklen > inst->bytes || valuelen > inst->bytes || in pmac_i2c_do_rmw()
1322 totallen > inst->bytes || valuelen > masklen) in pmac_i2c_do_rmw()
1323 return -EINVAL; in pmac_i2c_do_rmw()
1327 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 0, 0, in pmac_i2c_do_rmw()
1328 inst->scratch, totallen); in pmac_i2c_do_rmw()
1335 inst->bytes = len; in pmac_i2c_do_read_sub()
1336 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_read, 1, subaddr, in pmac_i2c_do_read_sub()
1337 inst->buffer, len); in pmac_i2c_do_read_sub()
1345 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 1, in pmac_i2c_do_write_sub()
1353 return pmac_i2c_setmode(inst->bus, mode); in pmac_i2c_do_set_mode()
1362 if (masklen > inst->bytes || valuelen > inst->bytes || in pmac_i2c_do_rmw_sub()
1363 totallen > inst->bytes || valuelen > masklen) in pmac_i2c_do_rmw_sub()
1364 return -EINVAL; in pmac_i2c_do_rmw_sub()
1368 return pmac_i2c_xfer(inst->bus, inst->addr | pmac_i2c_write, 1, in pmac_i2c_do_rmw_sub()
1369 subaddr, inst->scratch, totallen); in pmac_i2c_do_rmw_sub()
1380 if (!args || !args->count || !args->u[0].p) in pmac_i2c_do_mask_and_comp()
1381 return -EINVAL; in pmac_i2c_do_mask_and_comp()
1384 if (len > inst->bytes) in pmac_i2c_do_mask_and_comp()
1385 return -EINVAL; in pmac_i2c_do_mask_and_comp()
1388 if ((inst->buffer[i] & maskdata[i]) != valuedata[i]) in pmac_i2c_do_mask_and_comp()
1390 *args->u[0].p = match; in pmac_i2c_do_mask_and_comp()
1453 * Initialize us: probe all i2c busses on the machine, instantiate
1456 /* This is non-static as it might be called early by smp code */
1465 /* Probe keywest-i2c busses */ in pmac_i2c_init()
1469 /* Probe PMU i2c busses */ in pmac_i2c_init()
1474 /* Probe SMU i2c busses */ in pmac_i2c_init()
1502 bus->platform_dev = in pmac_i2c_create_platform_devices()
1503 platform_device_alloc("i2c-powermac", i++); in pmac_i2c_create_platform_devices()
1504 if (bus->platform_dev == NULL) in pmac_i2c_create_platform_devices()
1505 return -ENOMEM; in pmac_i2c_create_platform_devices()
1506 bus->platform_dev->dev.platform_data = bus; in pmac_i2c_create_platform_devices()
1507 bus->platform_dev->dev.of_node = bus->busnode; in pmac_i2c_create_platform_devices()
1508 platform_device_add(bus->platform_dev); in pmac_i2c_create_platform_devices()