Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update time #1

Open
wants to merge 23 commits into
base: mm6.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bea2897
power: Add support for tap-to-wake feature control
Oct 19, 2015
dfabe50
power-8974: Explicitly send the magical opcode
Oct 30, 2015
15f1c12
power: add support for bias modes on 8994
Oct 21, 2015
bc9b1e2
power-8974: Implement bias modes for 8974
Nov 1, 2015
9dddfdd
power: safely convert int to void *
Nov 3, 2015
bdf16fe
power: Update for PerformanceManager changes
Nov 3, 2015
eb97f5f
power: Fix 8084 compilation issue
Nov 4, 2015
bc82e99
dtbtool: Allow forcing v3 output.
maniac103 Aug 27, 2015
3d4e4c8
dtbtool: use detected version to determine entry_size
invisiblek Nov 8, 2015
0dee43f
dtbtool: use stat to determine file type if its unknown
invisiblek Nov 8, 2015
f0a6562
Fix error checking of open file error
Nov 9, 2015
cbabda2
Fix build breaks on M
Nov 9, 2015
a29c349
power: enable perf options for power bias
Oct 29, 2015
1347875
Refactor TARGET_TAP_TO_WAKE_NODE
Nov 13, 2015
ac9c8a8
dtbtool: Recursively search input directory for dtb files
Dec 9, 2015
38807b1
power: Reduce interactive timer with screen off
Dec 16, 2015
4fdf322
power-8960: Implement performance profiles
zwliew Nov 17, 2015
d07d4f1
power-8960: Remove set_interactive handling
zwliew Jan 5, 2016
87a8618
power: Add support for 8952
intervigilium Jan 3, 2016
29a1035
power: Remove custom low power mode hint handling
zwliew Jan 12, 2016
41354cb
power-8992: Add launch boost profile
zwliew Feb 14, 2016
053d0c3
init: Add msm8952-specific init extension library
Apr 10, 2015
da3c30e
power-8992: Fix build error and warnings
zwliew Feb 20, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
533 changes: 371 additions & 162 deletions dtbtool/dtbtool.c

Large diffs are not rendered by default.

111 changes: 94 additions & 17 deletions dtbtool/dtbtool.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012, The Linux Foundation. All rights reserved.
Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.

Redistribution and use in source form and compiled forms (SGML, HTML,
PDF, PostScript, RTF and so forth) with or without modification, are
Expand Down Expand Up @@ -33,6 +33,7 @@ Android - Table of Device Tree

0) Document revision
v1.0 - Initial version (dng)
v1.1 - Add v2 format to allow subtype (dng)

1) Android boot image:
----------------------
Expand Down Expand Up @@ -72,16 +73,26 @@ Android - Table of Device Tree
x +------------------+
| | MAGIC ("QCDT") | 4B
| +------------------+
header | VERSION | uint32 (initial version 1)
header | VERSION | uint32 (version 3)
| +------------------+
| | num of DTBs | uint32 (number of DTB entries)
x +------------------+
| | platform id #1 | uint32 (e.g. ID for MSM8974)
| +------------------+
| | variant id #1 | uint32 (e.g. ID for CDP, MTP)
| +------------------+
| | subtype id #1 | uint32 (e.g. ID for subtype) (QCDT v2)
device +------------------+
#1 | soc rev #1 | uint32 (e.g. MSM8974 v2)
entry +------------------+
| | pmic0 #1 | uint32 (pmic0-> first smallest SID of existing pmic)
| +------------------+
| | pmic1 #1 | uint32 (pmic1-> secondary smallest SID of existing pmic)
| +------------------+
| | pmic2 #1 | uint32 (pmic2-> third smallest SID of existing pmic)
| +------------------+
| | pmic3 #1 | uint32 (pmic3-> fourth smallest SID of existing pmic)
| +------------------+
| | offset #1 | uint32 (byte offset from start/before MAGIC
| +------------------+ to DTB entry)
| | size #1 | uint32 (size in bytes of DTB blob)
Expand All @@ -95,8 +106,18 @@ Android - Table of Device Tree
| +------------------+
device | variant id #Z | uint32 (e.g. ID for CDP, MTP)
#Z +------------------+
entry | soc rev #Z | uint32 (e.g. MSM8974 v2)
entry | subtype id #Z | uint32 (e.g. ID for subtype) (QCDT v2)
(last) +------------------+
| | soc rev #Z | uint32 (e.g. MSM8974 v2)
| +------------------+
| | pmic0 #1 | uint32 (pmic0-> first smallest SID of existing pmic)
| +------------------+
| | pmic1 #1 | uint32 (pmic1-> secondary smallest SID of existing pmic)
| +------------------+
| | pmic2 #1 | uint32 (pmic2-> third smallest SID of existing pmic)
| +------------------+
| | pmic3 #1 | uint32 (pmic3-> fourth smallest SID of existing pmic)
| +------------------+
| | offset #Z | uint32 (byte offset from start/before MAGIC
x +------------------+ to DTB entry)
| 0 ("zero") | uint32 (end of list delimiter)
Expand All @@ -122,25 +143,63 @@ Android - Table of Device Tree
3) Operations
-------------
3.1) Build-time:
1) Each DTS per device will add a "qcom,msm-id" triplet
1) Each DTS per device will add a "qcom,msm-id" entry
e.g. for msm8974-sim.dts, add
qcom,msm-id = <x y z>;
x = ID for msm8974
y = ID for CDP, MTP, etc.
z = ID for soc revision
The triplet can optionally be an array of triplets:
qcom,msm-id = <x1, y1, z1>, <x2, y2, z2>, ...;
qcom,msm-id = <x y z>;
or
qcom,msm-id = <x z>;
qcom,board-id = <y y'>;
or
qcom,msm-id = <x z>;
qcom,board-id = <y y'>;
qcom,pmic-id = <a b c d>;
x = ID for msm8974
y = ID for CDP, MTP, etc.
y' = ID for subtype (assumed zero if absent)
z = ID for soc revision
a = pmic0
b = pmic1
c = pmic2
d = pmic3
SBL populates the pmic entries always in ascending order of SID, so
pmic0-> SID0, pmic1-> SID1, pmic2-> SID2, pmic3-> SID3.
e.g. for qcom,pmic-id = <pmic0 pmic1 pmic2 pmic3>
Board X = MSM8994 + PM8994 + PMI8994 (Existing boards [ROW])
Board Y = MSM8994 + PM8994 + PMI8994 + PM8004 (Internal SS board variant)
Board Z = MSM8994 + PM8994 + PM8004 (Boards that SS will be making)

