clockworkpi-uconsole-cm4: new device (MR 4751)

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Federico Amedeo Izzo 2024-02-04 16:16:47 +01:00 committed by Oliver Smith
parent 7fdf08a0ad
commit 587b03ad73
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
15 changed files with 10815 additions and 0 deletions

View file

@ -0,0 +1 @@
SUBSYSTEM=="vchiq", GROUP="video", MODE="0660"

View file

@ -0,0 +1,48 @@
# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: Federico Amedeo Izzo <federico@izzo.pro>
pkgname=device-clockworkpi-uconsole-cm4
pkgdesc="Clockwork Tech ClockworkPi uConsole CM4"
pkgver=1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
linux-clockworkpi-uconsole-cm4
postmarketos-base
raspberrypi-bootloader
"
makedepends="devicepkg-dev"
install="$pkgname.post-install $pkgname.post-upgrade"
subpackages="$pkgname-nonfree-firmware:nonfree_firmware"
source="
deviceinfo
modules-initfs
usercfg.txt
95-vchiq-permissions.rules
"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
install -Dm644 "$srcdir"/usercfg.txt "$pkgdir"/boot/usercfg.txt
install -Dm644 "$srcdir"/95-vchiq-permissions.rules \
"$pkgdir"/usr/lib/udev/rules.d/95-vchiq-permissions.rules
}
nonfree_firmware() {
pkgdesc="WiFi/Bluetooth firmware"
depends="linux-firmware-brcm"
mkdir "$subpkgdir"
}
sha512sums="
8239d117839d3e3603c7ab73e598059bb521b81aeec5d6f7d0ec68d00cb9912bbad9fe5a0741e41e7ec94250729042dce91a6efb412c4e30c43a9c0b0a81a5b5 deviceinfo
bc630857d9b0b6a89b3d9ff794be1133f5d7a681f26cd826ea4315649f8bf6c0c24aafa220093cbb313aa8bd6d46d2621c7aacb62e445a2d60c87e50099b45a5 modules-initfs
43c2aca99ee3e02f4563bc27d331fa6e4e3c540732487c5806fd7574025cabc69347b74e2cea72f9c36fde8876833126063ca808a7398c5754dd53aecd6df7bf usercfg.txt
7e5505cb07d5b4a81bd28443d508336b5c547356538f1c06f91ed93ad0d7d456d4f74f1d24df5a2e08c17e74f0a66607352ac4874e967e9a91dfec9522d2d58d 95-vchiq-permissions.rules
"

View file

@ -0,0 +1,3 @@
#!/bin/sh
rc-update add swclock boot

View file

@ -0,0 +1,3 @@
#!/bin/sh
rc-update add swclock boot

View file

@ -0,0 +1,23 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Maintainer: Federico Amedeo Izzo <federico@izzo.pro>
# Please use double quotes only. You can source this file in shell
# scripts.
deviceinfo_format_version="0"
deviceinfo_name="Clockwork Tech ClockworkPi uConsole CM4"
deviceinfo_manufacturer="Clockwork Tech"
deviceinfo_codename="clockworkpi-uconsole-cm4"
deviceinfo_year="2023"
deviceinfo_arch="aarch64"
deviceinfo_disable_dhcpd="true"
# Device related
deviceinfo_gpu_accelerated="true"
deviceinfo_chassis="embedded"
deviceinfo_keyboard="true"
deviceinfo_external_storage="true"
deviceinfo_mesa_driver="vc4"
# Bootloader related
deviceinfo_flash_method="none"
deviceinfo_boot_filesystem="fat32"

View file

@ -0,0 +1,3 @@
vc4
panel_clockwork_cwu50
ocp8178_bl

View file

@ -0,0 +1,14 @@
ignore_lcd=1
disable_fw_kms_setup=1
max_framebuffers=2
arm_boost=1
# setup headphone detect pin
gpio=10=ip,np
# overlays
dtoverlay=dwc2,dr_mode=host
dtoverlay=vc4-kms-v3d
dtoverlay=audremap,pins_12_13
dtparam=audio=on
dtoverlay=uconsole

View file

