Showing posts with label msm8x60. Show all posts
Showing posts with label msm8x60. Show all posts

6/22/2012

I2C Suspend Power Collapse in AMSS 8650 Software

Problem: The modem side processor keeps spinning for the spinlock acquired by the apps side processor for an I2C transaction when the apps side processor is suspend power collapsed.



Solution: The interrupts should be enabled before calling I2C on the Apps side.



Suspend() is already using a mutex_lock (which is also being used for the I2C transaction) which makes sure that the transaction is over before suspend happens. So, suspend power collapse should not happen until ongoing I2C transaction is done. And once suspend is called, any further I2C transaction cannot even acquire remote lock.



In such a situation, one should check that the interrupts are enabled when an I2C transaction on the apps side is being initiated. If the interrupts are disabled, then the driver cannot finish the transaction since the driver is interrupt driven and the lock acquired is never released. Thus, the interrupts should be enabled before calling I2C on the Apps side.

Direct control of sensors through apps processor on Qualcomm msm8x60

Question: How do we control sensors directly (bypassing DSPS) through the apps processor on 8x60 ?


Answer: There are two steps to be done for this:
1) Disabling of DSPS: This is done through disabling the parameter "CONFIG_MSM_DSPS" either in the file msm8660-perf_defconfig or the file msm8660_defconfig file. The file is selected depending upon the "KERNEL_DEFCONFIG" configuration specified in the makefile "AndroidBoard.mk" located at /device/qcom/msm8660_surf.
After changing the file above, a clean build must be done.

2) Voting for turning on the voltage regulators S3 and L5: The sensor drivers will need to vote to turn these regulators on. The voting can be handled in /kernel/arch/arm/mach-msm/board-msm8x60.c. For eg: if a BMA150 Linux kernel is being ported, the board file board-msm8x60.c should be modified according to the following patch:


https://www.codeaurora.org/patches/quic/la/PATCH_M8660AAABQNLYA1080_5904_turning_s3_l5_ON_for_sensor_control_20110401.tar.gz


The patch above should be referred to for any modifications.


static struct bma150_platform_data bma150_data = {
.power_on = sensors_ldo_enable,
.power_off = sensors_ldo_disable,
};


static struct i2c_board_info msm_i2c_bma150_info[] = {
{
I2C_BOARD_INFO("bma150", 0x38),
.flags = I2C_CLIENT_WAKE,
.irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
.platform_data = &bma150_data,
}
};



Notes: The solution is based on 8x60 FFA sensor design � BMA150 controlled by GSBI12. For different sensor design, a different sensor driver and platform data structure should be created. Similarly, a different i2c_board_info structure should be created.

GSBI Protocol Code/PIN mappings in qualcomm MSM8660, MSM8660A, MSM8960

When GSBI protocol code is configured to below functions, related PIN are configured as below.


protocol code 1 I2C + SIM/R-UIM
GSBI_PO(0) i2c_clk
GSBI_PO(1) i2c_dat
GSBI_PO(2) uim_clk
GSBI_PO(3) uim_dat


Protocol code 2 I2C
GSBI_PO(0) i2c_clk
GSBI_PO(1) i2c_dat
GSBI_PO(2) not used
GSBI_PO(3) not used


Protocol code 3 SPI
GSBI_PO(0) spi_clk
GSBI_PO(1) spi_cs_n
GSBI_PO(2) spi_data_miso
GSBI_PO(3) spi_data_mosi


Protocol code 4 UART or IRDA
GSBI_PO(0) uart_rfr_n
GSBI_PO(1) uart_cts_n
GSBI_PO(2) uart_rx_dat
GSBI_PO(3) uart_tx_dat


Protocol code 5 SIM/R-UIM
GSBI_PO(0) not used
GSBI_PO(1) not used
GSBI_PO(2) uim_clk
GSBI_PO(3) uim_dat


protocol code 6 I2C + 2-wire UART
GSBI_PO(0) i2c_clk
GSBI_PO(1) i2c_dat
GSBI_PO(2) uart_rx_dat
GSBI_PO(3) uart_tx_dat

