[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <d7502989-dbfd-40d8-8a4e-8e194eefb523@amlogic.com>
Date: Tue, 24 Jun 2025 17:52:44 +0800
From: Xianwei Zhao <xianwei.zhao@...ogic.com>
To: Krzysztof Kozlowski <krzk@...nel.org>, Sunny Luo <sunny.luo@...ogic.com>,
Mark Brown <broonie@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>
Cc: linux-amlogic@...ts.infradead.org, linux-spi@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/3] spi: Add Amlogic SPISG driver
Hi Krzysztof,
Thanks for your reply.
On 2025/6/23 17:17, Krzysztof Kozlowski wrote:
> [ EXTERNAL EMAIL ]
>
> On 23/06/2025 10:53, Xianwei Zhao via B4 Relay wrote:
>> From: Sunny Luo <sunny.luo@...ogic.com>
>>
>> Introduced support for the new SPI IP (SPISG) driver. The SPISG is
>> a communication-oriented SPI controller from Amlogic,supporting
>> three operation modes: PIO, block DMA, and scatter-gather DMA.
>>
>> Signed-off-by: Sunny Luo <sunny.luo@...ogic.com>
>> Signed-off-by: Xianwei Zhao <xianwei.zhao@...ogic.com>
>> ---
>> drivers/spi/Kconfig | 9 +
>> drivers/spi/Makefile | 1 +
>> drivers/spi/spi-amlogic-spisg.c | 876 ++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 886 insertions(+)
>>
>> diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
>> index c51da3fc3604..e11341df2ecf 100644
>> --- a/drivers/spi/Kconfig
>> +++ b/drivers/spi/Kconfig
>> @@ -99,6 +99,15 @@ config SPI_AMLOGIC_SPIFC_A1
>> This enables master mode support for the SPIFC (SPI flash
>> controller) available in Amlogic A1 (A113L SoC).
>>
>> +config SPI_AMLOGIC_SPISG
>> + tristate "Amlogic SPISG controller"
>> + depends on COMMON_CLK
>> + depends on ARCH_MESON || COMPILE_TEST
>> + help
>> + This enables master mode support for the SPISG (SPI scatter-gather
>> + communication controller), which is available on platforms such as
>> + Amlogic A4 SoCs.
>> +
>> config SPI_APPLE
>> tristate "Apple SoC SPI Controller platform driver"
>> depends on ARCH_APPLE || COMPILE_TEST
>> diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
>> index 4ea89f6fc531..b74e3104d71f 100644
>> --- a/drivers/spi/Makefile
>> +++ b/drivers/spi/Makefile
>> @@ -20,6 +20,7 @@ obj-$(CONFIG_SPI_ALTERA) += spi-altera-platform.o
>> obj-$(CONFIG_SPI_ALTERA_CORE) += spi-altera-core.o
>> obj-$(CONFIG_SPI_ALTERA_DFL) += spi-altera-dfl.o
>> obj-$(CONFIG_SPI_AMLOGIC_SPIFC_A1) += spi-amlogic-spifc-a1.o
>> +obj-$(CONFIG_SPI_AMLOGIC_SPISG) += spi-amlogic-spisg.o
>> obj-$(CONFIG_SPI_APPLE) += spi-apple.o
>> obj-$(CONFIG_SPI_AR934X) += spi-ar934x.o
>> obj-$(CONFIG_SPI_ARMADA_3700) += spi-armada-3700.o
>> diff --git a/drivers/spi/spi-amlogic-spisg.c b/drivers/spi/spi-amlogic-spisg.c
>> new file mode 100644
>> index 000000000000..2f2982154d49
>> --- /dev/null
>> +++ b/drivers/spi/spi-amlogic-spisg.c
>> @@ -0,0 +1,876 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * Driver for Amlogic SPI communication Scatter-Gather Controller
>> + *
>> + * Copyright (C) 2025 Amlogic, Inc. All rights reserved
>> + *
>> + * Author: Sunny Luo <sunny.luo@...ogic.com>
>> + * Author: Xianwei Zhao <xianwei.zhao@...ogic.com>
>> + */
>> +
>> +#include <linux/bitfield.h>
>> +#include <linux/clk.h>
>> +#include <linux/device.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/clk-provider.h>
>> +#include <linux/dma-mapping.h>
>> +#include <linux/pm_runtime.h>
>> +#include <linux/pm_domain.h>
>
> cacheflush
>
>> +#include <linux/platform_device.h>
>> +#include <linux/spi/spi.h>
>> +#include <linux/types.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/reset.h>
>
> So this you take to reset device... but your device does not have any
> resets! Just look at your binding.
>
Will add resets prop in binding.
>> +#include <linux/pinctrl/consumer.h>
>> +#include <linux/delay.h>
>> +#include <linux/cacheflush.h>
>
> Where do you use it?
>
Will remove it.
>> +#include <linux/regmap.h>
>
> Actually several other headers looks unused. I am not going to keep
> checking one by one - you should check and do not include irrelevant
> headers.
>
Will do.
>> +
>> +static int aml_spisg_probe(struct platform_device *pdev)
>> +{
>> + struct spi_controller *ctlr;
>> + struct spisg_device *spisg;
>> + struct device *dev = &pdev->dev;
>> + void __iomem *base;
>> + int ret, irq;
>> +
>> + const struct regmap_config aml_regmap_config = {
>> + .reg_bits = 32,
>> + .val_bits = 32,
>> + .reg_stride = 4,
>> + .max_register = SPISG_MAX_REG,
>> + };
>> +
>> + if (of_property_read_bool(dev->of_node, "slave"))
>
> "slave" is not a bool. You want to check for child presence, don't you?
> You need to use appropriate API for that otherwise you just add one of
> the issues which was being fixed recently.
>
The correct property name should be "spi-salve". I will fix it.
>> + ctlr = spi_alloc_target(dev, sizeof(*spisg));
>> + else
>> + ctlr = spi_alloc_host(dev, sizeof(*spisg));
>> + if (!ctlr)
>> + return dev_err_probe(dev, -ENOMEM, "controller allocation failed\n");
>> +
>
>
>
>> +
>> +static struct platform_driver amlogic_spisg_driver = {
>> + .probe = aml_spisg_probe,
>> + .remove = aml_spisg_remove,
>> + .driver = {
>> + .name = "amlogic-spisg",
>> + .of_match_table = of_match_ptr(amlogic_spisg_of_match),
>
> So now you will have warnings... drop of_match_ptr.
>
Will drop it.
> Both suggest you send us some old code, instead of working on something
> recent.
>
The following is the link of my first version:
https://lore.kernel.org/all/20250604-spisg-v1-0-5893dbe9d953@amlogic.com/
>> + .pm = &amlogic_spisg_pm_ops,
>> + },
>> +};
>> +
>> +module_platform_driver(amlogic_spisg_driver);
>> +
>> +MODULE_DESCRIPTION("Amlogic SPI Scatter-Gather Controller driver");
>> +MODULE_AUTHOR("Sunny Luo <sunny.luo@...ogic.com>");
>> +MODULE_LICENSE("GPL");
>>
>
>
> Best regards,
> Krzysztof
Powered by blists - more mailing lists