Showing posts with label android linux. Show all posts
Showing posts with label android linux. Show all posts

2/01/2013

Unified boot cookie

Background
A cookie is needed to be set in AMSS for a number of features that are triggered from AMSS but executed in boot.
the cookie is stored in the first 2K of IRAM because the higher 2K of IRAM is used by AMSS clock switch.

Implementation

the unified boot cookie has the following set of properties:
1. A boot cookie gets set in AMSS context. Setting can be triggered from Modem or from Apps through proc.comm
2. Once the cookie is set, the boot_set_cookie API never returns. It enables WATCHDOG and goes into an infinite
loop so the phone resets and enters BOOT.
3. Reset of the phone can be avoided by using an overriding argument: reset
4. The supported boot cookies are added in an enumeration list: boot_cookie_t
5. Once in BOOT, boot_get_cookie will be called in appropriate places for the needed action.

boot_set_cookie() can be called from AMSS and it sets the boot cookie,
boot_get_cookie() can be called from Boot or AMSS and it retrieves the saved cookie.

Customization

Customer can add their own cookie per their requirement befor BOOT_COOKIE_MAX
typedef enum
{
BOOT_COOKIE_SD_IMG_UPGRADE,
BOOT_COOKIE_BACKUP,
BOOT_COOKIE_RECOVERY,

/*****************************
** ADD YOUR ENUM ABOVE THIS **
*****************************/
BOOT_COOKIE_MAX
}boot_cookie_t;

12/19/2012

How to build adb.exe/fastboot.exe on Ubuntu

1.apt-get install mingw32
2. build/envsetup.sh
3.choosecombo. config your settings
4.make USE_MINGW=y adb
make USE_MINGW=y fastboot
5.check out/host/windows-x86/bin for adb.exe/fastboot.exe

9/18/2012

How to change CPU Dynamic Frequency Scaling

Using the Sys Interface

The files in /sys/devices/system/cpu/cpu0/cpufreq/ provide information and a means of controlling the frequency scaling subsystem. Seed values are given in Khz. You need to be root to access the /sys filesystem.
Your max speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq.
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
700000
Your min speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq.
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
500000
If you are using the userspace governor, you can write to /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change the current speed.
# echo 700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz : 697.252
# echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz : 976.152



Using Frequency Scaling Governors

You can get a list of available governors with (as root):
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand powersave userspace performance
Note: If the governors are compiled as modules, load them first:
# modprobe cpufreq_performance cpufreq_ondemand cpufreq_conservative cpufreq_powersave cpufreq_userspace
Now we set our governor: What is our current governor?
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
userspace
Set new governor and watch if it has changed
# echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative
Congrats! Your governor is active.
You may set the governor in your init.rc, to make it used on every boot.

6/22/2012

How to make mass-storage recognized as CD-ROM drive.

Many customer asked how to make their mass-storage device recognized as CD-ROM drive.

It can be done by setting the value of device type for the response of "INQUIRY" request from Host.



Set the value in vget_desc() function in hsu_al_ms.c file like following



static void vget_desc
(
msfd_appctx_t ctx,
juint8_t vlun,
/* out parameters that need to be filled in by the function */
juint32_t* dev_type,
juint8_t* version,
char** vendor,
char** product,
char** prod_rev
)
{

//Sample implementation


*dev_type = SCSI_DEVICE_CDROM // the value is 0x05

*vendor = "Customer company name";
*product = "customer product name ";
*prod_rev = inquiry_data_prod_rev;

How to add GPIO bit-bang i2c device to Linux kernel?

1. Check Kernel configuration
#define CONFIG_I2C_GPIO y
#define CONFIG_I2C_MSM y


2. Configure GPIOs at Modem side for general purpose, in/out...
You should edit TLMMBsp.c at modem side.


*3. ~ 7. You should add/modify "kernel/arch/arm/mach-msm/board-xxxxx.c"

3. Make i2c_gpio_platform_data
static struct i2c_gpio_platform_data ALRAN_i2c_gpio_data = {
.sda_pin = 91, // GPIO pin number for SDA
.scl_pin = 90, // GPIO pin number for SCL
};


4. Make platform_device
static struct platform_device ALRAN_i2c_gpio_device = {
.name = "i2c-gpio",
.id = 3, // do not be same with the another i2c_gpio_device
.dev = {
.platform_data = &ALRAN_i2c_gpio_data, // You have made it at step 3.
},
};


5. Add devices array for initdata
static struct platform_device *devices[] __initdata = {
<snip>
&ALRAN_i2c_gpio_device,
<snip>



6. Add i2c client information
static struct i2c_board_info ALRAN_i2c_devices[] = {
{
I2C_BOARD_INFO("ALRAN",0x4A>>1), // 0x4A should be changed with your device address
},
};


7. Register i2c client to board_init function
static void __init msm7x2x_init(void)
{
<snip>
i2c_register_board_info(3, ALRAN_i2c_devices, ARRAY_SIZE(ALRAN_i2c_devices));
<snip>
}
It's just for i2c client board.

How to add new clock param for SPI bus in linux build on Qualcomm chipset?

SPI clock parameters are defined in arch/arm/mach-msm/clock-xxxx.c file.


The table for the parameters is like below.


static struct clk_freq_tbl clk_tbl_spi[] = {
F_MND8(10000000, 19, 12, SRC_PLL3, 4, 7, 129),
F_MND8(26000000, 19, 12, SRC_PLL3, 4, 34, 241),
F_END,
};


Clock frequency for SPI bus is determined by M:N:D counter and the information about this is described in clock chapter of software interface manual. The concerned registers are SPI_MD_REG and SPI_NS_REG.


The example vale for 1 Mhz SPI clock is below.


F_MND8(1000000, 19, 12, SRC_PLL3, 4, 1, 185),

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.

Does MTP supported in Android builds?

Is there support for MTP function driver in Android builds?





There is support for MTP in ICS builds by default in all the android software releases.



MTP is protocol similar to mass-storage. On ICS, MTP is the default function to access phone's storage media. It was not available on GB and but was supported in Honeycomb.



OEMS can test this feature function driver, user can enable MTP/PTP using UI Notification menu.



One thing to note here is that once user selects MTP/PTP, it is then marked as default configuration. Afterward device always enumerates with MTP even across reboots. To return to non-MTP composition user need to reprogram userdata.img or below command from shell followed by reboot:



setprop persist.sys.usb.config ""

sync







There is no support for MTP function driver from the Qualcomm in android builds before ICS and Honeycomb.



There are solutions in the market to suite such requirement. OEMs can contact third party vendors( Jungo/Packet Video) for MTP feature support in Android builds.



http://www.opencore.net/files/Android_WM_Package.pdf



http://www.jungo.com/st/embedded_usb_mtp_device.html

12/30/2011

how to mount the SDcard in init.rc manually

in init.rc 
please add the following:
# mount mtd partitions
mount vfat /dev/block/mmcblk1p1 /sdcard
chown system system /sdcard
chmod 0777 /sdcard
setprop EXTERNAL_STORAGE_STATE mounted

How to mount the USB disk storage decies in android device

in device/qcom/msm7627_7x_surf/vold.fstab
change:
dev_mount sdcard /mnt/sdcard auto /devices/platform/msm_sdcc.1/mmc_host
to
dev_mount sdcard /mnt/sdcard auto /devices/platform/msm_hsusb_host.0/usb1

How to get the max frequency of CPU var ADB shell

get the max:
cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
get the current:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq