aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-07-10 07:44:36 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-10 16:24:19 -0400
commit977c60238cfff1f9eb07cfd78bc02da91b7b499b (patch)
treee44a3e190aa857d1d843366ead8929fd0fe163a6 /sound
parenta08bc4cb09dfea4cb1d29061d82b04338ed7c21a (diff)
[PATCH] aoa: i2sbus: revamp control layer
This patch revamps the i2sbus control layer by using the macio/keylargo functions instead of directly mapping. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-control.c79
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-control.h37
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus.h12
3 files changed, 47 insertions, 81 deletions
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-control.c b/sound/aoa/soundbus/i2sbus/i2sbus-control.c
index f50407952d3c..87beb4ad4d63 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-control.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-control.c
@@ -6,12 +6,16 @@
6 * GPL v2, can be found in COPYING. 6 * GPL v2, can be found in COPYING.
7 */ 7 */
8 8
9#include <asm/io.h> 9#include <linux/kernel.h>
10#include <linux/delay.h> 10#include <linux/delay.h>
11
12#include <asm/io.h>
11#include <asm/prom.h> 13#include <asm/prom.h>
12#include <asm/macio.h> 14#include <asm/macio.h>
13#include <asm/pmac_feature.h> 15#include <asm/pmac_feature.h>
14#include <asm/pmac_pfunc.h> 16#include <asm/pmac_pfunc.h>
17#include <asm/keylargo.h>
18
15#include "i2sbus.h" 19#include "i2sbus.h"
16 20
17int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c) 21int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c)
@@ -22,26 +26,12 @@ int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c)
22 26
23 INIT_LIST_HEAD(&(*c)->list); 27 INIT_LIST_HEAD(&(*c)->list);
24 28
25 if (of_address_to_resource(dev->ofdev.node, 0, &(*c)->rsrc)) 29 (*c)->macio = dev->bus->chip;
26 goto err;
27 /* we really should be using feature calls instead of mapping
28 * these registers. It's safe for now since no one else is
29 * touching them... */
30 (*c)->controlregs = ioremap((*c)->rsrc.start,
31 sizeof(struct i2s_control_regs));
32 if (!(*c)->controlregs)
33 goto err;
34
35 return 0; 30 return 0;
36 err:
37 kfree(*c);
38 *c = NULL;
39 return -ENODEV;
40} 31}
41 32
42void i2sbus_control_destroy(struct i2sbus_control *c) 33void i2sbus_control_destroy(struct i2sbus_control *c)
43{ 34{
44 iounmap(c->controlregs);
45 kfree(c); 35 kfree(c);
46} 36}
47 37
@@ -93,19 +83,22 @@ int i2sbus_control_enable(struct i2sbus_control *c,
93 struct i2sbus_dev *i2sdev) 83 struct i2sbus_dev *i2sdev)
94{ 84{
95 struct pmf_args args = { .count = 0 }; 85 struct pmf_args args = { .count = 0 };
96 int cc; 86 struct macio_chip *macio = c->macio;
97 87
98 if (i2sdev->enable) 88 if (i2sdev->enable)
99 return pmf_call_one(i2sdev->enable, &args); 89 return pmf_call_one(i2sdev->enable, &args);
100 90
91 if (macio == NULL || macio->base == NULL)
92 return -ENODEV;
93
101 switch (i2sdev->bus_number) { 94 switch (i2sdev->bus_number) {
102 case 0: 95 case 0:
103 cc = in_le32(&c->controlregs->cell_control); 96 /* these need to be locked or done through
104 out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_0_ENABLE); 97 * newly created feature calls! */
98 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
105 break; 99 break;
106 case 1: 100 case 1:
107 cc = in_le32(&c->controlregs->cell_control); 101 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_ENABLE);
108 out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_1_ENABLE);
109 break; 102 break;
110 default: 103 default:
111 return -ENODEV; 104 return -ENODEV;
@@ -118,7 +111,7 @@ int i2sbus_control_cell(struct i2sbus_control *c,
118 int enable) 111 int enable)
119{ 112{
120 struct pmf_args args = { .count = 0 }; 113 struct pmf_args args = { .count = 0 };
121 int cc; 114 struct macio_chip *macio = c->macio;
122 115
123 switch (enable) { 116 switch (enable) {
124 case 0: 117 case 0:
@@ -133,18 +126,22 @@ int i2sbus_control_cell(struct i2sbus_control *c,
133 printk(KERN_ERR "i2sbus: INVALID CELL ENABLE VALUE\n"); 126 printk(KERN_ERR "i2sbus: INVALID CELL ENABLE VALUE\n");
134 return -ENODEV; 127 return -ENODEV;
135 } 128 }
129
130 if (macio == NULL || macio->base == NULL)
131 return -ENODEV;
132
136 switch (i2sdev->bus_number) { 133 switch (i2sdev->bus_number) {
137 case 0: 134 case 0:
138 cc = in_le32(&c->controlregs->cell_control); 135 if (enable)
139 cc &= ~CTRL_CLOCK_CELL_0_ENABLE; 136 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
140 cc |= enable * CTRL_CLOCK_CELL_0_ENABLE; 137 else
141 out_le32(&c->controlregs->cell_control, cc); 138 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
142 break; 139 break;
143 case 1: 140 case 1:
144 cc = in_le32(&c->controlregs->cell_control); 141 if (enable)
145 cc &= ~CTRL_CLOCK_CELL_1_ENABLE; 142 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
146 cc |= enable * CTRL_CLOCK_CELL_1_ENABLE; 143 else
147 out_le32(&c->controlregs->cell_control, cc); 144 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
148 break; 145 break;
149 default: 146 default:
150 return -ENODEV; 147 return -ENODEV;
@@ -157,7 +154,7 @@ int i2sbus_control_clock(struct i2sbus_control *c,
157 int enable) 154 int enable)
158{ 155{
159 struct pmf_args args = { .count = 0 }; 156 struct pmf_args args = { .count = 0 };
160 int cc; 157 struct macio_chip *macio = c->macio;
161 158
162 switch (enable) { 159 switch (enable) {
163 case 0: 160 case 0:
@@ -172,18 +169,22 @@ int i2sbus_control_clock(struct i2sbus_control *c,
172 printk(KERN_ERR "i2sbus: INVALID CLOCK ENABLE VALUE\n"); 169 printk(KERN_ERR "i2sbus: INVALID CLOCK ENABLE VALUE\n");
173 return -ENODEV; 170 return -ENODEV;
174 } 171 }
172
173 if (macio == NULL || macio->base == NULL)
174 return -ENODEV;
175
175 switch (i2sdev->bus_number) { 176 switch (i2sdev->bus_number) {
176 case 0: 177 case 0:
177 cc = in_le32(&c->controlregs->cell_control); 178 if (enable)
178 cc &= ~CTRL_CLOCK_CLOCK_0_ENABLE; 179 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
179 cc |= enable * CTRL_CLOCK_CLOCK_0_ENABLE; 180 else
180 out_le32(&c->controlregs->cell_control, cc); 181 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
181 break; 182 break;
182 case 1: 183 case 1:
183 cc = in_le32(&c->controlregs->cell_control); 184 if (enable)
184 cc &= ~CTRL_CLOCK_CLOCK_1_ENABLE; 185 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
185 cc |= enable * CTRL_CLOCK_CLOCK_1_ENABLE; 186 else
186 out_le32(&c->controlregs->cell_control, cc); 187 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
187 break; 188 break;
188 default: 189 default:
189 return -ENODEV; 190 return -ENODEV;
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-control.h b/sound/aoa/soundbus/i2sbus/i2sbus-control.h
deleted file mode 100644
index bb05550f730b..000000000000
--- a/sound/aoa/soundbus/i2sbus/i2sbus-control.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * i2sbus driver -- bus register definitions
3 *
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPL v2, can be found in COPYING.
7 */
8#ifndef __I2SBUS_CONTROLREGS_H
9#define __I2SBUS_CONTROLREGS_H
10
11/* i2s control registers, at least what we know about them */
12
13#define __PAD(m,n) u8 __pad##m[n]
14#define _PAD(line, n) __PAD(line, n)
15#define PAD(n) _PAD(__LINE__, (n))
16struct i2s_control_regs {
17 PAD(0x38);
18 __le32 fcr0; /* 0x38 (unknown) */
19 __le32 cell_control; /* 0x3c (fcr1) */
20 __le32 fcr2; /* 0x40 (unknown) */
21 __le32 fcr3; /* 0x44 (fcr3) */
22 __le32 clock_control; /* 0x48 (unknown) */
23 PAD(4);
24 /* total size: 0x50 bytes */
25} __attribute__((__packed__));
26
27#define CTRL_CLOCK_CELL_0_ENABLE (1<<10)
28#define CTRL_CLOCK_CLOCK_0_ENABLE (1<<12)
29#define CTRL_CLOCK_SWRESET_0 (1<<11)
30#define CTRL_CLOCK_INTF_0_ENABLE (1<<13)
31
32#define CTRL_CLOCK_CELL_1_ENABLE (1<<17)
33#define CTRL_CLOCK_CLOCK_1_ENABLE (1<<18)
34#define CTRL_CLOCK_SWRESET_1 (1<<19)
35#define CTRL_CLOCK_INTF_1_ENABLE (1<<20)
36
37#endif /* __I2SBUS_CONTROLREGS_H */
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus.h b/sound/aoa/soundbus/i2sbus/i2sbus.h
index d32f8a9724d7..0c69d209be50 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus.h
+++ b/sound/aoa/soundbus/i2sbus/i2sbus.h
@@ -7,20 +7,22 @@
7 */ 7 */
8#ifndef __I2SBUS_H 8#ifndef __I2SBUS_H
9#define __I2SBUS_H 9#define __I2SBUS_H
10#include <asm/dbdma.h>
11#include <linux/interrupt.h> 10#include <linux/interrupt.h>
12#include <sound/pcm.h>
13#include <linux/spinlock.h> 11#include <linux/spinlock.h>
14#include <linux/mutex.h> 12#include <linux/mutex.h>
13
14#include <sound/pcm.h>
15
15#include <asm/prom.h> 16#include <asm/prom.h>
17#include <asm/pmac_feature.h>
18#include <asm/dbdma.h>
19
16#include "i2sbus-interface.h" 20#include "i2sbus-interface.h"
17#include "i2sbus-control.h"
18#include "../soundbus.h" 21#include "../soundbus.h"
19 22
20struct i2sbus_control { 23struct i2sbus_control {
21 volatile struct i2s_control_regs __iomem *controlregs;
22 struct resource rsrc;
23 struct list_head list; 24 struct list_head list;
25 struct macio_chip *macio;
24}; 26};
25 27
26#define MAX_DBDMA_COMMANDS 32 28#define MAX_DBDMA_COMMANDS 32