BigW Consortium Gitlab

Commit a1d14f8f by David Frey

Copy drivers/mangoh/ from the legato-af repository

The directory has been placed at linux_kernel_modules/iot_slot/ since mangoh is an existing driver in this folder.
parent 28823699
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef MANGOH_IOT_EEPROM_H
#define MANGOH_IOT_EEPROM_H
#include <linux/i2c.h>
#define IRQ_GPIO_UNUSED (0xFF)
#define EEPROM_GPIO_CFG_INPUT_PULL_UP (0x1)
#define EEPROM_GPIO_CFG_INPUT_PULL_DOWN (0x2)
#define EEPROM_GPIO_CFG_INPUT_FLOATING (0x3)
#define EEPROM_GPIO_CFG_OUTPUT_LOW (0x4)
#define EEPROM_GPIO_CFG_OUTPUT_HIGH (0x5)
struct i2c_client *eeprom_load(int slot);
void eeprom_unload(struct i2c_client *eeprom);
struct list_head *eeprom_if_list(struct i2c_client *eeprom);
int eeprom_num_slots(struct i2c_client *eeprom);
#define __DECLARE_IS_IF_PROTOTYPE(bus, ifc) \
bool eeprom_is_if_##bus(struct list_head *ifc)
__DECLARE_IS_IF_PROTOTYPE(gpio, ifc);
__DECLARE_IS_IF_PROTOTYPE(i2c, ifc);
__DECLARE_IS_IF_PROTOTYPE(spi, ifc);
__DECLARE_IS_IF_PROTOTYPE(usb, ifc);
__DECLARE_IS_IF_PROTOTYPE(sdio, ifc);
__DECLARE_IS_IF_PROTOTYPE(adc, ifc);
__DECLARE_IS_IF_PROTOTYPE(pcm, ifc);
__DECLARE_IS_IF_PROTOTYPE(clk, ifc);
__DECLARE_IS_IF_PROTOTYPE(uart, ifc);
__DECLARE_IS_IF_PROTOTYPE(plat, ifc);
uint8_t eeprom_if_gpio_cfg(struct list_head *item, unsigned int pin);
char *eeprom_if_spi_modalias(struct list_head *item);
int eeprom_if_spi_irq_gpio(struct list_head *item);
char *eeprom_if_i2c_modalias(struct list_head *item);
int eeprom_if_i2c_irq_gpio(struct list_head *item);
uint8_t eeprom_if_i2c_address(struct list_head *item);
#endif /* MANGOH_IOT_EEPROM_H */
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef MANGOH_IOT_EEPROM_1V0_H
#define MANGOH_IOT_EEPROM_1V0_H
typedef struct eeprom_if_reserved_ {
char reserved[63];
} __attribute__((packed)) eeprom_if_reserved;
typedef struct eeprom_if_gpio_1v0_ {
uint8_t cfg[4];
char reserved[59];
} __attribute__((packed)) eeprom_if_gpio_1v0;
typedef struct eeprom_if_i2c_1v0_ {
uint8_t address;
uint8_t irq_gpio;
char modalias[32];
char reserved[29];
} __attribute__((packed)) eeprom_if_i2c_1v0;
typedef struct eeprom_if_spi_1v0_ {
uint8_t irq_gpio;
char modalias[32];
char reserved[30];
} __attribute__((packed)) eeprom_if_spi_1v0;
typedef eeprom_if_reserved eeprom_if_usb_1v0;
typedef eeprom_if_reserved eeprom_if_sdio_1v0;
typedef eeprom_if_reserved eeprom_if_adc_1v0;
typedef eeprom_if_reserved eeprom_if_pcm_1v0;
typedef eeprom_if_reserved eeprom_if_clk_1v0;
typedef eeprom_if_reserved eeprom_if_uart_1v0;
typedef struct eeprom_if_plat_1v0_ {
uint8_t irq_gpio;
char modalias[32];
char reserved[30];
} __attribute__((packed)) eeprom_if_plat_1v0;
typedef struct eeprom_if_1v0_ {
uint8_t type;
union {
eeprom_if_gpio_1v0 gpio;
eeprom_if_i2c_1v0 i2c;
eeprom_if_spi_1v0 spi;
eeprom_if_sdio_1v0 sdio;
eeprom_if_usb_1v0 usb;
eeprom_if_adc_1v0 adc;
eeprom_if_pcm_1v0 pcm;
eeprom_if_clk_1v0 clk;
eeprom_if_uart_1v0 uart;
eeprom_if_plat_1v0 plat;
} ifc;
} __attribute__((packed)) eeprom_if_1v0;
#define EEPROM_1V0_INTERFACE_OFFSET 192
#endif /* MANGOH_IOT_EEPROM_1V0_H */
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef MANGOH_IOT_MANGOH_H
#define MANGOH_IOT_MANGOH_H
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/spi/spi.h>
typedef enum {
mangoh_bus_i2c,
mangoh_bus_spi,
mangoh_bus_uart,
mangoh_bus_sdio,
mangoh_bus_usb,
mangoh_bus_gpio,
mangoh_bus_pcm,
mangoh_bus_adc,
mangoh_bus_last,
} mangoh_bus_t;
struct mangoh_desc {
char *type;
int (*map)(struct platform_device *pdev);
int (*unmap)(struct platform_device *pdev);
};
extern struct mangoh_desc mangoh_green_desc;
extern struct platform_device mangoh_green;
#endif /* MANGOH_IOT_MANGOH_H */
sources:
{
mangoh_iot.c
green.c
eeprom.c
}
params:
{
model = "green"
}
/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
/*
* IoT expansion platform driver for Sierra Wireless MangOH board(s).
* Currently supporting only MangOH green platform.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include "mangoh.h"
static char *model = "green";
module_param(model, charp, S_IRUGO);
MODULE_PARM_DESC(model, "MangOH board model.");
static const struct platform_device_id mangoh_iot_ids[] = {
{"mangoh-green", (kernel_ulong_t)&mangoh_green_desc},
{},
};
MODULE_DEVICE_TABLE(platform, mangoh_iot_ids);
static int mangoh_iot_probe(struct platform_device *pdev)
{
struct mangoh_desc *desc;
desc = (struct mangoh_desc *)platform_get_device_id(pdev)->driver_data;
if (!desc || !desc->map)
return -ENODEV;
platform_set_drvdata(pdev, desc);
return desc->map(pdev);
}
static int mangoh_iot_remove(struct platform_device *pdev)
{
struct mangoh_desc *desc = platform_get_drvdata(pdev);
if (desc && desc->unmap)
desc->unmap(pdev);
/* desc will be freed with device removal, so we're done */
dev_info(&pdev->dev, "Removed.\n");
return 0;
}
static struct platform_driver mangoh_iot_driver = {
.probe = mangoh_iot_probe,
.remove = mangoh_iot_remove,
.driver = {
.name = "mangoh-iot",
.owner = THIS_MODULE,
.bus = &platform_bus_type,
},
.id_table = mangoh_iot_ids,
};
static int __init mangoh_iot_init(void)
{
struct platform_device *pdev;
if (!strcasecmp(model, "green"))
pdev = &mangoh_green;
else
pdev = NULL;
if (!pdev) {
pr_err("%s: unknown model 'mangoh-%s'.\n", __func__, model);
return -ENODEV;
}
platform_driver_register(&mangoh_iot_driver);
if (platform_device_register(pdev)) {
platform_driver_unregister(&mangoh_iot_driver);
return -ENODEV;
}
return 0;
}
static void __exit mangoh_iot_exit(void)
{
platform_device_unregister(&mangoh_green);
platform_driver_unregister(&mangoh_iot_driver);
}
module_init(mangoh_iot_init);
module_exit(mangoh_iot_exit);
MODULE_ALIAS("platform:mangoh-iot");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Sierra Wireless");
MODULE_DESCRIPTION("Linux driver for MangOH IoT expander");
MODULE_VERSION("0.1");
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