diff options
Diffstat (limited to 'sound/aoa/soundbus/i2sbus/i2sbus-control.c')
-rw-r--r-- | sound/aoa/soundbus/i2sbus/i2sbus-control.c | 79 |
1 files changed, 40 insertions, 39 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 | ||
17 | int i2sbus_control_init(struct macio_dev* dev, struct i2sbus_control **c) | 21 | 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) | |||
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 | ||
42 | void i2sbus_control_destroy(struct i2sbus_control *c) | 33 | void 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; |