X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=target%2Flinux%2Far7%2Ffiles%2Fdrivers%2Fvlynq%2Fvlynq.c;h=1de5789b7c6d7ec70ad1be91caac20255e6271d9;hb=3abe371efdeffd046cbaacdf1af75d8ce57cf536;hp=c2ac536ba16819095c8cf5ac5a158db7ced63346;hpb=9b93a436c7d6756444252404fde0c69464d176e3;p=librecmc%2Flibrecmc.git diff --git a/target/linux/ar7/files/drivers/vlynq/vlynq.c b/target/linux/ar7/files/drivers/vlynq/vlynq.c index c2ac536ba1..1de5789b7c 100644 --- a/target/linux/ar7/files/drivers/vlynq/vlynq.c +++ b/target/linux/ar7/files/drivers/vlynq/vlynq.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006, 2007 OpenWrt.org + * Copyright (C) 2006, 2007 Eugene Konev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,7 +68,7 @@ struct vlynq_regs { u32 autonego; u32 unused[6]; u32 int_device[8]; -} __attribute__ ((packed)); +}; #define vlynq_reg_read(reg) readl(&(reg)) #define vlynq_reg_write(reg, val) writel(val, &(reg)) @@ -304,20 +304,36 @@ static int vlynq_device_match(struct device *dev, struct plat_vlynq_ops *ops = dev->platform_data; struct vlynq_device_id *ids = vdrv->id_table; u32 id = 0; - int result; + int result, flag; while (ids->id) { - vdev->divisor = ids->divisor; - result = __vlynq_enable_device(vdev); - if (result == 0) { - id = vlynq_reg_read(vdev->remote->chip); - ops->off(vdev); - if (ids->id == id) { - vlynq_set_drvdata(vdev, ids); - return 1; - } + flag = 0; + if (ids->divisor != vlynq_div_auto + && vdev->divisor == vlynq_div_auto) { + flag = 1; + vdev->divisor = ids->divisor; + result = __vlynq_enable_device(vdev); + if (result == 0) { + id = vlynq_reg_read(vdev->remote->chip); + vlynq_reg_write(vdev->local->control, 0); + vlynq_reg_write(vdev->remote->control, 0); + ops->off(vdev); + } else + id = vdev->dev_id; + } else + id = vdev->dev_id; + if (ids->id == id) { + vdev->dev_id = id; + vlynq_set_drvdata(vdev, ids); + printk(KERN_INFO "Driver found for VLYNQ " \ + "device: %08x\n", id); + return 1; } + printk(KERN_INFO "Not using the %08x VLYNQ device's " \ + "driver for VLYNQ device: %08x\n", ids->id, id); ids++; + if (flag) + vdev->divisor = vlynq_div_auto; } return 0; } @@ -380,6 +396,7 @@ static int __vlynq_enable_device(struct vlynq_device *dev) switch (dev->divisor) { case vlynq_div_auto: /* Only try locally supplied clock, others cause problems */ + vlynq_reg_write(dev->local->control, 0); vlynq_reg_write(dev->remote->control, 0); for (i = vlynq_ldiv2; i <= vlynq_ldiv8; i++) { vlynq_reg_write(dev->local->control, @@ -395,11 +412,11 @@ static int __vlynq_enable_device(struct vlynq_device *dev) } case vlynq_ldiv1: case vlynq_ldiv2: case vlynq_ldiv3: case vlynq_ldiv4: case vlynq_ldiv5: case vlynq_ldiv6: case vlynq_ldiv7: case vlynq_ldiv8: - vlynq_reg_write(dev->remote->control, 0); vlynq_reg_write(dev->local->control, VLYNQ_CTRL_CLOCK_INT | VLYNQ_CTRL_CLOCK_DIV(dev->divisor - vlynq_ldiv1)); + vlynq_reg_write(dev->remote->control, 0); if (vlynq_linked(dev)) { printk(KERN_DEBUG "%s: using local clock divisor %d\n", @@ -601,6 +618,18 @@ static int vlynq_probe(struct platform_device *pdev) dev->dev.bus_id, (void *)dev->regs_start, dev->irq, (void *)dev->mem_start); + dev->divisor = vlynq_div_auto; + result = __vlynq_enable_device(dev); + if (result == 0) { + dev->dev_id = vlynq_reg_read(dev->remote->chip); + vlynq_reg_write(dev->local->control, 0); + vlynq_reg_write(dev->remote->control, 0); + ((struct plat_vlynq_ops *)(dev->dev.platform_data))->off(dev); + } else + dev->dev_id = 0; + if (dev->dev_id) + printk(KERN_INFO "Found a VLYNQ device: %08x\n", dev->dev_id); + return 0; fail_register: @@ -625,7 +654,7 @@ static int vlynq_remove(struct platform_device *pdev) return 0; } -static struct platform_driver vlynq_driver = { +static struct platform_driver vlynq_platform_driver = { .driver.name = "vlynq", .probe = vlynq_probe, .remove = __devexit_p(vlynq_remove), @@ -647,7 +676,7 @@ static int __devinit vlynq_init(void) if (res) goto fail_bus; - res = platform_driver_register(&vlynq_driver); + res = platform_driver_register(&vlynq_platform_driver); if (res) goto fail_platform; @@ -661,7 +690,7 @@ fail_bus: static void __devexit vlynq_exit(void) { - platform_driver_unregister(&vlynq_driver); + platform_driver_unregister(&vlynq_platform_driver); bus_unregister(&vlynq_bus_type); }