Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
74 changes: 74 additions & 0 deletions Documentation/devicetree/bindings/iio/light/dynaimage,ap3216c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/light/dynaimage,ap3216c.yaml#
$schema: http://devicetree.org/schemas/meta-schemas/core.yaml#

title: DynaImage AP3216C / AP3426 Ambient Light and Proximity Sensor

maintainers:
- Vladislav Dubrovin <foxy9855@gmail.com>

description: |
DynaImage AP3216C and AP3426 are integrated digital ambient light,
proximity, and IR sensor.

Specifications about the devices can be found at:
https://github.com/RT-Thread-packages/ap3216c/blob/master/ap3216c_datasheet.pdf

properties:
compatible:
oneOf:
- items:
- const: dynaimage,ap3426
- const: dynaimage,ap3216c
- enum:
- dynaimage,ap3216c
- dynaimage,ap3426

reg:
maxItems: 1

interrupts:
maxItems: 1

vdd-supply:
description: Regulator powering the sensor VDD pin.

vddio-supply:
description: Regulator powering the sensor VDDIO pin.

proximity-near-level:
$ref: /schemas/types.yaml#/definitions/uint32
description:
Raw proximity threshold level above which an object is considered "near".
default: 300

required:
- compatible
- reg

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>

i2c {
#address-cells = <1>;
#size-cells = <0>;

light-sensor@1e {
compatible = "dynaimage,ap3426", "dynaimage,ap3216c";
reg = <0x1e>;

interrupt-parent = <&tlmm>;
interrupts = <113 IRQ_TYPE_EDGE_FALLING>;
vdd-supply = <&pm8916_l17>;
vddio-supply = <&pm8916_l6>;
proximity-near-level = <300>;

pinctrl-0 = <&als_int_default>;
pinctrl-names = "default";
};
};
97 changes: 76 additions & 21 deletions arch/arm64/boot/dts/qcom/msm8916-asus-z010d.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/leds/common.h>

/ {
Expand All @@ -26,51 +28,50 @@

gpio-keys {
compatible = "gpio-keys";
label = "GPIO Buttons";

pinctrl-0 = <&gpio_keys_default>;
pinctrl-names = "default";

label = "GPIO Buttons";

volume-up-button {
label = "Volume Up";
gpios = <&tlmm 107 GPIO_ACTIVE_LOW>;
linux,code = <KEY_VOLUMEUP>;
gpios = <&tlmm 107 GPIO_ACTIVE_LOW>;
debounce-interval = <15>;
};
};

gpio-hall-sensor {
compatible = "gpio-keys";
label = "GPIO Hall Effect Sensor";

pinctrl-0 = <&gpio_hall_sensor_default>;
pinctrl-names = "default";

label = "GPIO Hall Effect Sensor";

hall-sensor-switch {
label = "Hall Effect Sensor";
gpios = <&tlmm 115 GPIO_ACTIVE_LOW>;
linux,input-type = <EV_SW>;
linux,code = <SW_LID>;
linux,can-disable;
gpios = <&tlmm 115 GPIO_ACTIVE_LOW>;
};
};

speaker_amp: audio-amplifier {
compatible = "awinic,aw8738";
sound-name-prefix = "Speaker Amp";
mode-gpios = <&tlmm 112 GPIO_ACTIVE_HIGH>;

pinctrl-0 = <&spk_ext_pa_default>;
pinctrl-names = "default";

mode-gpios = <&tlmm 112 GPIO_ACTIVE_HIGH>;
awinic,mode = <2>;
sound-name-prefix = "Speaker Amp";
};

usb_id: usb-id {
compatible = "linux,extcon-usb-gpio";
id-gpios = <&tlmm 110 GPIO_ACTIVE_HIGH>;

pinctrl-0 = <&usb_id_default>;
pinctrl-names = "default";
};
Expand All @@ -89,6 +90,10 @@
vdd-supply = <&pm8916_l17>;
vddio-supply = <&pm8916_l6>;

mount-matrix = "-1", "0", "0",
"0", "-1", "0",
"0", "0", "1";

pinctrl-0 = <&accel_int_default>;
pinctrl-names = "default";
};
Expand All @@ -97,15 +102,28 @@
compatible = "asahi-kasei,ak09911";
reg = <0x0c>;

reset-gpios = <&tlmm 36 GPIO_ACTIVE_LOW>;
vdd-supply = <&pm8916_l17>;
vid-supply = <&pm8916_l6>;

reset-gpios = <&tlmm 36 GPIO_ACTIVE_LOW>;

pinctrl-0 = <&mag_reset_default>;
pinctrl-names = "default";
};

light-sensor@1e {
compatible = "dynaimage,ap3426", "dynaimage,ap3216c";
reg = <0x1e>;

interrupt-parent = <&tlmm>;
interrupts = <113 IRQ_TYPE_EDGE_FALLING>;
vdd-supply = <&pm8916_l17>;
vddio-supply = <&pm8916_l6>;
proximity-near-level = <300>;

pinctrl-0 = <&als_int_default>;
pinctrl-names = "default";
};

