1 /* 2 * i2sbus driver -- private definitions 3 * 4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 5 * 6 * GPL v2, can be found in COPYING. 7 */ 8 #ifndef __I2SBUS_H 9 #define __I2SBUS_H 10 #include <linux/interrupt.h> 11 #include <linux/spinlock.h> 12 #include <linux/mutex.h> 13 14 #include <sound/pcm.h> 15 16 #include <asm/prom.h> 17 #include <asm/pmac_feature.h> 18 #include <asm/dbdma.h> 19 20 #include "i2sbus-interface.h" 21 #include "../soundbus.h" 22 23 struct i2sbus_control { 24 struct list_head list; 25 struct macio_chip *macio; 26 }; 27 28 #define MAX_DBDMA_COMMANDS 32 29 30 struct dbdma_command_mem { 31 dma_addr_t bus_addr; 32 dma_addr_t bus_cmd_start; 33 struct dbdma_cmd *cmds; 34 void *space; 35 int size; 36 u32 running:1; 37 }; 38 39 struct pcm_info { 40 u32 created:1, /* has this direction been created with alsa? */ 41 active:1; /* is this stream active? */ 42 /* runtime information */ 43 struct snd_pcm_substream *substream; 44 int current_period; 45 u32 frame_count; 46 struct dbdma_command_mem dbdma_ring; 47 volatile struct dbdma_regs __iomem *dbdma; 48 }; 49 50 enum { 51 aoa_resource_i2smmio = 0, 52 aoa_resource_txdbdma, 53 aoa_resource_rxdbdma, 54 }; 55 56 struct i2sbus_dev { 57 struct soundbus_dev sound; 58 struct macio_dev *macio; 59 struct i2sbus_control *control; 60 volatile struct i2s_interface_regs __iomem *intfregs; 61 62 struct resource resources[3]; 63 struct resource *allocated_resource[3]; 64 int interrupts[3]; 65 char rnames[3][32]; 66 67 /* info about currently active substreams */ 68 struct pcm_info out, in; 69 snd_pcm_format_t format; 70 unsigned int rate; 71 72 /* list for a single controller */ 73 struct list_head item; 74 /* number of bus on controller */ 75 int bus_number; 76 /* for use by control layer */ 77 struct pmf_function *enable, 78 *cell_enable, 79 *cell_disable, 80 *clock_enable, 81 *clock_disable; 82 83 /* locks */ 84 /* spinlock for low-level interrupt locking */ 85 spinlock_t low_lock; 86 /* mutex for high-level consistency */ 87 struct mutex lock; 88 }; 89 90 #define soundbus_dev_to_i2sbus_dev(sdev) \ 91 container_of(sdev, struct i2sbus_dev, sound) 92 93 /* pcm specific functions */ 94 extern int 95 i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card, 96 struct codec_info *ci, void *data); 97 extern void 98 i2sbus_detach_codec(struct soundbus_dev *dev, void *data); 99 extern irqreturn_t 100 i2sbus_tx_intr(int irq, void *devid, struct pt_regs *regs); 101 extern irqreturn_t 102 i2sbus_rx_intr(int irq, void *devid, struct pt_regs *regs); 103 104 /* control specific functions */ 105 extern int i2sbus_control_init(struct macio_dev* dev, 106 struct i2sbus_control **c); 107 extern void i2sbus_control_destroy(struct i2sbus_control *c); 108 extern int i2sbus_control_add_dev(struct i2sbus_control *c, 109 struct i2sbus_dev *i2sdev); 110 extern void i2sbus_control_remove_dev(struct i2sbus_control *c, 111 struct i2sbus_dev *i2sdev); 112 extern int i2sbus_control_enable(struct i2sbus_control *c, 113 struct i2sbus_dev *i2sdev); 114 extern int i2sbus_control_cell(struct i2sbus_control *c, 115 struct i2sbus_dev *i2sdev, 116 int enable); 117 extern int i2sbus_control_clock(struct i2sbus_control *c, 118 struct i2sbus_dev *i2sdev, 119 int enable); 120 #endif /* __I2SBUS_H */ 121