usb: tegra: configure current in ua
Rakesh Babu Bodla [Fri, 6 May 2016 10:43:25 +0000 (15:43 +0530)]
Allow the system to configure current in ua for
uniformity. Also modify the input to QC2.0 charger
through dt node in readable format.

Bug 200194931

Change-Id: Ic18e873f08ee50282e34f76e9536a0f46e2ae8e2
Signed-off-by: Rakesh Babu Bodla <rbodla@nvidia.com>
Reviewed-on: http://git-master/r/1142708
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>

Documentation/devicetree/bindings/usb/udc-tegra.txt
arch/arm/mach-tegra/board-ardbeg.c
drivers/usb/gadget/tegra_udc.c
drivers/usb/gadget/tegra_udc.h
drivers/usb/phy/tegra11x_usb_phy.c
include/dt-bindings/usb/tegra-usb.h [new file with mode: 0644]
include/linux/platform_data/tegra_usb.h

index b40ad89..1355eeb 100644 (file)
@@ -17,13 +17,13 @@ Optional properties:
        0 - if detection is through USB controller
        1 - if detection is through PMU extcon
        2 - if enable through sysfs interface.
-- nvidia,qc2-voltage: Specify the input voltage needed to support QC2.0 charger.
-       0 - if input voltage is 5V
-       1 - if input voltage is 9V
-       2 - if input voltage is 12V
-       3 - if input voltage is 20V
-- nvidia,qc2-current-limit-ma: Specify the QC2.0 charger current limit in milliamperes.
-- nvidia,dcp-current-limit-ma: If needs to overried standard DCP charger current limit (1.5A), specify the value in milliamperes.
+- nvidia,qc2-input-voltage: Specify the input voltage needed to support QC2.0 charger.
+       TEGRA_USB_QC2_5V - if input voltage is 5V
+       TEGRA_USB_QC2_9V - if input voltage is 9V
+       TEGRA_USB_QC2_12V - if input voltage is 12V
+       TEGRA_USB_QC2_20V - if input voltage is 20V
+- nvidia,qc2-current-limit-ua: Specify the QC2.0 charger current limit in microamperes.
+- nvidia,dcp-current-limit-ua: If needs to overried standard DCP charger current limit (1.5A), specify the value in microamperes.
 - nvidia,enable-xhci-host: Specify whether this port is taken by XUSB.
 - avdd_usb-supply: Specify the phandle of corresponding regulator device tree node.
 - avdd_pll_utmip-supply: Specify the phandle of corresponding regulator device tree node.
@@ -40,9 +40,9 @@ Example:
                nvidia,port-otg;
                nvidia,charging-supported;
                nvidia,enable-pmu-vbus-detection;
-               nvidia,qc2_input_voltage = <1>;
-               nvidia,qc2_current_limit_ma = <1200>;
-               nvidia,dcp_current_limit_ma = <1800>;
+               nvidia,qc2-input-voltage = <TEGRA_USB_QC2_9V>;
+               nvidia,qc2-current-limit-ua = <1200000>;
+               nvidia,dcp-current-limit-ua = <1800000>;
                avdd_usb-supply = <&ldousb_reg>;
                avdd_pll_utmip-supply = <&palmas_smps8>;
                usb_bat_chg-supply = <&battery_charger>;
index 7e525ad..2f75e7c 100644 (file)
@@ -573,14 +573,6 @@ static void ardbeg_usb_init(void)
                        board_info.board_id == BOARD_E1784 ||
                        board_info.board_id == BOARD_E1780) {
 
-                       /*
-                        * Set the maximum voltage that can be supplied
-                        * over USB vbus that the board supports if we use
-                        * a quick charge 2 wall charger.
-                        */
-                       tegra_udc_pdata.qc2_voltage = TEGRA_USB_QC2_9V;
-                       tegra_udc_pdata.u_data.dev.qc2_current_limit_ma = 1200;
-
                        /* charger needs to be set to 3A - h/w will do 2A */
                        tegra_udc_pdata.u_data.dev.dcp_current_limit_ma = 3000;
                }
