1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/Kconfig linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Kconfig
--- linux-4.7.3/arch/avr32/boards/grasshopper/Kconfig 2016-09-20 11:29:35.780351249 +0200
+++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Kconfig 2016-09-20 11:39:58.981762577 +0200
@@ -44,4 +44,9 @@
depends on BOARD_GRASSHOPPER_MMC
default n
+config BOARD_GRASSHOPPER_I2C
+ bool "Enable I2C interface"
+ depends on I2C && I2C_GPIO
+ default y
+
endif # BOARD_GRASSHOPPER
diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/setup.c linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/setup.c
--- linux-4.7.3/arch/avr32/boards/grasshopper/setup.c 2016-09-20 11:29:35.781351262 +0200
+++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/setup.c 2016-09-20 11:32:21.270587433 +0200
@@ -129,6 +129,28 @@
};
#endif
+/* I2C/TWI */
+#ifdef CONFIG_BOARD_GRASSHOPPER_I2C
+static struct i2c_gpio_platform_data i2c_gpio_data = {
+ .sda_pin = GPIO_PIN_PA(6),
+ .scl_pin = GPIO_PIN_PA(7),
+ .sda_is_open_drain = 1,
+ .scl_is_open_drain = 1,
+ .udelay = 2, /* close to 100 kHz */
+};
+
+static struct platform_device i2c_gpio_device = {
+ .name = "i2c-gpio",
+ .id = 0,
+ .dev = {
+ .platform_data = &i2c_gpio_data,
+ },
+};
+
+static struct i2c_board_info i2c_info[] = {
+};
+#endif
+
/* MCI */
#ifdef CONFIG_BOARD_GRASSHOPPER_MMC
static struct mci_platform_data __initdata mci0_data = {
@@ -168,6 +190,22 @@
ATMEL_LCDC_PRI_CONTROL | ATMEL_LCDC_PRI_24BIT);
#endif
+ // I2C / TWI
+#ifdef CONFIG_BOARD_GRASSHOPPER_I2C
+ /* all these i2c/smbus pins should have external pullups for
+ * open-drain sharing among all I2C devices. SDA and SCL do;
+ * PB28/EXTINT3 doesn't; it should be SMBALERT# (for PMBus),
+ * but it's not available off-board.
+ */
+ at32_select_periph(GPIO_PIOB_BASE, 1 << 28, 0, AT32_GPIOF_PULLUP);
+ at32_select_gpio(i2c_gpio_data.sda_pin,
+ AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+ at32_select_gpio(i2c_gpio_data.scl_pin,
+ AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
+ platform_device_register(&i2c_gpio_device);
+ i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
+#endif
+
#ifdef CONFIG_BOARD_GRASSHOPPER_MMC
at32_add_device_mci(0, &mci0_data); /* MMC/SD */
#endif
|