Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2014 Imagination Technologies Ltd.
0007  */
0008 #ifndef __ASM_CDMM_H
0009 #define __ASM_CDMM_H
0010 
0011 #include <linux/device.h>
0012 #include <linux/mod_devicetable.h>
0013 
0014 /**
0015  * struct mips_cdmm_device - Represents a single device on a CDMM bus.
0016  * @dev:    Driver model device object.
0017  * @cpu:    CPU which can access this device.
0018  * @res:    MMIO resource.
0019  * @type:   Device type identifier.
0020  * @rev:    Device revision number.
0021  */
0022 struct mips_cdmm_device {
0023     struct device       dev;
0024     unsigned int        cpu;
0025     struct resource     res;
0026     unsigned int        type;
0027     unsigned int        rev;
0028 };
0029 
0030 /**
0031  * struct mips_cdmm_driver - Represents a driver for a CDMM device.
0032  * @drv:    Driver model driver object.
0033  * @probe   Callback for probing newly discovered devices.
0034  * @remove: Callback to remove the device.
0035  * @shutdown:   Callback on system shutdown.
0036  * @cpu_down:   Callback when the parent CPU is going down.
0037  *      Any CPU pinned threads/timers should be disabled.
0038  * @cpu_up: Callback when the parent CPU is coming back up again.
0039  *      CPU pinned threads/timers can be restarted.
0040  * @id_table:   Table for CDMM IDs to match against.
0041  */
0042 struct mips_cdmm_driver {
0043     struct device_driver    drv;
0044     int         (*probe)(struct mips_cdmm_device *);
0045     int         (*remove)(struct mips_cdmm_device *);
0046     void            (*shutdown)(struct mips_cdmm_device *);
0047     int         (*cpu_down)(struct mips_cdmm_device *);
0048     int         (*cpu_up)(struct mips_cdmm_device *);
0049     const struct mips_cdmm_device_id *id_table;
0050 };
0051 
0052 /**
0053  * mips_cdmm_phys_base() - Choose a physical base address for CDMM region.
0054  *
0055  * Picking a suitable physical address at which to map the CDMM region is
0056  * platform specific, so this function can be defined by platform code to
0057  * pick a suitable value if none is configured by the bootloader.
0058  *
0059  * This address must be 32kB aligned, and the region occupies a maximum of 32kB
0060  * of physical address space which must not be used for anything else.
0061  *
0062  * Returns: Physical base address for CDMM region, or 0 on failure.
0063  */
0064 phys_addr_t mips_cdmm_phys_base(void);
0065 
0066 extern struct bus_type mips_cdmm_bustype;
0067 void __iomem *mips_cdmm_early_probe(unsigned int dev_type);
0068 
0069 #define to_mips_cdmm_device(d)  container_of(d, struct mips_cdmm_device, dev)
0070 
0071 #define mips_cdmm_get_drvdata(d)    dev_get_drvdata(&d->dev)
0072 #define mips_cdmm_set_drvdata(d, p) dev_set_drvdata(&d->dev, p)
0073 
0074 int mips_cdmm_driver_register(struct mips_cdmm_driver *);
0075 void mips_cdmm_driver_unregister(struct mips_cdmm_driver *);
0076 
0077 /*
0078  * module_mips_cdmm_driver() - Helper macro for drivers that don't do
0079  * anything special in module init/exit.  This eliminates a lot of
0080  * boilerplate.  Each module may only use this macro once, and
0081  * calling it replaces module_init() and module_exit()
0082  */
0083 #define module_mips_cdmm_driver(__mips_cdmm_driver) \
0084     module_driver(__mips_cdmm_driver, mips_cdmm_driver_register, \
0085             mips_cdmm_driver_unregister)
0086 
0087 /*
0088  * builtin_mips_cdmm_driver() - Helper macro for drivers that don't do anything
0089  * special in init and have no exit. This eliminates some boilerplate. Each
0090  * driver may only use this macro once, and calling it replaces device_initcall
0091  * (or in some cases, the legacy __initcall). This is meant to be a direct
0092  * parallel of module_mips_cdmm_driver() above but without the __exit stuff that
0093  * is not used for builtin cases.
0094  */
0095 #define builtin_mips_cdmm_driver(__mips_cdmm_driver) \
0096     builtin_driver(__mips_cdmm_driver, mips_cdmm_driver_register)
0097 
0098 /* drivers/tty/mips_ejtag_fdc.c */
0099 
0100 #ifdef CONFIG_MIPS_EJTAG_FDC_EARLYCON
0101 int setup_early_fdc_console(void);
0102 #else
0103 static inline int setup_early_fdc_console(void)
0104 {
0105     return -ENODEV;
0106 }
0107 #endif
0108 
0109 #endif /* __ASM_CDMM_H */