提交 70866373 编写于 作者: J Jay Fang 提交者: Xie XiuQi

spi: add ACPI support for SPI controller chip select lines(cs-gpios)

euler inclusion
category: feature (SPI ACPI for Hi1620)
bugzilla: 5443
CVE: NA

TPM chip on D06 is SPI based, so we need to add SPI ACPI support
for Hi1620.

Two patches already merged for 4.21, but the core support for spi
has another patchset needs lots of refactor, so just use the patch
from Fang Jian to enable this feature on 4.19

[PATCH 1/4] spi: dw-mmio: add ACPI support
[PATCH 2/4] ACPI / APD: Add clock frequency for Hisilicon Hip08 SPI controller
[PATCH 3/4] spi: add ACPI support for SPI controller chip select lines(cs-gpios)
[PATCH 4/4] hulk_defconfig: ensble SPI designware driver for Hi1620
-----------------------------------------

This will also allow to use cs-gpios for chip select in ACPI code
with no modification in the driver binding, like it be used in DT.
We could share almost all of the code with the DT path.
Signed-off-by: NJay Fang <f.fangjian@huawei.com>
Signed-off-by: NHanjun Guo <guohanjun@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 94cd2f7b
...@@ -2031,16 +2031,13 @@ struct spi_controller *__spi_alloc_controller(struct device *dev, ...@@ -2031,16 +2031,13 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
} }
EXPORT_SYMBOL_GPL(__spi_alloc_controller); EXPORT_SYMBOL_GPL(__spi_alloc_controller);
#ifdef CONFIG_OF static int __spi_register_controller(struct spi_controller *ctlr)
static int of_spi_register_master(struct spi_controller *ctlr)
{ {
int nb, i, *cs; int nb, i, *cs;
struct device_node *np = ctlr->dev.of_node; struct device_node *np = ctlr->dev.of_node;
struct gpio_desc *desc;
if (!np) nb = gpiod_count(&ctlr->dev, "cs");
return 0;
nb = of_gpio_named_count(np, "cs-gpios");
ctlr->num_chipselect = max_t(int, nb, ctlr->num_chipselect); ctlr->num_chipselect = max_t(int, nb, ctlr->num_chipselect);
/* Return error only for an incorrectly formed cs-gpios property */ /* Return error only for an incorrectly formed cs-gpios property */
...@@ -2059,17 +2056,20 @@ static int of_spi_register_master(struct spi_controller *ctlr) ...@@ -2059,17 +2056,20 @@ static int of_spi_register_master(struct spi_controller *ctlr)
for (i = 0; i < ctlr->num_chipselect; i++) for (i = 0; i < ctlr->num_chipselect; i++)
cs[i] = -ENOENT; cs[i] = -ENOENT;
if (IS_ENABLED(CONFIG_OF) && np) {
for (i = 0; i < nb; i++) for (i = 0; i < nb; i++)
cs[i] = of_get_named_gpio(np, "cs-gpios", i); cs[i] = of_get_named_gpio(np, "cs-gpios", i);
} else if (IS_ENABLED(CONFIG_ACPI) && ACPI_HANDLE(&ctlr->dev)) {
return 0; for (i = 0; i < nb; i++) {
} desc = devm_gpiod_get_index(&ctlr->dev, "cs",
#else i, GPIOD_ASIS);
static int of_spi_register_master(struct spi_controller *ctlr) if (IS_ERR(desc))
{ continue;
cs[i] = desc_to_gpio(desc);
}
}
return 0; return 0;
} }
#endif
static int spi_controller_check_ops(struct spi_controller *ctlr) static int spi_controller_check_ops(struct spi_controller *ctlr)
{ {
...@@ -2133,7 +2133,7 @@ int spi_register_controller(struct spi_controller *ctlr) ...@@ -2133,7 +2133,7 @@ int spi_register_controller(struct spi_controller *ctlr)
return status; return status;
if (!spi_controller_is_slave(ctlr)) { if (!spi_controller_is_slave(ctlr)) {
status = of_spi_register_master(ctlr); status = __spi_register_controller(ctlr);
if (status) if (status)
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册