BigW Consortium Gitlab

Commit 4f37e70b by Forest Godfrey

Add support for Arduino I2C keyboard to MangOH red driver.

This really should use a Device Tree overlay but the mangOH code doesn't allow that to happen because the i2c expander isn't declared using an overlay.
parent 85f0829f
......@@ -10,6 +10,7 @@
#include <linux/platform_data/at24.h>
#include <linux/ctype.h>
#include <ai2c_platform_data.h>
#include "ltc294x-platform-data.h"
#include "bq24190-platform-data.h"
#include "bq27xxx_battery.h"
......@@ -30,6 +31,7 @@
#define MANGOH_RED_I2C_BUS_USB_HUB (MANGOH_RED_I2C_SW_BUS_BASE + 1)
#define MANGOH_RED_I2C_BUS_GPIO_EXPANDER (MANGOH_RED_I2C_SW_BUS_BASE + 2)
#define MANGOH_RED_I2C_BUS_EXP (MANGOH_RED_I2C_SW_BUS_BASE + 3)
#define MANGOH_RED_I2C_BUS_AI2C_KBD (MANGOH_RED_I2C_SW_BUS_BASE + 3)
/*
......@@ -109,6 +111,7 @@ static struct mangoh_red_driver_data {
struct i2c_client* battery_gauge;
struct i2c_client* battery_charger;
struct i2c_client* gpio_expander;
struct i2c_client* ai2c_keyboard;
bool mux_initialized;
bool iot_slot_registered;
bool led_registered;
......@@ -154,6 +157,12 @@ static struct sx150x_platform_data mangoh_red_gpio_expander_platform_data = {
.reset_during_probe = true,
};
static struct arduino_i2c_keyboard_platform_data mangoh_red_ai2c_keyboard_platform_data = {
.gpio_intr_pin = 9, /* Device gets its interrupts on Linux 9 which is schematic 22 */
.keymap = NULL, /* Use default keymap */
};
static const struct i2c_board_info mangoh_red_gpio_expander_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x3e),
.platform_data = &mangoh_red_gpio_expander_platform_data,
......@@ -191,6 +200,10 @@ static struct i2c_board_info bq27426_battery_gauge_devinfo = {
static struct i2c_board_info mangoh_red_battery_charger_devinfo = {
I2C_BOARD_INFO("bq24190", 0x6B),
};
static struct i2c_board_info mangoh_red_ai2c_keyboard_devinfo = {
I2C_BOARD_INFO("ai2c-keys", 0x42),
.platform_data = &mangoh_red_ai2c_keyboard_platform_data,
};
#ifdef ENABLE_IOT_SLOT
static struct iot_slot_platform_data mangoh_red_iot_slot_pdata = {
......@@ -387,6 +400,26 @@ static int mangoh_red_probe(struct platform_device* pdev)
goto cleanup;
}
/* Map the Arduino I2C keyboard */
dev_dbg(&pdev->dev, "mapping arduino i2c keyboard\n");
other_adapter = i2c_get_adapter(MANGOH_RED_I2C_BUS_AI2C_KBD);
if (!other_adapter) {
dev_err(&pdev->dev,
"Couldn't get I2C bus %d to add the AI2C keyboard.\n",
MANGOH_RED_I2C_BUS_GPIO_EXPANDER);
ret = -ENODEV;
goto cleanup;
}
mangoh_red_driver_data.ai2c_keyboard =
i2c_new_device(other_adapter, &mangoh_red_ai2c_keyboard_devinfo);
i2c_put_adapter(other_adapter);
if (!mangoh_red_driver_data.ai2c_keyboard) {
dev_err(&pdev->dev, "Failed to register %s\n",
mangoh_red_gpio_expander_devinfo.type);
ret = -ENODEV;
goto cleanup;
}
gpio_expander = i2c_get_clientdata(
mangoh_red_driver_data.gpio_expander);
#ifdef ENABLE_IOT_SLOT
......@@ -497,6 +530,7 @@ static int mangoh_red_remove(struct platform_device* pdev)
i2c_unregister_device(dd->battery_charger);
i2c_unregister_device(dd->pressure);
i2c_unregister_device(dd->accelerometer);
i2c_unregister_device(dd->ai2c_keyboard);
if (dd->led_registered)
platform_device_unregister(&mangoh_red_led);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment