diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2008-01-09 14:10:41 -0500 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2008-01-15 11:23:43 -0500 |
commit | 61f7162117d4767875825abf2f6ed1eeebbcceed (patch) | |
tree | 93ce729c0c499e45f7fb0adf805e6399bea9e404 /drivers | |
parent | cf03613e9662c28372b8c83538fb402df37c53f5 (diff) |
libata: pata_of_platform: OF-Platform PATA device driver
This driver nicely wraps around pata_platform library functions,
and provides OF platform bus bindings to the PATA devices.
Also add || PPC to the PATA_PLATFORM's "depends on" Kconfig entry,
needed for PA Semi Electra.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/Kconfig | 12 | ||||
-rw-r--r-- | drivers/ata/Makefile | 1 | ||||
-rw-r--r-- | drivers/ata/pata_of_platform.c | 104 |
3 files changed, 116 insertions, 1 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index ba63619ae5df..64b4964d57e7 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -607,13 +607,23 @@ config PATA_WINBOND_VLB | |||
607 | 607 | ||
608 | config PATA_PLATFORM | 608 | config PATA_PLATFORM |
609 | tristate "Generic platform device PATA support" | 609 | tristate "Generic platform device PATA support" |
610 | depends on EMBEDDED || ARCH_RPC | 610 | depends on EMBEDDED || ARCH_RPC || PPC |
611 | help | 611 | help |
612 | This option enables support for generic directly connected ATA | 612 | This option enables support for generic directly connected ATA |
613 | devices commonly found on embedded systems. | 613 | devices commonly found on embedded systems. |
614 | 614 | ||
615 | If unsure, say N. | 615 | If unsure, say N. |
616 | 616 | ||
617 | config PATA_OF_PLATFORM | ||
618 | tristate "OpenFirmware platform device PATA support" | ||
619 | depends on PATA_PLATFORM && PPC_OF | ||
620 | help | ||
621 | This option enables support for generic directly connected ATA | ||
622 | devices commonly found on embedded systems with OpenFirmware | ||
623 | bindings. | ||
624 | |||
625 | If unsure, say N. | ||
626 | |||
617 | config PATA_ICSIDE | 627 | config PATA_ICSIDE |
618 | tristate "Acorn ICS PATA support" | 628 | tristate "Acorn ICS PATA support" |
619 | depends on ARM && ARCH_ACORN | 629 | depends on ARM && ARCH_ACORN |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index b13feb2c5dae..ebcee64dd5e2 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o | |||
67 | obj-$(CONFIG_PATA_SCC) += pata_scc.o | 67 | obj-$(CONFIG_PATA_SCC) += pata_scc.o |
68 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o | 68 | obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o |
69 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o | 69 | obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o |
70 | obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o | ||
70 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o | 71 | obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o |
71 | # Should be last but two libata driver | 72 | # Should be last but two libata driver |
72 | obj-$(CONFIG_PATA_ACPI) += pata_acpi.o | 73 | obj-$(CONFIG_PATA_ACPI) += pata_acpi.o |
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c new file mode 100644 index 000000000000..b7bc4e4a0a26 --- /dev/null +++ b/drivers/ata/pata_of_platform.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * OF-platform PATA driver | ||
3 | * | ||
4 | * Copyright (c) 2007 MontaVista Software, Inc. | ||
5 | * Anton Vorontsov <avorontsov@ru.mvista.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License (Version 2) as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/of_platform.h> | ||
15 | #include <linux/pata_platform.h> | ||
16 | |||
17 | static int __devinit pata_of_platform_probe(struct of_device *ofdev, | ||
18 | const struct of_device_id *match) | ||
19 | { | ||
20 | int ret; | ||
21 | struct device_node *dn = ofdev->node; | ||
22 | struct resource io_res; | ||
23 | struct resource ctl_res; | ||
24 | struct resource irq_res; | ||
25 | unsigned int reg_shift = 0; | ||
26 | int pio_mode = 0; | ||
27 | int pio_mask; | ||
28 | const u32 *prop; | ||
29 | |||
30 | ret = of_address_to_resource(dn, 0, &io_res); | ||
31 | if (ret) { | ||
32 | dev_err(&ofdev->dev, "can't get IO address from " | ||
33 | "device tree\n"); | ||
34 | return -EINVAL; | ||
35 | } | ||
36 | |||
37 | ret = of_address_to_resource(dn, 1, &ctl_res); | ||
38 | if (ret) { | ||
39 | dev_err(&ofdev->dev, "can't get CTL address from " | ||
40 | "device tree\n"); | ||
41 | return -EINVAL; | ||
42 | } | ||
43 | |||
44 | ret = of_irq_to_resource(dn, 0, &irq_res); | ||
45 | if (ret == NO_IRQ) | ||
46 | irq_res.start = irq_res.end = -1; | ||
47 | else | ||
48 | irq_res.flags = 0; | ||
49 | |||
50 | prop = of_get_property(dn, "reg-shift", NULL); | ||
51 | if (prop) | ||
52 | reg_shift = *prop; | ||
53 | |||
54 | prop = of_get_property(dn, "pio-mode", NULL); | ||
55 | if (prop) { | ||
56 | pio_mode = *prop; | ||
57 | if (pio_mode > 6) { | ||
58 | dev_err(&ofdev->dev, "invalid pio-mode\n"); | ||
59 | return -EINVAL; | ||
60 | } | ||
61 | } else { | ||
62 | dev_info(&ofdev->dev, "pio-mode unspecified, assuming PIO0\n"); | ||
63 | } | ||
64 | |||
65 | pio_mask = 1 << pio_mode; | ||
66 | pio_mask |= (1 << pio_mode) - 1; | ||
67 | |||
68 | return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, &irq_res, | ||
69 | reg_shift, pio_mask); | ||
70 | } | ||
71 | |||
72 | static int __devexit pata_of_platform_remove(struct of_device *ofdev) | ||
73 | { | ||
74 | return __pata_platform_remove(&ofdev->dev); | ||
75 | } | ||
76 | |||
77 | static struct of_device_id pata_of_platform_match[] = { | ||
78 | { .compatible = "ata-generic", }, | ||
79 | {}, | ||
80 | }; | ||
81 | MODULE_DEVICE_TABLE(of, pata_of_platform_match); | ||
82 | |||
83 | static struct of_platform_driver pata_of_platform_driver = { | ||
84 | .name = "pata_of_platform", | ||
85 | .match_table = pata_of_platform_match, | ||
86 | .probe = pata_of_platform_probe, | ||
87 | .remove = __devexit_p(pata_of_platform_remove), | ||
88 | }; | ||
89 | |||
90 | static int __init pata_of_platform_init(void) | ||
91 | { | ||
92 | return of_register_platform_driver(&pata_of_platform_driver); | ||
93 | } | ||
94 | module_init(pata_of_platform_init); | ||
95 | |||
96 | static void __exit pata_of_platform_exit(void) | ||
97 | { | ||
98 | of_unregister_platform_driver(&pata_of_platform_driver); | ||
99 | } | ||
100 | module_exit(pata_of_platform_exit); | ||
101 | |||
102 | MODULE_DESCRIPTION("OF-platform PATA driver"); | ||
103 | MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>"); | ||
104 | MODULE_LICENSE("GPL"); | ||