You are on page 1of 14

Hotswap Support of SIM Tray with Only One

GPIO's Assistance
Application Note
80-NP621-1 A
June 13, 2014

Submit technical questions at:


https://support.cdmatech.com/

Confidential and Proprietary – Qualcomm Technologies, Inc.


NO PUBLIC DISCLOSURE PERMITTED: Please report postings of this document on public servers or websites
to: DocCtrlAgent@qualcomm.com.

Restricted Distribution: Not to be distributed to anyone who is not an employee of either Qualcomm or its
subsidiaries without the express approval of Qualcomm’s Configuration Management.

Not to be used, copied, reproduced, or modified in whole or in part, nor its contents revealed in any manner to others
without the express written permission of Qualcomm Technologies, Inc.

Qualcomm reserves the right to make changes to the product(s) or information contained herein without notice. No
liability is assumed for any damages arising directly or indirectly by their use or application. The information
provided in this document is provided on an “as is” basis.

This document contains confidential and proprietary information and must be shredded when discarded.

Qualcomm is a trademark of QUALCOMM Incorporated, registered in the United States and other countries. All
QUALCOMM Incorporated trademarks are used with permission. Other product and brand names may be
trademarks or registered trademarks of their respective owners.

This technical data may be subject to U.S. and international export, re-export, or transfer (“export”) laws. Diversion
contrary to U.S. and international law is strictly prohibited.

Qualcomm Technologies, Inc.


5775 Morehouse Drive
San Diego, CA 92121
U.S.A.

© 2014 Qualcomm Technologies, Inc.


All rights reserved.
Contents

1 Introduction...................................................................................................... 5
1.1 Purpose.......................................................................................................................... 5
1.2 Scope............................................................................................................................. 5
1.3 Conventions .................................................................................................................. 5
1.4 References ..................................................................................................................... 5
1.5 Technical assistance ...................................................................................................... 5
1.6 Acronyms ...................................................................................................................... 6

2 Code Changes ................................................................................................. 7


2.1 Problem description ...................................................................................................... 7
2.2 Change description ....................................................................................................... 7
2.3 Code changes ................................................................................................................ 7
2.3.1 Change 1 ............................................................................................................ 7
2.3.2 Change 2 ............................................................................................................ 8
2.3.3 Change 3 .......................................................................................................... 11
2.3.4 Change 4 .......................................................................................................... 13

80-NP621-1 A 2 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Contents

Tables
Table 1-1 Reference documents and standards ............................................................................................ 5

80-NP621-1 A 3 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Revision history

Revision Date Description


A Jun 2014 Initial release

80-NP621-1 A 4 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
1 1 Introduction

2 1.1 Purpose
3 This document provides the UE code changes to detect the cards inserted in slot1 and slot2
4 through a tray using only one GPIO.

5 1.2 Scope
6 This document is intended for engineers using the Qualcomm Technologies, Inc. (QTI) solution
7 who need to understand the UE support of single GPIO to detect slot1 and slot2.

8 1.3 Conventions
9 Function declarations, function names, type declarations, and code samples appear in a different
10 font, e.g., #include.
11 Code variables appear in angle brackets, e.g., <number>.
12 If you are viewing this document using a color monitor, or if you print this document to a color
13 printer, red boldface indicates code that is to be added, and blue strikethrough indicates code
14 that is to be replaced or removed.

15 1.4 References
16 Reference documents are listed in Table 1-1. Reference documents that are no longer applicable
17 are deleted from this table; therefore, reference numbers may not be sequential.

18 Table 1-1 Reference documents and standards

Ref. Document

Qualcomm Technologies
Q1 Application Note: Software Glossary for Customers CL93-V3077-1

19 1.5 Technical assistance


20 For assistance or clarification on information in this document, submit a case to Qualcomm
21 Technologies, Inc. (QTI) at https://support.cdmatech.com/.
22 If you do not have access to the CDMATech Support website, register for access or send email to
23 support.cdmatech@qti.qualcomm.com.

