diff options
author | John Garry <john.garry@huawei.com> | 2015-11-17 11:50:32 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2015-11-25 22:12:52 -0500 |
commit | e26b2f405a6a65c0ce0ea168aef7d4607ec7ad80 (patch) | |
tree | bd2f713bccc9ed7b9da5d8477359a56b2b61b4c8 /drivers/scsi/hisi_sas | |
parent | 7eb7869f1307cc86fca9afd1425bba023c35414f (diff) |
hisi_sas: Scan device tree
Scan the device tree for all properties. Also do this:
- do ioremap for SAS registers
- allocate memory for interrupt names
Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/hisi_sas')
-rw-r--r-- | drivers/scsi/hisi_sas/hisi_sas.h | 10 | ||||
-rw-r--r-- | drivers/scsi/hisi_sas/hisi_sas_main.c | 45 |
2 files changed, 54 insertions, 1 deletions
diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 6f57fd16e937..87f4b61028eb 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h | |||
@@ -28,6 +28,8 @@ | |||
28 | #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES | 28 | #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES |
29 | #define HISI_SAS_COMMAND_ENTRIES 8192 | 29 | #define HISI_SAS_COMMAND_ENTRIES 8192 |
30 | 30 | ||
31 | #define HISI_SAS_NAME_LEN 32 | ||
32 | |||
31 | struct hisi_sas_phy { | 33 | struct hisi_sas_phy { |
32 | struct asd_sas_phy sas_phy; | 34 | struct asd_sas_phy sas_phy; |
33 | }; | 35 | }; |
@@ -44,6 +46,11 @@ struct hisi_hba { | |||
44 | struct sas_ha_struct *p; | 46 | struct sas_ha_struct *p; |
45 | 47 | ||
46 | struct platform_device *pdev; | 48 | struct platform_device *pdev; |
49 | void __iomem *regs; | ||
50 | struct regmap *ctrl; | ||
51 | u32 ctrl_reset_reg; | ||
52 | u32 ctrl_reset_sts_reg; | ||
53 | u32 ctrl_clock_ena_reg; | ||
47 | u8 sas_addr[SAS_ADDR_SIZE]; | 54 | u8 sas_addr[SAS_ADDR_SIZE]; |
48 | 55 | ||
49 | int n_phy; | 56 | int n_phy; |
@@ -53,6 +60,9 @@ struct hisi_hba { | |||
53 | struct Scsi_Host *shost; | 60 | struct Scsi_Host *shost; |
54 | struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; | 61 | struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; |
55 | struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; | 62 | struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; |
63 | |||
64 | int queue_count; | ||
65 | char *int_names; | ||
56 | const struct hisi_sas_hw *hw; /* Low level hw interface */ | 66 | const struct hisi_sas_hw *hw; /* Low level hw interface */ |
57 | }; | 67 | }; |
58 | 68 | ||
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 4fd000e565c2..4fc5a6c6d0ce 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c | |||
@@ -39,9 +39,13 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { | |||
39 | static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, | 39 | static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, |
40 | const struct hisi_sas_hw *hw) | 40 | const struct hisi_sas_hw *hw) |
41 | { | 41 | { |
42 | struct resource *res; | ||
42 | struct Scsi_Host *shost; | 43 | struct Scsi_Host *shost; |
43 | struct hisi_hba *hisi_hba; | 44 | struct hisi_hba *hisi_hba; |
44 | struct device *dev = &pdev->dev; | 45 | struct device *dev = &pdev->dev; |
46 | struct device_node *np = pdev->dev.of_node; | ||
47 | struct property *sas_addr_prop; | ||
48 | int num; | ||
45 | 49 | ||
46 | shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba)); | 50 | shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba)); |
47 | if (!shost) | 51 | if (!shost) |
@@ -53,6 +57,46 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, | |||
53 | hisi_hba->shost = shost; | 57 | hisi_hba->shost = shost; |
54 | SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; | 58 | SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; |
55 | 59 | ||
60 | sas_addr_prop = of_find_property(np, "sas-addr", NULL); | ||
61 | if (!sas_addr_prop || (sas_addr_prop->length != SAS_ADDR_SIZE)) | ||
62 | goto err_out; | ||
63 | memcpy(hisi_hba->sas_addr, sas_addr_prop->value, SAS_ADDR_SIZE); | ||
64 | |||
65 | if (of_property_read_u32(np, "ctrl-reset-reg", | ||
66 | &hisi_hba->ctrl_reset_reg)) | ||
67 | goto err_out; | ||
68 | |||
69 | if (of_property_read_u32(np, "ctrl-reset-sts-reg", | ||
70 | &hisi_hba->ctrl_reset_sts_reg)) | ||
71 | goto err_out; | ||
72 | |||
73 | if (of_property_read_u32(np, "ctrl-clock-ena-reg", | ||
74 | &hisi_hba->ctrl_clock_ena_reg)) | ||
75 | goto err_out; | ||
76 | |||
77 | if (of_property_read_u32(np, "phy-count", &hisi_hba->n_phy)) | ||
78 | goto err_out; | ||
79 | |||
80 | if (of_property_read_u32(np, "queue-count", &hisi_hba->queue_count)) | ||
81 | goto err_out; | ||
82 | |||
83 | num = of_irq_count(np); | ||
84 | hisi_hba->int_names = devm_kcalloc(dev, num, | ||
85 | HISI_SAS_NAME_LEN, | ||
86 | GFP_KERNEL); | ||
87 | if (!hisi_hba->int_names) | ||
88 | goto err_out; | ||
89 | |||
90 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
91 | hisi_hba->regs = devm_ioremap_resource(dev, res); | ||
92 | if (IS_ERR(hisi_hba->regs)) | ||
93 | goto err_out; | ||
94 | |||
95 | hisi_hba->ctrl = syscon_regmap_lookup_by_phandle( | ||
96 | np, "hisilicon,sas-syscon"); | ||
97 | if (IS_ERR(hisi_hba->ctrl)) | ||
98 | goto err_out; | ||
99 | |||
56 | return shost; | 100 | return shost; |
57 | err_out: | 101 | err_out: |
58 | dev_err(dev, "shost alloc failed\n"); | 102 | dev_err(dev, "shost alloc failed\n"); |
@@ -79,7 +123,6 @@ int hisi_sas_probe(struct platform_device *pdev, | |||
79 | sha = SHOST_TO_SAS_HA(shost); | 123 | sha = SHOST_TO_SAS_HA(shost); |
80 | hisi_hba = shost_priv(shost); | 124 | hisi_hba = shost_priv(shost); |
81 | platform_set_drvdata(pdev, sha); | 125 | platform_set_drvdata(pdev, sha); |
82 | hisi_hba->n_phy = HISI_SAS_MAX_PHYS; | ||
83 | phy_nr = port_nr = hisi_hba->n_phy; | 126 | phy_nr = port_nr = hisi_hba->n_phy; |
84 | 127 | ||
85 | arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL); | 128 | arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL); |