diff options
author | Jaya Kumar <jayakumar.lkml@gmail.com> | 2010-03-10 18:21:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-12 18:52:34 -0500 |
commit | 2afb18981739a1426af2a6c952e03c5966b3dfc6 (patch) | |
tree | fb1feeb9e7882a4810bf9088959e33a1148bc090 /drivers/video | |
parent | e17cea3cece6d3ec47a5b358821505943abe6541 (diff) |
broadsheetfb: add MMIO hooks
Allow boards with GP-MMIO controllers to provide hooks to broadsheetfb in
order to offload cmd/data writes and data reads instead of relying only on
host based GPIO wiggling.
Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/broadsheetfb.c | 110 |
1 files changed, 94 insertions, 16 deletions
diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c index 8f011062dec5..57dc1a0065c2 100644 --- a/drivers/video/broadsheetfb.c +++ b/drivers/video/broadsheetfb.c | |||
@@ -115,30 +115,30 @@ static struct fb_var_screeninfo broadsheetfb_var __devinitdata = { | |||
115 | }; | 115 | }; |
116 | 116 | ||
117 | /* main broadsheetfb functions */ | 117 | /* main broadsheetfb functions */ |
118 | static void broadsheet_issue_data(struct broadsheetfb_par *par, u16 data) | 118 | static void broadsheet_gpio_issue_data(struct broadsheetfb_par *par, u16 data) |
119 | { | 119 | { |
120 | par->board->set_ctl(par, BS_WR, 0); | 120 | par->board->set_ctl(par, BS_WR, 0); |
121 | par->board->set_hdb(par, data); | 121 | par->board->set_hdb(par, data); |
122 | par->board->set_ctl(par, BS_WR, 1); | 122 | par->board->set_ctl(par, BS_WR, 1); |
123 | } | 123 | } |
124 | 124 | ||
125 | static void broadsheet_issue_cmd(struct broadsheetfb_par *par, u16 data) | 125 | static void broadsheet_gpio_issue_cmd(struct broadsheetfb_par *par, u16 data) |
126 | { | 126 | { |
127 | par->board->set_ctl(par, BS_DC, 0); | 127 | par->board->set_ctl(par, BS_DC, 0); |
128 | broadsheet_issue_data(par, data); | 128 | broadsheet_gpio_issue_data(par, data); |
129 | } | 129 | } |
130 | 130 | ||
131 | static void broadsheet_send_command(struct broadsheetfb_par *par, u16 data) | 131 | static void broadsheet_gpio_send_command(struct broadsheetfb_par *par, u16 data) |
132 | { | 132 | { |
133 | par->board->wait_for_rdy(par); | 133 | par->board->wait_for_rdy(par); |
134 | 134 | ||
135 | par->board->set_ctl(par, BS_CS, 0); | 135 | par->board->set_ctl(par, BS_CS, 0); |
136 | broadsheet_issue_cmd(par, data); | 136 | broadsheet_gpio_issue_cmd(par, data); |
137 | par->board->set_ctl(par, BS_DC, 1); | 137 | par->board->set_ctl(par, BS_DC, 1); |
138 | par->board->set_ctl(par, BS_CS, 1); | 138 | par->board->set_ctl(par, BS_CS, 1); |
139 | } | 139 | } |
140 | 140 | ||
141 | static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | 141 | static void broadsheet_gpio_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, |
142 | int argc, u16 *argv) | 142 | int argc, u16 *argv) |
143 | { | 143 | { |
144 | int i; | 144 | int i; |
@@ -146,15 +146,43 @@ static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | |||
146 | par->board->wait_for_rdy(par); | 146 | par->board->wait_for_rdy(par); |
147 | 147 | ||
148 | par->board->set_ctl(par, BS_CS, 0); | 148 | par->board->set_ctl(par, BS_CS, 0); |
149 | broadsheet_issue_cmd(par, cmd); | 149 | broadsheet_gpio_issue_cmd(par, cmd); |
150 | par->board->set_ctl(par, BS_DC, 1); | 150 | par->board->set_ctl(par, BS_DC, 1); |
151 | 151 | ||
152 | for (i = 0; i < argc; i++) | 152 | for (i = 0; i < argc; i++) |
153 | broadsheet_issue_data(par, argv[i]); | 153 | broadsheet_gpio_issue_data(par, argv[i]); |
154 | par->board->set_ctl(par, BS_CS, 1); | 154 | par->board->set_ctl(par, BS_CS, 1); |
155 | } | 155 | } |
156 | 156 | ||
157 | static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | 157 | static void broadsheet_mmio_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, |
158 | int argc, u16 *argv) | ||
159 | { | ||
160 | int i; | ||
161 | |||
162 | par->board->mmio_write(par, BS_MMIO_CMD, cmd); | ||
163 | |||
164 | for (i = 0; i < argc; i++) | ||
165 | par->board->mmio_write(par, BS_MMIO_DATA, argv[i]); | ||
166 | } | ||
167 | |||
168 | static void broadsheet_send_command(struct broadsheetfb_par *par, u16 data) | ||
169 | { | ||
170 | if (par->board->mmio_write) | ||
171 | par->board->mmio_write(par, BS_MMIO_CMD, data); | ||
172 | else | ||
173 | broadsheet_gpio_send_command(par, data); | ||
174 | } | ||
175 | |||
176 | static void broadsheet_send_cmdargs(struct broadsheetfb_par *par, u16 cmd, | ||
177 | int argc, u16 *argv) | ||
178 | { | ||
179 | if (par->board->mmio_write) | ||
180 | broadsheet_mmio_send_cmdargs(par, cmd, argc, argv); | ||
181 | else | ||
182 | broadsheet_gpio_send_cmdargs(par, cmd, argc, argv); | ||
183 | } | ||
184 | |||
185 | static void broadsheet_gpio_burst_write(struct broadsheetfb_par *par, int size, | ||
158 | u16 *data) | 186 | u16 *data) |
159 | { | 187 | { |
160 | int i; | 188 | int i; |
@@ -174,7 +202,30 @@ static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | |||
174 | par->board->set_ctl(par, BS_CS, 1); | 202 | par->board->set_ctl(par, BS_CS, 1); |
175 | } | 203 | } |
176 | 204 | ||
177 | static u16 broadsheet_get_data(struct broadsheetfb_par *par) | 205 | static void broadsheet_mmio_burst_write(struct broadsheetfb_par *par, int size, |
206 | u16 *data) | ||
207 | { | ||
208 | int i; | ||
209 | u16 tmp; | ||
210 | |||
211 | for (i = 0; i < size; i++) { | ||
212 | tmp = (data[i] & 0x0F) << 4; | ||
213 | tmp |= (data[i] & 0x0F00) << 4; | ||
214 | par->board->mmio_write(par, BS_MMIO_DATA, tmp); | ||
215 | } | ||
216 | |||
217 | } | ||
218 | |||
219 | static void broadsheet_burst_write(struct broadsheetfb_par *par, int size, | ||
220 | u16 *data) | ||
221 | { | ||
222 | if (par->board->mmio_write) | ||
223 | broadsheet_mmio_burst_write(par, size, data); | ||
224 | else | ||
225 | broadsheet_gpio_burst_write(par, size, data); | ||
226 | } | ||
227 | |||
228 | static u16 broadsheet_gpio_get_data(struct broadsheetfb_par *par) | ||
178 | { | 229 | { |
179 | u16 res; | 230 | u16 res; |
180 | /* wait for ready to go hi. (lo is busy) */ | 231 | /* wait for ready to go hi. (lo is busy) */ |
@@ -194,7 +245,16 @@ static u16 broadsheet_get_data(struct broadsheetfb_par *par) | |||
194 | return res; | 245 | return res; |
195 | } | 246 | } |
196 | 247 | ||
197 | static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | 248 | |
249 | static u16 broadsheet_get_data(struct broadsheetfb_par *par) | ||
250 | { | ||
251 | if (par->board->mmio_read) | ||
252 | return par->board->mmio_read(par); | ||
253 | else | ||
254 | return broadsheet_gpio_get_data(par); | ||
255 | } | ||
256 | |||
257 | static void broadsheet_gpio_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
198 | u16 data) | 258 | u16 data) |
199 | { | 259 | { |
200 | /* wait for ready to go hi. (lo is busy) */ | 260 | /* wait for ready to go hi. (lo is busy) */ |
@@ -203,16 +263,34 @@ static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | |||
203 | /* cs lo, dc lo for cmd, we lo for each data, db as usual */ | 263 | /* cs lo, dc lo for cmd, we lo for each data, db as usual */ |
204 | par->board->set_ctl(par, BS_CS, 0); | 264 | par->board->set_ctl(par, BS_CS, 0); |
205 | 265 | ||
206 | broadsheet_issue_cmd(par, BS_CMD_WR_REG); | 266 | broadsheet_gpio_issue_cmd(par, BS_CMD_WR_REG); |
207 | 267 | ||
208 | par->board->set_ctl(par, BS_DC, 1); | 268 | par->board->set_ctl(par, BS_DC, 1); |
209 | 269 | ||
210 | broadsheet_issue_data(par, reg); | 270 | broadsheet_gpio_issue_data(par, reg); |
211 | broadsheet_issue_data(par, data); | 271 | broadsheet_gpio_issue_data(par, data); |
212 | 272 | ||
213 | par->board->set_ctl(par, BS_CS, 1); | 273 | par->board->set_ctl(par, BS_CS, 1); |
214 | } | 274 | } |
215 | 275 | ||
276 | static void broadsheet_mmio_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
277 | u16 data) | ||
278 | { | ||
279 | par->board->mmio_write(par, BS_MMIO_CMD, BS_CMD_WR_REG); | ||
280 | par->board->mmio_write(par, BS_MMIO_DATA, reg); | ||
281 | par->board->mmio_write(par, BS_MMIO_DATA, data); | ||
282 | |||
283 | } | ||
284 | |||
285 | static void broadsheet_write_reg(struct broadsheetfb_par *par, u16 reg, | ||
286 | u16 data) | ||
287 | { | ||
288 | if (par->board->mmio_write) | ||
289 | broadsheet_mmio_write_reg(par, reg, data); | ||
290 | else | ||
291 | broadsheet_gpio_write_reg(par, reg, data); | ||
292 | } | ||
293 | |||
216 | static void broadsheet_write_reg32(struct broadsheetfb_par *par, u16 reg, | 294 | static void broadsheet_write_reg32(struct broadsheetfb_par *par, u16 reg, |
217 | u32 data) | 295 | u32 data) |
218 | { | 296 | { |
@@ -223,8 +301,8 @@ static void broadsheet_write_reg32(struct broadsheetfb_par *par, u16 reg, | |||
223 | 301 | ||
224 | static u16 broadsheet_read_reg(struct broadsheetfb_par *par, u16 reg) | 302 | static u16 broadsheet_read_reg(struct broadsheetfb_par *par, u16 reg) |
225 | { | 303 | { |
226 | broadsheet_send_command(par, reg); | 304 | broadsheet_send_cmdargs(par, BS_CMD_RD_REG, 1, ®); |
227 | msleep(100); | 305 | par->board->wait_for_rdy(par); |
228 | return broadsheet_get_data(par); | 306 | return broadsheet_get_data(par); |
229 | } | 307 | } |
230 | 308 | ||