mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
soc: qcom: sdx_ext_ipc: Change GPIO configuration
Changing GPIO output value is not reflecting. Change GPIO pull up configuration from pull up to no pull to reflect state change. Change-Id: Iac636b9b601b9819ee7aac2118c1af3b0f864e86 Signed-off-by: Prasanna Kumar Thoorvas Samyrao Muralidharan <ptsm@codeaurora.org>
This commit is contained in:
parent
a72d52e9ec
commit
0106d8287c
1 changed files with 48 additions and 7 deletions
|
|
@ -14,6 +14,12 @@
|
|||
#include <linux/suspend.h>
|
||||
#include <soc/qcom/sb_notification.h>
|
||||
|
||||
#define GPIO_BASE 0xf100000
|
||||
#define GPIO_REG_OFFSET 0x1000
|
||||
#define GPIO_REG_SIZE 0x300000
|
||||
|
||||
#define E911_GPIO_NUMBER 45
|
||||
|
||||
#define STATUS_UP 1
|
||||
#define STATUS_DOWN 0
|
||||
|
||||
|
|
@ -49,6 +55,8 @@ struct gpio_cntrl {
|
|||
int status_irq;
|
||||
int wakeup_irq;
|
||||
int policy;
|
||||
unsigned int ipq807x_attach;
|
||||
void __iomem *gpio_base;
|
||||
struct device *dev;
|
||||
struct mutex policy_lock;
|
||||
struct mutex e911_lock;
|
||||
|
|
@ -114,15 +122,27 @@ static DEVICE_ATTR_RW(policy);
|
|||
static ssize_t e911_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int ret, state;
|
||||
int ret;
|
||||
u32 state;
|
||||
struct gpio_cntrl *mdm = dev_get_drvdata(dev);
|
||||
void __iomem *addr = NULL;
|
||||
|
||||
if (mdm->gpios[STATUS_OUT2] < 0)
|
||||
return -ENXIO;
|
||||
|
||||
mutex_lock(&mdm->e911_lock);
|
||||
state = gpio_get_value(mdm->gpios[STATUS_OUT2]);
|
||||
ret = scnprintf(buf, 2, "%d\n", state);
|
||||
|
||||
if (mdm->ipq807x_attach) {
|
||||
addr = mdm->gpio_base + GPIO_REG_OFFSET * E911_GPIO_NUMBER;
|
||||
state = readl_relaxed(addr);
|
||||
if (state == 0x3c7)
|
||||
ret = scnprintf(buf, 2, "1\n");
|
||||
else
|
||||
ret = scnprintf(buf, 2, "0\n");
|
||||
} else {
|
||||
state = gpio_get_value(mdm->gpios[STATUS_OUT2]);
|
||||
ret = scnprintf(buf, 2, "%d\n", state);
|
||||
}
|
||||
mutex_unlock(&mdm->e911_lock);
|
||||
|
||||
return ret;
|
||||
|
|
@ -132,6 +152,7 @@ static ssize_t e911_store(struct device *dev, struct device_attribute *attr,
|
|||
const char *buf, size_t count)
|
||||
{
|
||||
struct gpio_cntrl *mdm = dev_get_drvdata(dev);
|
||||
void __iomem *addr = NULL;
|
||||
int e911;
|
||||
|
||||
if (kstrtoint(buf, 0, &e911))
|
||||
|
|
@ -141,10 +162,19 @@ static ssize_t e911_store(struct device *dev, struct device_attribute *attr,
|
|||
return -ENXIO;
|
||||
|
||||
mutex_lock(&mdm->e911_lock);
|
||||
if (e911)
|
||||
gpio_set_value(mdm->gpios[STATUS_OUT2], 1);
|
||||
else
|
||||
gpio_set_value(mdm->gpios[STATUS_OUT2], 0);
|
||||
|
||||
if (mdm->ipq807x_attach) {
|
||||
addr = mdm->gpio_base + GPIO_REG_OFFSET * E911_GPIO_NUMBER;
|
||||
if (e911)
|
||||
writel_relaxed(0x3c7, addr);
|
||||
else
|
||||
writel_relaxed(0x4, addr);
|
||||
} else {
|
||||
if (e911)
|
||||
gpio_set_value(mdm->gpios[STATUS_OUT2], 1);
|
||||
else
|
||||
gpio_set_value(mdm->gpios[STATUS_OUT2], 0);
|
||||
}
|
||||
mutex_unlock(&mdm->e911_lock);
|
||||
|
||||
return count;
|
||||
|
|
@ -297,6 +327,7 @@ static int setup_ipc(struct gpio_cntrl *mdm)
|
|||
static int sdx_ext_ipc_panic(struct notifier_block *this,
|
||||
unsigned long event, void *ptr)
|
||||
{
|
||||
void __iomem *addr = NULL;
|
||||
struct gpio_cntrl *mdm = container_of(this,
|
||||
struct gpio_cntrl, panic_blk);
|
||||
|
||||
|
|
@ -323,6 +354,13 @@ static int sdx_ext_ipc_probe(struct platform_device *pdev)
|
|||
return -ENOMEM;
|
||||
|
||||
mdm->dev = &pdev->dev;
|
||||
|
||||
of_property_read_u32(node, "ipq807x_attach", &mdm->ipq807x_attach);
|
||||
if (mdm->ipq807x_attach) {
|
||||
dev_info(mdm->dev, "IPQ807x attach detected\n");
|
||||
mdm->gpio_base = ioremap(GPIO_BASE, GPIO_REG_SIZE);
|
||||
}
|
||||
|
||||
ret = setup_ipc(mdm);
|
||||
if (ret) {
|
||||
dev_err(mdm->dev, "Error setting up gpios\n");
|
||||
|
|
@ -426,6 +464,9 @@ static int sdx_ext_ipc_remove(struct platform_device *pdev)
|
|||
&mdm->panic_blk);
|
||||
remove_ipc(mdm);
|
||||
device_remove_file(mdm->dev, &dev_attr_policy);
|
||||
if (mdm->ipq807x_attach)
|
||||
iounmap(mdm->gpio_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue