1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 09:17:42 +02:00

Fix divisor settings for external devices like wireless devices, thanks sn9

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@12443 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2008-08-31 11:32:26 +00:00
parent 668080e69c
commit f46a1a6ee4
2 changed files with 42 additions and 14 deletions

View File

@ -304,20 +304,36 @@ static int vlynq_device_match(struct device *dev,
struct plat_vlynq_ops *ops = dev->platform_data; struct plat_vlynq_ops *ops = dev->platform_data;
struct vlynq_device_id *ids = vdrv->id_table; struct vlynq_device_id *ids = vdrv->id_table;
u32 id = 0; u32 id = 0;
int result; int result, flag;
while (ids->id) { while (ids->id) {
vdev->divisor = ids->divisor; flag = 0;
result = __vlynq_enable_device(vdev); if (ids->divisor != vlynq_div_auto
if (result == 0) { && vdev->divisor == vlynq_div_auto) {
id = vlynq_reg_read(vdev->remote->chip); flag = 1;
ops->off(vdev); vdev->divisor = ids->divisor;
if (ids->id == id) { result = __vlynq_enable_device(vdev);
vlynq_set_drvdata(vdev, ids); if (result == 0) {
return 1; 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++; ids++;
if (flag)
vdev->divisor = vlynq_div_auto;
} }
return 0; return 0;
} }
@ -602,6 +618,18 @@ static int vlynq_probe(struct platform_device *pdev)
dev->dev.bus_id, (void *)dev->regs_start, dev->irq, dev->dev.bus_id, (void *)dev->regs_start, dev->irq,
(void *)dev->mem_start); (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; return 0;
fail_register: fail_register:
@ -626,7 +654,7 @@ static int vlynq_remove(struct platform_device *pdev)
return 0; return 0;
} }
static struct platform_driver vlynq_driver = { static struct platform_driver vlynq_platform_driver = {
.driver.name = "vlynq", .driver.name = "vlynq",
.probe = vlynq_probe, .probe = vlynq_probe,
.remove = __devexit_p(vlynq_remove), .remove = __devexit_p(vlynq_remove),
@ -648,7 +676,7 @@ static int __devinit vlynq_init(void)
if (res) if (res)
goto fail_bus; goto fail_bus;
res = platform_driver_register(&vlynq_driver); res = platform_driver_register(&vlynq_platform_driver);
if (res) if (res)
goto fail_platform; goto fail_platform;
@ -662,7 +690,7 @@ fail_bus:
static void __devexit vlynq_exit(void) static void __devexit vlynq_exit(void)
{ {
platform_driver_unregister(&vlynq_driver); platform_driver_unregister(&vlynq_platform_driver);
bus_unregister(&vlynq_bus_type); bus_unregister(&vlynq_bus_type);
} }

View File

@ -59,7 +59,7 @@ struct vlynq_device_id {
struct vlynq_regs; struct vlynq_regs;
struct vlynq_device { struct vlynq_device {
u32 id; u32 id, dev_id;
int local_irq; int local_irq;
int remote_irq; int remote_irq;
enum vlynq_divisor divisor; enum vlynq_divisor divisor;