1f29dbc25Smrg/* Copyright (c) 2005 Advanced Micro Devices, Inc. 2f29dbc25Smrg * 3f29dbc25Smrg * Permission is hereby granted, free of charge, to any person obtaining a copy 4f29dbc25Smrg * of this software and associated documentation files (the "Software"), to 5f29dbc25Smrg * deal in the Software without restriction, including without limitation the 6f29dbc25Smrg * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 7f29dbc25Smrg * sell copies of the Software, and to permit persons to whom the Software is 8f29dbc25Smrg * furnished to do so, subject to the following conditions: 9f29dbc25Smrg * 10f29dbc25Smrg * The above copyright notice and this permission notice shall be included in 11f29dbc25Smrg * all copies or substantial portions of the Software. 12f29dbc25Smrg * 13f29dbc25Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14f29dbc25Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15f29dbc25Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16f29dbc25Smrg * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17f29dbc25Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18f29dbc25Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19f29dbc25Smrg * IN THE SOFTWARE. 20f29dbc25Smrg * 21f29dbc25Smrg * Neither the name of the Advanced Micro Devices, Inc. nor the names of its 22f29dbc25Smrg * contributors may be used to endorse or promote products derived from this 23f29dbc25Smrg * software without specific prior written permission. 24f29dbc25Smrg * */ 25f29dbc25Smrg 26f29dbc25Smrg/* 27f29dbc25Smrg * File Contents: This file contains the panel library files to the 28f29dbc25Smrg * platforms with 9210, and 9211 support. 29f29dbc25Smrg * 30f29dbc25Smrg * SubModule: Geode FlatPanel library 31f29dbc25Smrg * */ 32f29dbc25Smrg 33f29dbc25Smrg#include "drac9210.h" 34f29dbc25Smrg 3504007ebaSmrg#define CS9210 0x40 /* Chip select pin */ 36f29dbc25Smrg 37f29dbc25Smrg/* 9210 on Draco */ 3804007ebaSmrg#define CLOCK9210 0x04 /* Clock pin */ 3904007ebaSmrg#define DATAIN9210 0x20 /* Data from 9210 */ 4004007ebaSmrg#define DATAOUT9210 0x80 /* Data to 9210 */ 41f29dbc25Smrg 42f29dbc25Smrgstatic void DracoWriteData(unsigned char data); 43f29dbc25Smrgstatic void DracoReadData(unsigned char *data); 44f29dbc25Smrgstatic void Draco9210GpioInit(); 45f29dbc25Smrgstatic void Draco9210SetCS(void); 46f29dbc25Smrgstatic unsigned char Draco9210ReadReg(unsigned char index); 47f29dbc25Smrgstatic void Draco9210WriteReg(unsigned char index, unsigned char data); 48f29dbc25Smrgstatic void Draco9210ClearCS(void); 49f29dbc25Smrgstatic void Draco9210SetDataOut(void); 50f29dbc25Smrgstatic void Draco9210ClearDataOut(void); 51f29dbc25Smrgstatic unsigned char Draco9210ReadDataIn(void); 52f29dbc25Smrgstatic void Draco9210ToggleClock(void); 53f29dbc25Smrg 54f29dbc25Smrgvoid 55f29dbc25SmrgDraco9210Init(Pnl_PanelStat * pstat) 56f29dbc25Smrg{ 57f29dbc25Smrg unsigned char panelvalues[] = { 58f29dbc25Smrg 0x2, 0x80, 59f29dbc25Smrg 0x2, 0x24, 60f29dbc25Smrg 0x03, 0x00, 61f29dbc25Smrg 0xc0, 0x00, 62f29dbc25Smrg 0xc1, 0x00, 63f29dbc25Smrg 0xc2, 0x00, 64f29dbc25Smrg 0xc3, 0x00, 65f29dbc25Smrg 0xc4, 0x00, 66f29dbc25Smrg 0xc5, 0x01, 67f29dbc25Smrg 0xc6, 0xff, 68f29dbc25Smrg 0xc7, 0xff, 69f29dbc25Smrg 0xc8, 0x3, 70f29dbc25Smrg 0xc9, 0xfe, 71f29dbc25Smrg 0xca, 0x0, 72f29dbc25Smrg 0xcb, 0x3f, 73f29dbc25Smrg 0xcc, 0xc, 74f29dbc25Smrg 0xcd, 0x1, 75f29dbc25Smrg 0xce, 0xff, 76f29dbc25Smrg 0xcf, 0xc1, 77f29dbc25Smrg 0xd0, 0x0, 78f29dbc25Smrg 0xd1, 0x7e, 79f29dbc25Smrg 0xd2, 0x3, 80f29dbc25Smrg 0xd3, 0xfe, 81f29dbc25Smrg 0xd4, 0x3, 82f29dbc25Smrg 0xd5, 0x81, 83f29dbc25Smrg 0xd6, 0xfc, 84f29dbc25Smrg 0xd7, 0x3f, 85f29dbc25Smrg 0xd8, 0x14, 86f29dbc25Smrg 0xd9, 0x1e, 87f29dbc25Smrg 0xda, 0x0f, 88f29dbc25Smrg 0xdb, 0xc7, 89f29dbc25Smrg 0xdc, 0x29, 90f29dbc25Smrg 0xdd, 0xe1, 91f29dbc25Smrg 0xde, 0xf1, 92f29dbc25Smrg 0xdf, 0xf9, 93f29dbc25Smrg 0xe0, 0x2, 94f29dbc25Smrg 0xe1, 0xe, 95f29dbc25Smrg 0xe2, 0x1e, 96f29dbc25Smrg 0xe3, 0x3e, 97f29dbc25Smrg 0xe4, 0x04, 98f29dbc25Smrg 0xe5, 0x71, 99f29dbc25Smrg 0xe6, 0xe3, 100f29dbc25Smrg 0xe7, 0xcf, 101f29dbc25Smrg 0xe8, 0x1, 102f29dbc25Smrg 0xe9, 0x86, 103f29dbc25Smrg 0xea, 0x3c, 104f29dbc25Smrg 0xeb, 0xf3, 105f29dbc25Smrg 0xec, 0xa, 106f29dbc25Smrg 0xed, 0x39, 107f29dbc25Smrg 0xee, 0xc7, 108f29dbc25Smrg 0xef, 0x3d, 109f29dbc25Smrg 110f29dbc25Smrg 0xf0, 0x14, 111f29dbc25Smrg 0xf1, 0xc6, 112f29dbc25Smrg 0xf2, 0x39, 113f29dbc25Smrg 0xf3, 0xce, 114f29dbc25Smrg 0xf4, 0x3, 115f29dbc25Smrg 0xf5, 0x19, 116f29dbc25Smrg 0xf6, 0xce, 117f29dbc25Smrg 0xf7, 0x77, 118f29dbc25Smrg 0xf8, 0x0, 119f29dbc25Smrg 0xf9, 0x66, 120f29dbc25Smrg 0xfa, 0x33, 121f29dbc25Smrg 0xfb, 0xbb, 122f29dbc25Smrg 0xfc, 0x2d, 123f29dbc25Smrg 0xfd, 0x99, 124f29dbc25Smrg 0xfe, 0xdd, 125f29dbc25Smrg 0xff, 0xdd, 126f29dbc25Smrg 127f29dbc25Smrg 0x3, 0x1, 128f29dbc25Smrg 0xc0, 0x2, 129f29dbc25Smrg 0xc1, 0x22, 130f29dbc25Smrg 0xc2, 0x66, 131f29dbc25Smrg 0xc3, 0x66, 132f29dbc25Smrg 0xc4, 0x0, 133f29dbc25Smrg 0xc5, 0xcd, 134f29dbc25Smrg 0xc6, 0x99, 135f29dbc25Smrg 0xc7, 0xbb, 136f29dbc25Smrg 0xc8, 0x5, 137f29dbc25Smrg 0xc9, 0x32, 138f29dbc25Smrg 0xca, 0x66, 139f29dbc25Smrg 0xcb, 0xdd, 140f29dbc25Smrg 0xcc, 0x1a, 141f29dbc25Smrg 0xcd, 0x4d, 142f29dbc25Smrg 0xce, 0x9b, 143f29dbc25Smrg 0xcf, 0x6f, 144f29dbc25Smrg 0xd0, 0x0, 145f29dbc25Smrg 0xd1, 0x92, 146f29dbc25Smrg 0xd2, 0x6d, 147f29dbc25Smrg 0xd3, 0xb6, 148f29dbc25Smrg 0xd4, 0x5, 149f29dbc25Smrg 0xd5, 0x25, 150f29dbc25Smrg 0xd6, 0xb6, 151f29dbc25Smrg 0xd7, 0xdb, 152f29dbc25Smrg 0xd8, 0x2, 153f29dbc25Smrg 0xd9, 0x5a, 154f29dbc25Smrg 0xda, 0x4b, 155f29dbc25Smrg 0xdb, 0x6d, 156f29dbc25Smrg 0xdc, 0x29, 157f29dbc25Smrg 0xdd, 0xa5, 158f29dbc25Smrg 0xde, 0xb5, 159f29dbc25Smrg 0xdf, 0xb7, 160f29dbc25Smrg 0xe0, 0x4, 161f29dbc25Smrg 0xe1, 0x4a, 162f29dbc25Smrg 0xe2, 0x5a, 163f29dbc25Smrg 0xe3, 0xda, 164f29dbc25Smrg 0xe4, 0x12, 165f29dbc25Smrg 0xe5, 0x95, 166f29dbc25Smrg 0xe6, 0xad, 167f29dbc25Smrg 0xe7, 0x6f, 168f29dbc25Smrg 0xe8, 0x1, 169f29dbc25Smrg 0xe9, 0x2a, 170f29dbc25Smrg 0xea, 0x56, 171f29dbc25Smrg 0xeb, 0xb5, 172f29dbc25Smrg 0xec, 0xe, 173f29dbc25Smrg 0xed, 0x55, 174f29dbc25Smrg 0xee, 0xab, 175f29dbc25Smrg 0xef, 0x5f, 176f29dbc25Smrg 0xf0, 0x0, 177f29dbc25Smrg 0xf1, 0xaa, 178f29dbc25Smrg 0xf2, 0x55, 179f29dbc25Smrg 0xf3, 0xea, 180f29dbc25Smrg 0xf4, 0x1, 181f29dbc25Smrg 0xf5, 0x55, 182f29dbc25Smrg 0xf6, 0xaa, 183f29dbc25Smrg 0xf7, 0xbf, 184f29dbc25Smrg 0xf8, 0x6, 185f29dbc25Smrg 0xf9, 0xaa, 186f29dbc25Smrg 0xfa, 0x55, 187f29dbc25Smrg 0xfb, 0x55, 188f29dbc25Smrg 0xfc, 0x39, 189f29dbc25Smrg 0xfd, 0x55, 190f29dbc25Smrg 0xfe, 0xff, 191f29dbc25Smrg 0xff, 0xff, 192f29dbc25Smrg 193f29dbc25Smrg 0x3, 0x2, 194f29dbc25Smrg 0xc0, 0x0, 195f29dbc25Smrg 0xc1, 0x0, 196f29dbc25Smrg 0xc2, 0xaa, 197f29dbc25Smrg 0xc3, 0xaa, 198f29dbc25Smrg 0xc4, 0x6, 199f29dbc25Smrg 0xc5, 0xab, 200f29dbc25Smrg 0xc6, 0x55, 201f29dbc25Smrg 0xc7, 0x55, 202f29dbc25Smrg 0xc8, 0x01, 203f29dbc25Smrg 0xc9, 0x54, 204f29dbc25Smrg 0xca, 0xaa, 205f29dbc25Smrg 0xcb, 0xbf, 206f29dbc25Smrg 0xcc, 0x8, 207f29dbc25Smrg 0xcd, 0xab, 208f29dbc25Smrg 0xce, 0x55, 209f29dbc25Smrg 0xcf, 0xeb, 210f29dbc25Smrg 0xd0, 0x6, 211f29dbc25Smrg 0xd1, 0x54, 212f29dbc25Smrg 0xd2, 0xab, 213f29dbc25Smrg 0xd3, 0x5e, 214f29dbc25Smrg 0xd4, 0x1, 215f29dbc25Smrg 0xd5, 0x2b, 216f29dbc25Smrg 0xd6, 0x56, 217f29dbc25Smrg 0xd7, 0xb5, 218f29dbc25Smrg 0xd8, 0x12, 219f29dbc25Smrg 0xd9, 0x94, 220f29dbc25Smrg 0xda, 0xad, 221f29dbc25Smrg 0xdb, 0x6f, 222f29dbc25Smrg 0xdc, 0x2d, 223f29dbc25Smrg 0xdd, 0x4b, 224f29dbc25Smrg 0xde, 0x5b, 225f29dbc25Smrg 0xdf, 0xdb, 226f29dbc25Smrg 0xe0, 0x0, 227f29dbc25Smrg 0xe1, 0xa4, 228f29dbc25Smrg 0xe2, 0xb4, 229f29dbc25Smrg 0xe3, 0xb6, 230f29dbc25Smrg 0xe4, 0x2, 231f29dbc25Smrg 0xe5, 0x5b, 232f29dbc25Smrg 0xe6, 0x4b, 233f29dbc25Smrg 0xe7, 0x6d, 234f29dbc25Smrg 0xe8, 0x5, 235f29dbc25Smrg 0xe9, 0x24, 236f29dbc25Smrg 0xea, 0xb6, 237f29dbc25Smrg 0xeb, 0xdb, 238f29dbc25Smrg 0xec, 0x8, 239f29dbc25Smrg 0xed, 0x93, 240f29dbc25Smrg 0xee, 0x6d, 241f29dbc25Smrg 0xef, 0xb7, 242f29dbc25Smrg 0xf0, 0x12, 243f29dbc25Smrg 0xf1, 0x4c, 244f29dbc25Smrg 0xf2, 0x9b, 245f29dbc25Smrg 0xf3, 0x6e, 246f29dbc25Smrg 0xf4, 0x5, 247f29dbc25Smrg 0xf5, 0x33, 248f29dbc25Smrg 0xf6, 0x66, 249f29dbc25Smrg 0xf7, 0xdd, 250f29dbc25Smrg 0xf8, 0x0, 251f29dbc25Smrg 0xf9, 0xcc, 252f29dbc25Smrg 0xfa, 0x99, 253f29dbc25Smrg 0xfb, 0xbb, 254f29dbc25Smrg 0xfc, 0x2b, 255f29dbc25Smrg 0xfd, 0x33, 256f29dbc25Smrg 0xfe, 0x77, 257f29dbc25Smrg 0xff, 0x77, 258f29dbc25Smrg 259f29dbc25Smrg 0x3, 0x3, 260f29dbc25Smrg 0xc0, 0x4, 261f29dbc25Smrg 0xc1, 0x88, 262f29dbc25Smrg 0xc2, 0xcc, 263f29dbc25Smrg 0xc3, 0xcc, 264f29dbc25Smrg 0xc4, 0x0, 265f29dbc25Smrg 0xc5, 0x67, 266f29dbc25Smrg 0xc6, 0x33, 267f29dbc25Smrg 0xc7, 0xbb, 268f29dbc25Smrg 0xc8, 0x3, 269f29dbc25Smrg 0xc9, 0x18, 270f29dbc25Smrg 0xca, 0xce, 271f29dbc25Smrg 0xcb, 0x77, 272f29dbc25Smrg 0xcc, 0x1c, 273f29dbc25Smrg 0xcd, 0xc7, 274f29dbc25Smrg 0xce, 0x39, 275f29dbc25Smrg 0xcf, 0xcf, 276f29dbc25Smrg 277f29dbc25Smrg 0xd0, 0x2, 278f29dbc25Smrg 0xd1, 0x38, 279f29dbc25Smrg 0xd2, 0xc7, 280f29dbc25Smrg 0xd3, 0x3c, 281f29dbc25Smrg 0xd4, 0x1, 282f29dbc25Smrg 0xd5, 0x87, 283f29dbc25Smrg 0xd6, 0x3c, 284f29dbc25Smrg 0xd7, 0xf3, 285f29dbc25Smrg 0xd8, 0x4, 286f29dbc25Smrg 0xd9, 0x70, 287f29dbc25Smrg 0xda, 0xe3, 288f29dbc25Smrg 0xdb, 0xcf, 289f29dbc25Smrg 0xdc, 0x2b, 290f29dbc25Smrg 0xdd, 0xf, 291f29dbc25Smrg 0xde, 0x1f, 292f29dbc25Smrg 0xdf, 0x3f, 293f29dbc25Smrg 0xe0, 0x00, 294f29dbc25Smrg 0xe1, 0xe0, 295f29dbc25Smrg 0xe2, 0xf0, 296f29dbc25Smrg 0xe3, 0xf8, 297f29dbc25Smrg 0xe4, 0x14, 298f29dbc25Smrg 0xe5, 0x1f, 299f29dbc25Smrg 0xe6, 0xf, 300f29dbc25Smrg 0xe7, 0xc7, 301f29dbc25Smrg 0xe8, 0x3, 302f29dbc25Smrg 0xe9, 0x80, 303f29dbc25Smrg 0xea, 0xfc, 304f29dbc25Smrg 0xeb, 0x3f, 305f29dbc25Smrg 0xec, 0x8, 306f29dbc25Smrg 0xed, 0x7f, 307f29dbc25Smrg 0xee, 0x3, 308f29dbc25Smrg 0xef, 0xff, 309f29dbc25Smrg 0xf0, 0x4, 310f29dbc25Smrg 0xf1, 0x0, 311f29dbc25Smrg 0xf2, 0xff, 312f29dbc25Smrg 0xf3, 0xc0, 313f29dbc25Smrg 0xf4, 0x3, 314f29dbc25Smrg 0xf5, 0xff, 315f29dbc25Smrg 0xf6, 0x0, 316f29dbc25Smrg 0xf7, 0x3f, 317f29dbc25Smrg 0xf8, 0x0, 318f29dbc25Smrg 0xf9, 0x0, 319f29dbc25Smrg 0xfa, 0xff, 320f29dbc25Smrg 0xfb, 0xff, 321f29dbc25Smrg 0xfc, 0x3f, 322f29dbc25Smrg 0xfd, 0xff, 323f29dbc25Smrg 0xfe, 0xff, 324f29dbc25Smrg 0xff, 0xff, 325f29dbc25Smrg 0x3, 0x4, 326f29dbc25Smrg 327f29dbc25Smrg /* Setup the Diter to Pattern33 */ 328f29dbc25Smrg 0x80, 0xdd, 329f29dbc25Smrg 0x81, 0xdd, 330f29dbc25Smrg 0x82, 0x33, 331f29dbc25Smrg 0x83, 0x33, 332f29dbc25Smrg 0x84, 0xdd, 333f29dbc25Smrg 0x85, 0xdd, 334f29dbc25Smrg 0x86, 0x33, 335f29dbc25Smrg 0x87, 0x33, 336f29dbc25Smrg 0x88, 0x33, 337f29dbc25Smrg 0x89, 0x33, 338f29dbc25Smrg 0x8a, 0x77, 339f29dbc25Smrg 0x8b, 0x77, 340f29dbc25Smrg 0x8c, 0x33, 341f29dbc25Smrg 0x8d, 0x33, 342f29dbc25Smrg 0x8e, 0x77, 343f29dbc25Smrg 0x8f, 0x77, 344f29dbc25Smrg 0x90, 0xdd, 345f29dbc25Smrg 0x91, 0xdd, 346f29dbc25Smrg 0x92, 0x33, 347f29dbc25Smrg 0x93, 0x33, 348f29dbc25Smrg 0x94, 0xdd, 349f29dbc25Smrg 0x95, 0xdd, 350f29dbc25Smrg 0x96, 0x33, 351f29dbc25Smrg 0x97, 0x33, 352f29dbc25Smrg 0x98, 0x33, 353f29dbc25Smrg 0x99, 0x33, 354f29dbc25Smrg 0x9a, 0x77, 355f29dbc25Smrg 0x9b, 0x77, 356f29dbc25Smrg 0x9c, 0x33, 357f29dbc25Smrg 0x9d, 0x33, 358f29dbc25Smrg 0x9e, 0x77, 359f29dbc25Smrg 0x9f, 0x77, 360f29dbc25Smrg 361f29dbc25Smrg 0x4, 0x20, 362f29dbc25Smrg 0x5, 0x3, 363f29dbc25Smrg 0x6, 0x56, 364f29dbc25Smrg 0x7, 0x2, 365f29dbc25Smrg 0x8, 0x1c, 366f29dbc25Smrg 0x9, 0x0, 367f29dbc25Smrg 0xa, 0x26, 368f29dbc25Smrg 0xb, 0x0, 369f29dbc25Smrg 0xc, 0x15, 370f29dbc25Smrg 0xd, 0x4, 371f29dbc25Smrg 0xe, 0x50, 372f29dbc25Smrg 0xf, 0x4, 373f29dbc25Smrg 0x10, 0xfa, 374f29dbc25Smrg 0x11, 0x0, 375f29dbc25Smrg 0x12, 0xc8, 376f29dbc25Smrg 0x13, 0x0, 377f29dbc25Smrg 0x14, 0x31, 378f29dbc25Smrg 0x15, 0x23, 379f29dbc25Smrg 0x16, 0x0, 380f29dbc25Smrg 381f29dbc25Smrg /* Enable DSTN panel */ 382f29dbc25Smrg 0x2, 0x64 383f29dbc25Smrg }; 384f29dbc25Smrg unsigned char index, data; 385f29dbc25Smrg int i; 386f29dbc25Smrg 387f29dbc25Smrg gfx_delay_milliseconds(100); 388f29dbc25Smrg Draco9210GpioInit(); 389f29dbc25Smrg Draco9210SetCS(); 390f29dbc25Smrg Draco9210ToggleClock(); 391f29dbc25Smrg Draco9210ToggleClock(); 392f29dbc25Smrg Draco9210ToggleClock(); 393f29dbc25Smrg Draco9210ToggleClock(); 394f29dbc25Smrg Draco9210ClearCS(); 395f29dbc25Smrg 39604007ebaSmrg#if defined(_WIN32) /* For Windows */ 397f29dbc25Smrg for (i = 0; i < 10; i++) { 398f29dbc25Smrg _asm { 399f29dbc25Smrg out 0ED h, al} 400f29dbc25Smrg } 401f29dbc25Smrg 40204007ebaSmrg#elif defined(linux) /* Linux */ 403f29dbc25Smrg 404f29dbc25Smrg#endif 405f29dbc25Smrg 406f29dbc25Smrg for (i = 0; i < 630; i += 2) { 407f29dbc25Smrg index = panelvalues[i]; 408f29dbc25Smrg data = panelvalues[i + 1]; 409f29dbc25Smrg Draco9210WriteReg(index, data); 410f29dbc25Smrg } 411f29dbc25Smrg 412f29dbc25Smrg} 413f29dbc25Smrg 414f29dbc25Smrgstatic void 415f29dbc25SmrgDracoWriteData(unsigned char data) 416f29dbc25Smrg{ 417f29dbc25Smrg int i; 418f29dbc25Smrg unsigned char mask = 0x80, databit; 419f29dbc25Smrg 420f29dbc25Smrg for (i = 0; i < 8; i++) { 421f29dbc25Smrg 422f29dbc25Smrg databit = data & mask; 423f29dbc25Smrg if (data & mask) { 424f29dbc25Smrg Draco9210SetDataOut(); 42504007ebaSmrg } 42604007ebaSmrg else { 427f29dbc25Smrg Draco9210ClearDataOut(); 428f29dbc25Smrg } 429f29dbc25Smrg mask >>= 1; 430f29dbc25Smrg Draco9210ToggleClock(); 431f29dbc25Smrg } 432f29dbc25Smrg} 433f29dbc25Smrg 434f29dbc25Smrgstatic void 435f29dbc25SmrgDracoReadData(unsigned char *data) 436f29dbc25Smrg{ 437f29dbc25Smrg int i; 438f29dbc25Smrg unsigned char tmp = 0, readbit; 439f29dbc25Smrg 440f29dbc25Smrg Draco9210ClearDataOut(); 441f29dbc25Smrg Draco9210ToggleClock(); 442f29dbc25Smrg for (i = 0; i < 7; i++) { 443f29dbc25Smrg readbit = Draco9210ReadDataIn(); 444f29dbc25Smrg tmp |= (readbit & 0x1); 445f29dbc25Smrg tmp <<= 1; 446f29dbc25Smrg Draco9210ToggleClock(); 447f29dbc25Smrg } 448f29dbc25Smrg readbit = Draco9210ReadDataIn(); 449f29dbc25Smrg tmp |= (readbit & 0x1); 450f29dbc25Smrg *data = tmp; 451f29dbc25Smrg} 452f29dbc25Smrg 45304007ebaSmrg#if defined(_WIN32) /* For Windows */ 454f29dbc25Smrg 455f29dbc25Smrgvoid 456f29dbc25SmrgDraco9210GpioInit() 457f29dbc25Smrg{ 458f29dbc25Smrg _asm { 459f29dbc25Smrg pushf 460f29dbc25Smrg cli 461f29dbc25Smrg mov dx, 0 CF8h 462f29dbc25Smrg mov eax, CX55x0_ID + 090 h 463f29dbc25Smrg out dx, eax 464f29dbc25Smrg mov dx, 0 CFCh mov al, 0 CFh mov ah, 00 h out dx, ax popf} 465f29dbc25Smrg} 466f29dbc25Smrg 467f29dbc25Smrgvoid 468f29dbc25SmrgDraco9210SetCS() 469f29dbc25Smrg{ 470f29dbc25Smrg _asm { 471f29dbc25Smrg pushf; 472f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 473f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h out dx, eax; 474f29dbc25Smrg Point to PCI data register (CFCh) 47504007ebaSmrgmov dx, 0 CFCh 476f29dbc25Smrg in ax, dx 477f29dbc25Smrg and ah, 30 h 478f29dbc25Smrg mov ah, c92DataReg 47904007ebaSmrg or ah, CS9210 mov c92DataReg, ah out dx, ax popf}} void 480f29dbc25SmrgDraco9210ClearCS() 481f29dbc25Smrg{ 482f29dbc25Smrg _asm { 483f29dbc25Smrg pushf; 484f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 485f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h out dx, eax; 486f29dbc25Smrg Point to PCI data register (CFCh) 487f29dbc25Smrg mov dx, 0 CFCh; 48804007ebaSmrgSet CS LOW 489f29dbc25Smrg in ax, dx 490f29dbc25Smrg mov ah, c92DataReg 49104007ebaSmrg and ah, NOT CS9210 mov c92DataReg, ah out dx, ax popf}} void 492f29dbc25SmrgDraco9210SetDataOut() 493f29dbc25Smrg{ 494f29dbc25Smrg _asm { 495f29dbc25Smrg pushf; 496f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 497f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h out dx, eax; 498f29dbc25Smrg Point to PCI data register (CFCh) 499f29dbc25Smrg mov dx, 0 CFCh; 50004007ebaSmrgSet DATA HIGH 501f29dbc25Smrg in ax, dx 502f29dbc25Smrg mov ah, c92DataReg 50304007ebaSmrg or ah, DATAOUT9210 mov c92DataReg, ah out dx, ax popf}} void 504f29dbc25SmrgDraco9210ClearDataOut() 505f29dbc25Smrg{ 506f29dbc25Smrg _asm { 507f29dbc25Smrg pushf; 508f29dbc25Smrg Point to PCI address register 50904007ebaSmrg mov dx, 0 CF8h mov eax, CX55x0_ID + 090 h; 51004007ebaSmrg 511f29dbc25Smrg ; 512f29dbc25Smrg 55 XX GPIO data register out dx, eax; 513f29dbc25Smrg Point to PCI data register (CFCh) 514f29dbc25Smrg mov dx, 0 CFCh; 51504007ebaSmrgSet Data LOW 516f29dbc25Smrg in ax, dx 517f29dbc25Smrg mov ah, c92DataReg 51804007ebaSmrg and ah, NOT DATAOUT9210 mov c92DataReg, ah out dx, ax popf}} 51904007ebaSmrg unsigned char 520f29dbc25SmrgDraco9210ReadDataIn() 521f29dbc25Smrg{ 522f29dbc25Smrg unsigned char readdata; 523f29dbc25Smrg 524f29dbc25Smrg _asm { 525f29dbc25Smrg pushf; 526f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 527f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h out dx, eax; 528f29dbc25Smrg Point to PCI data register (CFCh) 529f29dbc25Smrg mov dx, 0F Ch in ax, dx; 530f29dbc25Smrg Preserve just Data IN bit and ah, DATAIN9210 mov al, ah cmp al, 0; 531f29dbc25Smrg Is it LOW ? je readDataLow; 53204007ebaSmrg must be HIGH mov al, 1 readDataLow:mov readdata, al popf} return (readdata); 533f29dbc25Smrg} 534f29dbc25Smrg 535f29dbc25Smrgvoid 536f29dbc25SmrgDraco9210ToggleClock() 537f29dbc25Smrg{ 538f29dbc25Smrg _asm { 539f29dbc25Smrg pushf; 540f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 541f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h; 542f29dbc25Smrg Point to PCI data register (CFCh) 543f29dbc25Smrg out dx, eax mov dx, 0 CFCh; 544f29dbc25Smrg SET CLOCK in ax, dx mov ah, c92DataReg or ah, CLOCK9210 mov c92DataReg, ah out dx, ax out 0ED h, al /* IOPAUSE */ 54504007ebaSmrg ; 546f29dbc25Smrg Point to PCI address register mov dx, 0 CF8h; 547f29dbc25Smrg 55 XX GPIO data register mov eax, CX55x0_ID + 090 h out dx, eax; 548f29dbc25Smrg Point to PCI data register (CFCh) 549f29dbc25Smrg mov dx, 0 CFCh; 550f29dbc25Smrg 551f29dbc25Smrg ; 55204007ebaSmrgCLEAR CLOCK 553f29dbc25Smrg in ax, dx 554f29dbc25Smrg mov ah, c92DataReg 55504007ebaSmrg and ah, NOT CLOCK9210 mov c92DataReg, ah out dx, ax popf}} 55604007ebaSmrg#elif defined(linux) /* Linux */ 557f29dbc25Smrg 558f29dbc25Smrgvoid 559f29dbc25SmrgDraco9210GpioInit() 560f29dbc25Smrg{ 561f29dbc25Smrg} 56204007ebaSmrg 563f29dbc25Smrgvoid 564f29dbc25SmrgDraco9210SetCS() 565f29dbc25Smrg{ 566f29dbc25Smrg} 56704007ebaSmrg 568f29dbc25Smrgvoid 569f29dbc25SmrgDraco9210ClearCS() 570f29dbc25Smrg{ 571f29dbc25Smrg} 57204007ebaSmrg 573f29dbc25Smrgvoid 574f29dbc25SmrgDraco9210SetDataOut() 575f29dbc25Smrg{ 576f29dbc25Smrg} 57704007ebaSmrg 578f29dbc25Smrgvoid 579f29dbc25SmrgDraco9210ClearDataOut() 580f29dbc25Smrg{ 581f29dbc25Smrg} 58204007ebaSmrg 583f29dbc25Smrgunsigned char 584f29dbc25SmrgDraco9210ReadDataIn() 585f29dbc25Smrg{ 586f29dbc25Smrg} 58704007ebaSmrg 588f29dbc25Smrgvoid 589f29dbc25SmrgDraco9210ToggleClock() 590f29dbc25Smrg{ 591f29dbc25Smrg} 592f29dbc25Smrg 593f29dbc25Smrg#endif 594f29dbc25Smrg 595f29dbc25Smrgunsigned char 596f29dbc25SmrgDraco9210ReadReg(unsigned char index) 597f29dbc25Smrg{ 598f29dbc25Smrg unsigned char data; 599f29dbc25Smrg 600f29dbc25Smrg Draco9210SetCS(); 601f29dbc25Smrg Draco9210ToggleClock(); 602f29dbc25Smrg Draco9210SetDataOut(); 603f29dbc25Smrg Draco9210ToggleClock(); 604f29dbc25Smrg Draco9210ClearDataOut(); 605f29dbc25Smrg Draco9210ToggleClock(); 606f29dbc25Smrg Draco9210ClearDataOut(); 607f29dbc25Smrg Draco9210ToggleClock(); 608f29dbc25Smrg Draco9210ClearDataOut(); 609f29dbc25Smrg Draco9210ToggleClock(); 610f29dbc25Smrg 611f29dbc25Smrg DracoWriteData(index); 612f29dbc25Smrg DracoReadData(&data); 613f29dbc25Smrg 614f29dbc25Smrg return (data); 615f29dbc25Smrg} 616f29dbc25Smrg 617f29dbc25Smrgvoid 618f29dbc25SmrgDraco9210WriteReg(unsigned char index, unsigned char data) 619f29dbc25Smrg{ 620f29dbc25Smrg 621f29dbc25Smrg Draco9210SetCS(); 622f29dbc25Smrg Draco9210ToggleClock(); 623f29dbc25Smrg 624f29dbc25Smrg Draco9210SetDataOut(); 625f29dbc25Smrg Draco9210ToggleClock(); 626f29dbc25Smrg 627f29dbc25Smrg Draco9210ClearDataOut(); 628f29dbc25Smrg Draco9210ToggleClock(); 629f29dbc25Smrg 630f29dbc25Smrg Draco9210ClearDataOut(); 631f29dbc25Smrg Draco9210ToggleClock(); 632f29dbc25Smrg 633f29dbc25Smrg Draco9210SetDataOut(); 634f29dbc25Smrg Draco9210ToggleClock(); 635f29dbc25Smrg 636f29dbc25Smrg DracoWriteData(index); 637f29dbc25Smrg DracoWriteData(data); 638f29dbc25Smrg 639f29dbc25Smrg Draco9210ClearDataOut(); 640f29dbc25Smrg Draco9210ToggleClock(); 641f29dbc25Smrg 642f29dbc25Smrg Draco9210ClearCS(); 643f29dbc25Smrg Draco9210ToggleClock(); 644f29dbc25Smrg Draco9210ToggleClock(); 645f29dbc25Smrg 646f29dbc25Smrg} 647