This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TELIT HE910 Modem

Hi All,


I am currently working on Linux 2.6.37 Kernel Version and struggling on where to toggle my GPIO lines to Turn this HE910 Modem on. I am using cdc-acm driver. As a test I tried to turn the Modem on in a backlight driver which works fine and I can see my ttyACM ports in Logs. Now I want to turn this modem on but not sure which file it should turn on in. Is it the cdc-acm driver file I should turn this on or somewhere else. Do I need to have a specific file for the Telit Module not sure what should be done and is the right way to do it. Any suggestions would be great.


Many Thanks


Ali

  • Hi,
    I have already worked with telit modems, they have some POWER-ON and RESET sequences for their chips.
    So you may have to write character type kernel module driver with ioctl for user space access.
    You can also power-ON the modem through AT command set which they have given.

    You have to drive the GPIO to power-ON with recommended timings..
  • Hi Titus,


    Ok. Thanks for your reply. Where does this module need to reside. What is directory structure for this? Like cdc-acm driver is in location drivers/usb/class/cdc-acm, where does this module need to reside.

    Thanks.

    Ali

  • Why do you want to change the CDC ACM driver for powering ON the modem ?
    Just write the module driver to do that.
    Did you connect the Power-On and reset to pin GPIO ?
    Drive the required signals on GPIO for power ON and reset.
  • Hi Titus,

    I dont want to change it in the cdc-acm driver nor power it on there. I'll write a module to do it. Do you have an example?

    Regards

    Ali
  • Hi,
    I have written very simple module driver for power ON & resetting the modem while powering ON target board.
    Just it has GPIO initialization with ioctl fops (file operation structure) for user-space communication.
    I have to search that example code, if I found it, I will attach here.
  • Hi Titus,

    Thanks for that, I'll wait for it.

    Regards

    Ali
  • Hi Titus,


    I was just wanting to find out if you managed to find this code snippet. Also I want to know that once I have the ttyACM port open. How can we sent AT command in the driver code to the ttyACM port and wait for a reply. Any suggestion on this would be great.

    Thanks

    Ali

  • Hi Ali,

    I found that driver with its application.

    I have written that driver to enable the GPRS and for RESET, it will be controlled through C application which needs to be cross compiled.

    Here I have attached the gpio driver and application.

    Just you build this driver and cross compile application, you should do GPIO initialization as per your board/requirement & modify the driver since its developed

    for older kernel.

    GPIO DRIVER:

    /* Include linux kernel header files */
    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/fs.h>
    #include <linux/cdev.h>
    #include <asm/uaccess.h>
    #include <linux/ioctl.h>
    #include <linux/device.h>
    
    #include <asm/gpio.h>
    
    MODULE_LICENSE("GPL");
    MODULE_AUTHOR("Titusrathinaraj Stalin");
    
    
    /* Global structre to access the gpio info */
    struct hhtp_ctrl {
        int num;        /* GPIO pin number */
        int value;      /* value on the GPIO pin */
    };
    
    /* user 'G' as magic number G=0x47 */
    #define USER_GPIO_MAGIC 'G'
    
    /* gpio read ioctl */
    #define USER_GPIO_READ 0x4700
    
    /* gpio write ioctl */
    #define USER_GPIO_WRITE 0x4701
    
    /* max number of ioctl's */
    #define USER_GPIO_MAXNR 1
    #define GPRSSTATUS 97    //GPIO no for GPRS status

    #define GPRSRCTL 96    //GPIO no for GPRS control /* local functions */ static int gpio_open (struct inode *inode, struct file *filp); static int gpio_release (struct inode *inode, struct file *filp); static int gpio_ioctl (struct inode *inode, struct file *flip, unsigned int cmd, unsigned long args); static int gpio_get_value(int num); static int gpio_set_value(int num, int val); int gpio_init_module(void); void gpio_cleanup_module(void); static int major; static struct class *class_gpio; static struct device *dev_gpio; /* declare file operation structure */ static struct file_operations gpio_fops = { .owner = THIS_MODULE, .open = gpio_open, .ioctl = gpio_ioctl, .release = gpio_release, }; /****************************************************************************** * gpio_get_value - This function returns the value of gpio pin number. *****************************************************************************/ static int gpio_get_value (int num) { int val; /* get the value */ val = gpio_get_value(num); printk(KERN_WARNING "val = %d\n", val); /* free gpio resources */ gpio_free(num); return val; } /****************************************************************************** * gpio_set_value - This function sets the value of gpio pin number. *****************************************************************************/ static int gpio_set_value (int num, int val) { /* set the value */ gpio_set_value(num, val); /* free the resources */ gpio_free(num); return 0; } /****************************************************************************** * gpio_ioctl - function to implement the GPIO ioctl's *****************************************************************************/ static int gpio_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long args) { void __user *argp = (void __user *) args; struct gpio gpio; if (_IOC_TYPE(cmd) != USER_GPIO_MAGIC) { return -ENOTTY; } if (_IOC_NR(cmd) > USER_GPIO_MAXNR) { return -ENOTTY; } switch (cmd) { case USER_GPIO_READ: if (copy_from_user(&gpio, argp, sizeof(struct gpio))) return -EFAULT; gpio.value = gpio_get_value(gpio.num); if (copy_to_user(argp, &gpio, sizeof(struct gpio))) return -EFAULT; break; case USER_GPIO_WRITE: if (copy_from_user(&gpio, argp, sizeof(struct gpio))) return -EFAULT; gpio_set_value(gpio.num, gpio.value); break; default: return -ENOTTY; break; } return 0; } /****************************************************************************** * gpio_open - do nothing *****************************************************************************/ void hhtp_gpio_init(void) { unsigned int *PINMUX0 = PINMUX0 = ioremap(0x01c40000,4); unsigned int status,control; status = gpio_request(GPRSSTATUS, "gpio"); status = gpio_request(GPRSRCTL, "gpio"); control = *PINMUX0; control &= 0xffff80ff ; /* bit10 > 0 GIO88 & GIO89, bit11, bit12, bit13 */ *PINMUX0 = control; gpio_direction_output(GPRSSTATUS,0); // GPRS Power control gpio_direction_output(GPRSRCTL, 1); // GPRS reset control } /****************************************************************************** * gpio_open - do nothing *****************************************************************************/ static int gpio_open (struct inode *inode, struct file *filp) { return 0; } /****************************************************************************** * gpio_release - do nothing *****************************************************************************/ static int gpio_release (struct inode *inode, struct file *filp) { return 0; } /***************************************************************************** * gpio_init_module - initialise user gpio module ****************************************************************************/ int gpio_init_module () { unsigned int *PINMUX1 = PINMUX1 = ioremap(0x01c40004,4); unsigned int *PINMUX0 = PINMUX0 = ioremap(0x01c40000,4); unsigned int status,control; *PINMUX1 = 0x00105555; status = gpio_request(GPRSSTATUS, "gpio"); status = gpio_request(GPRSRCTL, "gpio"); control = *PINMUX0; control &= 0xffff80ff ; /* bit10 > 0 GIO88 & GIO89, bit11, bit12, bit13 */ *PINMUX0 = control; gpio_direction_output(GPRSSTATUS,0); // GPRS Power control gpio_direction_output(GPRSRCTL, 1); // GPRS reset control void *ptr_err; if ((major = register_chrdev(0, "gpio_driver", &gpio_fops)) < 0) return major; class_gpio = class_create(THIS_MODULE, "gpio_driver"); if (IS_ERR(ptr_err = class_gpio)) goto err2; dev_gpio = device_create(class_gpio, NULL, MKDEV(major, 0), NULL, "gpio_driver"); if (IS_ERR(ptr_err = dev_gpio)) goto err; printk(KERN_ALERT "gpio device is inserted sucessfully...\n"); return 0; err: class_destroy(class_gpio); err2: unregister_chrdev(major, "gpio_driver"); return PTR_ERR(ptr_err); } /***************************************************************************** * gpio_init_cleanup - cleanup user gpio module ****************************************************************************/ void gpio_cleanup_module () { device_destroy(class_gpio, MKDEV(major, 0)); class_destroy(class_gpio); unregister_chrdev(major, "gpio_driver"); printk(KERN_ALERT "gpio device is ejected sucessfully...\n"); } /* Register driver to the kernel */ module_init(gpio_init_module); module_exit(gpio_cleanup_module);

    GPIO CONTROL APPLICATION:

     

    /* Include the standard linux header files */
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <stdlib.h>
    #include <string.h>
    
    /* Global structre to access the gpio info */
    struct hhtp_ctrl {
        int num;        /* GPIO pin number */
        int value;      /* value on the GPIO pin */
    };
    /* gpio read ioctl */
    #define USER_GPIO_READ 0x4700
    /* gpio write ioctl */
    #define USER_GPIO_WRITE 0x4701
    #define WRI_REG(reg)    (*(int *__iomem) IO_ADDRESS(reg))
    
    #define GPRSSTATUS 97	//GPIO no for GPRS status
    
    #define GPRSRCTL 96 //GPIO no for GPRS control
    #define LOW 0 #define HIGH 1 /***************************************************************************** * gpio_read - function to read gpio pin ****************************************************************************/ static int gpio_read (int num) { struct hhtp_ctrl gpio; int fd; fd = open("gpio_driver", O_RDWR); if (fd < 0) { printf("Failed to open device\n"); return 1; } gpio.num = num; if (ioctl(fd, USER_GPIO_READ, &gpio) < 0) { printf("Failed to read gpio%d\n", num); return -1; } close(fd); return gpio.value; } /****************************************************************************** * gpio_write - function to write on gpio pin *****************************************************************************/ static int gpio_write (int num, int val) { struct hhtp_ctrl gpio; int fd; fd = open("gpio_driver", O_RDWR); if (fd < 0) { printf("Failed to open device\n"); return 1; } gpio.num = num; gpio.value = val; if (ioctl(fd, USER_GPIO_WRITE, &gpio) < 0) { printf("Failed to read gpio%d\n", num); return -1; } close(fd); return 1; } /***************************************************************************** * perp_ctrl - function to control the following peripherals. This function * takes int as input parameter and returns 1 during success or returns -1 during * error. Its also returns error if invalid input command received. ****************************************************************************/ int perp_ctrl(int cmd) { switch(cmd) { case GPRS_ON_OFF: { if(gpio_write (GPRSPCTL, LOW)) // GPRS ON & OFF { sleep(1); if(gpio_write (GPRSPCTL, HIGH)) return 0; } else return -1; } case GPRS_RESET: { if(gpio_write (GPRSRCTL, LOW)) /* GPRS Reset */ { usleep(1000); if(gpio_write (GPRSRCTL, HIGH)) return 0; } else return -1; } default: return -1; } } int main (void) { int opt; while(1) { printf("Enter the option\n"); printf("1. GPRS ON/OFF\n"); printf("2. GPRS Reset\n"); printf("0. Exit\n"); scanf("%d",&opt); if(opt == 1) perp_ctrl(GPRS_ON_OFF); if(opt == 2) perp_ctrl(GPRS_RESET); if(opt == 0) return 0; } return 0; }

  • Hi Titus,

    Thanks for this. Will let you know the outcome.

    Regards

    Ali

  • hi,
    Have you done that?
  • hello,
    I am a graduate student in university working with a custom board based on DM8168. Now I have a telit modem connected to my board through USB protocal. And I can see it is recognized by my linux system after insmod the cdc-acm.ko module.
    And now, someone tell me to use "AT" commands, and someone tell me to use pppd, then I see the post here posted the application. Be as a newbie, I am wandering what to do?
    Can you give a help?
  • Dear Fire Lord,

    Typically, USB modem will detect as CD then we need to convert into USB modem.

    Method 1) You can install the "wvdial" package into your filesystem to connect the internet on your board via USB modem (Telit)

    wvdial would detect the USB modem (it will convert to modem by default) and will connect to internet via pppd.

    Method 2) For this, you have to convert the USB CD device to USB modem by using the "usb-modeswitch" command in linux.
    After that, you can use "pppd" command to connect into internet.

    You have to cross compile the "usb-modeswitch" and "wvdial" package to use on your target board.
    Please use google for how to use the "usb-modeswitch" and "wvidal" command.

    Please refer to the following pppd scripts used to connect to internet.
    e2e.ti.com/.../1133784
  • hello,
    In the earlier post, I saw you post the code about gpio driver and gpio application. what's the relation between the code and the two ways you suggested?

  • Dear Fire Lord,
    That driver is used to up the modem (enabling the Modem and wakeup from reset)
    If you refer the Modem data sheet, you could see information about to enable the modem.
    POWER ON pin, RESET pin etc.,

    After the modem powered ON and ready for communication, now you need to get the IP address (internet access), for that you need pppd and wvdial.
  • hello,

    Titusrathinaraj Stalin said:

    That driver is used to up the modem (enabling the Modem and wakeup from reset)

    After the modem powered ON and ready for communication, now you need to get the IP address (internet access), for that you need pppd and wvdial.

    So if I can see the module in the boot log which means the modem has been wakeup? Even I saw the module with the help of USB protocal?

  • I'm not getting your problem.
    I've written the module driver for my modem to enable it (followed the steps from modem data sheet on how to power ON the modem and wakeup)

    They have given some sequence to power ON, so I have connect a GPIO to POWER ON pin of modem and did the POWER ON sequence on the GPIO pin (in module driver) to power ON the modem.
  • Dear Fire Lord,

    Typically, USB modem will detect as CD then we need to convert into USB modem.

    Method 1) You can install the "wvdial" package into your filesystem to connect the internet on your board via USB modem (Telit)

    wvdial would detect the USB modem (it will convert to modem by default) and will connect to internet via pppd.

    Method 2) For this, you have to convert the USB CD device to USB modem by using the "usb-modeswitch" command in linux.
    After that, you can use "pppd" command to connect into internet.

    You have to cross compile the "usb-modeswitch" and "wvdial" package to use on your target board.
    Please use google for how to use the "usb-modeswitch" and "wvidal" command.

    Hello,

    I did what you told me about the package called 'wvdial'. I have cross-compile and put it into my target board. But when I want to use this tool, comes up the following problem. 

    I have tried some commands to see the USB Modem. You can see the Modem using the command as "lsusb". But the command "wvdialconf" can not find the Modem. You told me that the wvdial package would convert usb CD to modem defaultly. So what should I do now? Need your help.

  • Have you enabled the USB modem driver support in your linux kernel ?

    Can you post the log when you connect the USB modem or linux complete bootup log ?