aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/masters
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 15:09:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 15:09:59 -0400
commit3aebd34b1200a902a8662da8845824a02f00772e (patch)
tree13eac224dc1ac40be53bccc90f27bebf2e619c26 /drivers/w1/masters
parent2c0c86d5b67ee04e8b71a2ea2a3af6d224611cfc (diff)
parent5dc2db05f2f690d71d95979b14cca50ab8e49f40 (diff)
Merge tag 'char-misc-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver merge from Greg Kroah-Hartman: "Here is the "big" char/misc driver tree update for the 3.7-rc1 merge window. Nothing major, just a number of driver updates and fixes, all of which have been in the linux-next releases for a while now either in my tree, or in Andrew's (the lis3l driver changes came from his tree last week). Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'char-misc-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (52 commits) drivers/misc/lis3lv02d/lis3lv02d_i2c.c: add lis3lv02d device tree init drivers/misc/lis3lv02d/lis3lv02d_spi.c: add lis3lv02d device tree init drivers/misc/lis3lv02d: remove lis3lv02d driver DT init drivers/misc/lis3lv02d/lis3lv02d_spi.c: add DT matching table passthru code drivers/misc/lis3lv02d: add generic DT matching code lis3lv02d: fix some comments specific to lis331dlh driver MISC: hpilo, remove pci_disable_device pcmcia: synclink_cs: fix potential tty NULL dereference drivers/char/mmtimer.c: Remove useless kfree drivers/char: removes unnecessary semicolon char/misc: remove CONFIG_EXPERIMENTAL dependencies mei: don't print buffer as a string mei: struct mei_message_data doesn't have to be packed mei: add error messages for open count errors misc: use module_spi_driver tifm: use module_pci_driver misc/at25, dt: Improve at25 SPI eeprom device tree bindings. mei: add lynx point pci device ids mei: fix max number of open handles mei: rename struct pci_dev *mei_device to mei_pdev ...
Diffstat (limited to 'drivers/w1/masters')
-rw-r--r--drivers/w1/masters/Kconfig1
-rw-r--r--drivers/w1/masters/omap_hdq.c57
-rw-r--r--drivers/w1/masters/w1-gpio.c66
3 files changed, 77 insertions, 47 deletions
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index 5ceb1cd50195..7e984034a11b 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -60,7 +60,6 @@ config W1_MASTER_GPIO
60 60
61config HDQ_MASTER_OMAP 61config HDQ_MASTER_OMAP
62 tristate "OMAP HDQ driver" 62 tristate "OMAP HDQ driver"
63 depends on ARCH_OMAP2PLUS
64 help 63 help
65 Say Y here if you want support for the 1-wire or HDQ Interface 64 Say Y here if you want support for the 1-wire or HDQ Interface
66 on an OMAP processor. 65 on an OMAP processor.
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 4b0fcf3c2d03..ca8e60bb2f9c 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -18,9 +18,6 @@
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/pm_runtime.h> 19#include <linux/pm_runtime.h>
20 20
21#include <asm/irq.h>
22#include <mach/hardware.h>
23
24#include "../w1.h" 21#include "../w1.h"
25#include "../w1_int.h" 22#include "../w1_int.h"
26 23
@@ -73,11 +70,11 @@ struct hdq_data {
73}; 70};
74 71
75static int __devinit omap_hdq_probe(struct platform_device *pdev); 72static int __devinit omap_hdq_probe(struct platform_device *pdev);
76static int omap_hdq_remove(struct platform_device *pdev); 73static int __devexit omap_hdq_remove(struct platform_device *pdev);
77 74
78static struct platform_driver omap_hdq_driver = { 75static struct platform_driver omap_hdq_driver = {
79 .probe = omap_hdq_probe, 76 .probe = omap_hdq_probe,
80 .remove = omap_hdq_remove, 77 .remove = __devexit_p(omap_hdq_remove),
81 .driver = { 78 .driver = {
82 .name = "omap_hdq", 79 .name = "omap_hdq",
83 }, 80 },
@@ -538,39 +535,35 @@ static void omap_w1_write_byte(void *_hdq, u8 byte)
538 hdq_data->init_trans = 0; 535 hdq_data->init_trans = 0;
539 mutex_unlock(&hdq_data->hdq_mutex); 536 mutex_unlock(&hdq_data->hdq_mutex);
540 } 537 }
541
542 return;
543} 538}
544 539
545static int __devinit omap_hdq_probe(struct platform_device *pdev) 540static int __devinit omap_hdq_probe(struct platform_device *pdev)
546{ 541{
542 struct device *dev = &pdev->dev;
547 struct hdq_data *hdq_data; 543 struct hdq_data *hdq_data;
548 struct resource *res; 544 struct resource *res;
549 int ret, irq; 545 int ret, irq;
550 u8 rev; 546 u8 rev;
551 547
552 hdq_data = kmalloc(sizeof(*hdq_data), GFP_KERNEL); 548 hdq_data = devm_kzalloc(dev, sizeof(*hdq_data), GFP_KERNEL);
553 if (!hdq_data) { 549 if (!hdq_data) {
554 dev_dbg(&pdev->dev, "unable to allocate memory\n"); 550 dev_dbg(&pdev->dev, "unable to allocate memory\n");
555 ret = -ENOMEM; 551 return -ENOMEM;
556 goto err_kmalloc;
557 } 552 }
558 553
559 hdq_data->dev = &pdev->dev; 554 hdq_data->dev = dev;
560 platform_set_drvdata(pdev, hdq_data); 555 platform_set_drvdata(pdev, hdq_data);
561 556
562 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
563 if (!res) { 558 if (!res) {
564 dev_dbg(&pdev->dev, "unable to get resource\n"); 559 dev_dbg(&pdev->dev, "unable to get resource\n");
565 ret = -ENXIO; 560 return -ENXIO;
566 goto err_resource;
567 } 561 }
568 562
569 hdq_data->hdq_base = ioremap(res->start, SZ_4K); 563 hdq_data->hdq_base = devm_request_and_ioremap(dev, res);
570 if (!hdq_data->hdq_base) { 564 if (!hdq_data->hdq_base) {
571 dev_dbg(&pdev->dev, "ioremap failed\n"); 565 dev_dbg(&pdev->dev, "ioremap failed\n");
572 ret = -EINVAL; 566 return -ENOMEM;
573 goto err_ioremap;
574 } 567 }
575 568
576 hdq_data->hdq_usecount = 0; 569 hdq_data->hdq_usecount = 0;
@@ -591,7 +584,8 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev)
591 goto err_irq; 584 goto err_irq;
592 } 585 }
593 586
594 ret = request_irq(irq, hdq_isr, IRQF_DISABLED, "omap_hdq", hdq_data); 587 ret = devm_request_irq(dev, irq, hdq_isr, IRQF_DISABLED,
588 "omap_hdq", hdq_data);
595 if (ret < 0) { 589 if (ret < 0) {
596 dev_dbg(&pdev->dev, "could not request irq\n"); 590 dev_dbg(&pdev->dev, "could not request irq\n");
597 goto err_irq; 591 goto err_irq;
@@ -616,19 +610,10 @@ err_irq:
616err_w1: 610err_w1:
617 pm_runtime_disable(&pdev->dev); 611 pm_runtime_disable(&pdev->dev);
618 612
619 iounmap(hdq_data->hdq_base);
620
621err_ioremap:
622err_resource:
623 platform_set_drvdata(pdev, NULL);
624 kfree(hdq_data);
625
626err_kmalloc:
627 return ret; 613 return ret;
628
629} 614}
630 615
631static int omap_hdq_remove(struct platform_device *pdev) 616static int __devexit omap_hdq_remove(struct platform_device *pdev)
632{ 617{
633 struct hdq_data *hdq_data = platform_get_drvdata(pdev); 618 struct hdq_data *hdq_data = platform_get_drvdata(pdev);
634 619
@@ -644,27 +629,11 @@ static int omap_hdq_remove(struct platform_device *pdev)
644 629
645 /* remove module dependency */ 630 /* remove module dependency */
646 pm_runtime_disable(&pdev->dev); 631 pm_runtime_disable(&pdev->dev);
647 free_irq(INT_24XX_HDQ_IRQ, hdq_data);
648 platform_set_drvdata(pdev, NULL);
649 iounmap(hdq_data->hdq_base);
650 kfree(hdq_data);
651 632
652 return 0; 633 return 0;
653} 634}
654 635
655static int __init 636module_platform_driver(omap_hdq_driver);
656omap_hdq_init(void)
657{
658 return platform_driver_register(&omap_hdq_driver);
659}
660module_init(omap_hdq_init);
661
662static void __exit
663omap_hdq_exit(void)
664{
665 platform_driver_unregister(&omap_hdq_driver);
666}
667module_exit(omap_hdq_exit);
668 637
669module_param(w1_id, int, S_IRUSR); 638module_param(w1_id, int, S_IRUSR);
670MODULE_PARM_DESC(w1_id, "1-wire id for the slave detection"); 639MODULE_PARM_DESC(w1_id, "1-wire id for the slave detection");
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index df600d14974d..6012c4ea3206 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -14,6 +14,8 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/w1-gpio.h> 15#include <linux/w1-gpio.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/of_platform.h>
18#include <linux/of_gpio.h>
17 19
18#include "../w1.h" 20#include "../w1.h"
19#include "../w1_int.h" 21#include "../w1_int.h"
@@ -42,12 +44,55 @@ static u8 w1_gpio_read_bit(void *data)
42 return gpio_get_value(pdata->pin) ? 1 : 0; 44 return gpio_get_value(pdata->pin) ? 1 : 0;
43} 45}
44 46
47#ifdef CONFIG_OF
48static struct of_device_id w1_gpio_dt_ids[] = {
49 { .compatible = "w1-gpio" },
50 {}
51};
52MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids);
53
54static int w1_gpio_probe_dt(struct platform_device *pdev)
55{
56 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
57 struct device_node *np = pdev->dev.of_node;
58 const struct of_device_id *of_id =
59 of_match_device(w1_gpio_dt_ids, &pdev->dev);
60
61 if (!of_id)
62 return 0;
63
64 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
65 if (!pdata)
66 return -ENOMEM;
67
68 if (of_get_property(np, "linux,open-drain", NULL))
69 pdata->is_open_drain = 1;
70
71 pdata->pin = of_get_gpio(np, 0);
72 pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);
73 pdev->dev.platform_data = pdata;
74
75 return 0;
76}
77#else
78static int w1_gpio_probe_dt(struct platform_device *pdev)
79{
80 return 0;
81}
82#endif
83
45static int __init w1_gpio_probe(struct platform_device *pdev) 84static int __init w1_gpio_probe(struct platform_device *pdev)
46{ 85{
47 struct w1_bus_master *master; 86 struct w1_bus_master *master;
48 struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; 87 struct w1_gpio_platform_data *pdata;
49 int err; 88 int err;
50 89
90 err = w1_gpio_probe_dt(pdev);
91 if (err < 0)
92 return err;
93
94 pdata = pdev->dev.platform_data;
95
51 if (!pdata) 96 if (!pdata)
52 return -ENXIO; 97 return -ENXIO;
53 98
@@ -59,6 +104,13 @@ static int __init w1_gpio_probe(struct platform_device *pdev)
59 if (err) 104 if (err)
60 goto free_master; 105 goto free_master;
61 106
107 if (gpio_is_valid(pdata->ext_pullup_enable_pin)) {
108 err = gpio_request_one(pdata->ext_pullup_enable_pin,
109 GPIOF_INIT_LOW, "w1 pullup");
110 if (err < 0)
111 goto free_gpio;
112 }
113
62 master->data = pdata; 114 master->data = pdata;
63 master->read_bit = w1_gpio_read_bit; 115 master->read_bit = w1_gpio_read_bit;
64 116
@@ -72,15 +124,21 @@ static int __init w1_gpio_probe(struct platform_device *pdev)
72 124
73 err = w1_add_master_device(master); 125 err = w1_add_master_device(master);
74 if (err) 126 if (err)
75 goto free_gpio; 127 goto free_gpio_ext_pu;
76 128
77 if (pdata->enable_external_pullup) 129 if (pdata->enable_external_pullup)
78 pdata->enable_external_pullup(1); 130 pdata->enable_external_pullup(1);
79 131
132 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
133 gpio_set_value(pdata->ext_pullup_enable_pin, 1);
134
80 platform_set_drvdata(pdev, master); 135 platform_set_drvdata(pdev, master);
81 136
82 return 0; 137 return 0;
83 138
139 free_gpio_ext_pu:
140 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
141 gpio_free(pdata->ext_pullup_enable_pin);
84 free_gpio: 142 free_gpio:
85 gpio_free(pdata->pin); 143 gpio_free(pdata->pin);
86 free_master: 144 free_master:
@@ -97,6 +155,9 @@ static int __exit w1_gpio_remove(struct platform_device *pdev)
97 if (pdata->enable_external_pullup) 155 if (pdata->enable_external_pullup)
98 pdata->enable_external_pullup(0); 156 pdata->enable_external_pullup(0);
99 157
158 if (gpio_is_valid(pdata->ext_pullup_enable_pin))
159 gpio_set_value(pdata->ext_pullup_enable_pin, 0);
160
100 w1_remove_master_device(master); 161 w1_remove_master_device(master);
101 gpio_free(pdata->pin); 162 gpio_free(pdata->pin);
102 kfree(master); 163 kfree(master);
@@ -135,6 +196,7 @@ static struct platform_driver w1_gpio_driver = {
135 .driver = { 196 .driver = {
136 .name = "w1-gpio", 197 .name = "w1-gpio",
137 .owner = THIS_MODULE, 198 .owner = THIS_MODULE,
199 .of_match_table = of_match_ptr(w1_gpio_dt_ids),
138 }, 200 },
139 .remove = __exit_p(w1_gpio_remove), 201 .remove = __exit_p(w1_gpio_remove),
140 .suspend = w1_gpio_suspend, 202 .suspend = w1_gpio_suspend,