linux/drivers/spi/spi-fsl-spi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Freescale SPI controller driver.
 *
 * Maintainer: Kumar Gala
 *
 * Copyright (C) 2006 Polycom, Inc.
 * Copyright 2010 Freescale Semiconductor, Inc.
 *
 * CPM SPI and QE buffer descriptors mode support:
 * Copyright (c) 2009  MontaVista Software, Inc.
 * Author: Anton Vorontsov <[email protected]>
 *
 * GRLIB support:
 * Copyright (c) 2012 Aeroflex Gaisler AB.
 * Author: Andreas Larsson <[email protected]>
 */
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/fsl_devices.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/spi/spi_bitbang.h>
#include <linux/types.h>

#ifdef CONFIG_FSL_SOC
#include <sysdev/fsl_soc.h>
#endif

/* Specific to the MPC8306/MPC8309 */
#define IMMR_SPI_CS_OFFSET
#define SPI_BOOT_SEL_BIT

#include "spi-fsl-lib.h"
#include "spi-fsl-cpm.h"
#include "spi-fsl-spi.h"

#define TYPE_FSL
#define TYPE_GRLIB

struct fsl_spi_match_data {};

static struct fsl_spi_match_data of_fsl_spi_fsl_config =;

static struct fsl_spi_match_data of_fsl_spi_grlib_config =;

static const struct of_device_id of_fsl_spi_match[] =;
MODULE_DEVICE_TABLE(of, of_fsl_spi_match);

static int fsl_spi_get_type(struct device *dev)
{}

static void fsl_spi_change_mode(struct spi_device *spi)
{}

static void fsl_spi_qe_cpu_set_shifts(u32 *rx_shift, u32 *tx_shift,
				      int bits_per_word, int msb_first)
{}

static void fsl_spi_grlib_set_shifts(u32 *rx_shift, u32 *tx_shift,
				     int bits_per_word, int msb_first)
{}

static void mspi_apply_cpu_mode_quirks(struct spi_mpc8xxx_cs *cs,
				       struct spi_device *spi,
				       struct mpc8xxx_spi *mpc8xxx_spi,
				       int bits_per_word)
{}

static int fsl_spi_setup_transfer(struct spi_device *spi,
					struct spi_transfer *t)
{}

static int fsl_spi_cpu_bufs(struct mpc8xxx_spi *mspi,
				struct spi_transfer *t, unsigned int len)
{}

static int fsl_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
{}

static int fsl_spi_prepare_message(struct spi_controller *ctlr,
				   struct spi_message *m)
{}

static int fsl_spi_transfer_one(struct spi_controller *controller,
				struct spi_device *spi,
				struct spi_transfer *t)
{}

static int fsl_spi_unprepare_message(struct spi_controller *controller,
				     struct spi_message *msg)
{}

static int fsl_spi_setup(struct spi_device *spi)
{}

static void fsl_spi_cleanup(struct spi_device *spi)
{}

static void fsl_spi_cpu_irq(struct mpc8xxx_spi *mspi, u32 events)
{}

static irqreturn_t fsl_spi_irq(s32 irq, void *context_data)
{}

static void fsl_spi_grlib_cs_control(struct spi_device *spi, bool on)
{}

static void fsl_spi_grlib_probe(struct device *dev)
{}

static void fsl_spi_cs_control(struct spi_device *spi, bool on)
{}

static struct spi_controller *fsl_spi_probe(struct device *dev,
		struct resource *mem, unsigned int irq)
{}

static int of_fsl_spi_probe(struct platform_device *ofdev)
{}

static void of_fsl_spi_remove(struct platform_device *ofdev)
{}

static struct platform_driver of_fsl_spi_driver =;

#ifdef CONFIG_MPC832x_RDB
/*
 * XXX XXX XXX
 * This is "legacy" platform driver, was used by the MPC8323E-RDB boards
 * only. The driver should go away soon, since newer MPC8323E-RDB's device
 * tree can work with OpenFirmware driver. But for now we support old trees
 * as well.
 */
static int plat_mpc8xxx_spi_probe(struct platform_device *pdev)
{
	struct resource *mem;
	int irq;
	struct spi_controller *host;

	if (!dev_get_platdata(&pdev->dev))
		return -EINVAL;

	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!mem)
		return -EINVAL;

	irq = platform_get_irq(pdev, 0);
	if (irq < 0)
		return irq;

	host = fsl_spi_probe(&pdev->dev, mem, irq);
	return PTR_ERR_OR_ZERO(host);
}

static void plat_mpc8xxx_spi_remove(struct platform_device *pdev)
{
	struct spi_controller *host = platform_get_drvdata(pdev);
	struct mpc8xxx_spi *mpc8xxx_spi = spi_controller_get_devdata(host);

	fsl_spi_cpm_free(mpc8xxx_spi);
}

MODULE_ALIAS("platform:mpc8xxx_spi");
static struct platform_driver mpc8xxx_spi_driver = {
	.probe = plat_mpc8xxx_spi_probe,
	.remove_new = plat_mpc8xxx_spi_remove,
	.driver = {
		.name = "mpc8xxx_spi",
	},
};

static bool legacy_driver_failed;

static void __init legacy_driver_register(void)
{
	legacy_driver_failed = platform_driver_register(&mpc8xxx_spi_driver);
}

static void __exit legacy_driver_unregister(void)
{
	if (legacy_driver_failed)
		return;
	platform_driver_unregister(&mpc8xxx_spi_driver);
}
#else
static void __init legacy_driver_register(void) {}
static void __exit legacy_driver_unregister(void) {}
#endif /* CONFIG_MPC832x_RDB */

static int __init fsl_spi_init(void)
{}
module_init();

static void __exit fsl_spi_exit(void)
{}
module_exit(fsl_spi_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();