GSBI Configuration for I2C on quaclomm Android msm8660

Question: What steps should be followed for the configuration of a particular GSBI for I2C on 8660 ?


Answer: Steps to be followed for the GSBI configuration for I2C:


Suppose the GSBIx is to be configured:


1) In file devices-msm8x60.c, add:
static struct resource gsbix_qup_i2c_resources[] = {
{
.name = "qup_phys_addr",
.start = MSM_GSBIx_QUP_PHYS,
.end = MSM_GSBIx_QUP_PHYS + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
{
.name = "gsbi_qup_i2c_addr",
.start = MSM_GSBIx_PHYS,
.end = MSM_GSBIx_PHYS + 4 - 1,
.flags = IORESOURCE_MEM,
},
{
.name = "qup_err_intr",
.start = GSBIx_QUP_IRQ,
.end = GSBIx_QUP_IRQ,
.flags = IORESOURCE_IRQ,
},
};


/* Use GSBIx QUP for /dev/i2c-5 (i.e. if i2c-5 has not been used before else choose the next number) */
struct platform_device msm_gsbix_qup_i2c_device = {
.name = "qup_i2c",
/* this BUS_ID has been mapped to 5 inside the file devices-msm8x60.h. this part has been explained below */
.id = MSM_GSBIx_QUP_I2C_BUS_ID,
.num_resources = ARRAY_SIZE(gsbix_qup_i2c_resources),
.resource = gsbix_qup_i2c_resources,
};

In the same file, inside the structure, struct clk msm_clocks_8x60[] = {
/* change the following : */
CLK_8X60("gsbi_qup_clk", GSBIx_QUP_CLK, NULL , 0),
/* to: */
CLK_8X60("gsbi_qup_clk", GSBIx_QUP_CLK, &msm_gsbix_qup_i2c_device.dev, 0),

/* and change the following: */
CLK_8X60("gsbi_pclk", GSBIx_P_CLK, NULL , 0),
/* to: */
CLK_8X60("gsbi_pclk", GSBIx_P_CLK, &msm_gsbix_qup_i2c_device.dev, 0),

2) In file board-msm8x60.c:

A) Add
static struct msm_i2c_platform_data msm_gsbix_qup_i2c_pdata = {
.clk_freq = 100000,
.src_clk_rate = 24000000,
.clk = "gsbi_qup_clk",
.pclk = "gsbi_pclk",
.msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config,
};

B) Modify
static struct platform_device *surf_devices[] __initdata = {
/* add the following: */
&msm_gsbix_qup_i2c_device,

C) Add
/* in section #ifdef CONFIG_I2C_QUP of msm8x60_init_buses() , add */
msm_gsbix_qup_i2c_device.dev.platform_data = &msm_gsbix_qup_i2c_pdata;

3) In file devices.h, add:
extern struct platform_device msm_gsbix_qup_i2c_device;

4) in file devices-msm8x60.h, add:
/* if 5 has already been used, then the next consecutive number */
#define MSM_GSBIx_QUP_I2C_BUS_ID 5

6/02/2012

Accessory ( Headset , Headphone , ANC Headset etc ) Detection in 8660,8260 ( 8x60) Android Builds

The Accessories that can be detected by PMIC 8058 OTHC used in 8x60 are listed in
LINUX/android/kernel/include/linux/pmic8058-othc.h
enum othc_accessory_type {
OTHC_NO_DEVICE = 0,
OTHC_HEADSET = 1 << 0,
OTHC_HEADPHONE = 1 << 1,
OTHC_MICROPHONE = 1 << 2,
OTHC_ANC_HEADSET = 1 << 3,
OTHC_ANC_HEADPHONE = 1 << 4,
OTHC_ANC_MICROPHONE = 1 << 5,
OTHC_SVIDEO_OUT = 1 << 6,
};

The Logic to decide the type of accessory is based on the detect_flags that idetifies the Accessory type and other parameters as
specified in the othc_accessories array found in the file /LINUX/android/kernel/arch/arm/mach-msm/board-msm8x60.c


