make sure the arm implementation struct is aligned
[AROS.git] / arch / arm-native / soc / broadcom / 283x / hidd / i2c / i2c-bcm283x.c
blob1d6810a736434da3b72c9ccf6b107643b5c52f14
1 /*
2 Copyright © 2010-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/symbolsets.h>
7 #include <aros/debug.h>
8 #include <proto/exec.h>
9 #include <proto/kernel.h>
11 #include <hidd/i2c.h>
13 static IPTR __arm_periiobase;
14 #define ARM_PERIIOBASE __arm_periiobase
15 #include <hardware/bcm283x.h>
16 #include <asm/io.h>
18 #include "i2c-bcm283x.h"
20 APTR KernelBase __attribute__((used)) = NULL;
22 void METHOD(I2CBCM283X, Hidd_I2C, PutByte)
24 while (!((*(volatile UBYTE *)BSC0_STATUS) & BSC_STATUS_DONE))
26 asm volatile ("mov r2,r2\n");
29 *(volatile UBYTE *)BSC0_DATALEN = 1;
30 *(volatile UBYTE *)BSC0_FIFO = msg->data;
32 *(volatile UBYTE *)BSC0_STATUS = BSC_CLEAR;
33 *(volatile UBYTE *)BSC0_CONTROL = BSC_WRITE;
36 void METHOD(I2CBCM283X, Hidd_I2C, GetByte)
38 while (!((*(volatile UBYTE *)BSC0_STATUS) & BSC_STATUS_DONE))
40 asm volatile ("mov r2,r2\n");
43 *(volatile UBYTE *)BSC0_DATALEN = 1;
44 *(volatile UBYTE *)BSC0_STATUS = BSC_CLEAR;
45 *(volatile UBYTE *)BSC0_CONTROL = BSC_READ;
47 *msg->data = *(volatile UBYTE *)BSC0_FIFO;
50 void I2CBCM283X_Init(void)
52 KernelBase = OpenResource("kernel.resource");
53 __arm_periiobase = KrnGetSystemAttr(KATTR_PeripheralBase);
55 /* BSC0 is on GPIO 0 & 1 */
56 *(volatile UBYTE *)GPFSEL0 &= ~0x3f; // Mask out bits 0-5
57 *(volatile UBYTE *)GPFSEL0 |= 0x24; // Set bits 0-5 to binary '100100'
60 ADD2LIBS((STRPTR)"i2c.hidd", 0, static struct Library *, I2CBase);