Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: ebus.h,v 1.10 2001/03/14 05:00:55 davem Exp $ |
| 2 | * ebus.h: PCI to Ebus pseudo driver software state. |
| 3 | * |
| 4 | * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) |
| 5 | * Copyright (C) 1999 David S. Miller (davem@redhat.com) |
| 6 | */ |
| 7 | |
| 8 | #ifndef __SPARC64_EBUS_H |
| 9 | #define __SPARC64_EBUS_H |
| 10 | |
| 11 | #include <asm/pbm.h> |
| 12 | #include <asm/oplib.h> |
David S. Miller | 690c8fd | 2006-06-22 19:12:03 -0700 | [diff] [blame] | 13 | #include <asm/prom.h> |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 14 | #include <asm/of_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
| 16 | struct linux_ebus_child { |
| 17 | struct linux_ebus_child *next; |
| 18 | struct linux_ebus_device *parent; |
| 19 | struct linux_ebus *bus; |
David S. Miller | 690c8fd | 2006-06-22 19:12:03 -0700 | [diff] [blame] | 20 | struct device_node *prom_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | struct resource resource[PROMREG_MAX]; |
| 22 | int num_addrs; |
| 23 | unsigned int irqs[PROMINTR_MAX]; |
| 24 | int num_irqs; |
| 25 | }; |
| 26 | |
| 27 | struct linux_ebus_device { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 28 | struct of_device ofdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | struct linux_ebus_device *next; |
| 30 | struct linux_ebus_child *children; |
| 31 | struct linux_ebus *bus; |
David S. Miller | 690c8fd | 2006-06-22 19:12:03 -0700 | [diff] [blame] | 32 | struct device_node *prom_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | struct resource resource[PROMREG_MAX]; |
| 34 | int num_addrs; |
| 35 | unsigned int irqs[PROMINTR_MAX]; |
| 36 | int num_irqs; |
| 37 | }; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 38 | #define to_ebus_device(d) container_of(d, struct linux_ebus_device, ofdev.dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | struct linux_ebus { |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 41 | struct of_device ofdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | struct linux_ebus *next; |
| 43 | struct linux_ebus_device *devices; |
| 44 | struct pci_pbm_info *parent; |
| 45 | struct pci_dev *self; |
| 46 | int index; |
| 47 | int is_rio; |
David S. Miller | 690c8fd | 2006-06-22 19:12:03 -0700 | [diff] [blame] | 48 | struct device_node *prom_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | }; |
David S. Miller | a2bd4fd | 2006-06-23 01:44:10 -0700 | [diff] [blame] | 50 | #define to_ebus(d) container_of(d, struct linux_ebus, ofdev.dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | struct ebus_dma_info { |
| 53 | spinlock_t lock; |
| 54 | void __iomem *regs; |
| 55 | |
| 56 | unsigned int flags; |
| 57 | #define EBUS_DMA_FLAG_USE_EBDMA_HANDLER 0x00000001 |
| 58 | #define EBUS_DMA_FLAG_TCI_DISABLE 0x00000002 |
| 59 | |
| 60 | /* These are only valid is EBUS_DMA_FLAG_USE_EBDMA_HANDLER is |
| 61 | * set. |
| 62 | */ |
| 63 | void (*callback)(struct ebus_dma_info *p, int event, void *cookie); |
| 64 | void *client_cookie; |
| 65 | unsigned int irq; |
| 66 | #define EBUS_DMA_EVENT_ERROR 1 |
| 67 | #define EBUS_DMA_EVENT_DMA 2 |
| 68 | #define EBUS_DMA_EVENT_DEVICE 4 |
| 69 | |
| 70 | unsigned char name[64]; |
| 71 | }; |
| 72 | |
| 73 | extern int ebus_dma_register(struct ebus_dma_info *p); |
| 74 | extern int ebus_dma_irq_enable(struct ebus_dma_info *p, int on); |
| 75 | extern void ebus_dma_unregister(struct ebus_dma_info *p); |
| 76 | extern int ebus_dma_request(struct ebus_dma_info *p, dma_addr_t bus_addr, |
| 77 | size_t len); |
| 78 | extern void ebus_dma_prepare(struct ebus_dma_info *p, int write); |
| 79 | extern unsigned int ebus_dma_residue(struct ebus_dma_info *p); |
Georg Chini | b128254 | 2005-11-07 14:09:19 -0800 | [diff] [blame] | 80 | extern unsigned int ebus_dma_addr(struct ebus_dma_info *p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | extern void ebus_dma_enable(struct ebus_dma_info *p, int on); |
| 82 | |
| 83 | extern struct linux_ebus *ebus_chain; |
| 84 | |
| 85 | extern void ebus_init(void); |
| 86 | |
| 87 | #define for_each_ebus(bus) \ |
| 88 | for((bus) = ebus_chain; (bus); (bus) = (bus)->next) |
| 89 | |
| 90 | #define for_each_ebusdev(dev, bus) \ |
| 91 | for((dev) = (bus)->devices; (dev); (dev) = (dev)->next) |
| 92 | |
| 93 | #define for_each_edevchild(dev, child) \ |
| 94 | for((child) = (dev)->children; (child); (child) = (child)->next) |
| 95 | |
| 96 | #endif /* !(__SPARC64_EBUS_H) */ |