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