2 Copyright © 2005-2013, Davy Wentzler. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/expansion.h>
9 #include "DriverData.h"
15 static void Revo51_Start(struct CardData
*card
)
17 SaveGPIO(card
->pci_dev
, card
);
21 static void Revo51_Stop(struct CardData
*card
)
23 RestoreGPIO(card
->pci_dev
, card
);
28 // Set the direction of the CLK and SDA lines:
29 // For sending, use 1, 1
30 static void Revo51_SetDir_CLK_SDA(struct CardData
*card
, int clock
, int data
)
32 unsigned int mask
= 0, val
;
36 val
= REVO51_I2C_CLOCK
; /* write SCL */
38 val
|= REVO51_I2C_DATA
; /* write SDA */
40 mask
= REVO51_I2C_CLOCK
| REVO51_I2C_DATA
;
41 card
->gpio_dir
&= ~mask
;
42 card
->gpio_dir
|= val
;
43 SetGPIODir(card
->pci_dev
, card
, card
->gpio_dir
);
44 SetGPIOMask(card
, card
->iobase
, ~mask
);
50 // Write data to the SDA line and clock to the SCL
51 static void Revo51_Write_CLK_SDA(struct CardData
*card
, int clk
, int data
)
53 unsigned int val
= 0, mask
= REVO51_I2C_CLOCK
| REVO51_I2C_DATA
;;
56 val
|= REVO51_I2C_CLOCK
;
58 val
|= REVO51_I2C_DATA
;
60 card
->gpio_dir
|= mask
;
61 SetGPIODir(card
->pci_dev
, card
, card
->gpio_dir
);
62 SetGPIOMask(card
, card
->iobase
, ~mask
);
63 SetGPIOData(card
, card
->iobase
, mask
& val
);
69 static int Revo51_GetDataBit(struct CardData
*card
, int ack
)
76 // get data bit from the GPIO pines
77 card
->gpio_dir
&= ~REVO51_I2C_DATA
;
78 SetGPIODir(card
->pci_dev
, card
, card
->gpio_dir
);
79 bit
= GetGPIOData(card
, card
->iobase
) & REVO51_I2C_DATA
? 1 : 0;
85 static struct I2C_bit_ops Revo51_bit_ops
= {
88 Revo51_SetDir_CLK_SDA
,
94 void Revo51_Init(struct CardData
*card
)
96 unsigned char bytes
[4];
98 /* create i2c devices */
99 card
->i2c
= AllocI2C(0x40);
100 card
->i2c
->bit
= &Revo51_bit_ops
;
102 card
->bit_ops
= &Revo51_bit_ops
;
104 //DEBUGPRINTF("Resetting PT2258\n");
106 // step 1: clear reg 0xC0
108 WriteBytesI2C(card
, card
->i2c
, bytes
, 1);
110 // unmute all channels
111 bytes
[0] = REVO51_2258_UNMUTE
;
112 WriteBytesI2C(card
, card
->i2c
, bytes
, 1);
114 // set all 6 channels to no attenuation (0dB)
117 WriteBytesI2C(card
, card
->i2c
, bytes
, 2);