diff options
author | Andrew Lunn <andrew@lunn.ch> | 2012-06-10 10:45:37 -0400 |
---|---|---|
committer | Andrew Lunn <andrew@lunn.ch> | 2012-07-27 10:48:45 -0400 |
commit | 97b414e119ccc7216e29c3bd62fe1a1797f21404 (patch) | |
tree | 3e2104f4e1ce2b8ae7451084d8ca6e0c2c463e27 | |
parent | 1e7bad0f5b91150fef78d732095ca84ca4a16585 (diff) |
ATA: sata_mv: Add device tree support
Add support for instantiating this driver from device tree, and add
the necassary DT information to the kirkwood.dtsi file.
This is based on previous work by Michael Walle and Jason Cooper.
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Josh Coombs <josh.coombs@gmail.com>
-rw-r--r-- | Documentation/devicetree/bindings/ata/marvell.txt | 16 | ||||
-rw-r--r-- | arch/arm/boot/dts/kirkwood.dtsi | 7 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/board-dt.c | 1 | ||||
-rw-r--r-- | drivers/ata/sata_mv.c | 42 |
4 files changed, 53 insertions, 13 deletions
diff --git a/Documentation/devicetree/bindings/ata/marvell.txt b/Documentation/devicetree/bindings/ata/marvell.txt new file mode 100644 index 000000000000..b5cdd20cde9c --- /dev/null +++ b/Documentation/devicetree/bindings/ata/marvell.txt | |||
@@ -0,0 +1,16 @@ | |||
1 | * Marvell Orion SATA | ||
2 | |||
3 | Required Properties: | ||
4 | - compatibility : "marvell,orion-sata" | ||
5 | - reg : Address range of controller | ||
6 | - interrupts : Interrupt controller is using | ||
7 | - nr-ports : Number of SATA ports in use. | ||
8 | |||
9 | Example: | ||
10 | |||
11 | sata@80000 { | ||
12 | compatible = "marvell,orion-sata"; | ||
13 | reg = <0x80000 0x5000>; | ||
14 | interrupts = <21>; | ||
15 | nr-ports = <2>; | ||
16 | } | ||
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi index 458d137d0951..cef9616f330a 100644 --- a/arch/arm/boot/dts/kirkwood.dtsi +++ b/arch/arm/boot/dts/kirkwood.dtsi | |||
@@ -76,6 +76,13 @@ | |||
76 | status = "okay"; | 76 | status = "okay"; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | sata@80000 { | ||
80 | compatible = "marvell,orion-sata"; | ||
81 | reg = <0x80000 0x5000>; | ||
82 | interrupts = <21>; | ||
83 | status = "disabled"; | ||
84 | }; | ||
85 | |||
79 | nand@3000000 { | 86 | nand@3000000 { |
80 | #address-cells = <1>; | 87 | #address-cells = <1>; |
81 | #size-cells = <1>; | 88 | #size-cells = <1>; |
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index aa229fc1cdc4..8c67c222a0c1 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c | |||
@@ -31,6 +31,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = { | |||
31 | OF_DEV_AUXDATA("marvell,mv64xxx-i2c", 0xf1011000, "mv64xxx_i2c.0", | 31 | OF_DEV_AUXDATA("marvell,mv64xxx-i2c", 0xf1011000, "mv64xxx_i2c.0", |
32 | NULL), | 32 | NULL), |
33 | OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL), | 33 | OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL), |
34 | OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL), | ||
34 | {}, | 35 | {}, |
35 | }; | 36 | }; |
36 | 37 | ||
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 24712adf69df..311be18d3f03 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -65,6 +65,8 @@ | |||
65 | #include <linux/mbus.h> | 65 | #include <linux/mbus.h> |
66 | #include <linux/bitops.h> | 66 | #include <linux/bitops.h> |
67 | #include <linux/gfp.h> | 67 | #include <linux/gfp.h> |
68 | #include <linux/of.h> | ||
69 | #include <linux/of_irq.h> | ||
68 | #include <scsi/scsi_host.h> | 70 | #include <scsi/scsi_host.h> |
69 | #include <scsi/scsi_cmnd.h> | 71 | #include <scsi/scsi_cmnd.h> |
70 | #include <scsi/scsi_device.h> | 72 | #include <scsi/scsi_device.h> |
@@ -4026,7 +4028,7 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4026 | struct ata_host *host; | 4028 | struct ata_host *host; |
4027 | struct mv_host_priv *hpriv; | 4029 | struct mv_host_priv *hpriv; |
4028 | struct resource *res; | 4030 | struct resource *res; |
4029 | int n_ports = 0; | 4031 | int n_ports = 0, irq = 0; |
4030 | int rc; | 4032 | int rc; |
4031 | #if defined(CONFIG_HAVE_CLK) | 4033 | #if defined(CONFIG_HAVE_CLK) |
4032 | int port; | 4034 | int port; |
@@ -4050,8 +4052,14 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4050 | return -EINVAL; | 4052 | return -EINVAL; |
4051 | 4053 | ||
4052 | /* allocate host */ | 4054 | /* allocate host */ |
4053 | mv_platform_data = pdev->dev.platform_data; | 4055 | if (pdev->dev.of_node) { |
4054 | n_ports = mv_platform_data->n_ports; | 4056 | of_property_read_u32(pdev->dev.of_node, "nr-ports", &n_ports); |
4057 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
4058 | } else { | ||
4059 | mv_platform_data = pdev->dev.platform_data; | ||
4060 | n_ports = mv_platform_data->n_ports; | ||
4061 | irq = platform_get_irq(pdev, 0); | ||
4062 | } | ||
4055 | 4063 | ||
4056 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); | 4064 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); |
4057 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | 4065 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
@@ -4109,8 +4117,7 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
4109 | dev_info(&pdev->dev, "slots %u ports %d\n", | 4117 | dev_info(&pdev->dev, "slots %u ports %d\n", |
4110 | (unsigned)MV_MAX_Q_DEPTH, host->n_ports); | 4118 | (unsigned)MV_MAX_Q_DEPTH, host->n_ports); |
4111 | 4119 | ||
4112 | rc = ata_host_activate(host, platform_get_irq(pdev, 0), mv_interrupt, | 4120 | rc = ata_host_activate(host, irq, mv_interrupt, IRQF_SHARED, &mv6_sht); |
4113 | IRQF_SHARED, &mv6_sht); | ||
4114 | if (!rc) | 4121 | if (!rc) |
4115 | return 0; | 4122 | return 0; |
4116 | 4123 | ||
@@ -4205,15 +4212,24 @@ static int mv_platform_resume(struct platform_device *pdev) | |||
4205 | #define mv_platform_resume NULL | 4212 | #define mv_platform_resume NULL |
4206 | #endif | 4213 | #endif |
4207 | 4214 | ||
4215 | #ifdef CONFIG_OF | ||
4216 | static struct of_device_id mv_sata_dt_ids[] __devinitdata = { | ||
4217 | { .compatible = "marvell,orion-sata", }, | ||
4218 | {}, | ||
4219 | }; | ||
4220 | MODULE_DEVICE_TABLE(of, mv_sata_dt_ids); | ||
4221 | #endif | ||
4222 | |||
4208 | static struct platform_driver mv_platform_driver = { | 4223 | static struct platform_driver mv_platform_driver = { |
4209 | .probe = mv_platform_probe, | 4224 | .probe = mv_platform_probe, |
4210 | .remove = __devexit_p(mv_platform_remove), | 4225 | .remove = __devexit_p(mv_platform_remove), |
4211 | .suspend = mv_platform_suspend, | 4226 | .suspend = mv_platform_suspend, |
4212 | .resume = mv_platform_resume, | 4227 | .resume = mv_platform_resume, |
4213 | .driver = { | 4228 | .driver = { |
4214 | .name = DRV_NAME, | 4229 | .name = DRV_NAME, |
4215 | .owner = THIS_MODULE, | 4230 | .owner = THIS_MODULE, |
4216 | }, | 4231 | .of_match_table = of_match_ptr(mv_sata_dt_ids), |
4232 | }, | ||
4217 | }; | 4233 | }; |
4218 | 4234 | ||
4219 | 4235 | ||