The Logic to decide the type of accessory is based on the detect_flags that idetifies the Accessory type and other parameters as
specified in the othc_accessories array found in the file /LINUX/android/kernel/arch/arm/mach-msm/board-msm8x60.c

static struct othc_accessory_info othc_accessories[] = {
{
.accessory = OTHC_SVIDEO_OUT,
.detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT
| OTHC_ADC_DETECT,
.key_code = SW_VIDEOOUT_INSERT,
.enabled = false,
.adc_thres = {
.min_threshold = 20,
.max_threshold = 40,
},
},
{
.accessory = OTHC_ANC_HEADPHONE,
.detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT |
OTHC_SWITCH_DETECT,
.gpio = PM8058_LINE_IN_DET_GPIO,
.active_low = 1,
.key_code = SW_HEADPHONE_INSERT,
.enabled = true,
},
{
.accessory = OTHC_ANC_HEADSET,
.detect_flags = OTHC_MICBIAS_DETECT | OTHC_GPIO_DETECT,
.gpio = PM8058_LINE_IN_DET_GPIO,
.active_low = 1,
.key_code = SW_HEADPHONE_INSERT,
.enabled = true,
},
{
.accessory = OTHC_HEADPHONE,
.detect_flags = OTHC_MICBIAS_DETECT | OTHC_SWITCH_DETECT,
.key_code = SW_HEADPHONE_INSERT,
.enabled = true,
},
{
.accessory = OTHC_MICROPHONE,
.detect_flags = OTHC_GPIO_DETECT,
.gpio = PM8058_LINE_IN_DET_GPIO,
.active_low = 1,
.key_code = SW_MICROPHONE_INSERT,
.enabled = true,
},
{
.accessory = OTHC_HEADSET,
.detect_flags = OTHC_MICBIAS_DETECT,
.key_code = SW_HEADPHONE_INSERT,
.enabled = true,
},
};

If OEM want to disable the detection of any accessory then they can set .enabled = false for the Accessory they dont want to support in the above table .



The decision about which Acessory is inserted or removed is done in the function
static int pm8058_accessory_report(struct pm8058_othc *dd, int status) present in the file
LINUX/android/kernel/drivers/input/misc/pmic8058-othc.c

8K Linux: How to change the maximum count of audio session?

QDSP6 supports multiple sessions operation which means that we can support playback/recording with different formats/configurations simultaneously. The default setting will allow for 4 playbacks and 4 recordings with different formats at the same time. This feature is currently only available in LE(Linux Enablement) build, not in Android.

Question:
How to increase the maximum count of audio session?

Answer:
- To change count of decoding session, refer to Q6_DEC_MAX_STREAM_COUNT.
- To change count of encoding session, refer to Q6_ENC_MAX_SESSION_COUNT.
- To change count of audio CAD session, refer to CAD_MAX_SESSION.
- CAD_MAX_SESSION > (Q6_DEC_MAX_STREAM_COUNT+Q6_ENC_MAX_SESSION_COUNT)
- These definitions are all in ARM, not Q6.

Additional information provided from Jason Hu,

Entering Q6, typical audio/video session instance is pre-defined and controlled by PM, e.g.,

#define AUD_TCM_MEMORY_PERF_4 0

#define AUD_MIPS_PERF_4 78000

#define AUD_MIN_Q6_FREQUENCY_PERF_4 115000

#define AUD_AXI_FREQUENCY_PERF_4 18000




For example, purely considering the above one "Audio Media session",

Q6 CPU max freq = 600MHz, then we can have 600,000 / 115,000 = 5.2

Q6 AXI max freq = 128MHz, then we can have 128,000 / 18,000 = 7.1



Therefore, considering some margin of other application/resource usage, 4 is a reasonable number for limiting from outside of Q6.

MSM8660: H264 Min_dpb and ouput buffer number calculation

Default min_dpb is calculated by video driver when SPS/PPS is unknown.
Actual min_dpb is calculated by firmware, after first buffer arrives with SPS/PPS. Port reconfig is generated.

