Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338470
b: refs/heads/master
c: 72d4724
h: refs/heads/master
v: v3
  • Loading branch information
Jun Chen authored and Greg Kroah-Hartman committed Nov 26, 2012
1 parent 94a9aa6 commit 0971126
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d7ffb9329012a517575e4c4d49480b6ce0d1529e
refs/heads/master: 72d4724ea54c360115bca7979167850dfa37ec65
56 changes: 53 additions & 3 deletions trunk/drivers/tty/serial/ifx6x60.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <linux/pm_runtime.h>
#include <linux/spi/ifx_modem.h>
#include <linux/delay.h>
#include <linux/reboot.h>

#include "ifx6x60.h"

Expand All @@ -72,15 +73,44 @@
#define IFX_SPI_HEADER_0 (-1)
#define IFX_SPI_HEADER_F (-2)

#define PO_POST_DELAY 200
#define IFX_MDM_RST_PMU 4

/* forward reference */
static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev);
static int ifx_modem_reboot_callback(struct notifier_block *nfb,
unsigned long event, void *data);
static int ifx_modem_power_off(struct ifx_spi_device *ifx_dev);

/* local variables */
static int spi_bpw = 16; /* 8, 16 or 32 bit word length */
static struct tty_driver *tty_drv;
static struct ifx_spi_device *saved_ifx_dev;
static struct lock_class_key ifx_spi_key;

static struct notifier_block ifx_modem_reboot_notifier_block = {
.notifier_call = ifx_modem_reboot_callback,
};

static int ifx_modem_power_off(struct ifx_spi_device *ifx_dev)
{
gpio_set_value(IFX_MDM_RST_PMU, 1);
msleep(PO_POST_DELAY);

return 0;
}

static int ifx_modem_reboot_callback(struct notifier_block *nfb,
unsigned long event, void *data)
{
if (saved_ifx_dev)
ifx_modem_power_off(saved_ifx_dev);
else
pr_warn("no ifx modem active;\n");

return NOTIFY_OK;
}

/* GPIO/GPE settings */

/**
Expand Down Expand Up @@ -1287,6 +1317,9 @@ static int ifx_spi_spi_remove(struct spi_device *spi)

static void ifx_spi_spi_shutdown(struct spi_device *spi)
{
struct ifx_spi_device *ifx_dev = spi_get_drvdata(spi);

ifx_modem_power_off(ifx_dev);
}

/*
Expand Down Expand Up @@ -1422,7 +1455,9 @@ static void __exit ifx_spi_exit(void)
{
/* unregister */
tty_unregister_driver(tty_drv);
put_tty_driver(tty_drv);
spi_unregister_driver((void *)&ifx_spi_driver);
unregister_reboot_notifier(&ifx_modem_reboot_notifier_block);
}

/**
Expand Down Expand Up @@ -1457,16 +1492,31 @@ static int __init ifx_spi_init(void)
if (result) {
pr_err("%s: tty_register_driver failed(%d)",
DRVNAME, result);
put_tty_driver(tty_drv);
return result;
goto err_free_tty;
}

result = spi_register_driver((void *)&ifx_spi_driver);
if (result) {
pr_err("%s: spi_register_driver failed(%d)",
DRVNAME, result);
tty_unregister_driver(tty_drv);
goto err_unreg_tty;
}

result = register_reboot_notifier(&ifx_modem_reboot_notifier_block);
if (result) {
pr_err("%s: register ifx modem reboot notifier failed(%d)",
DRVNAME, result);
goto err_unreg_spi;
}

return 0;
err_unreg_spi:
spi_unregister_driver((void *)&ifx_spi_driver);
err_unreg_tty:
tty_unregister_driver(tty_drv);
err_free_tty:
put_tty_driver(tty_drv);

return result;
}

Expand Down

0 comments on commit 0971126

Please sign in to comment.