@ -0,0 +1,295 @@
From c541b4c80043848ff19e4906ecfc49c6f6818198 Mon Sep 17 00:00:00 2001
From: Potato <nikko@faint.day>
Date: Mon, 2 Oct 2023 15:14:09 +0800
Subject: [PATCH 1/6] video: backlight: Add OCP8178 backlight driver
This driver is taken from
https://github.com/clockworkpi/DevTerm/blob/main/Code/patch/armbian_build_a06/patch/kernel-005-backlight.patch
and optimized for v6.5.
---
drivers/video/backlight/Kconfig | 6 +
drivers/video/backlight/Makefile | 1 +
drivers/video/backlight/ocp8178_bl.c | 245 +++++++++++++++++++++++++++
3 files changed, 252 insertions(+)
create mode 100644 drivers/video/backlight/ocp8178_bl.c
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 0e66152b02e6..efb66e7abb85 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -484,6 +484,12 @@ config BACKLIGHT_LED
If you have a LCD backlight adjustable by LED class driver, say Y
to enable this driver.
+config BACKLIGHT_OCP8178
+ tristate "OCP8178 Backlight Driver"
+ depends on GPIOLIB || COMPILE_TEST
+ help
+ If you have an OCP8178, say Y to enable the backlight driver.
+
endif # BACKLIGHT_CLASS_DEVICE
endmenu
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index ac878b4fb0ee..4d431321f1f2 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -60,3 +60,4 @@ 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_LED) += led_bl.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..2b0d1b159500
--- /dev/null
+++ b/drivers/video/backlight/ocp8178_bl.c
@@ -0,0 +1,245 @@
+/*
+ * 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/consumer.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/delay.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 *of_node = dev->of_node;
+ enum gpiod_flags flags;
+ int ret = 0;
+ u32 default_brightness;
+
+ of_property_read_u32(of_node, "default-brightness", &default_brightness);
+ if(default_brightness > MAX_BRIGHTNESS_VALUE)
+ gbl->def_value = MAX_BRIGHTNESS_VALUE;
+ else
+ gbl->def_value = default_brightness;
+ 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);
+ return dev_err_probe(dev, ret,
+ "Error: The backlight-control-gpios parameter is missing or invalid.\n");
+ }
+
+ return ret;
+}
+
+static int ocp8178_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct backlight_properties props;
+ struct backlight_device *bl;
+ struct ocp8178_backlight *gbl;
+ struct device_node *of_node = dev->of_node;
+ int ret;
+
+ if (!of_node) {
+ dev_err(&pdev->dev,
+ "failed to find platform data or device tree node.\n");
+ return -ENODEV;
+ }
+
+ gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
+ if (gbl == NULL)
+ return -ENOMEM;
+
+ gbl->dev = 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);
+ }
+
+ bl->props.brightness = gbl->def_value;
+ backlight_update_status(bl);
+
+ platform_set_drvdata(pdev, bl);
+ 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,
+};
+
+module_platform_driver(ocp8178_driver);
+
+MODULE_DESCRIPTION("OCP8178 Driver");
+MODULE_LICENSE("GPL");
--
2.43.0

View file

@ -0,0 +1,625 @@
From aa593278d760e468f79e2c785a96b7b049653a2e Mon Sep 17 00:00:00 2001
From: Potato <nikko@faint.day>
Date: Fri, 20 Oct 2023 23:18:19 +0800
Subject: [PATCH 2/6] drm: panel: add clockwork cwu50
- set `power_off_case` to 2(other than 1) to enable power off by
DCS command
---
drivers/gpu/drm/panel/Kconfig | 12 +
drivers/gpu/drm/panel/Makefile | 1 +
drivers/gpu/drm/panel/panel-clockwork-cwu50.c | 567 ++++++++++++++++++
3 files changed, 580 insertions(+)
create mode 100644 drivers/gpu/drm/panel/panel-clockwork-cwu50.c
diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 168403f59175..4a99ef1b0178 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -68,6 +68,18 @@ config DRM_PANEL_BOE_TV101WUM_NL6
Say Y here if you want to support for BOE TV101WUM and AUO KD101N80
45NA WUXGA PANEL DSI Video Mode panel
+config DRM_PANEL_CLOCKWORK_CWU50
+ tristate "Clockwork CWU50 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 the Clockwork CWU50
+ JD9365D-based panel, e.g. as used within the Clockwork uConsole.
+ The panel has a 720x1280 resolution and uses 24 bit RGB per pixel.
+
+ To compile this driver as a module, choose M here.
+
config DRM_PANEL_DSI_CM
tristate "Generic DSI command mode panels"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index bc4ded65aa4b..25d9c19d9cd0 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_PANEL_ASUS_Z00T_TM5P5_NT35596) += panel-asus-z00t-tm5p5-n35596.
obj-$(CONFIG_DRM_PANEL_BOE_BF060Y8M_AJ0) += panel-boe-bf060y8m-aj0.o
obj-$(CONFIG_DRM_PANEL_BOE_HIMAX8279D) += panel-boe-himax8279d.o
obj-$(CONFIG_DRM_PANEL_BOE_TV101WUM_NL6) += panel-boe-tv101wum-nl6.o
+obj-$(CONFIG_DRM_PANEL_CLOCKWORK_CWU50) += panel-clockwork-cwu50.o
obj-$(CONFIG_DRM_PANEL_DSI_CM) += panel-dsi-cm.o
obj-$(CONFIG_DRM_PANEL_LVDS) += panel-lvds.o
obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
diff --git a/drivers/gpu/drm/panel/panel-clockwork-cwu50.c b/drivers/gpu/drm/panel/panel-clockwork-cwu50.c
new file mode 100644
index 000000000000..a814d6bb25dd
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-clockwork-cwu50.c
@@ -0,0 +1,567 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0+
+ * Copyright (c) 2021 Clockwork Tech LLC
+ * Copyright (c) 2021 Max Fierke <max@maxfierke.com>
+ *
+ */
+
+#include <drm/drm_modes.h>
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_panel.h>
+#include <linux/backlight.h>
+#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
+#include <linux/delay.h>
+#include <linux/of_device.h>
+#include <linux/module.h>
+#include <video/mipi_display.h>
+
+static int power_off_case = 1;
+module_param(power_off_case,int,0660);
+
+struct cwu50 {
+ struct device *dev;
+ struct drm_panel panel;
+ struct regulator *vci;
+ struct regulator *iovcc;
+ struct gpio_desc *reset_gpio;
+ enum drm_panel_orientation orientation;
+ bool prepared;
+};
+
+static const struct drm_display_mode default_mode = {
+ .clock = 62500,
+
+ .hdisplay = 720,
+ .hsync_start = 720 + 43,
+ .hsync_end = 720 + 43 + 20,
+ .htotal = 720 + 43 + 20 + 20,
+
+ .vdisplay = 1280,
+ .vsync_start = 1280 + 8,
+ .vsync_end = 1280 + 8 + 2,
+ .vtotal = 1280 + 8 + 2 + 16,
+
+ .width_mm = 62,
+ .height_mm = 110,
+ .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static inline struct cwu50 *panel_to_cwu50(struct drm_panel *panel)
+{
+ return container_of(panel, struct cwu50, panel);
+}
+
+#define dcs_write_seq(seq...) \
+({ \
+ static const u8 d[] = { seq }; \
+ err = mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)); \
+ if (err < 0) \
+ return err; \
+})
+
+static int cwu50_init_sequence(struct cwu50 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int err;
+
+ dcs_write_seq(0xE1,0x93);
+ dcs_write_seq(0xE2,0x65);
+ dcs_write_seq(0xE3,0xF8);
+ dcs_write_seq(0x70,0x20);
+ dcs_write_seq(0x71,0x13);
+ dcs_write_seq(0x72,0x06);
+ dcs_write_seq(0x75,0x03);
+ dcs_write_seq(0xE0,0x01);
+ dcs_write_seq(0x00,0x00);
+ dcs_write_seq(0x01,0x47);//VCOM0x47
+ dcs_write_seq(0x03,0x00);
+ dcs_write_seq(0x04,0x4D);
+ dcs_write_seq(0x0C,0x64);
+ dcs_write_seq(0x17,0x00);
+ dcs_write_seq(0x18,0xBF);
+ dcs_write_seq(0x19,0x00);
+ dcs_write_seq(0x1A,0x00);
+ dcs_write_seq(0x1B,0xBF);
+ dcs_write_seq(0x1C,0x00);
+ dcs_write_seq(0x1F,0x7E);
+ dcs_write_seq(0x20,0x24);
+ dcs_write_seq(0x21,0x24);
+ dcs_write_seq(0x22,0x4E);
+ dcs_write_seq(0x24,0xFE);
+ dcs_write_seq(0x37,0x09);
+ dcs_write_seq(0x38,0x04);
+ dcs_write_seq(0x3C,0x76);
+ dcs_write_seq(0x3D,0xFF);
+ dcs_write_seq(0x3E,0xFF);
+ dcs_write_seq(0x3F,0x7F);
+ dcs_write_seq(0x40,0x04);//Dot inversion type
+ dcs_write_seq(0x41,0xA0);
+ dcs_write_seq(0x44,0x11);
+ dcs_write_seq(0x55,0x02);
+ dcs_write_seq(0x56,0x01);
+ dcs_write_seq(0x57,0x49);
+ dcs_write_seq(0x58,0x09);
+ dcs_write_seq(0x59,0x2A);
+ dcs_write_seq(0x5A,0x1A);
+ dcs_write_seq(0x5B,0x1A);
+ dcs_write_seq(0x5D,0x78);
+ dcs_write_seq(0x5E,0x6E);
+ dcs_write_seq(0x5F,0x66);
+ dcs_write_seq(0x60,0x5E);
+ dcs_write_seq(0x61,0x60);
+ dcs_write_seq(0x62,0x54);
+ dcs_write_seq(0x63,0x5C);
+ dcs_write_seq(0x64,0x47);
+ dcs_write_seq(0x65,0x5F);
+ dcs_write_seq(0x66,0x5D);
+ dcs_write_seq(0x67,0x5B);
+ dcs_write_seq(0x68,0x76);
+ dcs_write_seq(0x69,0x61);
+ dcs_write_seq(0x6A,0x63);
+ dcs_write_seq(0x6B,0x50);
+ dcs_write_seq(0x6C,0x45);
+ dcs_write_seq(0x6D,0x34);
+ dcs_write_seq(0x6E,0x1C);
+ dcs_write_seq(0x6F,0x07);
+ dcs_write_seq(0x70,0x78);
+ dcs_write_seq(0x71,0x6E);
+ dcs_write_seq(0x72,0x66);
+ dcs_write_seq(0x73,0x5E);
+ dcs_write_seq(0x74,0x60);
+ dcs_write_seq(0x75,0x54);
+ dcs_write_seq(0x76,0x5C);
+ dcs_write_seq(0x77,0x47);
+ dcs_write_seq(0x78,0x5F);
+ dcs_write_seq(0x79,0x5D);
+ dcs_write_seq(0x7A,0x5B);
+ dcs_write_seq(0x7B,0x76);
+ dcs_write_seq(0x7C,0x61);
+ dcs_write_seq(0x7D,0x63);
+ dcs_write_seq(0x7E,0x50);
+ dcs_write_seq(0x7F,0x45);
+ dcs_write_seq(0x80,0x34);
+ dcs_write_seq(0x81,0x1C);
+ dcs_write_seq(0x82,0x07);
+ dcs_write_seq(0xE0,0x02);
+ dcs_write_seq(0x00,0x44);
+ dcs_write_seq(0x01,0x46);
+ dcs_write_seq(0x02,0x48);
+ dcs_write_seq(0x03,0x4A);
+ dcs_write_seq(0x04,0x40);
+ dcs_write_seq(0x05,0x42);
+ dcs_write_seq(0x06,0x1F);
+ dcs_write_seq(0x07,0x1F);
+ dcs_write_seq(0x08,0x1F);
+ dcs_write_seq(0x09,0x1F);
+ dcs_write_seq(0x0A,0x1F);
+ dcs_write_seq(0x0B,0x1F);
+ dcs_write_seq(0x0C,0x1F);
+ dcs_write_seq(0x0D,0x1F);
+ dcs_write_seq(0x0E,0x1F);
+ dcs_write_seq(0x0F,0x1F);
+ dcs_write_seq(0x10,0x1F);
+ dcs_write_seq(0x11,0x1F);
+ dcs_write_seq(0x12,0x1F);
+ dcs_write_seq(0x13,0x1F);
+ dcs_write_seq(0x14,0x1E);
+ dcs_write_seq(0x15,0x1F);
+ dcs_write_seq(0x16,0x45);
+ dcs_write_seq(0x17,0x47);
+ dcs_write_seq(0x18,0x49);
+ dcs_write_seq(0x19,0x4B);
+ dcs_write_seq(0x1A,0x41);
+ dcs_write_seq(0x1B,0x43);
+ dcs_write_seq(0x1C,0x1F);
+ dcs_write_seq(0x1D,0x1F);
+ dcs_write_seq(0x1E,0x1F);
+ dcs_write_seq(0x1F,0x1F);
+ dcs_write_seq(0x20,0x1F);
+ dcs_write_seq(0x21,0x1F);
+ dcs_write_seq(0x22,0x1F);
+ dcs_write_seq(0x23,0x1F);
+ dcs_write_seq(0x24,0x1F);
+ dcs_write_seq(0x25,0x1F);
+ dcs_write_seq(0x26,0x1F);
+ dcs_write_seq(0x27,0x1F);
+ dcs_write_seq(0x28,0x1F);
+ dcs_write_seq(0x29,0x1F);
+ dcs_write_seq(0x2A,0x1E);
+ dcs_write_seq(0x2B,0x1F);
+ dcs_write_seq(0x2C,0x0B);
+ dcs_write_seq(0x2D,0x09);
+ dcs_write_seq(0x2E,0x07);
+ dcs_write_seq(0x2F,0x05);
+ dcs_write_seq(0x30,0x03);
+ dcs_write_seq(0x31,0x01);
+ dcs_write_seq(0x32,0x1F);
+ dcs_write_seq(0x33,0x1F);
+ dcs_write_seq(0x34,0x1F);
+ dcs_write_seq(0x35,0x1F);
+ dcs_write_seq(0x36,0x1F);
+ dcs_write_seq(0x37,0x1F);
+ dcs_write_seq(0x38,0x1F);
+ dcs_write_seq(0x39,0x1F);
+ dcs_write_seq(0x3A,0x1F);
+ dcs_write_seq(0x3B,0x1F);
+ dcs_write_seq(0x3C,0x1F);
+ dcs_write_seq(0x3D,0x1F);
+ dcs_write_seq(0x3E,0x1F);
+ dcs_write_seq(0x3F,0x1F);
+ dcs_write_seq(0x40,0x1F);
+ dcs_write_seq(0x41,0x1E);
+ dcs_write_seq(0x42,0x0A);
+ dcs_write_seq(0x43,0x08);
+ dcs_write_seq(0x44,0x06);
+ dcs_write_seq(0x45,0x04);
+ dcs_write_seq(0x46,0x02);
+ dcs_write_seq(0x47,0x00);
+ dcs_write_seq(0x48,0x1F);
+ dcs_write_seq(0x49,0x1F);
+ dcs_write_seq(0x4A,0x1F);
+ dcs_write_seq(0x4B,0x1F);
+ dcs_write_seq(0x4C,0x1F);
+ dcs_write_seq(0x4D,0x1F);
+ dcs_write_seq(0x4E,0x1F);
+ dcs_write_seq(0x4F,0x1F);
+ dcs_write_seq(0x50,0x1F);
+ dcs_write_seq(0x51,0x1F);
+ dcs_write_seq(0x52,0x1F);
+ dcs_write_seq(0x53,0x1F);
+ dcs_write_seq(0x54,0x1F);
+ dcs_write_seq(0x55,0x1F);
+ dcs_write_seq(0x56,0x1F);
+ dcs_write_seq(0x57,0x1E);
+ dcs_write_seq(0x58,0x40);
+ dcs_write_seq(0x59,0x00);
+ dcs_write_seq(0x5A,0x00);
+ dcs_write_seq(0x5B,0x30);
+ dcs_write_seq(0x5C,0x02);
+ dcs_write_seq(0x5D,0x40);
+ dcs_write_seq(0x5E,0x01);
+ dcs_write_seq(0x5F,0x02);
+ dcs_write_seq(0x60,0x00);
+ dcs_write_seq(0x61,0x01);
+ dcs_write_seq(0x62,0x02);
+ dcs_write_seq(0x63,0x65);
+ dcs_write_seq(0x64,0x66);
+ dcs_write_seq(0x65,0x00);
+ dcs_write_seq(0x66,0x00);
+ dcs_write_seq(0x67,0x74);
+ dcs_write_seq(0x68,0x06);
+ dcs_write_seq(0x69,0x65);
+ dcs_write_seq(0x6A,0x66);
+ dcs_write_seq(0x6B,0x10);
+ dcs_write_seq(0x6C,0x00);
+ dcs_write_seq(0x6D,0x04);
+ dcs_write_seq(0x6E,0x04);
+ dcs_write_seq(0x6F,0x88);
+ dcs_write_seq(0x70,0x00);
+ dcs_write_seq(0x71,0x00);
+ dcs_write_seq(0x72,0x06);
+ dcs_write_seq(0x73,0x7B);
+ dcs_write_seq(0x74,0x00);
+ dcs_write_seq(0x75,0x87);
+ dcs_write_seq(0x76,0x00);
+ dcs_write_seq(0x77,0x5D);
+ dcs_write_seq(0x78,0x17);
+ dcs_write_seq(0x79,0x1F);
+ dcs_write_seq(0x7A,0x00);
+ dcs_write_seq(0x7B,0x00);
+ dcs_write_seq(0x7C,0x00);
+ dcs_write_seq(0x7D,0x03);
+ dcs_write_seq(0x7E,0x7B);
+ dcs_write_seq(0xE0,0x04);
+ dcs_write_seq(0x09,0x10);
+ dcs_write_seq(0xE0,0x00);
+ dcs_write_seq(0xE6,0x02);
+ dcs_write_seq(0xE7,0x02);
+ // dcs_write_seq(0x11);// SLPOUT
+ // msleep (120);
+ // dcs_write_seq(0x29);// DSPON
+ // msleep (20);
+ // dcs_write_seq(0x35,0x00);// TE
+
+ return 0;
+}
+
+static int cwu50_unprepare(struct drm_panel *panel)
+{
+ struct cwu50 *ctx = panel_to_cwu50(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int err;
+
+ if (!ctx->prepared)
+ return 0;
+
+ /* Power off the display using case 1 described in JD9365D.pdf chapter 9.5.3.
+ * module's default behaviour
+ */
+ if (1 == power_off_case) {
+ goto power_off_case1;
+ }
+
+ /* Power off the display using case 2 described in JD9365D.pdf chapter 9.5.3. */
+
+ /* tCMD_OFF >= 1ms */
+ msleep(1);
+
+ err = mipi_dsi_dcs_set_display_off(dsi);
+ if (err) {
+ dev_warn(ctx->dev, "failed to send display off command (%d)\n", err);
+ goto fallback_case1;
+ }
+
+ /* tDISOFF >= 50ms */
+ msleep(50);
+
+
+ err = mipi_dsi_dcs_enter_sleep_mode(dsi);
+ if (err) {
+ dev_warn(ctx->dev, "failed to enter sleep mode (%d)\n", err);
+ goto fallback_case1;
+ }
+
+ /* tSLPIN >= 100ms */
+ msleep(100);
+
+
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1); /* assert reset */
+
+ goto disable_regulators;
+
+fallback_case1:
+ /* in case of error, fall back to case 1 */
+ dev_warn(ctx->dev, "falling back to power off case 1 using HW reset line");
+power_off_case1:
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1); /* assert reset */
+ /* tRSTOFF1 >= 120ms */
+ msleep(120);
+
+disable_regulators:
+ regulator_disable(ctx->vci);
+ regulator_disable(ctx->iovcc);
+
+ ctx->prepared = false;
+
+ return 0;
+}
+
+static int cwu50_prepare(struct drm_panel *panel)
+{
+ struct cwu50 *ctx = panel_to_cwu50(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int err;
+ u8 response;
+
+ if (ctx->prepared)
+ return 0;
+
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1); /* ensure asserted state */
+
+ /* IOVCC first, then VCI */
+ err = regulator_enable(ctx->iovcc);
+ if (err) {
+ dev_err(ctx->dev, "failed to enable iovcc (%d)\n", err);
+ return err;
+ }
+
+ /* tPWON>= 0ms */
+
+ err = regulator_enable(ctx->vci);
+ if (err) {
+ dev_err(ctx->dev, "failed to enable vci (%d)\n", err);
+ goto disable_iovcc;
+ }
+
+ /* MIPI should be LP-11 now */
+ /* tRPWIRES >= 5ms */
+ msleep(10);
+
+ /* tRESETL=10us */
+ /* tRESETH >= 5ms */
+ gpiod_set_value_cansleep(ctx->reset_gpio, 0); /* deassert */
+ msleep(10);
+
+ /* Exit sleep mode and power on */
+
+ err = cwu50_init_sequence(ctx);
+ if (err) {
+ dev_err(ctx->dev, "failed to send initialize sequence (%d)\n", err);
+ goto disable_vci;
+ }
+
+ /* slpout */
+ err = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (err) {
+ dev_err(ctx->dev, "failed to exit sleep mode (%d)\n", err);
+ goto disable_vci;
+ }
+
+ /* tSLPOUT 120ms */
+ msleep(120);
+
+ err = mipi_dsi_dcs_set_display_on(dsi);
+ if (err) {
+ dev_err(ctx->dev, "failed to turn display on (%d)\n", err);
+ goto disable_vci;
+ }
+ msleep(20);
+
+ /* Enabe tearing mode: send TE (tearing effect) at VBLANK */
+ /* JD9365D seems need a parameter for this command */
+ err = mipi_dsi_dcs_write_buffer(dsi, (u8[]){ 0x35, 0x00 }, 2);
+ // err = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+ if (err < 0) {
+ dev_err(ctx->dev, "failed to enable vblank TE (%d)\n", err);
+ return err;
+ }
+
+ err = mipi_dsi_dcs_get_power_mode(dsi, &response);
+ if (!err) {
+ /* debug, normally the command will fail */
+ dev_info(ctx->dev, "Read display power mode got: %d", response);
+ }
+
+ ctx->prepared = true;
+
+ return 0;
+disable_vci:
+ regulator_disable(ctx->vci);
+disable_iovcc:
+ regulator_disable(ctx->iovcc);
+ return err;
+}
+
+static int cwu50_get_modes(struct drm_panel *panel, struct drm_connector *connector)
+{
+ struct cwu50 *ctx = panel_to_cwu50(panel);
+ struct drm_display_mode *mode;
+
+ mode = drm_mode_duplicate(connector->dev, &default_mode);
+ if (!mode) {
+ dev_err(panel->dev, "bad mode or failed to add mode\n");
+ return -EINVAL;
+ }
+ drm_mode_set_name(mode);
+ mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
+
+ /* set up connector's "panel orientation" property */
+ /*
+ * TODO: Remove once all drm drivers call
+ * drm_connector_set_orientation_from_panel()
+ */
+ drm_connector_set_panel_orientation(connector, ctx->orientation);
+
+ drm_mode_probed_add(connector, mode);
+
+ return 1; /* Number of modes */
+}
+
+static enum drm_panel_orientation cwu50_get_orientation(struct drm_panel *panel)
+{
+ struct cwu50 *ctx = panel_to_cwu50(panel);
+
+ return ctx->orientation;
+}
+
+static const struct drm_panel_funcs cwu50_drm_funcs = {
+ .unprepare = cwu50_unprepare,
+ .prepare = cwu50_prepare,
+ .get_modes = cwu50_get_modes,
+ .get_orientation = cwu50_get_orientation,
+};
+
+static int cwu50_probe(struct mipi_dsi_device *dsi)
+{
+ struct device *dev = &dsi->dev;
+ struct cwu50 *ctx;
+ int err;
+
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ 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_BURST |
+ MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
+
+ ctx->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(ctx->reset_gpio)) {
+ err = PTR_ERR(ctx->reset_gpio);
+ return dev_err_probe(dev, err, "Failed to request GPIO (%d)\n", err);
+ }
+
+ ctx->vci = devm_regulator_get(dev, "vci");
+ if (IS_ERR(ctx->vci)) {
+ err = PTR_ERR(ctx->vci);
+ return dev_err_probe(dev, err, "Failed to request vci regulator: %d\n", err);
+ }
+
+ ctx->iovcc = devm_regulator_get(dev, "iovcc");
+ if (IS_ERR(ctx->iovcc)) {
+ err = PTR_ERR(ctx->iovcc);
+ return dev_err_probe(dev, err, "Failed to request iovcc regulator: %d\n", err);
+ }
+
+ err = of_drm_get_panel_orientation(dev->of_node, &ctx->orientation);
+ if (err) {
+ dev_err(dev, "%pOF: failed to get orientation %d\n", dev->of_node, err);
+ return err;
+ }
+
+ /* NOTE: this is only available on RPi's fork for the moment
+ * Maybe need to move part of the init sequence to cwu50_enable() instead of
+ * keeping them in cwu50_prepare().
+ */
+ ctx->panel.prepare_upstream_first = true;
+
+ drm_panel_init(&ctx->panel, dev, &cwu50_drm_funcs, DRM_MODE_CONNECTOR_DSI);
+
+ err = drm_panel_of_backlight(&ctx->panel);
+ if (err)
+ return dev_err_probe(dev, err, "Failed to get backlight\n");
+
+ drm_panel_add(&ctx->panel);
+
+ err = mipi_dsi_attach(dsi);
+ if (err < 0) {
+ dev_err(dev, "mipi_dsi_attach() failed: %d\n", err);
+ drm_panel_remove(&ctx->panel);
+ return err;
+ }
+
+ return 0;
+}
+
+static void cwu50_remove(struct mipi_dsi_device *dsi)
+{
+ struct cwu50 *ctx = mipi_dsi_get_drvdata(dsi);
+
+ mipi_dsi_detach(dsi);
+ drm_panel_remove(&ctx->panel);
+}
+
+static const struct of_device_id cwu50_of_match[] = {
+ { .compatible = "clockwork,cwu50" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cwu50_of_match);
+
+static struct mipi_dsi_driver cwu50_driver = {
+ .probe = cwu50_probe,
+ .remove = cwu50_remove,
+ .driver = {
+ .name = "panel-clockwork-cwu50",
+ .of_match_table = cwu50_of_match,
+ },
+};
+module_mipi_dsi_driver(cwu50_driver);
+
+MODULE_DESCRIPTION("ClockworkPi CWU50 panel driver");
+MODULE_LICENSE("GPL v2");
--
2.43.0

View file

@ -0,0 +1,203 @@
From e790ee89bbf63aa6f2741f4c18760ae877868daa Mon Sep 17 00:00:00 2001
From: Potato <nikko@faint.day>
Date: Fri, 13 Oct 2023 11:08:40 +0800
Subject: [PATCH 3/6] driver: staging: add uconsole simple amplifier switch
---
drivers/staging/Kconfig | 2 +
drivers/staging/Makefile | 1 +
drivers/staging/uconsole/Kconfig | 10 ++
drivers/staging/uconsole/Makefile | 1 +
.../uconsole/simple-amplifier-switch.c | 131 ++++++++++++++++++
5 files changed, 145 insertions(+)
create mode 100644 drivers/staging/uconsole/Kconfig
create mode 100644 drivers/staging/uconsole/Makefile
create mode 100644 drivers/staging/uconsole/simple-amplifier-switch.c
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 5cfabd5376cc..a5b88d33d3de 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -80,4 +80,6 @@ source "drivers/staging/qlge/Kconfig"
source "drivers/staging/vme_user/Kconfig"
+source "drivers/staging/uconsole/Kconfig"
+
endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index f8c3aa9c2418..4c09e021e321 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -2,6 +2,7 @@
# Makefile for staging directory
obj-y += media/
+obj-y += uconsole/
obj-$(CONFIG_PRISM2_USB) += wlan-ng/
obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/
obj-$(CONFIG_RTL8192U) += rtl8192u/
diff --git a/drivers/staging/uconsole/Kconfig b/drivers/staging/uconsole/Kconfig
new file mode 100644
index 000000000000..303e2e26a0b1
--- /dev/null
+++ b/drivers/staging/uconsole/Kconfig
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+config SIMPLE_AMPLIFIER_SWITCH
+ tristate "Simple amplifier switch driver"
+ depends on OF
+ depends on GPIOLIB
+ default n
+ help
+ Driver for simple gpio based switches. This can control a series of
+ gpios with another one. Used to control amplifiers with headphone
+ detect pin on uConsole.
diff --git a/drivers/staging/uconsole/Makefile b/drivers/staging/uconsole/Makefile
new file mode 100644
index 000000000000..8f3239c1f36c
--- /dev/null
+++ b/drivers/staging/uconsole/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_SIMPLE_AMPLIFIER_SWITCH) += simple-amplifier-switch.o
diff --git a/drivers/staging/uconsole/simple-amplifier-switch.c b/drivers/staging/uconsole/simple-amplifier-switch.c
new file mode 100644
index 000000000000..2471e035c213
--- /dev/null
+++ b/drivers/staging/uconsole/simple-amplifier-switch.c
@@ -0,0 +1,131 @@
+// SPDX-License-Identifier: GPL-2.0
+//
+// simple gpio switch support
+// use one gpio to control gpios
+// this really should be a generic gpio switch driver, leave it here anyway.
+//
+// Copyright (C) 2023 PotatoMania <nikko@faint.day>
+//
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/gpio/consumer.h>
+// #include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/interrupt.h>
+
+/* TODO: support regulators? */
+struct simple_amplifier_switch {
+ struct gpio_desc *sw;
+ struct gpio_descs *outputs;
+};
+
+// Components:
+// sw-gpios: 1 switch input
+// outputs-gpios: array of gpios
+
+static inline void set_outputs(struct gpio_descs *outputs, int value)
+{
+ unsigned long *values;
+ int nvalues = outputs->ndescs;
+
+ values = bitmap_alloc(nvalues, GFP_KERNEL);
+ if (!values)
+ return;
+
+ if (value)
+ bitmap_fill(values, nvalues);
+ else
+ bitmap_zero(values, nvalues);
+
+ gpiod_set_array_value_cansleep(nvalues, outputs->desc,
+ outputs->info, values);
+
+ bitmap_free(values);
+}
+
+static irqreturn_t amplifier_switch_interrupt(int irq, void *data)
+{
+ struct simple_amplifier_switch *ampsw = data;
+ int state;
+
+ state = gpiod_get_value(ampsw->sw);
+ set_outputs(ampsw->outputs, state);
+
+ return IRQ_HANDLED;
+}
+
+static int amplifier_switch_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct simple_amplifier_switch *ampsw;
+ int current_state;
+ int err;
+
+ ampsw = devm_kzalloc(dev, sizeof(*ampsw), GFP_KERNEL);
+ if (!ampsw)
+ return -ENOMEM;
+
+ ampsw->sw = devm_gpiod_get(dev, "sw", GPIOD_IN);
+ if (IS_ERR(ampsw->sw)) {
+ err = PTR_ERR(ampsw->sw);
+ dev_err(dev, "Failed to get sw gpio! The input is required! (%d)\n", err);
+ return err;
+ }
+
+ ampsw->outputs = devm_gpiod_get_array(dev, "outputs", GPIOD_OUT_LOW);
+ if (IS_ERR(ampsw->outputs)) {
+ err = PTR_ERR(ampsw->outputs);
+ dev_err(dev, "Failed to get outputs gpios! (%d)\n", err);
+ return err;
+ }
+
+ // setup initial state
+ current_state = gpiod_get_value(ampsw->sw);
+ set_outputs(ampsw->outputs, current_state);
+
+ // register interrupts
+ err = devm_request_irq(dev, gpiod_to_irq(ampsw->sw), amplifier_switch_interrupt,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "amplifier-switch", ampsw);
+ if (err) {
+ dev_err(dev, "Failed to request interrupt (%d)\n", err);
+ return err;
+ }
+
+ platform_set_drvdata(pdev, ampsw);
+
+ return 0;
+}
+
+static void amplifier_switch_shutdown(struct platform_device *pdev)
+{
+ struct simple_amplifier_switch *ampsw = platform_get_drvdata(pdev);
+
+ // Unregister interrupt
+ devm_free_irq(&pdev->dev, gpiod_to_irq(ampsw->sw), ampsw);
+
+ // Turn off all outputs
+ set_outputs(ampsw->outputs, 0);
+}
+
+static const struct of_device_id of_amplifier_switchs_match[] = {
+ { .compatible = "simple-amplifier-switch" },
+ {/* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, of_amplifier_switchs_match);
+
+static struct platform_driver amplifier_switch_driver = {
+ .probe = amplifier_switch_probe,
+ .shutdown = amplifier_switch_shutdown,
+ .driver = {
+ .name = "simple-amplifier-switch",
+ .of_match_table = of_amplifier_switchs_match,
+ },
+};
+
+module_platform_driver(amplifier_switch_driver);
+
+MODULE_AUTHOR("PotatoMania <nikko@faint.day>");
+MODULE_DESCRIPTION("A simple GPIO controlled gpios switch");
+MODULE_LICENSE("GPL v2");
\ No newline at end of file
--
2.43.0

View file

@ -0,0 +1,254 @@
Original patch: https://github.com/PotatoMania/uconsole-cm3/blob/dev/PKGBUILDs/linux-uconsole-cm3-rpi64/0004-arm-dts-overlays-add-uconsole.patch
Adapted from Raspberry Pi CM3 to Raspberry Pi CM4
diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile
index 04a9c9a8ab90..ddd90f3f087d 100644
--- a/arch/arm/boot/dts/overlays/Makefile
+++ b/arch/arm/boot/dts/overlays/Makefile
@@ -284,6 +284,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
uart4.dtbo \
uart4-pi5.dtbo \
uart5.dtbo \
+ uconsole.dtbo \
udrc.dtbo \
ugreen-dabboard.dtbo \
upstream.dtbo \
diff --git a/arch/arm/boot/dts/overlays/uconsole.dts b/arch/arm/boot/dts/overlays/uconsole.dts
new file mode 100644
index 000000000000..bfc12f7a029b
--- /dev/null
+++ b/arch/arm/boot/dts/overlays/uconsole.dts
@@ -0,0 +1,233 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/gpio/gpio.h>
+
+/* uConsole All In One */
+
+/ {
+ compatible = "brcm,bcm2835";
+
+ fragment@70 {
+ target-path = "/aliases";
+ __overlay__ {
+ i2c_uconsole = "/i2c@0";
+ };
+ };
+
+ fragment@71 {
+ target-path = "/__symbols__";
+ __overlay__ {
+ i2c_uconsole = "/i2c@0";
+ };
+ };
+
+ fragment@80 {
+ target-path = "/chosen";
+ __overlay__ {
+ bootargs = "snd_bcm2835.enable_headphones=1";
+ };
+ };
+
+ fragment@90 {
+ target-path = "/";
+ __overlay__ {
+ audio_amplifier: audio-amplifier {
+ compatible = "simple-amplifier-switch";
+ sw-gpios = <&gpio 10 1>; /* GPIO10, GPIO_ACTIVE_LOW */
+ outputs-gpios = <&gpio 11 0>; /* GPIO11, GPIO_ACTIVE_HIGH */
+ // vdd-supply = <&uc_reg_5v0>;
+ };
+
+ ocp8178_backlight: backlight@0 {
+ compatible = "ocp8178-backlight";
+ backlight-control-gpios = <&gpio 9 0>; /* GPIO9 ACTIVE HIGH */
+ default-brightness = <5>;
+ // vdd-supply = <&uc_reg_5v0>;
+ };
+
+ battery: battery@0 {
+ compatible = "simple-battery";
+ constant-charge-current-max-microamp = <2100000>;
+ voltage-min-design-microvolt = <3300000>;
+ voltage-max-design-microvolt = <4200000>;
+ };
+
+ i2c_uconsole: i2c@0 {
+ reg = <3>;
+ compatible = "i2c-gpio";
+ gpios = <&gpio 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* sda */
+ &gpio 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN) /* scl */
+ >;
+ i2c-gpio,delay-us = <2>; /* ~100 kHz */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+
+ /* TPS61178, the supply for 5V bus, including USB, backlight
+ */
+ // uc_reg_5v0: uc-reg-5v0 {
+ // compatible = "fixed-regulator";
+ // regulator-name = "sys-5v0";
+ // regulator-boot-on;
+ // regulator-always-on; /* cannot be turned off anyway */
+ // vin-supply = <&usb_power_supply>;
+ // };
+ };
+ };
+};
+
+&leds {
+ /delete-node/ led-act;
+
+ /* This is the green LED under the power button,
+ * However this is not usable without a hardware modification(move R117 to R116)
+ */
+ // act_led: led-act {
+ // linux,default-trigger = "default-on";
+ // gpios = <&axp_gpio 0 1>; /* gpio0 on pmu, low active */
+ // // function = "activity";
+ // };
+
+ /* This is the orange charging LED under the power button.
+ * Requires a patch to the pinctrl-axp209 driver, because
+ * charge led is not a gpio thus not supported.
+ */
+ // chg_led: led-chg {
+ // linux,default-trigger = "axp20x-battery-charging-blink-full-solid";
+ // gpios = <&axp_gpio 99 1>; /* CHGLED on pmu, low active */
+ // };
+};
+
+/* PMU */
+&i2c_uconsole {
+
+ axp22x: pmic@34 {
+ interrupt-controller;
+ #interrupt-cells = <1>;
+ compatible = "x-powers,axp228", "x-powers,axp223", "x-powers,axp221";
+ reg = <0x34>; /* i2c address */
+ interrupt-parent = <&gpio>;
+ interrupts = <2 8>; /* IRQ_TYPE_LEVEL_LOW */
+ irq-gpios = <&gpio 2 0>;
+
+ /* TODO: figure out the initial output states */
+ regulators {
+
+ x-powers,dcdc-freq = <3000>;
+
+ reg_dcdc1: dcdc1 {
+ regulator-name = "sys-3v3";
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ reg_dcdc3: dcdc3 {
+ regulator-name = "sys-1v8";
+ regulator-always-on;
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ };
+
+ /* TODO: switch this on demand? */
+ reg_aldo1: aldo1 {
+ regulator-name = "aud-3v3";
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ reg_aldo2: aldo2 {
+ regulator-name = "disp-3v3";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ /* DLDO2-DLDO4 are connected in parallel.
+ * They seem not necessary, BUT they are connected to the TPS2553's enable pin!
+ * Disable them will shutdown the USB 5V line.
+ */
+ reg_dldo2: dldo2 {
+ regulator-name = "vcc-3v3-ext-a";
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ reg_dldo3: dldo3 {
+ regulator-name = "vcc-3v3-ext-b";
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+
+ reg_dldo4: dldo4 {
+ regulator-name = "vcc-3v3-ext-c";
+ regulator-always-on;
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ };
+ };
+
+ battery_power_supply: battery-power-supply {
+ compatible = "x-powers,axp221-battery-power-supply";
+ monitored-battery = <&battery>;
+ };
+
+ ac_power_supply: ac_power_supply {
+ compatible = "x-powers,axp221-ac-power-supply";
+ };
+
+ axp_adc: adc {
+ compatible = "x-powers,axp221-adc";
+ #io-channel-cells = <1>;
+ };
+
+ axp_gpio: gpio {
+ compatible = "x-powers,axp221-gpio";
+ gpio-controller;
+ #gpio-cells = <2>;
+ status = "disabled";
+
+ gpio0_out: gpio0-out-pin {
+ pins = "GPIO0";
+ function = "gpio_out";
+ };
+ };
+
+ /* IPSOUT, feed to on-board buck to get 5V output */
+ /* TODO: figure out how to configure it properly */
+ usb_power_supply: usb-power {
+ compatible = "x-powers,axp221-usb-power-supply";
+ };
+ };
+};
+
+&dsi1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ port {
+ dsi_out_port: endpoint {
+ remote-endpoint = <&panel_dsi_port>;
+ };
+ };
+
+ panel_cwu50: panel@0 {
+ compatible = "clockwork,cwu50";
+ reg = <0>;
+ reset-gpio = <&gpio 8 1>; /* GPIO8 ACTIVE LOW */
+ backlight = <&ocp8178_backlight>;
+ rotation = <90>;
+ iovcc-supply = <&reg_dcdc3>;
+ vci-supply = <&reg_aldo2>;
+
+ port {
+ panel_dsi_port: endpoint {
+ remote-endpoint = <&dsi_out_port>;
+ };
+ };
+ };
+};

View file

@ -0,0 +1,146 @@
From af0bfa3cdd4a19ed5da5f43da250982b2217239d Mon Sep 17 00:00:00 2001
From: Potato <nikko@faint.day>
Date: Tue, 24 Oct 2023 19:08:18 +0800
Subject: [PATCH 5/6] drivers: power: axp20x: customize PMU
This patch set some default states, add new sysfs interfaces, and register the
power off callback to kernel. Mostly harmless.
---
drivers/mfd/axp20x.c | 22 +++++++++++++
drivers/power/supply/axp20x_ac_power.c | 3 ++
drivers/power/supply/axp20x_battery.c | 44 ++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index 880c41fa7021..27c2000badc7 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
@@ -845,6 +846,21 @@ static void axp20x_power_off(void)
mdelay(500);
}
+static int axp20x_power_off_handler(struct sys_off_data *data)
+{
+ struct axp20x_dev *device = data->cb_data;
+
+ if (device->variant == AXP288_ID)
+ return NOTIFY_DONE;
+
+ regmap_write(device->regmap, AXP20X_OFF_CTRL, AXP20X_OFF);
+
+ /* Give capacitors etc. time to drain to avoid kernel panic msg. */
+ mdelay(500);
+
+ return NOTIFY_DONE;
+}
+
int axp20x_match_device(struct axp20x_dev *axp20x)
{
struct device *dev = axp20x->dev;
@@ -1012,6 +1028,12 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
if (!pm_power_off) {
axp20x_pm_power_off = axp20x;
pm_power_off = axp20x_power_off;
+ } else {
+ /* register power off handler */
+ ret = devm_register_power_off_handler(axp20x->dev, axp20x_power_off_handler, axp20x);
+ if (ret) {
+ dev_warn(axp20x->dev, "Failed to register power off handler! (%d)", ret);
+ }
}
dev_info(axp20x->dev, "AXP20X driver loaded\n");
diff --git a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c
index 57e50208d537..ce7ad453201c 100644
--- a/drivers/power/supply/axp20x_ac_power.c
+++ b/drivers/power/supply/axp20x_ac_power.c
@@ -53,6 +53,9 @@ static irqreturn_t axp20x_ac_power_irq(int irq, void *devid)
{
struct axp20x_ac_power *power = devid;
+ /* do not limit IPSOUT current */
+ regmap_update_bits(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x03);
+
power_supply_changed(power->supply);
return IRQ_HANDLED;
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index 9106077c0dbb..53b53137a480 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,
+ &reg);
+ 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, &reg);
+ 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;
}
@@ -497,6 +533,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,
@@ -642,6 +680,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); /* do not limit IPSOUT current */
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_OFF_CTRL, 0x08, 0x08); /* set charge led controlled by charge module */
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL2, 0x30, 0x20); /* full charge output, charge led function type */
+ // regmap_update_bits(axp20x_batt->regmap, AXP20X_PEK_KEY, 0x0f, 0x0b); /* configure power key, this is handled by PEK driver */
+ regmap_update_bits(axp20x_batt->regmap, AXP20X_GPIO0_CTRL, 0x07, 0x00); /* configure charging LED */
+
return 0;
}
--
2.43.0