80-NP621-1 A 5 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Introduction

1 1.6 Acronyms
2 For definitions of terms and abbreviations, see [Q1].

80-NP621-1 A 6 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
1 2 Code Changes

2 2.1 Problem description


3 The OEM requirement is to use only one GPIO for card detection at both the slots. The GPIO
4 used for card detection is connected to the tray however, not to UIM1 or UIM2.

5 2.2 Change description


6 As single tray is used for both the SIMs, the UIM driver generates the card removed or card
7 inserted interrupt for both the slots when a user removes or inserts a SIM. Since UIM2 card
8 detection GPIO is not used for SIM2 detection, the UIM must not configure the UIM2 card
9 detection GPIO. Also, the UIM must not configure the UIM2 controller for card detection and
10 card deactivation sequence on card\battery removal.
11 Configuration of single GPIO for tray insertion/removal happens in UIM1 context.

12 NOTE: The UIM1 and UIM2 hotswap must be enabled in NV 70210.

13 2.3 Code changes


14 If you are viewing this document using a color monitor, or if you print this document to a color
15 printer, red boldface indicates code that is to be added, and blue strikethrough indicates code
16 that is to be replaced or removed.

17 2.3.1 Change 1
18 File: custuim.h

/*-------------------------------------------------------------------------
--
Task Related Defines
--------------------------------------------------------------------------
-*/
#ifdef TEST_FRAMEWORK
#include "custuim_qtf.h"
#endif /* TEST_FRAMEWORK */
#include "custsfs.h"
/* MMGSDI Task support */
#define FEATURE_GSDI
/* Enable the specific ATCSIM Support */

80-NP621-1 A 7 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

#define FEATURE_UIM_SUPPORT_ATCSIM
#define FEATURE_UIM1_UIM2_HOTSWAP_GPIO60

1 2.3.2 Change 2
2 File: uimdrv_uartdm.c
3 Function: uim_uartdm_uim_controller_config

/* Function to configure UIM controller */


void uim_uartdm_uim_controller_config(uim_instance_global_type *uim_ptr,
boolean hotswap_enabled)
{
uint32 uim_cfg_reg_value = (UIM_EVENT_DEBOUNCE_TIME | UIM_MODE_18);
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
/* BIT NAME Description
10 PMIC_ALARM_EN Enables messaging on the alarm-line to notify
PMIC to drop
card’s voltage supply. Set to enable messaging, clear
to disable.
9 BATT_ALARM_TRIGGER_EN Enables triggering of deactivation sequence
when batteryalarm
detected. Set to enable triggering, clear to
disable.
8 UIM_RMV_TRIGGER_EN Enables triggering of deactivation sequence
when cardremoval detected. Set to enable
triggering, clear to disable. */
if (TRUE == hotswap_enabled)
{
uim_cfg_reg_value |= ( UIM_PMIC_ALARM_EN | UIM_CARD_EVENTS_EN ) ;
}

4 Function: uim_uartdm_uim_controller_mask_carddet_int

/* Function mask card detect interrupt */


void uim_uartdm_uim_controller_mask_carddet_int(uim_instance_global_type
*uim_ptr)
{
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;

80-NP621-1 A 8 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
uimUartdmUimControllerMaskCarddetInt(uim_ptr->id);
return;
} /* uim_uartdm_uim_controller_mask_carddet_int */

1 Function: uim_uartdm_uim_controller_clear_carddet_int

/* Clear the controller card detect interrupt */


void uim_uartdm_uim_controller_clear_carddet_int(uim_instance_global_type
*uim_ptr)
{
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
uimUartdmUimControllerClearCarddetInt(uim_ptr->id);
return;
} /* uim_uartdm_uim_controller_clear_carddet_int */

2 Function: uim_uartdm_uim_controller_card_presence

/* Return the status of the UIM Controller card presence */


uim_card_swap_enum_type uim_uartdm_uim_controller_card_presence
(
uim_instance_global_type *uim_ptr
)
{
volatile uim_card_swap_enum_type uim_presence_status =
UIM_CARD_UNCHANGED;
if (0x00 == uim_hw_if.uart[uim_ptr->id].start_addr )
{
return uim_presence_status;
}
#ifndef FEATURE_UIM_TEST_FRAMEWORK
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
uim_presence_status =
(uim_card_swap_enum_type)(UIM_HWIO_IN(
uim_hw_if.uart[UIM_INSTANCE_1].start_addr +
UART_DM_UIM_IO_STATUS) & UIM_CARD_INSERTED);
}
else
{
uim_presence_status =
(uim_card_swap_enum_type)(UIM_HWIO_IN(

80-NP621-1 A 9 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

uim_hw_if.uart[uim_ptr->id].start_addr +
UART_DM_UIM_IO_STATUS) & UIM_CARD_INSERTED);
}
#else
uim_presence_status =
(uim_card_swap_enum_type)(UIM_HWIO_IN(
uim_hw_if.uart[uim_ptr->id].start_addr +
UART_DM_UIM_IO_STATUS) & UIM_CARD_INSERTED);
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
#endif /* FEATURE_UIM_TEST_FRAMEWORK */
return uim_presence_status;
} /* uim_uartdm_uim_controller_card_presence */

