Skip to content

Commit 977c602

Browse files
ozbenhLinus Torvalds
authored andcommitted
[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>
1 parent a08bc4c commit 977c602

3 files changed

Lines changed: 47 additions & 81 deletions

File tree

‎sound/aoa/soundbus/i2sbus/i2sbus-control.c‎

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
* GPL v2, can be found in COPYING.
77
*/
88

9-
#include <asm/io.h>
9+
#include <linux/kernel.h>
1010
#include <linux/delay.h>
11+
12+
#include <asm/io.h>
1113
#include <asm/prom.h>
1214
#include <asm/macio.h>
1315
#include <asm/pmac_feature.h>
1416
#include <asm/pmac_pfunc.h>
17+
#include <asm/keylargo.h>
18+
1519
#include "i2sbus.h"
1620

1721
int 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)
2226

2327
INIT_LIST_HEAD(&(*c)->list);
2428

25-
if (of_address_to_resource(dev->ofdev.node, 0, &(*c)->rsrc))
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-
29+
(*c)->macio = dev->bus->chip;
3530
return 0;
36-
err:
37-
kfree(*c);
38-
*c = NULL;
39-
return -ENODEV;
4031
}
4132

4233
void i2sbus_control_destroy(struct i2sbus_control *c)
4334
{
44-
iounmap(c->controlregs);
4535
kfree(c);
4636
}
4737

@@ -93,19 +83,22 @@ int i2sbus_control_enable(struct i2sbus_control *c,
9383
struct i2sbus_dev *i2sdev)
9484
{
9585
struct pmf_args args = { .count = 0 };
96-
int cc;
86+
struct macio_chip *macio = c->macio;
9787

9888
if (i2sdev->enable)
9989
return pmf_call_one(i2sdev->enable, &args);
10090

91+
if (macio == NULL || macio->base == NULL)
92+
return -ENODEV;
93+
10194
switch (i2sdev->bus_number) {
10295
case 0:
103-
cc = in_le32(&c->controlregs->cell_control);
104-
out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_0_ENABLE);
96+
/* these need to be locked or done through
97+
* newly created feature calls! */
98+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
10599
break;
106100
case 1:
107-
cc = in_le32(&c->controlregs->cell_control);
108-
out_le32(&c->controlregs->cell_control, cc | CTRL_CLOCK_INTF_1_ENABLE);
101+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_ENABLE);
109102
break;
110103
default:
111104
return -ENODEV;
@@ -118,7 +111,7 @@ int i2sbus_control_cell(struct i2sbus_control *c,
118111
int enable)
119112
{
120113
struct pmf_args args = { .count = 0 };
121-
int cc;
114+
struct macio_chip *macio = c->macio;
122115

123116
switch (enable) {
124117
case 0:
@@ -133,18 +126,22 @@ int i2sbus_control_cell(struct i2sbus_control *c,
133126
printk(KERN_ERR "i2sbus: INVALID CELL ENABLE VALUE\n");
134127
return -ENODEV;
135128
}
129+
130+
if (macio == NULL || macio->base == NULL)
131+
return -ENODEV;
132+
136133
switch (i2sdev->bus_number) {
137134
case 0:
138-
cc = in_le32(&c->controlregs->cell_control);
139-
cc &= ~CTRL_CLOCK_CELL_0_ENABLE;
140-
cc |= enable * CTRL_CLOCK_CELL_0_ENABLE;
141-
out_le32(&c->controlregs->cell_control, cc);
135+
if (enable)
136+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
137+
else
138+
MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE);
142139
break;
143140
case 1:
144-
cc = in_le32(&c->controlregs->cell_control);
145-
cc &= ~CTRL_CLOCK_CELL_1_ENABLE;
146-
cc |= enable * CTRL_CLOCK_CELL_1_ENABLE;
147-
out_le32(&c->controlregs->cell_control, cc);
141+
if (enable)
142+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
143+
else
144+
MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CELL_ENABLE);
148145
break;
149146
default:
150147
return -ENODEV;
@@ -157,7 +154,7 @@ int i2sbus_control_clock(struct i2sbus_control *c,
157154
int enable)
158155
{
159156
struct pmf_args args = { .count = 0 };
160-
int cc;
157+
struct macio_chip *macio = c->macio;
161158

162159
switch (enable) {
163160
case 0:
@@ -172,18 +169,22 @@ int i2sbus_control_clock(struct i2sbus_control *c,
172169
printk(KERN_ERR "i2sbus: INVALID CLOCK ENABLE VALUE\n");
173170
return -ENODEV;
174171
}
172+
173+
if (macio == NULL || macio->base == NULL)
174+
return -ENODEV;
175+
175176
switch (i2sdev->bus_number) {
176177
case 0:
177-
cc = in_le32(&c->controlregs->cell_control);
178-
cc &= ~CTRL_CLOCK_CLOCK_0_ENABLE;
179-
cc |= enable * CTRL_CLOCK_CLOCK_0_ENABLE;
180-
out_le32(&c->controlregs->cell_control, cc);
178+
if (enable)
179+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
180+
else
181+
MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
181182
break;
182183
case 1:
183-
cc = in_le32(&c->controlregs->cell_control);
184-
cc &= ~CTRL_CLOCK_CLOCK_1_ENABLE;
185-
cc |= enable * CTRL_CLOCK_CLOCK_1_ENABLE;
186-
out_le32(&c->controlregs->cell_control, cc);
184+
if (enable)
185+
MACIO_BIS(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
186+
else
187+
MACIO_BIC(KEYLARGO_FCR1, KL1_I2S1_CLK_ENABLE_BIT);
187188
break;
188189
default:
189190
return -ENODEV;

‎sound/aoa/soundbus/i2sbus/i2sbus-control.h‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎sound/aoa/soundbus/i2sbus/i2sbus.h‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@
77
*/
88
#ifndef __I2SBUS_H
99
#define __I2SBUS_H
10-
#include <asm/dbdma.h>
1110
#include <linux/interrupt.h>
12-
#include <sound/pcm.h>
1311
#include <linux/spinlock.h>
1412
#include <linux/mutex.h>
13+
14+
#include <sound/pcm.h>
15+
1516
#include <asm/prom.h>
17+
#include <asm/pmac_feature.h>
18+
#include <asm/dbdma.h>
19+
1620
#include "i2sbus-interface.h"
17-
#include "i2sbus-control.h"
1821
#include "../soundbus.h"
1922

2023
struct i2sbus_control {
21-
volatile struct i2s_control_regs __iomem *controlregs;
22-
struct resource rsrc;
2324
struct list_head list;
25+
struct macio_chip *macio;
2426
};
2527

2628
#define MAX_DBDMA_COMMANDS 32

0 commit comments

Comments
 (0)