2 * OF-platform PATA driver
4 * Copyright (c) 2007 MontaVista Software, Inc.
5 * Anton Vorontsov <avorontsov@ru.mvista.com>
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.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/of_platform.h>
15 #include <linux/pata_platform.h>
17 static int __devinit
pata_of_platform_probe(struct of_device
*ofdev
,
18 const struct of_device_id
*match
)
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;
30 ret
= of_address_to_resource(dn
, 0, &io_res
);
32 dev_err(&ofdev
->dev
, "can't get IO address from "
37 ret
= of_address_to_resource(dn
, 1, &ctl_res
);
39 dev_err(&ofdev
->dev
, "can't get CTL address from "
44 ret
= of_irq_to_resource(dn
, 0, &irq_res
);
46 irq_res
.start
= irq_res
.end
= -1;
50 prop
= of_get_property(dn
, "reg-shift", NULL
);
54 prop
= of_get_property(dn
, "pio-mode", NULL
);
58 dev_err(&ofdev
->dev
, "invalid pio-mode\n");
62 dev_info(&ofdev
->dev
, "pio-mode unspecified, assuming PIO0\n");
65 pio_mask
= 1 << pio_mode
;
66 pio_mask
|= (1 << pio_mode
) - 1;
68 return __pata_platform_probe(&ofdev
->dev
, &io_res
, &ctl_res
, &irq_res
,
72 static int __devexit
pata_of_platform_remove(struct of_device
*ofdev
)
74 return __pata_platform_remove(&ofdev
->dev
);
77 static struct of_device_id pata_of_platform_match
[] = {
78 { .compatible
= "ata-generic", },
81 MODULE_DEVICE_TABLE(of
, pata_of_platform_match
);
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
),
90 static int __init
pata_of_platform_init(void)
92 return of_register_platform_driver(&pata_of_platform_driver
);
94 module_init(pata_of_platform_init
);
96 static void __exit
pata_of_platform_exit(void)
98 of_unregister_platform_driver(&pata_of_platform_driver
);
100 module_exit(pata_of_platform_exit
);
102 MODULE_DESCRIPTION("OF-platform PATA driver");
103 MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
104 MODULE_LICENSE("GPL");