1 Function: uim_uartdm_uim_controller_card_ins_int

/* Enable card insertion interrupt */


void uim_uartdm_uim_controller_card_ins_int
(
uim_instance_enum_type uim_instance,
DALGpioValueType uim_ins_level
)
{
#ifndef FEATURE_UIM_TEST_FRAMEWORK
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_instance)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
uimUartdmUimControllerCardInsInt(uim_instance);
uim_clk_busy_wait(200);
#endif /* FEATURE_UIM_TEST_FRAMEWORK */
return;
} /* uim_uartdm_uim_controller_card_ins_int */

2 Function: uim_uartdm_uim_controller_card_rem_int

/* Enable card removal interrupt */


void uim_uartdm_uim_controller_card_rem_int(uim_instance_enum_type
uim_instance, DALGpioValueType uim_ins_level)
{
#ifndef FEATURE_UIM_TEST_FRAMEWORK
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_instance)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}

80-NP621-1 A 10 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
uimUartdmUimControllerCardRemInt(uim_instance);
uim_clk_busy_wait(200);
#endif /* FEATURE_UIM_TEST_FRAMEWORK */
return;
} /* uim_uartdm_uim_controller_card_rem_int */

1 2.3.3 Change 3
2 File: uimdrv.c
3 Function: uim_hotswap_isr

