[PATCH 8/9] extcon: max8997: Set default UART/USB path on probe

2013-02-13 Thread Chanwoo Choi
This patch set default H/W line path according to platfomr data.
The MAX8997 MUIC device can possibly set UART/USB or UART_AUX
/USB_AUX to internal H/W line path of MUIC device. Namely, only
one H/W line is used for two operation.

For example,
if H/W line path of MAX8997 device set UART/USB, micro usb cable
is connected to AP(Application Processor) and if H/W line path
set UART_AUX/USB_AUX, micro usb cable is connected to CP(Coprocessor).

Signed-off-by: Chanwoo Choi 
Signed-off-by: Myungjoo Ham 
---
 drivers/extcon/extcon-max8997.c | 28 ++--
 include/linux/mfd/max8997.h |  7 +++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 35338a0..349f65f 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -127,6 +127,13 @@ struct max8997_muic_info {
 
struct max8997_muic_platform_data *muic_pdata;
enum max8997_muic_charger_type pre_charger_type;
+
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   int path_usb;
+   int path_uart;
 };
 
 enum {
@@ -322,7 +329,7 @@ static int max8997_muic_handle_usb(struct max8997_muic_info 
*info,
int ret = 0;
 
if (usb_type == MAX8997_USB_HOST) {
-   ret = max8997_muic_set_path(info, CONTROL1_SW_USB, attached);
+   ret = max8997_muic_set_path(info, info->path_usb, attached);
if (ret < 0) {
dev_err(info->dev, "failed to update muic register\n");
return ret;
@@ -378,7 +385,7 @@ static int max8997_muic_handle_jig_uart(struct 
max8997_muic_info *info,
int ret = 0;
 
/* switch to UART */
-   ret = max8997_muic_set_path(info, CONTROL1_SW_UART, attached);
+   ret = max8997_muic_set_path(info, info->path_uart, attached);
if (ret) {
dev_err(info->dev, "failed to update muic register\n");
return -EINVAL;
@@ -694,6 +701,23 @@ static int max8997_muic_probe(struct platform_device *pdev)
}
}
 
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   if (pdata->muic_pdata->path_uart)
+   info->path_uart = pdata->muic_pdata->path_uart;
+   else
+   info->path_uart = CONTROL1_SW_UART;
+
+   if (pdata->muic_pdata->path_usb)
+   info->path_usb = pdata->muic_pdata->path_usb;
+   else
+   info->path_usb = CONTROL1_SW_USB;
+
+   /* Set initial path for UART */
+max8997_muic_set_path(info, info->path_uart, true);
+
/* Set ADC debounce time */
max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
 
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index 65f8d6a..2d2d67b 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -92,6 +92,13 @@ struct max8997_muic_reg_data {
 struct max8997_muic_platform_data {
struct max8997_muic_reg_data *init_data;
int num_init_data;
+
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   int path_usb;
+   int path_uart;
 };
 
 enum max8997_haptic_motor_type {
-- 
1.8.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/9] extcon: max8997: Set default UART/USB path on probe

2013-02-13 Thread Chanwoo Choi
This patch set default H/W line path according to platfomr data.
The MAX8997 MUIC device can possibly set UART/USB or UART_AUX
/USB_AUX to internal H/W line path of MUIC device. Namely, only
one H/W line is used for two operation.

For example,
if H/W line path of MAX8997 device set UART/USB, micro usb cable
is connected to AP(Application Processor) and if H/W line path
set UART_AUX/USB_AUX, micro usb cable is connected to CP(Coprocessor).

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Myungjoo Ham myungjoo@samsung.com
---
 drivers/extcon/extcon-max8997.c | 28 ++--
 include/linux/mfd/max8997.h |  7 +++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 35338a0..349f65f 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -127,6 +127,13 @@ struct max8997_muic_info {
 
struct max8997_muic_platform_data *muic_pdata;
enum max8997_muic_charger_type pre_charger_type;
+
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   int path_usb;
+   int path_uart;
 };
 
 enum {
@@ -322,7 +329,7 @@ static int max8997_muic_handle_usb(struct max8997_muic_info 
*info,
int ret = 0;
 
if (usb_type == MAX8997_USB_HOST) {
-   ret = max8997_muic_set_path(info, CONTROL1_SW_USB, attached);
+   ret = max8997_muic_set_path(info, info-path_usb, attached);
if (ret  0) {
dev_err(info-dev, failed to update muic register\n);
return ret;
@@ -378,7 +385,7 @@ static int max8997_muic_handle_jig_uart(struct 
max8997_muic_info *info,
int ret = 0;
 
/* switch to UART */
-   ret = max8997_muic_set_path(info, CONTROL1_SW_UART, attached);
+   ret = max8997_muic_set_path(info, info-path_uart, attached);
if (ret) {
dev_err(info-dev, failed to update muic register\n);
return -EINVAL;
@@ -694,6 +701,23 @@ static int max8997_muic_probe(struct platform_device *pdev)
}
}
 
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   if (pdata-muic_pdata-path_uart)
+   info-path_uart = pdata-muic_pdata-path_uart;
+   else
+   info-path_uart = CONTROL1_SW_UART;
+
+   if (pdata-muic_pdata-path_usb)
+   info-path_usb = pdata-muic_pdata-path_usb;
+   else
+   info-path_usb = CONTROL1_SW_USB;
+
+   /* Set initial path for UART */
+max8997_muic_set_path(info, info-path_uart, true);
+
/* Set ADC debounce time */
max8997_muic_set_debounce_time(info, ADC_DEBOUNCE_TIME_25MS);
 
diff --git a/include/linux/mfd/max8997.h b/include/linux/mfd/max8997.h
index 65f8d6a..2d2d67b 100644
--- a/include/linux/mfd/max8997.h
+++ b/include/linux/mfd/max8997.h
@@ -92,6 +92,13 @@ struct max8997_muic_reg_data {
 struct max8997_muic_platform_data {
struct max8997_muic_reg_data *init_data;
int num_init_data;
+
+   /*
+* Default usb/uart path whether UART/USB or AUX_UART/AUX_USB
+* h/w path of COMP2/COMN1 on CONTROL1 register.
+*/
+   int path_usb;
+   int path_uart;
 };
 
 enum max8997_haptic_motor_type {
-- 
1.8.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/