Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * include/linux/superhyway.h
0003  *
0004  * SuperHyway Bus definitions
0005  *
0006  * Copyright (C) 2004, 2005  Paul Mundt <lethal@linux-sh.org>
0007  *
0008  * This file is subject to the terms and conditions of the GNU General Public
0009  * License.  See the file "COPYING" in the main directory of this archive
0010  * for more details.
0011  */
0012 #ifndef __LINUX_SUPERHYWAY_H
0013 #define __LINUX_SUPERHYWAY_H
0014 
0015 #include <linux/device.h>
0016 
0017 /*
0018  * SuperHyway IDs
0019  */
0020 #define SUPERHYWAY_DEVICE_ID_SH5_DMAC   0x0183
0021 
0022 struct superhyway_vcr_info {
0023     u8  perr_flags; /* P-port Error flags */
0024     u8  merr_flags; /* Module Error flags */
0025     u16 mod_vers;   /* Module Version */
0026     u16 mod_id;     /* Module ID */
0027     u8  bot_mb;     /* Bottom Memory block */
0028     u8  top_mb;     /* Top Memory block */
0029 };
0030 
0031 struct superhyway_ops {
0032     int (*read_vcr)(unsigned long base, struct superhyway_vcr_info *vcr);
0033     int (*write_vcr)(unsigned long base, struct superhyway_vcr_info vcr);
0034 };
0035 
0036 struct superhyway_bus {
0037     struct superhyway_ops *ops;
0038 };
0039 
0040 extern struct superhyway_bus superhyway_channels[];
0041 
0042 struct superhyway_device_id {
0043     unsigned int id;
0044     unsigned long driver_data;
0045 };
0046 
0047 struct superhyway_device;
0048 extern struct bus_type superhyway_bus_type;
0049 
0050 struct superhyway_driver {
0051     char *name;
0052 
0053     const struct superhyway_device_id *id_table;
0054     struct device_driver drv;
0055 
0056     int (*probe)(struct superhyway_device *dev, const struct superhyway_device_id *id);
0057     void (*remove)(struct superhyway_device *dev);
0058 };
0059 
0060 #define to_superhyway_driver(d) container_of((d), struct superhyway_driver, drv)
0061 
0062 struct superhyway_device {
0063     char name[32];
0064 
0065     struct device dev;
0066 
0067     struct superhyway_device_id id;
0068     struct superhyway_driver *drv;
0069     struct superhyway_bus *bus;
0070 
0071     int num_resources;
0072     struct resource *resource;
0073     struct superhyway_vcr_info vcr;
0074 };
0075 
0076 #define to_superhyway_device(d) container_of((d), struct superhyway_device, dev)
0077 
0078 #define superhyway_get_drvdata(d)   dev_get_drvdata(&(d)->dev)
0079 #define superhyway_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, (p))
0080 
0081 static inline int
0082 superhyway_read_vcr(struct superhyway_device *dev, unsigned long base,
0083             struct superhyway_vcr_info *vcr)
0084 {
0085     return dev->bus->ops->read_vcr(base, vcr);
0086 }
0087 
0088 static inline int
0089 superhyway_write_vcr(struct superhyway_device *dev, unsigned long base,
0090              struct superhyway_vcr_info vcr)
0091 {
0092     return dev->bus->ops->write_vcr(base, vcr);
0093 }
0094 
0095 extern int superhyway_scan_bus(struct superhyway_bus *);
0096 
0097 /* drivers/sh/superhyway/superhyway.c */
0098 int superhyway_register_driver(struct superhyway_driver *);
0099 void superhyway_unregister_driver(struct superhyway_driver *);
0100 int superhyway_add_device(unsigned long base, struct superhyway_device *, struct superhyway_bus *);
0101 int superhyway_add_devices(struct superhyway_bus *bus, struct superhyway_device **devices, int nr_devices);
0102 
0103 /* drivers/sh/superhyway/superhyway-sysfs.c */
0104 extern const struct attribute_group *superhyway_dev_groups[];
0105 
0106 #endif /* __LINUX_SUPERHYWAY_H */
0107