18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2014 Imagination Technologies Ltd.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef __ASM_CDMM_H
98c2ecf20Sopenharmony_ci#define __ASM_CDMM_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/device.h>
128c2ecf20Sopenharmony_ci#include <linux/mod_devicetable.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/**
158c2ecf20Sopenharmony_ci * struct mips_cdmm_device - Represents a single device on a CDMM bus.
168c2ecf20Sopenharmony_ci * @dev:	Driver model device object.
178c2ecf20Sopenharmony_ci * @cpu:	CPU which can access this device.
188c2ecf20Sopenharmony_ci * @res:	MMIO resource.
198c2ecf20Sopenharmony_ci * @type:	Device type identifier.
208c2ecf20Sopenharmony_ci * @rev:	Device revision number.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_cistruct mips_cdmm_device {
238c2ecf20Sopenharmony_ci	struct device		dev;
248c2ecf20Sopenharmony_ci	unsigned int		cpu;
258c2ecf20Sopenharmony_ci	struct resource		res;
268c2ecf20Sopenharmony_ci	unsigned int		type;
278c2ecf20Sopenharmony_ci	unsigned int		rev;
288c2ecf20Sopenharmony_ci};
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/**
318c2ecf20Sopenharmony_ci * struct mips_cdmm_driver - Represents a driver for a CDMM device.
328c2ecf20Sopenharmony_ci * @drv:	Driver model driver object.
338c2ecf20Sopenharmony_ci * @probe	Callback for probing newly discovered devices.
348c2ecf20Sopenharmony_ci * @remove:	Callback to remove the device.
358c2ecf20Sopenharmony_ci * @shutdown:	Callback on system shutdown.
368c2ecf20Sopenharmony_ci * @cpu_down:	Callback when the parent CPU is going down.
378c2ecf20Sopenharmony_ci *		Any CPU pinned threads/timers should be disabled.
388c2ecf20Sopenharmony_ci * @cpu_up:	Callback when the parent CPU is coming back up again.
398c2ecf20Sopenharmony_ci *		CPU pinned threads/timers can be restarted.
408c2ecf20Sopenharmony_ci * @id_table:	Table for CDMM IDs to match against.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_cistruct mips_cdmm_driver {
438c2ecf20Sopenharmony_ci	struct device_driver	drv;
448c2ecf20Sopenharmony_ci	int			(*probe)(struct mips_cdmm_device *);
458c2ecf20Sopenharmony_ci	int			(*remove)(struct mips_cdmm_device *);
468c2ecf20Sopenharmony_ci	void			(*shutdown)(struct mips_cdmm_device *);
478c2ecf20Sopenharmony_ci	int			(*cpu_down)(struct mips_cdmm_device *);
488c2ecf20Sopenharmony_ci	int			(*cpu_up)(struct mips_cdmm_device *);
498c2ecf20Sopenharmony_ci	const struct mips_cdmm_device_id *id_table;
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/**
538c2ecf20Sopenharmony_ci * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * Picking a suitable physical address at which to map the CDMM region is
568c2ecf20Sopenharmony_ci * platform specific, so this function can be defined by platform code to
578c2ecf20Sopenharmony_ci * pick a suitable value if none is configured by the bootloader.
588c2ecf20Sopenharmony_ci *
598c2ecf20Sopenharmony_ci * This address must be 32kB aligned, and the region occupies a maximum of 32kB
608c2ecf20Sopenharmony_ci * of physical address space which must not be used for anything else.
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci * Returns:	Physical base address for CDMM region, or 0 on failure.
638c2ecf20Sopenharmony_ci */
648c2ecf20Sopenharmony_ciphys_addr_t mips_cdmm_phys_base(void);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciextern struct bus_type mips_cdmm_bustype;
678c2ecf20Sopenharmony_civoid __iomem *mips_cdmm_early_probe(unsigned int dev_type);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define to_mips_cdmm_device(d)	container_of(d, struct mips_cdmm_device, dev)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define mips_cdmm_get_drvdata(d)	dev_get_drvdata(&d->dev)
728c2ecf20Sopenharmony_ci#define mips_cdmm_set_drvdata(d, p)	dev_set_drvdata(&d->dev, p)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciint mips_cdmm_driver_register(struct mips_cdmm_driver *);
758c2ecf20Sopenharmony_civoid mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/*
788c2ecf20Sopenharmony_ci * module_mips_cdmm_driver() - Helper macro for drivers that don't do
798c2ecf20Sopenharmony_ci * anything special in module init/exit.  This eliminates a lot of
808c2ecf20Sopenharmony_ci * boilerplate.  Each module may only use this macro once, and
818c2ecf20Sopenharmony_ci * calling it replaces module_init() and module_exit()
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_ci#define module_mips_cdmm_driver(__mips_cdmm_driver) \
848c2ecf20Sopenharmony_ci	module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
858c2ecf20Sopenharmony_ci			mips_cdmm_driver_unregister)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
898c2ecf20Sopenharmony_ci * special in init and have no exit. This eliminates some boilerplate. Each
908c2ecf20Sopenharmony_ci * driver may only use this macro once, and calling it replaces device_initcall
918c2ecf20Sopenharmony_ci * (or in some cases, the legacy __initcall). This is meant to be a direct
928c2ecf20Sopenharmony_ci * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
938c2ecf20Sopenharmony_ci * is not used for builtin cases.
948c2ecf20Sopenharmony_ci */
958c2ecf20Sopenharmony_ci#define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
968c2ecf20Sopenharmony_ci	builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/* drivers/tty/mips_ejtag_fdc.c */
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
1018c2ecf20Sopenharmony_ciint setup_early_fdc_console(void);
1028c2ecf20Sopenharmony_ci#else
1038c2ecf20Sopenharmony_cistatic inline int setup_early_fdc_console(void)
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci	return -ENODEV;
1068c2ecf20Sopenharmony_ci}
1078c2ecf20Sopenharmony_ci#endif
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#endif /* __ASM_CDMM_H */
110