4 * Copyright (c) 2008 Shin-ichiro KAWASAKI
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 #include "qdev-addr.h"
35 * - Minimum implementation for Linux console : mmio regs and CRT layer.
36 * - 2D grapihcs acceleration partially supported : only fill rectangle.
40 * - Touch panel support
43 * - More 2D graphics engine support
44 * - Performance tuning
48 //#define DEBUG_BITBLT
51 #define SM501_DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
53 #define SM501_DPRINTF(fmt, ...) do {} while(0)
57 #define MMIO_BASE_OFFSET 0x3e00000
59 /* SM501 register definitions taken from "linux/include/linux/sm501-regs.h" */
61 /* System Configuration area */
62 /* System config base */
63 #define SM501_SYS_CONFIG (0x000000)
66 #define SM501_SYSTEM_CONTROL (0x000000)
68 #define SM501_SYSCTRL_PANEL_TRISTATE (1<<0)
69 #define SM501_SYSCTRL_MEM_TRISTATE (1<<1)
70 #define SM501_SYSCTRL_CRT_TRISTATE (1<<2)
72 #define SM501_SYSCTRL_PCI_SLAVE_BURST_MASK (3<<4)
73 #define SM501_SYSCTRL_PCI_SLAVE_BURST_1 (0<<4)
74 #define SM501_SYSCTRL_PCI_SLAVE_BURST_2 (1<<4)
75 #define SM501_SYSCTRL_PCI_SLAVE_BURST_4 (2<<4)
76 #define SM501_SYSCTRL_PCI_SLAVE_BURST_8 (3<<4)
78 #define SM501_SYSCTRL_PCI_CLOCK_RUN_EN (1<<6)
79 #define SM501_SYSCTRL_PCI_RETRY_DISABLE (1<<7)
80 #define SM501_SYSCTRL_PCI_SUBSYS_LOCK (1<<11)
81 #define SM501_SYSCTRL_PCI_BURST_READ_EN (1<<15)
83 /* miscellaneous control */
85 #define SM501_MISC_CONTROL (0x000004)
87 #define SM501_MISC_BUS_SH (0x0)
88 #define SM501_MISC_BUS_PCI (0x1)
89 #define SM501_MISC_BUS_XSCALE (0x2)
90 #define SM501_MISC_BUS_NEC (0x6)
91 #define SM501_MISC_BUS_MASK (0x7)
93 #define SM501_MISC_VR_62MB (1<<3)
94 #define SM501_MISC_CDR_RESET (1<<7)
95 #define SM501_MISC_USB_LB (1<<8)
96 #define SM501_MISC_USB_SLAVE (1<<9)
97 #define SM501_MISC_BL_1 (1<<10)
98 #define SM501_MISC_MC (1<<11)
99 #define SM501_MISC_DAC_POWER (1<<12)
100 #define SM501_MISC_IRQ_INVERT (1<<16)
101 #define SM501_MISC_SH (1<<17)
103 #define SM501_MISC_HOLD_EMPTY (0<<18)
104 #define SM501_MISC_HOLD_8 (1<<18)
105 #define SM501_MISC_HOLD_16 (2<<18)
106 #define SM501_MISC_HOLD_24 (3<<18)
107 #define SM501_MISC_HOLD_32 (4<<18)
108 #define SM501_MISC_HOLD_MASK (7<<18)
110 #define SM501_MISC_FREQ_12 (1<<24)
111 #define SM501_MISC_PNL_24BIT (1<<25)
112 #define SM501_MISC_8051_LE (1<<26)
116 #define SM501_GPIO31_0_CONTROL (0x000008)
117 #define SM501_GPIO63_32_CONTROL (0x00000C)
118 #define SM501_DRAM_CONTROL (0x000010)
121 #define SM501_ARBTRTN_CONTROL (0x000014)
124 #define SM501_COMMAND_LIST_STATUS (0x000024)
126 /* interrupt debug */
127 #define SM501_RAW_IRQ_STATUS (0x000028)
128 #define SM501_RAW_IRQ_CLEAR (0x000028)
129 #define SM501_IRQ_STATUS (0x00002C)
130 #define SM501_IRQ_MASK (0x000030)
131 #define SM501_DEBUG_CONTROL (0x000034)
133 /* power management */
134 #define SM501_POWERMODE_P2X_SRC (1<<29)
135 #define SM501_POWERMODE_V2X_SRC (1<<20)
136 #define SM501_POWERMODE_M_SRC (1<<12)
137 #define SM501_POWERMODE_M1_SRC (1<<4)
139 #define SM501_CURRENT_GATE (0x000038)
140 #define SM501_CURRENT_CLOCK (0x00003C)
141 #define SM501_POWER_MODE_0_GATE (0x000040)
142 #define SM501_POWER_MODE_0_CLOCK (0x000044)
143 #define SM501_POWER_MODE_1_GATE (0x000048)
144 #define SM501_POWER_MODE_1_CLOCK (0x00004C)
145 #define SM501_SLEEP_MODE_GATE (0x000050)
146 #define SM501_POWER_MODE_CONTROL (0x000054)
148 /* power gates for units within the 501 */
149 #define SM501_GATE_HOST (0)
150 #define SM501_GATE_MEMORY (1)
151 #define SM501_GATE_DISPLAY (2)
152 #define SM501_GATE_2D_ENGINE (3)
153 #define SM501_GATE_CSC (4)
154 #define SM501_GATE_ZVPORT (5)
155 #define SM501_GATE_GPIO (6)
156 #define SM501_GATE_UART0 (7)
157 #define SM501_GATE_UART1 (8)
158 #define SM501_GATE_SSP (10)
159 #define SM501_GATE_USB_HOST (11)
160 #define SM501_GATE_USB_GADGET (12)
161 #define SM501_GATE_UCONTROLLER (17)
162 #define SM501_GATE_AC97 (18)
165 #define SM501_CLOCK_P2XCLK (24)
167 #define SM501_CLOCK_V2XCLK (16)
169 #define SM501_CLOCK_MCLK (8)
170 /* SDRAM controller clock */
171 #define SM501_CLOCK_M1XCLK (0)
174 #define SM501_PCI_MASTER_BASE (0x000058)
175 #define SM501_ENDIAN_CONTROL (0x00005C)
176 #define SM501_DEVICEID (0x000060)
179 #define SM501_DEVICEID_SM501 (0x05010000)
180 #define SM501_DEVICEID_IDMASK (0xffff0000)
181 #define SM501_DEVICEID_REVMASK (0x000000ff)
183 #define SM501_PLLCLOCK_COUNT (0x000064)
184 #define SM501_MISC_TIMING (0x000068)
185 #define SM501_CURRENT_SDRAM_CLOCK (0x00006C)
187 #define SM501_PROGRAMMABLE_PLL_CONTROL (0x000074)
190 #define SM501_GPIO (0x010000)
191 #define SM501_GPIO_DATA_LOW (0x00)
192 #define SM501_GPIO_DATA_HIGH (0x04)
193 #define SM501_GPIO_DDR_LOW (0x08)
194 #define SM501_GPIO_DDR_HIGH (0x0C)
195 #define SM501_GPIO_IRQ_SETUP (0x10)
196 #define SM501_GPIO_IRQ_STATUS (0x14)
197 #define SM501_GPIO_IRQ_RESET (0x14)
199 /* I2C controller base */
200 #define SM501_I2C (0x010040)
201 #define SM501_I2C_BYTE_COUNT (0x00)
202 #define SM501_I2C_CONTROL (0x01)
203 #define SM501_I2C_STATUS (0x02)
204 #define SM501_I2C_RESET (0x02)
205 #define SM501_I2C_SLAVE_ADDRESS (0x03)
206 #define SM501_I2C_DATA (0x04)
209 #define SM501_SSP (0x020000)
212 #define SM501_UART0 (0x030000)
215 #define SM501_UART1 (0x030020)
217 /* USB host port base */
218 #define SM501_USB_HOST (0x040000)
220 /* USB slave/gadget base */
221 #define SM501_USB_GADGET (0x060000)
223 /* USB slave/gadget data port base */
224 #define SM501_USB_GADGET_DATA (0x070000)
226 /* Display controller/video engine base */
227 #define SM501_DC (0x080000)
229 /* common defines for the SM501 address registers */
230 #define SM501_ADDR_FLIP (1<<31)
231 #define SM501_ADDR_EXT (1<<27)
232 #define SM501_ADDR_CS1 (1<<26)
233 #define SM501_ADDR_MASK (0x3f << 26)
235 #define SM501_FIFO_MASK (0x3 << 16)
236 #define SM501_FIFO_1 (0x0 << 16)
237 #define SM501_FIFO_3 (0x1 << 16)
238 #define SM501_FIFO_7 (0x2 << 16)
239 #define SM501_FIFO_11 (0x3 << 16)
241 /* common registers for panel and the crt */
242 #define SM501_OFF_DC_H_TOT (0x000)
243 #define SM501_OFF_DC_V_TOT (0x008)
244 #define SM501_OFF_DC_H_SYNC (0x004)
245 #define SM501_OFF_DC_V_SYNC (0x00C)
247 #define SM501_DC_PANEL_CONTROL (0x000)
249 #define SM501_DC_PANEL_CONTROL_FPEN (1<<27)
250 #define SM501_DC_PANEL_CONTROL_BIAS (1<<26)
251 #define SM501_DC_PANEL_CONTROL_DATA (1<<25)
252 #define SM501_DC_PANEL_CONTROL_VDD (1<<24)
253 #define SM501_DC_PANEL_CONTROL_DP (1<<23)
255 #define SM501_DC_PANEL_CONTROL_TFT_888 (0<<21)
256 #define SM501_DC_PANEL_CONTROL_TFT_333 (1<<21)
257 #define SM501_DC_PANEL_CONTROL_TFT_444 (2<<21)
259 #define SM501_DC_PANEL_CONTROL_DE (1<<20)
261 #define SM501_DC_PANEL_CONTROL_LCD_TFT (0<<18)
262 #define SM501_DC_PANEL_CONTROL_LCD_STN8 (1<<18)
263 #define SM501_DC_PANEL_CONTROL_LCD_STN12 (2<<18)
265 #define SM501_DC_PANEL_CONTROL_CP (1<<14)
266 #define SM501_DC_PANEL_CONTROL_VSP (1<<13)
267 #define SM501_DC_PANEL_CONTROL_HSP (1<<12)
268 #define SM501_DC_PANEL_CONTROL_CK (1<<9)
269 #define SM501_DC_PANEL_CONTROL_TE (1<<8)
270 #define SM501_DC_PANEL_CONTROL_VPD (1<<7)
271 #define SM501_DC_PANEL_CONTROL_VP (1<<6)
272 #define SM501_DC_PANEL_CONTROL_HPD (1<<5)
273 #define SM501_DC_PANEL_CONTROL_HP (1<<4)
274 #define SM501_DC_PANEL_CONTROL_GAMMA (1<<3)
275 #define SM501_DC_PANEL_CONTROL_EN (1<<2)
277 #define SM501_DC_PANEL_CONTROL_8BPP (0<<0)
278 #define SM501_DC_PANEL_CONTROL_16BPP (1<<0)
279 #define SM501_DC_PANEL_CONTROL_32BPP (2<<0)
282 #define SM501_DC_PANEL_PANNING_CONTROL (0x004)
283 #define SM501_DC_PANEL_COLOR_KEY (0x008)
284 #define SM501_DC_PANEL_FB_ADDR (0x00C)
285 #define SM501_DC_PANEL_FB_OFFSET (0x010)
286 #define SM501_DC_PANEL_FB_WIDTH (0x014)
287 #define SM501_DC_PANEL_FB_HEIGHT (0x018)
288 #define SM501_DC_PANEL_TL_LOC (0x01C)
289 #define SM501_DC_PANEL_BR_LOC (0x020)
290 #define SM501_DC_PANEL_H_TOT (0x024)
291 #define SM501_DC_PANEL_H_SYNC (0x028)
292 #define SM501_DC_PANEL_V_TOT (0x02C)
293 #define SM501_DC_PANEL_V_SYNC (0x030)
294 #define SM501_DC_PANEL_CUR_LINE (0x034)
296 #define SM501_DC_VIDEO_CONTROL (0x040)
297 #define SM501_DC_VIDEO_FB0_ADDR (0x044)
298 #define SM501_DC_VIDEO_FB_WIDTH (0x048)
299 #define SM501_DC_VIDEO_FB0_LAST_ADDR (0x04C)
300 #define SM501_DC_VIDEO_TL_LOC (0x050)
301 #define SM501_DC_VIDEO_BR_LOC (0x054)
302 #define SM501_DC_VIDEO_SCALE (0x058)
303 #define SM501_DC_VIDEO_INIT_SCALE (0x05C)
304 #define SM501_DC_VIDEO_YUV_CONSTANTS (0x060)
305 #define SM501_DC_VIDEO_FB1_ADDR (0x064)
306 #define SM501_DC_VIDEO_FB1_LAST_ADDR (0x068)
308 #define SM501_DC_VIDEO_ALPHA_CONTROL (0x080)
309 #define SM501_DC_VIDEO_ALPHA_FB_ADDR (0x084)
310 #define SM501_DC_VIDEO_ALPHA_FB_OFFSET (0x088)
311 #define SM501_DC_VIDEO_ALPHA_FB_LAST_ADDR (0x08C)
312 #define SM501_DC_VIDEO_ALPHA_TL_LOC (0x090)
313 #define SM501_DC_VIDEO_ALPHA_BR_LOC (0x094)
314 #define SM501_DC_VIDEO_ALPHA_SCALE (0x098)
315 #define SM501_DC_VIDEO_ALPHA_INIT_SCALE (0x09C)
316 #define SM501_DC_VIDEO_ALPHA_CHROMA_KEY (0x0A0)
317 #define SM501_DC_VIDEO_ALPHA_COLOR_LOOKUP (0x0A4)
319 #define SM501_DC_PANEL_HWC_BASE (0x0F0)
320 #define SM501_DC_PANEL_HWC_ADDR (0x0F0)
321 #define SM501_DC_PANEL_HWC_LOC (0x0F4)
322 #define SM501_DC_PANEL_HWC_COLOR_1_2 (0x0F8)
323 #define SM501_DC_PANEL_HWC_COLOR_3 (0x0FC)
325 #define SM501_HWC_EN (1<<31)
327 #define SM501_OFF_HWC_ADDR (0x00)
328 #define SM501_OFF_HWC_LOC (0x04)
329 #define SM501_OFF_HWC_COLOR_1_2 (0x08)
330 #define SM501_OFF_HWC_COLOR_3 (0x0C)
332 #define SM501_DC_ALPHA_CONTROL (0x100)
333 #define SM501_DC_ALPHA_FB_ADDR (0x104)
334 #define SM501_DC_ALPHA_FB_OFFSET (0x108)
335 #define SM501_DC_ALPHA_TL_LOC (0x10C)
336 #define SM501_DC_ALPHA_BR_LOC (0x110)
337 #define SM501_DC_ALPHA_CHROMA_KEY (0x114)
338 #define SM501_DC_ALPHA_COLOR_LOOKUP (0x118)
340 #define SM501_DC_CRT_CONTROL (0x200)
342 #define SM501_DC_CRT_CONTROL_TVP (1<<15)
343 #define SM501_DC_CRT_CONTROL_CP (1<<14)
344 #define SM501_DC_CRT_CONTROL_VSP (1<<13)
345 #define SM501_DC_CRT_CONTROL_HSP (1<<12)
346 #define SM501_DC_CRT_CONTROL_VS (1<<11)
347 #define SM501_DC_CRT_CONTROL_BLANK (1<<10)
348 #define SM501_DC_CRT_CONTROL_SEL (1<<9)
349 #define SM501_DC_CRT_CONTROL_TE (1<<8)
350 #define SM501_DC_CRT_CONTROL_PIXEL_MASK (0xF << 4)
351 #define SM501_DC_CRT_CONTROL_GAMMA (1<<3)
352 #define SM501_DC_CRT_CONTROL_ENABLE (1<<2)
354 #define SM501_DC_CRT_CONTROL_8BPP (0<<0)
355 #define SM501_DC_CRT_CONTROL_16BPP (1<<0)
356 #define SM501_DC_CRT_CONTROL_32BPP (2<<0)
358 #define SM501_DC_CRT_FB_ADDR (0x204)
359 #define SM501_DC_CRT_FB_OFFSET (0x208)
360 #define SM501_DC_CRT_H_TOT (0x20C)
361 #define SM501_DC_CRT_H_SYNC (0x210)
362 #define SM501_DC_CRT_V_TOT (0x214)
363 #define SM501_DC_CRT_V_SYNC (0x218)
364 #define SM501_DC_CRT_SIGNATURE_ANALYZER (0x21C)
365 #define SM501_DC_CRT_CUR_LINE (0x220)
366 #define SM501_DC_CRT_MONITOR_DETECT (0x224)
368 #define SM501_DC_CRT_HWC_BASE (0x230)
369 #define SM501_DC_CRT_HWC_ADDR (0x230)
370 #define SM501_DC_CRT_HWC_LOC (0x234)
371 #define SM501_DC_CRT_HWC_COLOR_1_2 (0x238)
372 #define SM501_DC_CRT_HWC_COLOR_3 (0x23C)
374 #define SM501_DC_PANEL_PALETTE (0x400)
376 #define SM501_DC_VIDEO_PALETTE (0x800)
378 #define SM501_DC_CRT_PALETTE (0xC00)
380 /* Zoom Video port base */
381 #define SM501_ZVPORT (0x090000)
384 #define SM501_AC97 (0x0A0000)
386 /* 8051 micro controller base */
387 #define SM501_UCONTROLLER (0x0B0000)
389 /* 8051 micro controller SRAM base */
390 #define SM501_UCONTROLLER_SRAM (0x0C0000)
393 #define SM501_DMA (0x0D0000)
396 #define SM501_2D_ENGINE (0x100000)
397 #define SM501_2D_SOURCE (0x00)
398 #define SM501_2D_DESTINATION (0x04)
399 #define SM501_2D_DIMENSION (0x08)
400 #define SM501_2D_CONTROL (0x0C)
401 #define SM501_2D_PITCH (0x10)
402 #define SM501_2D_FOREGROUND (0x14)
403 #define SM501_2D_BACKGROUND (0x18)
404 #define SM501_2D_STRETCH (0x1C)
405 #define SM501_2D_COLOR_COMPARE (0x20)
406 #define SM501_2D_COLOR_COMPARE_MASK (0x24)
407 #define SM501_2D_MASK (0x28)
408 #define SM501_2D_CLIP_TL (0x2C)
409 #define SM501_2D_CLIP_BR (0x30)
410 #define SM501_2D_MONO_PATTERN_LOW (0x34)
411 #define SM501_2D_MONO_PATTERN_HIGH (0x38)
412 #define SM501_2D_WINDOW_WIDTH (0x3C)
413 #define SM501_2D_SOURCE_BASE (0x40)
414 #define SM501_2D_DESTINATION_BASE (0x44)
415 #define SM501_2D_ALPHA (0x48)
416 #define SM501_2D_WRAP (0x4C)
417 #define SM501_2D_STATUS (0x50)
419 #define SM501_CSC_Y_SOURCE_BASE (0xC8)
420 #define SM501_CSC_CONSTANTS (0xCC)
421 #define SM501_CSC_Y_SOURCE_X (0xD0)
422 #define SM501_CSC_Y_SOURCE_Y (0xD4)
423 #define SM501_CSC_U_SOURCE_BASE (0xD8)
424 #define SM501_CSC_V_SOURCE_BASE (0xDC)
425 #define SM501_CSC_SOURCE_DIMENSION (0xE0)
426 #define SM501_CSC_SOURCE_PITCH (0xE4)
427 #define SM501_CSC_DESTINATION (0xE8)
428 #define SM501_CSC_DESTINATION_DIMENSION (0xEC)
429 #define SM501_CSC_DESTINATION_PITCH (0xF0)
430 #define SM501_CSC_SCALE_FACTOR (0xF4)
431 #define SM501_CSC_DESTINATION_BASE (0xF8)
432 #define SM501_CSC_CONTROL (0xFC)
434 /* 2d engine data port base */
435 #define SM501_2D_ENGINE_DATA (0x110000)
437 /* end of register definitions */
439 #define SM501_HWC_WIDTH (64)
440 #define SM501_HWC_HEIGHT (64)
442 /* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */
443 static const uint32_t sm501_mem_local_size
[] = {
451 #define get_local_mem_size(s) sm501_mem_local_size[(s)->local_mem_size_index]
453 typedef struct SM501State
{
454 /* graphic console status */
457 /* status & internal resources */
458 target_phys_addr_t base
;
459 uint32_t local_mem_size_index
;
461 ram_addr_t local_mem_offset
;
463 uint32_t last_height
;
466 uint32_t system_control
;
467 uint32_t misc_control
;
468 uint32_t gpio_31_0_control
;
469 uint32_t gpio_63_32_control
;
470 uint32_t dram_control
;
472 uint32_t misc_timing
;
473 uint32_t power_mode_control
;
480 uint8_t dc_palette
[0x400 * 3];
482 uint32_t dc_panel_control
;
483 uint32_t dc_panel_panning_control
;
484 uint32_t dc_panel_fb_addr
;
485 uint32_t dc_panel_fb_offset
;
486 uint32_t dc_panel_fb_width
;
487 uint32_t dc_panel_fb_height
;
488 uint32_t dc_panel_tl_location
;
489 uint32_t dc_panel_br_location
;
490 uint32_t dc_panel_h_total
;
491 uint32_t dc_panel_h_sync
;
492 uint32_t dc_panel_v_total
;
493 uint32_t dc_panel_v_sync
;
495 uint32_t dc_panel_hwc_addr
;
496 uint32_t dc_panel_hwc_location
;
497 uint32_t dc_panel_hwc_color_1_2
;
498 uint32_t dc_panel_hwc_color_3
;
500 uint32_t dc_crt_control
;
501 uint32_t dc_crt_fb_addr
;
502 uint32_t dc_crt_fb_offset
;
503 uint32_t dc_crt_h_total
;
504 uint32_t dc_crt_h_sync
;
505 uint32_t dc_crt_v_total
;
506 uint32_t dc_crt_v_sync
;
508 uint32_t dc_crt_hwc_addr
;
509 uint32_t dc_crt_hwc_location
;
510 uint32_t dc_crt_hwc_color_1_2
;
511 uint32_t dc_crt_hwc_color_3
;
513 uint32_t twoD_destination
;
514 uint32_t twoD_dimension
;
515 uint32_t twoD_control
;
517 uint32_t twoD_foreground
;
518 uint32_t twoD_stretch
;
519 uint32_t twoD_color_compare_mask
;
521 uint32_t twoD_window_width
;
522 uint32_t twoD_source_base
;
523 uint32_t twoD_destination_base
;
527 static uint32_t get_local_mem_size_index(uint32_t size
)
529 uint32_t norm_size
= 0;
532 for (i
= 0; i
< ARRAY_SIZE(sm501_mem_local_size
); i
++) {
533 uint32_t new_size
= sm501_mem_local_size
[i
];
534 if (new_size
>= size
) {
535 if (norm_size
== 0 || norm_size
> new_size
) {
536 norm_size
= new_size
;
546 * Check the availability of hardware cursor.
547 * @param crt 0 for PANEL, 1 for CRT.
549 static inline int is_hwc_enabled(SM501State
*state
, int crt
)
551 uint32_t addr
= crt
? state
->dc_crt_hwc_addr
: state
->dc_panel_hwc_addr
;
552 return addr
& 0x80000000;
556 * Get the address which holds cursor pattern data.
557 * @param crt 0 for PANEL, 1 for CRT.
559 static inline uint32_t get_hwc_address(SM501State
*state
, int crt
)
561 uint32_t addr
= crt
? state
->dc_crt_hwc_addr
: state
->dc_panel_hwc_addr
;
562 return (addr
& 0x03FFFFF0)/* >> 4*/;
566 * Get the cursor position in y coordinate.
567 * @param crt 0 for PANEL, 1 for CRT.
569 static inline uint32_t get_hwc_y(SM501State
*state
, int crt
)
571 uint32_t location
= crt
? state
->dc_crt_hwc_location
572 : state
->dc_panel_hwc_location
;
573 return (location
& 0x07FF0000) >> 16;
577 * Get the cursor position in x coordinate.
578 * @param crt 0 for PANEL, 1 for CRT.
580 static inline uint32_t get_hwc_x(SM501State
*state
, int crt
)
582 uint32_t location
= crt
? state
->dc_crt_hwc_location
583 : state
->dc_panel_hwc_location
;
584 return location
& 0x000007FF;
588 * Get the cursor position in x coordinate.
589 * @param crt 0 for PANEL, 1 for CRT.
590 * @param index 0, 1, 2 or 3 which specifies color of corsor dot.
592 static inline uint16_t get_hwc_color(SM501State
*state
, int crt
, int index
)
594 uint16_t color_reg
= 0;
595 uint16_t color_565
= 0;
604 color_reg
= crt
? state
->dc_crt_hwc_color_1_2
605 : state
->dc_panel_hwc_color_1_2
;
608 color_reg
= crt
? state
->dc_crt_hwc_color_3
609 : state
->dc_panel_hwc_color_3
;
612 printf("invalid hw cursor color.\n");
619 color_565
= (uint16_t)(color_reg
& 0xFFFF);
622 color_565
= (uint16_t)((color_reg
>> 16) & 0xFFFF);
628 static int within_hwc_y_range(SM501State
*state
, int y
, int crt
)
630 int hwc_y
= get_hwc_y(state
, crt
);
631 return (hwc_y
<= y
&& y
< hwc_y
+ SM501_HWC_HEIGHT
);
634 static void sm501_2d_operation(SM501State
* s
)
636 /* obtain operation parameters */
637 int operation
= (s
->twoD_control
>> 16) & 0x1f;
638 int dst_x
= (s
->twoD_destination
>> 16) & 0x01FFF;
639 int dst_y
= s
->twoD_destination
& 0xFFFF;
640 int operation_width
= (s
->twoD_dimension
>> 16) & 0x1FFF;
641 int operation_height
= s
->twoD_dimension
& 0xFFFF;
642 uint32_t color
= s
->twoD_foreground
;
643 int format_flags
= (s
->twoD_stretch
>> 20) & 0x3;
644 int addressing
= (s
->twoD_stretch
>> 16) & 0xF;
646 /* get frame buffer info */
647 #if 0 /* for future use */
648 uint8_t * src
= s
->local_mem
+ (s
->twoD_source_base
& 0x03FFFFFF);
650 uint8_t * dst
= s
->local_mem
+ (s
->twoD_destination_base
& 0x03FFFFFF);
651 int dst_width
= (s
->dc_crt_h_total
& 0x00000FFF) + 1;
653 if (addressing
!= 0x0) {
654 printf("%s: only XY addressing is supported.\n", __func__
);
658 if ((s
->twoD_source_base
& 0x08000000) ||
659 (s
->twoD_destination_base
& 0x08000000)) {
660 printf("%s: only local memory is supported.\n", __func__
);
665 case 0x01: /* fill rectangle */
667 #define FILL_RECT(_bpp, _pixel_type) { \
669 for (y = 0; y < operation_height; y++) { \
670 for (x = 0; x < operation_width; x++) { \
671 int index = ((dst_y + y) * dst_width + dst_x + x) * _bpp; \
672 *(_pixel_type*)&dst[index] = (_pixel_type)color; \
677 switch (format_flags
) {
679 FILL_RECT(1, uint8_t);
682 FILL_RECT(2, uint16_t);
685 FILL_RECT(4, uint32_t);
691 printf("non-implemented SM501 2D operation. %d\n", operation
);
697 static uint32_t sm501_system_config_read(void *opaque
, target_phys_addr_t addr
)
699 SM501State
* s
= (SM501State
*)opaque
;
701 SM501_DPRINTF("sm501 system config regs : read addr=%x\n", (int)addr
);
704 case SM501_SYSTEM_CONTROL
:
705 ret
= s
->system_control
;
707 case SM501_MISC_CONTROL
:
708 ret
= s
->misc_control
;
710 case SM501_GPIO31_0_CONTROL
:
711 ret
= s
->gpio_31_0_control
;
713 case SM501_GPIO63_32_CONTROL
:
714 ret
= s
->gpio_63_32_control
;
719 case SM501_DRAM_CONTROL
:
720 ret
= (s
->dram_control
& 0x07F107C0) | s
->local_mem_size_index
<< 13;
725 case SM501_MISC_TIMING
:
726 /* TODO : simulate gate control */
727 ret
= s
->misc_timing
;
729 case SM501_CURRENT_GATE
:
730 /* TODO : simulate gate control */
733 case SM501_CURRENT_CLOCK
:
736 case SM501_POWER_MODE_CONTROL
:
737 ret
= s
->power_mode_control
;
741 printf("sm501 system config : not implemented register read."
742 " addr=%x\n", (int)addr
);
749 static void sm501_system_config_write(void *opaque
,
750 target_phys_addr_t addr
, uint32_t value
)
752 SM501State
* s
= (SM501State
*)opaque
;
753 SM501_DPRINTF("sm501 system config regs : write addr=%x, val=%x\n",
757 case SM501_SYSTEM_CONTROL
:
758 s
->system_control
= value
& 0xE300B8F7;
760 case SM501_MISC_CONTROL
:
761 s
->misc_control
= value
& 0xFF7FFF20;
763 case SM501_GPIO31_0_CONTROL
:
764 s
->gpio_31_0_control
= value
;
766 case SM501_GPIO63_32_CONTROL
:
767 s
->gpio_63_32_control
= value
;
769 case SM501_DRAM_CONTROL
:
770 s
->local_mem_size_index
= (value
>> 13) & 0x7;
771 /* rODO : check validity of size change */
772 s
->dram_control
|= value
& 0x7FFFFFC3;
777 case SM501_MISC_TIMING
:
778 s
->misc_timing
= value
& 0xF31F1FFF;
780 case SM501_POWER_MODE_0_GATE
:
781 case SM501_POWER_MODE_1_GATE
:
782 case SM501_POWER_MODE_0_CLOCK
:
783 case SM501_POWER_MODE_1_CLOCK
:
784 /* TODO : simulate gate & clock control */
786 case SM501_POWER_MODE_CONTROL
:
787 s
->power_mode_control
= value
& 0x00000003;
791 printf("sm501 system config : not implemented register write."
792 " addr=%x, val=%x\n", (int)addr
, value
);
797 static CPUReadMemoryFunc
* const sm501_system_config_readfn
[] = {
800 &sm501_system_config_read
,
803 static CPUWriteMemoryFunc
* const sm501_system_config_writefn
[] = {
806 &sm501_system_config_write
,
809 static uint32_t sm501_palette_read(void *opaque
, target_phys_addr_t addr
)
811 SM501State
* s
= (SM501State
*)opaque
;
812 SM501_DPRINTF("sm501 palette read addr=%x\n", (int)addr
);
814 /* TODO : consider BYTE/WORD access */
815 /* TODO : consider endian */
817 assert(0 <= addr
&& addr
< 0x400 * 3);
818 return *(uint32_t*)&s
->dc_palette
[addr
];
821 static void sm501_palette_write(void *opaque
,
822 target_phys_addr_t addr
, uint32_t value
)
824 SM501State
* s
= (SM501State
*)opaque
;
825 SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",
828 /* TODO : consider BYTE/WORD access */
829 /* TODO : consider endian */
831 assert(0 <= addr
&& addr
< 0x400 * 3);
832 *(uint32_t*)&s
->dc_palette
[addr
] = value
;
835 static uint32_t sm501_disp_ctrl_read(void *opaque
, target_phys_addr_t addr
)
837 SM501State
* s
= (SM501State
*)opaque
;
839 SM501_DPRINTF("sm501 disp ctrl regs : read addr=%x\n", (int)addr
);
843 case SM501_DC_PANEL_CONTROL
:
844 ret
= s
->dc_panel_control
;
846 case SM501_DC_PANEL_PANNING_CONTROL
:
847 ret
= s
->dc_panel_panning_control
;
849 case SM501_DC_PANEL_FB_ADDR
:
850 ret
= s
->dc_panel_fb_addr
;
852 case SM501_DC_PANEL_FB_OFFSET
:
853 ret
= s
->dc_panel_fb_offset
;
855 case SM501_DC_PANEL_FB_WIDTH
:
856 ret
= s
->dc_panel_fb_width
;
858 case SM501_DC_PANEL_FB_HEIGHT
:
859 ret
= s
->dc_panel_fb_height
;
861 case SM501_DC_PANEL_TL_LOC
:
862 ret
= s
->dc_panel_tl_location
;
864 case SM501_DC_PANEL_BR_LOC
:
865 ret
= s
->dc_panel_br_location
;
868 case SM501_DC_PANEL_H_TOT
:
869 ret
= s
->dc_panel_h_total
;
871 case SM501_DC_PANEL_H_SYNC
:
872 ret
= s
->dc_panel_h_sync
;
874 case SM501_DC_PANEL_V_TOT
:
875 ret
= s
->dc_panel_v_total
;
877 case SM501_DC_PANEL_V_SYNC
:
878 ret
= s
->dc_panel_v_sync
;
881 case SM501_DC_CRT_CONTROL
:
882 ret
= s
->dc_crt_control
;
884 case SM501_DC_CRT_FB_ADDR
:
885 ret
= s
->dc_crt_fb_addr
;
887 case SM501_DC_CRT_FB_OFFSET
:
888 ret
= s
->dc_crt_fb_offset
;
890 case SM501_DC_CRT_H_TOT
:
891 ret
= s
->dc_crt_h_total
;
893 case SM501_DC_CRT_H_SYNC
:
894 ret
= s
->dc_crt_h_sync
;
896 case SM501_DC_CRT_V_TOT
:
897 ret
= s
->dc_crt_v_total
;
899 case SM501_DC_CRT_V_SYNC
:
900 ret
= s
->dc_crt_v_sync
;
903 case SM501_DC_CRT_HWC_ADDR
:
904 ret
= s
->dc_crt_hwc_addr
;
906 case SM501_DC_CRT_HWC_LOC
:
907 ret
= s
->dc_crt_hwc_location
;
909 case SM501_DC_CRT_HWC_COLOR_1_2
:
910 ret
= s
->dc_crt_hwc_color_1_2
;
912 case SM501_DC_CRT_HWC_COLOR_3
:
913 ret
= s
->dc_crt_hwc_color_3
;
916 case SM501_DC_PANEL_PALETTE
... SM501_DC_PANEL_PALETTE
+ 0x400*3 - 4:
917 ret
= sm501_palette_read(opaque
, addr
- SM501_DC_PANEL_PALETTE
);
921 printf("sm501 disp ctrl : not implemented register read."
922 " addr=%x\n", (int)addr
);
929 static void sm501_disp_ctrl_write(void *opaque
,
930 target_phys_addr_t addr
,
933 SM501State
* s
= (SM501State
*)opaque
;
934 SM501_DPRINTF("sm501 disp ctrl regs : write addr=%x, val=%x\n",
938 case SM501_DC_PANEL_CONTROL
:
939 s
->dc_panel_control
= value
& 0x0FFF73FF;
941 case SM501_DC_PANEL_PANNING_CONTROL
:
942 s
->dc_panel_panning_control
= value
& 0xFF3FFF3F;
944 case SM501_DC_PANEL_FB_ADDR
:
945 s
->dc_panel_fb_addr
= value
& 0x8FFFFFF0;
947 case SM501_DC_PANEL_FB_OFFSET
:
948 s
->dc_panel_fb_offset
= value
& 0x3FF03FF0;
950 case SM501_DC_PANEL_FB_WIDTH
:
951 s
->dc_panel_fb_width
= value
& 0x0FFF0FFF;
953 case SM501_DC_PANEL_FB_HEIGHT
:
954 s
->dc_panel_fb_height
= value
& 0x0FFF0FFF;
956 case SM501_DC_PANEL_TL_LOC
:
957 s
->dc_panel_tl_location
= value
& 0x07FF07FF;
959 case SM501_DC_PANEL_BR_LOC
:
960 s
->dc_panel_br_location
= value
& 0x07FF07FF;
963 case SM501_DC_PANEL_H_TOT
:
964 s
->dc_panel_h_total
= value
& 0x0FFF0FFF;
966 case SM501_DC_PANEL_H_SYNC
:
967 s
->dc_panel_h_sync
= value
& 0x00FF0FFF;
969 case SM501_DC_PANEL_V_TOT
:
970 s
->dc_panel_v_total
= value
& 0x0FFF0FFF;
972 case SM501_DC_PANEL_V_SYNC
:
973 s
->dc_panel_v_sync
= value
& 0x003F0FFF;
976 case SM501_DC_PANEL_HWC_ADDR
:
977 s
->dc_panel_hwc_addr
= value
& 0x8FFFFFF0;
979 case SM501_DC_PANEL_HWC_LOC
:
980 s
->dc_panel_hwc_location
= value
& 0x0FFF0FFF;
982 case SM501_DC_PANEL_HWC_COLOR_1_2
:
983 s
->dc_panel_hwc_color_1_2
= value
;
985 case SM501_DC_PANEL_HWC_COLOR_3
:
986 s
->dc_panel_hwc_color_3
= value
& 0x0000FFFF;
989 case SM501_DC_CRT_CONTROL
:
990 s
->dc_crt_control
= value
& 0x0003FFFF;
992 case SM501_DC_CRT_FB_ADDR
:
993 s
->dc_crt_fb_addr
= value
& 0x8FFFFFF0;
995 case SM501_DC_CRT_FB_OFFSET
:
996 s
->dc_crt_fb_offset
= value
& 0x3FF03FF0;
998 case SM501_DC_CRT_H_TOT
:
999 s
->dc_crt_h_total
= value
& 0x0FFF0FFF;
1001 case SM501_DC_CRT_H_SYNC
:
1002 s
->dc_crt_h_sync
= value
& 0x00FF0FFF;
1004 case SM501_DC_CRT_V_TOT
:
1005 s
->dc_crt_v_total
= value
& 0x0FFF0FFF;
1007 case SM501_DC_CRT_V_SYNC
:
1008 s
->dc_crt_v_sync
= value
& 0x003F0FFF;
1011 case SM501_DC_CRT_HWC_ADDR
:
1012 s
->dc_crt_hwc_addr
= value
& 0x8FFFFFF0;
1014 case SM501_DC_CRT_HWC_LOC
:
1015 s
->dc_crt_hwc_location
= value
& 0x0FFF0FFF;
1017 case SM501_DC_CRT_HWC_COLOR_1_2
:
1018 s
->dc_crt_hwc_color_1_2
= value
;
1020 case SM501_DC_CRT_HWC_COLOR_3
:
1021 s
->dc_crt_hwc_color_3
= value
& 0x0000FFFF;
1024 case SM501_DC_PANEL_PALETTE
... SM501_DC_PANEL_PALETTE
+ 0x400*3 - 4:
1025 sm501_palette_write(opaque
, addr
- SM501_DC_PANEL_PALETTE
, value
);
1029 printf("sm501 disp ctrl : not implemented register write."
1030 " addr=%x, val=%x\n", (int)addr
, value
);
1035 static CPUReadMemoryFunc
* const sm501_disp_ctrl_readfn
[] = {
1038 &sm501_disp_ctrl_read
,
1041 static CPUWriteMemoryFunc
* const sm501_disp_ctrl_writefn
[] = {
1044 &sm501_disp_ctrl_write
,
1047 static uint32_t sm501_2d_engine_read(void *opaque
, target_phys_addr_t addr
)
1049 SM501State
* s
= (SM501State
*)opaque
;
1051 SM501_DPRINTF("sm501 2d engine regs : read addr=%x\n", (int)addr
);
1054 case SM501_2D_SOURCE_BASE
:
1055 ret
= s
->twoD_source_base
;
1058 printf("sm501 disp ctrl : not implemented register read."
1059 " addr=%x\n", (int)addr
);
1066 static void sm501_2d_engine_write(void *opaque
,
1067 target_phys_addr_t addr
, uint32_t value
)
1069 SM501State
* s
= (SM501State
*)opaque
;
1070 SM501_DPRINTF("sm501 2d engine regs : write addr=%x, val=%x\n",
1074 case SM501_2D_DESTINATION
:
1075 s
->twoD_destination
= value
;
1077 case SM501_2D_DIMENSION
:
1078 s
->twoD_dimension
= value
;
1080 case SM501_2D_CONTROL
:
1081 s
->twoD_control
= value
;
1083 /* do 2d operation if start flag is set. */
1084 if (value
& 0x80000000) {
1085 sm501_2d_operation(s
);
1086 s
->twoD_control
&= ~0x80000000; /* start flag down */
1090 case SM501_2D_PITCH
:
1091 s
->twoD_pitch
= value
;
1093 case SM501_2D_FOREGROUND
:
1094 s
->twoD_foreground
= value
;
1096 case SM501_2D_STRETCH
:
1097 s
->twoD_stretch
= value
;
1099 case SM501_2D_COLOR_COMPARE_MASK
:
1100 s
->twoD_color_compare_mask
= value
;
1103 s
->twoD_mask
= value
;
1105 case SM501_2D_WINDOW_WIDTH
:
1106 s
->twoD_window_width
= value
;
1108 case SM501_2D_SOURCE_BASE
:
1109 s
->twoD_source_base
= value
;
1111 case SM501_2D_DESTINATION_BASE
:
1112 s
->twoD_destination_base
= value
;
1115 printf("sm501 2d engine : not implemented register write."
1116 " addr=%x, val=%x\n", (int)addr
, value
);
1121 static CPUReadMemoryFunc
* const sm501_2d_engine_readfn
[] = {
1124 &sm501_2d_engine_read
,
1127 static CPUWriteMemoryFunc
* const sm501_2d_engine_writefn
[] = {
1130 &sm501_2d_engine_write
,
1133 /* draw line functions for all console modes */
1135 #include "pixel_ops.h"
1137 typedef void draw_line_func(uint8_t *d
, const uint8_t *s
,
1138 int width
, const uint32_t *pal
);
1140 typedef void draw_hwc_line_func(SM501State
* s
, int crt
, uint8_t * palette
,
1141 int c_y
, uint8_t *d
, int width
);
1144 #include "sm501_template.h"
1147 #include "sm501_template.h"
1151 #include "sm501_template.h"
1154 #include "sm501_template.h"
1158 #include "sm501_template.h"
1161 #include "sm501_template.h"
1165 #include "sm501_template.h"
1167 static draw_line_func
* draw_line8_funcs
[] = {
1177 static draw_line_func
* draw_line16_funcs
[] = {
1187 static draw_line_func
* draw_line32_funcs
[] = {
1197 static draw_hwc_line_func
* draw_hwc_line_funcs
[] = {
1202 draw_hwc_line_32bgr
,
1203 draw_hwc_line_15bgr
,
1204 draw_hwc_line_16bgr
,
1207 static inline int get_depth_index(DisplayState
*s
)
1209 switch(ds_get_bits_per_pixel(s
)) {
1218 if (is_surface_bgr(s
->surface
))
1225 static void sm501_draw_crt(SM501State
* s
)
1228 int width
= (s
->dc_crt_h_total
& 0x00000FFF) + 1;
1229 int height
= (s
->dc_crt_v_total
& 0x00000FFF) + 1;
1231 uint8_t * src
= s
->local_mem
;
1233 int dst_bpp
= ds_get_bytes_per_pixel(s
->ds
) + (ds_get_bits_per_pixel(s
->ds
) % 8 ? 1 : 0);
1234 uint32_t * palette
= (uint32_t *)&s
->dc_palette
[SM501_DC_CRT_PALETTE
1235 - SM501_DC_PANEL_PALETTE
];
1236 uint8_t hwc_palette
[3 * 3];
1237 int ds_depth_index
= get_depth_index(s
->ds
);
1238 draw_line_func
* draw_line
= NULL
;
1239 draw_hwc_line_func
* draw_hwc_line
= NULL
;
1240 int full_update
= 0;
1242 int page_min
= 0x7fffffff;
1244 ram_addr_t offset
= s
->local_mem_offset
;
1246 /* choose draw_line function */
1247 switch (s
->dc_crt_control
& 3) {
1248 case SM501_DC_CRT_CONTROL_8BPP
:
1250 draw_line
= draw_line8_funcs
[ds_depth_index
];
1252 case SM501_DC_CRT_CONTROL_16BPP
:
1254 draw_line
= draw_line16_funcs
[ds_depth_index
];
1256 case SM501_DC_CRT_CONTROL_32BPP
:
1258 draw_line
= draw_line32_funcs
[ds_depth_index
];
1261 printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
1267 /* set up to draw hardware cursor */
1268 if (is_hwc_enabled(s
, 1)) {
1271 /* get cursor palette */
1272 for (i
= 0; i
< 3; i
++) {
1273 uint16_t rgb565
= get_hwc_color(s
, 1, i
+ 1);
1274 hwc_palette
[i
* 3 + 0] = (rgb565
& 0xf800) >> 8; /* red */
1275 hwc_palette
[i
* 3 + 1] = (rgb565
& 0x07e0) >> 3; /* green */
1276 hwc_palette
[i
* 3 + 2] = (rgb565
& 0x001f) << 3; /* blue */
1279 /* choose cursor draw line function */
1280 draw_hwc_line
= draw_hwc_line_funcs
[ds_depth_index
];
1283 /* adjust console size */
1284 if (s
->last_width
!= width
|| s
->last_height
!= height
) {
1285 qemu_console_resize(s
->ds
, width
, height
);
1286 s
->last_width
= width
;
1287 s
->last_height
= height
;
1291 /* draw each line according to conditions */
1292 for (y
= 0; y
< height
; y
++) {
1293 int update_hwc
= draw_hwc_line
? within_hwc_y_range(s
, y
, 1) : 0;
1294 int update
= full_update
|| update_hwc
;
1295 ram_addr_t page0
= offset
& TARGET_PAGE_MASK
;
1296 ram_addr_t page1
= (offset
+ width
* src_bpp
- 1) & TARGET_PAGE_MASK
;
1299 /* check dirty flags for each line */
1300 for (page
= page0
; page
<= page1
; page
+= TARGET_PAGE_SIZE
)
1301 if (cpu_physical_memory_get_dirty(page
, VGA_DIRTY_FLAG
))
1304 /* draw line and change status */
1306 uint8_t * d
= &(ds_get_data(s
->ds
)[y
* width
* dst_bpp
]);
1308 /* draw graphics layer */
1309 draw_line(d
, src
, width
, palette
);
1311 /* draw haredware cursor */
1313 draw_hwc_line(s
, 1, hwc_palette
, y
- get_hwc_y(s
, 1), d
, width
);
1318 if (page0
< page_min
)
1320 if (page1
> page_max
)
1324 /* flush to display */
1325 dpy_update(s
->ds
, 0, y_start
, width
, y
- y_start
);
1330 src
+= width
* src_bpp
;
1331 offset
+= width
* src_bpp
;
1334 /* complete flush to display */
1336 dpy_update(s
->ds
, 0, y_start
, width
, y
- y_start
);
1338 /* clear dirty flags */
1340 cpu_physical_memory_reset_dirty(page_min
, page_max
+ TARGET_PAGE_SIZE
,
1344 static void sm501_update_display(void *opaque
)
1346 SM501State
* s
= (SM501State
*)opaque
;
1348 if (s
->dc_crt_control
& SM501_DC_CRT_CONTROL_ENABLE
)
1352 void sm501_init(uint32_t base
, uint32_t local_mem_bytes
, qemu_irq irq
,
1353 CharDriverState
*chr
)
1357 int sm501_system_config_index
;
1358 int sm501_disp_ctrl_index
;
1359 int sm501_2d_engine_index
;
1361 /* allocate management data region */
1362 s
= (SM501State
*)qemu_mallocz(sizeof(SM501State
));
1364 s
->local_mem_size_index
1365 = get_local_mem_size_index(local_mem_bytes
);
1366 SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s
),
1367 s
->local_mem_size_index
);
1368 s
->system_control
= 0x00100000;
1369 s
->misc_control
= 0x00001000; /* assumes SH, active=low */
1370 s
->dc_panel_control
= 0x00010000;
1371 s
->dc_crt_control
= 0x00010000;
1373 /* allocate local memory */
1374 s
->local_mem_offset
= qemu_ram_alloc(local_mem_bytes
);
1375 s
->local_mem
= qemu_get_ram_ptr(s
->local_mem_offset
);
1376 cpu_register_physical_memory(base
, local_mem_bytes
, s
->local_mem_offset
);
1379 sm501_system_config_index
1380 = cpu_register_io_memory(sm501_system_config_readfn
,
1381 sm501_system_config_writefn
, s
);
1382 cpu_register_physical_memory(base
+ MMIO_BASE_OFFSET
,
1383 0x6c, sm501_system_config_index
);
1384 sm501_disp_ctrl_index
= cpu_register_io_memory(sm501_disp_ctrl_readfn
,
1385 sm501_disp_ctrl_writefn
, s
);
1386 cpu_register_physical_memory(base
+ MMIO_BASE_OFFSET
+ SM501_DC
,
1387 0x1000, sm501_disp_ctrl_index
);
1388 sm501_2d_engine_index
= cpu_register_io_memory(sm501_2d_engine_readfn
,
1389 sm501_2d_engine_writefn
, s
);
1390 cpu_register_physical_memory(base
+ MMIO_BASE_OFFSET
+ SM501_2D_ENGINE
,
1391 0x54, sm501_2d_engine_index
);
1393 /* bridge to usb host emulation module */
1394 dev
= qdev_create(NULL
, "sysbus-ohci");
1395 qdev_prop_set_uint32(dev
, "num-ports", 2);
1396 qdev_prop_set_taddr(dev
, "dma-offset", base
);
1397 qdev_init_nofail(dev
);
1398 sysbus_mmio_map(sysbus_from_qdev(dev
), 0,
1399 base
+ MMIO_BASE_OFFSET
+ SM501_USB_HOST
);
1400 sysbus_connect_irq(sysbus_from_qdev(dev
), 0, irq
);
1402 /* bridge to serial emulation module */
1404 #ifdef TARGET_WORDS_BIGENDIAN
1405 serial_mm_init(base
+ MMIO_BASE_OFFSET
+ SM501_UART0
, 2,
1406 NULL
, /* TODO : chain irq to IRL */
1409 serial_mm_init(base
+ MMIO_BASE_OFFSET
+ SM501_UART0
, 2,
1410 NULL
, /* TODO : chain irq to IRL */
1415 /* create qemu graphic console */
1416 s
->ds
= graphic_console_init(sm501_update_display
, NULL
,