grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / monitors / IntelGMA / intelG45_i2c.c
blob9070706d4dabf8b179f0ce001bde3351d6038e6b
1 /*
2 Copyright © 2010-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
8 #include <aros/debug.h>
9 #include <aros/symbolsets.h>
10 #include <aros/debug.h>
11 #include <proto/exec.h>
12 #include <hidd/i2c.h>
14 #include <stdint.h>
17 #include "intelG45_intern.h"
18 #include "intelG45_regs.h"
20 void METHOD(INTELI2C, Hidd_I2C, PutBits)
22 struct g45staticdata *sd = SD(cl);
23 uint32_t val = 0;
25 #if 0
26 /* SCL as output */
27 val = G45_GPIO_CLOCK_DIR_MASK | G45_GPIO_CLOCK_DIR_VAL;
28 /* update SCL value */
29 val |= G45_GPIO_CLOCK_DATA_MASK;
30 /* SDA as output */
31 val |= G45_GPIO_DATA_DIR_MASK | G45_GPIO_DATA_DIR_VAL;
32 /* update SDA value */
33 val |= G45_GPIO_DATA_MASK;
35 /* set SCL */
36 if (msg->scl)
37 val |= G45_GPIO_CLOCK_DATA_VAL;
38 if (msg->sda)
39 val |= G45_GPIO_DATA_VAL;
40 #endif
42 if (msg->scl)
43 val |= G45_GPIO_CLOCK_DIR_MASK;
44 else
45 val |= G45_GPIO_CLOCK_DIR_MASK | G45_GPIO_CLOCK_DIR_VAL | G45_GPIO_CLOCK_DATA_MASK;
47 if (msg->sda)
48 val |= G45_GPIO_DATA_DIR_MASK;
49 else
50 val |= G45_GPIO_DATA_DIR_MASK | G45_GPIO_DATA_DIR_VAL | G45_GPIO_DATA_MASK;
52 //D(bug("[GMA_I2C] Put: %08x -> %08x\n", val, sd->Card.MMIO + G45_GPIOA));
54 writel(val, sd->Card.MMIO + sd->DDCPort);
55 val = readl(sd->Card.MMIO + sd->DDCPort);
58 void METHOD(INTELI2C, Hidd_I2C, GetBits)
60 struct g45staticdata *sd = SD(cl);
61 uint32_t val;
63 /* release SCL and SDA lines */
64 // writel(/*G45_GPIO_CLOCK_DIR_MASK |*/ G45_GPIO_DATA_DIR_MASK, sd->Card.MMIO + G45_GPIOA);
65 // writel(0, sd->Card.MMIO + G45_GPIOA);
67 val = readl(sd->Card.MMIO + sd->DDCPort);
69 //D(bug("[GMA_I2C] Get: %08x <- %08x\n", val, sd->Card.MMIO + G45_GPIOA));
70 *msg->scl = (val & G45_GPIO_CLOCK_DATA_IN) != 0;
71 *msg->sda = (val & G45_GPIO_DATA_IN) != 0;
75 static const struct OOP_MethodDescr INTELI2C_Hidd_I2C_descr[] =
77 {(OOP_MethodFunc)INTELI2C__Hidd_I2C__PutBits, moHidd_I2C_PutBits},
78 {(OOP_MethodFunc)INTELI2C__Hidd_I2C__GetBits, moHidd_I2C_GetBits},
79 {NULL, 0}
81 #define NUM_INTELI2C_Hidd_I2C_METHODS 2
83 const struct OOP_InterfaceDescr INTELI2C_ifdescr[] =
85 {INTELI2C_Hidd_I2C_descr, IID_Hidd_I2C, NUM_INTELI2C_Hidd_I2C_METHODS},
86 {NULL, NULL}
89 ADD2LIBS((STRPTR)"i2c.hidd", 0, static struct Library *, I2CBase);