void uim_hotswap_isr
(
uim_instance_global_type *uim_ptr,
boolean hos_need_to_query,
uim_card_swap_enum_type hos_new_card_status
)
{
RETURN_IF_INSTANCE_INVALID(uim_ptr->id);
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */

if(uim_hw_if.intctrl[uim_ptr->id].m_hs_enable == TRUE)
{
uim_card_swap_enum_type uim_query_card_status = UIM_CARD_UNCHANGED;
/* Check if we are already in debounce logic then do nothing */
if (uim_ptr->hotswap.hotswap_debounce_in_progress == TRUE)
{
MSG_LOW_UIM(uim_ptr->id,"HOTSWAP: Debounce is in progress",0,0,0);
return;
}

4 Function: uim_hotswap_slot_debounce_timer_expiry_cb

/* Check if the card detection status changes since the last ISR */
if(uim_new_query_status == uim_curr_hos_card_status )
{
/* Query status and ISR status is same , continue sampling */
if (*uim_hotswap_sample_couter_ptr >= uim_hotswap_max_sample_counter)
{
/* Debounce successfully completed !!!! */
/* Store the stable new card detect status */
/* send the hotswap signal to uim_task */

80-NP621-1 A 11 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

uim_hotswap_card_swap_debonce_end = TRUE;

if (uim_curr_hos_card_status == UIM_CARD_INSERTED)
{
MSG_HIGH_UIM(uim_ptr->id,"HOTSWAP: Debounce logic ended successfully,
processing card insertion", 0,0,0);
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_1 == uim_ptr->id)
{
MSG_HIGH_UIM(UIM_INSTANCE_2,"HOTSWAP: Debounce logic ended successfully,
processing card insertion", 0,0,0);
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
}
else
{
MSG_HIGH_UIM(uim_ptr->id,"HOTSWAP:Debounce logic ended successfully,
processing card removal", 0,0,0);
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_1 == uim_ptr->id)
{
MSG_HIGH_UIM(UIM_INSTANCE_2,"HOTSWAP:Debounce logic ended successfully,
processing card removal", 0,0,0);
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
}
if (FALSE == uim_hotswap_set_signal(uim_curr_hos_card_status, uim_ptr))
{
MSG_ERROR_UIM(uim_ptr->id,"HOTSWAP: Failed to set the CARD INSERTED or
REMOVED signal",0,0,0);
}
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_1 == uim_ptr->id){
if (FALSE == uim_hotswap_set_signal(uim_curr_hos_card_status,
uim_get_instance_ptr(UIM_INSTANCE_2)))
{
MSG_ERROR_UIM(UIM_INSTANCE_2,"HOTSWAP: Failed to set the CARD INSERTED or
REMOVED signal",0,0,0);
}
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
}
else
{
/* continue for next sampling */
uim_hotswap_reset_debounce_timer( uim_curr_hos_card_status, uim_ptr);
}
}
else
{
/* Query status and ISR status is not same, continue for next retry,

80-NP621-1 A 12 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

It reset the sample count again */


*uim_hotswap_debounce_retry_count_ptr =
*uim_hotswap_debounce_retry_count_ptr + 1;
if(*uim_hotswap_debounce_retry_count_ptr >= uim_ptr-
>hotswap.hotswap_me_conf.maximum_debounce_retry_counter)
{
/* Debounce is completed no change in card status */
MSG_HIGH_UIM(uim_ptr->id,"HOTSWAP: Debounce logic End, Unstable status: %d
[0=REMOVED 1=INSERTED]", uim_curr_hos_card_status,0,0);
uim_hotswap_card_swap_debonce_end = TRUE;
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_1 == uim_ptr->id)
{
/* Debounce is completed no change in card status */
MSG_HIGH_UIM(UIM_INSTANCE_2,"HOTSWAP: Debounce logic End, Unstable status:
%d [0=REMOVED 1=INSERTED]",uim_curr_hos_card_status,0,0);
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */
}
else
{
/* Reset and start sampling again */
*uim_hotswap_sample_couter_ptr = 0;
MSG_HIGH_UIM(uim_ptr->id,"HOTSWAP: Debounce logic Maximum Retry 0x%x
Current Count 0x%x",
uim_ptr>hotswap.hotswap_me_conf.maximum_debounce_retry_counter,*uim_hotswap
_debounce_retry_count_ptr,0);
uim_hotswap_reset_debounce_timer(uim_curr_hos_card_status, uim_ptr);
}
}

1 2.3.4 Change 4
2 File: uimdrv_gpio.c
3 Function: uim_config_hotswap_gpios

void uim_config_hotswap_gpios(uim_instance_global_type *uim_ptr)


{
if(uim_hw_if.intctrl[uim_ptr->id].m_hs_enable == FALSE)
{
return;
}
#ifdef FEATURE_UIM1_UIM2_HOTSWAP_GPIO60
if ( UIM_INSTANCE_2 == uim_ptr->id)
{
MSG_HIGH("No Need for UIM2 Hotswap Configuration",0,0,0);
return;
}
#endif /* FEATURE_UIM1_UIM2_HOTSWAP_GPIO60 */

80-NP621-1 A 13 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Code Changes

configHotswapGpios(uim_ptr->id);
return;
} /* uim_config_hotswap_gpios */

80-NP621-1 A 14 Confidential and Proprietary – Qualcomm Technologies, Inc.


MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION

You might also like