| 1 | |
| 2 | * This file is subject to the terms and conditions of the GNU General Public
|
| 3 | * License. See the file "COPYING" in the main directory of this archive
|
| 4 | * for more details.
|
| 5 | *
|
| 6 | * Copyright (C) 2014 Imagination Technologies Ltd.
|
| 7 |
|
| 8 | #ifndef __ASM_CDMM_H
|
| 9 | #define __ASM_CDMM_H
|
| 10 |
|
| 11 | #include <linux/device.h>
|
| 12 | #include <linux/device-id/mips_cdmm.h>
|
| 13 |
|
| 14 | |
| 15 | * struct mips_cdmm_device - Represents a single device on a CDMM bus.
|
| 16 | * @dev: Driver model device object.
|
| 17 | * @cpu: CPU which can access this device.
|
| 18 | * @res: MMIO resource.
|
| 19 | * @type: Device type identifier.
|
| 20 | * @rev: Device revision number.
|
| 21 |
|
| 22 | struct mips_cdmm_device {
|
| 23 | struct device dev;
|
| 24 | unsigned int cpu;
|
| 25 | struct resource res;
|
| 26 | unsigned int type;
|
| 27 | unsigned int rev;
|
| 28 | };
|
| 29 |
|
| 30 | |
| 31 | * struct mips_cdmm_driver - Represents a driver for a CDMM device.
|
| 32 | * @drv: Driver model driver object.
|
| 33 | * @probe Callback for probing newly discovered devices.
|
| 34 | * @remove: Callback to remove the device.
|
| 35 | * @shutdown: Callback on system shutdown.
|
| 36 | * @cpu_down: Callback when the parent CPU is going down.
|
| 37 | * Any CPU pinned threads/timers should be disabled.
|
| 38 | * @cpu_up: Callback when the parent CPU is coming back up again.
|
| 39 | * CPU pinned threads/timers can be restarted.
|
| 40 | * @id_table: Table for CDMM IDs to match against.
|
| 41 |
|
| 42 | struct mips_cdmm_driver {
|
| 43 | struct device_driver drv;
|
| 44 | int (*probe)(struct mips_cdmm_device *);
|
| 45 | int (*remove)(struct mips_cdmm_device *);
|
| 46 | void (*shutdown)(struct mips_cdmm_device *);
|
| 47 | int (*cpu_down)(struct mips_cdmm_device *);
|
| 48 | int (*cpu_up)(struct mips_cdmm_device *);
|
| 49 | const struct mips_cdmm_device_id *id_table;
|
| 50 | };
|
| 51 |
|
| 52 | |
| 53 | * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
|
| 54 | *
|
| 55 | * Picking a suitable physical address at which to map the CDMM region is
|
| 56 | * platform specific, so this function can be defined by platform code to
|
| 57 | * pick a suitable value if none is configured by the bootloader.
|
| 58 | *
|
| 59 | * This address must be 32kB aligned, and the region occupies a maximum of 32kB
|
| 60 | * of physical address space which must not be used for anything else.
|
| 61 | *
|
| 62 | * Returns: Physical base address for CDMM region, or 0 on failure.
|
| 63 |
|
| 64 | phys_addr_t mips_cdmm_phys_base(void);
|
| 65 |
|
| 66 | extern const struct bus_type mips_cdmm_bustype;
|
| 67 | void __iomem *mips_cdmm_early_probe(unsigned int dev_type);
|
| 68 |
|
| 69 | #define to_mips_cdmm_device(d) container_of(d, struct mips_cdmm_device, dev)
|
| 70 |
|
| 71 | #define mips_cdmm_get_drvdata(d) dev_get_drvdata(&d->dev)
|
| 72 | #define mips_cdmm_set_drvdata(d, p) dev_set_drvdata(&d->dev, p)
|
| 73 |
|
| 74 | int mips_cdmm_driver_register(struct mips_cdmm_driver *);
|
| 75 | void mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
|
| 76 |
|
| 77 | |
| 78 | * module_mips_cdmm_driver() - Helper macro for drivers that don't do
|
| 79 | * anything special in module init/exit. This eliminates a lot of
|
| 80 | * boilerplate. Each module may only use this macro once, and
|
| 81 | * calling it replaces module_init() and module_exit()
|
| 82 |
|
| 83 | #define module_mips_cdmm_driver(__mips_cdmm_driver) \
|
| 84 | module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
|
| 85 | mips_cdmm_driver_unregister)
|
| 86 |
|
| 87 | |
| 88 | * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
|
| 89 | * special in init and have no exit. This eliminates some boilerplate. Each
|
| 90 | * driver may only use this macro once, and calling it replaces device_initcall
|
| 91 | * (or in some cases, the legacy __initcall). This is meant to be a direct
|
| 92 | * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
|
| 93 | * is not used for builtin cases.
|
| 94 |
|
| 95 | #define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
|
| 96 | builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 | #ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
|
| 101 | int setup_early_fdc_console(void);
|
| 102 | #else
|
| 103 | static inline int setup_early_fdc_console(void)
|
| 104 | {
|
| 105 | return -ENODEV;
|
| 106 | }
|
| 107 | #endif
|
| 108 |
|
| 109 | #endif
|