From 151bc231e803570689dfcc7b51edfe01a64d432a Mon Sep 17 00:00:00 2001 From: Rakesh Goyal Date: Mon, 7 Nov 2011 17:25:56 +0530 Subject: 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 Tested-by: Varun Colbert Rebase-Id: R74ce3100c395b696c347fce4b4c9f5913aae3717 --- drivers/nfc/pn544.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'drivers/nfc') 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 */ -- cgit v1.2.3