led-controller@45 {
compatible = "awinic,aw2013";
reg = <0x45>;
Expand All @@ -117,16 +135,39 @@

led@0 {
reg = <0>;
led-max-microamp = <5000>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_GREEN>;
led-max-microamp = <5000>;
};

led@1 {
reg = <1>;
led-max-microamp = <5000>;
function = LED_FUNCTION_INDICATOR;
color = <LED_COLOR_ID_RED>;
led-max-microamp = <5000>;
};
};
};

&blsp_i2c4 {
status = "okay";

charger@14 {
compatible = "qcom,smb1360";
reg = <0x14>;

interrupt-parent = <&tlmm>;
interrupts = <62 IRQ_TYPE_LEVEL_LOW>;

qcom,float-voltage-mv = <4380>;
qcom,iterm-ma = <200>;
qcom,recharge-thresh-mv = <100>;

pinctrl-0 = <&smb1360_default>;
pinctrl-names = "default";

usb-otg-vbus {
regulator-name = "smb1360_otg_vreg";
};
};
Comment thread
FoxWind-coder marked this conversation as resolved.
};
Expand All @@ -142,11 +183,10 @@
interrupt-parent = <&tlmm>;
interrupts = <13 IRQ_TYPE_EDGE_FALLING>;

reset-gpios = <&tlmm 12 GPIO_ACTIVE_LOW>;
vcc-supply = <&pm8916_l17>;
iovcc-supply = <&pm8916_l6>;

reset-gpios = <&tlmm 12 GPIO_ACTIVE_LOW>;

touchscreen-size-x = <720>;
touchscreen-size-y = <1280>;

Expand Down Expand Up @@ -176,8 +216,8 @@
compatible = "asus,z010d-r69339";
reg = <0>;

power-supply = <&pm8916_l17>;
reset-gpios = <&tlmm 25 GPIO_ACTIVE_LOW>;
power-supply = <&pm8916_l17>;

port {
panel_in: endpoint {
Expand Down Expand Up @@ -228,21 +268,18 @@
};

&sdhc_2 {
cd-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;

pinctrl-0 = <&sdc2_default &sdc2_cd_default>;
pinctrl-1 = <&sdc2_sleep &sdc2_cd_default>;
pinctrl-names = "default", "sleep";

cd-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;

status = "okay";
};

&sound {
model = "bq-paella";
widgets =
"Speaker", "Speaker",
"Headphone", "Headphones";
pin-switches = "Speaker";

audio-routing =
"Speaker", "Speaker Amp OUT",
"Speaker Amp IN", "HPH_R",
Expand All @@ -252,6 +289,10 @@
"AMIC2", "MIC BIAS Internal2",
"AMIC3", "MIC BIAS Internal3";
aux-devs = <&speaker_amp>;
pin-switches = "Speaker";
widgets =
"Speaker", "Speaker",
"Headphone", "Headphones";
};

&usb {
Expand Down Expand Up @@ -284,6 +325,20 @@
};

&tlmm {
als_int_default: als-int-default-state {
pins = "gpio113";
function = "gpio";
drive-strength = <2>;
bias-disable;
};

smb1360_default: smb1360-default-state {
pins = "gpio62";
function = "gpio";
drive-strength = <2>;
bias-pull-up;
};

accel_int_default: accel-int-default-state {
pins = "gpio114";
function = "gpio";
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/msm8916_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,4 @@ CONFIG_DYNAMIC_DEBUG=y
CONFIG_MAGIC_SYSRQ=y
CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x0
CONFIG_DEBUG_FS=y
CONFIG_AP3216C=m
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ static int r69339_on(struct r69339 *ctx)
{
struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };

mipi_dsi_dcs_set_display_brightness_multi(&dsi_ctx, 0x0001);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY,
0x24);
mipi_dsi_dcs_set_display_brightness_multi(&dsi_ctx, 0xffff); /* awake brightness quickfix */
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x24);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_POWER_SAVE, 0x00);

mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 20);
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); /*changed awake direction */

mipi_dsi_msleep(&dsi_ctx, 150);
Comment thread
FoxWind-coder marked this conversation as resolved.

return dsi_ctx.accum_err;
Expand Down
10 changes: 10 additions & 0 deletions drivers/iio/light/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ config AL3320A
To compile this driver as a module, choose M here: the
module will be called al3320a.

config AP3216C
tristate "AP3216C/AP3426 ambient light sensor"
depends on I2C
help
Say Y here if you want to build a driver for the Dynaimage
AP3216C or AP3426 ambient light and proximity sensor.

To compile this driver as a module, choose M here: the
module will be called ap3216c.

config APDS9160
tristate "APDS9160 combined als and proximity sensor"
depends on I2C
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/light/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ obj-$(CONFIG_ADUX1020) += adux1020.o
obj-$(CONFIG_AL3000A) += al3000a.o
obj-$(CONFIG_AL3010) += al3010.o
obj-$(CONFIG_AL3320A) += al3320a.o
obj-$(CONFIG_AP3216C) += ap3216c.o
obj-$(CONFIG_APDS9160) += apds9160.o
obj-$(CONFIG_APDS9300) += apds9300.o
obj-$(CONFIG_APDS9306) += apds9306.o
Expand Down
Loading
Loading