scsi: hisi_sas: create hisi_sas_get_fw_info()
Move the functionality to retrieve the fw info into a dedicated device type-agnostic function, hisi_sas_get_fw_info(). The reasoning is that this function will be required for future pci-based platforms. Also add some debug logs for failure. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Родитель
11b752490a
Коммит
0fa24c19d8
|
@ -371,6 +371,7 @@ extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
|
||||||
extern void hisi_sas_sata_done(struct sas_task *task,
|
extern void hisi_sas_sata_done(struct sas_task *task,
|
||||||
struct hisi_sas_slot *slot);
|
struct hisi_sas_slot *slot);
|
||||||
extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag);
|
extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag);
|
||||||
|
extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba);
|
||||||
extern int hisi_sas_probe(struct platform_device *pdev,
|
extern int hisi_sas_probe(struct platform_device *pdev,
|
||||||
const struct hisi_sas_hw *ops);
|
const struct hisi_sas_hw *ops);
|
||||||
extern int hisi_sas_remove(struct platform_device *pdev);
|
extern int hisi_sas_remove(struct platform_device *pdev);
|
||||||
|
|
|
@ -1729,6 +1729,74 @@ static void hisi_sas_rst_work_handler(struct work_struct *work)
|
||||||
hisi_sas_controller_reset(hisi_hba);
|
hisi_sas_controller_reset(hisi_hba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba)
|
||||||
|
{
|
||||||
|
struct device *dev = hisi_hba->dev;
|
||||||
|
struct platform_device *pdev = hisi_hba->platform_dev;
|
||||||
|
struct device_node *np = pdev ? pdev->dev.of_node : NULL;
|
||||||
|
struct clk *refclk;
|
||||||
|
|
||||||
|
if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr,
|
||||||
|
SAS_ADDR_SIZE)) {
|
||||||
|
dev_err(dev, "could not get property sas-addr\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (np) {
|
||||||
|
/*
|
||||||
|
* These properties are only required for platform device-based
|
||||||
|
* controller with DT firmware.
|
||||||
|
*/
|
||||||
|
hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np,
|
||||||
|
"hisilicon,sas-syscon");
|
||||||
|
if (IS_ERR(hisi_hba->ctrl)) {
|
||||||
|
dev_err(dev, "could not get syscon\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device_property_read_u32(dev, "ctrl-reset-reg",
|
||||||
|
&hisi_hba->ctrl_reset_reg)) {
|
||||||
|
dev_err(dev,
|
||||||
|
"could not get property ctrl-reset-reg\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device_property_read_u32(dev, "ctrl-reset-sts-reg",
|
||||||
|
&hisi_hba->ctrl_reset_sts_reg)) {
|
||||||
|
dev_err(dev,
|
||||||
|
"could not get property ctrl-reset-sts-reg\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device_property_read_u32(dev, "ctrl-clock-ena-reg",
|
||||||
|
&hisi_hba->ctrl_clock_ena_reg)) {
|
||||||
|
dev_err(dev,
|
||||||
|
"could not get property ctrl-clock-ena-reg\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
refclk = devm_clk_get(dev, NULL);
|
||||||
|
if (IS_ERR(refclk))
|
||||||
|
dev_dbg(dev, "no ref clk property\n");
|
||||||
|
else
|
||||||
|
hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 1000000;
|
||||||
|
|
||||||
|
if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy)) {
|
||||||
|
dev_err(dev, "could not get property phy-count\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device_property_read_u32(dev, "queue-count",
|
||||||
|
&hisi_hba->queue_count)) {
|
||||||
|
dev_err(dev, "could not get property queue-count\n");
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(hisi_sas_get_fw_info);
|
||||||
|
|
||||||
static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
|
static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
|
||||||
const struct hisi_sas_hw *hw)
|
const struct hisi_sas_hw *hw)
|
||||||
{
|
{
|
||||||
|
@ -1736,8 +1804,6 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
|
||||||
struct Scsi_Host *shost;
|
struct Scsi_Host *shost;
|
||||||
struct hisi_hba *hisi_hba;
|
struct hisi_hba *hisi_hba;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
|
||||||
struct clk *refclk;
|
|
||||||
|
|
||||||
shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
|
shost = scsi_host_alloc(&hisi_sas_sht, sizeof(*hisi_hba));
|
||||||
if (!shost) {
|
if (!shost) {
|
||||||
|
@ -1748,47 +1814,14 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
|
||||||
|
|
||||||
INIT_WORK(&hisi_hba->rst_work, hisi_sas_rst_work_handler);
|
INIT_WORK(&hisi_hba->rst_work, hisi_sas_rst_work_handler);
|
||||||
hisi_hba->hw = hw;
|
hisi_hba->hw = hw;
|
||||||
hisi_hba->platform_dev = pdev;
|
|
||||||
hisi_hba->dev = dev;
|
hisi_hba->dev = dev;
|
||||||
|
hisi_hba->platform_dev = pdev;
|
||||||
hisi_hba->shost = shost;
|
hisi_hba->shost = shost;
|
||||||
SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
|
SHOST_TO_SAS_HA(shost) = &hisi_hba->sha;
|
||||||
|
|
||||||
init_timer(&hisi_hba->timer);
|
init_timer(&hisi_hba->timer);
|
||||||
|
|
||||||
if (device_property_read_u8_array(dev, "sas-addr", hisi_hba->sas_addr,
|
if (hisi_sas_get_fw_info(hisi_hba) < 0)
|
||||||
SAS_ADDR_SIZE))
|
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
if (np) {
|
|
||||||
hisi_hba->ctrl = syscon_regmap_lookup_by_phandle(np,
|
|
||||||
"hisilicon,sas-syscon");
|
|
||||||
if (IS_ERR(hisi_hba->ctrl))
|
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
if (device_property_read_u32(dev, "ctrl-reset-reg",
|
|
||||||
&hisi_hba->ctrl_reset_reg))
|
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
if (device_property_read_u32(dev, "ctrl-reset-sts-reg",
|
|
||||||
&hisi_hba->ctrl_reset_sts_reg))
|
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
if (device_property_read_u32(dev, "ctrl-clock-ena-reg",
|
|
||||||
&hisi_hba->ctrl_clock_ena_reg))
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
refclk = devm_clk_get(&pdev->dev, NULL);
|
|
||||||
if (IS_ERR(refclk))
|
|
||||||
dev_dbg(dev, "no ref clk property\n");
|
|
||||||
else
|
|
||||||
hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 1000000;
|
|
||||||
|
|
||||||
if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy))
|
|
||||||
goto err_out;
|
|
||||||
|
|
||||||
if (device_property_read_u32(dev, "queue-count",
|
|
||||||
&hisi_hba->queue_count))
|
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
|
if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
|
||||||
|
|
Загрузка…
Ссылка в новой задаче