diff options
author | Rakesh Goyal <rgoyal@nvidia.com> | 2011-11-07 17:25:56 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2012-03-23 18:52:45 -0700 |
commit | becbae0b0b22931b6cfc646a98898bba5f8d5507 (patch) | |
tree | de99fdbed4f50262097f81899bea532f58c151cf /drivers/nfc/pn544.c | |
parent | cc0232acbbd2dba0af4a791b4d21e2d1d8fccb06 (diff) |
nfc: control firmware download and nfc_en
control firmware download and VEN using gpio
Bug 846684
Bug 873017
Change-Id: I58391ac60e1b9cf440a186c155f993c9293f8223
Reviewed-on: http://git-master/r/62702
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Rebase-Id: R74ce3100c395b696c347fce4b4c9f5913aae3717
Diffstat (limited to 'drivers/nfc/pn544.c')
-rw-r--r-- | drivers/nfc/pn544.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/nfc/pn544.c b/drivers/nfc/pn544.c index c895dc332fe9..97a1f6b869f0 100644 --- a/drivers/nfc/pn544.c +++ b/drivers/nfc/pn544.c @@ -172,11 +172,10 @@ static int pn544_dev_open(struct inode *inode, struct file *filp) return 0; } -static int pn544_dev_ioctl(struct file *filp, unsigned cmd, +static long pn544_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct pn544_dev *pn544_dev = filp->private_data; - int ret=0; switch (cmd) { case PN544_SET_PWR: @@ -184,38 +183,28 @@ static int pn544_dev_ioctl(struct file *filp, unsigned cmd, /* power on with firmware download (requires hw reset) */ pr_info("%s power on with firmware\n", __func__); + gpio_set_value(pn544_dev->ven_gpio, 1); + msleep(20); if (pn544_dev->firm_gpio) gpio_set_value(pn544_dev->firm_gpio, 1); - msleep(10); - ret = gpio_direction_output(pn544_dev->ven_gpio, 0); - if (ret < 0) { - pr_err("%s : could not set it to 0\n", __func__); - } + msleep(20); + gpio_set_value(pn544_dev->ven_gpio, 0); msleep(100); - ret = gpio_direction_input(pn544_dev->ven_gpio); - if (ret < 0) { - pr_err("%s : could not set in input direction\n", __func__); - } - msleep(10); + gpio_set_value(pn544_dev->ven_gpio, 1); + msleep(20); } else if (arg == 1) { /* power on */ pr_info("%s power on\n", __func__); if (pn544_dev->firm_gpio) gpio_set_value(pn544_dev->firm_gpio, 0); - ret = gpio_direction_input(pn544_dev->ven_gpio); - if (ret < 0) { - pr_err("%s : could not set in input direction\n", __func__); - } - msleep(20); + gpio_set_value(pn544_dev->ven_gpio, 1); + msleep(100); } else if (arg == 0) { /* power off */ pr_info("%s power off\n", __func__); if (pn544_dev->firm_gpio) gpio_set_value(pn544_dev->firm_gpio, 0); - ret = gpio_direction_output(pn544_dev->ven_gpio, 0); - if (ret < 0) { - pr_err("%s : could not set it to 0\n", __func__); - } + gpio_set_value(pn544_dev->ven_gpio, 0); msleep(100); } else { pr_err("%s bad arg %lu\n", __func__, arg); @@ -283,14 +272,23 @@ static int pn544_probe(struct i2c_client *client, pn544_dev->firm_gpio = platform_data->firm_gpio; pn544_dev->client = client; - ret = gpio_direction_output(platform_data->ven_gpio, 0); + ret = gpio_direction_input(pn544_dev->irq_gpio); if (ret < 0) { - pr_err("%s : could not set it to 0\n", __func__); + pr_err("%s :not able to set irq_gpio as input\n", __func__); + goto err_ven; } - msleep(100); - ret = gpio_direction_input(platform_data->ven_gpio); + ret = gpio_direction_output(pn544_dev->ven_gpio, 0); if (ret < 0) { - pr_err("%s : could not set in input direction\n", __func__); + pr_err("%s : not able to set ven_gpio as output\n", __func__); + goto err_firm; + } + if (platform_data->firm_gpio) { + ret = gpio_direction_output(pn544_dev->firm_gpio, 0); + if (ret < 0) { + pr_err("%s : not able to set firm_gpio as output\n", + __func__); + goto err_exit; + } } /* init mutex and queues */ |