17104f784Smrg/* 27104f784SmrgCopyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved. 37104f784SmrgCopyright (C) 2000 Silicon Motion, Inc. All Rights Reserved. 47104f784SmrgCopyright (C) 2008 Mandriva Linux. All Rights Reserved. 57104f784Smrg 67104f784SmrgPermission is hereby granted, free of charge, to any person obtaining a copy of 77104f784Smrgthis software and associated documentation files (the "Software"), to deal in 87104f784Smrgthe Software without restriction, including without limitation the rights to 97104f784Smrguse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 107104f784Smrgof the Software, and to permit persons to whom the Software is furnished to do 117104f784Smrgso, subject to the following conditions: 127104f784Smrg 137104f784SmrgThe above copyright notice and this permission notice shall be included in all 147104f784Smrgcopies or substantial portions of the Software. 157104f784Smrg 167104f784SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 177104f784SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 187104f784SmrgNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 197104f784SmrgXFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 207104f784SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 217104f784SmrgWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 227104f784Smrg 237104f784SmrgExcept as contained in this notice, the names of the XFree86 Project and 247104f784SmrgSilicon Motion shall not be used in advertising or otherwise to promote the 257104f784Smrgsale, use or other dealings in this Software without prior written 267104f784Smrgauthorization from the XFree86 Project and Silicon Motion. 277104f784Smrg*/ 287104f784Smrg 297104f784Smrg#ifndef _SMI_501_H 307104f784Smrg#define _SMI_501_H 317104f784Smrg 327104f784Smrg/* 337104f784Smrg * Documentation: 347104f784Smrg * ftp://ftp.siliconmotion.com.tw/databooks/SM501MSOCDatabook_VersionB_1.pdf 357104f784Smrg * 367104f784Smrg * ftp://ftp.siliconmotion.com.tw/databooks/SM502_MMCC_Databook_V1.00.pdf 377104f784Smrg */ 387104f784Smrg 397104f784Smrg#include <stdint.h> 407104f784Smrg 417104f784Smrg#define bits(lo, hi) hi + 1 - lo 427104f784Smrg 437104f784Smrg 447104f784Smrg#define DRAM_CTL 0x000010 457104f784Smrg 467104f784Smrg#define CMD_ADDR 0x000018 477104f784Smrg/* COMMAND LIST ADDRESS 487104f784Smrg * Read/Write MMIO_base + 0x000018 497104f784Smrg * Power-on Default N/A 507104f784Smrg * 517104f784Smrg * 0:27 The current address of the Command List. The Command List 527104f784Smrg * updates this address continuously. Bits [2:0] are hardwired 537104f784Smrg * to "0" since every command must be aligned on a 64-bit 547104f784Smrg * boundary. It always points to the instruction being executed. 557104f784Smrg * 28:29 Reserved 567104f784Smrg * 30:30 Idle status. 577104f784Smrg * 0: busy. 587104f784Smrg * 1: idle (default). 597104f784Smrg * 31:31 When this bit is programmed to "1" the Command List will 607104f784Smrg * fetch the first instruction from the Command List specified 617104f784Smrg * by the Command List Address field. It will remain "1" as long 627104f784Smrg * as the Command List is executing code in the Command List. 637104f784Smrg * As soon as you program this bit to "0", the Command List will 647104f784Smrg * stop executing. Programming it back to "1" will continue the 657104f784Smrg * Command List at the address it has left off. 667104f784Smrg */ 677104f784Smrgtypedef union _MSOCCmdAddrRec { 687104f784Smrg struct { 697104f784Smrg int32_t address : bits( 0, 27); 707104f784Smrg int32_t u0 : bits(28, 29); 717104f784Smrg int32_t idle : bits(30, 30); 727104f784Smrg int32_t start : bits(31, 31); 737104f784Smrg } f; 747104f784Smrg int32_t value; 757104f784Smrg} MSOCCmdAddrRec, *MSOCCmdAddrPtr; 767104f784Smrg 777104f784Smrg#define CMD_COND 0x00001c 787104f784Smrg#define CMD_RETADDR 0x000020 797104f784Smrg 807104f784Smrg#define CMD_STATUS 0x000024 817104f784Smrg/* COMMAND LIST STATUS 827104f784Smrg * Read/Write MMIO_base + 0x000024 837104f784Smrg * Power-on Default 0b0000.0000.000X.XXXX.XXXX.X000.0000.0XXX 847104f784Smrg * 857104f784Smrg * 0:0 2D Engine Status. 867104f784Smrg * 0: Idle. 877104f784Smrg * 1: Busy. 887104f784Smrg * 1:1 2D Command FIFO Status. 897104f784Smrg * 0: Not empty. 907104f784Smrg * 1: Empty. 917104f784Smrg * 2:2 2D Setup Engine Status. 927104f784Smrg * 0: Idle. 937104f784Smrg * 1: Busy. 947104f784Smrg * 3:10 Reserved 957104f784Smrg * 11:11 Panel Vertical Sync Status. 967104f784Smrg * 0: Not active. 977104f784Smrg * 1: Active. 987104f784Smrg * 12:12 CRT Vertical Sync Status. 997104f784Smrg * 0: Not active. 1007104f784Smrg * 1: Active. 1017104f784Smrg * 13:13 Panel Graphics Layer Status. 1027104f784Smrg * 0: No flip pending. 1037104f784Smrg * 1: Flip in progress. 1047104f784Smrg * 14:14 Video Layer Status. 1057104f784Smrg * 0: No flip pending. 1067104f784Smrg * 1: Flip in progress. 1077104f784Smrg * 15:15 Current Video Field. 1087104f784Smrg * 0: Odd. 1097104f784Smrg * 1: Even. 1107104f784Smrg * 16:16 CRT Graphics Layer Status. 1117104f784Smrg * 0: No flip pending. 1127104f784Smrg * 1: Flip in progress. 1137104f784Smrg * 17:17 Memory DMA Status. 1147104f784Smrg * 0: Idle. 1157104f784Smrg * 1: Busy. 1167104f784Smrg * 18:18 2D Color Space Conversion Status. 1177104f784Smrg * 0: Idle. 1187104f784Smrg * 1: Busy. 1197104f784Smrg * 19:19 Command FIFO on HIF bus. 1207104f784Smrg * 0: Not empty. 1217104f784Smrg * 1: Empty. 1227104f784Smrg * 20:20 2D Memory FIFO Status. 1237104f784Smrg * 0: Not empty. 1247104f784Smrg * 1: Empty. 1257104f784Smrg * 21:31 Reserved 1267104f784Smrg */ 1277104f784Smrgtypedef union _MSOCCmdStatusRec { 1287104f784Smrg struct { 1297104f784Smrg int32_t engine : bits( 0, 0); 1307104f784Smrg int32_t cmdfifo : bits( 1, 1); 1317104f784Smrg int32_t setup : bits( 2, 2); 1327104f784Smrg int32_t u0 : bits( 3, 10); 1337104f784Smrg int32_t pvsync : bits(11, 11); 1347104f784Smrg int32_t cvsync : bits(12, 12); 1357104f784Smrg int32_t player : bits(13, 13); 1367104f784Smrg int32_t vlayer : bits(14, 14); 1377104f784Smrg int32_t vfield : bits(15, 15); 1387104f784Smrg int32_t clayer : bits(16, 16); 1397104f784Smrg int32_t dma : bits(17, 17); 1407104f784Smrg int32_t csc : bits(18, 18); 1417104f784Smrg int32_t cmdhif : bits(19, 19); 1427104f784Smrg int32_t memfifo : bits(20, 20); 1437104f784Smrg int32_t u1 : bits(21, 31); 1447104f784Smrg } f; 1457104f784Smrg int32_t value; 1467104f784Smrg} MSOCCmdStatusRec, *MSOCCmdStatusPtr; 1477104f784Smrg 1487104f784Smrg/* contents of either power0_clock or power1_clock */ 1497104f784Smrg#define CURRENT_CLOCK 0x00003c 1507104f784Smrg 1517104f784Smrg#define POWER0_CLOCK 0x000044 1527104f784Smrg#define POWER1_CLOCK 0x00004c 1537104f784Smrg/* POWER MODE 0 CLOCK 1547104f784Smrg * Read/Write MMIO_base + 0x000044 1557104f784Smrg * Power-on Default 0x2A1A0A09 1567104f784Smrg * 1577104f784Smrg * POWER MODE 1 CLOCK 1587104f784Smrg * Read/Write MMIO_base + 0x00004C 1597104f784Smrg * Power-on Default 0x2A1A0A09 1607104f784Smrg * 1617104f784Smrg * 0:3 M1XCLK Frequency Divider 1627104f784Smrg * 0000 / 1 1000 / 3 1637104f784Smrg * 0001 / 2 1001 / 6 1647104f784Smrg * 0010 / 4 1010 / 12 1657104f784Smrg * 0011 / 8 1011 / 24 1667104f784Smrg * 0100 / 16 1100 / 48 1677104f784Smrg * 0101 / 32 1101 / 96 1687104f784Smrg * 0110 / 64 1110 / 192 1697104f784Smrg * 0111 / 128 1111 / 384 1707104f784Smrg * 4:4 M2XCLK Frequency Input Select. 1717104f784Smrg * 0: 288 MHz. 1727104f784Smrg * 1: 336 MHz/288 MHz/240 MHz/192 MHz 1737104f784Smrg * (see bits 5:4 in the Miscellaneous Timing register 1747104f784Smrg * at offset 0x68 on page 2-42). 1757104f784Smrg * 8:11 MCLK Frequency Divider. 1767104f784Smrg * 0000 / 1 1000 / 3 1777104f784Smrg * 0001 / 2 1001 / 6 1787104f784Smrg * 0010 / 4 1010 / 12 1797104f784Smrg * 0011 / 8 1011 / 24 1807104f784Smrg * 0100 / 16 1100 / 48 1817104f784Smrg * 0101 / 32 1101 / 96 1827104f784Smrg * 0110 / 64 1110 / 192 1837104f784Smrg * 0111 / 128 1111 / 384 1847104f784Smrg * 12:12 MCLK Frequency Input Select. 1857104f784Smrg * 0: 288 MHz. 1867104f784Smrg * 1: 336 MHz/288 MHz/240 MHz/192 MHz 1877104f784Smrg * (see bits 5:4 in the Miscellaneous Timing register 1887104f784Smrg * at offset 0x68 on page 2-42). 1897104f784Smrg * 16:19 V2XCLK DIVIDER 1907104f784Smrg * 0000 / 1 1000 / 3 1917104f784Smrg * 0001 / 2 1001 / 6 1927104f784Smrg * 0010 / 4 1010 / 12 1937104f784Smrg * 0011 / 8 1011 / 24 1947104f784Smrg * 0100 / 16 1100 / 48 1957104f784Smrg * 0101 / 32 1101 / 96 1967104f784Smrg * 0110 / 64 1110 / 192 1977104f784Smrg * 0111 / 128 1111 / 384 1987104f784Smrg * 20:20 V2XCLK SELECT (Crt clock) 1997104f784Smrg * 0: 288 MHz 2007104f784Smrg * 1: 336 MHz/288 MHz/240 MHz/192 MHz 2017104f784Smrg * (see bits 5:4 in the Miscellaneous Timing register 2027104f784Smrg * at offset 0x68 on page 2-42). 2037104f784Smrg * 21:21 Disable 2X V2XCLK. 2047104f784Smrg * 0: Normal. 2057104f784Smrg * 1: No need to feed 2X VCLK. 2067104f784Smrg * 24:28 P2XCLK DIVIDER 2077104f784Smrg * 00000 / 1 01000 / 3 10000 / 5 2087104f784Smrg * 00001 / 2 01001 / 6 10001 / 10 2097104f784Smrg * 00010 / 4 01010 / 12 10010 / 20 2107104f784Smrg * 00011 / 8 01011 / 24 10011 / 40 2117104f784Smrg * 00100 / 16 01100 / 48 10100 / 80 2127104f784Smrg * 00101 / 32 01101 / 96 10101 / 160 2137104f784Smrg * 00110 / 64 01110 / 192 10110 / 320 2147104f784Smrg * 00111 / 128 01111 / 384 10111 / 640 2157104f784Smrg * 29:29 P2XCLK SELECT (Panel clock) 2167104f784Smrg * 00: 288 MHz 2177104f784Smrg * 01: 336 MHz/288 MHz/240 MHz/192 MHz 2187104f784Smrg * (see bits 5:4 in the Miscellaneous Timing register 2197104f784Smrg * at offset 0x68 on page 2-42). 2207104f784Smrg * 30:30 PLL SELECT 2217104f784Smrg * 0: Use standard p2_xxx clock 2227104f784Smrg * 1: Use PLL_CONTROL (MMIO 0x074) for clock setting. 2237104f784Smrg * Available only for the panel. 2247104f784Smrg * 31:31 Disable 2X P2XCLK. 2257104f784Smrg * 0: Normal. 2267104f784Smrg * 1: 1X clock for P2CLK. 2277104f784Smrg */ 2287104f784Smrgtypedef union _MSOCClockRec { 2297104f784Smrg struct { 2307104f784Smrg /* Clock source for the local SDRAM controller. */ 2317104f784Smrg int32_t m1_shift : bits( 0, 2); 2327104f784Smrg int32_t m1_divider : bits( 3, 3); 2337104f784Smrg int32_t m1_select : bits( 4, 4); 2347104f784Smrg int32_t u0 : bits( 5, 7); 2357104f784Smrg /* Main clock source for all functional blocks, 2367104f784Smrg * such as the 2D engine, GPIO, Video Engine, DMA Engine. */ 2377104f784Smrg int32_t m_shift : bits( 8, 10); 2387104f784Smrg int32_t m_divider : bits(11, 11); 2397104f784Smrg int32_t m_select : bits(12, 12); 2407104f784Smrg int32_t u1 : bits(13, 15); 2417104f784Smrg /* 2X clock source for the CRT interface timing. 2427104f784Smrg * The actual rate at which the pixels are shifted 2437104f784Smrg * out is V2XCLK divided by two. */ 2447104f784Smrg int32_t v2_shift : bits(16, 18); 2457104f784Smrg int32_t v2_divider : bits(19, 19); 2467104f784Smrg int32_t v2_select : bits(20, 20); 2477104f784Smrg int32_t v2_1xclck : bits(21, 21); 2487104f784Smrg int32_t u2 : bits(22, 23); 2497104f784Smrg /* 2X clock source for the Panel interface timing. 2507104f784Smrg * The actual rate at which the pixels are shifted 2517104f784Smrg * out is P2XCLK divided by two. */ 2527104f784Smrg int32_t p2_shift : bits(24, 26); 2537104f784Smrg int32_t p2_divider : bits(27, 28); 2547104f784Smrg int32_t p2_select : bits(29, 29); 2557104f784Smrg /* If pll_select is set, an alternate clock selection, available 2567104f784Smrg * only in the 502 (using PLL_CTL, MMIO 0x074), will be used, 2577104f784Smrg * and p2_* values will be ignored. */ 2587104f784Smrg int32_t pll_select : bits(30, 30); 2597104f784Smrg /* If p2_1xclck is set, it means use 1x clock, otherwise 2607104f784Smrg * 2x clocks must be specified in p2_{shift,divider,select}. */ 2617104f784Smrg int32_t p2_1xclck : bits(31, 31); 2627104f784Smrg } f; 2637104f784Smrg int32_t value; 2647104f784Smrg} MSOCClockRec, *MSOCClockPtr; 2657104f784Smrg 2667104f784Smrgtypedef struct _MSOCRegRec { 2677104f784Smrg#define SYSTEM_CTL 0x000000 2687104f784Smrg /* SYSTEM CONTROL 2697104f784Smrg * Read/Write MMIO_base + 0x000000 2707104f784Smrg * Power-on Default 0b0000.0000.XX0X.X0XX.0000.0000.0000.0000 2717104f784Smrg * 2727104f784Smrg * 7:7 PCI Retry 2737104f784Smrg * 0: Enable 2747104f784Smrg * 1: Disable 2757104f784Smrg * 15:15 PCI Burst Read Enable. 2767104f784Smrg * The BE bit must be enabled as well for this bit to take effect. 2777104f784Smrg * (BE bit is bit 29, bit 15 is BrE) 2787104f784Smrg * 0: Disable. 2797104f784Smrg * 1: Enable. 2807104f784Smrg * 29:29 PCI Burst Enable. 2817104f784Smrg * 0: Disable. 2827104f784Smrg * 1: Enable. 2837104f784Smrg * 30:31 Vertical Sync Horizontal Sync 2847104f784Smrg * 00 Pulsing Pulsing 2857104f784Smrg * 01 Pulsing Not pulsing 2867104f784Smrg * 10 Not pulsing Pulsing 2877104f784Smrg * 11 Not pulsing Not pulsing 2887104f784Smrg */ 2897104f784Smrg union { 2907104f784Smrg struct { 2917104f784Smrg int32_t u0 : bits( 0, 6); 2927104f784Smrg int32_t retry : bits( 7, 7); 2937104f784Smrg int32_t u1 : bits( 8, 14); 2947104f784Smrg int32_t burst_read : bits(15, 15); 2957104f784Smrg int32_t u2 : bits(16, 28); 2967104f784Smrg int32_t burst : bits(29, 29); 2977104f784Smrg int32_t dpmsh : bits(30, 30); 2987104f784Smrg int32_t dpmsv : bits(31, 31); 2997104f784Smrg } f; 3007104f784Smrg int32_t value; 3017104f784Smrg } system_ctl; 3027104f784Smrg 3037104f784Smrg#define MISC_CTL 0x000004 3047104f784Smrg /* Miscellaneous Control 3057104f784Smrg * Read/Write MMIO_base + 0x000004 3067104f784Smrg * Power-on Default 0b0000.0000.0000.00X0.0001.0000.XXX0.0XXX 3077104f784Smrg * 3087104f784Smrg * 12:12 DAC Power Control. 3097104f784Smrg * 0: Enable. 3107104f784Smrg * 1: Disable. 3117104f784Smrg * 24:24 Crystal Frequency Select. 3127104f784Smrg * 0: 24MHz. 3137104f784Smrg * 1: 12MHz 3147104f784Smrg */ 3157104f784Smrg union { 3167104f784Smrg struct { 3177104f784Smrg int32_t u0 : bits( 0, 11); 3187104f784Smrg int32_t dac : bits(12, 12); 3197104f784Smrg int32_t u1 : bits(13, 23); 3207104f784Smrg int32_t frequency : bits(24, 24); 3217104f784Smrg } f; 3227104f784Smrg int32_t value; 3237104f784Smrg } misc_ctl; 3247104f784Smrg 3257104f784Smrg#define POWER0_GATE 0x000040 3267104f784Smrg#define POWER1_GATE 0x000048 3277104f784Smrg /* POWER MODE 0 GATE 3287104f784Smrg * Read/Write MMIO_base + 0x000040 3297104f784Smrg * Power-on Default 0x00021807 3307104f784Smrg * 3317104f784Smrg * POWER MODE 1 GATE 3327104f784Smrg * Read/Write MMIO_base + 0x000048 3337104f784Smrg * Power-on Default 0x00021807 3347104f784Smrg * 3357104f784Smrg * 3:3 2D Engine Clock Control. 3367104f784Smrg * 0: Disable. 3377104f784Smrg * 1: Enable. 3387104f784Smrg * 4:4 Color Space Conversion Clock Control. 3397104f784Smrg * 0: Disable. 3407104f784Smrg * 1: Enable. 3417104f784Smrg * 5:5 ZV-Port Clock Control. 3427104f784Smrg * 0: Disable. 3437104f784Smrg * 1: Enable. 3447104f784Smrg * 6:6 GPIO, PWM, and I2C Clock Control. 3457104f784Smrg * 0: Disable. 3467104f784Smrg * 1: Enable. 3477104f784Smrg */ 3487104f784Smrg union { 3497104f784Smrg struct { 3507104f784Smrg int32_t u0 : bits(0, 2); 3517104f784Smrg int32_t engine : bits(3, 3); 3527104f784Smrg int32_t csc : bits(4, 4); 3537104f784Smrg int32_t zv : bits(5, 5); 3547104f784Smrg int32_t gpio : bits(6, 6); 3557104f784Smrg } f; 3567104f784Smrg int32_t value; 3577104f784Smrg } gate; 3587104f784Smrg int32_t current_gate; 3597104f784Smrg 3607104f784Smrg MSOCClockRec clock; 3617104f784Smrg int32_t current_clock; 3627104f784Smrg 3637104f784Smrg#define SLEEP_GATE 0x000050 3647104f784Smrg /* SLEEP MODE GATE 3657104f784Smrg * Read/Write MMIO_base + 0x000050 3667104f784Smrg * Power-on Default 0x00018000 3677104f784Smrg * 3687104f784Smrg * 13:14 PLL Recovery. 3697104f784Smrg * 00: 1ms (32 counts). 3707104f784Smrg * 01: 2ms (64 counts). 3717104f784Smrg * 10: 3ms (96 counts). 3727104f784Smrg * 11: 4ms (128 counts). 3737104f784Smrg * 19:22 PLL Recovery Clock Divider. 3747104f784Smrg * 0000 / 4096 0100 / 256 1000 / 16 3757104f784Smrg * 0001 / 2048 0101 / 128 1001 / 8 3767104f784Smrg * 0010 / 1024 0110 / 64 1010 / 4 3777104f784Smrg * 0011 / 512 0111 / 32 1011 / 2 3787104f784Smrg * Internally, the PLL recovery time counters are based on a 32 us 3797104f784Smrg * clock. So you have to program the D field (19:22) to make the 3807104f784Smrg * host clock come as close to 33 us as possible. 3817104f784Smrg */ 3827104f784Smrg union { 3837104f784Smrg struct { 3847104f784Smrg int32_t u0 : bits( 0, 12); 3857104f784Smrg int32_t recovery : bits(13, 14); 3867104f784Smrg int32_t u1 : bits(15, 18); 3877104f784Smrg int32_t divider : bits(19, 22); 3887104f784Smrg } f; 3897104f784Smrg int32_t value; 3907104f784Smrg } sleep_gate; 3917104f784Smrg 3927104f784Smrg#define POWER_CTL 0x000054 3937104f784Smrg /* POWER MODE CONTROL 3947104f784Smrg * Read/Write MMIO_base + 0x000054 3957104f784Smrg * Power-on Default 0x00000000 3967104f784Smrg * 3977104f784Smrg * 1:0 Power Mode Select. 3987104f784Smrg * 00: Power Mode 0. 3997104f784Smrg * 01: Power Mode 1. 4007104f784Smrg * 10: Sleep Mode. 4017104f784Smrg * 2:2 Current Sleep Status. 4027104f784Smrg * 0: Not in sleep mode. 4037104f784Smrg * 1: In sleep mode. 4047104f784Smrg * When the SM501 is transitioning back from sleep mode to a normal 4057104f784Smrg * power mode (Modes 0 or 1), the software needs to poll this bit 4067104f784Smrg * until it becomes "0" before writing any other commands to the chip. 4077104f784Smrg */ 4087104f784Smrg union { 4097104f784Smrg struct { 4107104f784Smrg int32_t mode : bits(0, 1); 4117104f784Smrg int32_t status : bits(2, 2); 4127104f784Smrg } f; 4137104f784Smrg int32_t value; 4147104f784Smrg } power_ctl; 4157104f784Smrg 4167104f784Smrg 4177104f784Smrg#define DEVICE_ID 0x000060 4187104f784Smrg /* DEVICE ID 4197104f784Smrg * Read/Write MMIO_base + 0x000060 4207104f784Smrg * Power-on Default 0x050100A0 4217104f784Smrg * 4227104f784Smrg * 0:7 Revision Identification: (0xC0 for the 502). 4237104f784Smrg * 16:31 DeviceId Device Identification: 0x0501. 4247104f784Smrg */ 4257104f784Smrg union { 4267104f784Smrg struct { 4277104f784Smrg int32_t revision : bits( 0, 7); 4287104f784Smrg int32_t u0 : bits( 8, 15); 4297104f784Smrg int32_t ident : bits(16, 31); 4307104f784Smrg } f; 4317104f784Smrg int32_t value; 4327104f784Smrg } device_id; 4337104f784Smrg 4347104f784Smrg#define TIMING_CTL 0x000068 4357104f784Smrg /* Miscellaneous Control 4367104f784Smrg * Read/Write MMIO_base + 0x000068 4377104f784Smrg * Power-on Default 0x00000000 4387104f784Smrg * 4397104f784Smrg * 4:5 PLL Input frequency 4407104f784Smrg * 00: the output of PLL2 = 48 MHz x 7 = 336 MHz, power on default 4417104f784Smrg * 01: the output of PLL2 = 48 MHz x 6 = 288 MHz 4427104f784Smrg * 10: the output of PLL2 = 48 MHz x 5 = 240 MHz 4437104f784Smrg * 11: the output of PLL2 = 48 MHz x 4 = 192 MHz 4447104f784Smrg */ 4457104f784Smrg union { 4467104f784Smrg struct { 4477104f784Smrg int32_t u0 : bits( 0, 3); 4487104f784Smrg int32_t pll : bits( 4, 5); 4497104f784Smrg } f; 4507104f784Smrg int32_t value; 4517104f784Smrg } timing_ctl; 4527104f784Smrg 4537104f784Smrg#define PLL_CTL 0x000074 4547104f784Smrg /* Programmable PLL Control 4557104f784Smrg * Read/Write MMIO_base + 0x000074 4567104f784Smrg * Power-on Default 0x000000FF 4577104f784Smrg * 0:7 PLL M Value 4587104f784Smrg * 8:14 PLL N Value 4597104f784Smrg * 15:15 PLL Output Divided by 2. 4607104f784Smrg * 0: Disable. 4617104f784Smrg * 1: Enable. 4627104f784Smrg * 16:16 PLL Clock Select. 4637104f784Smrg * 0: Crystal input. 4647104f784Smrg * 1: Test clock input. 4657104f784Smrg * 17:17 PLL Power Down. 4667104f784Smrg * 0: Power down. 4677104f784Smrg * 1: Power on. 4687104f784Smrg * 4697104f784Smrg * The formula is: 4707104f784Smrg * Requested Pixel Clock = Input Frequency * M / N 4717104f784Smrg * Input Frequency is the input crystal frequency value (24 MHz in 4727104f784Smrg * the SMI VGX Demo Board). N must be a value between 2 and 24. 4737104f784Smrg * M can be any (8 bits) value, and a loop testing all possible N 4747104f784Smrg * values should be the best approach to calculate it's value. 4757104f784Smrg */ 4767104f784Smrg union { 4777104f784Smrg struct { 4787104f784Smrg int32_t m : bits( 0, 7); 4797104f784Smrg int32_t n : bits( 8, 14); 4807104f784Smrg int32_t divider : bits(15, 15); 4817104f784Smrg int32_t select : bits(16, 16); 4827104f784Smrg int32_t power : bits(17, 17); 4837104f784Smrg } f; 4847104f784Smrg int32_t value; 4857104f784Smrg } pll_ctl; 4867104f784Smrg 4877104f784Smrg#define PANEL_DISPLAY_CTL 0x080000 4887104f784Smrg /* PANEL DISPLAY CONTROL 4897104f784Smrg * Read MMIO_base + 0x080000 4907104f784Smrg * Power-on Default 0x00010000 4917104f784Smrg * 4927104f784Smrg * 1:0 Format Panel Graphics Plane Format. 4937104f784Smrg * 00: 8-bit indexed mode. 4947104f784Smrg * 01: 16-bit RGB 5:6:5 mode. 4957104f784Smrg * 10: 32-bit RGB 8:8:8 mode. 4967104f784Smrg * 2:2 Panel Graphics Plane Enable. 4977104f784Smrg * 0: Disable panel graphics plane. 4987104f784Smrg * 1: Enable panel graphics plane. 4997104f784Smrg * 3:3 Enable Gamma Control. Gamma control can only 5007104f784Smrg * be enabled in RGB 5:6:5 and RGB 8:8:8 modes. 5017104f784Smrg * 0: Disable. 5027104f784Smrg * 1: Enable. 5037104f784Smrg * 8:8 Enable Panel Timing. 5047104f784Smrg * 0: Disable panel timing. 5057104f784Smrg * 1: Enable panel timing. 5067104f784Smrg * 12:12 Horizontal Sync Pulse Phase Select. 5077104f784Smrg * 0: Horizontal sync pulse active high. 5087104f784Smrg * 1: Horizontal sync pulse active low. 5097104f784Smrg * 13:13 Vertical Sync Pulse Phase Select. 5107104f784Smrg * 0: Vertical sync pulse active high. 5117104f784Smrg * 1: Vertical sync pulse active low. 5127104f784Smrg * 24:24 Control FPVDDEN Output Pin. 5137104f784Smrg * 0: Driven low. 5147104f784Smrg * 1: Driven high. 5157104f784Smrg * 25:25 Panel Control Signals and Data Lines Enable. 5167104f784Smrg * 0: Disable panel control signals and data lines. 5177104f784Smrg * 1: Enable panel control signals and data lines. 5187104f784Smrg * 26:26 Control VBIASEN Output Pin. 5197104f784Smrg * 0: Driven low. 5207104f784Smrg * 1: Driven high. 5217104f784Smrg * 27:27 Control FPEN Output Pin. 5227104f784Smrg * 0: Driven low. 5237104f784Smrg * 1: Driven high. 5247104f784Smrg */ 5257104f784Smrg union { 5267104f784Smrg struct { 5277104f784Smrg int32_t format : bits( 0, 1); 5287104f784Smrg int32_t enable : bits( 2, 2); 5297104f784Smrg int32_t gamma : bits( 3, 3); 5307104f784Smrg int32_t u0 : bits( 4, 7); 5317104f784Smrg int32_t timing : bits( 8, 8); 5327104f784Smrg int32_t u1 : bits( 9, 11); 5337104f784Smrg int32_t hsync : bits(12, 12); 5347104f784Smrg int32_t vsync : bits(13, 13); 5357104f784Smrg int32_t u2 : bits(14, 23); 5367104f784Smrg int32_t vdd : bits(24, 24); 5377104f784Smrg int32_t signal : bits(25, 25); 5387104f784Smrg int32_t bias : bits(26, 26); 5397104f784Smrg int32_t fp : bits(27, 27); 5407104f784Smrg } f; 5417104f784Smrg int32_t value; 5427104f784Smrg } panel_display_ctl; 5437104f784Smrg 5447104f784Smrg#define PANEL_FB_ADDRESS 0x08000c 5457104f784Smrg /* PANEL FB ADDRESS 5467104f784Smrg * Read/Write MMIO_base + 0x08000C 5477104f784Smrg * Power-on Default Undefined 5487104f784Smrg * 5497104f784Smrg * 4:25 Address Memory address of frame buffer for the 5507104f784Smrg * panel graphics plane with 128-bit alignment. 5517104f784Smrg * 26:26 Chip Select for External Memory. 5527104f784Smrg * 0: CS0 of external memory. 5537104f784Smrg * 1: CS1 of external memory. 5547104f784Smrg * 27:27 Ext Memory Selection. 5557104f784Smrg * 0: Local memory. 5567104f784Smrg * 1: External memory. 5577104f784Smrg * 31:31 Status Bit. 5587104f784Smrg * 0: No flip pending. 5597104f784Smrg * 1: Flip pending. 5607104f784Smrg */ 5617104f784Smrg union { 5627104f784Smrg struct { 5637104f784Smrg int32_t u0 : bits( 0, 3); 5647104f784Smrg int32_t address : bits( 4, 25); 5657104f784Smrg int32_t mextern : bits(26, 26); 5667104f784Smrg int32_t mselect : bits(27, 27); 5677104f784Smrg int32_t u1 : bits(28, 30); 5687104f784Smrg int32_t pending : bits(31, 31); 5697104f784Smrg } f; 5707104f784Smrg int32_t value; 5717104f784Smrg } panel_fb_address; 5727104f784Smrg 5737104f784Smrg#define PANEL_FB_WIDTH 0x080010 5747104f784Smrg /* PANEL FB WIDTH 5757104f784Smrg * Read/Write MMIO_base + 0x080010 5767104f784Smrg * Power-on Default Undefined 5777104f784Smrg * 5787104f784Smrg * 4:13 Number of 128-bit aligned bytes per line of the FB 5797104f784Smrg * graphics plane 5807104f784Smrg * 20:29 Number of bytes per line of the panel graphics window 5817104f784Smrg * specified in 128-bit aligned bytes. 5827104f784Smrg */ 5837104f784Smrg union { 5847104f784Smrg struct { 5857104f784Smrg int32_t u0 : bits( 0, 3); 5867104f784Smrg int32_t offset : bits( 4, 13); 5877104f784Smrg int32_t u1 : bits(14, 19); 5887104f784Smrg int32_t width : bits(20, 29); 5897104f784Smrg } f; 5907104f784Smrg int32_t value; 5917104f784Smrg } panel_fb_width; 5927104f784Smrg 5937104f784Smrg#define PANEL_WWIDTH 0x080014 5947104f784Smrg /* PANEL WINDOW WIDTH 5957104f784Smrg * Read/Write MMIO_base + 0x080014 5967104f784Smrg * Power-on Default Undefined 5977104f784Smrg * 5987104f784Smrg * 0:11 Starting x-coordinate of panel graphics window 5997104f784Smrg * specified in pixels. 6007104f784Smrg * 16:27 Width of FB graphics window specified in pixels. 6017104f784Smrg */ 6027104f784Smrg union { 6037104f784Smrg struct { 6047104f784Smrg int32_t x : bits( 0, 11); 6057104f784Smrg int32_t u0 : bits(12, 15); 6067104f784Smrg int32_t width : bits(16, 27); 6077104f784Smrg } f; 6087104f784Smrg int32_t value; 6097104f784Smrg } panel_wwidth; 6107104f784Smrg 6117104f784Smrg#define PANEL_WHEIGHT 0x080018 6127104f784Smrg /* PANEL WINDOW HEIGHT 6137104f784Smrg * Read/Write MMIO_base + 0x080018 6147104f784Smrg * Power-on Default Undefined 6157104f784Smrg * 6167104f784Smrg * 0:11 Starting y-coordinate of panel graphics window 6177104f784Smrg * specified in pixels. 6187104f784Smrg * 16:27 Height of FB graphics window specified in pixels. 6197104f784Smrg */ 6207104f784Smrg union { 6217104f784Smrg struct { 6227104f784Smrg int32_t y : bits( 0, 11); 6237104f784Smrg int32_t u0 : bits(12, 15); 6247104f784Smrg int32_t height : bits(16, 27); 6257104f784Smrg } f; 6267104f784Smrg int32_t value; 6277104f784Smrg } panel_wheight; 6287104f784Smrg 6297104f784Smrg#define PANEL_PLANE_TL 0x08001c 6307104f784Smrg /* PANEL PLANE TL 6317104f784Smrg * Read/Write MMIO_base + 0x08001c 6327104f784Smrg * Power-on Default Undefined 6337104f784Smrg * 6347104f784Smrg * 0:10 Left location of the panel graphics plane specified in pixels. 6357104f784Smrg * 16:26 Top location of the panel graphics plane specified in lines. 6367104f784Smrg */ 6377104f784Smrg union { 6387104f784Smrg struct { 6397104f784Smrg int32_t left : bits( 0, 10); 6407104f784Smrg int32_t u0 : bits(11, 15); 6417104f784Smrg int32_t top : bits(16, 26); 6427104f784Smrg } f; 6437104f784Smrg int32_t value; 6447104f784Smrg } panel_plane_tl; 6457104f784Smrg 6467104f784Smrg#define PANEL_PLANE_BR 0x080020 6477104f784Smrg /* PANEL PLANE BR 6487104f784Smrg * Read/Write MMIO_base + 0x080020 6497104f784Smrg * Power-on Default Undefined 6507104f784Smrg * 6517104f784Smrg * 0:10 Right location of the panel graphics plane specified in pixels. 6527104f784Smrg * 16:26 Bottom location of the panel graphics plane specified in lines. 6537104f784Smrg */ 6547104f784Smrg union { 6557104f784Smrg struct { 6567104f784Smrg int32_t right : bits( 0, 10); 6577104f784Smrg int32_t u0 : bits(11, 15); 6587104f784Smrg int32_t bottom : bits(16, 26); 6597104f784Smrg } f; 6607104f784Smrg int32_t value; 6617104f784Smrg } panel_plane_br; 6627104f784Smrg 6637104f784Smrg#define PANEL_HTOTAL 0x080024 6647104f784Smrg /* PANEL HORIZONTAL TOTAL 6657104f784Smrg * Read/Write MMIO_base + 0x080024 6667104f784Smrg * Power-on Default Undefined 6677104f784Smrg * 6687104f784Smrg * 0:11 Panel horizontal display end specified as number of pixels - 1. 6697104f784Smrg * 16:27 Panel horizontal total specified as number of pixels - 1. 6707104f784Smrg */ 6717104f784Smrg union { 6727104f784Smrg struct { 6737104f784Smrg int32_t end : bits( 0, 11); 6747104f784Smrg int32_t u0 : bits(12, 15); 6757104f784Smrg int32_t total : bits(16, 27); 6767104f784Smrg } f; 6777104f784Smrg int32_t value; 6787104f784Smrg } panel_htotal; 6797104f784Smrg 6807104f784Smrg#define PANEL_HSYNC 0x080028 6817104f784Smrg /* PANEL HORIZONTAL SYNC 6827104f784Smrg * Read/Write MMIO_base + 0x080028 6837104f784Smrg * Power-on Default Undefined 6847104f784Smrg * 6857104f784Smrg * 0:11 HS Panel horizontal sync start specified as pixel number - 1. 6867104f784Smrg * 16:23 HSW Panel horizontal sync width specified in pixels. 6877104f784Smrg */ 6887104f784Smrg union { 6897104f784Smrg struct { 6907104f784Smrg int32_t start : bits( 0, 11); 6917104f784Smrg int32_t u0 : bits(12, 15); 6927104f784Smrg int32_t width : bits(16, 23); 6937104f784Smrg } f; 6947104f784Smrg int32_t value; 6957104f784Smrg } panel_hsync; 6967104f784Smrg 6977104f784Smrg#define PANEL_VTOTAL 0x08002c 6987104f784Smrg /* PANEL VERTICAL TOTAL 6997104f784Smrg * Read/Write MMIO_base + 0x08002C 7007104f784Smrg * Power-on Default Undefined 7017104f784Smrg * 7027104f784Smrg * 0:11 VDE Panel vertical display end specified as number of pixels - 1. 7037104f784Smrg * 16:27 VT Panel vertical total specified as number of pixels - 1. 7047104f784Smrg */ 7057104f784Smrg union { 7067104f784Smrg struct { 7077104f784Smrg int32_t end : bits( 0, 11); 7087104f784Smrg int32_t u0 : bits(12, 15); 7097104f784Smrg int32_t total : bits(16, 27); 7107104f784Smrg } f; 7117104f784Smrg int32_t value; 7127104f784Smrg } panel_vtotal; 7137104f784Smrg 7147104f784Smrg#define PANEL_VSYNC 0x080030 7157104f784Smrg /* PANEL VERTICAL SYNC 7167104f784Smrg * Read/Write MMIO_base + 0x080030 7177104f784Smrg * Power-on Default Undefined 7187104f784Smrg * 7197104f784Smrg * 0:11 VS Panel vertical sync start specified as pixel number - 1. 7207104f784Smrg * 16:23 VSH Panel vertical sync height specified in pixels. 7217104f784Smrg */ 7227104f784Smrg union { 7237104f784Smrg struct { 7247104f784Smrg int32_t start : bits( 0, 11); 7257104f784Smrg int32_t u0 : bits(12, 15); 7267104f784Smrg int32_t height : bits(16, 23); 7277104f784Smrg } f; 7287104f784Smrg int32_t value; 7297104f784Smrg } panel_vsync; 7307104f784Smrg 7317104f784Smrg#define ALPHA_DISPLAY_CTL 0x080100 7327104f784Smrg /* ALPHA DISPLAY CONTROL 7337104f784Smrg * Read MMIO base + 0x080100 7347104f784Smrg * Power-on Default 0x00010000 7357104f784Smrg * 7367104f784Smrg * 0:1 Alpha Plane Format 7377104f784Smrg * 01: 16-bit RGB 5:6:5 mode. 7387104f784Smrg * 10: 8-bit indexed a|4:4 mode. 7397104f784Smrg * 11: 16-bit aRGB 4:4:4:4 mode. 7407104f784Smrg * 2:2 Alpha Plane Enable 7417104f784Smrg * 0: Disable Alpha Plane 7427104f784Smrg * 1: Enable Alpha Plane 7437104f784Smrg * 3:3 Enable Chroma Key. 7447104f784Smrg * 0: Disable chroma key. 7457104f784Smrg * 1: Enable chroma key. 7467104f784Smrg * 24:27 Alpha Plane Alpha Value. 7477104f784Smrg * This field is only valid when bit 28 is set. 7487104f784Smrg * 28:28 Alpha Select. 7497104f784Smrg * 0: 0: Use per-pixel alpha values. 7507104f784Smrg * 1: Use alpha value specified in Alpha. 7517104f784Smrg */ 7527104f784Smrg union { 7537104f784Smrg struct { 7547104f784Smrg int32_t format : bits( 0, 1); 7557104f784Smrg int32_t enable : bits( 2, 2); 7567104f784Smrg int32_t chromakey : bits( 3, 3); 7577104f784Smrg int32_t u0 : bits( 4, 23); 7587104f784Smrg int32_t alpha : bits(24, 27); 7597104f784Smrg int32_t select : bits(28, 28); 7607104f784Smrg } f; 7617104f784Smrg int32_t value; 7627104f784Smrg } alpha_display_ctl; 7637104f784Smrg 7647104f784Smrg#define ALPHA_FB_ADDRESS 0x080104 7657104f784Smrg /* ALPHA FB ADDRESS 7667104f784Smrg * Read/Write MMIO_base + 0x080104 7677104f784Smrg * Power-on Default Undefined 7687104f784Smrg * 7697104f784Smrg * 4:25 Address Memory address of frame buffer for the 7707104f784Smrg * CRT graphics plane with 128-bit alignment. 7717104f784Smrg * 26:26 Chip Select for External Memory. 7727104f784Smrg * 0: CS0 of external memory. 7737104f784Smrg * 1: CS1 of external memory. 7747104f784Smrg * 27:27 Ext Memory Selection. 7757104f784Smrg * 0: Local memory. 7767104f784Smrg * 1: External memory. 7777104f784Smrg * 31:31 Status Bit. 7787104f784Smrg * 0: No flip pending. 7797104f784Smrg * 1: Flip pending. 7807104f784Smrg */ 7817104f784Smrg union { 7827104f784Smrg struct { 7837104f784Smrg int32_t u0 : bits( 0, 3); 7847104f784Smrg int32_t address : bits( 4, 25); 7857104f784Smrg int32_t mextern : bits(26, 26); 7867104f784Smrg int32_t mselect : bits(27, 27); 7877104f784Smrg int32_t u1 : bits(28, 30); 7887104f784Smrg int32_t pending : bits(31, 31); 7897104f784Smrg } f; 7907104f784Smrg int32_t value; 7917104f784Smrg } alpha_fb_address; 7927104f784Smrg 7937104f784Smrg#define ALPHA_FB_WIDTH 0x080108 7947104f784Smrg /* ALPHA FB WIDTH 7957104f784Smrg * Read/Write MMIO_base + 0x080108 7967104f784Smrg * Power-on Default Undefined 7977104f784Smrg * 7987104f784Smrg * 4:13 Number of 128-bit aligned bytes per line of the FB 7997104f784Smrg * graphics plane 8007104f784Smrg * 20:29 Number of bytes per line of the alpha window 8017104f784Smrg * specified in 128-bit aligned bytes. 8027104f784Smrg */ 8037104f784Smrg union { 8047104f784Smrg struct { 8057104f784Smrg int32_t u0 : bits( 0, 3); 8067104f784Smrg int32_t offset : bits( 4, 13); 8077104f784Smrg int32_t u1 : bits(14, 19); 8087104f784Smrg int32_t width : bits(20, 29); 8097104f784Smrg } f; 8107104f784Smrg int32_t value; 8117104f784Smrg } alpha_fb_width; 8127104f784Smrg 8137104f784Smrg#define ALPHA_PLANE_TL 0x08010c 8147104f784Smrg /* ALPHA PLANE TL 8157104f784Smrg * Read/Write MMIO_base + 0x08010c 8167104f784Smrg * Power-on Default Undefined 8177104f784Smrg * 8187104f784Smrg * 0:10 Left location of the panel graphics plane specified in pixels. 8197104f784Smrg * 16:26 Top location of the panel graphics plane specified in lines. 8207104f784Smrg */ 8217104f784Smrg union { 8227104f784Smrg struct { 8237104f784Smrg int32_t left : bits( 0, 10); 8247104f784Smrg int32_t u0 : bits(11, 15); 8257104f784Smrg int32_t top : bits(16, 26); 8267104f784Smrg } f; 8277104f784Smrg int32_t value; 8287104f784Smrg } alpha_plane_tl; 8297104f784Smrg 8307104f784Smrg#define ALPHA_PLANE_BR 0x080110 8317104f784Smrg /* ALPHA PLANE BR 8327104f784Smrg * Read/Write MMIO_base + 0x080110 8337104f784Smrg * Power-on Default Undefined 8347104f784Smrg * 8357104f784Smrg * 0:10 Right location of the panel graphics plane specified in pixels. 8367104f784Smrg * 16:26 Bottom location of the panel graphics plane specified in lines. 8377104f784Smrg */ 8387104f784Smrg union { 8397104f784Smrg struct { 8407104f784Smrg int32_t right : bits( 0, 10); 8417104f784Smrg int32_t u0 : bits(11, 15); 8427104f784Smrg int32_t bottom : bits(16, 26); 8437104f784Smrg } f; 8447104f784Smrg int32_t value; 8457104f784Smrg } alpha_plane_br; 8467104f784Smrg 8477104f784Smrg#define ALPHA_CHROMA_KEY 0x080114 8487104f784Smrg /* ALPHA PLANE BR 8497104f784Smrg * Read/Write MMIO_base + 0x080114 8507104f784Smrg * Power-on Default Undefined 8517104f784Smrg * 8527104f784Smrg * 0:15 Chroma Key Value for Alpha Plane. 8537104f784Smrg * 16:31 Chroma Key Mask for Alpha Plane. 8547104f784Smrg * 0: Compare respective bit. 8557104f784Smrg * 1: Do not compare respective bit. 8567104f784Smrg * Note that the 0 and 1 values are mean't for every one of 8577104f784Smrg * the 16 5:6:5 bits 8587104f784Smrg */ 8597104f784Smrg union { 8607104f784Smrg struct { 8617104f784Smrg int32_t value : bits( 0, 15); 8627104f784Smrg int32_t mask : bits(16, 31); 8637104f784Smrg } f; 8647104f784Smrg int32_t value; 8657104f784Smrg } alpha_chroma_key; 8667104f784Smrg 8677104f784Smrg /* 0x080118 to 0x80134 16 4 bit indexed rgb 5:6:5 table */ 8687104f784Smrg#define ALPHA_COLOR_LOOKUP 0x080118 8697104f784Smrg 8707104f784Smrg#define CRT_DISPLAY_CTL 0x080200 8717104f784Smrg /* CRT DISPLAY CONTROL 8727104f784Smrg * Read MMIO_base + 0x080200 8737104f784Smrg * Power-on Default 0x00010000 8747104f784Smrg * 8757104f784Smrg * 0:1 Format Panel Graphics Plane Format. 8767104f784Smrg * 00: 8-bit indexed mode. 8777104f784Smrg * 01: 16-bit RGB 5:6:5 mode. 8787104f784Smrg * 10: 32-bit RGB 8:8:8 mode. 8797104f784Smrg * 2:2 CRT Graphics Plane Enable. 8807104f784Smrg * 0: Disable CRT Graphics plane. 8817104f784Smrg * 1: Enable CRT Graphics plane. 8827104f784Smrg * 3:3 Enable Gamma Control. Gamma control can be enabled 8837104f784Smrg * only in RGB 5:6:5 and RGB 8:8:8 modes. 8847104f784Smrg * 0: Disable gamma control. 8857104f784Smrg * 1: Enable gamma control. 8867104f784Smrg * 4:7 Starting Pixel Number for Smooth Pixel Panning. 8877104f784Smrg * 8:8 Enable CRT Timing. 8887104f784Smrg * 0: Disable CRT timing. 8897104f784Smrg * 1: Enable CRT timing. 8907104f784Smrg * 9:9: CRT Data Select. 8917104f784Smrg * 0: CRT will display panel data. 8927104f784Smrg * 1: CRT will display CRT data. 8937104f784Smrg * 10:10 CRT Data Blanking. 8947104f784Smrg * 0: CRT will show pixels. 8957104f784Smrg * 1: CRT will be blank. 8967104f784Smrg * 11:11 Vertical Sync. This bit is read only. 8977104f784Smrg * 12:12 Horizontal Sync Pulse Phase Select. 8987104f784Smrg * 0: Horizontal sync pulse active high. 8997104f784Smrg * 1: Horizontal sync pulse active low. 9007104f784Smrg * 13:13 Vertical Sync Pulse Phase Select. 9017104f784Smrg * 0: Vertical sync pulse active high. 9027104f784Smrg * 1: Vertical sync pulse active low. 9037104f784Smrg */ 9047104f784Smrg union { 9057104f784Smrg struct { 9067104f784Smrg int32_t format : bits( 0, 1); 9077104f784Smrg int32_t enable : bits( 2, 2); 9087104f784Smrg int32_t gamma : bits( 3, 3); 9097104f784Smrg int32_t pixel : bits( 4, 7); 9107104f784Smrg int32_t timing : bits( 8, 8); 9117104f784Smrg int32_t select : bits( 9, 9); 9127104f784Smrg int32_t blank : bits(10, 10); 9137104f784Smrg int32_t sync : bits(11, 11); 9147104f784Smrg int32_t hsync : bits(12, 12); 9157104f784Smrg int32_t vsync : bits(13, 13); 9167104f784Smrg } f; 9177104f784Smrg int32_t value; 9187104f784Smrg } crt_display_ctl; 9197104f784Smrg 9207104f784Smrg#define CRT_FB_ADDRESS 0x080204 9217104f784Smrg /* CRT FB ADDRESS 9227104f784Smrg * Read/Write MMIO_base + 0x080204 9237104f784Smrg * Power-on Default Undefined 9247104f784Smrg * 9257104f784Smrg * 4:25 Address Memory address of frame buffer for the 9267104f784Smrg * CRT graphics plane with 128-bit alignment. 9277104f784Smrg * 26:26 Chip Select for External Memory. 9287104f784Smrg * 0: CS0 of external memory. 9297104f784Smrg * 1: CS1 of external memory. 9307104f784Smrg * 27:27 Ext Memory Selection. 9317104f784Smrg * 0: Local memory. 9327104f784Smrg * 1: External memory. 9337104f784Smrg * 31:31 Status Bit. 9347104f784Smrg * 0: No flip pending. 9357104f784Smrg * 1: Flip pending. 9367104f784Smrg */ 9377104f784Smrg union { 9387104f784Smrg struct { 9397104f784Smrg int32_t u0 : bits( 0, 3); 9407104f784Smrg int32_t address : bits( 4, 25); 9417104f784Smrg int32_t mextern : bits(26, 26); 9427104f784Smrg int32_t mselect : bits(27, 27); 9437104f784Smrg int32_t u1 : bits(28, 30); 9447104f784Smrg int32_t pending : bits(31, 31); 9457104f784Smrg } f; 9467104f784Smrg int32_t value; 9477104f784Smrg } crt_fb_address; 9487104f784Smrg 9497104f784Smrg#define CRT_FB_WIDTH 0x080208 9507104f784Smrg /* CRT FB WIDTH 9517104f784Smrg * Read/Write MMIO_base + 0x080208 9527104f784Smrg * Power-on Default Undefined 9537104f784Smrg * 9547104f784Smrg * 4:13 Number of 128-bit aligned bytes per line of the FB 9557104f784Smrg * graphics plane 9567104f784Smrg * 20:29 Number of bytes per line of the crt graphics window 9577104f784Smrg * specified in 128-bit aligned bytes. 9587104f784Smrg */ 9597104f784Smrg union { 9607104f784Smrg struct { 9617104f784Smrg int32_t u0 : bits( 0, 3); 9627104f784Smrg int32_t offset : bits( 4, 13); 9637104f784Smrg int32_t u1 : bits(14, 19); 9647104f784Smrg int32_t width : bits(20, 29); 9657104f784Smrg } f; 9667104f784Smrg int32_t value; 9677104f784Smrg } crt_fb_width; 9687104f784Smrg 9697104f784Smrg#define CRT_HTOTAL 0x08020c 9707104f784Smrg /* CRT HORIZONTAL TOTAL 9717104f784Smrg * Read/Write MMIO_base + 0x08020C 9727104f784Smrg * Power-on Default Undefined 9737104f784Smrg * 9747104f784Smrg * 0:11 Crt horizontal display end specified as number of pixels - 1. 9757104f784Smrg * 16:27 Crt horizontal total specified as number of pixels - 1. 9767104f784Smrg */ 9777104f784Smrg union { 9787104f784Smrg struct { 9797104f784Smrg int32_t end : bits( 0, 11); 9807104f784Smrg int32_t u0 : bits(12, 15); 9817104f784Smrg int32_t total : bits(16, 27); 9827104f784Smrg } f; 9837104f784Smrg int32_t value; 9847104f784Smrg } crt_htotal; 9857104f784Smrg 9867104f784Smrg#define CRT_HSYNC 0x080210 9877104f784Smrg /* CRT HORIZONTAL SYNC 9887104f784Smrg * Read/Write MMIO_base + 0x080210 9897104f784Smrg * Power-on Default Undefined 9907104f784Smrg * 9917104f784Smrg * 0:11 Crt horizontal sync start specified as pixel number - 1. 9927104f784Smrg * 16:23 Crt horizontal sync width specified in pixels. 9937104f784Smrg */ 9947104f784Smrg union { 9957104f784Smrg struct { 9967104f784Smrg int32_t start : bits( 0, 11); 9977104f784Smrg int32_t u0 : bits(12, 15); 9987104f784Smrg int32_t width : bits(16, 23); 9997104f784Smrg } f; 10007104f784Smrg int32_t value; 10017104f784Smrg } crt_hsync; 10027104f784Smrg 10037104f784Smrg#define CRT_VTOTAL 0x080214 10047104f784Smrg /* CRT VERTICAL TOTAL 10057104f784Smrg * Read/Write MMIO_base + 0x080214 10067104f784Smrg * Power-on Default Undefined 10077104f784Smrg * 10087104f784Smrg * 0:10 Crt vertical display end specified as number of pixels - 1. 10097104f784Smrg * 16:26 Crt vertical total specified as number of pixels - 1. 10107104f784Smrg */ 10117104f784Smrg union { 10127104f784Smrg struct { 10137104f784Smrg int32_t end : bits( 0, 10); 10147104f784Smrg int32_t u0 : bits(11, 15); 10157104f784Smrg int32_t total : bits(16, 26); 10167104f784Smrg } f; 10177104f784Smrg int32_t value; 10187104f784Smrg } crt_vtotal; 10197104f784Smrg 10207104f784Smrg#define CRT_VSYNC 0x080218 10217104f784Smrg /* CRT VERTICAL SYNC 10227104f784Smrg * Read/Write MMIO_base + 0x080218 10237104f784Smrg * Power-on Default Undefined 10247104f784Smrg * 10257104f784Smrg * 0:11 Crt vertical sync start specified as pixel number - 1. 10267104f784Smrg * 16:21 Crt vertical sync height specified in pixels. 10277104f784Smrg */ 10287104f784Smrg union { 10297104f784Smrg struct { 10307104f784Smrg int32_t start : bits( 0, 11); 10317104f784Smrg int32_t u0 : bits(12, 15); 10327104f784Smrg int32_t height : bits(16, 21); 10337104f784Smrg } f; 10347104f784Smrg int32_t value; 10357104f784Smrg } crt_vsync; 10367104f784Smrg 10377104f784Smrg#define CRT_DETECT 0x080224 10387104f784Smrg /* CRT MONITOR DETECT 10397104f784Smrg * Read/Write MMIO_base + 0x080224 10407104f784Smrg * Power-on Default Undefined 10417104f784Smrg * 10427104f784Smrg * 0:23 Monitor Detect Data in RGB 8:8:8. This field is read-only. 10437104f784Smrg * 24:24 Monitor Detect Enable. 10447104f784Smrg * 0: Disable. 10457104f784Smrg * 1: Enable. 10467104f784Smrg * 25:25 Monitor Detect Read Back. 10477104f784Smrg * 1: All R, G, and B voltages are greater than 0.325 V. 10487104f784Smrg * 0: All R, G, and B voltages are less than or equal to 0.325 V. 10497104f784Smrg */ 10507104f784Smrg union { 10517104f784Smrg struct { 10527104f784Smrg int32_t data : bits( 0, 23); 10537104f784Smrg int32_t enable : bits(24, 24); 10547104f784Smrg int32_t voltage : bits(25, 25); 10557104f784Smrg } f; 10567104f784Smrg int32_t value; 10577104f784Smrg } crt_detect; 10587104f784Smrg 10597104f784Smrg#define PANEL_PALETTE 0x080400 10607104f784Smrg#define CRT_PALETTE 0x080c00 10617104f784Smrg 10627104f784Smrg#define ACCEL_SRC 0x100000 10637104f784Smrg int32_t accel_src; 10647104f784Smrg 10657104f784Smrg#define ACCEL_DST 0x100004 10667104f784Smrg int32_t accel_dst; 10677104f784Smrg 10687104f784Smrg#define ACCEL_DIM 0x100008 10697104f784Smrg int32_t accel_dim; 10707104f784Smrg 10717104f784Smrg#define ACCEL_CTL 0x10000c 10727104f784Smrg int32_t accel_ctl; 10737104f784Smrg 10747104f784Smrg#define ACCEL_PITCH 0x100010 10757104f784Smrg int32_t accel_pitch; 10767104f784Smrg 10777104f784Smrg#define ACCEL_FMT 0x10001c 10787104f784Smrg int32_t accel_fmt; 10797104f784Smrg 10807104f784Smrg#define ACCEL_CLIP_TL 0x10002c 10817104f784Smrg int32_t accel_clip_tl; 10827104f784Smrg 10837104f784Smrg#define ACCEL_CLIP_BR 0x100030 10847104f784Smrg int32_t accel_clip_br; 10857104f784Smrg 10867104f784Smrg#define ACCEL_PAT_LO 0x100034 10877104f784Smrg int32_t accel_pat_lo; 10887104f784Smrg 10897104f784Smrg#define ACCEL_PAT_HI 0x100038 10907104f784Smrg int32_t accel_pat_hi; 10917104f784Smrg 10927104f784Smrg#define ACCEL_WWIDTH 0x10003c 10937104f784Smrg int32_t accel_wwidth; 10947104f784Smrg 10957104f784Smrg#define ACCEL_SRC_BASE 0x100040 10967104f784Smrg int32_t accel_src_base; 10977104f784Smrg 10987104f784Smrg#define ACCEL_DST_BASE 0x100044 10997104f784Smrg int32_t accel_dst_base; 11007104f784Smrg 11017104f784Smrg} MSOCRegRec, *MSOCRegPtr; 11027104f784Smrg 11037104f784Smrgtypedef enum smi_cli_cmd_code { 11047104f784Smrg /* Load Memory 0000b 11057104f784Smrg * 11067104f784Smrg * 0:0 When this bit is programmed to "0", the 32-bit DWord 11077104f784Smrg * data (bits [63:32]) is written to the Memory Address. 11087104f784Smrg * When this bit is programmed to "1", the 16-bit Word 11097104f784Smrg * data (bits [47:32]) is written to the Memory Address. 11107104f784Smrg * 1:27 The Memory Address to write data to. Bits [3:0] are 11117104f784Smrg * hardwired to "0" since all Memory Addresses should be 11127104f784Smrg * 128-bit aligned. 11137104f784Smrg * 28:31 0000b 11147104f784Smrg * 32:61 The data to be loaded in the memory address specified 11157104f784Smrg * by Memory Address. The data format is either 32-bit 11167104f784Smrg * DWords or 16-bit Words. 11177104f784Smrg * 62:63 Bits [63:62] are the byte-enable signals for the Word 11187104f784Smrg * data. They are active high. 11197104f784Smrg */ 11207104f784Smrg smi_cli_load_mem, 11217104f784Smrg 11227104f784Smrg /* Load Register 0001b 11237104f784Smrg * 11247104f784Smrg * 0:27 The register address (in the space 0x00000000 - 11257104f784Smrg * 0x001FFFFF) to write data to. Bits [0:1] are 11267104f784Smrg * hardwired to "0"since all register addresses should 11277104f784Smrg * be 32-bit aligned. 11287104f784Smrg * 28:31 001b 11297104f784Smrg * 32:63 The data to be loaded in the register specified by 11307104f784Smrg * Register Address. 11317104f784Smrg */ 11327104f784Smrg smi_cli_load_reg, 11337104f784Smrg 11347104f784Smrg /* Load Memory Immediate 0010b 11357104f784Smrg * 11367104f784Smrg * 0:27 The starting memory address to write data to. 11377104f784Smrg * Bits [1:0] are hardwired to "0". 11387104f784Smrg * 28:31 0010b 11397104f784Smrg * 32:63 The number of DWORDs to load into the memory. 11407104f784Smrg * 11417104f784Smrg * The data that must be loaded into the memory directly follows 11427104f784Smrg * this command. Make sure the correct number of DWORDs (DWORD Count) 11437104f784Smrg * is provided, otherwise unpredicted results will happen. Also, if 11447104f784Smrg * an odd number of DWORDs is specified, the last DWORD should be 11457104f784Smrg * padded with a dummy DWORD to align the next command to 64-bit again. 11467104f784Smrg */ 11477104f784Smrg smi_cli_load_mem_imm, 11487104f784Smrg 11497104f784Smrg /* Load Register Immediate 0011b 11507104f784Smrg * 11517104f784Smrg * 0:27 The register address (in the space 0x00000000 - 11527104f784Smrg * 0x001FFFFF) to write data to. Bits [0:1] are 11537104f784Smrg * hardwired to "0"since all register addresses should 11547104f784Smrg * be 32-bit aligned. 11557104f784Smrg * 28:31 0011b 11567104f784Smrg * 32:63 The number of DWORDs to load into the registers. 11577104f784Smrg * 11587104f784Smrg * The data that must be loaded into the registers directly follows 11597104f784Smrg * this command. Make sure the correct number of DWORDs (DWORD Count) 11607104f784Smrg * is provided, otherwise unpredicted results will happen. Also, if 11617104f784Smrg * an odd number of DWORDs is specified, the last DWORD should be 11627104f784Smrg * padded with a dummy DWORD to align the next command to 64-bit again. 11637104f784Smrg */ 11647104f784Smrg smi_cli_load_reg_imm, 11657104f784Smrg 11667104f784Smrg /* Load Memory Indirect 0100b 11677104f784Smrg * 11687104f784Smrg * 0:27 The starting memory address to write data to. 11697104f784Smrg * Bits [1:0] are hardwired to "0". 11707104f784Smrg * 28:31 0100b 11717104f784Smrg * 32:63 The number of DWORDs to copy into the memory. 11727104f784Smrg * 64:91 The starting memory address to read data from. 11737104f784Smrg * Bits [65:64] are hardwired to "0". 11747104f784Smrg * 92:127 Unused. 11757104f784Smrg * 11767104f784Smrg * This command copies data from the memory location specified 11777104f784Smrg * by Source Memory Address into the memory location specified by 11787104f784Smrg * Memory Address. The DWORD Count specifies the number of DWORDs 11797104f784Smrg * to copy. This command is most useful to copy texture, bitmap, 11807104f784Smrg * or vertex data to off-screen memory for caching purposes. 11817104f784Smrg */ 11827104f784Smrg smi_cli_load_mem_ind, 11837104f784Smrg 11847104f784Smrg /* Load Register Indirect 0101b 11857104f784Smrg * 11867104f784Smrg * 0:27 The register address (in the space 0x00000000 - 11877104f784Smrg * 0x001FFFFF) to write data to. Bits [0:1] are 11887104f784Smrg * hardwired to "0"since all register addresses should 11897104f784Smrg * be 32-bit aligned. 11907104f784Smrg * 28:31 0101b 11917104f784Smrg * 32:63 The number of DWORDs to copy into the memory. 11927104f784Smrg * 64:91 The starting memory address to read data from. 11937104f784Smrg * Bits [65:64] are hardwired to "0". 11947104f784Smrg * 92:127 Unused. 11957104f784Smrg * 11967104f784Smrg * This command copies data from the memory location specified 11977104f784Smrg * by Source Memory Address into the register bank location specified 11987104f784Smrg * by Register Address. The DWORD Count specifies the number of DWORDs 11997104f784Smrg * to copy. This command is most useful to copy texture, bitmap, 12007104f784Smrg * or vertex data to the engine FIFOs for processing. 12017104f784Smrg */ 12027104f784Smrg smi_cli_load_reg_ind, 12037104f784Smrg 12047104f784Smrg /* Status Test 0110b 12057104f784Smrg * 12067104f784Smrg * 0:0 2D Drawing Engine 12077104f784Smrg * (0 = idle, 1 = busy). 12087104f784Smrg * 1:1 2D and Color Space Conversion command FIFO 12097104f784Smrg * (0 = not empty, 1 = empty). 12107104f784Smrg * 2:2 2D Setup Engine (0 = idle, 1 = busy). 12117104f784Smrg * 3:10 Unused. 12127104f784Smrg * 11:11 Vertical Sync for Panel pipe 12137104f784Smrg * (0 = not active, 1 = active). 12147104f784Smrg * 12:12 Vertical Sync for CRT pipe 12157104f784Smrg * (0 = not active, 1 = active). 12167104f784Smrg * 13:13 Panel Graphics Layer status bit. 12177104f784Smrg * 14:14 Video Layer status bit. 12187104f784Smrg * 15:15 Current Video Layer field for BOB 12197104f784Smrg * (0 = odd, 1 = even). 12207104f784Smrg * 16:16 CRT Graphics Layer status bit. 12217104f784Smrg * 17:17 Memory DMA busy bit. 12227104f784Smrg * 18:18 Color Space Conversion busy bit. 12237104f784Smrg * 19:19 Command FIFO on HIF bus 12247104f784Smrg * (0 = not empty, 1 = empty). 12257104f784Smrg * 20:20 2D and Color Space Conversion memory FIFO 12267104f784Smrg * (0 = not empty, 1 = empty). 12277104f784Smrg * 21:27 Unused. 12287104f784Smrg * 28:31 0110b 12297104f784Smrg * 32:52 Bits Values 12307104f784Smrg * 53:63 Unused 12317104f784Smrg * 12327104f784Smrg * The Status Test command will wait until the requested status 12337104f784Smrg * is met. The value of the Status Test register is masked with the 12347104f784Smrg * internal hardware state and compared to the state in the Bit Values. 12357104f784Smrg * If the result does not equal the Bit Values, the command list 12367104f784Smrg * interpreter will wait until the hardware status changes. The 12377104f784Smrg * pseudo code looks like this: 12387104f784Smrg * WHILE (Hardware State & Mask [20:0] 12397104f784Smrg * != Bit Values [52:32] & Mask [20:0]) NOP; 12407104f784Smrg */ 12417104f784Smrg smi_cli_status_test, 12427104f784Smrg 12437104f784Smrg /* Finish 1000b 12447104f784Smrg * 12457104f784Smrg * 0:0 If the Interrupt bit is set, the FINISH command 12467104f784Smrg * will generate an interrupt that can still be 12477104f784Smrg * masked by the Command List mask bit in the Interrupt 12487104f784Smrg * Mask register. When an interrupt is generated, the 12497104f784Smrg * Command List bit in Interrupt Status register will 12507104f784Smrg * be set to "1". 12517104f784Smrg * 1:27 Unused 12527104f784Smrg * 28:31 1000b 12537104f784Smrg * 32:63 Unused 12547104f784Smrg * 12557104f784Smrg * The FINISH command stops executing commands in the Command List 12567104f784Smrg * and clears the Start bit ([31]) of the Command List Address register. 12577104f784Smrg */ 12587104f784Smrg smi_cli_finish = 8, 12597104f784Smrg 12607104f784Smrg /* Goto 1001b 12617104f784Smrg * 12627104f784Smrg * 0:27 The address of the new code to execute. 12637104f784Smrg * Bits [2:0] are hardwired to "0" since all addresses 12647104f784Smrg * need to be 64-bit aligned. 12657104f784Smrg * 28:31 1001b 12667104f784Smrg * 32:32 Relative bit. If set, the specified Address is relative 12677104f784Smrg * to the address of the current command (signed addition). 12687104f784Smrg * 33:63 Unused. 12697104f784Smrg * 12707104f784Smrg * The GOTO command will jump to the Command List code located at 12717104f784Smrg * the specified Address. 12727104f784Smrg */ 12737104f784Smrg smi_cli_goto, 12747104f784Smrg 12757104f784Smrg /* Gosub 1011b 12767104f784Smrg * 12777104f784Smrg * 0:27 The address of the new code to execute. 12787104f784Smrg * Bits [2:0] are hardwired to "0" since all addresses 12797104f784Smrg * need to be 64-bit aligned. 12807104f784Smrg * 28:31 1011b 12817104f784Smrg * 32:32 If the Relative bit is set, the specified Address 12827104f784Smrg * is relative to the address of the current command 12837104f784Smrg * (signed addition). 12847104f784Smrg * 33:63 Unused. 12857104f784Smrg * 12867104f784Smrg * The GOSUB command will store the address of the next instruction 12877104f784Smrg * it would execute in the Command List Return Address register and 12887104f784Smrg * starts executing the Command List code located at the specified 12897104f784Smrg * Address. 12907104f784Smrg */ 12917104f784Smrg smi_cli_gosub, 12927104f784Smrg 12937104f784Smrg /* Return 1010b 12947104f784Smrg * 12957104f784Smrg * 0:27 Unused 12967104f784Smrg * 28:31 1011b 12977104f784Smrg * 32:63 Unused. 12987104f784Smrg * 12997104f784Smrg * The RETURN command will jump to the address specified in the 13007104f784Smrg * Command List Return Address register. The RETURN command should 13017104f784Smrg * terminate a subroutine that is being called by GOSUB. 13027104f784Smrg */ 13037104f784Smrg smi_cli_return, 13047104f784Smrg 13057104f784Smrg /* Conditional Jump 1100b 13067104f784Smrg * 13077104f784Smrg * 0:27 A signed relative value that will be added to the 13087104f784Smrg * address of the next command in the Command List if 13097104f784Smrg * the result of the condition is TRUE. Bits [2:0] are 13107104f784Smrg * hardwired to "0" since all addresses need to be 64-bit 13117104f784Smrg * aligned. 13127104f784Smrg * 28:31 1100b 13137104f784Smrg * 32:63 The Condition field consists of a 32-bit mask that 13147104f784Smrg * will be applied to the Command List Condition Register. 13157104f784Smrg * If the result of this mask is TRUE (any bit set), the 13167104f784Smrg * condition shall return TRUE and the jump is taken by 13177104f784Smrg * adding the signed value of Address to the address of 13187104f784Smrg * the next command in the Command List. 13197104f784Smrg * The formula of the condition is: 13207104f784Smrg * RESULT = Condition * Command List Condition register 13217104f784Smrg */ 13227104f784Smrg smi_cli_cond_jump 13237104f784Smrg} smi_cli_cmd_code_t; 13247104f784Smrg 13257104f784Smrg/* Generic command list entry that matches most commands patterns */ 13267104f784Smrgtypedef union smi_cli_entry { 13277104f784Smrg struct { 13287104f784Smrg int64_t base : bits( 0, 27); 13297104f784Smrg int64_t cmd : bits(28, 31); 13307104f784Smrg int64_t data : bits(32, 63); 13317104f784Smrg } f; 13327104f784Smrg int64_t value; 13337104f784Smrg} smi_cli_entry_t; 13347104f784Smrg 13357104f784Smrg 13367104f784Smrg#if SMI501_CLI_DEBUG 13377104f784Smrg 13387104f784Smrg/* ensure there are "count" command list "slots" 8 bytes wide free */ 13397104f784Smrg#define BATCH_BEGIN(COUNT) \ 13407104f784Smrg do { \ 13417104f784Smrg if (IS_MSOC(pSmi)) { \ 13427104f784Smrg smi_cli_entry_t *entry; \ 13437104f784Smrg MSOCCmdAddrRec address; \ 13447104f784Smrg \ 13457104f784Smrg pSmi->batch_active = TRUE; \ 13467104f784Smrg ErrorF("BATCH_BEGIN(%d)\n", COUNT); \ 13477104f784Smrg /* One for finish */ \ 13487104f784Smrg if (pSmi->batch_index + COUNT + 1 >= pSmi->batch_length) { \ 13497104f784Smrg entry = (smi_cli_entry_t *) \ 13507104f784Smrg &pSmi->batch_handle[pSmi->batch_index]; \ 13517104f784Smrg entry->f.cmd = smi_cli_goto; \ 13527104f784Smrg /* start of buffer */ \ 13537104f784Smrg entry->f.base = pSmi->batch_offset; \ 13547104f784Smrg /* absolute jump */ \ 13557104f784Smrg entry->f.data = 0; \ 13567104f784Smrg ErrorF("wrap: from %d\n", pSmi->batch_index); \ 13577104f784Smrg address.value = READ_SCR(pSmi, CMD_ADDR); \ 13587104f784Smrg pSmi->batch_index = 0; \ 13597104f784Smrg } \ 13607104f784Smrg } \ 13617104f784Smrg } while (0) 13627104f784Smrg 13637104f784Smrg/* load register */ 13647104f784Smrg#define BATCH_LOAD_REG(PORT, VALUE) \ 13657104f784Smrg do { \ 13667104f784Smrg smi_cli_entry_t *entry = (smi_cli_entry_t *) \ 13677104f784Smrg &pSmi->batch_handle[pSmi->batch_index++]; \ 13687104f784Smrg \ 13697104f784Smrg ErrorF("BATCH_LOAD_REG(%x, %x)\n", PORT, VALUE); \ 13707104f784Smrg entry->f.cmd = smi_cli_load_reg; \ 13717104f784Smrg entry->f.base = PORT; \ 13727104f784Smrg entry->f.data = VALUE; \ 13737104f784Smrg } while (0) 13747104f784Smrg 13757104f784Smrg/* Appending to the Command List 13767104f784Smrg * 13777104f784Smrg * The procedure for chaining command lists is: 13787104f784Smrg * 1. Fill the command list buffer after the last FINISH command. 13797104f784Smrg * The software should always keep track of the address of the 13807104f784Smrg * last FINISH command. 13817104f784Smrg * 2. Terminate the command list with a FINISH and remember the 13827104f784Smrg * address of this FINISH. 13837104f784Smrg * 3. Stop the command list by programming "0" in bit 31 of the 13847104f784Smrg * Command List Address register. 13857104f784Smrg * 4. Read and remember the current program counter. 13867104f784Smrg * 5. Replace the previous FINISH command with a NOP command 13877104f784Smrg * (00000000C0000000). 13887104f784Smrg * 6. Restart the command list by programming the saved program counter 13897104f784Smrg * and "1" in bit 31 of the Command List Address register. 13907104f784Smrg */ 13917104f784Smrg#define BATCH_END() \ 13927104f784Smrg do { \ 13937104f784Smrg if (pSmi->batch_active) { \ 13947104f784Smrg MSOCCmdAddrRec address; \ 13957104f784Smrg smi_cli_entry_t *entry = (smi_cli_entry_t *) \ 13967104f784Smrg &pSmi->batch_handle[pSmi->batch_index]; \ 13977104f784Smrg \ 13987104f784Smrg ErrorF("BATCH_END()\n"); \ 13997104f784Smrg pSmi->batch_active = FALSE; \ 14007104f784Smrg /* Add new finish command */ \ 14017104f784Smrg entry->f.cmd = smi_cli_finish; \ 14027104f784Smrg /* Don't generate irq when processing the finish command */ \ 14037104f784Smrg entry->f.base = 0; \ 14047104f784Smrg address.value = READ_SCR(pSmi, CMD_ADDR); \ 14057104f784Smrg ErrorF("<<address = %d, finish = %d, index = %d\n", \ 14067104f784Smrg (address.f.address - pSmi->batch_offset) >> 3, \ 14077104f784Smrg pSmi->batch_finish, pSmi->batch_index); \ 14087104f784Smrg address.f.start = 0; \ 14097104f784Smrg WRITE_SCR(pSmi, CMD_ADDR, address.value); \ 14107104f784Smrg WaitIdle(); \ 14117104f784Smrg if (pSmi->batch_finish >= 0) \ 14127104f784Smrg pSmi->batch_handle[pSmi->batch_finish] = \ 14137104f784Smrg /* wait for idle engine */ \ 14147104f784Smrg /* just add a noop as there are 2 WaitIdle()'s */ \ 14157104f784Smrg /*0x180002601e0007ll*/0x00000000c0000000ll/*0x60060005ll*/; \ 14167104f784Smrg address.f.address = pSmi->batch_offset + \ 14177104f784Smrg ((pSmi->batch_finish + 1) << 3); \ 14187104f784Smrg /* New finish is current index */ \ 14197104f784Smrg pSmi->batch_finish = pSmi->batch_index; \ 14207104f784Smrg /* Where to start adding new entries */ \ 14217104f784Smrg ++pSmi->batch_index; \ 14227104f784Smrg /* Start executing list again */ \ 14237104f784Smrg address.f.start = 1; \ 14247104f784Smrg WRITE_SCR(pSmi, CMD_ADDR, address.value); \ 14257104f784Smrg do { \ 14267104f784Smrg address.value = READ_SCR(pSmi, CMD_ADDR); \ 14277104f784Smrg ErrorF("loop: %x\n", address.value); \ 14287104f784Smrg } while (!address.f.idle); \ 14297104f784Smrg WaitIdle(); \ 14307104f784Smrg ErrorF(">>address = %d, finish = %d, index = %d\n", \ 14317104f784Smrg (address.f.address - pSmi->batch_offset) >> 3, \ 14327104f784Smrg pSmi->batch_finish, pSmi->batch_index); \ 14337104f784Smrg } \ 14347104f784Smrg } while (0) 14357104f784Smrg 14367104f784Smrg#endif 14377104f784Smrg 14387104f784Smrg/* 14397104f784Smrg * 512 kb reserved for usb buffers 14407104f784Smrg * 14417104f784Smrg * In linux kernel source tree: 14427104f784Smrg * % grep USB_DMA_BUFFER_SIZE `find . -name sm5\*` 14437104f784Smrg * ./drivers/mfd/sm501.c: sm501_create_mem(sm, &pdev->resource[1], sm50x_mem_size-USB_DMA_BUFFER_SIZE, USB_DMA_BUFFER_SIZE); 14447104f784Smrg * ./drivers/mfd/sm501.c: sm501_create_mem(sm, &pdev->resource[2], 0, sm50x_mem_size-USB_DMA_BUFFER_SIZE); 14457104f784Smrg * ./include/linux/sm501.h:#define USB_DMA_BUFFER_SIZE 0x80000 14467104f784Smrg * 14477104f784Smrg */ 14487104f784Smrg#define SHARED_USB_DMA_BUFFER_SIZE 512 14497104f784Smrg 14507104f784Smrgvoid SMI501_Save(ScrnInfoPtr pScrn); 14517104f784Smrgvoid SMI501_DisplayPowerManagementSet(ScrnInfoPtr pScrn, 14527104f784Smrg int PowerManagementMode, int flags); 14537104f784Smrgvoid SMI501_PrintRegs(ScrnInfoPtr pScrn); 14547104f784Smrgdouble SMI501_FindClock(double clock, int max_divider, Bool has1xclck, 14557104f784Smrg int32_t *x2_1xclck, int32_t *x2_select, 14567104f784Smrg int32_t *x2_divider, int32_t *x2_shift); 14577104f784Smrgdouble SMI501_FindMemClock(double clock, int32_t *x1_select, 14587104f784Smrg int32_t *x1_divider, int32_t *x1_shift); 14597104f784Smrgdouble SMI501_FindPLLClock(double clock, int32_t *m, int32_t *n, 14607104f784Smrg int32_t *xclck); 14617104f784Smrgvoid SMI501_WaitVSync(SMIPtr pSmi, int vsync_count); 14627104f784Smrg 14637104f784Smrg/* Initialize the CRTC-independent hardware registers */ 14647104f784SmrgBool SMI501_HWInit(ScrnInfoPtr pScrn); 14657104f784Smrg/* Load to hardware the specified register set */ 14667104f784Smrgvoid SMI501_WriteMode_common(ScrnInfoPtr pScrn, MSOCRegPtr mode); 14677104f784Smrgvoid SMI501_WriteMode_lcd(ScrnInfoPtr pScrn, MSOCRegPtr mode); 14687104f784Smrgvoid SMI501_WriteMode_crt(ScrnInfoPtr pScrn, MSOCRegPtr mode); 14697104f784Smrgvoid SMI501_WriteMode_alpha(ScrnInfoPtr pScrn, MSOCRegPtr mode); 14707104f784Smrgvoid SMI501_WriteMode(ScrnInfoPtr pScrn, MSOCRegPtr restore); 14717104f784Smrgvoid SMI501_PowerPanel(ScrnInfoPtr pScrn, MSOCRegPtr mode, Bool on); 14727104f784Smrg 14737104f784Smrg/* smi501_crtc.c */ 14747104f784SmrgBool SMI501_CrtcPreInit(ScrnInfoPtr pScrn); 14757104f784Smrg 14767104f784Smrg/* smi501_output.c */ 14777104f784SmrgBool SMI501_OutputPreInit(ScrnInfoPtr pScrn); 14787104f784Smrg 14797104f784Smrg#endif /*_SMI_501_H*/ 1480