For all boards X, Y, and Z, PMICs have the following SIDs and REVID SUBTYPEs
(i.e. PMIC Model):
PM8994 - SID 0 and 1; subtype = 9
PMI8994 - SID 2 and 3; subtype = 10
PM8004 - SID 4 and 5; subtype = 12

LK using SMEM PMIC info(1 as major and 0 as minor version for example):
Board X: qcom,pmic-id = <0x0109 0x010A 0x0 0x0>;
Board Y: qcom,pmic-id = <0x0109 0x010A 0x010C 0x0>;
Board Z: qcom,pmic-id = <0x0109 0x010C 0x0 0x0>;

The entry can optionally be an array:
qcom,msm-id = <x1 y1 z1>, <x2 y2 z2>, ...;
or
qcom,msm-id = <x1 z1>, <x2 z2>, ...;
qcom,board-id = <y1 y1'>, ...;
or
qcom,msm-id = <x1 z1>, <x2 z2>, ...;
qcom,board-id = <y1 y1'>, ...;
qcom,pmic-id = <a1 b1 c1 d1>, ...;
Note that qcom,msm-id, qcom,board-id and qcom,pmic-id are not matched pairs.
2) Kernel compile will generate the DTB
3) Android build will run a new tool (dtbTool)
a) scan the DTB output directory for all compiled DTB
b) decompile the DTB for "qcom,msm-id"
b) decompile the DTB for "qcom,msm-id"/"qcom,board-id"/"qcom,pmic-id"
c) generate the QC table of device tree in sorted
order (platform, variant, soc rev)
order (platform, variant, subtype, soc rev, pmic0, pmic1, pmic2, pmic3)
d) modified mkbootimg will merge new table of DT

3.2) Run-time:
1) LK bootloader will obtain MSM id/variant/soc rev info
either from early bootloaders or via other means
1) LK bootloader will obtain platform id/variant/subtype/soc rev/major ver/minor ver
/pmic0/pmic1/pmic2/pmic3 info either from early bootloaders or via other means
2) LK bootloader will check entries #10 for non-zero
value (set to zero for standard boot.img). If the
value is non-zero, refer to page section after
Expand All @@ -150,9 +209,27 @@ Android - Table of Device Tree
QCDT version)
5) LK scans through the QCDT table to look for matching
entry. Search order is:
1) platform ID exact match
2) variant ID exact match
3) select the highest soc rev in QCDT that is
1) msm ID exact match
2) Platform type exact match
3) subtype ID exact match
4) HLOS subtype exact match
5) Pmic0 model ID exact match
6) Pmic1 model ID exact match
7) Pmic2 model ID exact match
8) Pmic3 model ID exact match
9) foundry ID, look for exact match, if not found choose
device tree with foundry-id(0x0)
10) select the highest soc rev in QCDT that is
equal to or lower than the runtime detected soc rev
11) select the highest major&minor ver in QCDT that is
equal to or lower than the runtime detected major ver
12) select the highest pmic0 major&minor in QCDT that is
equal to or lower than the runtime detected pmic0
13) select the highest pmic1 major&minor in QCDT that is
equal to or lower than the runtime detected pmic1
14) select the highest pmic2 major&minor in QCDT that is
equal to or lower than the runtime detected pmic2
15) select the highest pmic3 major&minor in QCDT that is
equal to or lower than the runtime detected pmic3
6) Load the matching DTB blob to the tags addr
7) LK pass the correct DTB to the kernel
119 changes: 119 additions & 0 deletions init/init_msm8952.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
Copyright (c) 2015, The Linux Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdlib.h>
#include <fcntl.h>