Default min_dbp is calculated in ddl_decoder_min_num_dpb() @kernel/drivers/video/msm/vidc/1080p/ddl
Information available in h264 standard and http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Decoded_picture_buffering

After SPS/PPS is sent to 1080p HW core, a port reconfiguration event is propagated to free (already allocated) and allocate (new requirement) output buffers, when requirements differ.

Output buffer count = min_dpb + 6 extra buffers
� Two extra buffers for the current decode and displayed frames (firmware added)
� Two for display pipeline (video driver added)
� Two for performance (video driver added)

From OMX IL logs,
E OMX-VDEC-720P: Allocated virt:0x40951000, FD: 39 of size 294912 count: 18 <-video driver estimated
E OMX-VDEC-720P: Empty this arbitrary <- SPS/PPS sent to driver
E OMX-VDEC-720P: Rxd OMX_COMPONENT_GENERATE_PORT_RECONFIG
E OMX-VDEC-720P: Allocated virt:0x41615000, FD: 39 of size 2293760 count: 14 <-After reconfig

MSM8660 Video Payback Power Measurement Procedure

1. After loading MSM build, load device QCN, place in airplane mode before measurements.
2. Insert SD card in the device
3. Push required files to the SD card (Make sure SD card is formatted if using for the first time)
4. Make sure the device is ON, and USB is connected when executing the steps given below
a. Make sure that SD card read-only lock is not on
b. adb push FILE_PATH /sdcard/ (for example: adb push C:\QTC88.mp3 /sdcard/)
c. If it is not able to write, change permissions as "chmod 777 /sdcard/"
5. Insert headset
6. Reboot the device
7. Connect USB to the device
8. Set Class D using batch file(classd.bat) - This step is only for 8660 Spartanized FFA
9. Disconnect USB
10. Make sure Display Timeout is set to 30 minutes
11. Play the video file under e.g. Main menu > Videos > select video(QTC48.mp4, QTC77.mp4 , or QTC88.mp4) to play
12. Set volume to 9/15
13. Start power measurement

Note:
1. SD card contribution should be subtracted for power measurement
2. Video test cases(QTC48, QTC77 and QTC88) are measured with LCD/BL ON with default setting values. LCD/BL power contribution should be subtracted after power measurement
3. To verify the FPS of the video, type command: adb shell setprop persist.debug.sf.statistics 1 or adb shell setprop persist.debug.sf.showfps 1 and the FPS will show in adb logcat (needs USB connected)

MSM8660 Audio Playback Power measurement Procedure

1. After loading MSM build, load device QCN, place in airplane mode before measurements.
2. Insert SD card in the device
3. Push required files to the SD card (Make sure SD card is formatted if using for the first time)
4. Make sure the device is ON, and USB is connected when executing the steps given below
a. Make sure that SD card read-only lock is not on
b. adb push FILE_PATH /sdcard/ (for example: adb push C:\AU4.mp3 /sdcard/)
c. If it is not able to write, change permissions as "chmod 777 /sdcard/"
5. Insert headset
6. Reboot the device
7. Connect USB to the device
8. Set Class D using batch file(classd.bat) - This step is only for 8660 Spartanized FFA
9. Disconnect USB
10. Play the audio file under e.g. Main menu > Music > Songs tab > select AU4.mp3
11. Set volume to 9/15
12. Turn off the display using the power key
13. Start power measurement

Note: SD card contribution should be subtracted for power measurement

MSM8660 3D UI PowerLift Power Measurement Procedure

1. After loading MSM build, load device QCN, place in airplane mode before measurements.
2. Request for the PowerLift application from QCT side(A200_ANDROID_PowerLift_8660)
3. Double click on "install.bat" of the provided package to install PowerLift application
4. Reboot the device
5. Make sure Display Timeout is set to 30 minutes
6. Run graphics under e.g. Main menu > select PowerLift
7. Start power measurement

