From patchwork Tue Nov 17 16:50:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 56834 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2052143lbb; Tue, 17 Nov 2015 08:49:08 -0800 (PST) X-Received: by 10.68.220.3 with SMTP id ps3mr5693269pbc.153.1447778948071; Tue, 17 Nov 2015 08:49:08 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ml1si45853528pab.189.2015.11.17.08.49.07; Tue, 17 Nov 2015 08:49:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932321AbbKQQss (ORCPT + 28 others); Tue, 17 Nov 2015 11:48:48 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:37301 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754176AbbKQQgo (ORCPT ); Tue, 17 Nov 2015 11:36:44 -0500 Received: from 172.24.1.49 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.49]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CZG01751; Wed, 18 Nov 2015 00:36:37 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Wed, 18 Nov 2015 00:36:21 +0800 From: John Garry To: , , , , , , CC: , , , , , , , , Subject: [PATCH v5 05/32] scsi: hisi_sas: scan device tree Date: Wed, 18 Nov 2015 00:50:32 +0800 Message-ID: <1447779059-136143-6-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447779059-136143-1-git-send-email-john.garry@huawei.com> References: <1447779059-136143-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.564B5795.0219, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 701c56f38c9c5e399c5f1fcba7601e45 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/scsi/hisi_sas/hisi_sas.h | 10 ++++++++ drivers/scsi/hisi_sas/hisi_sas_main.c | 45 ++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 6f57fd1..87f4b61 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -28,6 +28,8 @@ #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES #define HISI_SAS_COMMAND_ENTRIES 8192 +#define HISI_SAS_NAME_LEN 32 + struct hisi_sas_phy { struct asd_sas_phy sas_phy; }; @@ -44,6 +46,11 @@ struct hisi_hba { struct sas_ha_struct *p; struct platform_device *pdev; + void __iomem *regs; + struct regmap *ctrl; + u32 ctrl_reset_reg; + u32 ctrl_reset_sts_reg; + u32 ctrl_clock_ena_reg; u8 sas_addr[SAS_ADDR_SIZE]; int n_phy; @@ -53,6 +60,9 @@ struct hisi_hba { struct Scsi_Host *shost; struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; + + int queue_count; + char *int_names; const struct hisi_sas_hw *hw; /* Low level hw interface */ }; diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 4fd000e..4fc5a6c 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 = { static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, const struct hisi_sas_hw *hw) { + struct resource *res; struct Scsi_Host *shost; struct hisi_hba *hisi_hba; struct device *dev = &pdev->dev; + struct device_node *np = pdev->dev.of_node; + struct property *sas_addr_prop; + int num; shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba)); if (!shost) @@ -53,6 +57,46 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev, hisi_hba->shost = shost; SHOST_TO_SAS_HA(shost) = &hisi_hba->sha; + sas_addr_prop = of_find_property(np, "sas-addr", NULL); + if (!sas_addr_prop || (sas_addr_prop->length != SAS_ADDR_SIZE)) + goto err_out; + memcpy(hisi_hba->sas_addr, sas_addr_prop->value, SAS_ADDR_SIZE); + + if (of_property_read_u32(np, "ctrl-reset-reg", + &hisi_hba->ctrl_reset_reg)) + goto err_out; + + if (of_property_read_u32(np, "ctrl-reset-sts-reg", + &hisi_hba->ctrl_reset_sts_reg)) + goto err_out; + + if (of_property_read_u32(np, "ctrl-clock-ena-reg", + &hisi_hba->ctrl_clock_ena_reg)) + goto err_out; + + if (of_property_read_u32(np, "phy-count", &hisi_hba->n_phy)) + goto err_out; + + if (of_property_read_u32(np, "queue-count", &hisi_hba->queue_count)) + goto err_out; + + num = of_irq_count(np); + hisi_hba->int_names = devm_kcalloc(dev, num, + HISI_SAS_NAME_LEN, + GFP_KERNEL); + if (!hisi_hba->int_names) + goto err_out; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + hisi_hba->regs = devm_ioremap_resource(dev, res); + if (IS_ERR(hisi_hba->regs)) + goto err_out; + + hisi_hba->ctrl = syscon_regmap_lookup_by_phandle( + np, "hisilicon,sas-syscon"); + if (IS_ERR(hisi_hba->ctrl)) + goto err_out; + return shost; err_out: dev_err(dev, "shost alloc failed\n"); @@ -79,7 +123,6 @@ int hisi_sas_probe(struct platform_device *pdev, sha = SHOST_TO_SAS_HA(shost); hisi_hba = shost_priv(shost); platform_set_drvdata(pdev, sha); - hisi_hba->n_phy = HISI_SAS_MAX_PHYS; phy_nr = port_nr = hisi_hba->n_phy; arr_phy = devm_kcalloc(dev, phy_nr, sizeof(void *), GFP_KERNEL);