sm501.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. /*
  2. * QEMU SM501 Device
  3. *
  4. * Copyright (c) 2008 Shin-ichiro KAWASAKI
  5. *
  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:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  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
  22. * THE SOFTWARE.
  23. */
  24. #include <stdio.h>
  25. #include <assert.h>
  26. #include "hw.h"
  27. #include "pc.h"
  28. #include "console.h"
  29. #include "devices.h"
  30. /*
  31. * Status: 2008/11/02
  32. * - Minimum implementation for Linux console : mmio regs and CRT layer.
  33. * - Always updates full screen.
  34. *
  35. * TODO:
  36. * - Panel support
  37. * - Hardware cursor support
  38. * - Touch panel support
  39. * - USB support
  40. * - UART support
  41. * - Performance tuning
  42. */
  43. //#define DEBUG_SM501
  44. //#define DEBUG_BITBLT
  45. #ifdef DEBUG_SM501
  46. #define SM501_DPRINTF(fmt...) printf(fmt)
  47. #else
  48. #define SM501_DPRINTF(fmt...) do {} while(0)
  49. #endif
  50. #define MMIO_BASE_OFFSET 0x3e00000
  51. /* SM501 register definitions taken from "linux/include/linux/sm501-regs.h" */
  52. /* System Configuration area */
  53. /* System config base */
  54. #define SM501_SYS_CONFIG (0x000000)
  55. /* config 1 */
  56. #define SM501_SYSTEM_CONTROL (0x000000)
  57. #define SM501_SYSCTRL_PANEL_TRISTATE (1<<0)
  58. #define SM501_SYSCTRL_MEM_TRISTATE (1<<1)
  59. #define SM501_SYSCTRL_CRT_TRISTATE (1<<2)
  60. #define SM501_SYSCTRL_PCI_SLAVE_BURST_MASK (3<<4)
  61. #define SM501_SYSCTRL_PCI_SLAVE_BURST_1 (0<<4)
  62. #define SM501_SYSCTRL_PCI_SLAVE_BURST_2 (1<<4)
  63. #define SM501_SYSCTRL_PCI_SLAVE_BURST_4 (2<<4)
  64. #define SM501_SYSCTRL_PCI_SLAVE_BURST_8 (3<<4)
  65. #define SM501_SYSCTRL_PCI_CLOCK_RUN_EN (1<<6)
  66. #define SM501_SYSCTRL_PCI_RETRY_DISABLE (1<<7)
  67. #define SM501_SYSCTRL_PCI_SUBSYS_LOCK (1<<11)
  68. #define SM501_SYSCTRL_PCI_BURST_READ_EN (1<<15)
  69. /* miscellaneous control */
  70. #define SM501_MISC_CONTROL (0x000004)
  71. #define SM501_MISC_BUS_SH (0x0)
  72. #define SM501_MISC_BUS_PCI (0x1)
  73. #define SM501_MISC_BUS_XSCALE (0x2)
  74. #define SM501_MISC_BUS_NEC (0x6)
  75. #define SM501_MISC_BUS_MASK (0x7)
  76. #define SM501_MISC_VR_62MB (1<<3)
  77. #define SM501_MISC_CDR_RESET (1<<7)
  78. #define SM501_MISC_USB_LB (1<<8)
  79. #define SM501_MISC_USB_SLAVE (1<<9)
  80. #define SM501_MISC_BL_1 (1<<10)
  81. #define SM501_MISC_MC (1<<11)
  82. #define SM501_MISC_DAC_POWER (1<<12)
  83. #define SM501_MISC_IRQ_INVERT (1<<16)
  84. #define SM501_MISC_SH (1<<17)
  85. #define SM501_MISC_HOLD_EMPTY (0<<18)
  86. #define SM501_MISC_HOLD_8 (1<<18)
  87. #define SM501_MISC_HOLD_16 (2<<18)
  88. #define SM501_MISC_HOLD_24 (3<<18)
  89. #define SM501_MISC_HOLD_32 (4<<18)
  90. #define SM501_MISC_HOLD_MASK (7<<18)
  91. #define SM501_MISC_FREQ_12 (1<<24)
  92. #define SM501_MISC_PNL_24BIT (1<<25)
  93. #define SM501_MISC_8051_LE (1<<26)
  94. #define SM501_GPIO31_0_CONTROL (0x000008)
  95. #define SM501_GPIO63_32_CONTROL (0x00000C)
  96. #define SM501_DRAM_CONTROL (0x000010)
  97. /* command list */
  98. #define SM501_ARBTRTN_CONTROL (0x000014)
  99. /* command list */
  100. #define SM501_COMMAND_LIST_STATUS (0x000024)
  101. /* interrupt debug */
  102. #define SM501_RAW_IRQ_STATUS (0x000028)
  103. #define SM501_RAW_IRQ_CLEAR (0x000028)
  104. #define SM501_IRQ_STATUS (0x00002C)
  105. #define SM501_IRQ_MASK (0x000030)
  106. #define SM501_DEBUG_CONTROL (0x000034)
  107. /* power management */
  108. #define SM501_POWERMODE_P2X_SRC (1<<29)
  109. #define SM501_POWERMODE_V2X_SRC (1<<20)
  110. #define SM501_POWERMODE_M_SRC (1<<12)
  111. #define SM501_POWERMODE_M1_SRC (1<<4)
  112. #define SM501_CURRENT_GATE (0x000038)
  113. #define SM501_CURRENT_CLOCK (0x00003C)
  114. #define SM501_POWER_MODE_0_GATE (0x000040)
  115. #define SM501_POWER_MODE_0_CLOCK (0x000044)
  116. #define SM501_POWER_MODE_1_GATE (0x000048)
  117. #define SM501_POWER_MODE_1_CLOCK (0x00004C)
  118. #define SM501_SLEEP_MODE_GATE (0x000050)
  119. #define SM501_POWER_MODE_CONTROL (0x000054)
  120. /* power gates for units within the 501 */
  121. #define SM501_GATE_HOST (0)
  122. #define SM501_GATE_MEMORY (1)
  123. #define SM501_GATE_DISPLAY (2)
  124. #define SM501_GATE_2D_ENGINE (3)
  125. #define SM501_GATE_CSC (4)
  126. #define SM501_GATE_ZVPORT (5)
  127. #define SM501_GATE_GPIO (6)
  128. #define SM501_GATE_UART0 (7)
  129. #define SM501_GATE_UART1 (8)
  130. #define SM501_GATE_SSP (10)
  131. #define SM501_GATE_USB_HOST (11)
  132. #define SM501_GATE_USB_GADGET (12)
  133. #define SM501_GATE_UCONTROLLER (17)
  134. #define SM501_GATE_AC97 (18)
  135. /* panel clock */
  136. #define SM501_CLOCK_P2XCLK (24)
  137. /* crt clock */
  138. #define SM501_CLOCK_V2XCLK (16)
  139. /* main clock */
  140. #define SM501_CLOCK_MCLK (8)
  141. /* SDRAM controller clock */
  142. #define SM501_CLOCK_M1XCLK (0)
  143. /* config 2 */
  144. #define SM501_PCI_MASTER_BASE (0x000058)
  145. #define SM501_ENDIAN_CONTROL (0x00005C)
  146. #define SM501_DEVICEID (0x000060)
  147. /* 0x050100A0 */
  148. #define SM501_DEVICEID_SM501 (0x05010000)
  149. #define SM501_DEVICEID_IDMASK (0xffff0000)
  150. #define SM501_DEVICEID_REVMASK (0x000000ff)
  151. #define SM501_PLLCLOCK_COUNT (0x000064)
  152. #define SM501_MISC_TIMING (0x000068)
  153. #define SM501_CURRENT_SDRAM_CLOCK (0x00006C)
  154. #define SM501_PROGRAMMABLE_PLL_CONTROL (0x000074)
  155. /* GPIO base */
  156. #define SM501_GPIO (0x010000)
  157. #define SM501_GPIO_DATA_LOW (0x00)
  158. #define SM501_GPIO_DATA_HIGH (0x04)
  159. #define SM501_GPIO_DDR_LOW (0x08)
  160. #define SM501_GPIO_DDR_HIGH (0x0C)
  161. #define SM501_GPIO_IRQ_SETUP (0x10)
  162. #define SM501_GPIO_IRQ_STATUS (0x14)
  163. #define SM501_GPIO_IRQ_RESET (0x14)
  164. /* I2C controller base */
  165. #define SM501_I2C (0x010040)
  166. #define SM501_I2C_BYTE_COUNT (0x00)
  167. #define SM501_I2C_CONTROL (0x01)
  168. #define SM501_I2C_STATUS (0x02)
  169. #define SM501_I2C_RESET (0x02)
  170. #define SM501_I2C_SLAVE_ADDRESS (0x03)
  171. #define SM501_I2C_DATA (0x04)
  172. /* SSP base */
  173. #define SM501_SSP (0x020000)
  174. /* Uart 0 base */
  175. #define SM501_UART0 (0x030000)
  176. /* Uart 1 base */
  177. #define SM501_UART1 (0x030020)
  178. /* USB host port base */
  179. #define SM501_USB_HOST (0x040000)
  180. /* USB slave/gadget base */
  181. #define SM501_USB_GADGET (0x060000)
  182. /* USB slave/gadget data port base */
  183. #define SM501_USB_GADGET_DATA (0x070000)
  184. /* Display controller/video engine base */
  185. #define SM501_DC (0x080000)
  186. /* common defines for the SM501 address registers */
  187. #define SM501_ADDR_FLIP (1<<31)
  188. #define SM501_ADDR_EXT (1<<27)
  189. #define SM501_ADDR_CS1 (1<<26)
  190. #define SM501_ADDR_MASK (0x3f << 26)
  191. #define SM501_FIFO_MASK (0x3 << 16)
  192. #define SM501_FIFO_1 (0x0 << 16)
  193. #define SM501_FIFO_3 (0x1 << 16)
  194. #define SM501_FIFO_7 (0x2 << 16)
  195. #define SM501_FIFO_11 (0x3 << 16)
  196. /* common registers for panel and the crt */
  197. #define SM501_OFF_DC_H_TOT (0x000)
  198. #define SM501_OFF_DC_V_TOT (0x008)
  199. #define SM501_OFF_DC_H_SYNC (0x004)
  200. #define SM501_OFF_DC_V_SYNC (0x00C)
  201. #define SM501_DC_PANEL_CONTROL (0x000)
  202. #define SM501_DC_PANEL_CONTROL_FPEN (1<<27)
  203. #define SM501_DC_PANEL_CONTROL_BIAS (1<<26)
  204. #define SM501_DC_PANEL_CONTROL_DATA (1<<25)
  205. #define SM501_DC_PANEL_CONTROL_VDD (1<<24)
  206. #define SM501_DC_PANEL_CONTROL_DP (1<<23)
  207. #define SM501_DC_PANEL_CONTROL_TFT_888 (0<<21)
  208. #define SM501_DC_PANEL_CONTROL_TFT_333 (1<<21)
  209. #define SM501_DC_PANEL_CONTROL_TFT_444 (2<<21)
  210. #define SM501_DC_PANEL_CONTROL_DE (1<<20)
  211. #define SM501_DC_PANEL_CONTROL_LCD_TFT (0<<18)
  212. #define SM501_DC_PANEL_CONTROL_LCD_STN8 (1<<18)
  213. #define SM501_DC_PANEL_CONTROL_LCD_STN12 (2<<18)
  214. #define SM501_DC_PANEL_CONTROL_CP (1<<14)
  215. #define SM501_DC_PANEL_CONTROL_VSP (1<<13)
  216. #define SM501_DC_PANEL_CONTROL_HSP (1<<12)
  217. #define SM501_DC_PANEL_CONTROL_CK (1<<9)
  218. #define SM501_DC_PANEL_CONTROL_TE (1<<8)
  219. #define SM501_DC_PANEL_CONTROL_VPD (1<<7)
  220. #define SM501_DC_PANEL_CONTROL_VP (1<<6)
  221. #define SM501_DC_PANEL_CONTROL_HPD (1<<5)
  222. #define SM501_DC_PANEL_CONTROL_HP (1<<4)
  223. #define SM501_DC_PANEL_CONTROL_GAMMA (1<<3)
  224. #define SM501_DC_PANEL_CONTROL_EN (1<<2)
  225. #define SM501_DC_PANEL_CONTROL_8BPP (0<<0)
  226. #define SM501_DC_PANEL_CONTROL_16BPP (1<<0)
  227. #define SM501_DC_PANEL_CONTROL_32BPP (2<<0)
  228. #define SM501_DC_PANEL_PANNING_CONTROL (0x004)
  229. #define SM501_DC_PANEL_COLOR_KEY (0x008)
  230. #define SM501_DC_PANEL_FB_ADDR (0x00C)
  231. #define SM501_DC_PANEL_FB_OFFSET (0x010)
  232. #define SM501_DC_PANEL_FB_WIDTH (0x014)
  233. #define SM501_DC_PANEL_FB_HEIGHT (0x018)
  234. #define SM501_DC_PANEL_TL_LOC (0x01C)
  235. #define SM501_DC_PANEL_BR_LOC (0x020)
  236. #define SM501_DC_PANEL_H_TOT (0x024)
  237. #define SM501_DC_PANEL_H_SYNC (0x028)
  238. #define SM501_DC_PANEL_V_TOT (0x02C)
  239. #define SM501_DC_PANEL_V_SYNC (0x030)
  240. #define SM501_DC_PANEL_CUR_LINE (0x034)
  241. #define SM501_DC_VIDEO_CONTROL (0x040)
  242. #define SM501_DC_VIDEO_FB0_ADDR (0x044)
  243. #define SM501_DC_VIDEO_FB_WIDTH (0x048)
  244. #define SM501_DC_VIDEO_FB0_LAST_ADDR (0x04C)
  245. #define SM501_DC_VIDEO_TL_LOC (0x050)
  246. #define SM501_DC_VIDEO_BR_LOC (0x054)
  247. #define SM501_DC_VIDEO_SCALE (0x058)
  248. #define SM501_DC_VIDEO_INIT_SCALE (0x05C)
  249. #define SM501_DC_VIDEO_YUV_CONSTANTS (0x060)
  250. #define SM501_DC_VIDEO_FB1_ADDR (0x064)
  251. #define SM501_DC_VIDEO_FB1_LAST_ADDR (0x068)
  252. #define SM501_DC_VIDEO_ALPHA_CONTROL (0x080)
  253. #define SM501_DC_VIDEO_ALPHA_FB_ADDR (0x084)
  254. #define SM501_DC_VIDEO_ALPHA_FB_OFFSET (0x088)
  255. #define SM501_DC_VIDEO_ALPHA_FB_LAST_ADDR (0x08C)
  256. #define SM501_DC_VIDEO_ALPHA_TL_LOC (0x090)
  257. #define SM501_DC_VIDEO_ALPHA_BR_LOC (0x094)
  258. #define SM501_DC_VIDEO_ALPHA_SCALE (0x098)
  259. #define SM501_DC_VIDEO_ALPHA_INIT_SCALE (0x09C)
  260. #define SM501_DC_VIDEO_ALPHA_CHROMA_KEY (0x0A0)
  261. #define SM501_DC_VIDEO_ALPHA_COLOR_LOOKUP (0x0A4)
  262. #define SM501_DC_PANEL_HWC_BASE (0x0F0)
  263. #define SM501_DC_PANEL_HWC_ADDR (0x0F0)
  264. #define SM501_DC_PANEL_HWC_LOC (0x0F4)
  265. #define SM501_DC_PANEL_HWC_COLOR_1_2 (0x0F8)
  266. #define SM501_DC_PANEL_HWC_COLOR_3 (0x0FC)
  267. #define SM501_HWC_EN (1<<31)
  268. #define SM501_OFF_HWC_ADDR (0x00)
  269. #define SM501_OFF_HWC_LOC (0x04)
  270. #define SM501_OFF_HWC_COLOR_1_2 (0x08)
  271. #define SM501_OFF_HWC_COLOR_3 (0x0C)
  272. #define SM501_DC_ALPHA_CONTROL (0x100)
  273. #define SM501_DC_ALPHA_FB_ADDR (0x104)
  274. #define SM501_DC_ALPHA_FB_OFFSET (0x108)
  275. #define SM501_DC_ALPHA_TL_LOC (0x10C)
  276. #define SM501_DC_ALPHA_BR_LOC (0x110)
  277. #define SM501_DC_ALPHA_CHROMA_KEY (0x114)
  278. #define SM501_DC_ALPHA_COLOR_LOOKUP (0x118)
  279. #define SM501_DC_CRT_CONTROL (0x200)
  280. #define SM501_DC_CRT_CONTROL_TVP (1<<15)
  281. #define SM501_DC_CRT_CONTROL_CP (1<<14)
  282. #define SM501_DC_CRT_CONTROL_VSP (1<<13)
  283. #define SM501_DC_CRT_CONTROL_HSP (1<<12)
  284. #define SM501_DC_CRT_CONTROL_VS (1<<11)
  285. #define SM501_DC_CRT_CONTROL_BLANK (1<<10)
  286. #define SM501_DC_CRT_CONTROL_SEL (1<<9)
  287. #define SM501_DC_CRT_CONTROL_TE (1<<8)
  288. #define SM501_DC_CRT_CONTROL_PIXEL_MASK (0xF << 4)
  289. #define SM501_DC_CRT_CONTROL_GAMMA (1<<3)
  290. #define SM501_DC_CRT_CONTROL_ENABLE (1<<2)
  291. #define SM501_DC_CRT_CONTROL_8BPP (0<<0)
  292. #define SM501_DC_CRT_CONTROL_16BPP (1<<0)
  293. #define SM501_DC_CRT_CONTROL_32BPP (2<<0)
  294. #define SM501_DC_CRT_FB_ADDR (0x204)
  295. #define SM501_DC_CRT_FB_OFFSET (0x208)
  296. #define SM501_DC_CRT_H_TOT (0x20C)
  297. #define SM501_DC_CRT_H_SYNC (0x210)
  298. #define SM501_DC_CRT_V_TOT (0x214)
  299. #define SM501_DC_CRT_V_SYNC (0x218)
  300. #define SM501_DC_CRT_SIGNATURE_ANALYZER (0x21C)
  301. #define SM501_DC_CRT_CUR_LINE (0x220)
  302. #define SM501_DC_CRT_MONITOR_DETECT (0x224)
  303. #define SM501_DC_CRT_HWC_BASE (0x230)
  304. #define SM501_DC_CRT_HWC_ADDR (0x230)
  305. #define SM501_DC_CRT_HWC_LOC (0x234)
  306. #define SM501_DC_CRT_HWC_COLOR_1_2 (0x238)
  307. #define SM501_DC_CRT_HWC_COLOR_3 (0x23C)
  308. #define SM501_DC_PANEL_PALETTE (0x400)
  309. #define SM501_DC_VIDEO_PALETTE (0x800)
  310. #define SM501_DC_CRT_PALETTE (0xC00)
  311. /* Zoom Video port base */
  312. #define SM501_ZVPORT (0x090000)
  313. /* AC97/I2S base */
  314. #define SM501_AC97 (0x0A0000)
  315. /* 8051 micro controller base */
  316. #define SM501_UCONTROLLER (0x0B0000)
  317. /* 8051 micro controller SRAM base */
  318. #define SM501_UCONTROLLER_SRAM (0x0C0000)
  319. /* DMA base */
  320. #define SM501_DMA (0x0D0000)
  321. /* 2d engine base */
  322. #define SM501_2D_ENGINE (0x100000)
  323. #define SM501_2D_SOURCE (0x00)
  324. #define SM501_2D_DESTINATION (0x04)
  325. #define SM501_2D_DIMENSION (0x08)
  326. #define SM501_2D_CONTROL (0x0C)
  327. #define SM501_2D_PITCH (0x10)
  328. #define SM501_2D_FOREGROUND (0x14)
  329. #define SM501_2D_BACKGROUND (0x18)
  330. #define SM501_2D_STRETCH (0x1C)
  331. #define SM501_2D_COLOR_COMPARE (0x20)
  332. #define SM501_2D_COLOR_COMPARE_MASK (0x24)
  333. #define SM501_2D_MASK (0x28)
  334. #define SM501_2D_CLIP_TL (0x2C)
  335. #define SM501_2D_CLIP_BR (0x30)
  336. #define SM501_2D_MONO_PATTERN_LOW (0x34)
  337. #define SM501_2D_MONO_PATTERN_HIGH (0x38)
  338. #define SM501_2D_WINDOW_WIDTH (0x3C)
  339. #define SM501_2D_SOURCE_BASE (0x40)
  340. #define SM501_2D_DESTINATION_BASE (0x44)
  341. #define SM501_2D_ALPHA (0x48)
  342. #define SM501_2D_WRAP (0x4C)
  343. #define SM501_2D_STATUS (0x50)
  344. #define SM501_CSC_Y_SOURCE_BASE (0xC8)
  345. #define SM501_CSC_CONSTANTS (0xCC)
  346. #define SM501_CSC_Y_SOURCE_X (0xD0)
  347. #define SM501_CSC_Y_SOURCE_Y (0xD4)
  348. #define SM501_CSC_U_SOURCE_BASE (0xD8)
  349. #define SM501_CSC_V_SOURCE_BASE (0xDC)
  350. #define SM501_CSC_SOURCE_DIMENSION (0xE0)
  351. #define SM501_CSC_SOURCE_PITCH (0xE4)
  352. #define SM501_CSC_DESTINATION (0xE8)
  353. #define SM501_CSC_DESTINATION_DIMENSION (0xEC)
  354. #define SM501_CSC_DESTINATION_PITCH (0xF0)
  355. #define SM501_CSC_SCALE_FACTOR (0xF4)
  356. #define SM501_CSC_DESTINATION_BASE (0xF8)
  357. #define SM501_CSC_CONTROL (0xFC)
  358. /* 2d engine data port base */
  359. #define SM501_2D_ENGINE_DATA (0x110000)
  360. /* end of register definitions */
  361. /* SM501 local memory size taken from "linux/drivers/mfd/sm501.c" */
  362. static const uint32_t sm501_mem_local_size[] = {
  363. [0] = 4*1024*1024,
  364. [1] = 8*1024*1024,
  365. [2] = 16*1024*1024,
  366. [3] = 32*1024*1024,
  367. [4] = 64*1024*1024,
  368. [5] = 2*1024*1024,
  369. };
  370. #define get_local_mem_size(s) sm501_mem_local_size[(s)->local_mem_size_index]
  371. typedef struct SM501State {
  372. /* graphic console status */
  373. DisplayState *ds;
  374. /* status & internal resources */
  375. target_phys_addr_t base;
  376. uint32_t local_mem_size_index;
  377. uint8_t * local_mem;
  378. uint32_t last_width;
  379. uint32_t last_height;
  380. /* mmio registers */
  381. uint32_t system_control;
  382. uint32_t misc_control;
  383. uint32_t gpio_31_0_control;
  384. uint32_t gpio_63_32_control;
  385. uint32_t dram_control;
  386. uint32_t irq_mask;
  387. uint32_t misc_timing;
  388. uint32_t power_mode_control;
  389. uint32_t uart0_ier;
  390. uint32_t uart0_lcr;
  391. uint32_t uart0_mcr;
  392. uint32_t uart0_scr;
  393. uint8_t dc_palette[0x400 * 3];
  394. uint32_t dc_panel_control;
  395. uint32_t dc_panel_panning_control;
  396. uint32_t dc_panel_fb_addr;
  397. uint32_t dc_panel_fb_offset;
  398. uint32_t dc_panel_fb_width;
  399. uint32_t dc_panel_fb_height;
  400. uint32_t dc_panel_tl_location;
  401. uint32_t dc_panel_br_location;
  402. uint32_t dc_panel_h_total;
  403. uint32_t dc_panel_h_sync;
  404. uint32_t dc_panel_v_total;
  405. uint32_t dc_panel_v_sync;
  406. uint32_t dc_panel_hwc_addr;
  407. uint32_t dc_panel_hwc_location;
  408. uint32_t dc_panel_hwc_color_1_2;
  409. uint32_t dc_panel_hwc_color_3;
  410. uint32_t dc_crt_control;
  411. uint32_t dc_crt_fb_addr;
  412. uint32_t dc_crt_fb_offset;
  413. uint32_t dc_crt_h_total;
  414. uint32_t dc_crt_h_sync;
  415. uint32_t dc_crt_v_total;
  416. uint32_t dc_crt_v_sync;
  417. uint32_t dc_crt_hwc_addr;
  418. uint32_t dc_crt_hwc_location;
  419. uint32_t dc_crt_hwc_color_1_2;
  420. uint32_t dc_crt_hwc_color_3;
  421. } SM501State;
  422. static uint32_t get_local_mem_size_index(uint32_t size)
  423. {
  424. uint32_t norm_size = 0;
  425. int i, index = 0;
  426. for (i = 0; i < ARRAY_SIZE(sm501_mem_local_size); i++) {
  427. uint32_t new_size = sm501_mem_local_size[i];
  428. if (new_size >= size) {
  429. if (norm_size == 0 || norm_size > new_size) {
  430. norm_size = new_size;
  431. index = i;
  432. }
  433. }
  434. }
  435. return index;
  436. }
  437. static uint32_t sm501_system_config_read(void *opaque, target_phys_addr_t addr)
  438. {
  439. SM501State * s = (SM501State *)opaque;
  440. uint32_t ret = 0;
  441. SM501_DPRINTF("sm501 system config regs : read addr=%x\n", (int)addr);
  442. switch(addr) {
  443. case SM501_SYSTEM_CONTROL:
  444. ret = s->system_control;
  445. break;
  446. case SM501_MISC_CONTROL:
  447. ret = s->misc_control;
  448. break;
  449. case SM501_GPIO31_0_CONTROL:
  450. ret = s->gpio_31_0_control;
  451. break;
  452. case SM501_GPIO63_32_CONTROL:
  453. ret = s->gpio_63_32_control;
  454. break;
  455. case SM501_DEVICEID:
  456. ret = 0x050100A0;
  457. break;
  458. case SM501_DRAM_CONTROL:
  459. ret = (s->dram_control & 0x07F107C0) | s->local_mem_size_index << 13;
  460. break;
  461. case SM501_IRQ_MASK:
  462. ret = s->irq_mask;
  463. break;
  464. case SM501_MISC_TIMING:
  465. /* TODO : simulate gate control */
  466. ret = s->misc_timing;
  467. break;
  468. case SM501_CURRENT_GATE:
  469. /* TODO : simulate gate control */
  470. ret = 0x00021807;
  471. break;
  472. case SM501_CURRENT_CLOCK:
  473. ret = 0x2A1A0A09;
  474. break;
  475. case SM501_POWER_MODE_CONTROL:
  476. ret = s->power_mode_control;
  477. break;
  478. default:
  479. printf("sm501 system config : not implemented register read."
  480. " addr=%x\n", (int)addr);
  481. assert(0);
  482. }
  483. return ret;
  484. }
  485. static void sm501_system_config_write(void *opaque,
  486. target_phys_addr_t addr, uint32_t value)
  487. {
  488. SM501State * s = (SM501State *)opaque;
  489. SM501_DPRINTF("sm501 system config regs : write addr=%x, val=%x\n",
  490. addr, value);
  491. switch(addr) {
  492. case SM501_SYSTEM_CONTROL:
  493. s->system_control = value & 0xE300B8F7;
  494. break;
  495. case SM501_MISC_CONTROL:
  496. s->misc_control = value & 0xFF7FFF20;
  497. break;
  498. case SM501_GPIO31_0_CONTROL:
  499. s->gpio_31_0_control = value;
  500. break;
  501. case SM501_GPIO63_32_CONTROL:
  502. s->gpio_63_32_control = value;
  503. break;
  504. case SM501_DRAM_CONTROL:
  505. s->local_mem_size_index = (value >> 13) & 0x7;
  506. /* rODO : check validity of size change */
  507. s->dram_control |= value & 0x7FFFFFC3;
  508. break;
  509. case SM501_IRQ_MASK:
  510. s->irq_mask = value;
  511. break;
  512. case SM501_MISC_TIMING:
  513. s->misc_timing = value & 0xF31F1FFF;
  514. break;
  515. case SM501_POWER_MODE_0_GATE:
  516. case SM501_POWER_MODE_1_GATE:
  517. case SM501_POWER_MODE_0_CLOCK:
  518. case SM501_POWER_MODE_1_CLOCK:
  519. /* TODO : simulate gate & clock control */
  520. break;
  521. case SM501_POWER_MODE_CONTROL:
  522. s->power_mode_control = value & 0x00000003;
  523. break;
  524. default:
  525. printf("sm501 system config : not implemented register write."
  526. " addr=%x, val=%x\n", (int)addr, value);
  527. assert(0);
  528. }
  529. }
  530. static CPUReadMemoryFunc *sm501_system_config_readfn[] = {
  531. NULL,
  532. NULL,
  533. &sm501_system_config_read,
  534. };
  535. static CPUWriteMemoryFunc *sm501_system_config_writefn[] = {
  536. NULL,
  537. NULL,
  538. &sm501_system_config_write,
  539. };
  540. static uint32_t sm501_palette_read(void *opaque, target_phys_addr_t addr)
  541. {
  542. SM501State * s = (SM501State *)opaque;
  543. SM501_DPRINTF("sm501 palette read addr=%x\n", (int)addr);
  544. /* TODO : consider BYTE/WORD access */
  545. /* TODO : consider endian */
  546. assert(0 <= addr && addr < 0x400 * 3);
  547. return *(uint32_t*)&s->dc_palette[addr];
  548. }
  549. static void sm501_palette_write(void *opaque,
  550. target_phys_addr_t addr, uint32_t value)
  551. {
  552. SM501State * s = (SM501State *)opaque;
  553. SM501_DPRINTF("sm501 palette write addr=%x, val=%x\n",
  554. (int)addr, value);
  555. /* TODO : consider BYTE/WORD access */
  556. /* TODO : consider endian */
  557. assert(0 <= addr && addr < 0x400 * 3);
  558. *(uint32_t*)&s->dc_palette[addr] = value;
  559. }
  560. static uint32_t sm501_disp_ctrl_read(void *opaque, target_phys_addr_t addr)
  561. {
  562. SM501State * s = (SM501State *)opaque;
  563. uint32_t ret = 0;
  564. SM501_DPRINTF("sm501 disp ctrl regs : read addr=%x\n", (int)addr);
  565. switch(addr) {
  566. case SM501_DC_PANEL_CONTROL:
  567. ret = s->dc_panel_control;
  568. break;
  569. case SM501_DC_PANEL_PANNING_CONTROL:
  570. ret = s->dc_panel_panning_control;
  571. break;
  572. case SM501_DC_PANEL_FB_ADDR:
  573. ret = s->dc_panel_fb_addr;
  574. break;
  575. case SM501_DC_PANEL_FB_OFFSET:
  576. ret = s->dc_panel_fb_offset;
  577. break;
  578. case SM501_DC_PANEL_FB_WIDTH:
  579. ret = s->dc_panel_fb_width;
  580. break;
  581. case SM501_DC_PANEL_FB_HEIGHT:
  582. ret = s->dc_panel_fb_height;
  583. break;
  584. case SM501_DC_PANEL_TL_LOC:
  585. ret = s->dc_panel_tl_location;
  586. break;
  587. case SM501_DC_PANEL_BR_LOC:
  588. ret = s->dc_panel_br_location;
  589. break;
  590. case SM501_DC_PANEL_H_TOT:
  591. ret = s->dc_panel_h_total;
  592. break;
  593. case SM501_DC_PANEL_H_SYNC:
  594. ret = s->dc_panel_h_sync;
  595. break;
  596. case SM501_DC_PANEL_V_TOT:
  597. ret = s->dc_panel_v_total;
  598. break;
  599. case SM501_DC_PANEL_V_SYNC:
  600. ret = s->dc_panel_v_sync;
  601. break;
  602. case SM501_DC_CRT_CONTROL:
  603. ret = s->dc_crt_control;
  604. break;
  605. case SM501_DC_CRT_FB_ADDR:
  606. ret = s->dc_crt_fb_addr;
  607. break;
  608. case SM501_DC_CRT_FB_OFFSET:
  609. ret = s->dc_crt_fb_offset;
  610. break;
  611. case SM501_DC_CRT_H_TOT:
  612. ret = s->dc_crt_h_total;
  613. break;
  614. case SM501_DC_CRT_H_SYNC:
  615. ret = s->dc_crt_h_sync;
  616. break;
  617. case SM501_DC_CRT_V_TOT:
  618. ret = s->dc_crt_v_total;
  619. break;
  620. case SM501_DC_CRT_V_SYNC:
  621. ret = s->dc_crt_v_sync;
  622. break;
  623. case SM501_DC_CRT_HWC_ADDR:
  624. ret = s->dc_crt_hwc_addr;
  625. break;
  626. case SM501_DC_CRT_HWC_LOC:
  627. ret = s->dc_crt_hwc_addr;
  628. break;
  629. case SM501_DC_CRT_HWC_COLOR_1_2:
  630. ret = s->dc_crt_hwc_addr;
  631. break;
  632. case SM501_DC_CRT_HWC_COLOR_3:
  633. ret = s->dc_crt_hwc_addr;
  634. break;
  635. case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4:
  636. ret = sm501_palette_read(opaque, addr - SM501_DC_PANEL_PALETTE);
  637. break;
  638. default:
  639. printf("sm501 disp ctrl : not implemented register read."
  640. " addr=%x\n", (int)addr);
  641. assert(0);
  642. }
  643. return ret;
  644. }
  645. static void sm501_disp_ctrl_write(void *opaque,
  646. target_phys_addr_t addr,
  647. uint32_t value)
  648. {
  649. SM501State * s = (SM501State *)opaque;
  650. SM501_DPRINTF("sm501 disp ctrl regs : write addr=%x, val=%x\n",
  651. addr, value);
  652. switch(addr) {
  653. case SM501_DC_PANEL_CONTROL:
  654. s->dc_panel_control = value & 0x0FFF73FF;
  655. break;
  656. case SM501_DC_PANEL_PANNING_CONTROL:
  657. s->dc_panel_panning_control = value & 0xFF3FFF3F;
  658. break;
  659. case SM501_DC_PANEL_FB_ADDR:
  660. s->dc_panel_fb_addr = value & 0x8FFFFFF0;
  661. break;
  662. case SM501_DC_PANEL_FB_OFFSET:
  663. s->dc_panel_fb_offset = value & 0x3FF03FF0;
  664. break;
  665. case SM501_DC_PANEL_FB_WIDTH:
  666. s->dc_panel_fb_width = value & 0x0FFF0FFF;
  667. break;
  668. case SM501_DC_PANEL_FB_HEIGHT:
  669. s->dc_panel_fb_height = value & 0x0FFF0FFF;
  670. break;
  671. case SM501_DC_PANEL_TL_LOC:
  672. s->dc_panel_tl_location = value & 0x07FF07FF;
  673. break;
  674. case SM501_DC_PANEL_BR_LOC:
  675. s->dc_panel_br_location = value & 0x07FF07FF;
  676. break;
  677. case SM501_DC_PANEL_H_TOT:
  678. s->dc_panel_h_total = value & 0x0FFF0FFF;
  679. break;
  680. case SM501_DC_PANEL_H_SYNC:
  681. s->dc_panel_h_sync = value & 0x00FF0FFF;
  682. break;
  683. case SM501_DC_PANEL_V_TOT:
  684. s->dc_panel_v_total = value & 0x0FFF0FFF;
  685. break;
  686. case SM501_DC_PANEL_V_SYNC:
  687. s->dc_panel_v_sync = value & 0x003F0FFF;
  688. break;
  689. case SM501_DC_PANEL_HWC_ADDR:
  690. s->dc_panel_hwc_addr = value & 0x8FFFFFF0;
  691. break;
  692. case SM501_DC_PANEL_HWC_LOC:
  693. s->dc_panel_hwc_addr = value & 0x0FFF0FFF;
  694. break;
  695. case SM501_DC_PANEL_HWC_COLOR_1_2:
  696. s->dc_panel_hwc_addr = value;
  697. break;
  698. case SM501_DC_PANEL_HWC_COLOR_3:
  699. s->dc_panel_hwc_addr = value & 0x0000FFFF;
  700. break;
  701. case SM501_DC_CRT_CONTROL:
  702. s->dc_crt_control = value & 0x0003FFFF;
  703. break;
  704. case SM501_DC_CRT_FB_ADDR:
  705. s->dc_crt_fb_addr = value & 0x8FFFFFF0;
  706. break;
  707. case SM501_DC_CRT_FB_OFFSET:
  708. s->dc_crt_fb_offset = value & 0x3FF03FF0;
  709. break;
  710. case SM501_DC_CRT_H_TOT:
  711. s->dc_crt_h_total = value & 0x0FFF0FFF;
  712. break;
  713. case SM501_DC_CRT_H_SYNC:
  714. s->dc_crt_h_sync = value & 0x00FF0FFF;
  715. break;
  716. case SM501_DC_CRT_V_TOT:
  717. s->dc_crt_v_total = value & 0x0FFF0FFF;
  718. break;
  719. case SM501_DC_CRT_V_SYNC:
  720. s->dc_crt_v_sync = value & 0x003F0FFF;
  721. break;
  722. case SM501_DC_CRT_HWC_ADDR:
  723. s->dc_crt_hwc_addr = value & 0x8FFFFFF0;
  724. break;
  725. case SM501_DC_CRT_HWC_LOC:
  726. s->dc_crt_hwc_addr = value & 0x0FFF0FFF;
  727. break;
  728. case SM501_DC_CRT_HWC_COLOR_1_2:
  729. s->dc_crt_hwc_addr = value;
  730. break;
  731. case SM501_DC_CRT_HWC_COLOR_3:
  732. s->dc_crt_hwc_addr = value & 0x0000FFFF;
  733. break;
  734. case SM501_DC_PANEL_PALETTE ... SM501_DC_PANEL_PALETTE + 0x400*3 - 4:
  735. sm501_palette_write(opaque, addr - SM501_DC_PANEL_PALETTE, value);
  736. break;
  737. default:
  738. printf("sm501 disp ctrl : not implemented register write."
  739. " addr=%x, val=%x\n", (int)addr, value);
  740. assert(0);
  741. }
  742. }
  743. static CPUReadMemoryFunc *sm501_disp_ctrl_readfn[] = {
  744. NULL,
  745. NULL,
  746. &sm501_disp_ctrl_read,
  747. };
  748. static CPUWriteMemoryFunc *sm501_disp_ctrl_writefn[] = {
  749. NULL,
  750. NULL,
  751. &sm501_disp_ctrl_write,
  752. };
  753. /* draw line functions for all console modes */
  754. #include "pixel_ops.h"
  755. typedef void draw_line_func(uint8_t *d, const uint8_t *s,
  756. int width, const uint32_t *pal);
  757. #define DEPTH 8
  758. #include "sm501_template.h"
  759. #define DEPTH 15
  760. #include "sm501_template.h"
  761. #define BGR_FORMAT
  762. #define DEPTH 15
  763. #include "sm501_template.h"
  764. #define DEPTH 16
  765. #include "sm501_template.h"
  766. #define BGR_FORMAT
  767. #define DEPTH 16
  768. #include "sm501_template.h"
  769. #define DEPTH 32
  770. #include "sm501_template.h"
  771. #define BGR_FORMAT
  772. #define DEPTH 32
  773. #include "sm501_template.h"
  774. static draw_line_func * draw_line8_funcs[] = {
  775. draw_line8_8,
  776. draw_line8_15,
  777. draw_line8_16,
  778. draw_line8_32,
  779. draw_line8_32bgr,
  780. draw_line8_15bgr,
  781. draw_line8_16bgr,
  782. };
  783. static draw_line_func * draw_line16_funcs[] = {
  784. draw_line16_8,
  785. draw_line16_15,
  786. draw_line16_16,
  787. draw_line16_32,
  788. draw_line16_32bgr,
  789. draw_line16_15bgr,
  790. draw_line16_16bgr,
  791. };
  792. static draw_line_func * draw_line32_funcs[] = {
  793. draw_line32_8,
  794. draw_line32_15,
  795. draw_line32_16,
  796. draw_line32_32,
  797. draw_line32_32bgr,
  798. draw_line32_15bgr,
  799. draw_line32_16bgr,
  800. };
  801. static inline int get_depth_index(DisplayState *s)
  802. {
  803. switch(ds_get_bits_per_pixel(s)) {
  804. default:
  805. case 8:
  806. return 0;
  807. case 15:
  808. return 1;
  809. case 16:
  810. return 2;
  811. case 32:
  812. return 3;
  813. }
  814. }
  815. static void sm501_draw_crt(SM501State * s)
  816. {
  817. int y;
  818. int width = (s->dc_crt_h_total & 0x00000FFF) + 1;
  819. int height = (s->dc_crt_v_total & 0x00000FFF) + 1;
  820. uint8_t * src = s->local_mem;
  821. int src_bpp = 0;
  822. int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0);
  823. uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE
  824. - SM501_DC_PANEL_PALETTE];
  825. int ds_depth_index = get_depth_index(s->ds);
  826. draw_line_func * draw_line = NULL;
  827. int full_update = 0;
  828. int y_start = -1;
  829. int page_min = 0x7fffffff;
  830. int page_max = -1;
  831. /* choose draw_line function */
  832. switch (s->dc_crt_control & 3) {
  833. case SM501_DC_CRT_CONTROL_8BPP:
  834. src_bpp = 1;
  835. draw_line = draw_line8_funcs[ds_depth_index];
  836. break;
  837. case SM501_DC_CRT_CONTROL_16BPP:
  838. src_bpp = 2;
  839. draw_line = draw_line16_funcs[ds_depth_index];
  840. break;
  841. case SM501_DC_CRT_CONTROL_32BPP:
  842. src_bpp = 4;
  843. draw_line = draw_line32_funcs[ds_depth_index];
  844. break;
  845. default:
  846. printf("sm501 draw crt : invalid DC_CRT_CONTROL=%x.\n",
  847. s->dc_crt_control);
  848. assert(0);
  849. break;
  850. }
  851. /* adjust console size */
  852. if (s->last_width != width || s->last_height != height) {
  853. qemu_console_resize(s->ds, width, height);
  854. s->last_width = width;
  855. s->last_height = height;
  856. full_update = 1;
  857. }
  858. /* draw each line according to conditions */
  859. for (y = 0; y < height; y++) {
  860. int update = full_update;
  861. uint8_t * line_end = &src[width * src_bpp - 1];
  862. int page0 = (src - phys_ram_base) & TARGET_PAGE_MASK;
  863. int page1 = (line_end - phys_ram_base) & TARGET_PAGE_MASK;
  864. int page;
  865. /* check dirty flags for each line */
  866. for (page = page0; page <= page1; page += TARGET_PAGE_SIZE)
  867. if (cpu_physical_memory_get_dirty(page, VGA_DIRTY_FLAG))
  868. update = 1;
  869. /* draw line and change status */
  870. if (update) {
  871. draw_line(&(ds_get_data(s->ds)[y * width * dst_bpp]), src, width, palette);
  872. if (y_start < 0)
  873. y_start = y;
  874. if (page0 < page_min)
  875. page_min = page0;
  876. if (page1 > page_max)
  877. page_max = page1;
  878. } else {
  879. if (y_start >= 0) {
  880. /* flush to display */
  881. dpy_update(s->ds, 0, y_start, width, y - y_start);
  882. y_start = -1;
  883. }
  884. }
  885. src += width * src_bpp;
  886. }
  887. /* complete flush to display */
  888. if (y_start >= 0)
  889. dpy_update(s->ds, 0, y_start, width, y - y_start);
  890. /* clear dirty flags */
  891. if (page_max != -1)
  892. cpu_physical_memory_reset_dirty(page_min, page_max + TARGET_PAGE_SIZE,
  893. VGA_DIRTY_FLAG);
  894. }
  895. static void sm501_update_display(void *opaque)
  896. {
  897. SM501State * s = (SM501State *)opaque;
  898. if (s->dc_crt_control & SM501_DC_CRT_CONTROL_ENABLE)
  899. sm501_draw_crt(s);
  900. }
  901. void sm501_init(uint32_t base, unsigned long local_mem_base,
  902. uint32_t local_mem_bytes, CharDriverState *chr)
  903. {
  904. SM501State * s;
  905. int sm501_system_config_index;
  906. int sm501_disp_ctrl_index;
  907. /* allocate management data region */
  908. s = (SM501State *)qemu_mallocz(sizeof(SM501State));
  909. s->base = base;
  910. s->local_mem_size_index
  911. = get_local_mem_size_index(local_mem_bytes);
  912. SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s),
  913. s->local_mem_size_index);
  914. s->system_control = 0x00100000;
  915. s->misc_control = 0x00001000; /* assumes SH, active=low */
  916. s->dc_panel_control = 0x00010000;
  917. s->dc_crt_control = 0x00010000;
  918. /* allocate local memory */
  919. s->local_mem = (uint8 *)phys_ram_base + local_mem_base;
  920. cpu_register_physical_memory(base, local_mem_bytes, local_mem_base);
  921. /* map mmio */
  922. sm501_system_config_index
  923. = cpu_register_io_memory(0, sm501_system_config_readfn,
  924. sm501_system_config_writefn, s);
  925. cpu_register_physical_memory(base + MMIO_BASE_OFFSET,
  926. 0x6c, sm501_system_config_index);
  927. sm501_disp_ctrl_index = cpu_register_io_memory(0, sm501_disp_ctrl_readfn,
  928. sm501_disp_ctrl_writefn, s);
  929. cpu_register_physical_memory(base + MMIO_BASE_OFFSET + SM501_DC,
  930. 0x1000, sm501_disp_ctrl_index);
  931. /* bridge to serial emulation module */
  932. if (chr)
  933. serial_mm_init(base + MMIO_BASE_OFFSET + SM501_UART0, 2,
  934. 0, /* TODO : chain irq to IRL */
  935. 115200, chr, 1);
  936. /* create qemu graphic console */
  937. s->ds = graphic_console_init(sm501_update_display, NULL,
  938. NULL, NULL, s);
  939. }