- vlynq_reg_write(dev->local->control, 0);
- vlynq_reg_write(dev->remote->control, 0);
-
-/*
- if (vlynq_linked(dev)) {
- printk(KERN_INFO "%s: linked (using external clock)\n",
- dev->dev.bus_id);
- return vlynq_setup_irq(dev);
- }
-*/
-
- for (div = 1; div <= 8; div++) {
- mdelay(20);
- vlynq_reg_write(dev->local->control, VLYNQ_CTRL_CLOCK_INT |
- VLYNQ_CTRL_CLOCK_DIV(div - 1));
+ switch (dev->divisor) {
+ case vlynq_div_auto:
+ /* First try locally supplied clock */
+ vlynq_reg_write(dev->remote->control, 0);
+ for (i = vlynq_ldiv1; i <= vlynq_ldiv8; i++) {
+ vlynq_reg_write(dev->local->control,
+ VLYNQ_CTRL_CLOCK_INT |
+ VLYNQ_CTRL_CLOCK_DIV(i - vlynq_ldiv1));
+ if (vlynq_linked(dev)) {
+ printk(KERN_DEBUG
+ "%s: using local clock divisor %d\n",
+ dev->dev.bus_id, i - vlynq_ldiv1 + 1);
+ return vlynq_setup_irq(dev);
+ }
+ }
+ /* Then remotely supplied clock */
+ vlynq_reg_write(dev->local->control, 0);
+ for (i = vlynq_rdiv1; i <= vlynq_rdiv8; i++) {
+ vlynq_reg_write(dev->remote->control,
+ VLYNQ_CTRL_CLOCK_INT |
+ VLYNQ_CTRL_CLOCK_DIV(i - vlynq_rdiv1));
+ if (vlynq_linked(dev)) {
+ printk(KERN_DEBUG
+ "%s: using remote clock divisor %d\n",
+ dev->dev.bus_id, i - vlynq_rdiv1 + 1);
+ return vlynq_setup_irq(dev);
+ }
+ }
+ /* At last, externally supplied clock */
+ vlynq_reg_write(dev->remote->control, 0);
+ if (vlynq_linked(dev)) {
+ printk(KERN_DEBUG "%s: using external clock\n",
+ dev->dev.bus_id);
+ return vlynq_setup_irq(dev);
+ }
+ break;
+ case vlynq_ldiv1: case vlynq_ldiv2: case vlynq_ldiv3: case vlynq_ldiv4:
+ case vlynq_ldiv5: case vlynq_ldiv6: case vlynq_ldiv7: case vlynq_ldiv8: