~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/include/asm/macio.h

Version: ~ [ linux-5.3 ] ~ [ linux-5.2.15 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.73 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.144 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.193 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.193 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.73 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __MACIO_ASIC_H__
  2 #define __MACIO_ASIC_H__
  3 #ifdef __KERNEL__
  4 
  5 #include <linux/of_device.h>
  6 
  7 extern struct bus_type macio_bus_type;
  8 
  9 /* MacIO device driver is defined later */
 10 struct macio_driver;
 11 struct macio_chip;
 12 
 13 #define MACIO_DEV_COUNT_RESOURCES       8
 14 #define MACIO_DEV_COUNT_IRQS            8
 15 
 16 /*
 17  * the macio_bus structure is used to describe a "virtual" bus
 18  * within a MacIO ASIC. It's typically provided by a macio_pci_asic
 19  * PCI device, but could be provided differently as well (nubus
 20  * machines using a fake OF tree).
 21  *
 22  * The pdev field can be NULL on non-PCI machines
 23  */
 24 struct macio_bus
 25 {
 26         struct macio_chip       *chip;          /* macio_chip (private use) */
 27         int                     index;          /* macio chip index in system */
 28 #ifdef CONFIG_PCI
 29         struct pci_dev          *pdev;          /* PCI device hosting this bus */
 30 #endif
 31 };
 32 
 33 /*
 34  * the macio_dev structure is used to describe a device
 35  * within an Apple MacIO ASIC.
 36  */
 37 struct macio_dev
 38 {
 39         struct macio_bus        *bus;           /* macio bus this device is on */
 40         struct macio_dev        *media_bay;     /* Device is part of a media bay */
 41         struct platform_device  ofdev;
 42         struct device_dma_parameters dma_parms; /* ide needs that */
 43         int                     n_resources;
 44         struct resource         resource[MACIO_DEV_COUNT_RESOURCES];
 45         int                     n_interrupts;
 46         struct resource         interrupt[MACIO_DEV_COUNT_IRQS];
 47 };
 48 #define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
 49 #define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
 50 
 51 extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
 52 extern void macio_dev_put(struct macio_dev *dev);
 53 
 54 /*
 55  * Accessors to resources & interrupts and other device
 56  * fields
 57  */
 58 
 59 static inline int macio_resource_count(struct macio_dev *dev)
 60 {
 61         return dev->n_resources;
 62 }
 63 
 64 static inline unsigned long macio_resource_start(struct macio_dev *dev, int resource_no)
 65 {
 66         return dev->resource[resource_no].start;
 67 }
 68 
 69 static inline unsigned long macio_resource_end(struct macio_dev *dev, int resource_no)
 70 {
 71         return dev->resource[resource_no].end;
 72 }
 73 
 74 static inline unsigned long macio_resource_len(struct macio_dev *dev, int resource_no)
 75 {
 76         struct resource *res = &dev->resource[resource_no];
 77         if (res->start == 0 || res->end == 0 || res->end < res->start)
 78                 return 0;
 79         return resource_size(res);
 80 }
 81 
 82 extern int macio_enable_devres(struct macio_dev *dev);
 83 
 84 extern int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name);
 85 extern void macio_release_resource(struct macio_dev *dev, int resource_no);
 86 extern int macio_request_resources(struct macio_dev *dev, const char *name);
 87 extern void macio_release_resources(struct macio_dev *dev);
 88 
 89 static inline int macio_irq_count(struct macio_dev *dev)
 90 {
 91         return dev->n_interrupts;
 92 }
 93 
 94 static inline int macio_irq(struct macio_dev *dev, int irq_no)
 95 {
 96         return dev->interrupt[irq_no].start;
 97 }
 98 
 99 static inline void macio_set_drvdata(struct macio_dev *dev, void *data)
100 {
101         dev_set_drvdata(&dev->ofdev.dev, data);
102 }
103 
104 static inline void* macio_get_drvdata(struct macio_dev *dev)
105 {
106         return dev_get_drvdata(&dev->ofdev.dev);
107 }
108 
109 static inline struct device_node *macio_get_of_node(struct macio_dev *mdev)
110 {
111         return mdev->ofdev.dev.of_node;
112 }
113 
114 #ifdef CONFIG_PCI
115 static inline struct pci_dev *macio_get_pci_dev(struct macio_dev *mdev)
116 {
117         return mdev->bus->pdev;
118 }
119 #endif
120 
121 /*
122  * A driver for a mac-io chip based device
123  */
124 struct macio_driver
125 {
126         int     (*probe)(struct macio_dev* dev, const struct of_device_id *match);
127         int     (*remove)(struct macio_dev* dev);
128 
129         int     (*suspend)(struct macio_dev* dev, pm_message_t state);
130         int     (*resume)(struct macio_dev* dev);
131         int     (*shutdown)(struct macio_dev* dev);
132 
133 #ifdef CONFIG_PMAC_MEDIABAY
134         void    (*mediabay_event)(struct macio_dev* dev, int mb_state);
135 #endif
136         struct device_driver    driver;
137 };
138 #define to_macio_driver(drv) container_of(drv,struct macio_driver, driver)
139 
140 extern int macio_register_driver(struct macio_driver *);
141 extern void macio_unregister_driver(struct macio_driver *);
142 
143 #endif /* __KERNEL__ */
144 #endif /* __MACIO_ASIC_H__ */
145 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp