BigW Consortium Gitlab

Commit 5b1d059a by David Frey

Remove gpio init code from mangoh kernel module

Remove the commented out gpio initialization code because it doesn't seem like the gpio interface of the wp85 kernel will change in the short term and thus the gpio kernel driver isn't useful.
parent bb71eb57
......@@ -4,8 +4,6 @@
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c/pca954x.h>
#include <linux/i2c/sx150x.h>
#include <linux/gpio.h>
#include "mangoh.h"
#include "lsm6ds3_platform_data.h"
......@@ -17,9 +15,6 @@
*/
struct green_dv4_platform_data {
struct i2c_client* i2c_switch;
struct i2c_client* gpio_expander1;
struct i2c_client* gpio_expander2;
struct i2c_client* gpio_expander3;
struct i2c_client* accelerometer;
};
......@@ -84,59 +79,6 @@ static const struct i2c_board_info green_dv4_pca954x_device_info = {
.platform_data = &green_dv4_pca954x_pdata,
};
static struct sx150x_platform_data green_dv4_expander1_platform_data = {
.gpio_base = -1,
.oscio_is_gpo = false,
.io_pullup_ena = 0,
.io_pulldn_ena = 0,
.io_open_drain_ena = 0,
.io_polarity = 0,
.irq_base = -1,
.irq_summary = -1,
};
static const struct i2c_board_info green_dv4_expander1_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x3e),
.platform_data = &green_dv4_expander1_platform_data,
};
static struct sx150x_platform_data green_dv4_expander2_platform_data = {
.gpio_base = -1,
.oscio_is_gpo = false,
/*
* Enable pull-up resistors for CARD_DETECT_IOT0, CARD_DETECT_IOT2 and
* CARD_DETECT_IOT1 respectively.
*/
.io_pullup_ena = ((1 << 11) | (1 << 12) | (1 << 13)),
.io_pulldn_ena = 0,
.io_open_drain_ena = 0,
/*
* The interrupt lines driven by expanders 1 and 3 respectively are
* driven low when an interrupt occurs, so invert the polarity
*/
.io_polarity = ((1 << 0) | (1 << 14)),
.irq_base = -1,
.irq_summary = -1,
};
static const struct i2c_board_info green_dv4_expander2_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x3f),
.platform_data = &green_dv4_expander2_platform_data,
};
static struct sx150x_platform_data green_dv4_expander3_platform_data = {
.gpio_base = -1,
.oscio_is_gpo = false,
.io_pullup_ena = 0,
.io_pulldn_ena = 0,
.io_open_drain_ena = 0,
.io_polarity = 0,
.irq_base = -1,
.irq_summary = -1,
};
static const struct i2c_board_info green_dv4_expander3_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x70),
.platform_data = &green_dv4_expander3_platform_data,
};
static struct lsm6ds3_platform_data green_dv4_accelerometer_platform_data = {
.drdy_int_pin = 1,
};
......@@ -173,19 +115,6 @@ int green_dv4_create_device(struct platform_device** d)
* Static function definitions
*-----------------------------------------------------------------------------
*/
static int get_sx150x_gpio_base(struct i2c_client *client)
{
/*
* This is kind of a hack. It depends on the fact that we know
* that the clientdata of the gpio expander is a struct
* sx150x_chip (type is private to the sx150x driver) and
* knowing that the first element of that struct is a struct
* gpio_chip.
*/
struct gpio_chip *expander = i2c_get_clientdata(client);
return expander->base;
}
static int green_dv4_map(struct platform_device *pdev)
{
struct green_dv4_platform_data* pdata = dev_get_platdata(&pdev->dev);
......@@ -208,92 +137,6 @@ static int green_dv4_map(struct platform_device *pdev)
return -ENODEV;
}
#if 0
/*
* Map SX1509 GPIO expander 2. Expander 2 has to be mapped first because
* the interrupt pins of expanders 1 and 3 are connected to I/Os of
* expander 2.
*/
dev_dbg(&pdev->dev, "mapping gpio expander 2\n");
/*
* GPIOEXP_INT2 goes to "GPIO2" on the inner ring in the green dv4
* schematic. The WP85 schematic maps this to GPIO 59.
*/
green_dv4_expander2_platform_data.irq_summary = gpio_to_irq(59);
/*
* Currently we just hard code an IRQ base that was tested to have a
* contiguous set of 16 available IRQs. TODO: Is there a better way to
* find a contiguous set of IRQs?
*/
green_dv4_expander2_platform_data.irq_base = 347;
adapter = i2c_get_adapter(
GREEN_DV4_I2C_SW_BASE_ADAPTER_ID +
GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER2);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER2);
return -ENODEV;
}
pdata->gpio_expander2 = i2c_new_device(adapter, &green_dv4_expander2_devinfo);
if (!pdata->gpio_expander2) {
dev_err(&pdev->dev, "GPIO expander 2 is missing\n");
return -ENODEV;
}
/* Map SX1509 GPIO expander 1 */
dev_dbg(&pdev->dev, "mapping gpio expander 1\n");
/*
* GPIOEXP_INT1 goes to I/O0 on GPIO expander 2 in the green dv4
* schematic.
*/
green_dv4_expander1_platform_data.irq_summary =
gpio_to_irq(get_sx150x_gpio_base(pdata->gpio_expander2) + 0);
/*
* Currently we just hard code an IRQ base that was tested to have a
* contiguous set of 16 available IRQs. TODO: Is there a better way to
* find a contiguous set of IRQs?
*/
green_dv4_expander1_platform_data.irq_base = 154;
adapter = i2c_get_adapter(
GREEN_DV4_I2C_SW_BASE_ADAPTER_ID +
GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER1);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER1);
return -ENODEV;
}
pdata->gpio_expander1 = i2c_new_device(adapter, &green_dv4_expander1_devinfo);
if (!pdata->gpio_expander1) {
dev_err(&pdev->dev, "GPIO expander 1 is missing\n");
return -ENODEV;
}
/* Map SX1509 GPIO expander 3 */
dev_dbg(&pdev->dev, "mapping gpio expander 3\n");
/*
* GPIOEXP_INT3 goes to I/O14 on GPIO expander 2 in the green dv4
* schematic.
*/
green_dv4_expander3_platform_data.irq_summary =
gpio_to_irq(get_sx150x_gpio_base(pdata->gpio_expander2) + 14);
/*
* Currently we just hard code an IRQ base that was tested to have a
* contiguous set of 16 available IRQs. TODO: Is there a better way to
* find a contiguous set of IRQs?
*/
green_dv4_expander3_platform_data.irq_base = 168;
adapter = i2c_get_adapter(
GREEN_DV4_I2C_SW_BASE_ADAPTER_ID +
GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER3);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", GREEN_DV4_I2C_SW_PORT_GPIO_EXPANDER3);
return -ENODEV;
}
pdata->gpio_expander3 = i2c_new_device(adapter, &green_dv4_expander3_devinfo);
if (!pdata->gpio_expander3) {
dev_err(&pdev->dev, "GPIO expander 3 is missing\n");
return -ENODEV;
}
#endif // GPIO expander not properly supported
/* Map the I2C LSM6DS3 accelerometer */
dev_dbg(&pdev->dev, "mapping lsm6ds3 accelerometer\n");
/* Pin 10 of gpio expander 2 is connected to INT2 of the lsm6ds3 */
......@@ -314,6 +157,10 @@ static int green_dv4_map(struct platform_device *pdev)
/*
* TODO:
* SX1509 GPIO expanders: 0x3E, 0x3F, 0x70
* There is a driver in the WP85 kernel, but the gpiolib
* infrastructure of the WP85 kernel does not allow the expander
* GPIOs to be used in sysfs due to a hardcoded translation table.
* 3503 USB Hub: 0x08
* Looks like there is a driver in the wp85 kernel source at drivers/usb/misc/usb3503.c
* I'm not really sure what benefit is achieved through using this driver.
......@@ -340,17 +187,6 @@ static int green_dv4_unmap(struct platform_device* pdev)
i2c_unregister_device(pdata->accelerometer);
i2c_put_adapter(pdata->accelerometer->adapter);
#if 0
i2c_unregister_device(pdata->gpio_expander3);
i2c_put_adapter(pdata->gpio_expander3->adapter);
i2c_unregister_device(pdata->gpio_expander1);
i2c_put_adapter(pdata->gpio_expander1->adapter);
i2c_unregister_device(pdata->gpio_expander2);
i2c_put_adapter(pdata->gpio_expander2->adapter);
#endif // GPIO expander not properly supported
i2c_unregister_device(pdata->i2c_switch);
i2c_put_adapter(pdata->i2c_switch->adapter);
......
#define DEBUG
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c/pca954x.h>
#include <linux/i2c/sx150x.h>
#include <linux/gpio.h>
#include "mangoh.h"
#include "lsm6ds3_platform_data.h"
......@@ -18,7 +15,6 @@
*/
struct red_dv2_platform_data {
struct i2c_client* i2c_switch;
struct i2c_client* gpio_expander;
struct i2c_client* accelerometer;
struct i2c_client* pressure;
};
......@@ -46,6 +42,7 @@ static void red_dv2_release_device(struct device* dev);
*/
#define RED_DV2_I2C_SW_BASE_ADAPTER_ID (1)
#define RED_DV2_I2C_SW_PORT_IOT0 (0)
#define RED_DV2_I2C_SW_PORT_BATTERY_CHARGER (1)
#define RED_DV2_I2C_SW_PORT_USB_HUB (1)
#define RED_DV2_I2C_SW_PORT_GPIO_EXPANDER (2)
#define RED_DV2_I2C_SW_PORT_EXP (3) /* expansion header */
......@@ -76,22 +73,6 @@ static const struct i2c_board_info red_dv2_pca954x_device_info = {
.platform_data = &red_dv2_pca954x_pdata,
};
static struct sx150x_platform_data red_dv2_expander_platform_data = {
.gpio_base = -1,
.oscio_is_gpo = false,
.io_pullup_ena = 0,
.io_pulldn_ena = 0,
.io_open_drain_ena = 0,
.io_polarity = 0,
.irq_summary = -1,
.irq_base = -1,
};
static const struct i2c_board_info red_dv2_expander_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x3e),
.platform_data = &red_dv2_expander_platform_data,
.irq = 0,
};
static struct lsm6ds3_platform_data red_dv2_accelerometer_platform_data = {
.drdy_int_pin = 1,
};
......@@ -132,19 +113,6 @@ int red_dv2_create_device(struct platform_device** d)
* Static function definitions
*-----------------------------------------------------------------------------
*/
static int get_sx150x_gpio_base(struct i2c_client *client)
{
/*
* This is kind of a hack. It depends on the fact that we know
* that the clientdata of the gpio expander is a struct
* sx150x_chip (type is private to the sx150x driver) and
* knowing that the first element of that struct is a struct
* gpio_chip.
*/
struct gpio_chip *expander = i2c_get_clientdata(client);
return expander->base;
}
static int red_dv2_map(struct platform_device *pdev)
{
struct red_dv2_platform_data* pdata = dev_get_platdata(&pdev->dev);
......@@ -167,36 +135,13 @@ static int red_dv2_map(struct platform_device *pdev)
return -ENODEV;
}
/* Map GPIO expander */
dev_dbg(&pdev->dev, "mapping gpio expander\n");
/*
* GPIOEXP_INT1 goes to GPIO32 on the CF3 inner ring which maps to
* GPIO30 in the WP85.
*/
red_dv2_expander_platform_data.irq_summary = gpio_to_irq(30);
/*
* Currently we just hard code an IRQ base that was tested to have a
* contiguous set of 16 available IRQs. TODO: Is there a better way to
* find a contiguous set of IRQs?
*/
red_dv2_expander_platform_data.irq_base = 347;
adapter = i2c_get_adapter(RED_DV2_I2C_SW_BASE_ADAPTER_ID +
RED_DV2_I2C_SW_PORT_GPIO_EXPANDER);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", RED_DV2_I2C_SW_PORT_GPIO_EXPANDER);
return -ENODEV;
}
pdata->gpio_expander = i2c_new_device(adapter, &red_dv2_expander_devinfo);
if (!pdata->gpio_expander) {
dev_err(&pdev->dev, "GPIO expander is missing\n");
return -ENODEV;
}
/* Map the I2C LSM6DS3 accelerometer */
dev_dbg(&pdev->dev, "mapping lsm6ds3 accelerometer\n");
/* Pin 12 of the gpio expander is connected to INT2 of the lsm6ds3 */
/* Can't use the irq because the GPIO expander isn't controlled by a kernel driver
red_dv2_accelerometer_devinfo.irq =
gpio_to_irq(get_sx150x_gpio_base(pdata->gpio_expander) + 12);
*/
adapter = i2c_get_adapter(0);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", RED_DV2_I2C_SW_BASE_ADAPTER_ID);
......@@ -222,6 +167,10 @@ static int red_dv2_map(struct platform_device *pdev)
}
/*
* TODO:
* SX1509 GPIO expander: 0x3E
* There is a driver in the WP85 kernel, but the gpiolib
* infrastructure of the WP85 kernel does not allow the expander
* GPIOs to be used in sysfs due to a hardcoded translation table.
* Pressure Sensor: 0x76
* chip is bmp280 by Bosch which has a driver in the mainline kernel
* 3503 USB Hub: 0x08
......@@ -246,9 +195,6 @@ static int red_dv2_unmap(struct platform_device* pdev)
i2c_unregister_device(pdata->accelerometer);
i2c_put_adapter(pdata->accelerometer->adapter);
i2c_unregister_device(pdata->gpio_expander);
i2c_put_adapter(pdata->gpio_expander->adapter);
i2c_unregister_device(pdata->i2c_switch);
i2c_put_adapter(pdata->i2c_switch->adapter);
......
#define DEBUG
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c/pca954x.h>
#include <linux/i2c/sx150x.h>
#include <linux/gpio.h>
#include "mangoh.h"
#include "lsm6ds3_platform_data.h"
......@@ -18,7 +15,6 @@
*/
struct red_dv3_platform_data {
struct i2c_client* i2c_switch;
struct i2c_client* gpio_expander;
struct i2c_client* accelerometer;
struct i2c_client* pressure;
};
......@@ -46,6 +42,7 @@ static void red_dv3_release_device(struct device* dev);
*/
#define RED_DV3_I2C_SW_BASE_ADAPTER_ID (1)
#define RED_DV3_I2C_SW_PORT_IOT0 (0)
#define GREEN_DV4_I2C_SW_PORT_BATTERY_CHARGER (1)
#define RED_DV3_I2C_SW_PORT_USB_HUB (1)
#define RED_DV3_I2C_SW_PORT_GPIO_EXPANDER (2)
#define RED_DV3_I2C_SW_PORT_EXP (3) /* expansion header */
......@@ -76,22 +73,6 @@ static const struct i2c_board_info red_dv3_pca954x_device_info = {
.platform_data = &red_dv3_pca954x_pdata,
};
static struct sx150x_platform_data red_dv3_expander_platform_data = {
.gpio_base = -1,
.oscio_is_gpo = false,
.io_pullup_ena = 0,
.io_pulldn_ena = 0,
.io_open_drain_ena = 0,
.io_polarity = 0,
.irq_summary = -1,
.irq_base = -1,
};
static const struct i2c_board_info red_dv3_expander_devinfo = {
I2C_BOARD_INFO("sx1509q", 0x3e),
.platform_data = &red_dv3_expander_platform_data,
.irq = 0,
};
static struct i2c_board_info red_dv3_accelerometer_devinfo = {
I2C_BOARD_INFO("bmi160", 0x68),
};
......@@ -150,35 +131,6 @@ static int red_dv3_map(struct platform_device *pdev)
return -ENODEV;
}
#if 0
/* Map GPIO expander */
dev_dbg(&pdev->dev, "mapping gpio expander\n");
/*
* GPIOEXP_INT1 goes to GPIO32 on the CF3 inner ring which maps to
* GPIO30 in the WP85.
*/
red_dv3_expander_platform_data.irq_summary = gpio_to_irq(30);
/*
* Currently we just hard code an IRQ base that was tested to have a
* contiguous set of 16 available IRQs. TODO: Is there a better way to
* find a contiguous set of IRQs?
*/
red_dv3_expander_platform_data.irq_base = 347;
adapter = i2c_get_adapter(RED_DV3_I2C_SW_BASE_ADAPTER_ID +
RED_DV3_I2C_SW_PORT_GPIO_EXPANDER);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n",
RED_DV3_I2C_SW_BASE_ADAPTER_ID +
RED_DV3_I2C_SW_PORT_GPIO_EXPANDER);
return -ENODEV;
}
pdata->gpio_expander = i2c_new_device(adapter, &red_dv3_expander_devinfo);
if (!pdata->gpio_expander) {
dev_err(&pdev->dev, "GPIO expander is missing\n");
return -ENODEV;
}
#endif // GPIO expander not properly supported
/* Map the I2C BMI160 accelerometer */
dev_dbg(&pdev->dev, "mapping bmi160 accelerometer\n");
/*
......@@ -233,11 +185,6 @@ static int red_dv3_unmap(struct platform_device* pdev)
i2c_unregister_device(pdata->accelerometer);
i2c_put_adapter(pdata->accelerometer->adapter);
#if 0
i2c_unregister_device(pdata->gpio_expander);
i2c_put_adapter(pdata->gpio_expander->adapter);
#endif // GPIO expander not properly supported
i2c_unregister_device(pdata->i2c_switch);
i2c_put_adapter(pdata->i2c_switch->adapter);
......
#define DEBUG
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
......@@ -66,10 +65,8 @@ static struct platform_driver mangoh_driver = {
*/
static int __init mangoh_init(void)
{
printk(KERN_DEBUG "Called %s\n", __func__);
if (strcmp(board, "green dv4") == 0) {
int rc = green_dv4_create_device(&mangoh_device);
printk(KERN_DEBUG "mangoh: created green_dv4 device\n");
if (rc != 0) {
pr_err(
"%s: Couldn't create device for '%s'.\n",
......@@ -102,21 +99,21 @@ static int __init mangoh_init(void)
board);
return -ENODEV;
}
printk(KERN_INFO "mangoh: created device for board %s\n", board);
platform_driver_register(&mangoh_driver);
printk(KERN_DEBUG "mangoh: registered platform driver\n");
printk(KERN_DEBUG "mangoh: registered platform driver\n");
if (platform_device_register(mangoh_device)) {
platform_driver_unregister(&mangoh_driver);
return -ENODEV;
}
printk(KERN_DEBUG "mangoh: registered platform device\n");
printk(KERN_DEBUG "mangoh: registered platform device\n");
return 0;
}
static void __exit mangoh_exit(void)
{
printk(KERN_DEBUG "Called %s\n", __func__);
if (mangoh_device != NULL)
platform_device_unregister(mangoh_device);
......
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