RK3288如何开机GPIO为高或者为低

来源:互联网 发布:pc端软件界面设计 编辑:程序博客网 时间:2024/05/16 08:29

1,修改/kernel/arch/arm/boot/dts/rk3288-box.dts

[csharp] view plain copy
  1. usb_control {  
  2.         compatible = "rockchip,rk3288-usb-control";  
  3.   
  4.         host_drv_gpio = <&gpio0 GPIO_B6 GPIO_ACTIVE_LOW>;//modify by jiangdou  
  5.         otg_drv_gpio = <&gpio0 GPIO_B4 GPIO_ACTIVE_LOW>;  
  6. ++      3G_VCC_33_POWER = <&gpio7 GPIO_A5 GPIO_ACTIVE_HIGH>;//modify by jiangdou for 3G_POWER  

2,修改/kernel/drivers/usb/dwc_otg_310/usbdev_rk32.c
[csharp] view plain copy
  1. ++#define INVALID_GPIO  -1 //add for 3G_power  by jiangdou  
  2. ++int power_3g_en = INVALID_GPIO;//add for 3G_power  by jiangdou  
  3.   
  4. static int rk_usb_control_probe(struct platform_device *pdev)  
  5. {  
  6.     int gpio, err;  
  7.     struct device_node *np = pdev->dev.of_node;  
  8.     int ret = 0;  
  9.   
  10.     control_usb =  
  11.         devm_kzalloc(&pdev->dev, sizeof(*control_usb), GFP_KERNEL);  
  12.     if (!control_usb) {  
  13.         dev_err(&pdev->dev, "unable to alloc memory for control usb\n");  
  14.         ret = -ENOMEM;  
  15.         goto out;  
  16.     }  
  17.   
  18.     control_usb->chip_id = RK3288_USB_CTLR;  
  19.     control_usb->remote_wakeup = of_property_read_bool(np,  
  20.                                "rockchip,remote_wakeup");  
  21.     control_usb->usb_irq_wakeup = of_property_read_bool(np,  
  22.                                 "rockchip,usb_irq_wakeup");  
  23.   
  24.     INIT_DELAYED_WORK(&control_usb->usb_charger_det_work,  
  25.               usb_battery_charger_detect_work);  
  26.   
  27.     control_usb->host_gpios =  
  28.         devm_kzalloc(&pdev->dev, sizeof(struct gpio), GFP_KERNEL);  
  29.     if (!control_usb->host_gpios) {  
  30.         dev_err(&pdev->dev, "unable to alloc memory for host_gpios\n");  
  31.         ret = -ENOMEM;  
  32.         goto out;  
  33.     }  
  34. ++/*------------------------------我是分割线----------------------------------*/  
  35. ++//add for 3G_power  by jiangdou    start  
  36. ++  power_3g_en = of_get_named_gpio(np, "3G_VCC_33_POWER", 0);  
  37. ++  if (!gpio_is_valid(power_3g_en)) {  
  38. ++      dev_err(&pdev->dev, "invalid host gpio%d\n", power_3g_en);  
  39. ++  } else {  
  40. ++      err = devm_gpio_request(&pdev->dev, power_3g_en, "3G_VCC_33_POWER");  
  41. ++      if (err) {  
  42. ++          dev_err(&pdev->dev,  
  43. ++              "failed to request GPIO%d for host_drv\n",  
  44. ++              power_3g_en);  
  45. ++          ret = err;  
  46. ++          //goto out;  
  47. ++      }  
  48. ++      gpio_direction_output(power_3g_en, 1);  
  49. ++  }  
  50. ++    
  51. ++//add for 3G_power  by jiangdou    end  
  52. ++/*------------------------------我是分割线----------------------------------*/  
  53.     gpio = of_get_named_gpio(np, "host_drv_gpio", 0); 
0 0