static int __devinit gpio_sw_probe(struct platform_device *dev) { struct gpio_sw *gpio; struct gpio_sw_platdata *pdata = dev->dev.platform_data; unsigned int irq_ctl; int ret; char io_area[16]; static script_item_value_type_e type; static script_item_u item; gpio = kzalloc(sizeof(struct gpio_sw), GFP_KERNEL); GPIO_SW_DEBUG("kzalloc ok !\n"); if (gpio == NULL) { dev_err(&dev->dev, "No memory for device\n"); return -ENOMEM; } platform_set_drvdata(dev, gpio); GPIO_SW_DEBUG("platform_set_drvdata ok !\n"); gpio->pdata = pdata; type = script_get_item("3g_gpio_para", pdata->name, &item); if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) { printk("script_get_item return type err\n"); return -EFAULT; } gpio->cdev.pio_hdle = item.gpio.gpio; if (0 != gpio_request_one(item.gpio.gpio, GPIOF_OUT_INIT_HIGH, NULL)) { printk("[gpio_para] gpio_request gpio:%d failed\n", item.gpio.gpio); return -EFAULT; } if (0 != sw_gpio_setall_range(&item.gpio, 1)) { printk(KERN_ERR "[gpio_para] gpio setall_range err!"); return -EFAULT; } GPIO_SW_DEBUG("pio_hdle is %x \n",gpio->cdev.pio_hdle); GPIO_SW_DEBUG("gpio_num = %s\n",pdata->name); GPIO_SW_DEBUG("pd->name = %s\n",gpio->pdata->name); gpio->cdev.port = item.gpio.port; gpio->cdev.port_num = item.gpio.port_num; gpio->cdev.mul_sel = item.gpio.mul_sel; gpio->cdev.pull = item.gpio.pull; gpio->cdev.drv_level = item.gpio.drv_level; gpio->cdev.data = item.gpio.data; gpio->cdev.irq_type = 0x0; sprintf(io_area,"P%c%d",gpio->cdev.port+'A'-1,gpio->cdev.port_num); GPIO_SW_DEBUG("io_area is %s \n",io_area); gpio->cdev.gpio_sw_cfg_set = gpio_sw_cfg_set; gpio->cdev.gpio_sw_pull_set = gpio_sw_pull_set; gpio->cdev.gpio_sw_data_set = gpio_sw_data_set; gpio->cdev.gpio_sw_drv_level_set = gpio_sw_drv_level_set; gpio->cdev.gpio_sw_cfg_get = gpio_sw_cfg_get; gpio->cdev.gpio_sw_pull_get = gpio_sw_pull_get; gpio->cdev.gpio_sw_data_get = gpio_sw_data_get; gpio->cdev.gpio_sw_drv_level_get = gpio_sw_drv_level_get; gpio->cdev.name = io_area; gpio->cdev.flags |= pdata->flags; if(gpio->cdev.mul_sel == 6) { if(gpio->cdev.port== 'H' - 'A' + 1) { if((gpio->cdev.port_num >= 0) && (gpio->cdev.port_num <= 21)) { irq_ctl = REG_RD(GPIO_TEST_BASE + 0x210); __raw_writel((1 << gpio->cdev.port_num) | irq_ctl, GPIO_TEST_BASE + 0x210); gpio->cdev.irq_num = gpio->cdev.port_num + 1; all_irq_enable = 1; } else { printk("[gpio]: this pin don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } } else if(gpio->cdev.port== 'I' - 'A' + 1) { if((gpio->cdev.port_num >= 10) && (gpio->cdev.port_num <= 19)) { irq_ctl = REG_RD(GPIO_TEST_BASE + 0x210); __raw_writel((1 << (gpio->cdev.port_num + 12)) | irq_ctl, GPIO_TEST_BASE + 0x210); gpio->cdev.irq_num = gpio->cdev.port_num + 12 + 1; all_irq_enable = 1; } else { printk("[gpio]: this pin don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } } else { printk("[gpio]: this area don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } } gpio->cdev.irq=all_irq_enable; ret = gpio_sw_classdev_register(&dev->dev, &gpio->cdev); GPIO_SW_DEBUG("gpio_sw_classdev_register ok !\n"); if (ret < 0) { dev_err(&dev->dev, "gpio_sw_classdev_register failed\n"); kfree(gpio); return ret; } GPIO_SW_DEBUG("pio_hdle is %x \n",gpio->cdev.pio_hdle); GPIO_SW_DEBUG("gpio_sw_classdev_register good !\n"); return 0; }
static int __devinit gpio_sw_probe(struct platform_device *dev) { struct gpio_sw *gpio; struct gpio_sw_platdata *pdata = dev->dev.platform_data; unsigned int irq_ctl; int ret; char io_area[16]; gpio = kzalloc(sizeof(struct gpio_sw), GFP_KERNEL); GPIO_SW_DEBUG("kzalloc ok !\n"); if (gpio == NULL) { dev_err(&dev->dev, "No memory for device\n"); return -ENOMEM; } platform_set_drvdata(dev, gpio); GPIO_SW_DEBUG("platform_set_drvdata ok !\n"); gpio->pdata = pdata; gpio->cdev.pio_hdle = gpio_request_ex("gpio_para", pdata->name); GPIO_SW_DEBUG("pio_hdle is %x \n",gpio->cdev.pio_hdle); GPIO_SW_DEBUG("gpio_num = %s\n",pdata->name); GPIO_SW_DEBUG("pd->name = %s\n",gpio->pdata->name); gpio->cdev.port = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,port_5 ); gpio->cdev.port_num = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,port_num_6 ); gpio->cdev.mul_sel = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,mul_sel_1 ); gpio->cdev.pull = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,pull_2 ); gpio->cdev.drv_level = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,drv_level_3 ); gpio->cdev.data = get_gpio_member_value(gpio->cdev.pio_hdle,pdata->name,data_4 ); gpio->cdev.irq_type = 0x0; sprintf(io_area,"P%c%d",gpio->cdev.port+'A'-1,gpio->cdev.port_num); GPIO_SW_DEBUG("io_area is %s \n",io_area); gpio->cdev.gpio_sw_cfg_set = gpio_sw_cfg_set; gpio->cdev.gpio_sw_pull_set = gpio_sw_pull_set; gpio->cdev.gpio_sw_data_set = gpio_sw_data_set; gpio->cdev.gpio_sw_drv_level_set = gpio_sw_drv_level_set; gpio->cdev.gpio_sw_cfg_get = gpio_sw_cfg_get; gpio->cdev.gpio_sw_pull_get = gpio_sw_pull_get; gpio->cdev.gpio_sw_data_get = gpio_sw_data_get; gpio->cdev.gpio_sw_drv_level_get = gpio_sw_drv_level_get; gpio->cdev.name = io_area; gpio->cdev.flags |= pdata->flags; if(gpio->cdev.mul_sel == 6){ if(gpio->cdev.port== 'H' - 'A' + 1){ if((gpio->cdev.port_num >= 0) && (gpio->cdev.port_num <= 21)){ irq_ctl = REG_RD(GPIO_TEST_BASE + 0x210); __raw_writel((1 << gpio->cdev.port_num) | irq_ctl, GPIO_TEST_BASE + 0x210); gpio->cdev.irq_num = gpio->cdev.port_num + 1; all_irq_enable = 1; }else{ printk("[gpio]: this pin don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } }else if(gpio->cdev.port== 'I' - 'A' + 1){ if((gpio->cdev.port_num >= 10) && (gpio->cdev.port_num <= 19)){ irq_ctl = REG_RD(GPIO_TEST_BASE + 0x210); __raw_writel((1 << (gpio->cdev.port_num + 12)) | irq_ctl, GPIO_TEST_BASE + 0x210); gpio->cdev.irq_num = gpio->cdev.port_num + 12 + 1; all_irq_enable = 1; }else{ printk("[gpio]: this pin don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } } else{ printk("[gpio]: this area don`t have EINT FUNCTION\n"); kfree(gpio); return 1; } } gpio->cdev.irq=all_irq_enable; ret = gpio_sw_classdev_register(&dev->dev, &gpio->cdev); GPIO_SW_DEBUG("gpio_sw_classdev_register ok !\n"); if (ret < 0) { dev_err(&dev->dev, "gpio_sw_classdev_register failed\n"); kfree(gpio); return ret; } GPIO_SW_DEBUG("pio_hdle is %x \n",gpio->cdev.pio_hdle); GPIO_SW_DEBUG("gpio_sw_classdev_register good !\n"); return 0; }