#include "vendor_init.h"
#include "property_service.h"
#include "log.h"
#include "util.h"

#include "init_msm.h"

#define VIRTUAL_SIZE "/sys/class/graphics/fb0/virtual_size"
#define VERSION "/sys/devices/soc.0/1d00000.qcom,vidc/version"
#define BUF_SIZE 64

int get_version(int *version)
{
char buf[16];
int pos = 0, rv = 0, fd = -1;
long value = 0;
char *endptr = NULL;
int bytes_to_read = sizeof(buf);

fd = open(VERSION, O_RDONLY, 0660);
if (fd < 0) {
return -1;
}

do {
pos += rv;
if ((bytes_to_read - pos) <= 0)
break;
rv += read(fd, buf + pos, bytes_to_read - pos);
} while (rv > 0);

if (rv < 0) {
return -1;
}
buf[pos - 1] = '\0';
value = strtol(buf, &endptr, sizeof(long));
if (endptr == buf) {
return -1;
}
*version = (int)value;

return 1;
}

void init_msm_properties(unsigned long msm_id, unsigned long msm_ver, char *board_type)
{
char platform[PROP_VALUE_MAX];
int rc;
int version = 0;
unsigned long virtual_size = 0;
char str[BUF_SIZE];

UNUSED(msm_id);
UNUSED(msm_ver);
UNUSED(board_type);

rc = property_get("ro.board.platform", platform);
if (!rc || !ISMATCH(platform, ANDROID_TARGET)){
return;
}

rc = read_file2(VIRTUAL_SIZE, str, sizeof(str));
if (rc) {
virtual_size = strtoul(str, NULL, 0);
}

if(virtual_size >= 1080) {
property_set(PROP_LCDDENSITY, "480");
} else if (virtual_size >= 720) {
// For 720x1280 resolution
property_set(PROP_LCDDENSITY, "320");
} else if (virtual_size >= 480) {
// For 480x854 resolution QRD.
property_set(PROP_LCDDENSITY, "240");
} else
property_set(PROP_LCDDENSITY, "320");

if (msm_id == 266 || msm_id == 278 || msm_id == 277 || msm_id == 274) {
property_set("media.msm8956hw", "1");
property_set("media.settings.xml", "/etc/media_profiles_8956.xml");
get_version(&version);
if (version == 1)
property_set("media.msm8956.version", "1");
else
property_set("media.msm8956.version", "0");
}
}
14 changes: 14 additions & 0 deletions power/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ ifeq ($(call is-board-platform-in-list, msm8916), true)
LOCAL_SRC_FILES += power-8916.c
endif

ifeq ($(call is-board-platform-in-list, msm8952), true)
LOCAL_SRC_FILES += power-8952.c
endif

ifeq ($(call is-board-platform-in-list, apq8084), true)
LOCAL_SRC_FILES += power-8084.c
endif
Expand All @@ -58,6 +62,16 @@ LOCAL_CFLAGS += -DSET_INTERACTIVE_EXT
LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_SET_INTERACTIVE_EXT)
endif

ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
endif

ifeq ($(TARGET_POWER_SET_FEATURE_LIB),)
LOCAL_SRC_FILES += power-feature-default.c
else
LOCAL_STATIC_LIBRARIES += $(TARGET_POWER_SET_FEATURE_LIB)
endif

ifneq ($(CM_POWERHAL_EXTENSION),)
LOCAL_MODULE := power.$(CM_POWERHAL_EXTENSION)
else
Expand Down
20 changes: 5 additions & 15 deletions power/power-8084.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ static int display_hint2_sent;
static int first_display_off_hint;
extern int display_boost;

enum {
PROFILE_POWER_SAVE = 0,
PROFILE_BALANCED,
PROFILE_HIGH_PERFORMANCE
};
int get_number_of_profiles() {
return 3;
}

static int current_power_profile = PROFILE_BALANCED;

Expand Down Expand Up @@ -98,25 +96,17 @@ int power_hint_override(__attribute__((unused)) struct power_module *module,
power_hint_t hint, void *data)
{
if (hint == POWER_HINT_SET_PROFILE) {
set_power_profile((int)data);
set_power_profile(*(int32_t *)data);
return HINT_HANDLED;
}

if (hint == POWER_HINT_LOW_POWER) {
if (current_power_profile == PROFILE_POWER_SAVE) {
set_power_profile(PROFILE_BALANCED);
} else {
set_power_profile(PROFILE_POWER_SAVE);
}
}

// Skip other hints in custom power modes
if (current_power_profile != PROFILE_BALANCED) {
return HINT_HANDLED;
}

if (hint == POWER_HINT_CPU_BOOST) {
int duration = (int)data / 1000;
int duration = *(int32_t *)data / 1000;
int resources[] = { CPUS_ONLINE_MIN_2, 0x20B, 0x30B, 0x1C00};

if (duration > 0)
Expand Down
Loading