BigW Consortium Gitlab

Commit 45bab41f by David Clark

Merge branch 'master' of ssh://github.com/mangOH/mangOH

parents f297cd05 f94d71a0
all:
$(info Bug LE-7663 prevents this Makefile from building a correct Legato system.)
$(info Once this bug is fixed in a stable version of Legato, the Makefile will)
$(info be restored. For now, build the mangOH system by executing the following)
$(info command from a Legato working copy:)
$(info make wp85 SDEF_TO_USE=$$MANGOH_ROOT/mangOH_Red.sdef MKSYS_FLAGS="-s $$MANGOH_ROOT/apps/GpioExpander/gpioExpanderService -s $$MANGOH_ROOT/apps/RedSensorToCloud")
$(info Note that you must first define MANGOH_ROOT. eg. export MANGOH_ROOT=~/mangOH)
exit 1
export MANGOH_ROOT = $(shell pwd)
MKSYS_ARGS_COMMON = -s $(MANGOH_ROOT)/apps/GpioExpander/gpioExpanderService
MKSYS_ARGS_GREEN =
MKSYS_ARGS_RED = -s $(MANGOH_ROOT)/apps/RedSensorToCloud
# The comments below are for Developer Studio integration. Do not remove them.
# DS_CLONE_ROOT(MANGOH_ROOT)
# DS_CUSTOM_OPTIONS(MKSYS_ARGS_COMMON)
# DS_CUSTOM_OPTIONS(MKSYS_ARGS_GREEN)
# DS_CUSTOM_OPTIONS(MKSYS_ARGS_RED)
# This is a temporary workaround for bug LE-7850. Once Legato 17.08.0 or 17.07.2 is released, this
# should no longer be necessary.
export TARGET := wp85
.PHONY: all
all: green_wp85 green_wp750x red_wp85 red_wp750x
.PHONY: green_wp85
green_wp85:
mksys -t wp85 $(MKSYS_ARGS_COMMON) $(MKSYS_ARGS_GREEN) mangOH_Green.sdef
.PHONY: green_wp750x
green_wp750x:
mksys -t wp750x $(MKSYS_ARGS_COMMON) $(MKSYS_ARGS_GREEN) mangOH_Green.sdef
.PHONY: red_wp85
red_wp85:
mksys -t wp85 $(MKSYS_ARGS_COMMON) $(MKSYS_ARGS_RED) mangOH_Red.sdef
.PHONY: red_wp750x
red_wp750x:
mksys -t wp750x $(MKSYS_ARGS_COMMON) $(MKSYS_ARGS_RED) mangOH_Red.sdef
.PHONY: clean
clean:
rm -rf \
_build_mangOH_Green \
mangOH_Green.wp85.update \
mangOH_Green.wp750x.update \
_build_mangOH_Red \
mangOH_Red.wp85.update \
mangOH_Red.wp750x.update
......@@ -5,8 +5,14 @@ Base project containing apps and drivers for the mangOH hardware
## Setup
1. Download and install the appropriate toolchain from [source.sierrawireless.com](https://source.sierrawireless.com/resources/legato/downloads/)
1. Enable the toolchain to build kernel modules by running these commands:
1. `export PATH=$PATH:/opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi`
1. `cd /opt/swi/y17-ext/sysroots/armv7a-vfp-neon-poky-linux-gnueabi/usr/src/kernel`
1. `sudo chown -R $USER .`
1. `ARCH=arm CROSS_COMPILE=arm-poky-linux-gnueabi- make scripts`
1. `sudo chown -R root .`
1. Get the Legato source code as described by the [Legato README](https://github.com/legatoproject/legato-af/blob/master/README.md)
1. Clone the mangOH source code by running `git clone --recursive git://github.com/mangOH/mangOH`
1. `cd` into the Legato working folder and run the following command to build a system for the mangOH Red: `make wp85 SDEF_TO_USE=$MANGOH_ROOT/mangOH_Red.sdef MKSYS_FLAGS="-s $MANGOH_ROOT/apps/GpioExpander/gpioExpanderService -s $MANGOH_ROOT/apps/RedSensorToCloud"`
1. Run `./bin/legs` to put the Legato tools into `$PATH`
1. Run `source ./bin/configlegatoenv` to put the Legato tools into `$PATH`
1. Run `instlegato wp85 192.168.2.2` to install the system onto the mangOH connected via a USB cable to the CF3 USB port.
Subproject commit 1df717d51f6d2f25a62b57f1b6b7abbdfb4e5319
Subproject commit e4ae027c9f447f84723f3fc1c872875166840cfa
Subproject commit 84a92c33c6cb1cc73f42799a806fd4223023178d
Subproject commit 84b40089f470cd0574ca72bf1943c3bcb6f2842d
Subproject commit 3f6ec22ecdcfe42a4582c55321a5b8d8d90cbb2f
Subproject commit d93113164cd059d6a63842d593ae88be575c3fdc
......@@ -10,6 +10,7 @@ sources:
board_green_dv4.c
board_red_dv2.c
board_red_dv3.c
board_red_dv4.c
}
params:
......
......@@ -10,6 +10,7 @@ sources:
board_green_dv4.c
board_red_dv2.c
board_red_dv3.c
board_red_dv4.c
}
params:
......
......@@ -10,6 +10,7 @@ sources:
board_green_dv4.c
board_red_dv2.c
board_red_dv3.c
board_red_dv4.c
}
params:
......
cflags:
{
// Needed for lsm6ds3 platform data type definition
-I${MANGOH_ROOT}/linux_kernel_modules/lsm6ds3
}
sources:
{
mangoh_module.c
board_green_dv4.c
board_red_dv2.c
board_red_dv3.c
board_red_dv4.c
}
params:
{
board = "red dv4"
}
......@@ -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,14 +167,17 @@ static int red_dv2_map(struct platform_device *pdev)
}
/*
* TODO:
* Pressure Sensor: 0x76
* chip is bmp280 by Bosch which has a driver in the mainline kernel
* 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.
* 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.
* Battery Gauge: 0x64
* chip is LTC29421 which is made by linear technologies (now Analog
* Devices). I haven't found a linux kernel driver.
* chip is LTC2942 which is made by linear technologies (now Analog
* Devices). There is a kernel driver in the linux-power-supply
* repository in the for-next branch.
* Buck & Battery Charger: 0x6B
* chip is BQ24296RGER
*/
......@@ -246,9 +194,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 RED_DV3_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");
/*
......@@ -214,9 +166,6 @@ static int red_dv3_map(struct platform_device *pdev)
* 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.
* Battery Gauge: 0x64
* chip is LTC29421 which is made by linear technologies (now Analog
* Devices). I haven't found a linux kernel driver.
* Buck & Battery Charger: 0x6B
* chip is BQ24296RGER
*/
......@@ -233,11 +182,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);
......
#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 "mangoh.h"
#include "lsm6ds3_platform_data.h"
/*
*-----------------------------------------------------------------------------
* Type definitions
*-----------------------------------------------------------------------------
*/
struct red_dv4_platform_data {
struct i2c_client* i2c_switch;
struct i2c_client* accelerometer;
struct i2c_client* pressure;
};
struct red_dv4_device
{
struct platform_device pdev;
struct red_dv4_platform_data pdata;
};
/*
*-----------------------------------------------------------------------------
* Function declarations
*-----------------------------------------------------------------------------
*/
static int red_dv4_map(struct platform_device *pdev);
static int red_dv4_unmap(struct platform_device* pdev);
static void red_dv4_release_device(struct device* dev);
/*
*-----------------------------------------------------------------------------
* Constants
*-----------------------------------------------------------------------------
*/
#define RED_DV4_I2C_SW_BASE_ADAPTER_ID (1)
#define RED_DV4_I2C_SW_PORT_IOT0 (0)
#define RED_DV4_I2C_SW_PORT_BATTERY_CHARGER (1)
#define RED_DV4_I2C_SW_PORT_USB_HUB (1)
#define RED_DV4_I2C_SW_PORT_GPIO_EXPANDER (2)
#define RED_DV4_I2C_SW_PORT_EXP (3) /* expansion header */
/*
*-----------------------------------------------------------------------------
* Variables
*-----------------------------------------------------------------------------
*/
const struct mangoh_descriptor red_dv4_descriptor = {
.type = "mangoh red dv4",
.map = red_dv4_map,
.unmap = red_dv4_unmap,
};
static struct pca954x_platform_mode red_dv4_pca954x_adap_modes[] = {
{.adap_id=RED_DV4_I2C_SW_BASE_ADAPTER_ID + 0, .deselect_on_exit=1, .class=0},
{.adap_id=RED_DV4_I2C_SW_BASE_ADAPTER_ID + 1, .deselect_on_exit=1, .class=0},
{.adap_id=RED_DV4_I2C_SW_BASE_ADAPTER_ID + 2, .deselect_on_exit=1, .class=0},
{.adap_id=RED_DV4_I2C_SW_BASE_ADAPTER_ID + 3, .deselect_on_exit=1, .class=0},
};
static struct pca954x_platform_data red_dv4_pca954x_pdata = {
red_dv4_pca954x_adap_modes,
ARRAY_SIZE(red_dv4_pca954x_adap_modes),
};
static const struct i2c_board_info red_dv4_pca954x_device_info = {
I2C_BOARD_INFO("pca9546", 0x71),
.platform_data = &red_dv4_pca954x_pdata,
};
static struct i2c_board_info red_dv4_accelerometer_devinfo = {
I2C_BOARD_INFO("bmi160", 0x68),
};
static struct i2c_board_info red_dv4_pressure_devinfo = {
I2C_BOARD_INFO("bmp280", 0x76),
};
static const char platform_device_name[] = "mangoh red dv4";
/*
*-----------------------------------------------------------------------------
* Public function definitions
*-----------------------------------------------------------------------------
*/
int red_dv4_create_device(struct platform_device** d)
{
struct red_dv4_device *dv4 = kzalloc(sizeof(struct red_dv4_device), GFP_KERNEL);
if (!dv4)
return -ENOMEM;
dv4->pdev.name = platform_device_name;
dv4->pdev.id = -1;
dv4->pdev.dev.platform_data = &dv4->pdata;
dv4->pdev.dev.release = red_dv4_release_device;
*d = &dv4->pdev;
return 0;
}
/*
*-----------------------------------------------------------------------------
* Static function definitions
*-----------------------------------------------------------------------------
*/
static int red_dv4_map(struct platform_device *pdev)
{
struct red_dv4_platform_data* pdata = dev_get_platdata(&pdev->dev);
/* Get the main i2c adapter */
struct i2c_adapter* adapter = i2c_get_adapter(0);
if (!adapter) {
dev_err(&pdev->dev, "Failed to get I2C adapter 0.\n");
return -ENODEV;
}
/* Map the I2C switch */
dev_dbg(&pdev->dev, "mapping i2c switch\n");
pdata->i2c_switch = i2c_new_device(adapter, &red_dv4_pca954x_device_info);
if (!pdata->i2c_switch) {
dev_err(
&pdev->dev,
"Failed to register %s\n",
red_dv4_pca954x_device_info.type);
return -ENODEV;
}
/* Map the I2C BMI160 accelerometer */
dev_dbg(&pdev->dev, "mapping bmi160 accelerometer\n");
/*
* Pins 11 and 12 of the gpio expander are connected to bmi160's INT1
* and INT2 pins respectively. It does not appear that the bmi160 driver
* makes use of these interrupt pins.
*/
adapter = i2c_get_adapter(0);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", 0);
return -ENODEV;
}
pdata->accelerometer = i2c_new_device(adapter, &red_dv4_accelerometer_devinfo);
if (!pdata->accelerometer) {
dev_err(&pdev->dev, "Accelerometer is missing\n");
return -ENODEV;
}
/* Map the I2C BMP280 pressure sensor */
dev_dbg(&pdev->dev, "mapping bmp280 pressure sensor\n");
adapter = i2c_get_adapter(0);
if (!adapter) {
dev_err(&pdev->dev, "No I2C bus %d.\n", 0);
return -ENODEV;
}
pdata->pressure = i2c_new_device(adapter, &red_dv4_pressure_devinfo);
if (!pdata->pressure) {
dev_err(&pdev->dev, "Pressure sensor is missing\n");
return -ENODEV;
}
/*
* TODO:
* 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.
* Battery Gauge: 0x64
* chip is LTC2942 which is made by linear technologies (now Analog
* Devices). There is a kernel driver in the linux-power-supply
* repository in the for-next branch.
* Buck & Battery Charger: 0x6B
* chip is BQ24296RGER
*/
return 0;
}
static int red_dv4_unmap(struct platform_device* pdev)
{
struct red_dv4_platform_data* pdata = dev_get_platdata(&pdev->dev);
i2c_unregister_device(pdata->pressure);
i2c_put_adapter(pdata->pressure->adapter);
i2c_unregister_device(pdata->accelerometer);
i2c_put_adapter(pdata->accelerometer->adapter);
i2c_unregister_device(pdata->i2c_switch);
i2c_put_adapter(pdata->i2c_switch->adapter);
return 0;
}
static void red_dv4_release_device(struct device* dev)
{
struct platform_device *pdev = container_of(dev, struct platform_device, dev);
struct red_dv4_device *dv4 = container_of(pdev, struct red_dv4_device, pdev);
kfree(dv4);
}
#ifndef BOARD_RED_DV4_H
#define BOARD_RED_DV4_H
#include "mangoh.h"
extern const struct mangoh_descriptor red_dv4_descriptor;
int red_dv4_create_device(struct platform_device** d);
#endif // BOARD_RED_DV4_H
#define DEBUG
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <asm/irq.h>
#include <linux/delay.h>
#include "mangoh.h"
#include "board_green_dv4.h"
#include "board_red_dv2.h"
#include "board_red_dv3.h"
#include "board_red_dv4.h"
/*
*-----------------------------------------------------------------------------
......@@ -42,6 +43,7 @@ static const struct platform_device_id mangoh_ids[] = {
{.name="mangoh green dv4", .driver_data=(kernel_ulong_t)&green_dv4_descriptor},
{.name="mangoh red dv2", .driver_data=(kernel_ulong_t)&red_dv2_descriptor},
{.name="mangoh red dv3", .driver_data=(kernel_ulong_t)&red_dv3_descriptor},
{.name="mangoh red dv4", .driver_data=(kernel_ulong_t)&red_dv4_descriptor},
{},
};
MODULE_DEVICE_TABLE(platform, mangoh_ids);
......@@ -65,10 +67,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",
......@@ -94,6 +94,15 @@ static int __init mangoh_init(void)
board);
return rc;
}
} else if (strcmp(board, "red dv4") == 0) {
int rc = red_dv4_create_device(&mangoh_device);
if (rc != 0) {
pr_err(
"%s: Couldn't create device for '%s'.\n",
__func__,
board);
return rc;
}
} else {
pr_err(
"%s: unsupported board '%s'.\n",
......@@ -101,21 +110,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);
......@@ -129,6 +138,9 @@ static int mangoh_probe(struct platform_device* pdev)
platform_get_device_id(pdev)->driver_data;
platform_set_drvdata(pdev, desc);
/* Work around USB issues at boot time by delaying device installation */
dev_info(&pdev->dev, "Probing mangOH platform device\n");
msleep(5000);
return desc->map(pdev);
}
......@@ -146,5 +158,5 @@ module_exit(mangoh_exit);
MODULE_ALIAS(PLATFORM_MODULE_PREFIX "mangoh");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sierra Wireless");
MODULE_DESCRIPTION("Add devices on mangOH green hardware board");
MODULE_DESCRIPTION("Add devices on mangOH hardware boards");
MODULE_VERSION("1.0");
......@@ -14,10 +14,9 @@ apps:
$MANGOH_ROOT/apps/MuxControl/tools/muxCtrlTools
$MANGOH_ROOT/apps/MqttClient/mqttClient
// Data Router is disabled because the published version doesn't build against Legato 17.05
// $MANGOH_ROOT/apps/DataRouter/dataRouter
// $MANGOH_ROOT/apps/DataRouter/drTool/drTool
// $MANGOH_ROOT/apps/ArduinoBridge/arduinoBridge
$MANGOH_ROOT/apps/DataRouter/dataRouter
$MANGOH_ROOT/apps/DataRouter/drTool/drTool
$MANGOH_ROOT/apps/ArduinoBridge/arduinoBridge
$MANGOH_ROOT/apps/SocialService/socialService
$MANGOH_ROOT/apps/Heartbeat/heartbeatGreen
......@@ -28,7 +27,7 @@ apps:
commands:
{
mux = muxCtrlTools:/bin/mux
// dr = drTool:/bin/dr
dr = drTool:/bin/dr
twitter = socialService:/bin/twitter
}
......
......@@ -11,9 +11,8 @@ apps:
$MANGOH_ROOT/apps/GpioExpander/gpioExpanderService/gpioExpanderServiceRed
$MANGOH_ROOT/apps/MqttClient/mqttClient
// Data Router is disabled because the published version doesn't build against Legato 17.05
// $MANGOH_ROOT/apps/DataRouter/dataRouter
// $MANGOH_ROOT/apps/DataRouter/drTool/drTool
$MANGOH_ROOT/apps/DataRouter/dataRouter
$MANGOH_ROOT/apps/DataRouter/drTool/drTool
$MANGOH_ROOT/apps/SocialService/socialService
$MANGOH_ROOT/apps/RedSensorToCloud/redSensorToCloud
......@@ -28,17 +27,19 @@ apps:
commands:
{
// dr = drTool:/bin/dr
dr = drTool:/bin/dr
twitter = socialService:/bin/twitter
}
kernelModules:
{
$MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv3
// $MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv2
// $MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv3
$MANGOH_ROOT/linux_kernel_modules/mangoh/9-mangoh_red_dv4
$MANGOH_ROOT/linux_kernel_modules/cp2130/0-cp2130
// Disable the cp2130 for now until the lockup issue is resolved
// $MANGOH_ROOT/linux_kernel_modules/cp2130/0-cp2130
// Required for bmp280 & bmi160
$MANGOH_ROOT/linux_kernel_modules/iio/0-iio
......@@ -49,11 +50,11 @@ kernelModules:
$MANGOH_ROOT/linux_kernel_modules/bmp280/2-bmp280
$MANGOH_ROOT/linux_kernel_modules/bmp280/3-bmp280-i2c
// Only on mangOH Red DV2
// Used on mangOH Red DV2
// $MANGOH_ROOT/linux_kernel_modules/lsm6ds3/0-lsm6ds3
// $MANGOH_ROOT/linux_kernel_modules/lsm6ds3/1-lsm6ds3-i2c
// Only on mangOH Red DV3
// Used on mangOH Red DV3 and later
$MANGOH_ROOT/linux_kernel_modules/bmi160/3-bmi160
$MANGOH_ROOT/linux_kernel_modules/bmi160/4-bmi160-i2c
}
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