diff options
author | Erik Staats <estaats@google.com> | 2017-11-06 16:47:20 -0800 |
---|---|---|
committer | Erik Staats <estaats@google.com> | 2017-11-06 16:49:22 -0800 |
commit | e7d3e4757dc32f72c6a71425224b37e2aade60fc (patch) | |
tree | 50d6ca331f26967572a28311a0d797e188d265d8 | |
parent | f3306053a56473b80764fd691bbb05bc7806c38b (diff) | |
download | bonito-e7d3e4757dc32f72c6a71425224b37e2aade60fc.tar.gz |
Add EdgeSense LDO power initialization.
Bug: 68950393
Test: Verified that the Max11259 sensor is being enumerated and works. See
details in testing done comment in
https://googleplex-android-review.git.corp.google.com/3175117 .
Change-Id: Id7cacdbae1f85b0c06dd193cca990271631ab0b2
-rw-r--r-- | device.mk | 5 | ||||
-rw-r--r-- | init.edge_sense.sh | 113 | ||||
-rw-r--r-- | init.qcom.devstart.sh | 4 |
3 files changed, 122 insertions, 0 deletions
@@ -70,6 +70,11 @@ PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/thermal-engine-crosshatch.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine-crosshatch.conf \ $(LOCAL_PATH)/thermal-engine-crosshatch-vr.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine-crosshatch-vr.conf +# Edge Sense initialization script. +# TODO: b/67205273 +PRODUCT_COPY_FILES += \ + $(LOCAL_PATH)/init.edge_sense.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.edge_sense.sh + ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/init.hardware.diag.rc.userdebug:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.$(PRODUCT_PLATFORM).diag.rc diff --git a/init.edge_sense.sh b/init.edge_sense.sh new file mode 100644 index 00000000..8c3d9ce0 --- /dev/null +++ b/init.edge_sense.sh @@ -0,0 +1,113 @@ +#!/vendor/bin/sh +# +# edge_sense_init.sh [<power chip name>] [<power gpio number>] +# +# Initialize Edge Sense. If needed, power it up using the power controller chip +# specified by [<power chip name>] and power GPIO specified by +# [<power gpio number>]. +# +# [<power chip name>] Name of chip (e.g., "pm8998") controlling Edge Sense +# power. +# [<power gpio number>] GPIO number controlling Edge Sens power (e.g., 2). +# +# [<power chip name>] and [<power gpio number>] default to values appropriate +# for the type and version of device. +# +# TODO: b/67205273 +# The Edge Sense should only be powered up when it's in use. +# Ideally, this would be done in the Edge Sense SLPI driver, but it +# doesn't have direct access to the PM8998 GPIOs. +# As an alternative, the Elmyra Edge Sense sensor HAL driver could power +# up the Edge Sense or act as a GPIO proxy for the SLPI driver. +# + +# Check for default values. +if [ "${#}" -eq 0 ]; then + use_defaults=1 +else + use_defaults=0 +fi + +# Get the program name. +prog_name=$(basename ${0}) + +# Read the power chip name. +chip_name=${1} + +# Read the power gpio number. +gpio_num=${2} + +# Get the hardware platform and platform version. +hw_platform=`cat /sys/devices/soc0/hw_platform` +platform_version=`cat /sys/devices/soc0/platform_version` + +# If using default values, check if platform needs Edge Sense to be initialized. +if [ ${use_defaults} -ne 0 ]; then + if [ "${hw_platform}" != "OEM" ] || \ + [ "${platform_version}" == "65538" ]; then + log -t "${prog_name}" "Platform \"${hw_platform}\" version" \ + "${platform_version} does not need Edge Sense to be initialized." + exit + fi +fi + +# Set default values if using them. +if [ ${use_defaults} -ne 0 ]; then + chip_name=pm8998 + gpio_num=2 +fi + +# Validate chip name and gpio number. +if [ -z ${chip_name} ]; then + log -t "${prog_name}" "Chip name not specified." + exit 1 +fi +if [ -z ${gpio_num} ]; then + log -t "${prog_name}" "GPIO number not specified." + exit 1 +fi + +# Find the GPIO pin control device node for the power chip. +pinctrl=`find /sys/devices -name "*${chip_name}*pinctrl*"` +if [ -z ${pinctrl} ]; then + log -t "${prog_name}" "Power chip \"${chip_name}\" not found." + exit 1 +fi + +# Find the GPIO index within the chip GPIO interrupt name list. This will be +# the GPIO index offset from the chip GPIO index base. +found=0 +gpio_name=gpio${gpio_num} +gpio_index_off=0 +while IFS= read -d '' name; do + # Check for a match. + if [ "${name%${gpio_name}}" != "${name}" ]; then + found=1 + break + fi + + # Check next GPIO index. + gpio_index_off=$((${gpio_index_off} + 1)) +done < ${pinctrl}/of_node/interrupt-names +if [ ${found} -eq 0 ]; then + log -t "${prog_name}" "GPIO ${gpio_num} on chip \"${chip_name}\" not found." + exit 1 +fi + +# Find the chip GPIO base index. +base_file=`find ${pinctrl} -name base` +gpio_index_base=`cat ${base_file}` + +# Get the GPIO index. +gpio_index=$((${gpio_index_base} + ${gpio_index_off})) + +# Export the GPIO. +echo ${gpio_index} > /sys/class/gpio/export + +# Set the GPIO direction to out. +echo out > /sys/class/gpio/gpio${gpio_index}/direction + +# Set the GPIO high. +echo 1 > /sys/class/gpio/gpio${gpio_index}/value + + diff --git a/init.qcom.devstart.sh b/init.qcom.devstart.sh index 3589ac22..05a6a589 100644 --- a/init.qcom.devstart.sh +++ b/init.qcom.devstart.sh @@ -1,5 +1,9 @@ #! /vendor/bin/sh +# Initialize Edge Sense. +# TODO: b/67205273 +/vendor/bin/init.edge_sense.sh + echo 1 > /sys/kernel/boot_adsp/boot echo 1 > /sys/kernel/boot_slpi/boot setprop sys.qcom.devup 1 |