serial: ifx6x60: Add module parameters to manage the modem status through sysfs.
PATCH 1/1 serial: ifx6x60: Add module parameters to manage the modem status through sysfs.
The Medfield Platform implements a recovery procedure consisting in an escalation from simple and light recovery procedures to stronger ones with increased visibility and impact to end-user.After platform find some problem from Modem,such as no response, platform will try do modem warm reset.If several tries failed, platform will try to do modem cold boot procedure.For Modem Cold Boot, AP is responsible to generate blob (binary object containing PIN code and other necessary information). Blob is stored in AP volatile memory. AP decides to read PIN code from cache instead of prompting end-user, and sends it to modem as if end-user had entered it.
This patch add module parameters to manage the modem status through sysfs. Reset_modem can be read and write by user space.When read the reset_modem,user space will get the mdm_reset_state which used to avoid to run twice at once.When set the reset_modem to IFX_COLD_RESET_REQ,modem will do cold reset, other val value will trigger modem reset.
Hangup_reasons used to give one interface to user space to know and clear the modem reset reasons. Now there are four reasons:SPI timeout, modem initiative reset,modem coredump,spi tranfer error.
--- drivers/tty/serial/Kconfig | 2 +- drivers/tty/serial/ifx6x60.c | 194 +++++++++++++++++++++++++++++++++++++++++- drivers/tty/serial/ifx6x60.h | 8 ++ 3 files changed, 202 insertions(+), 2 deletions(-)
drivers/tty/serial/Kconfig +1 -1
@@ -1323,7 +1323,7 @@ config SERIAL_ALTERA_UART_CONSOLE config SERIAL_IFX6X60 tristate "SPI protocol driver for Infineon 6x60 modem (EXPERIMENTAL)" - depends on GPIOLIB && SPI + depends on GPIOLIB && SPI && X86_INTEL_MID && INTEL_SCU_IPC help Support for the IFX6x60 modem devices on Intel MID platforms.
drivers/tty/serial/ifx6x60.c +193 -1
236 lines not on this page · raw message
drivers/tty/serial/ifx6x60.h +8 -0
@@ -66,6 +66,13 @@#define IFX_SPI_POWER_DATA_PENDING 1#define IFX_SPI_POWER_SRDY 2 + +/* reasons for hanging up */ +#define HU_TIMEOUT 1/* spi timer out */ +#define HU_RESET 2/* modem initiative reset */ +#define HU_COREDUMP 4/* modem crash coredump */ +#define HU_RORTUR 8/* spi transfer error:ROR or TUR */ +struct ifx_spi_device {/* Our SPI device */ struct spi_device *spi_dev;
@@ -120,6 +127,7 @@ struct ifx_spi_device {/* modem reset */ unsigned long mdm_reset_state; +unsigned long hangup_reasons;#define MR_START 0#define MR_INPROGRESS 1#define MR_COMPLETE 2
Signature · 1 line
1.7.4.1
drivers/tty/serial/ifx6x60.c static void ifx_spi_timeout(unsigned long arg) · line 283
Quoted 3 lines
drivers/tty/serial/ifx6x60.c +1
-0dev_warn (&ifx_dev->spi_dev->dev,"*** SPI Timeout ***" ); + saved_ifx_dev->hangup_reasons |=HU_TIMEOUT ;ifx_spi_ttyhangup (ifx_dev);
This one should be using ifx_dev->hangup_reasons |=
this part of the code is clean for multiple devices so the ifx_dev pointer should be used (it will always be the same as saved_ifx_dev currently so it's just a tidy up)
Quoted 18 lines
drivers/tty/serial/ifx6x60.c +18
-0+/** +* reset_modem - modem reset command function +* @val: a reference to the string where the modem reset query is given +* @kp: an unused reference to the kernel parameter +*/ + +static int reset_modem (const char *val,const struct kernel_param *kp) +{ +unsigned long reset_request; +int err =0 ; + +u16 addr =V1P35CNT_W ; +u8 data, def_value; + +if (kstrtoul (val,10 , &reset_request) <0 ) +return -EINVAL ; + +if (!saved_ifx_dev) {
drivers/tty/serial/ifx6x60.c static int __init ifx_spi_init(void) · line 1491
Quoted 10 lines
drivers/tty/serial/ifx6x60.c +10
-0+dev_dbg (&saved_ifx_dev->spi_dev->dev, +"%s is called before probe\n" , __func__); +return -ENODEV ; + } + +dev_dbg (&saved_ifx_dev->spi_dev->dev, +"%s requested !\n" , __func__); + +if (test_and_set_bit (MR_START , &saved_ifx_dev->mdm_reset_state)) + goto out;
This case returns 0 - rather than an error like -EBUSY - is that intentional ?
Otherwise
and the two points noted can be fixed up with a later patch IMHO.
Chen, Jun D
Acked-by Alan CoxHi,Alan,
Thank for your suggestion for two point, I have updated the patch in other email.
-----Original Message-----
From: Alan Cox [mailto:[email protected]]
Sent: Tuesday, November 06, 2012 5:46 PM
To: Chen, Jun D
Cc: Alan Cox; serial; Gorby, Russ; Bi, Chao; Liu, Chuansheng
Subject: Re: [PATCH] serial: ifx6x60: Add module parameters to manage the modem status through sysfs.
drivers/tty/serial/ifx6x60.c static void ifx_spi_timeout(unsigned long arg) · line 283
Quoted 3 lines
drivers/tty/serial/ifx6x60.c +1
-0dev_warn (&ifx_dev->spi_dev->dev,"*** SPI Timeout ***" ); + saved_ifx_dev->hangup_reasons |=HU_TIMEOUT ;ifx_spi_ttyhangup (ifx_dev);
This one should be using ifx_dev->hangup_reasons |=
this part of the code is clean for multiple devices so the ifx_dev pointer should be used (it will always be the same as saved_ifx_dev currently so it's just a tidy up)
Quoted 18 lines
drivers/tty/serial/ifx6x60.c +18
-0+/** +* reset_modem - modem reset command function +* @val: a reference to the string where the modem reset query is +given +* @kp: an unused reference to the kernel parameter */ + +static int reset_modem (const char *val,const struct kernel_param +*kp) { +unsigned long reset_request; +int err =0 ; + +u16 addr =V1P35CNT_W ; +u8 data, def_value; + +if (kstrtoul (val,10 , &reset_request) <0 ) +return -EINVAL ; + +if (!saved_ifx_dev) {
drivers/tty/serial/ifx6x60.c static int __init ifx_spi_init(void) · line 1491
Quoted 10 lines
drivers/tty/serial/ifx6x60.c +10
-0+dev_dbg (&saved_ifx_dev->spi_dev->dev, +"%s is called before probe\n" , __func__); +return -ENODEV ; + } + +dev_dbg (&saved_ifx_dev->spi_dev->dev, +"%s requested !\n" , __func__); + +if (test_and_set_bit (MR_START , &saved_ifx_dev->mdm_reset_state)) + goto out;
This case returns 0 - rather than an error like -EBUSY - is that intentional ?
Otherwise
and the two points noted can be fixed up with a later patch IMHO.