
From: Ding Tianhong <dingtianhong@huawei.com> ascend inclusion category: feature bugzilla: NA CVE: NA ------------------------------------------------- The spi-cpld device is used for ascend610 evb platform and would be initialized by default value at probe time. Signed-off-by: Ding Tianhong <dingtianhong@huawei.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/spi/spidev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index e444e7cc6968..3eb57f6de607 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -672,11 +672,34 @@ static const struct file_operations spidev_fops = { static struct class *spidev_class; #ifdef CONFIG_OF + +static void spi_cpld_init(struct spi_device *spi) +{ + int ret; + unsigned int chip_select, mode; + + ret = of_property_read_u32(spi->dev.of_node, "reg", &(chip_select)); + if (ret != 0) + dev_warn(&spi->dev, "of_property_read_u8 get chip_select fail\n"); + + spi->chip_select = (u8)(chip_select); + ret = of_property_read_u32(spi->dev.of_node, "mode", &(mode)); + if (ret != 0) + dev_warn(&spi->dev, "of_property_read_u16 get num-cs fail\n"); + + spi->mode = (u16)(mode); + ret = of_property_read_u32(spi->dev.of_node, "spi-max-frequency", + &(spi->max_speed_hz)); + if (ret != 0) + dev_warn(&spi->dev, "of_property_read_u32 get spi-max-frequency fail\n"); +} + static const struct of_device_id spidev_dt_ids[] = { { .compatible = "rohm,dh2228fv" }, { .compatible = "lineartechnology,ltc2488" }, { .compatible = "ge,achc" }, { .compatible = "semtech,sx1301" }, + { .compatible = "spi-cpld", .data = spi_cpld_init, }, {}, }; MODULE_DEVICE_TABLE(of, spidev_dt_ids); @@ -727,6 +750,8 @@ static int spidev_probe(struct spi_device *spi) int status; unsigned long minor; + void (*spi_init)(struct spi_device *dev); + /* * spidev should never be referenced in DT without a specific * compatible string, it is a Linux implementation thing @@ -738,6 +763,10 @@ static int spidev_probe(struct spi_device *spi) spidev_probe_acpi(spi); + spi_init = of_device_get_match_data(&spi->dev); + if (spi_init) + spi_init(spi); + /* Allocate driver data */ spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); if (!spidev) -- 2.25.1