index 1db15d4..1db419f 100644 (file)
@@ -2934,6 +2934,7 @@ static struct tegra_usb_platform_data *tegra_udc_dt_parse_pdata(
 {
        struct tegra_usb_platform_data *pdata;
        struct device_node *np = pdev->dev.of_node;
+       u32 current_ua;
 
        if (!np)
                return NULL;
@@ -2953,10 +2954,13 @@ static struct tegra_usb_platform_data *tegra_udc_dt_parse_pdata(
        pdata->u_data.dev.is_xhci =
                of_property_read_bool(np, "nvidia,enable-xhci-host");
 
-       of_property_read_u32(np, "nvidia,dcp-current-limit-ma",
-                               &pdata->u_data.dev.dcp_current_limit_ma);
-       of_property_read_u32(np, "nvidia,qc2-current-limit-ma",
-                               &pdata->u_data.dev.qc2_current_limit_ma);
+       of_property_read_u32(np, "nvidia,dcp-current-limit-ua",
+                               &current_ua);
+       pdata->u_data.dev.dcp_current_limit_ma = current_ua/1000;
+
+       of_property_read_u32(np, "nvidia,qc2-current-limit-ua",
+                               &current_ua);
+       pdata->u_data.dev.qc2_current_limit_ma = current_ua/1000;
        of_property_read_u32(np, "nvidia,qc2-input-voltage",
                                &pdata->qc2_voltage);
        of_property_read_u32(np, "nvidia,id-detection-type",
index 0e2888e..00ec983 100644 (file)
@@ -466,7 +466,7 @@ struct tegra_udc {
        enum tegra_connect_type connect_type;
        enum tegra_connect_type prev_connect_type;
        enum tegra_connect_type connect_type_lp0;
-       enum tegra_usb_qc2_voltage qc2_voltage;
+       u32 qc2_voltage;
        void __iomem *regs;
        size_t ep_qh_size;              /* size after alignment adjustment*/
        dma_addr_t ep_qh_dma;           /* dma address of QH */
index 28cd721..3b2e852 100644 (file)
@@ -32,6 +32,7 @@
 #include <mach/tegra_usb_pmc.h>
 #include <mach/tegra_usb_pad_ctrl.h>
 #include <linux/tegra_prod.h>
+#include <dt-bindings/usb/tegra-usb.h>
 
 #include "tegra_usb_phy.h"
 #include "../../../arch/arm/mach-tegra/gpio-names.h"
diff --git a/include/dt-bindings/usb/tegra-usb.h b/include/dt-bindings/usb/tegra-usb.h
new file mode 100644 (file)
index 0000000..221d28e
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2016, NVIDIA Corporation.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#ifndef _DT_BINDINGS_TEGRA_USB_H
+#define _DT_BINDINGS_TEGRA_USB_H
+
+#define TEGRA_USB_QC2_5V       (0)
+#define TEGRA_USB_QC2_9V       (1)
+#define TEGRA_USB_QC2_12V      (2)
+#define TEGRA_USB_QC2_20V      (3)
+
+#endif
index bb327e7..12ca8b9 100644 (file)
@@ -45,30 +45,6 @@ enum tegra_usb_id_detection {
 };
 
 /**
- * Set the maximum voltage that can be supplied
- * over USB vbus that the board supports if we use
- * a quick charge 2 wall charger.
- * a low value means longer charge time
- * a too high value will blow up the board.
- * if not sure what board supports use 5V.
- * Allowed values:
- *     TEGRA_USB_QC2_5V
- *     TEGRA_USB_QC2_9V
- *     TEGRA_USB_QC2_12V
- *     TEGRA_USB_QC2_20V (probably not safe)
- *
- * specify the maximum current that the internal charger
- * can draw from an external wall charger
- */
-enum tegra_usb_qc2_voltage {
-       TEGRA_USB_QC2_5V = 0,
-       TEGRA_USB_QC2_9V = 1,
-       TEGRA_USB_QC2_12V = 2,
-       TEGRA_USB_QC2_20V = 3,
-};
-
-
-/**
  * configuration structure for setting up utmi phy
  */
 struct tegra_utmi_config {
@@ -157,7 +133,7 @@ struct tegra_usb_platform_data {
        enum tegra_usb_id_detection id_det_type;
        enum tegra_usb_phy_interface phy_intf;
        enum tegra_usb_operation_mode op_mode;
-       enum tegra_usb_qc2_voltage qc2_voltage;
+       u32 qc2_voltage;
 
        union {
                struct tegra_usb_dev_mode_data dev;