162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
362306a36Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
462306a36Sopenharmony_ci * for more details.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2014 Imagination Technologies Ltd.
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#ifndef __ASM_CDMM_H
962306a36Sopenharmony_ci#define __ASM_CDMM_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <linux/device.h>
1262306a36Sopenharmony_ci#include <linux/mod_devicetable.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/**
1562306a36Sopenharmony_ci * struct mips_cdmm_device - Represents a single device on a CDMM bus.
1662306a36Sopenharmony_ci * @dev:	Driver model device object.
1762306a36Sopenharmony_ci * @cpu:	CPU which can access this device.
1862306a36Sopenharmony_ci * @res:	MMIO resource.
1962306a36Sopenharmony_ci * @type:	Device type identifier.
2062306a36Sopenharmony_ci * @rev:	Device revision number.
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_cistruct mips_cdmm_device {
2362306a36Sopenharmony_ci	struct device		dev;
2462306a36Sopenharmony_ci	unsigned int		cpu;
2562306a36Sopenharmony_ci	struct resource		res;
2662306a36Sopenharmony_ci	unsigned int		type;
2762306a36Sopenharmony_ci	unsigned int		rev;
2862306a36Sopenharmony_ci};
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/**
3162306a36Sopenharmony_ci * struct mips_cdmm_driver - Represents a driver for a CDMM device.
3262306a36Sopenharmony_ci * @drv:	Driver model driver object.
3362306a36Sopenharmony_ci * @probe	Callback for probing newly discovered devices.
3462306a36Sopenharmony_ci * @remove:	Callback to remove the device.
3562306a36Sopenharmony_ci * @shutdown:	Callback on system shutdown.
3662306a36Sopenharmony_ci * @cpu_down:	Callback when the parent CPU is going down.
3762306a36Sopenharmony_ci *		Any CPU pinned threads/timers should be disabled.
3862306a36Sopenharmony_ci * @cpu_up:	Callback when the parent CPU is coming back up again.
3962306a36Sopenharmony_ci *		CPU pinned threads/timers can be restarted.
4062306a36Sopenharmony_ci * @id_table:	Table for CDMM IDs to match against.
4162306a36Sopenharmony_ci */
4262306a36Sopenharmony_cistruct mips_cdmm_driver {
4362306a36Sopenharmony_ci	struct device_driver	drv;
4462306a36Sopenharmony_ci	int			(*probe)(struct mips_cdmm_device *);
4562306a36Sopenharmony_ci	int			(*remove)(struct mips_cdmm_device *);
4662306a36Sopenharmony_ci	void			(*shutdown)(struct mips_cdmm_device *);
4762306a36Sopenharmony_ci	int			(*cpu_down)(struct mips_cdmm_device *);
4862306a36Sopenharmony_ci	int			(*cpu_up)(struct mips_cdmm_device *);
4962306a36Sopenharmony_ci	const struct mips_cdmm_device_id *id_table;
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/**
5362306a36Sopenharmony_ci * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
5462306a36Sopenharmony_ci *
5562306a36Sopenharmony_ci * Picking a suitable physical address at which to map the CDMM region is
5662306a36Sopenharmony_ci * platform specific, so this function can be defined by platform code to
5762306a36Sopenharmony_ci * pick a suitable value if none is configured by the bootloader.
5862306a36Sopenharmony_ci *
5962306a36Sopenharmony_ci * This address must be 32kB aligned, and the region occupies a maximum of 32kB
6062306a36Sopenharmony_ci * of physical address space which must not be used for anything else.
6162306a36Sopenharmony_ci *
6262306a36Sopenharmony_ci * Returns:	Physical base address for CDMM region, or 0 on failure.
6362306a36Sopenharmony_ci */
6462306a36Sopenharmony_ciphys_addr_t mips_cdmm_phys_base(void);
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciextern struct bus_type mips_cdmm_bustype;
6762306a36Sopenharmony_civoid __iomem *mips_cdmm_early_probe(unsigned int dev_type);
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci#define to_mips_cdmm_device(d)	container_of(d, struct mips_cdmm_device, dev)
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci#define mips_cdmm_get_drvdata(d)	dev_get_drvdata(&d->dev)
7262306a36Sopenharmony_ci#define mips_cdmm_set_drvdata(d, p)	dev_set_drvdata(&d->dev, p)
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciint mips_cdmm_driver_register(struct mips_cdmm_driver *);
7562306a36Sopenharmony_civoid mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/*
7862306a36Sopenharmony_ci * module_mips_cdmm_driver() - Helper macro for drivers that don't do
7962306a36Sopenharmony_ci * anything special in module init/exit.  This eliminates a lot of
8062306a36Sopenharmony_ci * boilerplate.  Each module may only use this macro once, and
8162306a36Sopenharmony_ci * calling it replaces module_init() and module_exit()
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_ci#define module_mips_cdmm_driver(__mips_cdmm_driver) \
8462306a36Sopenharmony_ci	module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
8562306a36Sopenharmony_ci			mips_cdmm_driver_unregister)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci/*
8862306a36Sopenharmony_ci * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
8962306a36Sopenharmony_ci * special in init and have no exit. This eliminates some boilerplate. Each
9062306a36Sopenharmony_ci * driver may only use this macro once, and calling it replaces device_initcall
9162306a36Sopenharmony_ci * (or in some cases, the legacy __initcall). This is meant to be a direct
9262306a36Sopenharmony_ci * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
9362306a36Sopenharmony_ci * is not used for builtin cases.
9462306a36Sopenharmony_ci */
9562306a36Sopenharmony_ci#define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
9662306a36Sopenharmony_ci	builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci/* drivers/tty/mips_ejtag_fdc.c */
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
10162306a36Sopenharmony_ciint setup_early_fdc_console(void);
10262306a36Sopenharmony_ci#else
10362306a36Sopenharmony_cistatic inline int setup_early_fdc_console(void)
10462306a36Sopenharmony_ci{
10562306a36Sopenharmony_ci	return -ENODEV;
10662306a36Sopenharmony_ci}
10762306a36Sopenharmony_ci#endif
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#endif /* __ASM_CDMM_H */
110