summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-meson-spifc.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:35:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:31 +0000
commit85c675d0d09a45a135bddd15d7b385f8758c32fb (patch)
tree76267dbc9b9a130337be3640948fe397b04ac629 /drivers/spi/spi-meson-spifc.c
parentAdding upstream version 6.6.15. (diff)
downloadlinux-85c675d0d09a45a135bddd15d7b385f8758c32fb.tar.xz
linux-85c675d0d09a45a135bddd15d7b385f8758c32fb.zip
Adding upstream version 6.7.7.upstream/6.7.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/spi/spi-meson-spifc.c')
-rw-r--r--drivers/spi/spi-meson-spifc.c79
1 files changed, 34 insertions, 45 deletions
diff --git a/drivers/spi/spi-meson-spifc.c b/drivers/spi/spi-meson-spifc.c
index 06626f406f..fd8b26dd4a 100644
--- a/drivers/spi/spi-meson-spifc.c
+++ b/drivers/spi/spi-meson-spifc.c
@@ -67,13 +67,13 @@
/**
* struct meson_spifc
- * @master: the SPI master
+ * @host: the SPI host
* @regmap: regmap for device registers
* @clk: input clock of the built-in baud rate generator
* @dev: the device structure
*/
struct meson_spifc {
- struct spi_master *master;
+ struct spi_controller *host;
struct regmap *regmap;
struct clk *clk;
struct device *dev;
@@ -237,16 +237,16 @@ static int meson_spifc_txrx(struct meson_spifc *spifc,
/**
* meson_spifc_transfer_one() - perform a single transfer
- * @master: the SPI master
+ * @host: the SPI host
* @spi: the SPI device
* @xfer: the current SPI transfer
* Return: 0 on success, a negative value on error
*/
-static int meson_spifc_transfer_one(struct spi_master *master,
+static int meson_spifc_transfer_one(struct spi_controller *host,
struct spi_device *spi,
struct spi_transfer *xfer)
{
- struct meson_spifc *spifc = spi_master_get_devdata(master);
+ struct meson_spifc *spifc = spi_controller_get_devdata(host);
int len, done = 0, ret = 0;
meson_spifc_setup_speed(spifc, xfer->speed_hz);
@@ -256,7 +256,7 @@ static int meson_spifc_transfer_one(struct spi_master *master,
while (done < xfer->len && !ret) {
len = min_t(int, xfer->len - done, SPIFC_BUFFER_SIZE);
ret = meson_spifc_txrx(spifc, xfer, done, len,
- spi_transfer_is_last(master, xfer),
+ spi_transfer_is_last(host, xfer),
done + len >= xfer->len);
done += len;
}
@@ -284,19 +284,19 @@ static void meson_spifc_hw_init(struct meson_spifc *spifc)
static int meson_spifc_probe(struct platform_device *pdev)
{
- struct spi_master *master;
+ struct spi_controller *host;
struct meson_spifc *spifc;
void __iomem *base;
unsigned int rate;
int ret = 0;
- master = spi_alloc_master(&pdev->dev, sizeof(struct meson_spifc));
- if (!master)
+ host = spi_alloc_host(&pdev->dev, sizeof(struct meson_spifc));
+ if (!host)
return -ENOMEM;
- platform_set_drvdata(pdev, master);
+ platform_set_drvdata(pdev, host);
- spifc = spi_master_get_devdata(master);
+ spifc = spi_controller_get_devdata(host);
spifc->dev = &pdev->dev;
base = devm_platform_ioremap_resource(pdev, 0);
@@ -312,67 +312,56 @@ static int meson_spifc_probe(struct platform_device *pdev)
goto out_err;
}
- spifc->clk = devm_clk_get(spifc->dev, NULL);
+ spifc->clk = devm_clk_get_enabled(spifc->dev, NULL);
if (IS_ERR(spifc->clk)) {
dev_err(spifc->dev, "missing clock\n");
ret = PTR_ERR(spifc->clk);
goto out_err;
}
- ret = clk_prepare_enable(spifc->clk);
- if (ret) {
- dev_err(spifc->dev, "can't prepare clock\n");
- goto out_err;
- }
-
rate = clk_get_rate(spifc->clk);
- master->num_chipselect = 1;
- master->dev.of_node = pdev->dev.of_node;
- master->bits_per_word_mask = SPI_BPW_MASK(8);
- master->auto_runtime_pm = true;
- master->transfer_one = meson_spifc_transfer_one;
- master->min_speed_hz = rate >> 6;
- master->max_speed_hz = rate >> 1;
+ host->num_chipselect = 1;
+ host->dev.of_node = pdev->dev.of_node;
+ host->bits_per_word_mask = SPI_BPW_MASK(8);
+ host->auto_runtime_pm = true;
+ host->transfer_one = meson_spifc_transfer_one;
+ host->min_speed_hz = rate >> 6;
+ host->max_speed_hz = rate >> 1;
meson_spifc_hw_init(spifc);
pm_runtime_set_active(spifc->dev);
pm_runtime_enable(spifc->dev);
- ret = devm_spi_register_master(spifc->dev, master);
+ ret = devm_spi_register_controller(spifc->dev, host);
if (ret) {
- dev_err(spifc->dev, "failed to register spi master\n");
- goto out_clk;
+ dev_err(spifc->dev, "failed to register spi host\n");
+ goto out_pm;
}
return 0;
-out_clk:
- clk_disable_unprepare(spifc->clk);
+out_pm:
pm_runtime_disable(spifc->dev);
out_err:
- spi_master_put(master);
+ spi_controller_put(host);
return ret;
}
static void meson_spifc_remove(struct platform_device *pdev)
{
- struct spi_master *master = platform_get_drvdata(pdev);
- struct meson_spifc *spifc = spi_master_get_devdata(master);
-
pm_runtime_get_sync(&pdev->dev);
- clk_disable_unprepare(spifc->clk);
pm_runtime_disable(&pdev->dev);
}
#ifdef CONFIG_PM_SLEEP
static int meson_spifc_suspend(struct device *dev)
{
- struct spi_master *master = dev_get_drvdata(dev);
- struct meson_spifc *spifc = spi_master_get_devdata(master);
+ struct spi_controller *host = dev_get_drvdata(dev);
+ struct meson_spifc *spifc = spi_controller_get_devdata(host);
int ret;
- ret = spi_master_suspend(master);
+ ret = spi_controller_suspend(host);
if (ret)
return ret;
@@ -384,8 +373,8 @@ static int meson_spifc_suspend(struct device *dev)
static int meson_spifc_resume(struct device *dev)
{
- struct spi_master *master = dev_get_drvdata(dev);
- struct meson_spifc *spifc = spi_master_get_devdata(master);
+ struct spi_controller *host = dev_get_drvdata(dev);
+ struct meson_spifc *spifc = spi_controller_get_devdata(host);
int ret;
if (!pm_runtime_suspended(dev)) {
@@ -396,7 +385,7 @@ static int meson_spifc_resume(struct device *dev)
meson_spifc_hw_init(spifc);
- ret = spi_master_resume(master);
+ ret = spi_controller_resume(host);
if (ret)
clk_disable_unprepare(spifc->clk);
@@ -407,8 +396,8 @@ static int meson_spifc_resume(struct device *dev)
#ifdef CONFIG_PM
static int meson_spifc_runtime_suspend(struct device *dev)
{
- struct spi_master *master = dev_get_drvdata(dev);
- struct meson_spifc *spifc = spi_master_get_devdata(master);
+ struct spi_controller *host = dev_get_drvdata(dev);
+ struct meson_spifc *spifc = spi_controller_get_devdata(host);
clk_disable_unprepare(spifc->clk);
@@ -417,8 +406,8 @@ static int meson_spifc_runtime_suspend(struct device *dev)
static int meson_spifc_runtime_resume(struct device *dev)
{
- struct spi_master *master = dev_get_drvdata(dev);
- struct meson_spifc *spifc = spi_master_get_devdata(master);
+ struct spi_controller *host = dev_get_drvdata(dev);
+ struct meson_spifc *spifc = spi_controller_get_devdata(host);
return clk_prepare_enable(spifc->clk);
}