-
Notifications
You must be signed in to change notification settings - Fork 105
(kernel-rolling) spi: qspi: Add Phytium spi/qspi controller support #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(kernel-rolling) spi: qspi: Add Phytium spi/qspi controller support #210
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
deepin pr auto reviewMake sure to include the new headers: #include <linux/acpi.h>
#include <linux/hw.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/acpi/acpi.h>
#include <linux/acpi/of.h>
#include <linux/hwcap.h>Here's the updated int phytium_spi_add_host(struct device *dev, struct phytium_spi *fts) {
struct spi_master *master;
int ret;
WARN_ON(fts == NULL);
master = spi_alloc_master(dev, 0);
if (!master)
return -ENOMEM;
fts->master = master;
fts->dma_addr = (dma_addr_t)(fts->paddr + DR);
snprintf(fts->name, sizeof(fts->name), "phytium_spi%d", fts->bus_num);
ret = request_irq(fts->irq, phytium_spi_irq, IRQF_SHARED,
fts->name, master);
if (ret < 0) {
dev_err(dev, "can not get IRQ\n");
goto err_free_master;
}
master->use_gpio_descriptors = true;
master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LOOP;
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
master->bus_num = fts->bus_num;
master->num_chipselect = fts->num_cs;
master->setup = phytium_spi_setup;
master->cleanup = phytium_spi_cleanup;
master->set_cs = phytium_spi_set_cs;
master->transfer_one = phytium_spi_transfer_one;
master->handle_err = phytium_spi_handle_err;
master->max_speed_hz = fts->max_freq;
master->dev.of_node = dev->of_node;
master->dev.fwnode = dev->fwnode;
master->flags = SPI_CONTROLLER_GPIO_SS;
spi_hw_init(dev, fts);
if (fts->dma_ops && fts->dma_ops->dma_init) {
ret = fts->dma_ops->dma_init(dev, fts);
if (ret) {
dev_warn(dev, "DMA init failed\n");
} else {
master->can_dma = fts->dma_ops->can_dma;
master->flags |= SPI_CONTROLLER_MUST_TX;
}
}
spi_master_set_devdata(master, fts);
ret = spi_register_controller(master);
if (ret) {
dev_err(dev, "problem registering spi master\n");
goto err_exit;
}
return 0;
err_exit:
if (fts->dma_ops && fts->dma_ops->dma_exit)
fts->dma_ops->dma_exit(fts);
spi_enable_chip(fts, 0);
free_irq(fts->irq, master);
err_free_master:
spi_master_put(master);
return ret;
} |
Add binding documentation for Phytium SPI controller. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Add support for the Phytium SPI controller driver. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Zhang Yiqun <zhangyiqun@phytium.com.cn> Signed-off-by: Peng Min <pengmin1540@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Add the device tree binding documentation for Phytium QuadSPI controller. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
This patch adds a new driver for Phytium QuadSPI (QSPI) controller, which is used to access NOR Flash memory slaves. The driver implements spi-mem framework and does not support generic SPI operations. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Zhou Yulin <zhouyulin1283@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
The driver used devm_spi_register_controller() on bind. Therefore, __device_release_driver() first invokes phytium_spi_remove_host() before unregistering the SPI controller via devres_release_all() when unbinding. Since phytium_spi_remove_host() shuts down the chip, rendering the SPI bus inaccessible even through the SPI controller is still registered. When the SPI controller is subsequently unregistered, it unbinds all its slave devices. Because their drivers cannot access the SPI bus, the slave devices may be left in an improper state. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Since the platform driver wraps the core phytium_spi into phytium_spi_clk struct to include a platform clock, the pointer extract from driver_data should also be 'struct phytium_spi_clk *'. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Reported-by: Zhou Yulin <zhouyulin1283@phytium.com.cn> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
The mask of sck_sel should be 0x7 instead of 0x3, otherwise the split is set differently than expected. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Liu Tianyu <liutianyu1250@phytium.com.cn> Signed-off-by: Li Mingzhe <limingzhe1839@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Code has been modified and added in the SPI driver section to adapt to the DDMA controller. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Liu Tianyu <liutianyu1250@phytium.com.cn> Signed-off-by: Wang Hanmo <wanghanmo2242@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Add acpi table support for qspi/spi driver, supporting parsing of ACPI tables. Signed-off-by: yuanxia <yuanxia2073@phytium.com.cn> Signed-off-by: Wang Hanmo <wanghanmo2242@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
There was an unused-variable 'adev' brings a warning.
Resolve following error when '-Werror' was enabled:
drivers/mtd/mtdpart.c: In function ‘mtd_part_acpi_parse’:
drivers/mtd/mtdpart.c:584:29: error: unused variable ‘adev’ [-Werror=unused-variable]
584 | struct acpi_device *adev;
| ^~~~
cc1: all warnings being treated as errors
Reported-by: Mingcong Bai <baimingcong@uniontech.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
f65e651 to
3c6b717
Compare
Picked and rebased from #136.
From original pull request:
Builds tested