summaryrefslogtreecommitdiff
path: root/target/linux/ar7/files
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2008-08-31 11:32:26 +0000
committerFlorian Fainelli <florian@openwrt.org>2008-08-31 11:32:26 +0000
commit3abe371efdeffd046cbaacdf1af75d8ce57cf536 (patch)
treeb50578e6dd385093bb64ce525f79702174b98f62 /target/linux/ar7/files
parentb25f2f5edb9f618ee32a7a3a5165165e579e9fba (diff)
downloadmtk-20170518-3abe371efdeffd046cbaacdf1af75d8ce57cf536.zip
mtk-20170518-3abe371efdeffd046cbaacdf1af75d8ce57cf536.tar.gz
mtk-20170518-3abe371efdeffd046cbaacdf1af75d8ce57cf536.tar.bz2
Fix divisor settings for external devices like wireless devices, thanks sn9
SVN-Revision: 12443
Diffstat (limited to 'target/linux/ar7/files')
-rw-r--r--target/linux/ar7/files/drivers/vlynq/vlynq.c54
-rw-r--r--target/linux/ar7/files/include/linux/vlynq.h2
2 files changed, 42 insertions, 14 deletions
diff --git a/target/linux/ar7/files/drivers/vlynq/vlynq.c b/target/linux/ar7/files/drivers/vlynq/vlynq.c
index 3358bb7..1de5789 100644
--- a/target/linux/ar7/files/drivers/vlynq/vlynq.c
+++ b/target/linux/ar7/files/drivers/vlynq/vlynq.c
@@ -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;
}
@@ -602,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:
@@ -626,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),
@@ -648,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;
@@ -662,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);
}
diff --git a/target/linux/ar7/files/include/linux/vlynq.h b/target/linux/ar7/files/include/linux/vlynq.h
index 7658fe4..8f6a958 100644
--- a/target/linux/ar7/files/include/linux/vlynq.h
+++ b/target/linux/ar7/files/include/linux/vlynq.h
@@ -59,7 +59,7 @@ struct vlynq_device_id {
struct vlynq_regs;
struct vlynq_device {
- u32 id;
+ u32 id, dev_id;
int local_irq;
int remote_irq;
enum vlynq_divisor divisor;