Note:
1. Graphic test case(QGC23) is measured with LCD/BL ON with default setting values. LCD/BL power contribution should be subtracted after power measurement
2. To verify the FPS of PowerLift, this can be seen from the PowerLift application UI

6/01/2012

How the Scropion clock is configured during boot stage in the msm8x60?

If you are working on the 8x60 LK boot-loader, you might note the Scoprion clock is no longer configured in LK - acpu_clock_init() anymore, it's because boot architecture in 8x60 platfrom is different from previous platform (i.e 7x30/8x55), in 8x60 platfomr the Scorpion is start to run before the modem processor.



Basically, the Scorpion clock is controlled by the SCSS_CLK_CTL and SCSS_CLK_SEL register, after the system boot up (reset), by default the Scorpion clock is tighted with AXI (EBI1) speed. In current 8x60 software design the Scorpion clock is configured in SBL1 (RPM bootloader), SBL2(Scorpion bootloader), and SBL3 (Scorpion bootloader), this solution will show you where the Scorpion clock is set and what speed of Scorpion at that point.



SBL1:

After calling clk_regime_rpm_init_boot_rpmsbl(), the AXI is configured to 128MHz, so the Scorpion clock is 128MHz.



SBL2:

In clk_regime_apps_init_boot(), the Scorpion clock is configured from 128MHz to 524MHz, the detailed are : 128MHz (AXI Speed) -> 262MHz (AXI Speed) -> 384MHz (PLL8 -- 384MHz / 1) -> 524MHz (PLL11 -- 1048MHz / 2).


SBL3:

After calling the clk_regime_apps_switch_acpu_clk_core(), the Scorpion clock is 750MHz (PLL9 -- 1500MHz / 2).

ELF image load and autentication in TZ in the msm8660

All the ELF images will load by HLOS and authenticated by Truszone .



Linux Andorid is using the PIL to load the image , PIL has following functions.


struct pil_reset_ops {

int (*init_image)(const u8 *metadata, size_t size);

int (*verify_blob)(u32 phy_addr, size_t size);

int (*auth_and_reset)(void);

int (*shutdown)(void);

};



The init_image will map to TZ api call tzbsp_pil_init_image(), the api will authenticate the hash segment and (elf_header+program header).

TZBSP_DEFINE_SYSCALL(TZBSP_PIL_INIT_ID,

PIL_FLAGS,

tzbsp_pil_init_image,

3, { sizeof(int), sizeof(int), sizeof(int) } );



The auth_and_reset map to tzbsp_pil_auth_reset(),this will verify all the segment except hash segment.

TZBSP_DEFINE_SYSCALL(TZBSP_PIL_AUTH_RESET_ID,

PIL_FLAGS,

tzbsp_pil_auth_reset,

1, { sizeof(int) } );

The hash algorithm is using SHA1



The sw id type in Tzone are, so for MODEM HASH table is=2, LPA QDSP6=4 SPS HASH=11

typedef enum

{

SECBOOT_SBL_SW_TYPE = 0,

SECBOOT_SBL1_SW_TYPE = 0,

SECBOOT_AMSS_SW_TYPE = 1,

SECBOOT_DMSS_SW_TYPE = 1,

SECBOOT_AMSS_HASH_TABLE_SW_TYPE = 2,

SECBOOT_FLASH_PRG_SW_TYPE = 3,

SECBOOT_EHOSTD_SW_TYPE = 3,

SECBOOT_DSP_HASH_TABLE_SW_TYPE = 4,

SECBOOT_SBL2_SW_TYPE = 5,

SECBOOT_SBL3_SW_TYPE = 6,

SECBOOT_TZ_KERNEL_SW_TYPE = 7,

SECBOOT_HOSTDL_SW_TYPE = 8,

SECBOOT_APPSBL_SW_TYPE = 9,

SECBOOT_RPM_FW_SW_TYPE = 10,

SECBOOT_SPS_HASH_TABLE_TYPE = 11,

SECBOOT_MAX_SW_TYPE = 0x7FFFFFFF /* force to 32 bits*/

} secboot_sw_type;