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