diff options
-rw-r--r-- | drivers/video/broadsheetfb.c | 110 | ||||
-rw-r--r-- | include/video/broadsheetfb.h | 17 |
2 files changed, 107 insertions, 20 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 | ||
diff --git a/include/video/broadsheetfb.h b/include/video/broadsheetfb.h index a2c2829ceb38..d65b6689e92c 100644 --- a/include/video/broadsheetfb.h +++ b/include/video/broadsheetfb.h | |||
@@ -34,6 +34,10 @@ | |||
34 | #define BS_DC 0x02 | 34 | #define BS_DC 0x02 |
35 | #define BS_WR 0x03 | 35 | #define BS_WR 0x03 |
36 | 36 | ||
37 | /* Broadsheet IO interface specific defines */ | ||
38 | #define BS_MMIO_CMD 0x01 | ||
39 | #define BS_MMIO_DATA 0x02 | ||
40 | |||
37 | /* struct used by broadsheet. board specific stuff comes from *board */ | 41 | /* struct used by broadsheet. board specific stuff comes from *board */ |
38 | struct broadsheetfb_par { | 42 | struct broadsheetfb_par { |
39 | struct fb_info *info; | 43 | struct fb_info *info; |
@@ -49,12 +53,17 @@ struct broadsheet_board { | |||
49 | struct module *owner; | 53 | struct module *owner; |
50 | int (*init)(struct broadsheetfb_par *); | 54 | int (*init)(struct broadsheetfb_par *); |
51 | int (*wait_for_rdy)(struct broadsheetfb_par *); | 55 | int (*wait_for_rdy)(struct broadsheetfb_par *); |
52 | void (*set_ctl)(struct broadsheetfb_par *, unsigned char, u8); | ||
53 | void (*set_hdb)(struct broadsheetfb_par *, u16); | ||
54 | u16 (*get_hdb)(struct broadsheetfb_par *); | ||
55 | void (*cleanup)(struct broadsheetfb_par *); | 56 | void (*cleanup)(struct broadsheetfb_par *); |
56 | int (*get_panel_type)(void); | 57 | int (*get_panel_type)(void); |
57 | int (*setup_irq)(struct fb_info *); | 58 | int (*setup_irq)(struct fb_info *); |
58 | }; | ||
59 | 59 | ||
60 | /* Functions for boards that use GPIO */ | ||
61 | void (*set_ctl)(struct broadsheetfb_par *, unsigned char, u8); | ||
62 | void (*set_hdb)(struct broadsheetfb_par *, u16); | ||
63 | u16 (*get_hdb)(struct broadsheetfb_par *); | ||
64 | |||
65 | /* Functions for boards that have specialized MMIO */ | ||
66 | void (*mmio_write)(struct broadsheetfb_par *, int type, u16); | ||
67 | u16 (*mmio_read)(struct broadsheetfb_par *); | ||
68 | }; | ||
60 | #endif | 69 | #endif |