blob: befefd99e271a525a9a5175768501d199aa64887 [file] [log] [blame]
Johannes Bergf3d94782006-06-21 15:42:43 +02001/*
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
Johannes Bergf3d94782006-06-21 15:42:43 +020010#include <linux/interrupt.h>
Johannes Bergf3d94782006-06-21 15:42:43 +020011#include <linux/spinlock.h>
12#include <linux/mutex.h>
Paul Mackerras547ac2a2007-02-08 14:25:39 +010013#include <linux/completion.h>
Benjamin Herrenschmidt977c6022006-07-10 04:44:36 -070014
15#include <sound/pcm.h>
16
Johannes Bergf3d94782006-06-21 15:42:43 +020017#include <asm/prom.h>
Benjamin Herrenschmidt977c6022006-07-10 04:44:36 -070018#include <asm/pmac_feature.h>
19#include <asm/dbdma.h>
20
Johannes Berg888dcb72008-10-23 15:47:56 +020021#include "interface.h"
Johannes Bergf3d94782006-06-21 15:42:43 +020022#include "../soundbus.h"
23
24struct i2sbus_control {
Johannes Bergf3d94782006-06-21 15:42:43 +020025 struct list_head list;
Benjamin Herrenschmidt977c6022006-07-10 04:44:36 -070026 struct macio_chip *macio;
Johannes Bergf3d94782006-06-21 15:42:43 +020027};
28
29#define MAX_DBDMA_COMMANDS 32
30
31struct dbdma_command_mem {
32 dma_addr_t bus_addr;
33 dma_addr_t bus_cmd_start;
34 struct dbdma_cmd *cmds;
35 void *space;
36 int size;
37 u32 running:1;
Paul Mackerras547ac2a2007-02-08 14:25:39 +010038 u32 stopping:1;
Johannes Bergf3d94782006-06-21 15:42:43 +020039};
40
41struct pcm_info {
42 u32 created:1, /* has this direction been created with alsa? */
43 active:1; /* is this stream active? */
44 /* runtime information */
45 struct snd_pcm_substream *substream;
46 int current_period;
47 u32 frame_count;
48 struct dbdma_command_mem dbdma_ring;
49 volatile struct dbdma_regs __iomem *dbdma;
Paul Mackerras547ac2a2007-02-08 14:25:39 +010050 struct completion *stop_completion;
Johannes Bergf3d94782006-06-21 15:42:43 +020051};
52
Benjamin Herrenschmidt389ba792006-07-10 04:44:34 -070053enum {
54 aoa_resource_i2smmio = 0,
55 aoa_resource_txdbdma,
56 aoa_resource_rxdbdma,
57};
58
Johannes Bergf3d94782006-06-21 15:42:43 +020059struct i2sbus_dev {
60 struct soundbus_dev sound;
61 struct macio_dev *macio;
62 struct i2sbus_control *control;
63 volatile struct i2s_interface_regs __iomem *intfregs;
64
65 struct resource resources[3];
66 struct resource *allocated_resource[3];
67 int interrupts[3];
68 char rnames[3][32];
69
70 /* info about currently active substreams */
71 struct pcm_info out, in;
72 snd_pcm_format_t format;
73 unsigned int rate;
74
75 /* list for a single controller */
76 struct list_head item;
77 /* number of bus on controller */
78 int bus_number;
79 /* for use by control layer */
80 struct pmf_function *enable,
81 *cell_enable,
82 *cell_disable,
83 *clock_enable,
84 *clock_disable;
85
86 /* locks */
87 /* spinlock for low-level interrupt locking */
88 spinlock_t low_lock;
89 /* mutex for high-level consistency */
90 struct mutex lock;
91};
92
93#define soundbus_dev_to_i2sbus_dev(sdev) \
94 container_of(sdev, struct i2sbus_dev, sound)
95
96/* pcm specific functions */
97extern int
98i2sbus_attach_codec(struct soundbus_dev *dev, struct snd_card *card,
99 struct codec_info *ci, void *data);
100extern void
101i2sbus_detach_codec(struct soundbus_dev *dev, void *data);
102extern irqreturn_t
David Howells7d12e782006-10-05 14:55:46 +0100103i2sbus_tx_intr(int irq, void *devid);
Johannes Bergf3d94782006-06-21 15:42:43 +0200104extern irqreturn_t
David Howells7d12e782006-10-05 14:55:46 +0100105i2sbus_rx_intr(int irq, void *devid);
Johannes Bergf3d94782006-06-21 15:42:43 +0200106
Paul Mackerras547ac2a2007-02-08 14:25:39 +0100107extern void i2sbus_wait_for_stop_both(struct i2sbus_dev *i2sdev);
108extern void i2sbus_pcm_prepare_both(struct i2sbus_dev *i2sdev);
109
Johannes Bergf3d94782006-06-21 15:42:43 +0200110/* control specific functions */
111extern int i2sbus_control_init(struct macio_dev* dev,
112 struct i2sbus_control **c);
113extern void i2sbus_control_destroy(struct i2sbus_control *c);
114extern int i2sbus_control_add_dev(struct i2sbus_control *c,
115 struct i2sbus_dev *i2sdev);
116extern void i2sbus_control_remove_dev(struct i2sbus_control *c,
117 struct i2sbus_dev *i2sdev);
118extern int i2sbus_control_enable(struct i2sbus_control *c,
119 struct i2sbus_dev *i2sdev);
120extern int i2sbus_control_cell(struct i2sbus_control *c,
121 struct i2sbus_dev *i2sdev,
122 int enable);
123extern int i2sbus_control_clock(struct i2sbus_control *c,
124 struct i2sbus_dev *i2sdev,
125 int enable);
126#endif /* __I2SBUS_H */