mirror of
https://github.com/clockworkpi/DevTerm.git
synced 2025-12-12 18:28:50 +01:00
1237 lines
32 KiB
Diff
1237 lines
32 KiB
Diff
diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile
|
|
index 9863b50ad6da..4ec57b4a087f 100644
|
|
--- a/arch/arm/boot/dts/overlays/Makefile
|
|
+++ b/arch/arm/boot/dts/overlays/Makefile
|
|
@@ -27,6 +27,11 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
|
|
audremap.dtbo \
|
|
balena-fin.dtbo \
|
|
bmp085_i2c-sensor.dtbo \
|
|
+ devterm-bt.dtbo \
|
|
+ devterm-misc.dtbo \
|
|
+ devterm-panel.dtbo \
|
|
+ devterm-pmu.dtbo \
|
|
+ devterm-wifi.dtbo \
|
|
dht11.dtbo \
|
|
dionaudio-loco.dtbo \
|
|
dionaudio-loco-v2.dtbo \
|
|
diff --git a/arch/arm/boot/dts/overlays/devterm-bt-overlay.dts b/arch/arm/boot/dts/overlays/devterm-bt-overlay.dts
|
|
new file mode 100755
|
|
index 000000000000..4b634fdd3bda
|
|
--- /dev/null
|
|
+++ b/arch/arm/boot/dts/overlays/devterm-bt-overlay.dts
|
|
@@ -0,0 +1,40 @@
|
|
+/dts-v1/;
|
|
+/plugin/;
|
|
+
|
|
+/{
|
|
+ compatible = "brcm,bcm2835";
|
|
+
|
|
+ fragment@0 {
|
|
+ target = <&uart0>;
|
|
+ __overlay__ {
|
|
+ pinctrl-names = "default";
|
|
+ pinctrl-0 = <&uart0_pins &bt_pins>;
|
|
+ status = "okay";
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@1 {
|
|
+ target = <&gpio>;
|
|
+ __overlay__ {
|
|
+ uart0_pins: uart0_pins {
|
|
+ brcm,pins = <14 15 16 17>;
|
|
+ brcm,function = <4 4 7 7>;
|
|
+ brcm,pull = <0 2 0 2>;
|
|
+ };
|
|
+
|
|
+ bt_pins: bt_pins {
|
|
+ brcm,pins = <5 6 7>;
|
|
+ brcm,function = <1 0 1>;
|
|
+ brcm,pull = <0 2 0>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@2 {
|
|
+ target-path = "/aliases";
|
|
+ __overlay__ {
|
|
+ serial1 = "/soc/serial@7e201000";
|
|
+ serial0 = "/soc/serial@7e215040";
|
|
+ };
|
|
+ };
|
|
+};
|
|
diff --git a/arch/arm/boot/dts/overlays/devterm-misc-overlay.dts b/arch/arm/boot/dts/overlays/devterm-misc-overlay.dts
|
|
new file mode 100644
|
|
index 000000000000..84413870bf4c
|
|
--- /dev/null
|
|
+++ b/arch/arm/boot/dts/overlays/devterm-misc-overlay.dts
|
|
@@ -0,0 +1,94 @@
|
|
+/dts-v1/;
|
|
+/plugin/;
|
|
+
|
|
+/{
|
|
+ compatible = "brcm,bcm2835";
|
|
+
|
|
+ fragment@0 {
|
|
+ target = <&pwm>;
|
|
+ __overlay__ {
|
|
+ pinctrl-names = "default";
|
|
+ pinctrl-0 = <&pwm_pins>;
|
|
+ assigned-clock-rates = <100000000>;
|
|
+ status = "okay";
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@1 {
|
|
+ target = <&i2c1>;
|
|
+ __overlay__ {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
+ pinctrl-names = "default";
|
|
+ pinctrl-0 = <&i2c1_pins>;
|
|
+ status = "okay";
|
|
+
|
|
+ adc101c: adc@54 {
|
|
+ reg = <0x54>;
|
|
+ compatible = "ti,adc101c";
|
|
+ status = "okay";
|
|
+ };
|
|
+
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@2 {
|
|
+ target = <&spi0>;
|
|
+ __overlay__ {
|
|
+ pinctrl-names = "default";
|
|
+ pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
|
|
+ cs-gpios = <&gpio 35 1>;
|
|
+ status = "okay";
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@3 {
|
|
+ target = <&uart1>;
|
|
+ __overlay__ {
|
|
+ pinctrl-names = "default";
|
|
+ pinctrl-0 = <&uart1_pins>;
|
|
+ status = "okay";
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@4 {
|
|
+ target = <&gpio>;
|
|
+ __overlay__ {
|
|
+
|
|
+ pwm_pins: pwm_pins {
|
|
+ brcm,pins = <12 13>;
|
|
+ brcm,function = <4>;
|
|
+ };
|
|
+
|
|
+ i2c1_pins: i2c1 {
|
|
+ brcm,pins = <44 45>;
|
|
+ brcm,function = <6>;
|
|
+ };
|
|
+
|
|
+ spi0_pins: spi0_pins {
|
|
+ brcm,pins = <38 39>;
|
|
+ brcm,function = <4>;
|
|
+ };
|
|
+
|
|
+ spi0_cs_pins: spi0_cs_pins {
|
|
+ brcm,pins = <35>;
|
|
+ brcm,function = <1>;
|
|
+ };
|
|
+
|
|
+ uart1_pins: uart1_pins {
|
|
+ brcm,pins = <32 33>;
|
|
+ brcm,function = <2>;
|
|
+ brcm,pull = <0 2>;
|
|
+ };
|
|
+
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@5 {
|
|
+ target-path = "/chosen";
|
|
+ __overlay__ {
|
|
+ bootargs = "8250.nr_uarts=1";
|
|
+ };
|
|
+ };
|
|
+
|
|
+};
|
|
diff --git a/arch/arm/boot/dts/overlays/devterm-panel-overlay.dts b/arch/arm/boot/dts/overlays/devterm-panel-overlay.dts
|
|
new file mode 100644
|
|
index 000000000000..7d9ff963f309
|
|
--- /dev/null
|
|
+++ b/arch/arm/boot/dts/overlays/devterm-panel-overlay.dts
|
|
@@ -0,0 +1,46 @@
|
|
+/dts-v1/;
|
|
+/plugin/;
|
|
+
|
|
+/ {
|
|
+ compatible = "brcm,bcm2835";
|
|
+
|
|
+ fragment@0 {
|
|
+ target=<&dsi1>;
|
|
+ __overlay__ {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
+ status = "okay";
|
|
+
|
|
+ port {
|
|
+ dsi_out_port: endpoint {
|
|
+ remote-endpoint = <&panel_dsi_port>;
|
|
+ };
|
|
+ };
|
|
+
|
|
+ panel_cwd686: panel@0 {
|
|
+ compatible = "cw,cwd686";
|
|
+ reg = <0>;
|
|
+ reset-gpio = <&gpio 8 1>;
|
|
+ backlight = <&ocp8178_backlight>;
|
|
+
|
|
+ port {
|
|
+ panel_dsi_port: endpoint {
|
|
+ remote-endpoint = <&dsi_out_port>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@1 {
|
|
+ target-path = "/";
|
|
+ __overlay__ {
|
|
+ ocp8178_backlight: backlight@0 {
|
|
+ compatible = "ocp8178-backlight";
|
|
+ backlight-control-gpios = <&gpio 9 0>;
|
|
+ default-brightness = <5>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+};
|
|
diff --git a/arch/arm/boot/dts/overlays/devterm-pmu-overlay.dts b/arch/arm/boot/dts/overlays/devterm-pmu-overlay.dts
|
|
new file mode 100644
|
|
index 000000000000..45f730e0e757
|
|
--- /dev/null
|
|
+++ b/arch/arm/boot/dts/overlays/devterm-pmu-overlay.dts
|
|
@@ -0,0 +1,124 @@
|
|
+/dts-v1/;
|
|
+/plugin/;
|
|
+
|
|
+/ {
|
|
+ compatible = "brcm,bcm2835";
|
|
+
|
|
+ fragment@0 {
|
|
+ target = <&i2c0>;
|
|
+ __overlay__ {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
+ pinctrl-0 = <&i2c0_pins>;
|
|
+ pinctrl-names = "default";
|
|
+ status = "okay";
|
|
+
|
|
+ axp22x: pmic@34 {
|
|
+ interrupt-controller;
|
|
+ #interrupt-cells = <1>;
|
|
+ compatible = "x-powers,axp221";
|
|
+ reg = <0x34>; /* i2c address */
|
|
+ interrupt-parent = <&gpio>;
|
|
+ interrupts = <2 8>; /* IRQ_TYPE_EDGE_FALLING */
|
|
+ irq-gpios = <&gpio 2 0>;
|
|
+
|
|
+ regulators {
|
|
+
|
|
+ x-powers,dcdc-freq = <3000>;
|
|
+
|
|
+ reg_aldo1: aldo1 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "audio-vdd";
|
|
+ };
|
|
+
|
|
+ reg_aldo2: aldo2 {
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "display-vcc";
|
|
+ };
|
|
+
|
|
+ reg_aldo3: aldo3 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "wifi-vdd";
|
|
+ };
|
|
+
|
|
+ reg_dldo1: dldo1 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "wifi-vcc1";
|
|
+ };
|
|
+
|
|
+ reg_dldo2: dldo2 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "dldo2";
|
|
+ };
|
|
+
|
|
+ reg_dldo3: dldo3 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "dldo3";
|
|
+ };
|
|
+
|
|
+ reg_dldo4: dldo4 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "dldo4";
|
|
+ };
|
|
+
|
|
+ reg_eldo1: eldo1 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "wifi-vcc2";
|
|
+ };
|
|
+
|
|
+ reg_eldo2: eldo2 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "wifi-vcc3";
|
|
+ };
|
|
+
|
|
+ reg_eldo3: eldo3 {
|
|
+ regulator-always-on;
|
|
+ regulator-min-microvolt = <3300000>;
|
|
+ regulator-max-microvolt = <3300000>;
|
|
+ regulator-name = "wifi-vcc4";
|
|
+ };
|
|
+
|
|
+ };
|
|
+
|
|
+ battery_power_supply: battery-power-supply {
|
|
+ compatible = "x-powers,axp221-battery-power-supply";
|
|
+ monitored-battery = <&battery>;
|
|
+ };
|
|
+
|
|
+ usb_power_supply: usb_power_supply {
|
|
+ compatible = "x-powers,axp221-usb-power-supply";
|
|
+ };
|
|
+
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@1 {
|
|
+ target-path = "/";
|
|
+ __overlay__ {
|
|
+ battery: battery@0 {
|
|
+ compatible = "simple-battery";
|
|
+ constant_charge_current_max_microamp = <2100000>;
|
|
+ voltage-min-design-microvolt = <3300000>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+};
|
|
diff --git a/arch/arm/boot/dts/overlays/devterm-wifi-overlay.dts b/arch/arm/boot/dts/overlays/devterm-wifi-overlay.dts
|
|
new file mode 100644
|
|
index 000000000000..d5da786dc445
|
|
--- /dev/null
|
|
+++ b/arch/arm/boot/dts/overlays/devterm-wifi-overlay.dts
|
|
@@ -0,0 +1,41 @@
|
|
+/dts-v1/;
|
|
+/plugin/;
|
|
+
|
|
+/* Enable SDIO from MMC interface via various GPIO groups */
|
|
+
|
|
+/{
|
|
+ compatible = "brcm,bcm2835";
|
|
+
|
|
+ fragment@0 {
|
|
+ target = <&mmc>;
|
|
+ sdio_ovl: __overlay__ {
|
|
+ pinctrl-0 = <&sdio_ovl_pins>;
|
|
+ pinctrl-names = "default";
|
|
+ non-removable;
|
|
+ bus-width = <4>;
|
|
+ status = "okay";
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@1 {
|
|
+ target = <&gpio>;
|
|
+ __overlay__ {
|
|
+ sdio_ovl_pins: sdio_ovl_pins {
|
|
+ brcm,pins = <22 23 24 25 26 27>;
|
|
+ brcm,function = <7>; /* ALT3 = SD1 */
|
|
+ brcm,pull = <0 2 2 2 2 2>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+ fragment@2 {
|
|
+ target-path = "/";
|
|
+ __overlay__ {
|
|
+ wifi_pwrseq: wifi-pwrseq {
|
|
+ compatible = "mmc-pwrseq-simple";
|
|
+ reset-gpios = <&gpio 3 0>;
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+
|
|
+};
|
|
diff --git a/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts b/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
|
|
index c5f687e8bcb9..d01d5e5d7810 100644
|
|
--- a/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
|
|
+++ b/arch/arm/boot/dts/overlays/vc4-kms-v3d-overlay.dts
|
|
@@ -141,12 +141,20 @@
|
|
};
|
|
};
|
|
|
|
+ fragment@18 {
|
|
+ target-path = "/chosen";
|
|
+ __dormant__ {
|
|
+ bootargs = "cma=384M";
|
|
+ };
|
|
+ };
|
|
+
|
|
__overrides__ {
|
|
- cma-256 = <0>,"+0-1-2-3-4";
|
|
- cma-192 = <0>,"-0+1-2-3-4";
|
|
- cma-128 = <0>,"-0-1+2-3-4";
|
|
- cma-96 = <0>,"-0-1-2+3-4";
|
|
- cma-64 = <0>,"-0-1-2-3+4";
|
|
+ cma-256 = <0>,"+0-1-2-3-4-18";
|
|
+ cma-192 = <0>,"-0+1-2-3-4-18";
|
|
+ cma-128 = <0>,"-0-1+2-3-4-18";
|
|
+ cma-96 = <0>,"-0-1-2+3-4-18";
|
|
+ cma-64 = <0>,"-0-1-2-3+4-18";
|
|
+ cma-384 = <0>,"-0-1-2-3-4+18";
|
|
audio = <0>,"!17";
|
|
};
|
|
};
|
|
diff --git a/arch/arm/configs/bcm2709_defconfig b/arch/arm/configs/bcm2709_defconfig
|
|
index 4fd6bcc8b2bb..b9fbb84c8811 100644
|
|
--- a/arch/arm/configs/bcm2709_defconfig
|
|
+++ b/arch/arm/configs/bcm2709_defconfig
|
|
@@ -676,7 +676,7 @@ CONFIG_I2C_MUX=m
|
|
CONFIG_I2C_MUX_GPMUX=m
|
|
CONFIG_I2C_MUX_PCA954x=m
|
|
CONFIG_I2C_BCM2708=m
|
|
-CONFIG_I2C_BCM2835=m
|
|
+CONFIG_I2C_BCM2835=y
|
|
CONFIG_I2C_GPIO=m
|
|
CONFIG_I2C_ROBOTFUZZ_OSIF=m
|
|
CONFIG_I2C_TINY_USB=m
|
|
@@ -1468,3 +1468,15 @@ CONFIG_FUNCTION_PROFILER=y
|
|
CONFIG_KGDB=y
|
|
CONFIG_KGDB_KDB=y
|
|
CONFIG_KDB_KEYBOARD=y
|
|
+
|
|
+CONFIG_AXP20X_ADC=m
|
|
+CONFIG_AXP20X_POWER=m
|
|
+CONFIG_BATTERY_AXP20X=m
|
|
+CONFIG_CHARGER_AXP20X=m
|
|
+CONFIG_INPUT_AXP20X_PEK=y
|
|
+CONFIG_MFD_AXP20X=y
|
|
+CONFIG_MFD_AXP20X_I2C=y
|
|
+CONFIG_REGULATOR_AXP20X=y
|
|
+CONFIG_BACKLIGHT_OCP8178=y
|
|
+CONFIG_DRM_PANEL_CWD686=m
|
|
+CONFIG_TI_ADC081C=m
|
|
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
|
|
index 6020c30a33b3..1a0f8d87c7db 100644
|
|
--- a/drivers/gpu/drm/panel/Kconfig
|
|
+++ b/drivers/gpu/drm/panel/Kconfig
|
|
@@ -186,4 +186,17 @@ config DRM_PANEL_SITRONIX_ST7789V
|
|
Say Y here if you want to enable support for the Sitronix
|
|
ST7789V controller for 240x320 LCD panels
|
|
|
|
+
|
|
+config DRM_PANEL_CWD686
|
|
+ tristate "CWD686 panel"
|
|
+ depends on OF
|
|
+ depends on DRM_MIPI_DSI
|
|
+ depends on BACKLIGHT_CLASS_DEVICE
|
|
+ help
|
|
+ Say Y here if you want to enable support for CWD686 panel.
|
|
+ The panel has a 480x1280 resolution and uses 24 bit RGB per pixel.
|
|
+
|
|
+ To compile this driver as a module, choose M here: the module
|
|
+ will be called panel-cwd686.
|
|
+
|
|
endmenu
|
|
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
|
|
index 5ccaaa9d13af..52859d54b0f9 100644
|
|
--- a/drivers/gpu/drm/panel/Makefile
|
|
+++ b/drivers/gpu/drm/panel/Makefile
|
|
@@ -19,3 +19,4 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) += panel-seiko-43wvf1g.o
|
|
obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
|
|
obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
|
|
obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
|
|
+obj-$(CONFIG_DRM_PANEL_CWD686) += panel-cwd686.o
|
|
diff --git a/drivers/gpu/drm/panel/panel-cwd686.c b/drivers/gpu/drm/panel/panel-cwd686.c
|
|
new file mode 100644
|
|
index 000000000000..6b6969f29f62
|
|
--- /dev/null
|
|
+++ b/drivers/gpu/drm/panel/panel-cwd686.c
|
|
@@ -0,0 +1,295 @@
|
|
+// SPDX-License-Identifier: GPL-2.0
|
|
+
|
|
+#include <linux/backlight.h>
|
|
+#include <linux/gpio/consumer.h>
|
|
+#include <linux/regulator/consumer.h>
|
|
+
|
|
+#include <video/mipi_display.h>
|
|
+
|
|
+#include <drm/drmP.h>
|
|
+#include <drm/drm_mipi_dsi.h>
|
|
+#include <drm/drm_panel.h>
|
|
+
|
|
+
|
|
+struct cwd686 {
|
|
+ struct device *dev;
|
|
+ struct drm_panel panel;
|
|
+ struct gpio_desc *reset_gpio;
|
|
+ struct regulator *supply;
|
|
+ struct backlight_device *backlight;
|
|
+ bool prepared;
|
|
+ bool enabled;
|
|
+};
|
|
+
|
|
+static const struct drm_display_mode default_mode = {
|
|
+ .clock = 54465,
|
|
+ .hdisplay = 480,
|
|
+ .hsync_start = 480 + 150,
|
|
+ .hsync_end = 480 + 150 + 24,
|
|
+ .htotal = 480 + 150 + 24 + 40,
|
|
+ .vdisplay = 1280,
|
|
+ .vsync_start = 1280 + 12,
|
|
+ .vsync_end = 1280 + 12+ 6,
|
|
+ .vtotal = 1280 + 12 + 6 + 10,
|
|
+ .vrefresh = 60,
|
|
+ .flags = 0,
|
|
+};
|
|
+
|
|
+static inline struct cwd686 *panel_to_cwd686(struct drm_panel *panel)
|
|
+{
|
|
+ return container_of(panel, struct cwd686, panel);
|
|
+}
|
|
+
|
|
+#define dcs_write_seq(seq...) \
|
|
+({ \
|
|
+ static const u8 d[] = { seq }; \
|
|
+ mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); \
|
|
+})
|
|
+
|
|
+static void cwd686_init_sequence(struct cwd686 *ctx)
|
|
+{
|
|
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
|
|
+
|
|
+ dcs_write_seq(0xF0,0x5A,0x5A);
|
|
+ dcs_write_seq(0xF1,0xA5,0xA5);
|
|
+ dcs_write_seq(0xB6,0x0D,0x0D);
|
|
+ dcs_write_seq(0xB4,0x0A,0x08,0x12,0x10,0x0E,0x0C,0x00,0x00,0x00,0x03,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x04,0x06);
|
|
+ dcs_write_seq(0xB3,0x0B,0x09,0x13,0x11,0x0F,0x0D,0x00,0x00,0x00,0x03,0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x05,0x07);
|
|
+ dcs_write_seq(0xB0,0x54,0x32,0x23,0x45,0x44,0x44,0x44,0x44,0x90,0x01,0x90,0x01);
|
|
+ dcs_write_seq(0xB1,0x32,0x84,0x02,0x83,0x30,0x01,0x6B,0x01);
|
|
+ dcs_write_seq(0xB2,0x73);
|
|
+ dcs_write_seq(0xBD,0x4E,0x0E,0x50,0x50,0x26,0x1D,0x00,0x14,0x42,0x03);
|
|
+ dcs_write_seq(0xB7,0x01,0x01,0x09,0x11,0x0D,0x55,0x19,0x19,0x21,0x1D,0x00,0x00,0x00,0x00,0x02,0xFF,0x3C);
|
|
+ dcs_write_seq(0xB8,0x23,0x01,0x30,0x34,0x63);
|
|
+ dcs_write_seq(0xB9,0xA0,0x22,0x00,0x44);
|
|
+ dcs_write_seq(0xBA,0x12,0x63);
|
|
+ dcs_write_seq(0xC1,0x0C,0x16,0x04,0x0C,0x10,0x04);
|
|
+ dcs_write_seq(0xC2,0x11,0x41);
|
|
+ dcs_write_seq(0xC3,0x22,0x31,0x04);
|
|
+ dcs_write_seq(0xC7,0x05,0x23,0x6B,0x49,0x00);
|
|
+ dcs_write_seq(0xC5,0x00);
|
|
+ dcs_write_seq(0xD0,0x37,0xFF,0xFF);
|
|
+ dcs_write_seq(0xD2,0x63,0x0B,0x08,0x88);
|
|
+ dcs_write_seq(0xD3,0x01,0x00,0x00,0x01,0x01,0x37,0x25,0x38,0x31,0x06,0x07);
|
|
+ dcs_write_seq(0xC8,0x7C,0x6A,0x5D,0x53,0x53,0x45,0x4B,0x35,0x4D,0x4A,0x49,0x66,0x53,0x57,0x4A,0x48,0x3B,0x2A,0x06,0x7C,0x6A,0x5D,0x53,0x53,0x45,0x4B,0x35,0x4D,0x4A,0x49,0x66,0x53,0x57,0x4A,0x48,0x3B,0x2A,0x06);//GAMMA2.2
|
|
+ dcs_write_seq(0xC6,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00);
|
|
+ dcs_write_seq(0xF4,0x08,0x77);
|
|
+ dcs_write_seq(0x36,0x14);
|
|
+ dcs_write_seq(0x35,0x00);
|
|
+ dcs_write_seq(0xF1,0x5A,0x5A);
|
|
+ dcs_write_seq(0xF0,0xA5,0xA5);
|
|
+}
|
|
+
|
|
+static int cwd686_disable(struct drm_panel *panel)
|
|
+{
|
|
+ struct cwd686 *ctx = panel_to_cwd686(panel);
|
|
+
|
|
+ if (!ctx->enabled)
|
|
+ return 0;
|
|
+
|
|
+ backlight_disable(ctx->backlight);
|
|
+
|
|
+ ctx->enabled = false;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int cwd686_unprepare(struct drm_panel *panel)
|
|
+{
|
|
+ struct cwd686 *ctx = panel_to_cwd686(panel);
|
|
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
|
|
+ int ret;
|
|
+
|
|
+#if 0
|
|
+ if (!ctx->prepared)
|
|
+ return 0;
|
|
+
|
|
+ ret = mipi_dsi_dcs_set_display_off(dsi);
|
|
+ if (ret)
|
|
+ DRM_WARN("failed to set display off: %d\n", ret);
|
|
+
|
|
+ ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
|
|
+ if (ret)
|
|
+ DRM_WARN("failed to enter sleep mode: %d\n", ret);
|
|
+
|
|
+ msleep(120);
|
|
+
|
|
+ if (ctx->reset_gpio) {
|
|
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
|
|
+ msleep(20);
|
|
+ }
|
|
+
|
|
+ regulator_disable(ctx->supply);
|
|
+
|
|
+ ctx->prepared = false;
|
|
+#endif
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int cwd686_prepare(struct drm_panel *panel)
|
|
+{
|
|
+ struct cwd686 *ctx = panel_to_cwd686(panel);
|
|
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
|
|
+ int ret;
|
|
+
|
|
+ if (ctx->prepared)
|
|
+ return 0;
|
|
+
|
|
+ ret = regulator_enable(ctx->supply);
|
|
+ if (ret < 0) {
|
|
+ DRM_ERROR("failed to enable supply: %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ if (ctx->reset_gpio) {
|
|
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
|
|
+ msleep(10);
|
|
+ gpiod_set_value_cansleep(ctx->reset_gpio, 0);
|
|
+ msleep(100);
|
|
+ }
|
|
+
|
|
+ cwd686_init_sequence(ctx);
|
|
+
|
|
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ msleep(120);
|
|
+
|
|
+ ret = mipi_dsi_dcs_set_display_on(dsi);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ msleep(20);
|
|
+
|
|
+ ctx->prepared = true;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int cwd686_enable(struct drm_panel *panel)
|
|
+{
|
|
+ struct cwd686 *ctx = panel_to_cwd686(panel);
|
|
+
|
|
+ if (ctx->enabled)
|
|
+ return 0;
|
|
+
|
|
+ backlight_enable(ctx->backlight);
|
|
+
|
|
+ ctx->enabled = true;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int cwd686_get_modes(struct drm_panel *panel)
|
|
+{
|
|
+ struct drm_display_mode *mode;
|
|
+
|
|
+ mode = drm_mode_duplicate(panel->drm, &default_mode);
|
|
+ if (!mode) {
|
|
+ DRM_ERROR("failed to add mode %ux%ux@%u\n",
|
|
+ default_mode.hdisplay, default_mode.vdisplay,
|
|
+ default_mode.vrefresh);
|
|
+ return -ENOMEM;
|
|
+ }
|
|
+
|
|
+ drm_mode_set_name(mode);
|
|
+
|
|
+ mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
|
|
+
|
|
+ panel->connector->display_info.width_mm = mode->width_mm;
|
|
+ panel->connector->display_info.height_mm = mode->height_mm;
|
|
+
|
|
+ drm_mode_probed_add(panel->connector, mode);
|
|
+ return 1;
|
|
+}
|
|
+
|
|
+static const struct drm_panel_funcs cwd686_drm_funcs = {
|
|
+ .disable = cwd686_disable,
|
|
+ .unprepare = cwd686_unprepare,
|
|
+ .prepare = cwd686_prepare,
|
|
+ .enable = cwd686_enable,
|
|
+ .get_modes = cwd686_get_modes,
|
|
+};
|
|
+
|
|
+static int cwd686_probe(struct mipi_dsi_device *dsi)
|
|
+{
|
|
+ struct device *dev = &dsi->dev;
|
|
+ struct cwd686 *ctx;
|
|
+ int ret;
|
|
+
|
|
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
|
|
+ if (!ctx)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
|
|
+ if (IS_ERR(ctx->reset_gpio)) {
|
|
+ ret = PTR_ERR(ctx->reset_gpio);
|
|
+ dev_err(dev, "cannot get reset GPIO: %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ctx->supply = devm_regulator_get(dev, "display-vcc");
|
|
+ if (IS_ERR(ctx->supply)) {
|
|
+ ret = PTR_ERR(ctx->supply);
|
|
+ dev_err(dev, "cannot get regulator: %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ ctx->backlight = devm_of_find_backlight(dev);
|
|
+ if (IS_ERR(ctx->backlight))
|
|
+ return PTR_ERR(ctx->backlight);
|
|
+
|
|
+ mipi_dsi_set_drvdata(dsi, ctx);
|
|
+
|
|
+ ctx->dev = dev;
|
|
+
|
|
+ dsi->lanes = 4;
|
|
+ dsi->format = MIPI_DSI_FMT_RGB888;
|
|
+ dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_LPM;
|
|
+
|
|
+ drm_panel_init(&ctx->panel);
|
|
+ ctx->panel.dev = dev;
|
|
+ ctx->panel.funcs = &cwd686_drm_funcs;
|
|
+
|
|
+ drm_panel_add(&ctx->panel);
|
|
+
|
|
+ ret = mipi_dsi_attach(dsi);
|
|
+ if (ret < 0) {
|
|
+ dev_err(dev, "mipi_dsi_attach() failed: %d\n", ret);
|
|
+ drm_panel_remove(&ctx->panel);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int cwd686_remove(struct mipi_dsi_device *dsi)
|
|
+{
|
|
+ struct cwd686 *ctx = mipi_dsi_get_drvdata(dsi);
|
|
+
|
|
+ mipi_dsi_detach(dsi);
|
|
+ drm_panel_remove(&ctx->panel);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static const struct of_device_id cwd686_of_match[] = {
|
|
+ { .compatible = "cw,cwd686" },
|
|
+ { }
|
|
+};
|
|
+MODULE_DEVICE_TABLE(of, cwd686_of_match);
|
|
+
|
|
+static struct mipi_dsi_driver cwd686_driver = {
|
|
+ .probe = cwd686_probe,
|
|
+ .remove = cwd686_remove,
|
|
+ .driver = {
|
|
+ .name = "panel-cwd686",
|
|
+ .of_match_table = cwd686_of_match,
|
|
+ },
|
|
+};
|
|
+module_mipi_dsi_driver(cwd686_driver);
|
|
+
|
|
+MODULE_DESCRIPTION("DRM Driver for cwd686 MIPI DSI panel");
|
|
+MODULE_LICENSE("GPL v2");
|
|
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
|
|
index aa65931142ba..405358cf24c8 100644
|
|
--- a/drivers/mfd/axp20x.c
|
|
+++ b/drivers/mfd/axp20x.c
|
|
@@ -962,6 +962,7 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
|
|
return ret;
|
|
}
|
|
|
|
+ pm_power_off = 0;
|
|
if (!pm_power_off) {
|
|
axp20x_pm_power_off = axp20x;
|
|
pm_power_off = axp20x_power_off;
|
|
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
|
index 0eaacdbc612f..32c59228b1a6 100644
|
|
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
|
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
|
@@ -622,6 +622,7 @@ BRCMF_FW_DEF(43430A0, "brcmfmac43430a0-sdio");
|
|
/* Note the names are not postfixed with a1 for backward compatibility */
|
|
BRCMF_FW_DEF(43430A1, "brcmfmac43430-sdio");
|
|
BRCMF_FW_DEF(43455, "brcmfmac43455-sdio");
|
|
+BRCMF_FW_DEF(43456, "brcmfmac43456-sdio");
|
|
BRCMF_FW_DEF(4354, "brcmfmac4354-sdio");
|
|
BRCMF_FW_DEF(4356, "brcmfmac4356-sdio");
|
|
BRCMF_FW_DEF(4373, "brcmfmac4373-sdio");
|
|
@@ -641,6 +642,7 @@ static const struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
|
|
BRCMF_FW_ENTRY(BRCM_CC_4339_CHIP_ID, 0xFFFFFFFF, 4339),
|
|
BRCMF_FW_ENTRY(BRCM_CC_43430_CHIP_ID, 0x00000001, 43430A0),
|
|
BRCMF_FW_ENTRY(BRCM_CC_43430_CHIP_ID, 0xFFFFFFFE, 43430A1),
|
|
+ BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0x00000200, 43456),
|
|
BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFFC0, 43455),
|
|
BRCMF_FW_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354),
|
|
BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
|
|
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
|
|
index e84b6e4da14a..b62c361e2589 100644
|
|
--- a/drivers/power/supply/axp20x_battery.c
|
|
+++ b/drivers/power/supply/axp20x_battery.c
|
|
@@ -326,6 +326,42 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
|
|
val->intval *= 1000;
|
|
break;
|
|
|
|
+ case POWER_SUPPLY_PROP_ENERGY_FULL:
|
|
+ case POWER_SUPPLY_PROP_ENERGY_NOW:
|
|
+ /* When no battery is present, return 0 */
|
|
+ ret = regmap_read(axp20x_batt->regmap, AXP20X_PWR_OP_MODE,
|
|
+ ®);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (!(reg & AXP20X_PWR_OP_BATT_PRESENT)) {
|
|
+ val->intval = 0;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ if(psp == POWER_SUPPLY_PROP_ENERGY_FULL) {
|
|
+ val->intval = 8000000;
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, ®);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (axp20x_batt->data->has_fg_valid && !(reg & AXP22X_FG_VALID))
|
|
+ return -EINVAL;
|
|
+
|
|
+ val1 = reg & AXP209_FG_PERCENT;
|
|
+ if (val1 > 90)
|
|
+ val1= 80;
|
|
+ else if (val1 < 10)
|
|
+ val1 = 0;
|
|
+ else
|
|
+ val1 -= 10;
|
|
+
|
|
+ val->intval = val1 * 100000;
|
|
+ break;
|
|
+
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
@@ -486,6 +522,8 @@ static enum power_supply_property axp20x_battery_props[] = {
|
|
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
|
|
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
|
|
POWER_SUPPLY_PROP_CAPACITY,
|
|
+ POWER_SUPPLY_PROP_ENERGY_FULL,
|
|
+ POWER_SUPPLY_PROP_ENERGY_NOW,
|
|
};
|
|
|
|
static int axp20x_battery_prop_writeable(struct power_supply *psy,
|
|
@@ -630,6 +668,12 @@ static int axp20x_power_probe(struct platform_device *pdev)
|
|
axp20x_get_constant_charge_current(axp20x_batt,
|
|
&axp20x_batt->max_ccc);
|
|
|
|
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x03);
|
|
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_OFF_CTRL, 0x08, 0x08);
|
|
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL2, 0x30, 0x20);
|
|
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_PEK_KEY, 0x0f, 0x0b);
|
|
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_GPIO0_CTRL, 0x07, 0x00);
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
|
|
index 42001df4bd13..791ec9f466cb 100644
|
|
--- a/drivers/power/supply/axp20x_usb_power.c
|
|
+++ b/drivers/power/supply/axp20x_usb_power.c
|
|
@@ -58,6 +58,9 @@ static irqreturn_t axp20x_usb_power_irq(int irq, void *devid)
|
|
{
|
|
struct axp20x_usb_power *power = devid;
|
|
|
|
+ regmap_update_bits(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x00);
|
|
+ regmap_update_bits(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x03);
|
|
+
|
|
power_supply_changed(power->supply);
|
|
|
|
return IRQ_HANDLED;
|
|
diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
|
|
index 2f465dba54bf..b12eb465b44c 100644
|
|
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
|
|
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
|
|
@@ -11,9 +11,9 @@
|
|
#include "bcm2835.h"
|
|
#include <soc/bcm2835/raspberrypi-firmware.h>
|
|
|
|
-static bool enable_hdmi, enable_hdmi0, enable_hdmi1;
|
|
-static bool enable_headphones;
|
|
-static bool enable_compat_alsa = true;
|
|
+static bool enable_hdmi = true, enable_hdmi0, enable_hdmi1;
|
|
+static bool enable_headphones = true;
|
|
+static bool enable_compat_alsa;
|
|
|
|
module_param(enable_hdmi, bool, 0444);
|
|
MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device");
|
|
diff --git a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
|
|
index 9478f9fd96e2..621a4b3e0860 100644
|
|
--- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
|
|
+++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
|
|
@@ -2559,7 +2559,7 @@ static const struct v4l2_m2m_ops m2m_ops = {
|
|
* The ISP component currently advertises 33 input formats, so add a small
|
|
* overhead on that.
|
|
*/
|
|
-#define MAX_SUPPORTED_ENCODINGS 40
|
|
+#define MAX_SUPPORTED_ENCODINGS 70
|
|
|
|
/* Populate dev->supported_fmts with the formats supported by those ports. */
|
|
static int bcm2835_codec_get_supported_fmts(struct bcm2835_codec_dev *dev)
|
|
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
|
|
index 5268ed6d12c0..0da804257739 100644
|
|
--- a/drivers/video/backlight/Kconfig
|
|
+++ b/drivers/video/backlight/Kconfig
|
|
@@ -487,6 +487,12 @@ config BACKLIGHT_RAVE_SP
|
|
help
|
|
Support for backlight control on RAVE SP device.
|
|
|
|
+config BACKLIGHT_OCP8178
|
|
+ tristate "OCP8178 Backlight Driver"
|
|
+ depends on GPIOLIB
|
|
+ help
|
|
+ If you have an OCP8178, say Y to enable the backlight driver.
|
|
+
|
|
endif # BACKLIGHT_CLASS_DEVICE
|
|
|
|
endif # BACKLIGHT_LCD_SUPPORT
|
|
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
|
|
index 476f855a093f..56d7c9909cc4 100644
|
|
--- a/drivers/video/backlight/Makefile
|
|
+++ b/drivers/video/backlight/Makefile
|
|
@@ -60,3 +60,4 @@ obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o
|
|
obj-$(CONFIG_BACKLIGHT_WM831X) += wm831x_bl.o
|
|
obj-$(CONFIG_BACKLIGHT_ARCXCNN) += arcxcnn_bl.o
|
|
obj-$(CONFIG_BACKLIGHT_RAVE_SP) += rave-sp-backlight.o
|
|
+obj-$(CONFIG_BACKLIGHT_OCP8178) += ocp8178_bl.o
|
|
diff --git a/drivers/video/backlight/ocp8178_bl.c b/drivers/video/backlight/ocp8178_bl.c
|
|
new file mode 100644
|
|
index 000000000000..db8db1771644
|
|
--- /dev/null
|
|
+++ b/drivers/video/backlight/ocp8178_bl.c
|
|
@@ -0,0 +1,277 @@
|
|
+/*
|
|
+ * ocp8178_bl.c - ocp8178 backlight driver
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License version 2 as
|
|
+ * published by the Free Software Foundation.
|
|
+ */
|
|
+
|
|
+#include <linux/backlight.h>
|
|
+#include <linux/err.h>
|
|
+#include <linux/fb.h>
|
|
+#include <linux/gpio.h> /* Only for legacy support */
|
|
+#include <linux/gpio/consumer.h>
|
|
+#include <linux/init.h>
|
|
+#include <linux/kernel.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/of.h>
|
|
+#include <linux/of_gpio.h>
|
|
+#include <linux/platform_data/gpio_backlight.h>
|
|
+#include <linux/platform_device.h>
|
|
+#include <linux/slab.h>
|
|
+#include <linux/delay.h>
|
|
+#include <linux/timer.h>
|
|
+#include <linux/poll.h>
|
|
+#include <linux/proc_fs.h>
|
|
+#include <linux/seq_file.h>
|
|
+#include <linux/sched.h>
|
|
+#include <linux/interrupt.h>
|
|
+#include <linux/irq.h>
|
|
+#include <linux/io.h>
|
|
+#include <linux/clk.h>
|
|
+
|
|
+struct ocp8178_backlight {
|
|
+ struct device *dev;
|
|
+ struct device *fbdev;
|
|
+
|
|
+ struct gpio_desc *gpiod;
|
|
+ int def_value;
|
|
+ int current_value;
|
|
+};
|
|
+
|
|
+#define DETECT_DELAY 200
|
|
+#define DETECT_TIME 500
|
|
+#define DETECT_WINDOW_TIME 1000
|
|
+#define START_TIME 10
|
|
+#define END_TIME 10
|
|
+#define SHUTDOWN_TIME 3000
|
|
+#define LOW_BIT_HIGH_TIME 10
|
|
+#define LOW_BIT_LOW_TIME 50
|
|
+#define HIGH_BIT_HIGH_TIME 50
|
|
+#define HIGH_BIT_LOW_TIME 10
|
|
+#define MAX_BRIGHTNESS_VALUE 9
|
|
+
|
|
+static void entry_1wire_mode(struct ocp8178_backlight *gbl)
|
|
+{
|
|
+ unsigned long flags = 0;
|
|
+ local_irq_save(flags);
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ mdelay(SHUTDOWN_TIME/1000);
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(DETECT_DELAY);
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ udelay(DETECT_TIME);
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(DETECT_WINDOW_TIME);
|
|
+ local_irq_restore(flags);
|
|
+}
|
|
+
|
|
+static inline void write_bit(struct ocp8178_backlight *gbl, int bit)
|
|
+{
|
|
+ if (bit) {
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ udelay(HIGH_BIT_LOW_TIME);
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(HIGH_BIT_HIGH_TIME);
|
|
+ } else {
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ udelay(LOW_BIT_LOW_TIME);
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(LOW_BIT_HIGH_TIME);
|
|
+ }
|
|
+}
|
|
+
|
|
+static void write_byte(struct ocp8178_backlight *gbl, int byte)
|
|
+{
|
|
+ unsigned long flags = 0;
|
|
+ unsigned char data = 0x72;
|
|
+ int i;
|
|
+
|
|
+ local_irq_save(flags);
|
|
+
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(START_TIME);
|
|
+ for(i = 0; i < 8; i++) {
|
|
+ if(data & 0x80) {
|
|
+ write_bit(gbl, 1);
|
|
+ } else {
|
|
+ write_bit(gbl, 0);
|
|
+ }
|
|
+ data <<= 1;
|
|
+ }
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ udelay(END_TIME);
|
|
+
|
|
+ data = byte & 0x1f;
|
|
+
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+ udelay(START_TIME);
|
|
+ for(i = 0; i < 8; i++) {
|
|
+ if(data & 0x80) {
|
|
+ write_bit(gbl, 1);
|
|
+ } else {
|
|
+ write_bit(gbl, 0);
|
|
+ }
|
|
+ data <<= 1;
|
|
+ }
|
|
+ gpiod_set_value(gbl->gpiod, 0);
|
|
+ udelay(END_TIME);
|
|
+ gpiod_set_value(gbl->gpiod, 1);
|
|
+
|
|
+ local_irq_restore(flags);
|
|
+}
|
|
+
|
|
+unsigned char ocp8178_bl_table[MAX_BRIGHTNESS_VALUE+1] = {0, 1, 4, 8, 12, 16, 20, 24, 28, 31};
|
|
+
|
|
+static int ocp8178_update_status(struct backlight_device *bl)
|
|
+{
|
|
+ struct ocp8178_backlight *gbl = bl_get_data(bl);
|
|
+ int brightness = bl->props.brightness, i;
|
|
+
|
|
+ if (bl->props.power != FB_BLANK_UNBLANK ||
|
|
+ bl->props.fb_blank != FB_BLANK_UNBLANK ||
|
|
+ bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
|
|
+ brightness = 0;
|
|
+
|
|
+ if(brightness > MAX_BRIGHTNESS_VALUE)
|
|
+ brightness = MAX_BRIGHTNESS_VALUE;
|
|
+
|
|
+ for(i = 0; i < 2; i++) {
|
|
+ entry_1wire_mode(gbl);
|
|
+ write_byte(gbl, ocp8178_bl_table[brightness]);
|
|
+ }
|
|
+ gbl->current_value = brightness;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ocp8178_get_brightness(struct backlight_device *bl)
|
|
+{
|
|
+ struct ocp8178_backlight *gbl = bl_get_data(bl);
|
|
+ return gbl->current_value;
|
|
+}
|
|
+
|
|
+static int ocp8178_check_fb(struct backlight_device *bl,
|
|
+ struct fb_info *info)
|
|
+{
|
|
+ struct ocp8178_backlight *gbl = bl_get_data(bl);
|
|
+ return gbl->fbdev == NULL || gbl->fbdev == info->dev;
|
|
+}
|
|
+
|
|
+static const struct backlight_ops ocp8178_backlight_ops = {
|
|
+ .options = BL_CORE_SUSPENDRESUME,
|
|
+ .update_status = ocp8178_update_status,
|
|
+ .get_brightness = ocp8178_get_brightness,
|
|
+ .check_fb = ocp8178_check_fb,
|
|
+};
|
|
+
|
|
+static int ocp8178_probe_dt(struct platform_device *pdev,
|
|
+ struct ocp8178_backlight *gbl)
|
|
+{
|
|
+ struct device *dev = &pdev->dev;
|
|
+ struct device_node *np = dev->of_node;
|
|
+ enum gpiod_flags flags;
|
|
+ int ret = 0;
|
|
+ u32 value32;
|
|
+
|
|
+ of_property_read_u32(np, "default-brightness", &value32);
|
|
+ if(value32 > MAX_BRIGHTNESS_VALUE)
|
|
+ gbl->def_value = MAX_BRIGHTNESS_VALUE;
|
|
+ else
|
|
+ gbl->def_value = value32;
|
|
+ flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
|
|
+
|
|
+ gbl->gpiod = devm_gpiod_get(dev, "backlight-control", flags);
|
|
+ if (IS_ERR(gbl->gpiod)) {
|
|
+ ret = PTR_ERR(gbl->gpiod);
|
|
+
|
|
+ if (ret != -EPROBE_DEFER) {
|
|
+ dev_err(dev,
|
|
+ "Error: The gpios parameter is missing or invalid.\n");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static struct backlight_device *backlight;
|
|
+
|
|
+static int ocp8178_probe(struct platform_device *pdev)
|
|
+{
|
|
+ struct backlight_properties props;
|
|
+ struct backlight_device *bl;
|
|
+ struct ocp8178_backlight *gbl;
|
|
+ struct device_node *np = pdev->dev.of_node;
|
|
+ int ret;
|
|
+
|
|
+ if ( !np) {
|
|
+ dev_err(&pdev->dev,
|
|
+ "failed to find platform data or device tree node.\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
|
|
+ if (gbl == NULL)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ gbl->dev = &pdev->dev;
|
|
+
|
|
+ ret = ocp8178_probe_dt(pdev, gbl);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ gbl->current_value = gbl->def_value;
|
|
+
|
|
+ memset(&props, 0, sizeof(props));
|
|
+ props.type = BACKLIGHT_RAW;
|
|
+ props.max_brightness = MAX_BRIGHTNESS_VALUE;
|
|
+ bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
|
|
+ &pdev->dev, gbl, &ocp8178_backlight_ops,
|
|
+ &props);
|
|
+ if (IS_ERR(bl)) {
|
|
+ dev_err(&pdev->dev, "failed to register backlight\n");
|
|
+ return PTR_ERR(bl);
|
|
+ }
|
|
+
|
|
+// entry_1wire_mode(gbl);
|
|
+
|
|
+ bl->props.brightness = gbl->def_value;
|
|
+ backlight_update_status(bl);
|
|
+
|
|
+ platform_set_drvdata(pdev, bl);
|
|
+
|
|
+ backlight = bl;
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ocp8178_suspend(struct platform_device *pdev, pm_message_t state)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int ocp8178_resume(struct platform_device *pdev)
|
|
+{
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static struct of_device_id ocp8178_of_match[] = {
|
|
+ { .compatible = "ocp8178-backlight" },
|
|
+ { /* sentinel */ }
|
|
+};
|
|
+
|
|
+MODULE_DEVICE_TABLE(of, ocp8178_of_match);
|
|
+
|
|
+static struct platform_driver ocp8178_driver = {
|
|
+ .driver = {
|
|
+ .name = "ocp8178-backlight",
|
|
+ .of_match_table = of_match_ptr(ocp8178_of_match),
|
|
+ },
|
|
+ .probe = ocp8178_probe,
|
|
+ .suspend = ocp8178_suspend,
|
|
+ .resume = ocp8178_resume,
|
|
+};
|
|
+
|
|
+module_platform_driver(ocp8178_driver);
|
|
+
|
|
+MODULE_DESCRIPTION("OCP8178 Driver");
|
|
+MODULE_LICENSE("GPL");
|