View file

@ -0,0 +1,178 @@
From 64524afd6b6598addcf77c92832abdcd508fc8b4 Mon Sep 17 00:00:00 2001
From: Potato <nikko@faint.day>
Date: Sat, 4 Nov 2023 19:02:17 +0800
Subject: [PATCH 6/6] power: axp20x_battery: implement calibration
- add sysfs interface to initiate calibration
- capacity/energy is read from PMU rather than using a predefined value
- energy_full_designed is loaded from either
energy-full-design-microwatt-hours or charge-full-design-microamp-hours
- default is 8Wh
---
drivers/power/supply/axp20x_battery.c | 78 +++++++++++++++++++++++----
1 file changed, 68 insertions(+), 10 deletions(-)
diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
index 53b53137a480..609d240305a2 100644
--- a/drivers/power/supply/axp20x_battery.c
+++ b/drivers/power/supply/axp20x_battery.c
@@ -56,6 +56,10 @@
#define AXP20X_V_OFF_MASK GENMASK(2, 0)
+#define AXP228_FULL_CAPACITY_CALIBRATE_EN BIT(5)
+#define AXP228_CAPACITY_CALIBRATE BIT(4)
+#define AXP228_CALIBRATE_MASK (BIT(4) | BIT(5))
+
struct axp20x_batt_ps;
struct axp_data {
@@ -75,6 +79,7 @@ struct axp20x_batt_ps {
struct iio_channel *batt_v;
/* Maximum constant charge current */
unsigned int max_ccc;
+ int energy_full_design;
const struct axp_data *data;
};
@@ -328,6 +333,7 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_ENERGY_FULL:
case POWER_SUPPLY_PROP_ENERGY_NOW:
+ case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
/* When no battery is present, return 0 */
ret = regmap_read(axp20x_batt->regmap, AXP20X_PWR_OP_MODE,
&reg);
@@ -339,8 +345,29 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
return 0;
}
+ if(psp == POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN) {
+ val->intval = axp20x_batt->energy_full_design;
+ return 0;
+ }
+
+ /* read capacity from PMU */
+ val->intval = axp20x_batt->energy_full_design;
+
+ ret = regmap_read(axp20x_batt->regmap, AXP288_FG_DES_CAP0_REG, &reg); // [7:0]
+ if (ret)
+ return ret;
+
+ val1 = reg;
+
+ ret = regmap_read(axp20x_batt->regmap, AXP288_FG_DES_CAP1_REG, &reg); // [14:8]
+ if (ret)
+ return ret;
+
+ val1 |= (reg & 0x3F) << 8; // capacity report from pmu, unit 1.456mAh
+ val1 = val1 * 1456 * 36 / 10; // uWh
+
if(psp == POWER_SUPPLY_PROP_ENERGY_FULL) {
- val->intval = 8000000;
+ val->intval = val1;
return 0;
}
@@ -351,15 +378,18 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
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;
+ reg = reg & AXP209_FG_PERCENT;
+ reg = max(min(reg, 100), 0);
+ val->intval = (reg * ((long long int)(val1))) / 100;
+ break;
- val->intval = val1 * 100000;
+ case POWER_SUPPLY_PROP_CALIBRATE:
+ /* report both calibrate enable flag and calibration status */
+ ret = regmap_read(axp20x_batt->regmap, AXP20X_CC_CTRL, &reg);
+ if (ret)
+ return ret;
+ val1 = reg & AXP228_CALIBRATE_MASK;
+ val->intval = val1;
break;
default:
@@ -490,6 +520,7 @@ static int axp20x_battery_set_prop(struct power_supply *psy,
const union power_supply_propval *val)
{
struct axp20x_batt_ps *axp20x_batt = power_supply_get_drvdata(psy);
+ int val1;
switch (psp) {
case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
@@ -504,6 +535,15 @@ static int axp20x_battery_set_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
return axp20x_set_max_constant_charge_current(axp20x_batt,
val->intval);
+ case POWER_SUPPLY_PROP_CALIBRATE:
+ if (val->intval) {
+ // enable calibrate
+ val1 = AXP228_FULL_CAPACITY_CALIBRATE_EN | AXP228_CAPACITY_CALIBRATE;
+ } else {
+ // disable calibrate
+ val1 = 0;
+ }
+ return regmap_update_bits(axp20x_batt->regmap, AXP20X_CC_CTRL, AXP228_CALIBRATE_MASK, val1);
case POWER_SUPPLY_PROP_STATUS:
switch (val->intval) {
case POWER_SUPPLY_STATUS_CHARGING:
@@ -535,6 +575,8 @@ static enum power_supply_property axp20x_battery_props[] = {
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_ENERGY_FULL,
POWER_SUPPLY_PROP_ENERGY_NOW,
+ POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
+ POWER_SUPPLY_PROP_CALIBRATE,
};
static int axp20x_battery_prop_writeable(struct power_supply *psy,
@@ -544,7 +586,8 @@ static int axp20x_battery_prop_writeable(struct power_supply *psy,
psp == POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN ||
psp == POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN ||
psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT ||
- psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX;
+ psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX ||
+ psp == POWER_SUPPLY_PROP_CALIBRATE;
}
static const struct power_supply_desc axp20x_batt_ps_desc = {
@@ -654,6 +697,7 @@ static int axp20x_power_probe(struct platform_device *pdev)
if (!power_supply_get_battery_info(axp20x_batt->batt, &info)) {
int vmin = info->voltage_min_design_uv;
int ccc = info->constant_charge_current_max_ua;
+ int cfd = info->charge_full_design_uah;
if (vmin > 0 && axp20x_set_voltage_min_design(axp20x_batt,
vmin))
@@ -671,6 +715,20 @@ static int axp20x_power_probe(struct platform_device *pdev)
axp20x_batt->max_ccc = ccc;
axp20x_set_constant_charge_current(axp20x_batt, ccc);
}
+
+ if (info->energy_full_design_uwh != info->charge_full_design_uah) {
+ if (info->energy_full_design_uwh == -EINVAL)
+ dev_warn(axp20x_batt->dev, "missing battery:energy-full-design-microwatt-hours\n");
+ else if (info->charge_full_design_uah == -EINVAL)
+ dev_warn(axp20x_batt->dev, "missing battery:charge-full-design-microamp-hours\n");
+ }
+
+ if (info->energy_full_design_uwh != -EINVAL)
+ axp20x_batt->energy_full_design = info->energy_full_design_uwh;
+ else if (info->charge_full_design_uah != -EINVAL)
+ axp20x_batt->energy_full_design = cfd / 10 * 36; // assume standard voltage 3.6V
+ else
+ axp20x_batt->energy_full_design = 8000000; // default capacity, 8Wh
}
/*
--
2.43.0

View file

@ -0,0 +1,85 @@
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/bcm2711_defconfig
# Maintainer: Federico Amedeo Izzo <federico@izzo.pro>
pkgname=linux-clockworkpi-uconsole-cm4
pkgver=6.1.74
pkgrel=0
pkgdesc="Clockwork Tech ClockworkPi uConsole CM4 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="clockworkpi-uconsole-cm4"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
depends="linux-firmware-brcm"
makedepends="
bash
bc
bison
devicepkg-dev
flex
installkernel
linux-firmware
linux-headers
openssl-dev
perl
xz
"
# Source
_repository="linux"
_commit="1cdbd99f402b76c61632d09a49b20ce90af0cc72"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/raspberrypi/$_repository/archive/$_commit.tar.gz
$_config
0001-video-backlight-Add-OCP8178-backlight-driver.patch
0002-drm-panel-add-clockwork-cwu50.patch
0003-driver-staging-add-uconsole-simple-amplifier-switch.patch
0004-arm-dts-overlays-add-uconsole-cm4.patch
0005-drivers-power-axp20x-customize-PMU.patch
0006-power-axp20x_battery-implement-calibration.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"
prepare() {
default_prepare
cp "$srcdir/config-$_flavor.$CARCH" .config
}
build() {
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS"
}
package() {
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor"
local INSTALL_DTBS_PATH="$pkgdir"/boot
mkdir -p "$pkgdir"/boot
make modules_install dtbs_install \
ARCH="$_carch" \
INSTALL_PATH="$pkgdir"/boot \
INSTALL_MOD_PATH="$pkgdir" \
INSTALL_MOD_STRIP=1 \
INSTALL_DTBS_PATH="$INSTALL_DTBS_PATH"
rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source
mv -f "$INSTALL_DTBS_PATH"/broadcom/*.dtb \
"$INSTALL_DTBS_PATH"
rmdir "$INSTALL_DTBS_PATH"/broadcom
}
sha512sums="
880edc35f448ae2a072706efeda064a27273a25469a63c5bd7020fca1b115c13504b4d50135b97a6102a311dfa61419ce02d9f417ec673af3d1118529b015e1c linux-clockworkpi-uconsole-cm4-1cdbd99f402b76c61632d09a49b20ce90af0cc72.tar.gz
9578b4eb1a43bdd63c500227067b4ccaaedf29333c5bc8510404fa1015a63c9a291ab2a5262e697fec4b6a810fc03ef4d74f95fa9d93425bbbab2e00b7561399 config-clockworkpi-uconsole-cm4.aarch64
764faf249f98ba7a2299cf318bbd8e0922ab3a283dab8331710eccf83e4cc0088b4aa27894c196a2da5a08942c42ee173ca585844fa6abe36f9402095d845287 0001-video-backlight-Add-OCP8178-backlight-driver.patch
3b4eb2cbf11d4b094d75070bd8ab7926f495c3bfc1b1ecc3ddd4b7a5e2355120eaf1fca4e4fe1884de4249808525f5271a1a8db14f583f89b096d0000ca01eac 0002-drm-panel-add-clockwork-cwu50.patch
523ebd73d069c7e2ee55cefdcc9d2132264148dc13dfd79606cf87868ba86136d9df3dd7f54b130440544f51bbf8822a0a3c50eec34d54c996d867e260afa28c 0003-driver-staging-add-uconsole-simple-amplifier-switch.patch
9cf45723ede7eee7f3b6548e0e424db9403a4c863b22c4b63063370042ac1385b5b005be9e52d3e7fb8d3a6ca71c775b2f4f1ca328f8c3ad226abf88a11f0d01 0004-arm-dts-overlays-add-uconsole-cm4.patch
46cdb2bd144168c28cabbf235f4d0e23016a89a434670e12414e26422200ee3ff692168a9506a3989f93b60aac15903f6a641685cfe7d52193bc711bc648f6a0 0005-drivers-power-axp20x-customize-PMU.patch
f86fb6e30e64c3594b9a9dcd855e962265ea642cc72a79404ae9f939a0122543d3cf4c462cc5b19d8f37dc9558276d1747285149b3e96caf7fff2a1bdc0a5295 0006-power-axp20x_battery-implement-calibration.patch
"