mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-02 17:20:59 +00:00
bcm27xx: add 6.6 kernel patches
The patches were generated from the RPi repo with the following command: git format-patch v6.6.34..rpi-6.1.y Some patches needed rebasing and, as usual, the applied and reverted, wireless drivers, Github workflows, READMEs and defconfigs patches were removed. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
e8067fa108
commit
8c405cdccc
@ -0,0 +1,102 @@
|
||||
From e2726f05782135e15537575e95faea46c40a88a2 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Thu, 7 Apr 2022 18:23:07 +0100
|
||||
Subject: [PATCH 0003/1085] raspberrypi-firmware: Update mailbox commands
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
include/soc/bcm2835/raspberrypi-firmware.h | 28 +++++++++++++++++++++-
|
||||
1 file changed, 27 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/include/soc/bcm2835/raspberrypi-firmware.h
|
||||
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
|
||||
@@ -36,6 +36,8 @@ struct rpi_firmware_property_tag_header
|
||||
enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_PROPERTY_END = 0,
|
||||
RPI_FIRMWARE_GET_FIRMWARE_REVISION = 0x00000001,
|
||||
+ RPI_FIRMWARE_GET_FIRMWARE_VARIANT = 0x00000002,
|
||||
+ RPI_FIRMWARE_GET_FIRMWARE_HASH = 0x00000003,
|
||||
|
||||
RPI_FIRMWARE_SET_CURSOR_INFO = 0x00008010,
|
||||
RPI_FIRMWARE_SET_CURSOR_STATE = 0x00008011,
|
||||
@@ -71,6 +73,7 @@ enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_GET_DISPMANX_RESOURCE_MEM_HANDLE = 0x00030014,
|
||||
RPI_FIRMWARE_GET_EDID_BLOCK = 0x00030020,
|
||||
RPI_FIRMWARE_GET_CUSTOMER_OTP = 0x00030021,
|
||||
+ RPI_FIRMWARE_GET_EDID_BLOCK_DISPLAY = 0x00030023,
|
||||
RPI_FIRMWARE_GET_DOMAIN_STATE = 0x00030030,
|
||||
RPI_FIRMWARE_GET_THROTTLED = 0x00030046,
|
||||
RPI_FIRMWARE_GET_CLOCK_MEASURED = 0x00030047,
|
||||
@@ -89,8 +92,11 @@ enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_GET_PERIPH_REG = 0x00030045,
|
||||
RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045,
|
||||
RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049,
|
||||
- RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00030050,
|
||||
+ RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00038049,
|
||||
+ RPI_FIRMWARE_SET_POE_HAT_VAL_OLD = 0x00030050,
|
||||
RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058,
|
||||
+ RPI_FIRMWARE_GET_REBOOT_FLAGS = 0x00030064,
|
||||
+ RPI_FIRMWARE_SET_REBOOT_FLAGS = 0x00038064,
|
||||
RPI_FIRMWARE_NOTIFY_DISPLAY_DONE = 0x00030066,
|
||||
|
||||
/* Dispmanx TAGS */
|
||||
@@ -105,9 +111,16 @@ enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_FRAMEBUFFER_GET_VIRTUAL_OFFSET = 0x00040009,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_GET_OVERSCAN = 0x0004000a,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_GET_PALETTE = 0x0004000b,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_LAYER = 0x0004000c,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_TRANSFORM = 0x0004000d,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_VSYNC = 0x0004000e,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_GET_TOUCHBUF = 0x0004000f,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF = 0x00040010,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_RELEASE = 0x00048001,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_ID = 0x00040016,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM = 0x00048013,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS = 0x00040013,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_SETTINGS = 0x00040014,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT = 0x00044004,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_DEPTH = 0x00044005,
|
||||
@@ -116,22 +129,33 @@ enum rpi_firmware_property_tag {
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_VIRTUAL_OFFSET = 0x00044009,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_OVERSCAN = 0x0004400a,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_PALETTE = 0x0004400b,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_TEST_LAYER = 0x0004400c,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_TEST_TRANSFORM = 0x0004400d,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_TEST_VSYNC = 0x0004400e,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT = 0x00048003,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT = 0x00048004,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_DEPTH = 0x00048005,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_PITCH = 0x00048008,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE = 0x0004800b,
|
||||
+
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF = 0x0004801f,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF = 0x00048020,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC = 0x0004800e,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_LAYER = 0x0004800c,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_TRANSFORM = 0x0004800d,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f,
|
||||
|
||||
RPI_FIRMWARE_VCHIQ_INIT = 0x00048010,
|
||||
|
||||
+ RPI_FIRMWARE_SET_PLANE = 0x00048015,
|
||||
+ RPI_FIRMWARE_GET_DISPLAY_TIMING = 0x00040017,
|
||||
+ RPI_FIRMWARE_SET_TIMING = 0x00048017,
|
||||
+ RPI_FIRMWARE_GET_DISPLAY_CFG = 0x00040018,
|
||||
+ RPI_FIRMWARE_SET_DISPLAY_POWER = 0x00048019,
|
||||
RPI_FIRMWARE_GET_COMMAND_LINE = 0x00050001,
|
||||
RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001,
|
||||
};
|
||||
@@ -155,6 +179,8 @@ enum rpi_firmware_clk_id {
|
||||
RPI_FIRMWARE_NUM_CLK_ID,
|
||||
};
|
||||
|
||||
+#define GET_DISPLAY_SETTINGS_PAYLOAD_SIZE 64
|
||||
+
|
||||
/**
|
||||
* struct rpi_firmware_clk_rate_request - Firmware Request for a rate
|
||||
* @id: ID of the clock being queried
|
@ -0,0 +1,27 @@
|
||||
From 719d68c874bde83f2410dc41a34c3ddf6d71bda9 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Tue, 19 May 2020 16:20:30 +0100
|
||||
Subject: [PATCH 0004/1085] drm/vc4: Add FKMS as an acceptable node for dma
|
||||
ranges.
|
||||
|
||||
Under FKMS, the firmware (via FKMS) also requires the VideoCore cache
|
||||
aliases for image planes, as defined by the dma-ranges under /soc.
|
||||
|
||||
Add rpi-firmware-kms to the list of acceptable nodes to look for
|
||||
to copy dma config from.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_drv.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
|
||||
@@ -276,6 +276,7 @@ static void vc4_component_unbind_all(voi
|
||||
static const struct of_device_id vc4_dma_range_matches[] = {
|
||||
{ .compatible = "brcm,bcm2711-hvs" },
|
||||
{ .compatible = "brcm,bcm2835-hvs" },
|
||||
+ { .compatible = "raspberrypi,rpi-firmware-kms" },
|
||||
{ .compatible = "brcm,bcm2835-v3d" },
|
||||
{ .compatible = "brcm,cygnus-v3d" },
|
||||
{ .compatible = "brcm,vc4-v3d" },
|
@ -0,0 +1,25 @@
|
||||
From de213e0c7477e4c1be9a80cd9ebf97227ed75dbe Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Thu, 7 Jan 2021 16:30:55 +0000
|
||||
Subject: [PATCH 0005/1085] drm/atomic: Don't fixup modes that haven't been
|
||||
reset
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/drm_atomic_helper.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/drm_atomic_helper.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_helper.c
|
||||
@@ -443,6 +443,11 @@ mode_fixup(struct drm_atomic_state *stat
|
||||
new_crtc_state =
|
||||
drm_atomic_get_new_crtc_state(state, new_conn_state->crtc);
|
||||
|
||||
+ if (!new_crtc_state->mode_changed &&
|
||||
+ !new_crtc_state->connectors_changed) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
/*
|
||||
* Each encoder has at most one connector (since we always steal
|
||||
* it away), so we won't call ->mode_fixup twice.
|
@ -0,0 +1,210 @@
|
||||
From 4fac21e3a4d37667a86c762064dad5f76c42c235 Mon Sep 17 00:00:00 2001
|
||||
From: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
|
||||
Date: Thu, 15 Jul 2021 01:08:01 +0200
|
||||
Subject: [PATCH 0006/1085] drm/vc4: Allow setting the TV norm via module
|
||||
parameter
|
||||
|
||||
Similar to the ch7006 and nouveau drivers, introduce a "tv_mode" module
|
||||
parameter that allow setting the TV norm by specifying vc4.tv_norm= on
|
||||
the kernel command line.
|
||||
|
||||
If that is not specified, try inferring one of the most popular norms
|
||||
(PAL or NTSC) from the video mode specified on the command line. On
|
||||
Raspberry Pis, this causes the most common cases of the sdtv_mode
|
||||
setting in config.txt to be respected.
|
||||
|
||||
Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_vec.c | 108 +++++++++++++++++++++++++---------
|
||||
1 file changed, 81 insertions(+), 27 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_vec.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_vec.c
|
||||
@@ -67,7 +67,7 @@
|
||||
#define VEC_CONFIG0_YCDELAY BIT(4)
|
||||
#define VEC_CONFIG0_RAMPEN BIT(2)
|
||||
#define VEC_CONFIG0_YCDIS BIT(2)
|
||||
-#define VEC_CONFIG0_STD_MASK GENMASK(1, 0)
|
||||
+#define VEC_CONFIG0_STD_MASK (VEC_CONFIG0_SECAM_STD | GENMASK(1, 0))
|
||||
#define VEC_CONFIG0_NTSC_STD 0
|
||||
#define VEC_CONFIG0_PAL_BDGHI_STD 1
|
||||
#define VEC_CONFIG0_PAL_M_STD 2
|
||||
@@ -186,6 +186,8 @@
|
||||
#define VEC_DAC_MISC_DAC_RST_N BIT(0)
|
||||
|
||||
|
||||
+static char *vc4_vec_tv_norm;
|
||||
+
|
||||
struct vc4_vec_variant {
|
||||
u32 dac_config;
|
||||
};
|
||||
@@ -353,6 +355,33 @@ static const struct drm_prop_enum_list l
|
||||
{ VC4_VEC_TV_MODE_SECAM, "SECAM", },
|
||||
};
|
||||
|
||||
+enum drm_connector_tv_mode
|
||||
+vc4_vec_get_default_mode(struct drm_connector *connector)
|
||||
+{
|
||||
+ if (vc4_vec_tv_norm) {
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = drm_get_tv_mode_from_name(vc4_vec_tv_norm, strlen(vc4_vec_tv_norm));
|
||||
+ if (ret >= 0)
|
||||
+ return ret;
|
||||
+ } else if (connector->cmdline_mode.specified &&
|
||||
+ ((connector->cmdline_mode.refresh_specified &&
|
||||
+ (connector->cmdline_mode.refresh == 25 ||
|
||||
+ connector->cmdline_mode.refresh == 50)) ||
|
||||
+ (!connector->cmdline_mode.refresh_specified &&
|
||||
+ (connector->cmdline_mode.yres == 288 ||
|
||||
+ connector->cmdline_mode.yres == 576)))) {
|
||||
+ /*
|
||||
+ * no explicitly specified TV norm; use PAL if a mode that
|
||||
+ * looks like PAL has been specified on the command line
|
||||
+ */
|
||||
+ return DRM_MODE_TV_MODE_PAL;
|
||||
+ }
|
||||
+
|
||||
+ /* in all other cases, default to NTSC */
|
||||
+ return DRM_MODE_TV_MODE_NTSC;
|
||||
+}
|
||||
+
|
||||
static enum drm_connector_status
|
||||
vc4_vec_connector_detect(struct drm_connector *connector, bool force)
|
||||
{
|
||||
@@ -363,6 +392,10 @@ static void vc4_vec_connector_reset(stru
|
||||
{
|
||||
drm_atomic_helper_connector_reset(connector);
|
||||
drm_atomic_helper_connector_tv_reset(connector);
|
||||
+
|
||||
+ /* preserve TV standard */
|
||||
+ if (connector->state)
|
||||
+ connector->state->tv.mode = vc4_vec_get_default_mode(connector);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -414,48 +447,52 @@ vc4_vec_connector_set_property(struct dr
|
||||
}
|
||||
|
||||
static int
|
||||
-vc4_vec_connector_get_property(struct drm_connector *connector,
|
||||
- const struct drm_connector_state *state,
|
||||
- struct drm_property *property,
|
||||
- uint64_t *val)
|
||||
+vc4_vec_generic_tv_mode_to_legacy(enum drm_connector_tv_mode tv_mode)
|
||||
{
|
||||
- struct vc4_vec *vec = connector_to_vc4_vec(connector);
|
||||
-
|
||||
- if (property != vec->legacy_tv_mode_property)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- switch (state->tv.mode) {
|
||||
+ switch (tv_mode) {
|
||||
case DRM_MODE_TV_MODE_NTSC:
|
||||
- *val = VC4_VEC_TV_MODE_NTSC;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_NTSC;
|
||||
|
||||
case DRM_MODE_TV_MODE_NTSC_443:
|
||||
- *val = VC4_VEC_TV_MODE_NTSC_443;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_NTSC_443;
|
||||
|
||||
case DRM_MODE_TV_MODE_NTSC_J:
|
||||
- *val = VC4_VEC_TV_MODE_NTSC_J;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_NTSC_J;
|
||||
|
||||
case DRM_MODE_TV_MODE_PAL:
|
||||
- *val = VC4_VEC_TV_MODE_PAL;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_PAL;
|
||||
|
||||
case DRM_MODE_TV_MODE_PAL_M:
|
||||
- *val = VC4_VEC_TV_MODE_PAL_M;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_PAL_M;
|
||||
|
||||
case DRM_MODE_TV_MODE_PAL_N:
|
||||
- *val = VC4_VEC_TV_MODE_PAL_N;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_PAL_N;
|
||||
|
||||
case DRM_MODE_TV_MODE_SECAM:
|
||||
- *val = VC4_VEC_TV_MODE_SECAM;
|
||||
- break;
|
||||
+ return VC4_VEC_TV_MODE_SECAM;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+vc4_vec_connector_get_property(struct drm_connector *connector,
|
||||
+ const struct drm_connector_state *state,
|
||||
+ struct drm_property *property,
|
||||
+ uint64_t *val)
|
||||
+{
|
||||
+ struct vc4_vec *vec = connector_to_vc4_vec(connector);
|
||||
+ enum vc4_vec_tv_mode_id legacy_mode;
|
||||
+
|
||||
+ if (property != vec->legacy_tv_mode_property)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ legacy_mode = vc4_vec_generic_tv_mode_to_legacy(state->tv.mode);
|
||||
+ if (legacy_mode < 0)
|
||||
+ return legacy_mode;
|
||||
+
|
||||
+ *val = legacy_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -478,6 +515,8 @@ static const struct drm_connector_helper
|
||||
static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec)
|
||||
{
|
||||
struct drm_connector *connector = &vec->connector;
|
||||
+ enum vc4_vec_tv_mode_id legacy_default_mode;
|
||||
+ enum drm_connector_tv_mode default_mode;
|
||||
struct drm_property *prop;
|
||||
int ret;
|
||||
|
||||
@@ -490,9 +529,17 @@ static int vc4_vec_connector_init(struct
|
||||
|
||||
drm_connector_helper_add(connector, &vc4_vec_connector_helper_funcs);
|
||||
|
||||
+ default_mode = vc4_vec_get_default_mode(connector);
|
||||
+ if (default_mode < 0)
|
||||
+ return default_mode;
|
||||
+
|
||||
drm_object_attach_property(&connector->base,
|
||||
dev->mode_config.tv_mode_property,
|
||||
- DRM_MODE_TV_MODE_NTSC);
|
||||
+ default_mode);
|
||||
+
|
||||
+ legacy_default_mode = vc4_vec_generic_tv_mode_to_legacy(default_mode);
|
||||
+ if (legacy_default_mode < 0)
|
||||
+ return legacy_default_mode;
|
||||
|
||||
prop = drm_property_create_enum(dev, 0, "mode",
|
||||
legacy_tv_mode_names,
|
||||
@@ -501,7 +548,7 @@ static int vc4_vec_connector_init(struct
|
||||
return -ENOMEM;
|
||||
vec->legacy_tv_mode_property = prop;
|
||||
|
||||
- drm_object_attach_property(&connector->base, prop, VC4_VEC_TV_MODE_NTSC);
|
||||
+ drm_object_attach_property(&connector->base, prop, legacy_default_mode);
|
||||
|
||||
drm_connector_attach_encoder(connector, &vec->encoder.base);
|
||||
|
||||
@@ -825,3 +872,10 @@ struct platform_driver vc4_vec_driver =
|
||||
.of_match_table = vc4_vec_dt_match,
|
||||
},
|
||||
};
|
||||
+
|
||||
+module_param_named(tv_norm, vc4_vec_tv_norm, charp, 0600);
|
||||
+MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
|
||||
+ "\t\tSupported: NTSC, NTSC-J, NTSC-443, PAL, PAL-M, PAL-N,\n"
|
||||
+ "\t\t\tPAL60, SECAM.\n"
|
||||
+ "\t\tDefault: PAL if a 50 Hz mode has been set via video=,\n"
|
||||
+ "\t\t\tNTSC otherwise");
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,276 @@
|
||||
From efed9f6403c125e56b9852b81f81632e85feb2eb Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Tue, 27 Apr 2021 14:24:21 +0200
|
||||
Subject: [PATCH 0008/1085] drm/vc4: Add support for gamma on BCM2711
|
||||
|
||||
BCM2711 changes from a 256 entry lookup table to a 16 point
|
||||
piecewise linear function as the pipeline bitdepth has increased
|
||||
to make a LUT unwieldy.
|
||||
|
||||
Implement a simple conversion from a 256 entry LUT that userspace
|
||||
is likely to expect to 16 evenly spread points in the PWL. This
|
||||
could be improved with curve fitting at a later date.
|
||||
|
||||
Co-developed-by: Juerg Haefliger <juergh@canonical.com>
|
||||
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 35 ++++++++++---
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 28 +++++++++--
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 89 ++++++++++++++++++++++++++++++++--
|
||||
drivers/gpu/drm/vc4/vc4_regs.h | 22 +++++++++
|
||||
4 files changed, 162 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -1340,19 +1340,42 @@ int __vc4_crtc_init(struct drm_device *d
|
||||
|
||||
if (!vc4->is_vc5) {
|
||||
drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
|
||||
+ } else {
|
||||
+ /* This is a lie for hvs5 which uses a 16 point PWL, but it
|
||||
+ * allows for something smarter than just 16 linearly spaced
|
||||
+ * segments. Conversion is done in vc5_hvs_update_gamma_lut.
|
||||
+ */
|
||||
+ drm_mode_crtc_set_gamma_size(crtc, 256);
|
||||
+ }
|
||||
|
||||
- drm_crtc_enable_color_mgmt(crtc, 0, false, crtc->gamma_size);
|
||||
+ drm_crtc_enable_color_mgmt(crtc, 0, false, crtc->gamma_size);
|
||||
|
||||
+ if (!vc4->is_vc5) {
|
||||
/* We support CTM, but only for one CRTC at a time. It's therefore
|
||||
* implemented as private driver state in vc4_kms, not here.
|
||||
*/
|
||||
drm_crtc_enable_color_mgmt(crtc, 0, true, crtc->gamma_size);
|
||||
- }
|
||||
|
||||
- for (i = 0; i < crtc->gamma_size; i++) {
|
||||
- vc4_crtc->lut_r[i] = i;
|
||||
- vc4_crtc->lut_g[i] = i;
|
||||
- vc4_crtc->lut_b[i] = i;
|
||||
+ /* Initialize the VC4 gamma LUTs */
|
||||
+ for (i = 0; i < crtc->gamma_size; i++) {
|
||||
+ vc4_crtc->lut_r[i] = i;
|
||||
+ vc4_crtc->lut_g[i] = i;
|
||||
+ vc4_crtc->lut_b[i] = i;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Initialize the VC5 gamma PWL entries. Assume 12-bit pipeline,
|
||||
+ * evenly spread over full range.
|
||||
+ */
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++) {
|
||||
+ vc4_crtc->pwl_r[i] =
|
||||
+ VC5_HVS_SET_GAMMA_ENTRY(i << 8, i << 12, 1 << 8);
|
||||
+ vc4_crtc->pwl_g[i] =
|
||||
+ VC5_HVS_SET_GAMMA_ENTRY(i << 8, i << 12, 1 << 8);
|
||||
+ vc4_crtc->pwl_b[i] =
|
||||
+ VC5_HVS_SET_GAMMA_ENTRY(i << 8, i << 12, 1 << 8);
|
||||
+ vc4_crtc->pwl_a[i] =
|
||||
+ VC5_HVS_SET_GAMMA_ENTRY(i << 8, i << 12, 1 << 8);
|
||||
+ }
|
||||
}
|
||||
|
||||
return 0;
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <kunit/test-bug.h>
|
||||
|
||||
#include "uapi/drm/vc4_drm.h"
|
||||
+#include "vc4_regs.h"
|
||||
|
||||
struct drm_device;
|
||||
struct drm_gem_object;
|
||||
@@ -494,6 +495,17 @@ struct drm_encoder *vc4_find_encoder_by_
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+struct vc5_gamma_entry {
|
||||
+ u32 x_c_terms;
|
||||
+ u32 grad_term;
|
||||
+};
|
||||
+
|
||||
+#define VC5_HVS_SET_GAMMA_ENTRY(x, c, g) (struct vc5_gamma_entry){ \
|
||||
+ .x_c_terms = VC4_SET_FIELD((x), SCALER5_DSPGAMMA_OFF_X) | \
|
||||
+ VC4_SET_FIELD((c), SCALER5_DSPGAMMA_OFF_C), \
|
||||
+ .grad_term = (g) \
|
||||
+}
|
||||
+
|
||||
struct vc4_crtc_data {
|
||||
const char *name;
|
||||
|
||||
@@ -538,9 +550,19 @@ struct vc4_crtc {
|
||||
/* Timestamp at start of vblank irq - unaffected by lock delays. */
|
||||
ktime_t t_vblank;
|
||||
|
||||
- u8 lut_r[256];
|
||||
- u8 lut_g[256];
|
||||
- u8 lut_b[256];
|
||||
+ union {
|
||||
+ struct { /* VC4 gamma LUT */
|
||||
+ u8 lut_r[256];
|
||||
+ u8 lut_g[256];
|
||||
+ u8 lut_b[256];
|
||||
+ };
|
||||
+ struct { /* VC5 gamma PWL entries */
|
||||
+ struct vc5_gamma_entry pwl_r[SCALER5_DSPGAMMA_NUM_POINTS];
|
||||
+ struct vc5_gamma_entry pwl_g[SCALER5_DSPGAMMA_NUM_POINTS];
|
||||
+ struct vc5_gamma_entry pwl_b[SCALER5_DSPGAMMA_NUM_POINTS];
|
||||
+ struct vc5_gamma_entry pwl_a[SCALER5_DSPGAMMA_NUM_POINTS];
|
||||
+ };
|
||||
+ };
|
||||
|
||||
struct drm_pending_vblank_event *event;
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -243,7 +243,8 @@ static void vc4_hvs_lut_load(struct vc4_
|
||||
static void vc4_hvs_update_gamma_lut(struct vc4_hvs *hvs,
|
||||
struct vc4_crtc *vc4_crtc)
|
||||
{
|
||||
- struct drm_crtc_state *crtc_state = vc4_crtc->base.state;
|
||||
+ struct drm_crtc *crtc = &vc4_crtc->base;
|
||||
+ struct drm_crtc_state *crtc_state = crtc->state;
|
||||
struct drm_color_lut *lut = crtc_state->gamma_lut->data;
|
||||
u32 length = drm_color_lut_size(crtc_state->gamma_lut);
|
||||
u32 i;
|
||||
@@ -257,6 +258,81 @@ static void vc4_hvs_update_gamma_lut(str
|
||||
vc4_hvs_lut_load(hvs, vc4_crtc);
|
||||
}
|
||||
|
||||
+static void vc5_hvs_write_gamma_entry(struct vc4_hvs *hvs,
|
||||
+ u32 offset,
|
||||
+ struct vc5_gamma_entry *gamma)
|
||||
+{
|
||||
+ HVS_WRITE(offset, gamma->x_c_terms);
|
||||
+ HVS_WRITE(offset + 4, gamma->grad_term);
|
||||
+}
|
||||
+
|
||||
+static void vc5_hvs_lut_load(struct vc4_hvs *hvs,
|
||||
+ struct vc4_crtc *vc4_crtc)
|
||||
+{
|
||||
+ struct drm_crtc *crtc = &vc4_crtc->base;
|
||||
+ struct drm_crtc_state *crtc_state = crtc->state;
|
||||
+ struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
|
||||
+ u32 i;
|
||||
+ u32 offset = SCALER5_DSPGAMMA_START +
|
||||
+ vc4_state->assigned_channel * SCALER5_DSPGAMMA_CHAN_OFFSET;
|
||||
+
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8)
|
||||
+ vc5_hvs_write_gamma_entry(hvs, offset, &vc4_crtc->pwl_r[i]);
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8)
|
||||
+ vc5_hvs_write_gamma_entry(hvs, offset, &vc4_crtc->pwl_g[i]);
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8)
|
||||
+ vc5_hvs_write_gamma_entry(hvs, offset, &vc4_crtc->pwl_b[i]);
|
||||
+
|
||||
+ if (vc4_state->assigned_channel == 2) {
|
||||
+ /* Alpha only valid on channel 2 */
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8)
|
||||
+ vc5_hvs_write_gamma_entry(hvs, offset, &vc4_crtc->pwl_a[i]);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void vc5_hvs_update_gamma_lut(struct vc4_hvs *hvs,
|
||||
+ struct vc4_crtc *vc4_crtc)
|
||||
+{
|
||||
+ struct drm_crtc *crtc = &vc4_crtc->base;
|
||||
+ struct drm_color_lut *lut = crtc->state->gamma_lut->data;
|
||||
+ unsigned int step, i;
|
||||
+ u32 start, end;
|
||||
+
|
||||
+#define VC5_HVS_UPDATE_GAMMA_ENTRY_FROM_LUT(pwl, chan) \
|
||||
+ start = drm_color_lut_extract(lut[i * step].chan, 12); \
|
||||
+ end = drm_color_lut_extract(lut[(i + 1) * step - 1].chan, 12); \
|
||||
+ \
|
||||
+ /* Negative gradients not permitted by the hardware, so \
|
||||
+ * flatten such points out. \
|
||||
+ */ \
|
||||
+ if (end < start) \
|
||||
+ end = start; \
|
||||
+ \
|
||||
+ /* Assume 12bit pipeline. \
|
||||
+ * X evenly spread over full range (12 bit). \
|
||||
+ * C as U12.4 format. \
|
||||
+ * Gradient as U4.8 format. \
|
||||
+ */ \
|
||||
+ vc4_crtc->pwl[i] = \
|
||||
+ VC5_HVS_SET_GAMMA_ENTRY(i << 8, start << 4, \
|
||||
+ ((end - start) << 4) / (step - 1))
|
||||
+
|
||||
+ /* HVS5 has a 16 point piecewise linear function for each colour
|
||||
+ * channel (including alpha on channel 2) on each display channel.
|
||||
+ *
|
||||
+ * Currently take a crude subsample of the gamma LUT, but this could
|
||||
+ * be improved to implement curve fitting.
|
||||
+ */
|
||||
+ step = crtc->gamma_size / SCALER5_DSPGAMMA_NUM_POINTS;
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++) {
|
||||
+ VC5_HVS_UPDATE_GAMMA_ENTRY_FROM_LUT(pwl_r, red);
|
||||
+ VC5_HVS_UPDATE_GAMMA_ENTRY_FROM_LUT(pwl_g, green);
|
||||
+ VC5_HVS_UPDATE_GAMMA_ENTRY_FROM_LUT(pwl_b, blue);
|
||||
+ }
|
||||
+
|
||||
+ vc5_hvs_lut_load(hvs, vc4_crtc);
|
||||
+}
|
||||
+
|
||||
u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo)
|
||||
{
|
||||
struct drm_device *drm = &hvs->vc4->base;
|
||||
@@ -400,7 +476,10 @@ static int vc4_hvs_init_channel(struct v
|
||||
/* Reload the LUT, since the SRAMs would have been disabled if
|
||||
* all CRTCs had SCALER_DISPBKGND_GAMMA unset at once.
|
||||
*/
|
||||
- vc4_hvs_lut_load(hvs, vc4_crtc);
|
||||
+ if (!vc4->is_vc5)
|
||||
+ vc4_hvs_lut_load(hvs, vc4_crtc);
|
||||
+ else
|
||||
+ vc5_hvs_lut_load(hvs, vc4_crtc);
|
||||
|
||||
drm_dev_exit(idx);
|
||||
|
||||
@@ -646,7 +725,11 @@ void vc4_hvs_atomic_flush(struct drm_crt
|
||||
u32 dispbkgndx = HVS_READ(SCALER_DISPBKGNDX(channel));
|
||||
|
||||
if (crtc->state->gamma_lut) {
|
||||
- vc4_hvs_update_gamma_lut(hvs, vc4_crtc);
|
||||
+ if (!vc4->is_vc5)
|
||||
+ vc4_hvs_update_gamma_lut(hvs, vc4_crtc);
|
||||
+ else
|
||||
+ vc5_hvs_update_gamma_lut(hvs, vc4_crtc);
|
||||
+
|
||||
dispbkgndx |= SCALER_DISPBKGND_GAMMA;
|
||||
} else {
|
||||
/* Unsetting DISPBKGND_GAMMA skips the gamma lut step
|
||||
--- a/drivers/gpu/drm/vc4/vc4_regs.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_regs.h
|
||||
@@ -512,6 +512,28 @@
|
||||
#define SCALER_DLIST_START 0x00002000
|
||||
#define SCALER_DLIST_SIZE 0x00004000
|
||||
|
||||
+/* Gamma PWL for each channel. 16 points for each of 4 colour channels (alpha
|
||||
+ * only on channel 2). 8 bytes per entry, offsets first, then gradient:
|
||||
+ * Y = GRAD * X + C
|
||||
+ *
|
||||
+ * Values for X and C are left justified, and vary depending on the width of
|
||||
+ * the HVS channel:
|
||||
+ * 8-bit pipeline: X uses [31:24], C is U8.8 format, and GRAD is U4.8.
|
||||
+ * 12-bit pipeline: X uses [31:20], C is U12.4 format, and GRAD is U4.8.
|
||||
+ *
|
||||
+ * The 3 HVS channels start at 0x400 offsets (ie chan 1 starts at 0x2400, and
|
||||
+ * chan 2 at 0x2800).
|
||||
+ */
|
||||
+#define SCALER5_DSPGAMMA_NUM_POINTS 16
|
||||
+#define SCALER5_DSPGAMMA_START 0x00002000
|
||||
+#define SCALER5_DSPGAMMA_CHAN_OFFSET 0x400
|
||||
+# define SCALER5_DSPGAMMA_OFF_X_MASK VC4_MASK(31, 20)
|
||||
+# define SCALER5_DSPGAMMA_OFF_X_SHIFT 20
|
||||
+# define SCALER5_DSPGAMMA_OFF_C_MASK VC4_MASK(15, 0)
|
||||
+# define SCALER5_DSPGAMMA_OFF_C_SHIFT 0
|
||||
+# define SCALER5_DSPGAMMA_GRAD_MASK VC4_MASK(11, 0)
|
||||
+# define SCALER5_DSPGAMMA_GRAD_SHIFT 0
|
||||
+
|
||||
#define SCALER5_DLIST_START 0x00004000
|
||||
|
||||
# define VC4_HDMI_SW_RESET_FORMAT_DETECT BIT(1)
|
@ -0,0 +1,122 @@
|
||||
From 3931aecb383046dab3f43a4530fe527f7c50a4d5 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Wed, 28 Apr 2021 12:32:10 +0200
|
||||
Subject: [PATCH 0009/1085] drm/vc4: Add debugfs node that dumps the vc5 gamma
|
||||
PWL entries
|
||||
|
||||
This helps with debugging the conversion from a 256 point gamma LUT to
|
||||
16 point PWL entries as used by the BCM2711.
|
||||
|
||||
Co-developed-by: Juerg Haefliger <juergh@canonical.com>
|
||||
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 85 ++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 84 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -143,6 +143,85 @@ static int vc4_hvs_debugfs_dlist(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int vc5_hvs_debugfs_gamma(struct seq_file *m, void *data)
|
||||
+{
|
||||
+ struct drm_info_node *node = m->private;
|
||||
+ struct drm_device *dev = node->minor->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+ struct vc4_hvs *hvs = vc4->hvs;
|
||||
+ struct drm_printer p = drm_seq_file_printer(m);
|
||||
+ unsigned int i, chan;
|
||||
+ u32 dispstat, dispbkgndx;
|
||||
+
|
||||
+ for (chan = 0; chan < SCALER_CHANNELS_COUNT; chan++) {
|
||||
+ u32 x_c, grad;
|
||||
+ u32 offset = SCALER5_DSPGAMMA_START +
|
||||
+ chan * SCALER5_DSPGAMMA_CHAN_OFFSET;
|
||||
+
|
||||
+ dispstat = VC4_GET_FIELD(HVS_READ(SCALER_DISPSTATX(chan)),
|
||||
+ SCALER_DISPSTATX_MODE);
|
||||
+ if (dispstat == SCALER_DISPSTATX_MODE_DISABLED ||
|
||||
+ dispstat == SCALER_DISPSTATX_MODE_EOF) {
|
||||
+ drm_printf(&p, "HVS channel %u: Channel disabled\n", chan);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ dispbkgndx = HVS_READ(SCALER_DISPBKGNDX(chan));
|
||||
+ if (!(dispbkgndx & SCALER_DISPBKGND_GAMMA)) {
|
||||
+ drm_printf(&p, "HVS channel %u: Gamma disabled\n", chan);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ drm_printf(&p, "HVS channel %u:\n", chan);
|
||||
+ drm_printf(&p, " red:\n");
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8) {
|
||||
+ x_c = HVS_READ(offset);
|
||||
+ grad = HVS_READ(offset + 4);
|
||||
+ drm_printf(&p, " %08x %08x - x %u, c %u, grad %u\n",
|
||||
+ x_c, grad,
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_X),
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_C),
|
||||
+ grad);
|
||||
+ }
|
||||
+ drm_printf(&p, " green:\n");
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8) {
|
||||
+ x_c = HVS_READ(offset);
|
||||
+ grad = HVS_READ(offset + 4);
|
||||
+ drm_printf(&p, " %08x %08x - x %u, c %u, grad %u\n",
|
||||
+ x_c, grad,
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_X),
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_C),
|
||||
+ grad);
|
||||
+ }
|
||||
+ drm_printf(&p, " blue:\n");
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8) {
|
||||
+ x_c = HVS_READ(offset);
|
||||
+ grad = HVS_READ(offset + 4);
|
||||
+ drm_printf(&p, " %08x %08x - x %u, c %u, grad %u\n",
|
||||
+ x_c, grad,
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_X),
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_C),
|
||||
+ grad);
|
||||
+ }
|
||||
+
|
||||
+ /* Alpha only valid on channel 2 */
|
||||
+ if (chan != 2)
|
||||
+ continue;
|
||||
+
|
||||
+ drm_printf(&p, " alpha:\n");
|
||||
+ for (i = 0; i < SCALER5_DSPGAMMA_NUM_POINTS; i++, offset += 8) {
|
||||
+ x_c = HVS_READ(offset);
|
||||
+ grad = HVS_READ(offset + 4);
|
||||
+ drm_printf(&p, " %08x %08x - x %u, c %u, grad %u\n",
|
||||
+ x_c, grad,
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_X),
|
||||
+ VC4_GET_FIELD(x_c, SCALER5_DSPGAMMA_OFF_C),
|
||||
+ grad);
|
||||
+ }
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/* The filter kernel is composed of dwords each containing 3 9-bit
|
||||
* signed integers packed next to each other.
|
||||
*/
|
||||
@@ -850,11 +929,15 @@ int vc4_hvs_debugfs_init(struct drm_mino
|
||||
if (!vc4->hvs)
|
||||
return -ENODEV;
|
||||
|
||||
- if (!vc4->is_vc5)
|
||||
+ if (!vc4->is_vc5) {
|
||||
debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
|
||||
minor->debugfs_root,
|
||||
&vc4->load_tracker_enabled);
|
||||
|
||||
+ drm_debugfs_add_file(drm, "hvs_gamma", vc5_hvs_debugfs_gamma,
|
||||
+ NULL);
|
||||
+ }
|
||||
+
|
||||
drm_debugfs_add_file(drm, "hvs_dlists", vc4_hvs_debugfs_dlist, NULL);
|
||||
|
||||
drm_debugfs_add_file(drm, "hvs_underrun", vc4_hvs_debugfs_underrun, NULL);
|
@ -0,0 +1,105 @@
|
||||
From 50a879cfdb87baad4edb50f7b443177a592998ed Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Mon, 14 Jun 2021 15:28:30 +0200
|
||||
Subject: [PATCH 0010/1085] drm/vc4: hvs: Force modeset on gamma lut change
|
||||
|
||||
The HVS Gamma block can only be updated when idle, so we need to disable
|
||||
the HVS channel when the gamma property is set in an atomic commit.
|
||||
|
||||
Since the pixelvalve cannot have its assigned channel halted without
|
||||
stalling unless it's disabled as well, in our case that means forcing a
|
||||
full disable / enable cycle on the pipeline.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++++++++++++
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 3 +++
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 32 +++++++++++++++++++++++++++++++-
|
||||
3 files changed, 51 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -303,6 +303,23 @@ struct drm_encoder *vc4_get_crtc_encoder
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+#define drm_for_each_connector_mask(connector, dev, connector_mask) \
|
||||
+ list_for_each_entry((connector), &(dev)->mode_config.connector_list, head) \
|
||||
+ for_each_if ((connector_mask) & drm_connector_mask(connector))
|
||||
+
|
||||
+struct drm_connector *vc4_get_crtc_connector(struct drm_crtc *crtc,
|
||||
+ struct drm_crtc_state *state)
|
||||
+{
|
||||
+ struct drm_connector *connector;
|
||||
+
|
||||
+ WARN_ON(hweight32(state->connector_mask) > 1);
|
||||
+
|
||||
+ drm_for_each_connector_mask(connector, crtc->dev, state->connector_mask)
|
||||
+ return connector;
|
||||
+
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static void vc4_crtc_pixelvalve_reset(struct drm_crtc *crtc)
|
||||
{
|
||||
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -613,6 +613,9 @@ vc4_crtc_to_vc4_pv_data(const struct vc4
|
||||
return container_of_const(data, struct vc4_pv_data, base);
|
||||
}
|
||||
|
||||
+struct drm_connector *vc4_get_crtc_connector(struct drm_crtc *crtc,
|
||||
+ struct drm_crtc_state *state);
|
||||
+
|
||||
struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc *crtc,
|
||||
struct drm_crtc_state *state);
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -596,6 +596,36 @@ out:
|
||||
drm_dev_exit(idx);
|
||||
}
|
||||
|
||||
+static int vc4_hvs_gamma_check(struct drm_crtc *crtc,
|
||||
+ struct drm_atomic_state *state)
|
||||
+{
|
||||
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
|
||||
+ struct drm_connector_state *conn_state;
|
||||
+ struct drm_connector *connector;
|
||||
+ struct drm_device *dev = crtc->dev;
|
||||
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
+
|
||||
+ if (!vc4->is_vc5)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (!crtc_state->color_mgmt_changed)
|
||||
+ return 0;
|
||||
+
|
||||
+ connector = vc4_get_crtc_connector(crtc, crtc_state);
|
||||
+ if (!connector)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (!(connector->connector_type == DRM_MODE_CONNECTOR_HDMIA))
|
||||
+ return 0;
|
||||
+
|
||||
+ conn_state = drm_atomic_get_connector_state(state, connector);
|
||||
+ if (!conn_state)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ crtc_state->mode_changed = true;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
|
||||
{
|
||||
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
|
||||
@@ -626,7 +656,7 @@ int vc4_hvs_atomic_check(struct drm_crtc
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return 0;
|
||||
+ return vc4_hvs_gamma_check(crtc, state);
|
||||
}
|
||||
|
||||
static void vc4_hvs_install_dlist(struct drm_crtc *crtc)
|
@ -0,0 +1,68 @@
|
||||
From 2f04da8b66d1124c4cf9c1fd9733821801a01a5d Mon Sep 17 00:00:00 2001
|
||||
From: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
|
||||
Date: Thu, 15 Jul 2021 01:08:11 +0200
|
||||
Subject: [PATCH 0012/1085] drm/vc4: Make VEC progressive modes readily
|
||||
accessible
|
||||
|
||||
Add predefined modelines for the 240p (NTSC) and 288p (PAL) progressive
|
||||
modes, and report them through vc4_vec_connector_get_modes().
|
||||
|
||||
Signed-off-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_vec.c | 36 ++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 35 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_vec.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_vec.c
|
||||
@@ -273,6 +273,18 @@ static const struct debugfs_reg32 vec_re
|
||||
VC4_REG32(VEC_DAC_MISC),
|
||||
};
|
||||
|
||||
+static const struct drm_display_mode drm_mode_240p = {
|
||||
+ DRM_MODE("720x240", DRM_MODE_TYPE_DRIVER, 13500,
|
||||
+ 720, 720 + 14, 720 + 14 + 64, 720 + 14 + 64 + 60, 0,
|
||||
+ 240, 240 + 3, 240 + 3 + 3, 262, 0, 0)
|
||||
+};
|
||||
+
|
||||
+static const struct drm_display_mode drm_mode_288p = {
|
||||
+ DRM_MODE("720x288", DRM_MODE_TYPE_DRIVER, 13500,
|
||||
+ 720, 720 + 20, 720 + 20 + 64, 720 + 20 + 64 + 60, 0,
|
||||
+ 288, 288 + 2, 288 + 2 + 3, 312, 0, 0)
|
||||
+};
|
||||
+
|
||||
static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = {
|
||||
{
|
||||
.mode = DRM_MODE_TV_MODE_NTSC,
|
||||
@@ -507,9 +519,31 @@ static const struct drm_connector_funcs
|
||||
.atomic_set_property = vc4_vec_connector_set_property,
|
||||
};
|
||||
|
||||
+static int vc4_vec_connector_get_modes(struct drm_connector *connector)
|
||||
+{
|
||||
+ struct drm_display_mode *mode;
|
||||
+ int count = drm_connector_helper_tv_get_modes(connector);
|
||||
+
|
||||
+ mode = drm_mode_duplicate(connector->dev, &drm_mode_240p);
|
||||
+ if (!mode)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ drm_mode_probed_add(connector, mode);
|
||||
+ count++;
|
||||
+
|
||||
+ mode = drm_mode_duplicate(connector->dev, &drm_mode_288p);
|
||||
+ if (!mode)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ drm_mode_probed_add(connector, mode);
|
||||
+ count++;
|
||||
+
|
||||
+ return count;
|
||||
+}
|
||||
+
|
||||
static const struct drm_connector_helper_funcs vc4_vec_connector_helper_funcs = {
|
||||
.atomic_check = drm_atomic_helper_connector_tv_check,
|
||||
- .get_modes = drm_connector_helper_tv_get_modes,
|
||||
+ .get_modes = vc4_vec_connector_get_modes,
|
||||
};
|
||||
|
||||
static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec)
|
@ -0,0 +1,30 @@
|
||||
From 8101479299dec8b984ee1cef2224d67c8ae9921f Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Tue, 2 Nov 2021 16:01:36 +0000
|
||||
Subject: [PATCH 0013/1085] drm: Check whether the gamma lut has changed before
|
||||
updating
|
||||
|
||||
drm_crtc_legacy_gamma_set updates the gamma_lut blob unconditionally,
|
||||
which leads to unnecessary reprogramming of hardware.
|
||||
|
||||
Check whether the blob contents has actually changed before
|
||||
signalling that it has been updated.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/drm_color_mgmt.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/drm_color_mgmt.c
|
||||
+++ b/drivers/gpu/drm/drm_color_mgmt.c
|
||||
@@ -330,7 +330,9 @@ static int drm_crtc_legacy_gamma_set(str
|
||||
replaced = drm_property_replace_blob(&crtc_state->degamma_lut,
|
||||
use_gamma_lut ? NULL : blob);
|
||||
replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL);
|
||||
- replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
|
||||
+ if (!crtc_state->gamma_lut || !crtc_state->gamma_lut->data ||
|
||||
+ memcmp(crtc_state->gamma_lut->data, blob_data, blob->length))
|
||||
+ replaced |= drm_property_replace_blob(&crtc_state->gamma_lut,
|
||||
use_gamma_lut ? blob : NULL);
|
||||
crtc_state->color_mgmt_changed |= replaced;
|
||||
|
@ -0,0 +1,66 @@
|
||||
From c0e4a6b67c9e9c1be98e9e83708b04ca7ed34989 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Mon, 8 Nov 2021 17:32:45 +0000
|
||||
Subject: [PATCH 0014/1085] drm/vc4: Enable gamma block only when required.
|
||||
|
||||
With HVS5 the gamma block is now only reprogrammed with
|
||||
a disable/enable. Loading the table from vc4_hvs_init_channel
|
||||
(called from vc4_hvs_atomic_enable) appears to be at an
|
||||
invalid point in time and so isn't applied.
|
||||
|
||||
Switch to enabling and disabling the gamma table instead. This
|
||||
isn't safe if the pipeline is running, but it isn't now.
|
||||
For HVS4 it is safe to enable and disable dynamically, so
|
||||
adopt that approach there too.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 22 ++++++++++++++++------
|
||||
1 file changed, 16 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -548,8 +548,11 @@ static int vc4_hvs_init_channel(struct v
|
||||
dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
|
||||
dispbkgndx &= ~SCALER_DISPBKGND_INTERLACE;
|
||||
|
||||
+ if (crtc->state->gamma_lut)
|
||||
+ /* Enable gamma on if required */
|
||||
+ dispbkgndx |= SCALER_DISPBKGND_GAMMA;
|
||||
+
|
||||
HVS_WRITE(SCALER_DISPBKGNDX(chan), dispbkgndx |
|
||||
- ((!vc4->is_vc5) ? SCALER_DISPBKGND_GAMMA : 0) |
|
||||
(interlace ? SCALER_DISPBKGND_INTERLACE : 0));
|
||||
|
||||
/* Reload the LUT, since the SRAMs would have been disabled if
|
||||
@@ -834,18 +837,25 @@ void vc4_hvs_atomic_flush(struct drm_crt
|
||||
u32 dispbkgndx = HVS_READ(SCALER_DISPBKGNDX(channel));
|
||||
|
||||
if (crtc->state->gamma_lut) {
|
||||
- if (!vc4->is_vc5)
|
||||
+ if (!vc4->is_vc5) {
|
||||
vc4_hvs_update_gamma_lut(hvs, vc4_crtc);
|
||||
- else
|
||||
+ dispbkgndx |= SCALER_DISPBKGND_GAMMA;
|
||||
+ } else {
|
||||
vc5_hvs_update_gamma_lut(hvs, vc4_crtc);
|
||||
-
|
||||
- dispbkgndx |= SCALER_DISPBKGND_GAMMA;
|
||||
+ }
|
||||
} else {
|
||||
/* Unsetting DISPBKGND_GAMMA skips the gamma lut step
|
||||
* in hardware, which is the same as a linear lut that
|
||||
* DRM expects us to use in absence of a user lut.
|
||||
+ *
|
||||
+ * Do NOT change state dynamically for hvs5 as it
|
||||
+ * inserts a delay in the pipeline that will cause
|
||||
+ * stalls if enabled/disabled whilst running. The other
|
||||
+ * should already be disabling/enabling the pipeline
|
||||
+ * when gamma changes.
|
||||
*/
|
||||
- dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
|
||||
+ if (!vc4->is_vc5)
|
||||
+ dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
|
||||
}
|
||||
HVS_WRITE(SCALER_DISPBKGNDX(channel), dispbkgndx);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
From 57ec5c418588c6dd23a4ce7d0f0cb76667ec155f Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Mon, 8 Nov 2021 18:25:49 +0000
|
||||
Subject: [PATCH 0015/1085] drm/vc4: Only add gamma properties once.
|
||||
|
||||
Two calls were made to drm_crtc_enable_color_mgmt to add gamma
|
||||
and CTM, however they were both set to add the gamma properties,
|
||||
so they ended up added twice.
|
||||
|
||||
Fixes: 766cc6b1f7fc "drm/vc4: Add CTM support"
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -1371,7 +1371,7 @@ int __vc4_crtc_init(struct drm_device *d
|
||||
/* We support CTM, but only for one CRTC at a time. It's therefore
|
||||
* implemented as private driver state in vc4_kms, not here.
|
||||
*/
|
||||
- drm_crtc_enable_color_mgmt(crtc, 0, true, crtc->gamma_size);
|
||||
+ drm_crtc_enable_color_mgmt(crtc, 0, true, 0);
|
||||
|
||||
/* Initialize the VC4 gamma LUTs */
|
||||
for (i = 0; i < crtc->gamma_size; i++) {
|
@ -0,0 +1,32 @@
|
||||
From 67157d16a97a0dc896d5a70245ba8f9f360112c8 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Wed, 10 Nov 2021 16:36:12 +0000
|
||||
Subject: [PATCH 0016/1085] drm/vc4: Validate the size of the gamma_lut
|
||||
|
||||
Add a check to vc4_hvs_gamma_check to ensure a new non-empty
|
||||
gamma LUT is of the correct length before accepting it.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -614,6 +614,16 @@ static int vc4_hvs_gamma_check(struct dr
|
||||
if (!crtc_state->color_mgmt_changed)
|
||||
return 0;
|
||||
|
||||
+ if (crtc_state->gamma_lut) {
|
||||
+ unsigned int len = drm_color_lut_size(crtc_state->gamma_lut);
|
||||
+
|
||||
+ if (len != crtc->gamma_size) {
|
||||
+ DRM_DEBUG_KMS("Invalid LUT size; got %u, expected %u\n",
|
||||
+ len, crtc->gamma_size);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
connector = vc4_get_crtc_connector(crtc, crtc_state);
|
||||
if (!connector)
|
||||
return -EINVAL;
|
@ -0,0 +1,36 @@
|
||||
From 1a8c3424507c67088915f2136edfba381c2fa4b9 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Thu, 13 Jan 2022 11:30:42 +0000
|
||||
Subject: [PATCH 0017/1085] drm/vc4: Disable Gamma control on HVS5 due to
|
||||
issues writing the table
|
||||
|
||||
Still under investigation, but the conditions under which the HVS
|
||||
will accept values written to the gamma PWL are not straightforward.
|
||||
|
||||
Disable gamma on HVS5 again until it can be resolved to avoid
|
||||
gamma being enabled with an incorrect table.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 8 +-------
|
||||
1 file changed, 1 insertion(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -1357,15 +1357,9 @@ int __vc4_crtc_init(struct drm_device *d
|
||||
|
||||
if (!vc4->is_vc5) {
|
||||
drm_mode_crtc_set_gamma_size(crtc, ARRAY_SIZE(vc4_crtc->lut_r));
|
||||
- } else {
|
||||
- /* This is a lie for hvs5 which uses a 16 point PWL, but it
|
||||
- * allows for something smarter than just 16 linearly spaced
|
||||
- * segments. Conversion is done in vc5_hvs_update_gamma_lut.
|
||||
- */
|
||||
- drm_mode_crtc_set_gamma_size(crtc, 256);
|
||||
+ drm_crtc_enable_color_mgmt(crtc, 0, false, crtc->gamma_size);
|
||||
}
|
||||
|
||||
- drm_crtc_enable_color_mgmt(crtc, 0, false, crtc->gamma_size);
|
||||
|
||||
if (!vc4->is_vc5) {
|
||||
/* We support CTM, but only for one CRTC at a time. It's therefore
|
@ -0,0 +1,76 @@
|
||||
From cfd0ecb25ac9aecd0e6401d951a41988b7672776 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Fri, 17 Dec 2021 13:36:52 +0000
|
||||
Subject: [PATCH 0018/1085] drm/dsi: Document the meaning and spec references
|
||||
for MIPI_DSI_MODE_*
|
||||
|
||||
The MIPI_DSI_MODE_* flags have fairly terse descriptions and no reference
|
||||
to the DSI specification as to their exact meaning. Usage has therefore
|
||||
been rather fluid.
|
||||
|
||||
Extend the descriptions and provide references to the part of the
|
||||
MIPI DSI specification regarding what they mean.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
include/drm/drm_mipi_dsi.h | 38 ++++++++++++++++++++++++++------------
|
||||
1 file changed, 26 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/include/drm/drm_mipi_dsi.h
|
||||
+++ b/include/drm/drm_mipi_dsi.h
|
||||
@@ -113,29 +113,43 @@ struct mipi_dsi_host *of_find_mipi_dsi_h
|
||||
|
||||
/* DSI mode flags */
|
||||
|
||||
-/* video mode */
|
||||
+/* Video mode display.
|
||||
+ * Not set denotes a command mode display.
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO BIT(0)
|
||||
-/* video burst mode */
|
||||
+/* Video burst mode.
|
||||
+ * Link frequency to be configured via platform configuration.
|
||||
+ * This should always be set in conjunction with MIPI_DSI_MODE_VIDEO.
|
||||
+ * (DSI spec V1.1 8.11.4)
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO_BURST BIT(1)
|
||||
-/* video pulse mode */
|
||||
+/* Video pulse mode.
|
||||
+ * Not set denotes sync event mode. (DSI spec V1.1 8.11.2)
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO_SYNC_PULSE BIT(2)
|
||||
-/* enable auto vertical count mode */
|
||||
+/* Enable auto vertical count mode */
|
||||
#define MIPI_DSI_MODE_VIDEO_AUTO_VERT BIT(3)
|
||||
-/* enable hsync-end packets in vsync-pulse and v-porch area */
|
||||
+/* Enable hsync-end packets in vsync-pulse and v-porch area */
|
||||
#define MIPI_DSI_MODE_VIDEO_HSE BIT(4)
|
||||
-/* disable hfront-porch area */
|
||||
+/* Transmit NULL packets or LP mode during hfront-porch area.
|
||||
+ * Not set denotes sending a blanking packet instead. (DSI spec V1.1 8.11.1)
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO_NO_HFP BIT(5)
|
||||
-/* disable hback-porch area */
|
||||
+/* Transmit NULL packets or LP mode during hback-porch area.
|
||||
+ * Not set denotes sending a blanking packet instead. (DSI spec V1.1 8.11.1)
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO_NO_HBP BIT(6)
|
||||
-/* disable hsync-active area */
|
||||
+/* Transmit NULL packets or LP mode during hsync-active area.
|
||||
+ * Not set denotes sending a blanking packet instead. (DSI spec V1.1 8.11.1)
|
||||
+ */
|
||||
#define MIPI_DSI_MODE_VIDEO_NO_HSA BIT(7)
|
||||
-/* flush display FIFO on vsync pulse */
|
||||
+/* Flush display FIFO on vsync pulse */
|
||||
#define MIPI_DSI_MODE_VSYNC_FLUSH BIT(8)
|
||||
-/* disable EoT packets in HS mode */
|
||||
+/* Disable EoT packets in HS mode. (DSI spec V1.1 8.1) */
|
||||
#define MIPI_DSI_MODE_NO_EOT_PACKET BIT(9)
|
||||
-/* device supports non-continuous clock behavior (DSI spec 5.6.1) */
|
||||
+/* Device supports non-continuous clock behavior (DSI spec V1.1 5.6.1) */
|
||||
#define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10)
|
||||
-/* transmit data in low power */
|
||||
+/* Transmit data in low power */
|
||||
#define MIPI_DSI_MODE_LPM BIT(11)
|
||||
/* transmit data ending at the same time for all lanes within one hsync */
|
||||
#define MIPI_DSI_HS_PKT_END_ALIGNED BIT(12)
|
@ -0,0 +1,25 @@
|
||||
From 00e306d9dd4855b6a6da682b934bbc513e7cbcd5 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Thu, 20 Jan 2022 17:29:36 +0000
|
||||
Subject: [PATCH 0019/1085] drm/bridge: tc358762: Ignore EPROBE_DEFER when
|
||||
logging errors
|
||||
|
||||
mipi_dsi_attach can fail due to resources not being available
|
||||
yet, therefore do not log error messages should they occur.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/bridge/tc358762.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/bridge/tc358762.c
|
||||
+++ b/drivers/gpu/drm/bridge/tc358762.c
|
||||
@@ -294,7 +294,7 @@ static int tc358762_probe(struct mipi_ds
|
||||
ret = mipi_dsi_attach(dsi);
|
||||
if (ret < 0) {
|
||||
drm_bridge_remove(&ctx->bridge);
|
||||
- dev_err(dev, "failed to attach dsi\n");
|
||||
+ dev_err_probe(dev, ret, "failed to attach dsi\n");
|
||||
}
|
||||
|
||||
return ret;
|
@ -0,0 +1,212 @@
|
||||
From 1e18d70635d275e4c6a9ac63fa79a461ed50eac2 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Mon, 14 Mar 2022 17:56:10 +0000
|
||||
Subject: [PATCH 0020/1085] vc4/drm: vc4_plane: Keep fractional source coords
|
||||
inside state
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 2 +-
|
||||
drivers/gpu/drm/vc4/vc4_plane.c | 68 ++++++++++++++++-----------------
|
||||
2 files changed, 34 insertions(+), 36 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -408,7 +408,7 @@ struct vc4_plane_state {
|
||||
|
||||
/* Clipped coordinates of the plane on the display. */
|
||||
int crtc_x, crtc_y, crtc_w, crtc_h;
|
||||
- /* Clipped area being scanned from in the FB. */
|
||||
+ /* Clipped area being scanned from in the FB in u16.16 format */
|
||||
u32 src_x, src_y;
|
||||
|
||||
u32 src_w[2], src_h[2];
|
||||
--- a/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
@@ -251,9 +251,9 @@ static const struct hvs_format *vc4_get_
|
||||
|
||||
static enum vc4_scaling_mode vc4_get_scaling_mode(u32 src, u32 dst)
|
||||
{
|
||||
- if (dst == src)
|
||||
+ if (dst == src >> 16)
|
||||
return VC4_SCALING_NONE;
|
||||
- if (3 * dst >= 2 * src)
|
||||
+ if (3 * dst >= 2 * (src >> 16))
|
||||
return VC4_SCALING_PPF;
|
||||
else
|
||||
return VC4_SCALING_TPZ;
|
||||
@@ -462,15 +462,10 @@ static int vc4_plane_setup_clipping_and_
|
||||
vc4_state->offsets[i] = bo->dma_addr + fb->offsets[i];
|
||||
}
|
||||
|
||||
- /*
|
||||
- * We don't support subpixel source positioning for scaling,
|
||||
- * but fractional coordinates can be generated by clipping
|
||||
- * so just round for now
|
||||
- */
|
||||
- vc4_state->src_x = DIV_ROUND_CLOSEST(state->src.x1, 1 << 16);
|
||||
- vc4_state->src_y = DIV_ROUND_CLOSEST(state->src.y1, 1 << 16);
|
||||
- vc4_state->src_w[0] = DIV_ROUND_CLOSEST(state->src.x2, 1 << 16) - vc4_state->src_x;
|
||||
- vc4_state->src_h[0] = DIV_ROUND_CLOSEST(state->src.y2, 1 << 16) - vc4_state->src_y;
|
||||
+ vc4_state->src_x = state->src.x1;
|
||||
+ vc4_state->src_y = state->src.y1;
|
||||
+ vc4_state->src_w[0] = state->src.x2 - vc4_state->src_x;
|
||||
+ vc4_state->src_h[0] = state->src.y2 - vc4_state->src_y;
|
||||
|
||||
vc4_state->crtc_x = state->dst.x1;
|
||||
vc4_state->crtc_y = state->dst.y1;
|
||||
@@ -523,7 +518,7 @@ static void vc4_write_tpz(struct vc4_pla
|
||||
{
|
||||
u32 scale, recip;
|
||||
|
||||
- scale = (1 << 16) * src / dst;
|
||||
+ scale = src / dst;
|
||||
|
||||
/* The specs note that while the reciprocal would be defined
|
||||
* as (1<<32)/scale, ~0 is close enough.
|
||||
@@ -569,7 +564,7 @@ static u32 vc4_lbm_size(struct drm_plane
|
||||
if (vc4_state->x_scaling[0] == VC4_SCALING_TPZ)
|
||||
pix_per_line = vc4_state->crtc_w;
|
||||
else
|
||||
- pix_per_line = vc4_state->src_w[0];
|
||||
+ pix_per_line = vc4_state->src_w[0] >> 16;
|
||||
|
||||
if (!vc4_state->is_yuv) {
|
||||
if (vc4_state->y_scaling[0] == VC4_SCALING_TPZ)
|
||||
@@ -660,7 +655,8 @@ static void vc4_plane_calc_load(struct d
|
||||
for (i = 0; i < fb->format->num_planes; i++) {
|
||||
/* Even if the bandwidth/plane required for a single frame is
|
||||
*
|
||||
- * vc4_state->src_w[i] * vc4_state->src_h[i] * cpp * vrefresh
|
||||
+ * (vc4_state->src_w[i] >> 16) * (vc4_state->src_h[i] >> 16) *
|
||||
+ * cpp * vrefresh
|
||||
*
|
||||
* when downscaling, we have to read more pixels per line in
|
||||
* the time frame reserved for a single line, so the bandwidth
|
||||
@@ -669,11 +665,11 @@ static void vc4_plane_calc_load(struct d
|
||||
* load by this number. We're likely over-estimating the read
|
||||
* demand, but that's better than under-estimating it.
|
||||
*/
|
||||
- vscale_factor = DIV_ROUND_UP(vc4_state->src_h[i],
|
||||
+ vscale_factor = DIV_ROUND_UP(vc4_state->src_h[i] >> 16,
|
||||
vc4_state->crtc_h);
|
||||
- vc4_state->membus_load += vc4_state->src_w[i] *
|
||||
- vc4_state->src_h[i] * vscale_factor *
|
||||
- fb->format->cpp[i];
|
||||
+ vc4_state->membus_load += (vc4_state->src_w[i] >> 16) *
|
||||
+ (vc4_state->src_h[i] >> 16) *
|
||||
+ vscale_factor * fb->format->cpp[i];
|
||||
vc4_state->hvs_load += vc4_state->crtc_h * vc4_state->crtc_w;
|
||||
}
|
||||
|
||||
@@ -826,7 +822,8 @@ static int vc4_plane_mode_set(struct drm
|
||||
bool mix_plane_alpha;
|
||||
bool covers_screen;
|
||||
u32 scl0, scl1, pitch0;
|
||||
- u32 tiling, src_y;
|
||||
+ u32 tiling, src_x, src_y;
|
||||
+ u32 width, height;
|
||||
u32 hvs_format = format->hvs;
|
||||
unsigned int rotation;
|
||||
int ret, i;
|
||||
@@ -838,6 +835,9 @@ static int vc4_plane_mode_set(struct drm
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
+ width = vc4_state->src_w[0] >> 16;
|
||||
+ height = vc4_state->src_h[0] >> 16;
|
||||
+
|
||||
/* SCL1 is used for Cb/Cr scaling of planar formats. For RGB
|
||||
* and 4:4:4, scl1 should be set to scl0 so both channels of
|
||||
* the scaler do the same thing. For YUV, the Y plane needs
|
||||
@@ -858,9 +858,11 @@ static int vc4_plane_mode_set(struct drm
|
||||
DRM_MODE_REFLECT_Y);
|
||||
|
||||
/* We must point to the last line when Y reflection is enabled. */
|
||||
- src_y = vc4_state->src_y;
|
||||
+ src_y = vc4_state->src_y >> 16;
|
||||
if (rotation & DRM_MODE_REFLECT_Y)
|
||||
- src_y += vc4_state->src_h[0] - 1;
|
||||
+ src_y += height - 1;
|
||||
+
|
||||
+ src_x = vc4_state->src_x >> 16;
|
||||
|
||||
switch (base_format_mod) {
|
||||
case DRM_FORMAT_MOD_LINEAR:
|
||||
@@ -875,7 +877,7 @@ static int vc4_plane_mode_set(struct drm
|
||||
(i ? v_subsample : 1) *
|
||||
fb->pitches[i];
|
||||
|
||||
- vc4_state->offsets[i] += vc4_state->src_x /
|
||||
+ vc4_state->offsets[i] += src_x /
|
||||
(i ? h_subsample : 1) *
|
||||
fb->format->cpp[i];
|
||||
}
|
||||
@@ -898,7 +900,7 @@ static int vc4_plane_mode_set(struct drm
|
||||
* pitch * tile_h == tile_size * tiles_per_row
|
||||
*/
|
||||
u32 tiles_w = fb->pitches[0] >> (tile_size_shift - tile_h_shift);
|
||||
- u32 tiles_l = vc4_state->src_x >> tile_w_shift;
|
||||
+ u32 tiles_l = src_x >> tile_w_shift;
|
||||
u32 tiles_r = tiles_w - tiles_l;
|
||||
u32 tiles_t = src_y >> tile_h_shift;
|
||||
/* Intra-tile offsets, which modify the base address (the
|
||||
@@ -908,7 +910,7 @@ static int vc4_plane_mode_set(struct drm
|
||||
u32 tile_y = (src_y >> 4) & 1;
|
||||
u32 subtile_y = (src_y >> 2) & 3;
|
||||
u32 utile_y = src_y & 3;
|
||||
- u32 x_off = vc4_state->src_x & tile_w_mask;
|
||||
+ u32 x_off = src_x & tile_w_mask;
|
||||
u32 y_off = src_y & tile_h_mask;
|
||||
|
||||
/* When Y reflection is requested we must set the
|
||||
@@ -1004,7 +1006,7 @@ static int vc4_plane_mode_set(struct drm
|
||||
* of the 12-pixels in that 128-bit word is the
|
||||
* first pixel to be used
|
||||
*/
|
||||
- u32 remaining_pixels = vc4_state->src_x % 96;
|
||||
+ u32 remaining_pixels = src_x % 96;
|
||||
u32 aligned = remaining_pixels / 12;
|
||||
u32 last_bits = remaining_pixels % 12;
|
||||
|
||||
@@ -1026,12 +1028,12 @@ static int vc4_plane_mode_set(struct drm
|
||||
return -EINVAL;
|
||||
}
|
||||
pix_per_tile = tile_w / fb->format->cpp[0];
|
||||
- x_off = (vc4_state->src_x % pix_per_tile) /
|
||||
+ x_off = (src_x % pix_per_tile) /
|
||||
(i ? h_subsample : 1) *
|
||||
fb->format->cpp[i];
|
||||
}
|
||||
|
||||
- tile = vc4_state->src_x / pix_per_tile;
|
||||
+ tile = src_x / pix_per_tile;
|
||||
|
||||
vc4_state->offsets[i] += param * tile_w * tile;
|
||||
vc4_state->offsets[i] += src_y /
|
||||
@@ -1092,10 +1094,8 @@ static int vc4_plane_mode_set(struct drm
|
||||
vc4_dlist_write(vc4_state,
|
||||
(mix_plane_alpha ? SCALER_POS2_ALPHA_MIX : 0) |
|
||||
vc4_hvs4_get_alpha_blend_mode(state) |
|
||||
- VC4_SET_FIELD(vc4_state->src_w[0],
|
||||
- SCALER_POS2_WIDTH) |
|
||||
- VC4_SET_FIELD(vc4_state->src_h[0],
|
||||
- SCALER_POS2_HEIGHT));
|
||||
+ VC4_SET_FIELD(width, SCALER_POS2_WIDTH) |
|
||||
+ VC4_SET_FIELD(height, SCALER_POS2_HEIGHT));
|
||||
|
||||
/* Position Word 3: Context. Written by the HVS. */
|
||||
vc4_dlist_write(vc4_state, 0xc0c0c0c0);
|
||||
@@ -1148,10 +1148,8 @@ static int vc4_plane_mode_set(struct drm
|
||||
/* Position Word 2: Source Image Size */
|
||||
vc4_state->pos2_offset = vc4_state->dlist_count;
|
||||
vc4_dlist_write(vc4_state,
|
||||
- VC4_SET_FIELD(vc4_state->src_w[0],
|
||||
- SCALER5_POS2_WIDTH) |
|
||||
- VC4_SET_FIELD(vc4_state->src_h[0],
|
||||
- SCALER5_POS2_HEIGHT));
|
||||
+ VC4_SET_FIELD(width, SCALER5_POS2_WIDTH) |
|
||||
+ VC4_SET_FIELD(height, SCALER5_POS2_HEIGHT));
|
||||
|
||||
/* Position Word 3: Context. Written by the HVS. */
|
||||
vc4_dlist_write(vc4_state, 0xc0c0c0c0);
|
@ -0,0 +1,105 @@
|
||||
From 082526e9709190ec5e035266a33a7a4858ad7a79 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Fri, 9 Apr 2021 15:00:40 +0100
|
||||
Subject: [PATCH 0021/1085] vc4/drm: Handle fractional coordinates using the
|
||||
phase field
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_plane.c | 61 ++++++++++++++++++++++++++++++---
|
||||
1 file changed, 56 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
@@ -532,14 +532,47 @@ static void vc4_write_tpz(struct vc4_pla
|
||||
VC4_SET_FIELD(recip, SCALER_TPZ1_RECIP));
|
||||
}
|
||||
|
||||
-static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst)
|
||||
+/* phase magnitude bits */
|
||||
+#define PHASE_BITS 6
|
||||
+
|
||||
+static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst, u32 xy, int channel)
|
||||
{
|
||||
- u32 scale = (1 << 16) * src / dst;
|
||||
+ u32 scale = src / dst;
|
||||
+ s32 offset, offset2;
|
||||
+ s32 phase;
|
||||
+
|
||||
+ /* Start the phase at 1/2 pixel from the 1st pixel at src_x.
|
||||
+ 1/4 pixel for YUV. */
|
||||
+ if (channel) {
|
||||
+ /* the phase is relative to scale_src->x, so shift it for display list's x value */
|
||||
+ offset = (xy & 0x1ffff) >> (16 - PHASE_BITS) >> 1;
|
||||
+ offset += -(1 << PHASE_BITS >> 2);
|
||||
+ } else {
|
||||
+ /* the phase is relative to scale_src->x, so shift it for display list's x value */
|
||||
+ offset = (xy & 0xffff) >> (16 - PHASE_BITS);
|
||||
+ offset += -(1 << PHASE_BITS >> 1);
|
||||
+
|
||||
+ /* This is a kludge to make sure the scaling factors are consitent with YUV's luma scaling.
|
||||
+ we lose 1bit precision because of this. */
|
||||
+ scale &= ~1;
|
||||
+ }
|
||||
+
|
||||
+ /* There may be a also small error introduced by precision of scale.
|
||||
+ Add half of that as a compromise */
|
||||
+ offset2 = src - dst * scale;
|
||||
+ offset2 >>= 16 - PHASE_BITS;
|
||||
+ phase = offset + (offset2 >> 1);
|
||||
+
|
||||
+ /* Ensure +ve values don't touch the sign bit, then truncate negative values */
|
||||
+ if (phase >= 1 << PHASE_BITS)
|
||||
+ phase = (1 << PHASE_BITS) - 1;
|
||||
+
|
||||
+ phase &= SCALER_PPF_IPHASE_MASK;
|
||||
|
||||
vc4_dlist_write(vc4_state,
|
||||
SCALER_PPF_AGC |
|
||||
VC4_SET_FIELD(scale, SCALER_PPF_SCALE) |
|
||||
- VC4_SET_FIELD(0, SCALER_PPF_IPHASE));
|
||||
+ VC4_SET_FIELD(phase, SCALER_PPF_IPHASE));
|
||||
}
|
||||
|
||||
static u32 vc4_lbm_size(struct drm_plane_state *state)
|
||||
@@ -598,13 +631,13 @@ static void vc4_write_scaling_parameters
|
||||
/* Ch0 H-PPF Word 0: Scaling Parameters */
|
||||
if (vc4_state->x_scaling[channel] == VC4_SCALING_PPF) {
|
||||
vc4_write_ppf(vc4_state,
|
||||
- vc4_state->src_w[channel], vc4_state->crtc_w);
|
||||
+ vc4_state->src_w[channel], vc4_state->crtc_w, vc4_state->src_x, channel);
|
||||
}
|
||||
|
||||
/* Ch0 V-PPF Words 0-1: Scaling Parameters, Context */
|
||||
if (vc4_state->y_scaling[channel] == VC4_SCALING_PPF) {
|
||||
vc4_write_ppf(vc4_state,
|
||||
- vc4_state->src_h[channel], vc4_state->crtc_h);
|
||||
+ vc4_state->src_h[channel], vc4_state->crtc_h, vc4_state->src_y, channel);
|
||||
vc4_dlist_write(vc4_state, 0xc0c0c0c0);
|
||||
}
|
||||
|
||||
@@ -1052,6 +1085,24 @@ static int vc4_plane_mode_set(struct drm
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+ /* fetch an extra pixel if we don't actually line up with the left edge. */
|
||||
+ if ((vc4_state->src_x & 0xffff) && vc4_state->src_x < (state->fb->width << 16))
|
||||
+ width++;
|
||||
+
|
||||
+ /* same for the right side */
|
||||
+ if (((vc4_state->src_x + vc4_state->src_w[0]) & 0xffff) &&
|
||||
+ vc4_state->src_x + vc4_state->src_w[0] < (state->fb->width << 16))
|
||||
+ width++;
|
||||
+
|
||||
+ /* now for the top */
|
||||
+ if ((vc4_state->src_y & 0xffff) && vc4_state->src_y < (state->fb->height << 16))
|
||||
+ height++;
|
||||
+
|
||||
+ /* and the bottom */
|
||||
+ if (((vc4_state->src_y + vc4_state->src_h[0]) & 0xffff) &&
|
||||
+ vc4_state->src_y + vc4_state->src_h[0] < (state->fb->height << 16))
|
||||
+ height++;
|
||||
+
|
||||
/* Don't waste cycles mixing with plane alpha if the set alpha
|
||||
* is opaque or there is no per-pixel alpha information.
|
||||
* In any case we use the alpha property value as the fixed alpha.
|
@ -0,0 +1,170 @@
|
||||
From ab6920df43e7b33afb5aa0552c61f8485e1a60da Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Wed, 26 Jan 2022 15:58:13 +0000
|
||||
Subject: [PATCH 0022/1085] drm: Add chroma siting properties
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/drm_atomic_state_helper.c | 14 +++++++++
|
||||
drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++
|
||||
drivers/gpu/drm/drm_color_mgmt.c | 36 +++++++++++++++++++++++
|
||||
include/drm/drm_color_mgmt.h | 3 ++
|
||||
include/drm/drm_plane.h | 36 +++++++++++++++++++++++
|
||||
5 files changed, 97 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
|
||||
@@ -267,6 +267,20 @@ void __drm_atomic_helper_plane_state_res
|
||||
plane_state->color_range = val;
|
||||
}
|
||||
|
||||
+ if (plane->chroma_siting_h_property) {
|
||||
+ if (!drm_object_property_get_default_value(&plane->base,
|
||||
+ plane->chroma_siting_h_property,
|
||||
+ &val))
|
||||
+ plane_state->chroma_siting_h = val;
|
||||
+ }
|
||||
+
|
||||
+ if (plane->chroma_siting_v_property) {
|
||||
+ if (!drm_object_property_get_default_value(&plane->base,
|
||||
+ plane->chroma_siting_v_property,
|
||||
+ &val))
|
||||
+ plane_state->chroma_siting_v = val;
|
||||
+ }
|
||||
+
|
||||
if (plane->zpos_property) {
|
||||
if (!drm_object_property_get_default_value(&plane->base,
|
||||
plane->zpos_property,
|
||||
--- a/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
@@ -580,6 +580,10 @@ static int drm_atomic_plane_set_property
|
||||
state->color_encoding = val;
|
||||
} else if (property == plane->color_range_property) {
|
||||
state->color_range = val;
|
||||
+ } else if (property == plane->chroma_siting_h_property) {
|
||||
+ state->chroma_siting_h = val;
|
||||
+ } else if (property == plane->chroma_siting_v_property) {
|
||||
+ state->chroma_siting_v = val;
|
||||
} else if (property == config->prop_fb_damage_clips) {
|
||||
ret = drm_atomic_replace_property_blob_from_id(dev,
|
||||
&state->fb_damage_clips,
|
||||
@@ -646,6 +650,10 @@ drm_atomic_plane_get_property(struct drm
|
||||
*val = state->color_encoding;
|
||||
} else if (property == plane->color_range_property) {
|
||||
*val = state->color_range;
|
||||
+ } else if (property == plane->chroma_siting_h_property) {
|
||||
+ *val = state->chroma_siting_h;
|
||||
+ } else if (property == plane->chroma_siting_v_property) {
|
||||
+ *val = state->chroma_siting_v;
|
||||
} else if (property == config->prop_fb_damage_clips) {
|
||||
*val = (state->fb_damage_clips) ?
|
||||
state->fb_damage_clips->base.id : 0;
|
||||
--- a/drivers/gpu/drm/drm_color_mgmt.c
|
||||
+++ b/drivers/gpu/drm/drm_color_mgmt.c
|
||||
@@ -591,6 +591,42 @@ int drm_plane_create_color_properties(st
|
||||
EXPORT_SYMBOL(drm_plane_create_color_properties);
|
||||
|
||||
/**
|
||||
+ * drm_plane_create_chroma_siting_properties - chroma siting related plane properties
|
||||
+ * @plane: plane object
|
||||
+ *
|
||||
+ * Create and attach plane specific CHROMA_SITING
|
||||
+ * properties to @plane.
|
||||
+ */
|
||||
+int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
|
||||
+ int32_t default_chroma_siting_h,
|
||||
+ int32_t default_chroma_siting_v)
|
||||
+{
|
||||
+ struct drm_device *dev = plane->dev;
|
||||
+ struct drm_property *prop;
|
||||
+
|
||||
+ prop = drm_property_create_range(dev, 0, "CHROMA_SITING_H",
|
||||
+ 0, 1<<16);
|
||||
+ if (!prop)
|
||||
+ return -ENOMEM;
|
||||
+ plane->chroma_siting_h_property = prop;
|
||||
+ drm_object_attach_property(&plane->base, prop, default_chroma_siting_h);
|
||||
+
|
||||
+ prop = drm_property_create_range(dev, 0, "CHROMA_SITING_V",
|
||||
+ 0, 1<<16);
|
||||
+ if (!prop)
|
||||
+ return -ENOMEM;
|
||||
+ plane->chroma_siting_v_property = prop;
|
||||
+ drm_object_attach_property(&plane->base, prop, default_chroma_siting_v);
|
||||
+
|
||||
+ if (plane->state) {
|
||||
+ plane->state->chroma_siting_h = default_chroma_siting_h;
|
||||
+ plane->state->chroma_siting_v = default_chroma_siting_v;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL(drm_plane_create_chroma_siting_properties);
|
||||
+
|
||||
+/**
|
||||
* drm_color_lut_check - check validity of lookup table
|
||||
* @lut: property blob containing LUT to check
|
||||
* @tests: bitmask of tests to run
|
||||
--- a/include/drm/drm_color_mgmt.h
|
||||
+++ b/include/drm/drm_color_mgmt.h
|
||||
@@ -94,6 +94,9 @@ int drm_plane_create_color_properties(st
|
||||
enum drm_color_encoding default_encoding,
|
||||
enum drm_color_range default_range);
|
||||
|
||||
+int drm_plane_create_chroma_siting_properties(struct drm_plane *plane,
|
||||
+ int32_t default_chroma_siting_h, int32_t default_chroma_siting_v);
|
||||
+
|
||||
/**
|
||||
* enum drm_color_lut_tests - hw-specific LUT tests to perform
|
||||
*
|
||||
--- a/include/drm/drm_plane.h
|
||||
+++ b/include/drm/drm_plane.h
|
||||
@@ -178,6 +178,24 @@ struct drm_plane_state {
|
||||
enum drm_color_range color_range;
|
||||
|
||||
/**
|
||||
+ * @chroma_siting_h:
|
||||
+ *
|
||||
+ * Location of chroma samples horizontally compared to luma
|
||||
+ * 0 means chroma is sited with left luma
|
||||
+ * 0x8000 is interstitial. 0x10000 is sited with right luma
|
||||
+ */
|
||||
+ int32_t chroma_siting_h;
|
||||
+
|
||||
+ /**
|
||||
+ * @chroma_siting_v:
|
||||
+ *
|
||||
+ * Location of chroma samples vertically compared to luma
|
||||
+ * 0 means chroma is sited with top luma
|
||||
+ * 0x8000 is interstitial. 0x10000 is sited with bottom luma
|
||||
+ */
|
||||
+ int32_t chroma_siting_v;
|
||||
+
|
||||
+ /**
|
||||
* @fb_damage_clips:
|
||||
*
|
||||
* Blob representing damage (area in plane framebuffer that changed
|
||||
@@ -758,6 +776,24 @@ struct drm_plane {
|
||||
* scaling.
|
||||
*/
|
||||
struct drm_property *scaling_filter_property;
|
||||
+
|
||||
+ /**
|
||||
+ * @chroma_siting_h_property:
|
||||
+ *
|
||||
+ * Optional "CHROMA_SITING_H" property for specifying
|
||||
+ * chroma siting for YUV formats.
|
||||
+ * See drm_plane_create_chroma_siting_properties().
|
||||
+ */
|
||||
+ struct drm_property *chroma_siting_h_property;
|
||||
+
|
||||
+ /**
|
||||
+ * @chroma_siting_v_property:
|
||||
+ *
|
||||
+ * Optional "CHROMA_SITING_V" property for specifying
|
||||
+ * chroma siting for YUV formats.
|
||||
+ * See drm_plane_create_chroma_siting_properties().
|
||||
+ */
|
||||
+ struct drm_property *chroma_siting_v_property;
|
||||
};
|
||||
|
||||
#define obj_to_plane(x) container_of(x, struct drm_plane, base)
|
@ -0,0 +1,60 @@
|
||||
From 58d65d7d1c7b86291acaddea1606d884d5736ff0 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Thu, 27 Jan 2022 15:32:04 +0000
|
||||
Subject: [PATCH 0023/1085] vc4/drm:plane: Make use of chroma siting parameter
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_plane.c | 13 +++++++++----
|
||||
1 file changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
@@ -535,17 +535,18 @@ static void vc4_write_tpz(struct vc4_pla
|
||||
/* phase magnitude bits */
|
||||
#define PHASE_BITS 6
|
||||
|
||||
-static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst, u32 xy, int channel)
|
||||
+static void vc4_write_ppf(struct vc4_plane_state *vc4_state, u32 src, u32 dst, u32 xy, int channel, int chroma_offset)
|
||||
{
|
||||
u32 scale = src / dst;
|
||||
s32 offset, offset2;
|
||||
s32 phase;
|
||||
|
||||
/* Start the phase at 1/2 pixel from the 1st pixel at src_x.
|
||||
- 1/4 pixel for YUV. */
|
||||
+ 1/4 pixel for YUV, plus the offset for chroma siting */
|
||||
if (channel) {
|
||||
/* the phase is relative to scale_src->x, so shift it for display list's x value */
|
||||
offset = (xy & 0x1ffff) >> (16 - PHASE_BITS) >> 1;
|
||||
+ offset -= chroma_offset >> (17 - PHASE_BITS);
|
||||
offset += -(1 << PHASE_BITS >> 2);
|
||||
} else {
|
||||
/* the phase is relative to scale_src->x, so shift it for display list's x value */
|
||||
@@ -631,13 +632,15 @@ static void vc4_write_scaling_parameters
|
||||
/* Ch0 H-PPF Word 0: Scaling Parameters */
|
||||
if (vc4_state->x_scaling[channel] == VC4_SCALING_PPF) {
|
||||
vc4_write_ppf(vc4_state,
|
||||
- vc4_state->src_w[channel], vc4_state->crtc_w, vc4_state->src_x, channel);
|
||||
+ vc4_state->src_w[channel], vc4_state->crtc_w, vc4_state->src_x, channel,
|
||||
+ state->chroma_siting_h);
|
||||
}
|
||||
|
||||
/* Ch0 V-PPF Words 0-1: Scaling Parameters, Context */
|
||||
if (vc4_state->y_scaling[channel] == VC4_SCALING_PPF) {
|
||||
vc4_write_ppf(vc4_state,
|
||||
- vc4_state->src_h[channel], vc4_state->crtc_h, vc4_state->src_y, channel);
|
||||
+ vc4_state->src_h[channel], vc4_state->crtc_h, vc4_state->src_y, channel,
|
||||
+ state->chroma_siting_v);
|
||||
vc4_dlist_write(vc4_state, 0xc0c0c0c0);
|
||||
}
|
||||
|
||||
@@ -1718,6 +1721,8 @@ struct drm_plane *vc4_plane_init(struct
|
||||
DRM_COLOR_YCBCR_BT709,
|
||||
DRM_COLOR_YCBCR_LIMITED_RANGE);
|
||||
|
||||
+ drm_plane_create_chroma_siting_properties(plane, 0, 0);
|
||||
+
|
||||
if (type == DRM_PLANE_TYPE_PRIMARY)
|
||||
drm_plane_create_zpos_immutable_property(plane, 0);
|
||||
|
@ -0,0 +1,58 @@
|
||||
From c12bd0136e9772e955b5637185415d413d8d5b5c Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Fri, 1 Apr 2022 11:31:38 +0100
|
||||
Subject: [PATCH 0024/1085] drm/vc4: Force trigger of dlist update on margins
|
||||
change
|
||||
|
||||
When the margins are changed, the dlist needs to be regenerated
|
||||
with the changed updated dest regions for each of the planes.
|
||||
|
||||
Setting the zpos_changed flag is sufficient to trigger that
|
||||
without doing a full modeset, therefore set it should the
|
||||
margins be changed.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 14 ++++++++++----
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 7 +------
|
||||
2 files changed, 11 insertions(+), 10 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -752,10 +752,16 @@ int vc4_crtc_atomic_check(struct drm_crt
|
||||
if (conn_state->crtc != crtc)
|
||||
continue;
|
||||
|
||||
- vc4_state->margins.left = conn_state->tv.margins.left;
|
||||
- vc4_state->margins.right = conn_state->tv.margins.right;
|
||||
- vc4_state->margins.top = conn_state->tv.margins.top;
|
||||
- vc4_state->margins.bottom = conn_state->tv.margins.bottom;
|
||||
+ if (memcmp(&vc4_state->margins, &conn_state->tv.margins,
|
||||
+ sizeof(vc4_state->margins))) {
|
||||
+ memcpy(&vc4_state->margins, &conn_state->tv.margins,
|
||||
+ sizeof(vc4_state->margins));
|
||||
+
|
||||
+ /* Need to force the dlist entries for all planes to be
|
||||
+ * updated so that the dest rectangles are changed.
|
||||
+ */
|
||||
+ crtc_state->zpos_changed = true;
|
||||
+ }
|
||||
break;
|
||||
}
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -626,12 +626,7 @@ struct vc4_crtc_state {
|
||||
bool txp_armed;
|
||||
unsigned int assigned_channel;
|
||||
|
||||
- struct {
|
||||
- unsigned int left;
|
||||
- unsigned int right;
|
||||
- unsigned int top;
|
||||
- unsigned int bottom;
|
||||
- } margins;
|
||||
+ struct drm_connector_tv_margins margins;
|
||||
|
||||
unsigned long hvs_load;
|
||||
|
@ -0,0 +1,122 @@
|
||||
From 268e65023226cc59363dd9c9d9ad56a11588f4c3 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Vetter <daniel.vetter@ffwll.ch>
|
||||
Date: Fri, 23 Oct 2020 14:39:23 +0200
|
||||
Subject: [PATCH 0025/1085] drm/atomic-helpers: remove legacy_cursor_update
|
||||
hacks
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The stuff never really worked, and leads to lots of fun because it
|
||||
out-of-order frees atomic states. Which upsets KASAN, among other
|
||||
things.
|
||||
|
||||
For async updates we now have a more solid solution with the
|
||||
->atomic_async_check and ->atomic_async_commit hooks. Support for that
|
||||
for msm and vc4 landed. nouveau and i915 have their own commit
|
||||
routines, doing something similar.
|
||||
|
||||
For everyone else it's probably better to remove the use-after-free
|
||||
bug, and encourage folks to use the async support instead. The
|
||||
affected drivers which register a legacy cursor plane and don't either
|
||||
use the new async stuff or their own commit routine are: amdgpu,
|
||||
atmel, mediatek, qxl, rockchip, sti, sun4i, tegra, virtio, and vmwgfx.
|
||||
|
||||
Inspired by an amdgpu bug report.
|
||||
|
||||
v2: Drop RFC, I think with amdgpu converted over to use
|
||||
atomic_async_check/commit done in
|
||||
|
||||
commit 674e78acae0dfb4beb56132e41cbae5b60f7d662
|
||||
Author: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
|
||||
Date: Wed Dec 5 14:59:07 2018 -0500
|
||||
|
||||
drm/amd/display: Add fast path for cursor plane updates
|
||||
|
||||
we don't have any driver anymore where we have userspace expecting
|
||||
solid legacy cursor support _and_ they are using the atomic helpers in
|
||||
their fully glory. So we can retire this.
|
||||
|
||||
v3: Paper over msm and i915 regression. The complete_all is the only
|
||||
thing missing afaict.
|
||||
|
||||
v4: Rebased on recent kernel, added extra link for vc4 bug.
|
||||
|
||||
Link: https://bugzilla.kernel.org/show_bug.cgi?id=199425
|
||||
Link: https://lore.kernel.org/all/20220221134155.125447-9-maxime@cerno.tech/
|
||||
Cc: mikita.lipski@amd.com
|
||||
Cc: Michel Dänzer <michel@daenzer.net>
|
||||
Cc: harry.wentland@amd.com
|
||||
Cc: Rob Clark <robdclark@gmail.com>
|
||||
Cc: "Kazlauskas, Nicholas" <nicholas.kazlauskas@amd.com>
|
||||
Tested-by: Maxime Ripard <maxime@cerno.tech>
|
||||
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/drm_atomic_helper.c | 13 -------------
|
||||
drivers/gpu/drm/i915/display/intel_display.c | 13 +++++++++++++
|
||||
drivers/gpu/drm/msm/msm_atomic.c | 2 ++
|
||||
3 files changed, 15 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/drm_atomic_helper.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_helper.c
|
||||
@@ -1653,13 +1653,6 @@ drm_atomic_helper_wait_for_vblanks(struc
|
||||
int i, ret;
|
||||
unsigned int crtc_mask = 0;
|
||||
|
||||
- /*
|
||||
- * Legacy cursor ioctls are completely unsynced, and userspace
|
||||
- * relies on that (by doing tons of cursor updates).
|
||||
- */
|
||||
- if (old_state->legacy_cursor_update)
|
||||
- return;
|
||||
-
|
||||
for_each_oldnew_crtc_in_state(old_state, crtc, old_crtc_state, new_crtc_state, i) {
|
||||
if (!new_crtc_state->active)
|
||||
continue;
|
||||
@@ -2309,12 +2302,6 @@ int drm_atomic_helper_setup_commit(struc
|
||||
complete_all(&commit->flip_done);
|
||||
continue;
|
||||
}
|
||||
-
|
||||
- /* Legacy cursor updates are fully unsynced. */
|
||||
- if (state->legacy_cursor_update) {
|
||||
- complete_all(&commit->flip_done);
|
||||
- continue;
|
||||
- }
|
||||
|
||||
if (!new_crtc_state->event) {
|
||||
commit->event = kzalloc(sizeof(*commit->event),
|
||||
--- a/drivers/gpu/drm/i915/display/intel_display.c
|
||||
+++ b/drivers/gpu/drm/i915/display/intel_display.c
|
||||
@@ -7280,6 +7280,19 @@ int intel_atomic_commit(struct drm_devic
|
||||
state->base.legacy_cursor_update = false;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * FIXME: Cut over to (async) commit helpers instead of hand-rolling
|
||||
+ * everything.
|
||||
+ */
|
||||
+ if (state->base.legacy_cursor_update) {
|
||||
+ struct intel_crtc_state *new_crtc_state;
|
||||
+ struct intel_crtc *crtc;
|
||||
+ int i;
|
||||
+
|
||||
+ for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i)
|
||||
+ complete_all(&new_crtc_state->uapi.commit->flip_done);
|
||||
+ }
|
||||
+
|
||||
ret = intel_atomic_prepare_commit(state);
|
||||
if (ret) {
|
||||
drm_dbg_atomic(&dev_priv->drm,
|
||||
--- a/drivers/gpu/drm/msm/msm_atomic.c
|
||||
+++ b/drivers/gpu/drm/msm/msm_atomic.c
|
||||
@@ -242,6 +242,8 @@ void msm_atomic_commit_tail(struct drm_a
|
||||
/* async updates are limited to single-crtc updates: */
|
||||
WARN_ON(crtc_mask != drm_crtc_mask(async_crtc));
|
||||
|
||||
+ complete_all(&async_crtc->state->commit->flip_done);
|
||||
+
|
||||
/*
|
||||
* Start timer if we don't already have an update pending
|
||||
* on this crtc:
|
@ -0,0 +1,60 @@
|
||||
From f6d8271436e2589629ed6f3a8a85c3bde53353d6 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Fri, 1 Apr 2022 17:10:37 +0100
|
||||
Subject: [PATCH 0026/1085] drm/atomic: If margins are updated, update all
|
||||
planes.
|
||||
|
||||
Margins may be implemented by scaling the planes, but as there
|
||||
is no way of intercepting the set_property for a standard property,
|
||||
and all planes are checked in drm_atomic_check_only before the
|
||||
connectors, there's now way to add the planes into the state
|
||||
from the driver.
|
||||
|
||||
If the margin properties change, add all corresponding planes to
|
||||
the state.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/drm_atomic_uapi.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
|
||||
@@ -701,6 +701,7 @@ static int drm_atomic_connector_set_prop
|
||||
{
|
||||
struct drm_device *dev = connector->dev;
|
||||
struct drm_mode_config *config = &dev->mode_config;
|
||||
+ bool margins_updated = false;
|
||||
bool replaced = false;
|
||||
int ret;
|
||||
|
||||
@@ -729,12 +730,16 @@ static int drm_atomic_connector_set_prop
|
||||
state->tv.subconnector = val;
|
||||
} else if (property == config->tv_left_margin_property) {
|
||||
state->tv.margins.left = val;
|
||||
+ margins_updated = true;
|
||||
} else if (property == config->tv_right_margin_property) {
|
||||
state->tv.margins.right = val;
|
||||
+ margins_updated = true;
|
||||
} else if (property == config->tv_top_margin_property) {
|
||||
state->tv.margins.top = val;
|
||||
+ margins_updated = true;
|
||||
} else if (property == config->tv_bottom_margin_property) {
|
||||
state->tv.margins.bottom = val;
|
||||
+ margins_updated = true;
|
||||
} else if (property == config->legacy_tv_mode_property) {
|
||||
state->tv.legacy_mode = val;
|
||||
} else if (property == config->tv_mode_property) {
|
||||
@@ -817,6 +822,12 @@ static int drm_atomic_connector_set_prop
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
+ if (margins_updated && state->crtc) {
|
||||
+ ret = drm_atomic_add_affected_planes(state->state, state->crtc);
|
||||
+
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
From 8bfb80d65ef2ee6434517f5224d895c8f8eb57e6 Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Mon, 11 Jul 2022 10:38:25 +0200
|
||||
Subject: [PATCH 0027/1085] drm/vc4: hvs: Skip DebugFS Registration for FKMS
|
||||
|
||||
FKMS doesn't have an HVS and it's expected. Return from the debugfs init
|
||||
function immediately if we're running with fkms.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -976,6 +976,9 @@ int vc4_hvs_debugfs_init(struct drm_mino
|
||||
struct vc4_dev *vc4 = to_vc4_dev(drm);
|
||||
struct vc4_hvs *hvs = vc4->hvs;
|
||||
|
||||
+ if (vc4->firmware_kms)
|
||||
+ return 0;
|
||||
+
|
||||
if (!vc4->hvs)
|
||||
return -ENODEV;
|
||||
|
@ -0,0 +1,58 @@
|
||||
From b67f05e1c4b2027b4950661b118c91850e747ee7 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Wed, 1 Jun 2022 15:43:51 +0100
|
||||
Subject: [PATCH 0028/1085] drm/vc4_hdmi: Allow hotplug detect to be forced
|
||||
|
||||
See: https://forum.libreelec.tv/thread/24783-tv-avr-turns-back-on-right-after-turning-them-off
|
||||
|
||||
While the kernel provides a :D flag for assuming device is connected,
|
||||
it doesn't stop this function from being called and generating a cec_phys_addr_invalidate
|
||||
message when hotplug is deasserted.
|
||||
|
||||
That message provokes a flurry of CEC messages which for many users results in the TV
|
||||
switching back on again and it's very hard to get it to stay switched off.
|
||||
|
||||
It seems to only occur with an AVR and TV connected but has been observed across a
|
||||
number of manufacturers.
|
||||
|
||||
The issue started with https://github.com/raspberrypi/linux/pull/4371
|
||||
and this provides an optional way of getting back the old behaviour
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hdmi.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <linux/component.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/i2c.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/moduleparam.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
@@ -109,6 +111,10 @@
|
||||
|
||||
#define HDMI_14_MAX_TMDS_CLK (340 * 1000 * 1000)
|
||||
|
||||
+/* bit field to force hotplug detection. bit0 = HDMI0 */
|
||||
+static int force_hotplug = 0;
|
||||
+module_param(force_hotplug, int, 0644);
|
||||
+
|
||||
static const char * const output_format_str[] = {
|
||||
[VC4_HDMI_OUTPUT_RGB] = "RGB",
|
||||
[VC4_HDMI_OUTPUT_YUV420] = "YUV 4:2:0",
|
||||
@@ -472,7 +478,9 @@ static int vc4_hdmi_connector_detect_ctx
|
||||
|
||||
WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
|
||||
|
||||
- if (vc4_hdmi->hpd_gpio) {
|
||||
+ if (force_hotplug & BIT(vc4_hdmi->encoder.type - VC4_ENCODER_TYPE_HDMI0))
|
||||
+ status = connector_status_connected;
|
||||
+ else if (vc4_hdmi->hpd_gpio) {
|
||||
if (gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio))
|
||||
status = connector_status_connected;
|
||||
} else {
|
@ -0,0 +1,41 @@
|
||||
From 7508b889b8c8058e53ceeec90a1e3cc998897e16 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Tue, 6 Dec 2022 15:05:56 +0000
|
||||
Subject: [PATCH 0029/1085] vc4_hdmi: Avoid log spam for audio start failure
|
||||
|
||||
We regularly get dmesg error reports of:
|
||||
[ 18.184066] hdmi-audio-codec hdmi-audio-codec.3.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19
|
||||
[ 18.184098] MAI: soc_pcm_open() failed (-19)
|
||||
|
||||
Currently I get 30 of these when booting to desktop.
|
||||
We always say, ignore they are harmless, but removing them would be good.
|
||||
|
||||
A bit of investigation shows, for me, the errors are all generated by second, unused hdmi interface.
|
||||
|
||||
It shows as an alsa device, and pulseaudio attempts to open it (numerous times), generating a kernel
|
||||
error message each time.
|
||||
|
||||
systemctl --user restart pulseaudio.service generates 6 additional error messages.
|
||||
|
||||
The error messages all come through:
|
||||
https://github.com/raspberrypi/linux/blob/a009a9c0d79dfec114ee5102ec3d3325a172c952/sound/soc/soc-pcm.c#L39
|
||||
|
||||
which suggests returning ENOTSUPP, rather that ENODEV will be quiet. And indeed it is.
|
||||
|
||||
Note: earlier kernels do not have the quiet ENOTSUPP, so additional cherry-picks will be needed to backport
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
@@ -2394,7 +2394,7 @@ static int vc4_hdmi_audio_startup(struct
|
||||
}
|
||||
|
||||
if (!vc4_hdmi_audio_can_stream(vc4_hdmi)) {
|
||||
- ret = -ENODEV;
|
||||
+ ret = -ENOTSUPP;
|
||||
goto out_dev_exit;
|
||||
}
|
||||
|
@ -0,0 +1,401 @@
|
||||
From bd8bb0ed9c5908f84502ee76a152370291727eef Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Thu, 16 Dec 2021 14:54:54 +0100
|
||||
Subject: [PATCH 0030/1085] drm/vc4: hvs: Defer dlist slots deallocation
|
||||
|
||||
During normal operations, the cursor position update is done through an
|
||||
asynchronous plane update, which on the vc4 driver basically just
|
||||
modifies the right dlist word to move the plane to the new coordinates.
|
||||
|
||||
However, when we have the overscan margins setup, we fall back to a
|
||||
regular commit when we are next to the edges. And since that commit
|
||||
happens to be on a cursor plane, it's considered a legacy cursor update
|
||||
by KMS.
|
||||
|
||||
The main difference it makes is that it won't wait for its completion
|
||||
(ie, next vblank) before returning. This means if we have multiple
|
||||
commits happening in rapid succession, we can have several of them
|
||||
happening before the next vblank.
|
||||
|
||||
In parallel, our dlist allocation is tied to a CRTC state, and each time
|
||||
we do a commit we end up with a new CRTC state, with the previous one
|
||||
being freed. This means that we free our previous dlist entry (but don't
|
||||
clear it though) every time a new one is being committed.
|
||||
|
||||
Now, if we were to have two commits happening before the next vblank, we
|
||||
could end up freeing reusing the same dlist entries before the next
|
||||
vblank.
|
||||
|
||||
Indeed, we would start from an initial state taking, for example, the
|
||||
dlist entries 10 to 20, then start a commit taking the entries 20 to 30
|
||||
and setting the dlist pointer to 20, and freeing the dlist entries 10 to
|
||||
20. However, since we haven't reach vblank yet, the HVS is still using
|
||||
the entries 10 to 20.
|
||||
|
||||
If we were to make a new commit now, chances are the allocator are going
|
||||
to give the 10 to 20 entries back, and we would change their content to
|
||||
match the new state. If vblank hasn't happened yet, we just corrupted
|
||||
the active dlist entries.
|
||||
|
||||
A first attempt to solve this was made by creating an intermediate dlist
|
||||
buffer to store the current (ie, as of the last commit) dlist content,
|
||||
that we would update each time the HVS is done with a frame. However, if
|
||||
the interrupt handler missed the vblank window, we would end up copying
|
||||
our intermediate dlist to the hardware one during the composition,
|
||||
essentially creating the same issue.
|
||||
|
||||
Since making sure that our interrupt handler runs within a fixed,
|
||||
constrained, time window would require to make Linux a real-time kernel,
|
||||
this seems a bit out of scope.
|
||||
|
||||
Instead, we can work around our original issue by keeping the dlist
|
||||
slots allocation longer. That way, we won't reuse a dlist slot while
|
||||
it's still in flight. In order to achieve this, instead of freeing the
|
||||
dlist slot when its associated CRTC state is destroyed, we'll queue it
|
||||
in a list.
|
||||
|
||||
A naive implementation would free the buffers in that queue when we get
|
||||
our end of frame interrupt. However, there's still a race since, just
|
||||
like in the shadow dlist case, we don't control when the handler for
|
||||
that interrupt is going to run. Thus, we can end up with a commit adding
|
||||
an old dlist allocation to our queue during the window between our
|
||||
actual interrupt and when our handler will run. And since that buffer is
|
||||
still being used for the composition of the current frame, we can't free
|
||||
it right away, exposing us to the original bug.
|
||||
|
||||
Fortunately for us, the hardware provides a frame counter that is
|
||||
increased each time the first line of a frame is being generated.
|
||||
Associating the frame counter the image is supposed to go away to the
|
||||
allocation, and then only deallocate buffers that have a counter below
|
||||
or equal to the one we see when the deallocation code should prevent the
|
||||
above race from occuring.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_crtc.c | 10 +-
|
||||
drivers/gpu/drm/vc4/vc4_drv.h | 15 ++-
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 184 ++++++++++++++++++++++++++++++---
|
||||
3 files changed, 186 insertions(+), 23 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
|
||||
@@ -1097,14 +1097,8 @@ void vc4_crtc_destroy_state(struct drm_c
|
||||
struct vc4_dev *vc4 = to_vc4_dev(crtc->dev);
|
||||
struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
|
||||
|
||||
- if (drm_mm_node_allocated(&vc4_state->mm)) {
|
||||
- unsigned long flags;
|
||||
-
|
||||
- spin_lock_irqsave(&vc4->hvs->mm_lock, flags);
|
||||
- drm_mm_remove_node(&vc4_state->mm);
|
||||
- spin_unlock_irqrestore(&vc4->hvs->mm_lock, flags);
|
||||
-
|
||||
- }
|
||||
+ vc4_hvs_mark_dlist_entry_stale(vc4->hvs, vc4_state->mm);
|
||||
+ vc4_state->mm = NULL;
|
||||
|
||||
drm_atomic_helper_crtc_destroy_state(crtc, state);
|
||||
}
|
||||
--- a/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
|
||||
@@ -332,6 +332,9 @@ struct vc4_hvs {
|
||||
struct drm_mm lbm_mm;
|
||||
spinlock_t mm_lock;
|
||||
|
||||
+ struct list_head stale_dlist_entries;
|
||||
+ struct work_struct free_dlist_work;
|
||||
+
|
||||
struct drm_mm_node mitchell_netravali_filter;
|
||||
|
||||
struct debugfs_regset32 regset;
|
||||
@@ -619,10 +622,16 @@ struct drm_connector *vc4_get_crtc_conne
|
||||
struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc *crtc,
|
||||
struct drm_crtc_state *state);
|
||||
|
||||
+struct vc4_hvs_dlist_allocation {
|
||||
+ struct list_head node;
|
||||
+ struct drm_mm_node mm_node;
|
||||
+ unsigned int channel;
|
||||
+ u8 target_frame_count;
|
||||
+};
|
||||
+
|
||||
struct vc4_crtc_state {
|
||||
struct drm_crtc_state base;
|
||||
- /* Dlist area for this CRTC configuration. */
|
||||
- struct drm_mm_node mm;
|
||||
+ struct vc4_hvs_dlist_allocation *mm;
|
||||
bool txp_armed;
|
||||
unsigned int assigned_channel;
|
||||
|
||||
@@ -1032,6 +1041,8 @@ struct vc4_hvs *__vc4_hvs_alloc(struct v
|
||||
void vc4_hvs_stop_channel(struct vc4_hvs *hvs, unsigned int output);
|
||||
int vc4_hvs_get_fifo_from_output(struct vc4_hvs *hvs, unsigned int output);
|
||||
u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo);
|
||||
+void vc4_hvs_mark_dlist_entry_stale(struct vc4_hvs *hvs,
|
||||
+ struct vc4_hvs_dlist_allocation *alloc);
|
||||
int vc4_hvs_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state);
|
||||
void vc4_hvs_atomic_begin(struct drm_crtc *crtc, struct drm_atomic_state *state);
|
||||
void vc4_hvs_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_state *state);
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -412,6 +412,152 @@ static void vc5_hvs_update_gamma_lut(str
|
||||
vc5_hvs_lut_load(hvs, vc4_crtc);
|
||||
}
|
||||
|
||||
+static void vc4_hvs_irq_enable_eof(const struct vc4_hvs *hvs,
|
||||
+ unsigned int channel)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = hvs->vc4;
|
||||
+ u32 irq_mask = vc4->is_vc5 ?
|
||||
+ SCALER5_DISPCTRL_DSPEIEOF(channel) :
|
||||
+ SCALER_DISPCTRL_DSPEIEOF(channel);
|
||||
+
|
||||
+ HVS_WRITE(SCALER_DISPCTRL,
|
||||
+ HVS_READ(SCALER_DISPCTRL) | irq_mask);
|
||||
+}
|
||||
+
|
||||
+static void vc4_hvs_irq_clear_eof(const struct vc4_hvs *hvs,
|
||||
+ unsigned int channel)
|
||||
+{
|
||||
+ struct vc4_dev *vc4 = hvs->vc4;
|
||||
+ u32 irq_mask = vc4->is_vc5 ?
|
||||
+ SCALER5_DISPCTRL_DSPEIEOF(channel) :
|
||||
+ SCALER_DISPCTRL_DSPEIEOF(channel);
|
||||
+
|
||||
+ HVS_WRITE(SCALER_DISPCTRL,
|
||||
+ HVS_READ(SCALER_DISPCTRL) & ~irq_mask);
|
||||
+}
|
||||
+
|
||||
+static struct vc4_hvs_dlist_allocation *
|
||||
+vc4_hvs_alloc_dlist_entry(struct vc4_hvs *hvs,
|
||||
+ unsigned int channel,
|
||||
+ size_t dlist_count)
|
||||
+{
|
||||
+ struct vc4_hvs_dlist_allocation *alloc;
|
||||
+ unsigned long flags;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (channel == VC4_HVS_CHANNEL_DISABLED)
|
||||
+ return NULL;
|
||||
+
|
||||
+ alloc = kzalloc(sizeof(*alloc), GFP_KERNEL);
|
||||
+ if (!alloc)
|
||||
+ return ERR_PTR(-ENOMEM);
|
||||
+
|
||||
+ spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
+ ret = drm_mm_insert_node(&hvs->dlist_mm, &alloc->mm_node,
|
||||
+ dlist_count);
|
||||
+ spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
+ if (ret)
|
||||
+ return ERR_PTR(ret);
|
||||
+
|
||||
+ alloc->channel = channel;
|
||||
+
|
||||
+ return alloc;
|
||||
+}
|
||||
+
|
||||
+void vc4_hvs_mark_dlist_entry_stale(struct vc4_hvs *hvs,
|
||||
+ struct vc4_hvs_dlist_allocation *alloc)
|
||||
+{
|
||||
+ unsigned long flags;
|
||||
+ u8 frcnt;
|
||||
+
|
||||
+ if (!alloc)
|
||||
+ return;
|
||||
+
|
||||
+ if (!drm_mm_node_allocated(&alloc->mm_node))
|
||||
+ return;
|
||||
+
|
||||
+ frcnt = vc4_hvs_get_fifo_frame_count(hvs, alloc->channel);
|
||||
+ alloc->target_frame_count = (frcnt + 1) & ((1 << 6) - 1);
|
||||
+
|
||||
+ spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
+
|
||||
+ list_add_tail(&alloc->node, &hvs->stale_dlist_entries);
|
||||
+
|
||||
+ HVS_WRITE(SCALER_DISPSTAT, SCALER_DISPSTAT_EOF(alloc->channel));
|
||||
+ vc4_hvs_irq_enable_eof(hvs, alloc->channel);
|
||||
+
|
||||
+ spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
+}
|
||||
+
|
||||
+static void vc4_hvs_schedule_dlist_sweep(struct vc4_hvs *hvs,
|
||||
+ unsigned int channel)
|
||||
+{
|
||||
+ unsigned long flags;
|
||||
+
|
||||
+ spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
+
|
||||
+ if (!list_empty(&hvs->stale_dlist_entries))
|
||||
+ queue_work(system_unbound_wq, &hvs->free_dlist_work);
|
||||
+
|
||||
+ vc4_hvs_irq_clear_eof(hvs, channel);
|
||||
+
|
||||
+ spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Frame counts are essentially sequence numbers over 6 bits, and we
|
||||
+ * thus can use sequence number arithmetic and follow the RFC1982 to
|
||||
+ * implement proper comparison between them.
|
||||
+ */
|
||||
+static bool vc4_hvs_frcnt_lte(u8 cnt1, u8 cnt2)
|
||||
+{
|
||||
+ return (s8)((cnt1 << 2) - (cnt2 << 2)) <= 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Some atomic commits (legacy cursor updates, mostly) will not wait for
|
||||
+ * the next vblank and will just return once the commit has been pushed
|
||||
+ * to the hardware.
|
||||
+ *
|
||||
+ * On the hardware side, our HVS stores the planes parameters in its
|
||||
+ * context RAM, and will use part of the RAM to store data during the
|
||||
+ * frame rendering.
|
||||
+ *
|
||||
+ * This interacts badly if we get multiple commits before the next
|
||||
+ * vblank since we could end up overwriting the DLIST entries used by
|
||||
+ * previous commits if our dlist allocation reuses that entry. In such a
|
||||
+ * case, we would overwrite the data currently being used by the
|
||||
+ * hardware, resulting in a corrupted frame.
|
||||
+ *
|
||||
+ * In order to work around this, we'll queue the dlist entries in a list
|
||||
+ * once the associated CRTC state is destroyed. The HVS only allows us
|
||||
+ * to know which entry is being active, but not which one are no longer
|
||||
+ * being used, so in order to avoid freeing entries that are still used
|
||||
+ * by the hardware we add a guesstimate of the frame count where our
|
||||
+ * entry will no longer be used, and thus will only free those entries
|
||||
+ * when we will have reached that frame count.
|
||||
+ */
|
||||
+static void vc4_hvs_dlist_free_work(struct work_struct *work)
|
||||
+{
|
||||
+ struct vc4_hvs *hvs = container_of(work, struct vc4_hvs, free_dlist_work);
|
||||
+ struct vc4_hvs_dlist_allocation *cur, *next;
|
||||
+ unsigned long flags;
|
||||
+
|
||||
+ spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
+ list_for_each_entry_safe(cur, next, &hvs->stale_dlist_entries, node) {
|
||||
+ u8 frcnt;
|
||||
+
|
||||
+ frcnt = vc4_hvs_get_fifo_frame_count(hvs, cur->channel);
|
||||
+ if (!vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt))
|
||||
+ continue;
|
||||
+
|
||||
+ list_del(&cur->node);
|
||||
+ drm_mm_remove_node(&cur->mm_node);
|
||||
+ kfree(cur);
|
||||
+ }
|
||||
+ spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
+}
|
||||
+
|
||||
u8 vc4_hvs_get_fifo_frame_count(struct vc4_hvs *hvs, unsigned int fifo)
|
||||
{
|
||||
struct drm_device *drm = &hvs->vc4->base;
|
||||
@@ -643,13 +789,12 @@ int vc4_hvs_atomic_check(struct drm_crtc
|
||||
{
|
||||
struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
|
||||
struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
|
||||
+ struct vc4_hvs_dlist_allocation *alloc;
|
||||
struct drm_device *dev = crtc->dev;
|
||||
struct vc4_dev *vc4 = to_vc4_dev(dev);
|
||||
struct drm_plane *plane;
|
||||
- unsigned long flags;
|
||||
const struct drm_plane_state *plane_state;
|
||||
u32 dlist_count = 0;
|
||||
- int ret;
|
||||
|
||||
/* The pixelvalve can only feed one encoder (and encoders are
|
||||
* 1:1 with connectors.)
|
||||
@@ -662,12 +807,11 @@ int vc4_hvs_atomic_check(struct drm_crtc
|
||||
|
||||
dlist_count++; /* Account for SCALER_CTL0_END. */
|
||||
|
||||
- spin_lock_irqsave(&vc4->hvs->mm_lock, flags);
|
||||
- ret = drm_mm_insert_node(&vc4->hvs->dlist_mm, &vc4_state->mm,
|
||||
- dlist_count);
|
||||
- spin_unlock_irqrestore(&vc4->hvs->mm_lock, flags);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
+ alloc = vc4_hvs_alloc_dlist_entry(vc4->hvs, vc4_state->assigned_channel, dlist_count);
|
||||
+ if (IS_ERR(alloc))
|
||||
+ return PTR_ERR(alloc);
|
||||
+
|
||||
+ vc4_state->mm = alloc;
|
||||
|
||||
return vc4_hvs_gamma_check(crtc, state);
|
||||
}
|
||||
@@ -683,8 +827,9 @@ static void vc4_hvs_install_dlist(struct
|
||||
if (!drm_dev_enter(dev, &idx))
|
||||
return;
|
||||
|
||||
+ WARN_ON(!vc4_state->mm);
|
||||
HVS_WRITE(SCALER_DISPLISTX(vc4_state->assigned_channel),
|
||||
- vc4_state->mm.start);
|
||||
+ vc4_state->mm->mm_node.start);
|
||||
|
||||
drm_dev_exit(idx);
|
||||
}
|
||||
@@ -711,8 +856,10 @@ static void vc4_hvs_update_dlist(struct
|
||||
spin_unlock_irqrestore(&dev->event_lock, flags);
|
||||
}
|
||||
|
||||
+ WARN_ON(!vc4_state->mm);
|
||||
+
|
||||
spin_lock_irqsave(&vc4_crtc->irq_lock, flags);
|
||||
- vc4_crtc->current_dlist = vc4_state->mm.start;
|
||||
+ vc4_crtc->current_dlist = vc4_state->mm->mm_node.start;
|
||||
spin_unlock_irqrestore(&vc4_crtc->irq_lock, flags);
|
||||
}
|
||||
|
||||
@@ -769,8 +916,7 @@ void vc4_hvs_atomic_flush(struct drm_crt
|
||||
struct vc4_plane_state *vc4_plane_state;
|
||||
bool debug_dump_regs = false;
|
||||
bool enable_bg_fill = false;
|
||||
- u32 __iomem *dlist_start = vc4->hvs->dlist + vc4_state->mm.start;
|
||||
- u32 __iomem *dlist_next = dlist_start;
|
||||
+ u32 __iomem *dlist_start, *dlist_next;
|
||||
unsigned int zpos = 0;
|
||||
bool found = false;
|
||||
int idx;
|
||||
@@ -788,6 +934,9 @@ void vc4_hvs_atomic_flush(struct drm_crt
|
||||
vc4_hvs_dump_state(hvs);
|
||||
}
|
||||
|
||||
+ dlist_start = vc4->hvs->dlist + vc4_state->mm->mm_node.start;
|
||||
+ dlist_next = dlist_start;
|
||||
+
|
||||
/* Copy all the active planes' dlist contents to the hardware dlist. */
|
||||
do {
|
||||
found = false;
|
||||
@@ -821,7 +970,8 @@ void vc4_hvs_atomic_flush(struct drm_crt
|
||||
writel(SCALER_CTL0_END, dlist_next);
|
||||
dlist_next++;
|
||||
|
||||
- WARN_ON_ONCE(dlist_next - dlist_start != vc4_state->mm.size);
|
||||
+ WARN_ON(!vc4_state->mm);
|
||||
+ WARN_ON_ONCE(dlist_next - dlist_start != vc4_state->mm->mm_node.size);
|
||||
|
||||
if (enable_bg_fill)
|
||||
/* This sets a black background color fill, as is the case
|
||||
@@ -960,6 +1110,11 @@ static irqreturn_t vc4_hvs_irq_handler(i
|
||||
|
||||
irqret = IRQ_HANDLED;
|
||||
}
|
||||
+
|
||||
+ if (status & SCALER_DISPSTAT_EOF(channel)) {
|
||||
+ vc4_hvs_schedule_dlist_sweep(hvs, channel);
|
||||
+ irqret = IRQ_HANDLED;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Clear every per-channel interrupt flag. */
|
||||
@@ -1014,6 +1169,9 @@ struct vc4_hvs *__vc4_hvs_alloc(struct v
|
||||
|
||||
spin_lock_init(&hvs->mm_lock);
|
||||
|
||||
+ INIT_LIST_HEAD(&hvs->stale_dlist_entries);
|
||||
+ INIT_WORK(&hvs->free_dlist_work, vc4_hvs_dlist_free_work);
|
||||
+
|
||||
/* Set up the HVS display list memory manager. We never
|
||||
* overwrite the setup from the bootloader (just 128b out of
|
||||
* our 16K), since we don't want to scramble the screen when
|
@ -0,0 +1,30 @@
|
||||
From bc1c5829ecc698e41379f461f1fd7e8d600b879f Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Wed, 25 Jan 2023 12:38:37 +0100
|
||||
Subject: [PATCH 0031/1085] drm/vc4: hvs: Initialize the dlist allocation list
|
||||
entry
|
||||
|
||||
The vc4_hvs_dlist_allocation structure has a list that we don't
|
||||
initialize when we allocate a new instance.
|
||||
|
||||
This makes any call reading the list structure (such as list_empty) fail
|
||||
with a NULL pointer dereference.
|
||||
|
||||
Let's make sure our list is always initialized.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -452,6 +452,8 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
|
||||
if (!alloc)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
+ INIT_LIST_HEAD(&alloc->node);
|
||||
+
|
||||
spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
ret = drm_mm_insert_node(&hvs->dlist_mm, &alloc->mm_node,
|
||||
dlist_count);
|
@ -0,0 +1,46 @@
|
||||
From 9e2b5f6b8d74b18c96521c3e9ddd3f7fc75d917f Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Wed, 25 Jan 2023 12:54:36 +0100
|
||||
Subject: [PATCH 0032/1085] drm/vc4: hvs: Move the dlist allocation destruction
|
||||
to a function
|
||||
|
||||
We'll need to destroy a dlist allocation in multiple code paths, so
|
||||
let's move it to a separate function.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 16 +++++++++++++---
|
||||
1 file changed, 13 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -466,6 +466,18 @@ vc4_hvs_alloc_dlist_entry(struct vc4_hvs
|
||||
return alloc;
|
||||
}
|
||||
|
||||
+static void vc4_hvs_free_dlist_entry_locked(struct vc4_hvs *hvs,
|
||||
+ struct vc4_hvs_dlist_allocation *alloc)
|
||||
+{
|
||||
+ lockdep_assert_held(&hvs->mm_lock);
|
||||
+
|
||||
+ if (!list_empty(&alloc->node))
|
||||
+ list_del(&alloc->node);
|
||||
+
|
||||
+ drm_mm_remove_node(&alloc->mm_node);
|
||||
+ kfree(alloc);
|
||||
+}
|
||||
+
|
||||
void vc4_hvs_mark_dlist_entry_stale(struct vc4_hvs *hvs,
|
||||
struct vc4_hvs_dlist_allocation *alloc)
|
||||
{
|
||||
@@ -553,9 +565,7 @@ static void vc4_hvs_dlist_free_work(stru
|
||||
if (!vc4_hvs_frcnt_lte(cur->target_frame_count, frcnt))
|
||||
continue;
|
||||
|
||||
- list_del(&cur->node);
|
||||
- drm_mm_remove_node(&cur->mm_node);
|
||||
- kfree(cur);
|
||||
+ vc4_hvs_free_dlist_entry_locked(hvs, cur);
|
||||
}
|
||||
spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
From e546f85606dcf2cdff94ff32a0756e2541bccb05 Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Wed, 25 Jan 2023 13:05:26 +0100
|
||||
Subject: [PATCH 0033/1085] drm/vc4: hvs: Destroy dlist allocations immediately
|
||||
when running a test
|
||||
|
||||
When running a kunit test, the driver runs with a mock device. As such,
|
||||
any attempt to read or write to a hardware register will fail the
|
||||
current test immediately.
|
||||
|
||||
The dlist allocation management recently introduced will read the
|
||||
current frame count from the HVS to defer its destruction until a
|
||||
subsequent frame has been output. This obviously involves a register
|
||||
read that fails the Kunit tests.
|
||||
|
||||
Change the destruction deferral function to destroy the allocation
|
||||
immediately if we run under kunit. This is essentially harmless since
|
||||
the main reason for that deferall is to prevent any access to the
|
||||
hardware dlist while a frame described by that list is rendered. On our
|
||||
mock driver, we have neither a hardware dlist nor a rendering, so it
|
||||
doesn't matter.
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -490,6 +490,18 @@ void vc4_hvs_mark_dlist_entry_stale(stru
|
||||
if (!drm_mm_node_allocated(&alloc->mm_node))
|
||||
return;
|
||||
|
||||
+ /*
|
||||
+ * Kunit tests run with a mock device and we consider any hardware
|
||||
+ * access a test failure. Let's free the dlist allocation right away if
|
||||
+ * we're running under kunit, we won't risk a dlist corruption anyway.
|
||||
+ */
|
||||
+ if (kunit_get_current_test()) {
|
||||
+ spin_lock_irqsave(&hvs->mm_lock, flags);
|
||||
+ vc4_hvs_free_dlist_entry_locked(hvs, alloc);
|
||||
+ spin_unlock_irqrestore(&hvs->mm_lock, flags);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
frcnt = vc4_hvs_get_fifo_frame_count(hvs, alloc->channel);
|
||||
alloc->target_frame_count = (frcnt + 1) & ((1 << 6) - 1);
|
||||
|
@ -0,0 +1,53 @@
|
||||
From fb2081692fb040f6260e008272c9f6cb155c9a77 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Tue, 31 Jan 2023 15:14:32 +0000
|
||||
Subject: [PATCH 0034/1085] drm/vc4_plane: Add support for YUV444 formats
|
||||
|
||||
Support displaying DRM_FORMAT_YUV444 and DRM_FORMAT_YVU444 formats.
|
||||
Tested with kmstest and kodi. e.g.
|
||||
|
||||
kmstest -r 1920x1080@60 -f 400x300-YU24
|
||||
|
||||
Note: without the shift of width, only half the chroma is fetched,
|
||||
resulting in correct left half of image and corrupt colours on right half.
|
||||
|
||||
The increase in width shouldn't affect fetching of Y data,
|
||||
as the hardware will clamp at dest width.
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_plane.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
|
||||
@@ -110,6 +110,18 @@ static const struct hvs_format {
|
||||
.pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
|
||||
},
|
||||
{
|
||||
+ .drm = DRM_FORMAT_YUV444,
|
||||
+ .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
|
||||
+ .pixel_order = HVS_PIXEL_ORDER_XYCBCR,
|
||||
+ .pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCBCR,
|
||||
+ },
|
||||
+ {
|
||||
+ .drm = DRM_FORMAT_YVU444,
|
||||
+ .hvs = HVS_PIXEL_FORMAT_YCBCR_YUV422_3PLANE,
|
||||
+ .pixel_order = HVS_PIXEL_ORDER_XYCRCB,
|
||||
+ .pixel_order_hvs5 = HVS_PIXEL_ORDER_XYCRCB,
|
||||
+ },
|
||||
+ {
|
||||
.drm = DRM_FORMAT_YUV420,
|
||||
.hvs = HVS_PIXEL_FORMAT_YCBCR_YUV420_3PLANE,
|
||||
.pixel_order = HVS_PIXEL_ORDER_XYCBCR,
|
||||
@@ -1106,6 +1118,10 @@ static int vc4_plane_mode_set(struct drm
|
||||
vc4_state->src_y + vc4_state->src_h[0] < (state->fb->height << 16))
|
||||
height++;
|
||||
|
||||
+ /* for YUV444 hardware wants double the width, otherwise it doesn't fetch full width of chroma */
|
||||
+ if (format->drm == DRM_FORMAT_YUV444 || format->drm == DRM_FORMAT_YVU444)
|
||||
+ width <<= 1;
|
||||
+
|
||||
/* Don't waste cycles mixing with plane alpha if the set alpha
|
||||
* is opaque or there is no per-pixel alpha information.
|
||||
* In any case we use the alpha property value as the fixed alpha.
|
@ -0,0 +1,29 @@
|
||||
From 57fe034a5020aca4a7d1558b21c31737c2abc15e Mon Sep 17 00:00:00 2001
|
||||
From: Matthias Reichl <hias@horus.com>
|
||||
Date: Sat, 14 Jan 2023 16:24:39 +0100
|
||||
Subject: [PATCH 0035/1085] drm/vc4: Calculate bpc based on max_requested_bpc
|
||||
|
||||
This aligns vc4 with Intel, AMD and Synopsis drivers and fixes max bpc
|
||||
connector property not working as expected on monitors with YCbCr 4:2:2
|
||||
support but not deep color support.
|
||||
|
||||
max_bpc in connector state is clamped at max_bpc from display info and
|
||||
the latter only takes deep color modes into account so it will always
|
||||
be 8, even if the display can do 4:2:2 12-bit output.
|
||||
|
||||
Signed-off-by: Matthias Reichl <hias@horus.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
@@ -2126,7 +2126,7 @@ vc4_hdmi_encoder_compute_config(const st
|
||||
{
|
||||
struct drm_device *dev = vc4_hdmi->connector.dev;
|
||||
struct drm_connector_state *conn_state = &vc4_state->base;
|
||||
- unsigned int max_bpc = clamp_t(unsigned int, conn_state->max_bpc, 8, 12);
|
||||
+ unsigned int max_bpc = clamp_t(unsigned int, conn_state->max_requested_bpc, 8, 12);
|
||||
unsigned int bpc;
|
||||
int ret;
|
||||
|
@ -0,0 +1,39 @@
|
||||
From 78a1315a44243385c57289a2c30f3b25de87b603 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Thu, 11 Aug 2022 13:59:34 +0100
|
||||
Subject: [PATCH 0036/1085] drm/vc4: Set AXI panic modes for the HVS
|
||||
|
||||
The HVS can change AXI request mode based on how full the COB
|
||||
FIFOs are.
|
||||
Until now the vc4 driver has been relying on the firmware to
|
||||
have set these to sensible values.
|
||||
|
||||
With HVS channel 2 now being used for live video, change the
|
||||
panic mode for all channels to be explicitly set by the driver,
|
||||
and the same for all channels.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hvs.c | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hvs.c
|
||||
@@ -1363,6 +1363,17 @@ static int vc4_hvs_bind(struct device *d
|
||||
dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_PANIC1);
|
||||
dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_PANIC2);
|
||||
|
||||
+ /* Set AXI panic mode.
|
||||
+ * VC4 panics when < 2 lines in FIFO.
|
||||
+ * VC5 panics when less than 1 line in the FIFO.
|
||||
+ */
|
||||
+ dispctrl &= ~(SCALER_DISPCTRL_PANIC0_MASK |
|
||||
+ SCALER_DISPCTRL_PANIC1_MASK |
|
||||
+ SCALER_DISPCTRL_PANIC2_MASK);
|
||||
+ dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_PANIC0);
|
||||
+ dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_PANIC1);
|
||||
+ dispctrl |= VC4_SET_FIELD(2, SCALER_DISPCTRL_PANIC2);
|
||||
+
|
||||
HVS_WRITE(SCALER_DISPCTRL, dispctrl);
|
||||
|
||||
/* Recompute Composite Output Buffer (COB) allocations for the displays
|
@ -0,0 +1,37 @@
|
||||
From 4b89e6e55f5c04f836b92ffbeef7c4c8a545adfd Mon Sep 17 00:00:00 2001
|
||||
From: Matthias Reichl <hias@horus.com>
|
||||
Date: Sat, 11 Mar 2023 22:41:17 +0100
|
||||
Subject: [PATCH 0037/1085] drm/vc4: drop unnecessary and harmful HDMI RGB
|
||||
format check
|
||||
|
||||
RGB is a mandatory format for all DVI and HDMI monitors so there's
|
||||
no need to check for presence of the DRM_COLOR_FORMAT_RGB444 bit in
|
||||
color_formats.
|
||||
|
||||
More importantly this checks breaks working around EDID issues with
|
||||
eg video=HDMI-A-1:1024x768D or drm.edid_firmware=edid/1024x768.bin
|
||||
as the RGB444 bit is only set when a valid EDID with digital bit set in
|
||||
the input byte is present - which isn't the case when no EDID can be
|
||||
read from the display device at all or with the in-built kernel EDIDs,
|
||||
which mimic analog (VGA) displays without the digital bit set.
|
||||
|
||||
So drop the check, if we output video on the HDMI connector we can
|
||||
assume that the display can accept 8bit RGB.
|
||||
|
||||
Signed-off-by: Matthias Reichl <hias@horus.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hdmi.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
@@ -1952,9 +1952,6 @@ vc4_hdmi_sink_supports_format_bpc(const
|
||||
case VC4_HDMI_OUTPUT_RGB:
|
||||
drm_dbg(dev, "RGB Format, checking the constraints.\n");
|
||||
|
||||
- if (!(info->color_formats & DRM_COLOR_FORMAT_RGB444))
|
||||
- return false;
|
||||
-
|
||||
if (bpc == 10 && !(info->edid_hdmi_rgb444_dc_modes & DRM_EDID_HDMI_DC_30)) {
|
||||
drm_dbg(dev, "10 BPC but sink doesn't support Deep Color 30.\n");
|
||||
return false;
|
@ -0,0 +1,37 @@
|
||||
From accb4b40a97c432b8a83f6fedf12b015aebb711d Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
Date: Mon, 24 Apr 2023 18:32:45 +0100
|
||||
Subject: [PATCH 0038/1085] drm/vc4: Limit max_bpc to 8 on Pi0-3
|
||||
|
||||
Pi 0-3 have no deep colour support and only 24bpp output,
|
||||
so max_bpc should remain as 8.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
|
||||
---
|
||||
drivers/gpu/drm/vc4/vc4_hdmi.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
|
||||
@@ -756,7 +756,6 @@ static int vc4_hdmi_connector_init(struc
|
||||
|
||||
drm_connector_attach_colorspace_property(connector);
|
||||
drm_connector_attach_tv_margin_properties(connector);
|
||||
- drm_connector_attach_max_bpc_property(connector, 8, 12);
|
||||
|
||||
connector->polled = (DRM_CONNECTOR_POLL_CONNECT |
|
||||
DRM_CONNECTOR_POLL_DISCONNECT);
|
||||
@@ -765,8 +764,12 @@ static int vc4_hdmi_connector_init(struc
|
||||
connector->doublescan_allowed = 0;
|
||||
connector->stereo_allowed = 1;
|
||||
|
||||
- if (vc4_hdmi->variant->supports_hdr)
|
||||
+ if (vc4_hdmi->variant->supports_hdr) {
|
||||
+ drm_connector_attach_max_bpc_property(connector, 8, 12);
|
||||
drm_connector_attach_hdr_output_metadata_property(connector);
|
||||
+ } else {
|
||||
+ drm_connector_attach_max_bpc_property(connector, 8, 8);
|
||||
+ }
|
||||
|
||||
vc4_hdmi_attach_broadcast_rgb_property(dev, vc4_hdmi);
|
||||
|
@ -0,0 +1,24 @@
|
||||
From e51e9120a35d0b1600e4337e6ecbd020c074af80 Mon Sep 17 00:00:00 2001
|
||||
From: Maxime Ripard <maxime@cerno.tech>
|
||||
Date: Mon, 6 Jun 2022 11:02:16 +0200
|
||||
Subject: [PATCH 0039/1085] arm64: setup: Fix build warning
|
||||
|
||||
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
|
||||
---
|
||||
arch/arm64/kernel/setup.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/arm64/kernel/setup.c
|
||||
+++ b/arch/arm64/kernel/setup.c
|
||||
@@ -225,9 +225,9 @@ static void __init request_standard_reso
|
||||
size_t res_size;
|
||||
|
||||
kernel_code.start = __pa_symbol(_stext);
|
||||
- kernel_code.end = __pa_symbol(__init_begin - 1);
|
||||
+ kernel_code.end = __pa_symbol(__init_begin) - 1;
|
||||
kernel_data.start = __pa_symbol(_sdata);
|
||||
- kernel_data.end = __pa_symbol(_end - 1);
|
||||
+ kernel_data.end = __pa_symbol(_end) - 1;
|
||||
insert_resource(&iomem_resource, &kernel_code);
|
||||
insert_resource(&iomem_resource, &kernel_data);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
From 7cdd917ff28317a362935cbcd12e5ec98e22368c Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Tue, 12 Apr 2022 20:07:20 +0100
|
||||
Subject: [PATCH 0042/1085] clk-raspberrypi: Add ISP to exported clocks
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/clk/bcm/clk-raspberrypi.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-raspberrypi.c
|
||||
+++ b/drivers/clk/bcm/clk-raspberrypi.c
|
||||
@@ -118,6 +118,9 @@ raspberrypi_clk_variants[RPI_FIRMWARE_NU
|
||||
[RPI_FIRMWARE_HEVC_CLK_ID] = {
|
||||
.export = true,
|
||||
},
|
||||
+ [RPI_FIRMWARE_ISP_CLK_ID] = {
|
||||
+ .export = true,
|
||||
+ },
|
||||
[RPI_FIRMWARE_PIXEL_BVB_CLK_ID] = {
|
||||
.export = true,
|
||||
},
|
@ -0,0 +1,45 @@
|
||||
From 23472156777a9baa8724add831088560001b0d67 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Sperl <kernel@martin.sperl.org>
|
||||
Date: Fri, 2 Sep 2016 16:45:27 +0100
|
||||
Subject: [PATCH 0043/1085] Register the clocks early during the boot process,
|
||||
so that special/critical clocks can get enabled early on in the boot process
|
||||
avoiding the risk of disabling a clock, pll_divider or pll when a claiming
|
||||
driver fails to install propperly - maybe it needs to defer.
|
||||
|
||||
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 15 +++++++++++++--
|
||||
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -2319,8 +2319,15 @@ static int bcm2835_clk_probe(struct plat
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- return of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
|
||||
+ ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get,
|
||||
&cprman->onecell);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* note that we have registered all the clocks */
|
||||
+ dev_dbg(dev, "registered %d clocks\n", asize);
|
||||
+
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static const struct cprman_plat_data cprman_bcm2835_plat_data = {
|
||||
@@ -2346,7 +2353,11 @@ static struct platform_driver bcm2835_cl
|
||||
.probe = bcm2835_clk_probe,
|
||||
};
|
||||
|
||||
-builtin_platform_driver(bcm2835_clk_driver);
|
||||
+static int __init __bcm2835_clk_driver_init(void)
|
||||
+{
|
||||
+ return platform_driver_register(&bcm2835_clk_driver);
|
||||
+}
|
||||
+core_initcall(__bcm2835_clk_driver_init);
|
||||
|
||||
MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
|
||||
MODULE_DESCRIPTION("BCM2835 clock driver");
|
@ -0,0 +1,28 @@
|
||||
From 424a8ed7304489b35342229a6acddc9d1b9ed29f Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Mon, 13 Feb 2017 17:20:08 +0000
|
||||
Subject: [PATCH 0044/1085] clk-bcm2835: Mark used PLLs and dividers CRITICAL
|
||||
|
||||
The VPU configures and relies on several PLLs and dividers. Mark all
|
||||
enabled dividers and their PLLs as CRITICAL to prevent the kernel from
|
||||
switching them off.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -1407,6 +1407,11 @@ bcm2835_register_pll_divider(struct bcm2
|
||||
divider->div.hw.init = &init;
|
||||
divider->div.table = NULL;
|
||||
|
||||
+ if (!(cprman_read(cprman, divider_data->cm_reg) & divider_data->hold_mask)) {
|
||||
+ init.flags |= CLK_IS_CRITICAL;
|
||||
+ divider->div.flags |= CLK_IS_CRITICAL;
|
||||
+ }
|
||||
+
|
||||
divider->cprman = cprman;
|
||||
divider->data = divider_data;
|
||||
|
@ -0,0 +1,118 @@
|
||||
From a3e8abeba9c63145d98dfc1cf859a2a2796ea7c0 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Mon, 13 Feb 2017 17:20:08 +0000
|
||||
Subject: [PATCH 0045/1085] clk-bcm2835: Add claim-clocks property
|
||||
|
||||
The claim-clocks property can be used to prevent PLLs and dividers
|
||||
from being marked as critical. It contains a vector of clock IDs,
|
||||
as defined by dt-bindings/clock/bcm2835.h.
|
||||
|
||||
Use this mechanism to claim PLLD_DSI0, PLLD_DSI1, PLLH_AUX and
|
||||
PLLH_PIX for the vc4_kms_v3d driver.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 43 +++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 41 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -1335,6 +1335,8 @@ static const struct clk_ops bcm2835_vpu_
|
||||
.debug_init = bcm2835_clock_debug_init,
|
||||
};
|
||||
|
||||
+static bool bcm2835_clk_is_claimed(const char *name);
|
||||
+
|
||||
static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
|
||||
const void *data)
|
||||
{
|
||||
@@ -1352,6 +1354,9 @@ static struct clk_hw *bcm2835_register_p
|
||||
init.ops = &bcm2835_pll_clk_ops;
|
||||
init.flags = pll_data->flags | CLK_IGNORE_UNUSED;
|
||||
|
||||
+ if (!bcm2835_clk_is_claimed(pll_data->name))
|
||||
+ init.flags |= CLK_IS_CRITICAL;
|
||||
+
|
||||
pll = kzalloc(sizeof(*pll), GFP_KERNEL);
|
||||
if (!pll)
|
||||
return NULL;
|
||||
@@ -1408,8 +1413,10 @@ bcm2835_register_pll_divider(struct bcm2
|
||||
divider->div.table = NULL;
|
||||
|
||||
if (!(cprman_read(cprman, divider_data->cm_reg) & divider_data->hold_mask)) {
|
||||
- init.flags |= CLK_IS_CRITICAL;
|
||||
- divider->div.flags |= CLK_IS_CRITICAL;
|
||||
+ if (!bcm2835_clk_is_claimed(divider_data->source_pll))
|
||||
+ init.flags |= CLK_IS_CRITICAL;
|
||||
+ if (!bcm2835_clk_is_claimed(divider_data->name))
|
||||
+ divider->div.flags |= CLK_IS_CRITICAL;
|
||||
}
|
||||
|
||||
divider->cprman = cprman;
|
||||
@@ -1466,6 +1473,15 @@ static struct clk_hw *bcm2835_register_c
|
||||
init.flags = clock_data->flags | CLK_IGNORE_UNUSED;
|
||||
|
||||
/*
|
||||
+ * Some GPIO clocks for ethernet/wifi PLLs are marked as
|
||||
+ * critical (since some platforms use them), but if the
|
||||
+ * firmware didn't have them turned on then they clearly
|
||||
+ * aren't actually critical.
|
||||
+ */
|
||||
+ if ((cprman_read(cprman, clock_data->ctl_reg) & CM_ENABLE) == 0)
|
||||
+ init.flags &= ~CLK_IS_CRITICAL;
|
||||
+
|
||||
+ /*
|
||||
* Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate
|
||||
* rate changes on at least of the parents.
|
||||
*/
|
||||
@@ -2245,6 +2261,8 @@ static const struct bcm2835_clk_desc clk
|
||||
.ctl_reg = CM_PERIICTL),
|
||||
};
|
||||
|
||||
+static bool bcm2835_clk_claimed[ARRAY_SIZE(clk_desc_array)];
|
||||
+
|
||||
/*
|
||||
* Permanently take a reference on the parent of the SDRAM clock.
|
||||
*
|
||||
@@ -2264,6 +2282,19 @@ static int bcm2835_mark_sdc_parent_criti
|
||||
return clk_prepare_enable(parent);
|
||||
}
|
||||
|
||||
+static bool bcm2835_clk_is_claimed(const char *name)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
|
||||
+ const char *clk_name = *(const char **)(clk_desc_array[i].data);
|
||||
+ if (!strcmp(name, clk_name))
|
||||
+ return bcm2835_clk_claimed[i];
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static int bcm2835_clk_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
@@ -2273,6 +2304,7 @@ static int bcm2835_clk_probe(struct plat
|
||||
const size_t asize = ARRAY_SIZE(clk_desc_array);
|
||||
const struct cprman_plat_data *pdata;
|
||||
size_t i;
|
||||
+ u32 clk_id;
|
||||
int ret;
|
||||
|
||||
pdata = of_device_get_match_data(&pdev->dev);
|
||||
@@ -2291,6 +2323,13 @@ static int bcm2835_clk_probe(struct plat
|
||||
if (IS_ERR(cprman->regs))
|
||||
return PTR_ERR(cprman->regs);
|
||||
|
||||
+ memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
|
||||
+ for (i = 0;
|
||||
+ !of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
|
||||
+ i, &clk_id);
|
||||
+ i++)
|
||||
+ bcm2835_clk_claimed[clk_id]= true;
|
||||
+
|
||||
memcpy(cprman->real_parent_names, cprman_parent_names,
|
||||
sizeof(cprman_parent_names));
|
||||
of_clk_parent_fill(dev->of_node, cprman->real_parent_names,
|
@ -0,0 +1,115 @@
|
||||
From 7029b92f5fdba739ad2698dc9546e7be03002c51 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Mon, 6 Mar 2017 09:06:18 +0000
|
||||
Subject: [PATCH 0046/1085] clk-bcm2835: Read max core clock from firmware
|
||||
|
||||
The VPU is responsible for managing the core clock, usually under
|
||||
direction from the bcm2835-cpufreq driver but not via the clk-bcm2835
|
||||
driver. Since the core frequency can change without warning, it is
|
||||
safer to report the maximum clock rate to users of the core clock -
|
||||
I2C, SPI and the mini UART - to err on the safe side when calculating
|
||||
clock divisors.
|
||||
|
||||
If the DT node for the clock driver includes a reference to the
|
||||
firmware node, use the firmware API to query the maximum core clock
|
||||
instead of reading the divider registers.
|
||||
|
||||
Prior to this patch, a "100KHz" I2C bus was sometimes clocked at about
|
||||
160KHz. In particular, switching to the 4.9 kernel was likely to break
|
||||
SenseHAT usage on a Pi3.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 39 ++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 38 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <dt-bindings/clock/bcm2835.h>
|
||||
+#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
|
||||
#define CM_PASSWORD 0x5a000000
|
||||
|
||||
@@ -296,6 +297,8 @@
|
||||
#define SOC_BCM2711 BIT(1)
|
||||
#define SOC_ALL (SOC_BCM2835 | SOC_BCM2711)
|
||||
|
||||
+#define VCMSG_ID_CORE_CLOCK 4
|
||||
+
|
||||
/*
|
||||
* Names of clocks used within the driver that need to be replaced
|
||||
* with an external parent's name. This array is in the order that
|
||||
@@ -314,6 +317,7 @@ static const char *const cprman_parent_n
|
||||
struct bcm2835_cprman {
|
||||
struct device *dev;
|
||||
void __iomem *regs;
|
||||
+ struct rpi_firmware *fw;
|
||||
spinlock_t regs_lock; /* spinlock for all clocks */
|
||||
unsigned int soc;
|
||||
|
||||
@@ -1039,6 +1043,30 @@ static unsigned long bcm2835_clock_get_r
|
||||
return rate;
|
||||
}
|
||||
|
||||
+static unsigned long bcm2835_clock_get_rate_vpu(struct clk_hw *hw,
|
||||
+ unsigned long parent_rate)
|
||||
+{
|
||||
+ struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
|
||||
+ struct bcm2835_cprman *cprman = clock->cprman;
|
||||
+
|
||||
+ if (cprman->fw) {
|
||||
+ struct {
|
||||
+ u32 id;
|
||||
+ u32 val;
|
||||
+ } packet;
|
||||
+
|
||||
+ packet.id = VCMSG_ID_CORE_CLOCK;
|
||||
+ packet.val = 0;
|
||||
+
|
||||
+ if (!rpi_firmware_property(cprman->fw,
|
||||
+ RPI_FIRMWARE_GET_MAX_CLOCK_RATE,
|
||||
+ &packet, sizeof(packet)))
|
||||
+ return packet.val;
|
||||
+ }
|
||||
+
|
||||
+ return bcm2835_clock_get_rate(hw, parent_rate);
|
||||
+}
|
||||
+
|
||||
static void bcm2835_clock_wait_busy(struct bcm2835_clock *clock)
|
||||
{
|
||||
struct bcm2835_cprman *cprman = clock->cprman;
|
||||
@@ -1327,7 +1355,7 @@ static int bcm2835_vpu_clock_is_on(struc
|
||||
*/
|
||||
static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
|
||||
.is_prepared = bcm2835_vpu_clock_is_on,
|
||||
- .recalc_rate = bcm2835_clock_get_rate,
|
||||
+ .recalc_rate = bcm2835_clock_get_rate_vpu,
|
||||
.set_rate = bcm2835_clock_set_rate,
|
||||
.determine_rate = bcm2835_clock_determine_rate,
|
||||
.set_parent = bcm2835_clock_set_parent,
|
||||
@@ -2303,6 +2331,7 @@ static int bcm2835_clk_probe(struct plat
|
||||
const struct bcm2835_clk_desc *desc;
|
||||
const size_t asize = ARRAY_SIZE(clk_desc_array);
|
||||
const struct cprman_plat_data *pdata;
|
||||
+ struct device_node *fw_node;
|
||||
size_t i;
|
||||
u32 clk_id;
|
||||
int ret;
|
||||
@@ -2323,6 +2352,14 @@ static int bcm2835_clk_probe(struct plat
|
||||
if (IS_ERR(cprman->regs))
|
||||
return PTR_ERR(cprman->regs);
|
||||
|
||||
+ fw_node = of_parse_phandle(dev->of_node, "firmware", 0);
|
||||
+ if (fw_node) {
|
||||
+ struct rpi_firmware *fw = rpi_firmware_get(NULL);
|
||||
+ if (!fw)
|
||||
+ return -EPROBE_DEFER;
|
||||
+ cprman->fw = fw;
|
||||
+ }
|
||||
+
|
||||
memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
|
||||
for (i = 0;
|
||||
!of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
|
@ -0,0 +1,24 @@
|
||||
From f6ba78e08ca1e76ad4a8ac1007dd511d9ae31857 Mon Sep 17 00:00:00 2001
|
||||
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
Date: Thu, 24 Jan 2019 15:09:28 +0000
|
||||
Subject: [PATCH 0047/1085] clk: clk-bcm2835: Use %zd when printing size_t
|
||||
|
||||
The debug text for how many clocks have been registered
|
||||
uses "%d" with a size_t. Correct it to "%zd".
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -2406,7 +2406,7 @@ static int bcm2835_clk_probe(struct plat
|
||||
return ret;
|
||||
|
||||
/* note that we have registered all the clocks */
|
||||
- dev_dbg(dev, "registered %d clocks\n", asize);
|
||||
+ dev_dbg(dev, "registered %zd clocks\n", asize);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
From 1f4814d8f97794fce825b1dfb98c7e3d2e6a58b1 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Wed, 23 Jan 2019 16:11:50 +0000
|
||||
Subject: [PATCH 0048/1085] clk-bcm2835: Don't wait for pllh lock
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 18 ++++++++++--------
|
||||
1 file changed, 10 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -647,15 +647,17 @@ static int bcm2835_pll_on(struct clk_hw
|
||||
spin_unlock(&cprman->regs_lock);
|
||||
|
||||
/* Wait for the PLL to lock. */
|
||||
- timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
|
||||
- while (!(cprman_read(cprman, CM_LOCK) & data->lock_mask)) {
|
||||
- if (ktime_after(ktime_get(), timeout)) {
|
||||
- dev_err(cprman->dev, "%s: couldn't lock PLL\n",
|
||||
- clk_hw_get_name(hw));
|
||||
- return -ETIMEDOUT;
|
||||
- }
|
||||
+ if (strcmp(data->name, "pllh")) {
|
||||
+ timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS);
|
||||
+ while (!(cprman_read(cprman, CM_LOCK) & data->lock_mask)) {
|
||||
+ if (ktime_after(ktime_get(), timeout)) {
|
||||
+ dev_err(cprman->dev, "%s: couldn't lock PLL\n",
|
||||
+ clk_hw_get_name(hw));
|
||||
+ return -ETIMEDOUT;
|
||||
+ }
|
||||
|
||||
- cpu_relax();
|
||||
+ cpu_relax();
|
||||
+ }
|
||||
}
|
||||
|
||||
cprman_write(cprman, data->a2w_ctrl_reg,
|
@ -0,0 +1,53 @@
|
||||
From 7b05ff3ae2ddc2ef0e28d721ed3c521ab7b5140a Mon Sep 17 00:00:00 2001
|
||||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Thu, 2 May 2019 15:11:05 -0700
|
||||
Subject: [PATCH 0049/1085] clk: bcm2835: Add support for setting leaf clock
|
||||
rates while running.
|
||||
|
||||
As long as you wait for !BUSY, you can do glitch-free updates of clock
|
||||
rate while the clock is running.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 22 +++++++++++++---------
|
||||
1 file changed, 13 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -1138,15 +1138,19 @@ static int bcm2835_clock_set_rate(struct
|
||||
|
||||
spin_lock(&cprman->regs_lock);
|
||||
|
||||
- /*
|
||||
- * Setting up frac support
|
||||
- *
|
||||
- * In principle it is recommended to stop/start the clock first,
|
||||
- * but as we set CLK_SET_RATE_GATE during registration of the
|
||||
- * clock this requirement should be take care of by the
|
||||
- * clk-framework.
|
||||
+ ctl = cprman_read(cprman, data->ctl_reg);
|
||||
+
|
||||
+ /* If the clock is running, we have to pause clock generation while
|
||||
+ * updating the control and div regs. This is glitchless (no clock
|
||||
+ * signals generated faster than the rate) but each reg access is two
|
||||
+ * OSC cycles so the clock will slow down for a moment.
|
||||
*/
|
||||
- ctl = cprman_read(cprman, data->ctl_reg) & ~CM_FRAC;
|
||||
+ if (ctl & CM_ENABLE) {
|
||||
+ cprman_write(cprman, data->ctl_reg, ctl & ~CM_ENABLE);
|
||||
+ bcm2835_clock_wait_busy(clock);
|
||||
+ }
|
||||
+
|
||||
+ ctl &= ~CM_FRAC;
|
||||
ctl |= (div & CM_DIV_FRAC_MASK) ? CM_FRAC : 0;
|
||||
cprman_write(cprman, data->ctl_reg, ctl);
|
||||
|
||||
@@ -1522,7 +1526,7 @@ static struct clk_hw *bcm2835_register_c
|
||||
init.ops = &bcm2835_vpu_clock_clk_ops;
|
||||
} else {
|
||||
init.ops = &bcm2835_clock_clk_ops;
|
||||
- init.flags |= CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE;
|
||||
+ init.flags |= CLK_SET_PARENT_GATE;
|
||||
|
||||
/* If the clock wasn't actually enabled at boot, it's not
|
||||
* critical.
|
@ -0,0 +1,71 @@
|
||||
From 13a0d9f6df4ed584a6b927b92373713392d09b81 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Anholt <eric@anholt.net>
|
||||
Date: Thu, 2 May 2019 15:24:04 -0700
|
||||
Subject: [PATCH 0050/1085] clk: bcm2835: Allow reparenting leaf clocks while
|
||||
they're running.
|
||||
|
||||
This falls under the same "we can reprogram glitch-free as long as we
|
||||
pause generation" rule as updating the div/frac fields. This can be
|
||||
used for runtime reclocking of V3D to manage power leakage.
|
||||
|
||||
Signed-off-by: Eric Anholt <eric@anholt.net>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 19 ++++++++++++++++---
|
||||
1 file changed, 16 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -1127,8 +1127,10 @@ static int bcm2835_clock_on(struct clk_h
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int bcm2835_clock_set_rate(struct clk_hw *hw,
|
||||
- unsigned long rate, unsigned long parent_rate)
|
||||
+static int bcm2835_clock_set_rate_and_parent(struct clk_hw *hw,
|
||||
+ unsigned long rate,
|
||||
+ unsigned long parent_rate,
|
||||
+ u8 parent)
|
||||
{
|
||||
struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
|
||||
struct bcm2835_cprman *cprman = clock->cprman;
|
||||
@@ -1150,6 +1152,11 @@ static int bcm2835_clock_set_rate(struct
|
||||
bcm2835_clock_wait_busy(clock);
|
||||
}
|
||||
|
||||
+ if (parent != 0xff) {
|
||||
+ ctl &= ~(CM_SRC_MASK << CM_SRC_SHIFT);
|
||||
+ ctl |= parent << CM_SRC_SHIFT;
|
||||
+ }
|
||||
+
|
||||
ctl &= ~CM_FRAC;
|
||||
ctl |= (div & CM_DIV_FRAC_MASK) ? CM_FRAC : 0;
|
||||
cprman_write(cprman, data->ctl_reg, ctl);
|
||||
@@ -1161,6 +1168,12 @@ static int bcm2835_clock_set_rate(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int bcm2835_clock_set_rate(struct clk_hw *hw,
|
||||
+ unsigned long rate, unsigned long parent_rate)
|
||||
+{
|
||||
+ return bcm2835_clock_set_rate_and_parent(hw, rate, parent_rate, 0xff);
|
||||
+}
|
||||
+
|
||||
static bool
|
||||
bcm2835_clk_is_pllc(struct clk_hw *hw)
|
||||
{
|
||||
@@ -1344,6 +1357,7 @@ static const struct clk_ops bcm2835_cloc
|
||||
.unprepare = bcm2835_clock_off,
|
||||
.recalc_rate = bcm2835_clock_get_rate,
|
||||
.set_rate = bcm2835_clock_set_rate,
|
||||
+ .set_rate_and_parent = bcm2835_clock_set_rate_and_parent,
|
||||
.determine_rate = bcm2835_clock_determine_rate,
|
||||
.set_parent = bcm2835_clock_set_parent,
|
||||
.get_parent = bcm2835_clock_get_parent,
|
||||
@@ -1526,7 +1540,6 @@ static struct clk_hw *bcm2835_register_c
|
||||
init.ops = &bcm2835_vpu_clock_clk_ops;
|
||||
} else {
|
||||
init.ops = &bcm2835_clock_clk_ops;
|
||||
- init.flags |= CLK_SET_PARENT_GATE;
|
||||
|
||||
/* If the clock wasn't actually enabled at boot, it's not
|
||||
* critical.
|
@ -0,0 +1,29 @@
|
||||
From a1c557d74b66d5f37b68b07ee966d627b9dabe94 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Tue, 6 Aug 2019 15:23:14 +0100
|
||||
Subject: [PATCH 0051/1085] clk-bcm2835: Avoid null pointer exception
|
||||
|
||||
clk_desc_array[BCM2835_PLLB] doesn't exist so we dereference null when iterating
|
||||
|
||||
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -2334,9 +2334,11 @@ static bool bcm2835_clk_is_claimed(const
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
|
||||
- const char *clk_name = *(const char **)(clk_desc_array[i].data);
|
||||
- if (!strcmp(name, clk_name))
|
||||
- return bcm2835_clk_claimed[i];
|
||||
+ if (clk_desc_array[i].data) {
|
||||
+ const char *clk_name = *(const char **)(clk_desc_array[i].data);
|
||||
+ if (!strcmp(name, clk_name))
|
||||
+ return bcm2835_clk_claimed[i];
|
||||
+ }
|
||||
}
|
||||
|
||||
return false;
|
@ -0,0 +1,58 @@
|
||||
From 4178828dd4a72d6cc4ec0572fef4efa23e82869e Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Tue, 3 Sep 2019 20:28:00 +0100
|
||||
Subject: [PATCH 0052/1085] clk-bcm2835: Disable v3d clock
|
||||
|
||||
This is controlled by firmware, see clk-raspberrypi.c
|
||||
|
||||
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 30 ++++++++++++------------------
|
||||
1 file changed, 12 insertions(+), 18 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -1764,16 +1764,12 @@ static const struct bcm2835_clk_desc clk
|
||||
.hold_mask = CM_PLLA_HOLDCORE,
|
||||
.fixed_divider = 1,
|
||||
.flags = CLK_SET_RATE_PARENT),
|
||||
- [BCM2835_PLLA_PER] = REGISTER_PLL_DIV(
|
||||
- SOC_ALL,
|
||||
- .name = "plla_per",
|
||||
- .source_pll = "plla",
|
||||
- .cm_reg = CM_PLLA,
|
||||
- .a2w_reg = A2W_PLLA_PER,
|
||||
- .load_mask = CM_PLLA_LOADPER,
|
||||
- .hold_mask = CM_PLLA_HOLDPER,
|
||||
- .fixed_divider = 1,
|
||||
- .flags = CLK_SET_RATE_PARENT),
|
||||
+
|
||||
+ /*
|
||||
+ * PLLA_PER is used for gpu clocks. Controlled by firmware, see
|
||||
+ * clk-raspberrypi.c.
|
||||
+ */
|
||||
+
|
||||
[BCM2835_PLLA_DSI0] = REGISTER_PLL_DIV(
|
||||
SOC_ALL,
|
||||
.name = "plla_dsi0",
|
||||
@@ -2074,14 +2070,12 @@ static const struct bcm2835_clk_desc clk
|
||||
.int_bits = 6,
|
||||
.frac_bits = 0,
|
||||
.tcnt_mux = 3),
|
||||
- [BCM2835_CLOCK_V3D] = REGISTER_VPU_CLK(
|
||||
- SOC_ALL,
|
||||
- .name = "v3d",
|
||||
- .ctl_reg = CM_V3DCTL,
|
||||
- .div_reg = CM_V3DDIV,
|
||||
- .int_bits = 4,
|
||||
- .frac_bits = 8,
|
||||
- .tcnt_mux = 4),
|
||||
+
|
||||
+ /*
|
||||
+ * CLOCK_V3D is used for v3d clock. Controlled by firmware, see
|
||||
+ * clk-raspberrypi.c.
|
||||
+ */
|
||||
+
|
||||
/*
|
||||
* VPU clock. This doesn't have an enable bit, since it drives
|
||||
* the bus for everything else, and is special so it doesn't need
|
@ -0,0 +1,24 @@
|
||||
From f3af6755e55e6681cf25052bdc9cb81cfd412b18 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.com>
|
||||
Date: Thu, 8 Jul 2021 09:37:10 +0100
|
||||
Subject: [PATCH 0053/1085] clk: bcm2835: Pass DT node to rpi_firmware_get
|
||||
|
||||
The fw_node pointer has already been retrieved, and using it allows
|
||||
us to remove a downstream patch to the firmware driver.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -2369,7 +2369,7 @@ static int bcm2835_clk_probe(struct plat
|
||||
|
||||
fw_node = of_parse_phandle(dev->of_node, "firmware", 0);
|
||||
if (fw_node) {
|
||||
- struct rpi_firmware *fw = rpi_firmware_get(NULL);
|
||||
+ struct rpi_firmware *fw = rpi_firmware_get(fw_node);
|
||||
if (!fw)
|
||||
return -EPROBE_DEFER;
|
||||
cprman->fw = fw;
|
@ -0,0 +1,34 @@
|
||||
From 4424723464afdfcab18f76ea9010e908bf4dbda8 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Tue, 19 Oct 2021 14:14:55 +0100
|
||||
Subject: [PATCH 0054/1085] clk-bcm2835: Remove VEC clock support
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
drivers/clk/bcm/clk-bcm2835.c | 15 ---------------
|
||||
1 file changed, 15 deletions(-)
|
||||
|
||||
--- a/drivers/clk/bcm/clk-bcm2835.c
|
||||
+++ b/drivers/clk/bcm/clk-bcm2835.c
|
||||
@@ -2238,21 +2238,6 @@ static const struct bcm2835_clk_desc clk
|
||||
.tcnt_mux = 28,
|
||||
.round_up = true),
|
||||
|
||||
- /* TV encoder clock. Only operating frequency is 108Mhz. */
|
||||
- [BCM2835_CLOCK_VEC] = REGISTER_PER_CLK(
|
||||
- SOC_ALL,
|
||||
- .name = "vec",
|
||||
- .ctl_reg = CM_VECCTL,
|
||||
- .div_reg = CM_VECDIV,
|
||||
- .int_bits = 4,
|
||||
- .frac_bits = 0,
|
||||
- /*
|
||||
- * Allow rate change propagation only on PLLH_AUX which is
|
||||
- * assigned index 7 in the parent array.
|
||||
- */
|
||||
- .set_rate_parent = BIT(7),
|
||||
- .tcnt_mux = 29),
|
||||
-
|
||||
/* dsi clocks */
|
||||
[BCM2835_CLOCK_DSI0E] = REGISTER_PER_CLK(
|
||||
SOC_ALL,
|
@ -0,0 +1,99 @@
|
||||
From bd7e4336b9f12cf217deeb5778bcd4cf75a5e75e Mon Sep 17 00:00:00 2001
|
||||
From: Dan Pasanen <dan.pasanen@gmail.com>
|
||||
Date: Thu, 21 Sep 2017 09:55:42 -0500
|
||||
Subject: [PATCH 0055/1085] arm: partially revert
|
||||
702b94bff3c50542a6e4ab9a4f4cef093262fe65
|
||||
|
||||
* Re-expose some dmi APIs for use in VCSM
|
||||
---
|
||||
arch/arm/include/asm/cacheflush.h | 21 +++++++++++++++++++++
|
||||
arch/arm/include/asm/glue-cache.h | 2 ++
|
||||
arch/arm/mm/proc-macros.S | 2 ++
|
||||
arch/arm/mm/proc-syms.c | 3 +++
|
||||
4 files changed, 28 insertions(+)
|
||||
|
||||
--- a/arch/arm/include/asm/cacheflush.h
|
||||
+++ b/arch/arm/include/asm/cacheflush.h
|
||||
@@ -91,6 +91,21 @@
|
||||
* DMA Cache Coherency
|
||||
* ===================
|
||||
*
|
||||
+ * dma_inv_range(start, end)
|
||||
+ *
|
||||
+ * Invalidate (discard) the specified virtual address range.
|
||||
+ * May not write back any entries. If 'start' or 'end'
|
||||
+ * are not cache line aligned, those lines must be written
|
||||
+ * back.
|
||||
+ * - start - virtual start address
|
||||
+ * - end - virtual end address
|
||||
+ *
|
||||
+ * dma_clean_range(start, end)
|
||||
+ *
|
||||
+ * Clean (write back) the specified virtual address range.
|
||||
+ * - start - virtual start address
|
||||
+ * - end - virtual end address
|
||||
+ *
|
||||
* dma_flush_range(start, end)
|
||||
*
|
||||
* Clean and invalidate the specified virtual address range.
|
||||
@@ -112,6 +127,8 @@ struct cpu_cache_fns {
|
||||
void (*dma_map_area)(const void *, size_t, int);
|
||||
void (*dma_unmap_area)(const void *, size_t, int);
|
||||
|
||||
+ void (*dma_inv_range)(const void *, const void *);
|
||||
+ void (*dma_clean_range)(const void *, const void *);
|
||||
void (*dma_flush_range)(const void *, const void *);
|
||||
} __no_randomize_layout;
|
||||
|
||||
@@ -137,6 +154,8 @@ extern struct cpu_cache_fns cpu_cache;
|
||||
* is visible to DMA, or data written by DMA to system memory is
|
||||
* visible to the CPU.
|
||||
*/
|
||||
+#define dmac_inv_range cpu_cache.dma_inv_range
|
||||
+#define dmac_clean_range cpu_cache.dma_clean_range
|
||||
#define dmac_flush_range cpu_cache.dma_flush_range
|
||||
|
||||
#else
|
||||
@@ -156,6 +175,8 @@ extern void __cpuc_flush_dcache_area(voi
|
||||
* is visible to DMA, or data written by DMA to system memory is
|
||||
* visible to the CPU.
|
||||
*/
|
||||
+extern void dmac_inv_range(const void *, const void *);
|
||||
+extern void dmac_clean_range(const void *, const void *);
|
||||
extern void dmac_flush_range(const void *, const void *);
|
||||
|
||||
#endif
|
||||
--- a/arch/arm/include/asm/glue-cache.h
|
||||
+++ b/arch/arm/include/asm/glue-cache.h
|
||||
@@ -155,6 +155,8 @@ static inline void nop_dma_unmap_area(co
|
||||
#define __cpuc_coherent_user_range __glue(_CACHE,_coherent_user_range)
|
||||
#define __cpuc_flush_dcache_area __glue(_CACHE,_flush_kern_dcache_area)
|
||||
|
||||
+#define dmac_inv_range __glue(_CACHE,_dma_inv_range)
|
||||
+#define dmac_clean_range __glue(_CACHE,_dma_clean_range)
|
||||
#define dmac_flush_range __glue(_CACHE,_dma_flush_range)
|
||||
#endif
|
||||
|
||||
--- a/arch/arm/mm/proc-macros.S
|
||||
+++ b/arch/arm/mm/proc-macros.S
|
||||
@@ -334,6 +334,8 @@ ENTRY(\name\()_cache_fns)
|
||||
.long \name\()_flush_kern_dcache_area
|
||||
.long \name\()_dma_map_area
|
||||
.long \name\()_dma_unmap_area
|
||||
+ .long \name\()_dma_inv_range
|
||||
+ .long \name\()_dma_clean_range
|
||||
.long \name\()_dma_flush_range
|
||||
.size \name\()_cache_fns, . - \name\()_cache_fns
|
||||
.endm
|
||||
--- a/arch/arm/mm/proc-syms.c
|
||||
+++ b/arch/arm/mm/proc-syms.c
|
||||
@@ -27,6 +27,9 @@ EXPORT_SYMBOL(__cpuc_flush_user_all);
|
||||
EXPORT_SYMBOL(__cpuc_flush_user_range);
|
||||
EXPORT_SYMBOL(__cpuc_coherent_kern_range);
|
||||
EXPORT_SYMBOL(__cpuc_flush_dcache_area);
|
||||
+EXPORT_SYMBOL(dmac_inv_range);
|
||||
+EXPORT_SYMBOL(dmac_clean_range);
|
||||
+EXPORT_SYMBOL(dmac_flush_range);
|
||||
#else
|
||||
EXPORT_SYMBOL(cpu_cache);
|
||||
#endif
|
@ -0,0 +1,53 @@
|
||||
From edd661e1298992af02c87d389c1fa2cec366e29a Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Fri, 25 Aug 2017 19:18:13 +0100
|
||||
Subject: [PATCH 0056/1085] cache: export clean and invalidate
|
||||
|
||||
hack: cache: Fix linker error
|
||||
---
|
||||
arch/arm/mm/cache-v6.S | 4 ++--
|
||||
arch/arm/mm/cache-v7.S | 6 ++++--
|
||||
2 files changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/arch/arm/mm/cache-v6.S
|
||||
+++ b/arch/arm/mm/cache-v6.S
|
||||
@@ -200,7 +200,7 @@ ENTRY(v6_flush_kern_dcache_area)
|
||||
* - start - virtual start address of region
|
||||
* - end - virtual end address of region
|
||||
*/
|
||||
-v6_dma_inv_range:
|
||||
+ENTRY(v6_dma_inv_range)
|
||||
#ifdef CONFIG_DMA_CACHE_RWFO
|
||||
ldrb r2, [r0] @ read for ownership
|
||||
strb r2, [r0] @ write for ownership
|
||||
@@ -245,7 +245,7 @@ v6_dma_inv_range:
|
||||
* - start - virtual start address of region
|
||||
* - end - virtual end address of region
|
||||
*/
|
||||
-v6_dma_clean_range:
|
||||
+ENTRY(v6_dma_clean_range)
|
||||
bic r0, r0, #D_CACHE_LINE_SIZE - 1
|
||||
1:
|
||||
#ifdef CONFIG_DMA_CACHE_RWFO
|
||||
--- a/arch/arm/mm/cache-v7.S
|
||||
+++ b/arch/arm/mm/cache-v7.S
|
||||
@@ -361,7 +361,8 @@ ENDPROC(v7_flush_kern_dcache_area)
|
||||
* - start - virtual start address of region
|
||||
* - end - virtual end address of region
|
||||
*/
|
||||
-v7_dma_inv_range:
|
||||
+ENTRY(b15_dma_inv_range)
|
||||
+ENTRY(v7_dma_inv_range)
|
||||
dcache_line_size r2, r3
|
||||
sub r3, r2, #1
|
||||
tst r0, r3
|
||||
@@ -391,7 +392,8 @@ ENDPROC(v7_dma_inv_range)
|
||||
* - start - virtual start address of region
|
||||
* - end - virtual end address of region
|
||||
*/
|
||||
-v7_dma_clean_range:
|
||||
+ENTRY(b15_dma_clean_range)
|
||||
+ENTRY(v7_dma_clean_range)
|
||||
dcache_line_size r2, r3
|
||||
sub r3, r2, #1
|
||||
bic r0, r0, r3
|
@ -0,0 +1,32 @@
|
||||
From 32e719132bbbbe75a380a23423d74fef8c7b83b1 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.com>
|
||||
Date: Mon, 20 Apr 2020 13:41:10 +0100
|
||||
Subject: [PATCH 0057/1085] Revert "spi: spidev: Fix CS polarity if GPIO
|
||||
descriptors are used"
|
||||
|
||||
This reverts commit 83b2a8fe43bda0c11981ad6afa5dd0104d78be28.
|
||||
---
|
||||
drivers/spi/spidev.c | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
--- a/drivers/spi/spidev.c
|
||||
+++ b/drivers/spi/spidev.c
|
||||
@@ -424,7 +424,6 @@ spidev_ioctl(struct file *filp, unsigned
|
||||
else
|
||||
retval = get_user(tmp, (u32 __user *)arg);
|
||||
if (retval == 0) {
|
||||
- struct spi_controller *ctlr = spi->controller;
|
||||
u32 save = spi->mode;
|
||||
|
||||
if (tmp & ~SPI_MODE_MASK) {
|
||||
@@ -432,10 +431,6 @@ spidev_ioctl(struct file *filp, unsigned
|
||||
break;
|
||||
}
|
||||
|
||||
- if (ctlr->use_gpio_descriptors && ctlr->cs_gpiods &&
|
||||
- ctlr->cs_gpiods[spi_get_chipselect(spi, 0)])
|
||||
- tmp |= SPI_CS_HIGH;
|
||||
-
|
||||
tmp |= spi->mode & ~SPI_MODE_MASK;
|
||||
spi->mode = tmp & SPI_MODE_USER_MASK;
|
||||
retval = spi_setup(spi);
|
@ -0,0 +1,45 @@
|
||||
From eaeca896d077e9e42866f7f7caae7b62211a0d0d Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.com>
|
||||
Date: Mon, 1 Mar 2021 09:12:44 +0000
|
||||
Subject: [PATCH 0058/1085] Revert "Bluetooth: Always request for user
|
||||
confirmation for Just Works (LE SC)"
|
||||
|
||||
This reverts commit ffee202a78c2980688bc5d2f7d56480e69a5e0c9.
|
||||
|
||||
The commit "Bluetooth: Always request for user confirmation for Just
|
||||
Works" prevents BLE devices pairing in (at least) the Raspberry Pi OS
|
||||
GUI. After reverting it, pairing works again. Although this companion
|
||||
commit ("... (LE SC)") has not been demonstrated to be problematic,
|
||||
it follows the same logic and therefore could affect some use cases.
|
||||
|
||||
If another solution to the problem is found then this reversion will
|
||||
be removed.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/4139
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
net/bluetooth/smp.c | 5 +----
|
||||
1 file changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
--- a/net/bluetooth/smp.c
|
||||
+++ b/net/bluetooth/smp.c
|
||||
@@ -2221,7 +2221,7 @@ mackey_and_ltk:
|
||||
if (err)
|
||||
return SMP_UNSPECIFIED;
|
||||
|
||||
- if (smp->method == REQ_OOB) {
|
||||
+ if (smp->method == JUST_WORKS || smp->method == REQ_OOB) {
|
||||
if (hcon->out) {
|
||||
sc_dhkey_check(smp);
|
||||
SMP_ALLOW_CMD(smp, SMP_CMD_DHKEY_CHECK);
|
||||
@@ -2236,9 +2236,6 @@ mackey_and_ltk:
|
||||
confirm_hint = 0;
|
||||
|
||||
confirm:
|
||||
- if (smp->method == JUST_WORKS)
|
||||
- confirm_hint = 1;
|
||||
-
|
||||
err = mgmt_user_confirm_request(hcon->hdev, &hcon->dst, hcon->type,
|
||||
hcon->dst_type, passkey, confirm_hint);
|
||||
if (err)
|
@ -0,0 +1,43 @@
|
||||
From d82e1c63ce54621447756dd2430e99bf1124662e Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.com>
|
||||
Date: Mon, 1 Mar 2021 09:14:35 +0000
|
||||
Subject: [PATCH 0059/1085] Revert "Bluetooth: Always request for user
|
||||
confirmation for Just Works"
|
||||
|
||||
This reverts commit 92516cd97fd4d8ad5b1421a0d51771044f453a5f.
|
||||
|
||||
Thi commit "Bluetooth: Always request for user confirmation for Just
|
||||
Works" prevents BLE devices pairing in (at least) the Raspberry Pi OS
|
||||
GUI. After reverting it, pairing works again.
|
||||
|
||||
If another solution to the problem is found then this reversion will
|
||||
be removed.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/4139
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
net/bluetooth/smp.c | 11 ++---------
|
||||
1 file changed, 2 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/net/bluetooth/smp.c
|
||||
+++ b/net/bluetooth/smp.c
|
||||
@@ -885,16 +885,9 @@ static int tk_request(struct l2cap_conn
|
||||
hcon->io_capability == HCI_IO_NO_INPUT_OUTPUT)
|
||||
smp->method = JUST_WORKS;
|
||||
|
||||
- /* If Just Works, Continue with Zero TK and ask user-space for
|
||||
- * confirmation */
|
||||
+ /* If Just Works, Continue with Zero TK */
|
||||
if (smp->method == JUST_WORKS) {
|
||||
- ret = mgmt_user_confirm_request(hcon->hdev, &hcon->dst,
|
||||
- hcon->type,
|
||||
- hcon->dst_type,
|
||||
- passkey, 1);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
- set_bit(SMP_FLAG_WAIT_USER, &smp->flags);
|
||||
+ set_bit(SMP_FLAG_TK_VALID, &smp->flags);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
From 7e5ce18f06392dddd65863a221704d2e4e94aaba Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.com>
|
||||
Date: Mon, 7 Mar 2022 16:18:55 +0000
|
||||
Subject: [PATCH 0060/1085] Revert "net: bcmgenet: Request APD, DLL disable and
|
||||
IDDQ-SR"
|
||||
|
||||
This reverts commit c3a4c69360ab43560f212eed326c9d8bde35b14c, which
|
||||
broke rebooting when network booting.
|
||||
|
||||
See: https://github.com/raspberrypi/rpi-eeprom/issues/417
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
|
||||
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
|
||||
@@ -303,9 +303,7 @@ int bcmgenet_mii_probe(struct net_device
|
||||
struct device_node *dn = kdev->of_node;
|
||||
phy_interface_t phy_iface = priv->phy_interface;
|
||||
struct phy_device *phydev;
|
||||
- u32 phy_flags = PHY_BRCM_AUTO_PWRDWN_ENABLE |
|
||||
- PHY_BRCM_DIS_TXCRXC_NOENRGY |
|
||||
- PHY_BRCM_IDDQ_SUSPEND;
|
||||
+ u32 phy_flags = 0;
|
||||
int ret;
|
||||
|
||||
/* Communicate the integrated PHY revision */
|
@ -0,0 +1,71 @@
|
||||
From a956051a926b0a9e0bc587303ce1a2e153707e80 Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Mon, 31 Jul 2023 13:47:10 +0100
|
||||
Subject: [PATCH 0061/1085] Revert "Revert "xhci: add quirk for host
|
||||
controllers that don't update endpoint DCS""
|
||||
|
||||
This reverts commit 5bef4b3cb95a5b883dfec8b3ffc0d671323d55bb.
|
||||
|
||||
We don't agree with upstream revert so undo it.
|
||||
---
|
||||
drivers/usb/host/xhci-pci.c | 4 +++-
|
||||
drivers/usb/host/xhci-ring.c | 25 ++++++++++++++++++++++++-
|
||||
2 files changed, 27 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/usb/host/xhci-pci.c
|
||||
+++ b/drivers/usb/host/xhci-pci.c
|
||||
@@ -479,8 +479,10 @@ static void xhci_pci_quirks(struct devic
|
||||
pdev->device == 0x3432)
|
||||
xhci->quirks |= XHCI_BROKEN_STREAMS;
|
||||
|
||||
- if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
|
||||
+ if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483) {
|
||||
xhci->quirks |= XHCI_LPM_SUPPORT;
|
||||
+ xhci->quirks |= XHCI_EP_CTX_BROKEN_DCS;
|
||||
+ }
|
||||
|
||||
if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
|
||||
pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) {
|
||||
--- a/drivers/usb/host/xhci-ring.c
|
||||
+++ b/drivers/usb/host/xhci-ring.c
|
||||
@@ -633,8 +633,11 @@ static int xhci_move_dequeue_past_td(str
|
||||
struct xhci_ring *ep_ring;
|
||||
struct xhci_command *cmd;
|
||||
struct xhci_segment *new_seg;
|
||||
+ struct xhci_segment *halted_seg = NULL;
|
||||
union xhci_trb *new_deq;
|
||||
int new_cycle;
|
||||
+ union xhci_trb *halted_trb;
|
||||
+ int index = 0;
|
||||
dma_addr_t addr;
|
||||
u64 hw_dequeue;
|
||||
bool cycle_found = false;
|
||||
@@ -672,7 +675,27 @@ static int xhci_move_dequeue_past_td(str
|
||||
hw_dequeue = xhci_get_hw_deq(xhci, dev, ep_index, stream_id);
|
||||
new_seg = ep_ring->deq_seg;
|
||||
new_deq = ep_ring->dequeue;
|
||||
- new_cycle = hw_dequeue & 0x1;
|
||||
+
|
||||
+ /*
|
||||
+ * Quirk: xHC write-back of the DCS field in the hardware dequeue
|
||||
+ * pointer is wrong - use the cycle state of the TRB pointed to by
|
||||
+ * the dequeue pointer.
|
||||
+ */
|
||||
+ if (xhci->quirks & XHCI_EP_CTX_BROKEN_DCS &&
|
||||
+ !(ep->ep_state & EP_HAS_STREAMS))
|
||||
+ halted_seg = trb_in_td(xhci, td->start_seg,
|
||||
+ td->first_trb, td->last_trb,
|
||||
+ hw_dequeue & ~0xf, false);
|
||||
+ if (halted_seg) {
|
||||
+ index = ((dma_addr_t)(hw_dequeue & ~0xf) - halted_seg->dma) /
|
||||
+ sizeof(*halted_trb);
|
||||
+ halted_trb = &halted_seg->trbs[index];
|
||||
+ new_cycle = halted_trb->generic.field[3] & 0x1;
|
||||
+ xhci_dbg(xhci, "Endpoint DCS = %d TRB index = %d cycle = %d\n",
|
||||
+ (u8)(hw_dequeue & 0x1), index, new_cycle);
|
||||
+ } else {
|
||||
+ new_cycle = hw_dequeue & 0x1;
|
||||
+ }
|
||||
|
||||
/*
|
||||
* We want to find the pointer, segment and cycle state of the new trb
|
@ -0,0 +1,85 @@
|
||||
From 94a23e978235cd35f38075072b34152b2b667e6e Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Mon, 27 Nov 2017 17:14:54 +0000
|
||||
Subject: [PATCH 0065/1085] cgroup: Disable cgroup "memory" by default
|
||||
|
||||
Some Raspberry Pis have limited RAM and most users won't use the
|
||||
cgroup memory support so it is disabled by default. Enable with:
|
||||
|
||||
cgroup_enable=memory
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/1950
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
kernel/cgroup/cgroup.c | 38 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 38 insertions(+)
|
||||
|
||||
--- a/kernel/cgroup/cgroup.c
|
||||
+++ b/kernel/cgroup/cgroup.c
|
||||
@@ -6051,6 +6051,9 @@ int __init cgroup_init_early(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static u16 cgroup_enable_mask __initdata;
|
||||
+static int __init cgroup_disable(char *str);
|
||||
+
|
||||
/**
|
||||
* cgroup_init - cgroup initialization
|
||||
*
|
||||
@@ -6084,6 +6087,12 @@ int __init cgroup_init(void)
|
||||
|
||||
cgroup_unlock();
|
||||
|
||||
+ /*
|
||||
+ * Apply an implicit disable, knowing that an explicit enable will
|
||||
+ * prevent if from doing anything.
|
||||
+ */
|
||||
+ cgroup_disable("memory");
|
||||
+
|
||||
for_each_subsys(ss, ssid) {
|
||||
if (ss->early_init) {
|
||||
struct cgroup_subsys_state *css =
|
||||
@@ -6724,6 +6733,10 @@ static int __init cgroup_disable(char *s
|
||||
strcmp(token, ss->legacy_name))
|
||||
continue;
|
||||
|
||||
+ /* An explicit cgroup_enable overrides a disable */
|
||||
+ if (cgroup_enable_mask & (1 << i))
|
||||
+ continue;
|
||||
+
|
||||
static_branch_disable(cgroup_subsys_enabled_key[i]);
|
||||
pr_info("Disabling %s control group subsystem\n",
|
||||
ss->name);
|
||||
@@ -6742,6 +6755,31 @@ static int __init cgroup_disable(char *s
|
||||
}
|
||||
__setup("cgroup_disable=", cgroup_disable);
|
||||
|
||||
+static int __init cgroup_enable(char *str)
|
||||
+{
|
||||
+ struct cgroup_subsys *ss;
|
||||
+ char *token;
|
||||
+ int i;
|
||||
+
|
||||
+ while ((token = strsep(&str, ",")) != NULL) {
|
||||
+ if (!*token)
|
||||
+ continue;
|
||||
+
|
||||
+ for_each_subsys(ss, i) {
|
||||
+ if (strcmp(token, ss->name) &&
|
||||
+ strcmp(token, ss->legacy_name))
|
||||
+ continue;
|
||||
+
|
||||
+ cgroup_enable_mask |= 1 << i;
|
||||
+ static_branch_enable(cgroup_subsys_enabled_key[i]);
|
||||
+ pr_info("Enabling %s control group subsystem\n",
|
||||
+ ss->name);
|
||||
+ }
|
||||
+ }
|
||||
+ return 1;
|
||||
+}
|
||||
+__setup("cgroup_enable=", cgroup_enable);
|
||||
+
|
||||
void __init __weak enable_debug_cgroup(void) { }
|
||||
|
||||
static int __init enable_cgroup_debug(char *str)
|
@ -0,0 +1,28 @@
|
||||
From fd4dd0612e2b97840bb5ca1699ff7d779704c4a9 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Fri, 13 Mar 2015 12:43:36 +0000
|
||||
Subject: [PATCH 0066/1085] Protect __release_resource against resources
|
||||
without parents
|
||||
|
||||
Without this patch, removing a device tree overlay can crash here.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
kernel/resource.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
--- a/kernel/resource.c
|
||||
+++ b/kernel/resource.c
|
||||
@@ -200,6 +200,12 @@ static int __release_resource(struct res
|
||||
{
|
||||
struct resource *tmp, **p, *chd;
|
||||
|
||||
+ if (!old->parent) {
|
||||
+ WARN(old->sibling, "sibling but no parent");
|
||||
+ if (old->sibling)
|
||||
+ return -EINVAL;
|
||||
+ return 0;
|
||||
+ }
|
||||
p = &old->parent->child;
|
||||
for (;;) {
|
||||
tmp = *p;
|
@ -0,0 +1,24 @@
|
||||
From 72a7a6b93d9689b911a0117d7e1c627c68444f1c Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Thu, 9 Feb 2017 14:33:30 +0000
|
||||
Subject: [PATCH 0067/1085] irq-bcm2836: Avoid "Invalid trigger warning"
|
||||
|
||||
Initialise the level for each IRQ to avoid a warning from the
|
||||
arm arch timer code.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/irqchip/irq-bcm2836.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/irqchip/irq-bcm2836.c
|
||||
+++ b/drivers/irqchip/irq-bcm2836.c
|
||||
@@ -128,7 +128,7 @@ static int bcm2836_map(struct irq_domain
|
||||
irq_set_percpu_devid(irq);
|
||||
irq_domain_set_info(d, irq, hw, chip, d->host_data,
|
||||
handle_percpu_devid_irq, NULL, NULL);
|
||||
- irq_set_status_flags(irq, IRQ_NOAUTOEN);
|
||||
+ irq_set_status_flags(irq, IRQ_NOAUTOEN | IRQ_TYPE_LEVEL_LOW);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
From d323861454899d375d9c6473374f7ce55126577a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Fri, 12 Jun 2015 19:01:05 +0200
|
||||
Subject: [PATCH 0068/1085] irqchip: bcm2835: Add FIQ support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add a duplicate irq range with an offset on the hwirq's so the
|
||||
driver can detect that enable_fiq() is used.
|
||||
Tested with downstream dwc_otg USB controller driver.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
Reviewed-by: Eric Anholt <eric@anholt.net>
|
||||
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
|
||||
---
|
||||
arch/arm/mach-bcm/Kconfig | 1 +
|
||||
drivers/irqchip/irq-bcm2835.c | 51 +++++++++++++++++++++++++++++++----
|
||||
2 files changed, 47 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/arch/arm/mach-bcm/Kconfig
|
||||
+++ b/arch/arm/mach-bcm/Kconfig
|
||||
@@ -159,6 +159,7 @@ config ARCH_BCM2835
|
||||
select ARM_TIMER_SP804
|
||||
select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7
|
||||
select BCM2835_TIMER
|
||||
+ select FIQ
|
||||
select PINCTRL
|
||||
select PINCTRL_BCM2835
|
||||
select MFD_CORE
|
||||
--- a/drivers/irqchip/irq-bcm2835.c
|
||||
+++ b/drivers/irqchip/irq-bcm2835.c
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <asm/exception.h>
|
||||
|
||||
/* Put the bank and irq (32 bits) into the hwirq */
|
||||
-#define MAKE_HWIRQ(b, n) ((b << 5) | (n))
|
||||
+#define MAKE_HWIRQ(b, n) (((b) << 5) | (n))
|
||||
#define HWIRQ_BANK(i) (i >> 5)
|
||||
#define HWIRQ_BIT(i) BIT(i & 0x1f)
|
||||
|
||||
@@ -62,9 +62,13 @@
|
||||
|
||||
#define REG_FIQ_CONTROL 0x0c
|
||||
#define FIQ_CONTROL_ENABLE BIT(7)
|
||||
+#define REG_FIQ_ENABLE FIQ_CONTROL_ENABLE
|
||||
+#define REG_FIQ_DISABLE 0
|
||||
|
||||
#define NR_BANKS 3
|
||||
#define IRQS_PER_BANK 32
|
||||
+#define NUMBER_IRQS MAKE_HWIRQ(NR_BANKS, 0)
|
||||
+#define FIQ_START (NR_IRQS_BANK0 + MAKE_HWIRQ(NR_BANKS - 1, 0))
|
||||
|
||||
static const int reg_pending[] __initconst = { 0x00, 0x04, 0x08 };
|
||||
static const int reg_enable[] __initconst = { 0x18, 0x10, 0x14 };
|
||||
@@ -89,14 +93,38 @@ static void __exception_irq_entry bcm283
|
||||
struct pt_regs *regs);
|
||||
static void bcm2836_chained_handle_irq(struct irq_desc *desc);
|
||||
|
||||
+static inline unsigned int hwirq_to_fiq(unsigned long hwirq)
|
||||
+{
|
||||
+ hwirq -= NUMBER_IRQS;
|
||||
+ /*
|
||||
+ * The hwirq numbering used in this driver is:
|
||||
+ * BASE (0-7) GPU1 (32-63) GPU2 (64-95).
|
||||
+ * This differ from the one used in the FIQ register:
|
||||
+ * GPU1 (0-31) GPU2 (32-63) BASE (64-71)
|
||||
+ */
|
||||
+ if (hwirq >= 32)
|
||||
+ return hwirq - 32;
|
||||
+
|
||||
+ return hwirq + 64;
|
||||
+}
|
||||
+
|
||||
static void armctrl_mask_irq(struct irq_data *d)
|
||||
{
|
||||
- writel_relaxed(HWIRQ_BIT(d->hwirq), intc.disable[HWIRQ_BANK(d->hwirq)]);
|
||||
+ if (d->hwirq >= NUMBER_IRQS)
|
||||
+ writel_relaxed(REG_FIQ_DISABLE, intc.base + REG_FIQ_CONTROL);
|
||||
+ else
|
||||
+ writel_relaxed(HWIRQ_BIT(d->hwirq),
|
||||
+ intc.disable[HWIRQ_BANK(d->hwirq)]);
|
||||
}
|
||||
|
||||
static void armctrl_unmask_irq(struct irq_data *d)
|
||||
{
|
||||
- writel_relaxed(HWIRQ_BIT(d->hwirq), intc.enable[HWIRQ_BANK(d->hwirq)]);
|
||||
+ if (d->hwirq >= NUMBER_IRQS)
|
||||
+ writel_relaxed(REG_FIQ_ENABLE | hwirq_to_fiq(d->hwirq),
|
||||
+ intc.base + REG_FIQ_CONTROL);
|
||||
+ else
|
||||
+ writel_relaxed(HWIRQ_BIT(d->hwirq),
|
||||
+ intc.enable[HWIRQ_BANK(d->hwirq)]);
|
||||
}
|
||||
|
||||
static struct irq_chip armctrl_chip = {
|
||||
@@ -142,8 +170,9 @@ static int __init armctrl_of_init(struct
|
||||
if (!base)
|
||||
panic("%pOF: unable to map IC registers\n", node);
|
||||
|
||||
- intc.domain = irq_domain_add_linear(node, MAKE_HWIRQ(NR_BANKS, 0),
|
||||
- &armctrl_ops, NULL);
|
||||
+ intc.base = base;
|
||||
+ intc.domain = irq_domain_add_linear(node, NUMBER_IRQS * 2,
|
||||
+ &armctrl_ops, NULL);
|
||||
if (!intc.domain)
|
||||
panic("%pOF: unable to create IRQ domain\n", node);
|
||||
|
||||
@@ -186,6 +215,18 @@ static int __init armctrl_of_init(struct
|
||||
set_handle_irq(bcm2835_handle_irq);
|
||||
}
|
||||
|
||||
+ /* Make a duplicate irq range which is used to enable FIQ */
|
||||
+ for (b = 0; b < NR_BANKS; b++) {
|
||||
+ for (i = 0; i < bank_irqs[b]; i++) {
|
||||
+ irq = irq_create_mapping(intc.domain,
|
||||
+ MAKE_HWIRQ(b, i) + NUMBER_IRQS);
|
||||
+ BUG_ON(irq <= 0);
|
||||
+ irq_set_chip(irq, &armctrl_chip);
|
||||
+ set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
|
||||
+ }
|
||||
+ }
|
||||
+ init_FIQ(FIQ_START);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,99 @@
|
||||
From 73fde97789bc341d361e801b254afea33fe45f06 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Fri, 23 Oct 2015 16:26:55 +0200
|
||||
Subject: [PATCH 0069/1085] irqchip: irq-bcm2835: Add 2836 FIQ support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
---
|
||||
drivers/irqchip/irq-bcm2835.c | 43 +++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 41 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/irqchip/irq-bcm2835.c
|
||||
+++ b/drivers/irqchip/irq-bcm2835.c
|
||||
@@ -41,8 +41,11 @@
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/irqchip.h>
|
||||
#include <linux/irqdomain.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
+#include <linux/regmap.h>
|
||||
|
||||
#include <asm/exception.h>
|
||||
+#include <asm/mach/irq.h>
|
||||
|
||||
/* Put the bank and irq (32 bits) into the hwirq */
|
||||
#define MAKE_HWIRQ(b, n) (((b) << 5) | (n))
|
||||
@@ -60,6 +63,9 @@
|
||||
#define BANK0_VALID_MASK (BANK0_HWIRQ_MASK | BANK1_HWIRQ | BANK2_HWIRQ \
|
||||
| SHORTCUT1_MASK | SHORTCUT2_MASK)
|
||||
|
||||
+#undef ARM_LOCAL_GPU_INT_ROUTING
|
||||
+#define ARM_LOCAL_GPU_INT_ROUTING 0x0c
|
||||
+
|
||||
#define REG_FIQ_CONTROL 0x0c
|
||||
#define FIQ_CONTROL_ENABLE BIT(7)
|
||||
#define REG_FIQ_ENABLE FIQ_CONTROL_ENABLE
|
||||
@@ -86,6 +92,7 @@ struct armctrl_ic {
|
||||
void __iomem *enable[NR_BANKS];
|
||||
void __iomem *disable[NR_BANKS];
|
||||
struct irq_domain *domain;
|
||||
+ struct regmap *local_regmap;
|
||||
};
|
||||
|
||||
static struct armctrl_ic intc __read_mostly;
|
||||
@@ -119,12 +126,35 @@ static void armctrl_mask_irq(struct irq_
|
||||
|
||||
static void armctrl_unmask_irq(struct irq_data *d)
|
||||
{
|
||||
- if (d->hwirq >= NUMBER_IRQS)
|
||||
+ if (d->hwirq >= NUMBER_IRQS) {
|
||||
+ if (num_online_cpus() > 1) {
|
||||
+ unsigned int data;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (!intc.local_regmap) {
|
||||
+ pr_err("FIQ is disabled due to missing regmap\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ret = regmap_read(intc.local_regmap,
|
||||
+ ARM_LOCAL_GPU_INT_ROUTING, &data);
|
||||
+ if (ret) {
|
||||
+ pr_err("Failed to read int routing %d\n", ret);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ data &= ~0xc;
|
||||
+ data |= (1 << 2);
|
||||
+ regmap_write(intc.local_regmap,
|
||||
+ ARM_LOCAL_GPU_INT_ROUTING, data);
|
||||
+ }
|
||||
+
|
||||
writel_relaxed(REG_FIQ_ENABLE | hwirq_to_fiq(d->hwirq),
|
||||
intc.base + REG_FIQ_CONTROL);
|
||||
- else
|
||||
+ } else {
|
||||
writel_relaxed(HWIRQ_BIT(d->hwirq),
|
||||
intc.enable[HWIRQ_BANK(d->hwirq)]);
|
||||
+ }
|
||||
}
|
||||
|
||||
static struct irq_chip armctrl_chip = {
|
||||
@@ -215,6 +245,15 @@ static int __init armctrl_of_init(struct
|
||||
set_handle_irq(bcm2835_handle_irq);
|
||||
}
|
||||
|
||||
+ if (is_2836) {
|
||||
+ intc.local_regmap =
|
||||
+ syscon_regmap_lookup_by_compatible("brcm,bcm2836-arm-local");
|
||||
+ if (IS_ERR(intc.local_regmap)) {
|
||||
+ pr_err("Failed to get local register map. FIQ is disabled for cpus > 1\n");
|
||||
+ intc.local_regmap = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
/* Make a duplicate irq range which is used to enable FIQ */
|
||||
for (b = 0; b < NR_BANKS; b++) {
|
||||
for (i = 0; i < bank_irqs[b]; i++) {
|
@ -0,0 +1,24 @@
|
||||
From 389c8d3272050cd89a464779a47a575dee3e308b Mon Sep 17 00:00:00 2001
|
||||
From: Dom Cobley <popcornmix@gmail.com>
|
||||
Date: Mon, 24 Jan 2022 13:41:16 +0000
|
||||
Subject: [PATCH 0070/1085] spi: spidev: Completely disable the spidev warning
|
||||
|
||||
An alternative strategy would be to use "rpi,spidev" instead, but that
|
||||
would require many Raspberry Pi Device Tree changes.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/spi/spidev.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/spi/spidev.c
|
||||
+++ b/drivers/spi/spidev.c
|
||||
@@ -719,7 +719,7 @@ MODULE_DEVICE_TABLE(spi, spidev_spi_ids)
|
||||
*/
|
||||
static int spidev_of_check(struct device *dev)
|
||||
{
|
||||
- if (device_property_match_string(dev, "compatible", "spidev") < 0)
|
||||
+ if (1 || device_property_match_string(dev, "compatible", "spidev") < 0)
|
||||
return 0;
|
||||
|
||||
dev_err(dev, "spidev listed directly in DT is not supported\n");
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
From 62cc6444d30992fcb534bb150525eaaa31891a62 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Wed, 15 Jun 2016 16:48:41 +0100
|
||||
Subject: [PATCH 0072/1085] rtc: Add SPI alias for pcf2123 driver
|
||||
|
||||
Without this alias, Device Tree won't cause the driver
|
||||
to be loaded.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/pull/1510
|
||||
---
|
||||
drivers/rtc/rtc-pcf2123.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/rtc/rtc-pcf2123.c
|
||||
+++ b/drivers/rtc/rtc-pcf2123.c
|
||||
@@ -479,3 +479,4 @@ module_spi_driver(pcf2123_driver);
|
||||
MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>");
|
||||
MODULE_DESCRIPTION("NXP PCF2123 RTC driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
+MODULE_ALIAS("spi:rtc-pcf2123");
|
@ -0,0 +1,102 @@
|
||||
From 45d9fa5c9a92c2b5595f41be8a04752dbdae9001 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Fri, 7 Oct 2016 16:50:59 +0200
|
||||
Subject: [PATCH 0073/1085] watchdog: bcm2835: Support setting reboot partition
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The Raspberry Pi firmware looks at the RSTS register to know which
|
||||
partition to boot from. The reboot syscall command
|
||||
LINUX_REBOOT_CMD_RESTART2 supports passing in a string argument.
|
||||
|
||||
Add support for passing in a partition number 0..63 to boot from.
|
||||
Partition 63 is a special partiton indicating halt.
|
||||
If the partition doesn't exist, the firmware falls back to partition 0.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
---
|
||||
drivers/watchdog/bcm2835_wdt.c | 49 +++++++++++++++++++---------------
|
||||
1 file changed, 27 insertions(+), 22 deletions(-)
|
||||
|
||||
--- a/drivers/watchdog/bcm2835_wdt.c
|
||||
+++ b/drivers/watchdog/bcm2835_wdt.c
|
||||
@@ -32,13 +32,7 @@
|
||||
#define PM_RSTC_WRCFG_SET 0x00000030
|
||||
#define PM_RSTC_WRCFG_FULL_RESET 0x00000020
|
||||
#define PM_RSTC_RESET 0x00000102
|
||||
-
|
||||
-/*
|
||||
- * The Raspberry Pi firmware uses the RSTS register to know which partition
|
||||
- * to boot from. The partition value is spread into bits 0, 2, 4, 6, 8, 10.
|
||||
- * Partition 63 is a special partition used by the firmware to indicate halt.
|
||||
- */
|
||||
-#define PM_RSTS_RASPBERRYPI_HALT 0x555
|
||||
+#define PM_RSTS_PARTITION_CLR 0xfffffaaa
|
||||
|
||||
#define SECS_TO_WDOG_TICKS(x) ((x) << 16)
|
||||
#define WDOG_TICKS_TO_SECS(x) ((x) >> 16)
|
||||
@@ -98,9 +92,24 @@ static unsigned int bcm2835_wdt_get_time
|
||||
return WDOG_TICKS_TO_SECS(ret & PM_WDOG_TIME_SET);
|
||||
}
|
||||
|
||||
-static void __bcm2835_restart(struct bcm2835_wdt *wdt)
|
||||
+/*
|
||||
+ * The Raspberry Pi firmware uses the RSTS register to know which partiton
|
||||
+ * to boot from. The partiton value is spread into bits 0, 2, 4, 6, 8, 10.
|
||||
+ * Partiton 63 is a special partition used by the firmware to indicate halt.
|
||||
+ */
|
||||
+
|
||||
+static void __bcm2835_restart(struct bcm2835_wdt *wdt, u8 partition)
|
||||
{
|
||||
- u32 val;
|
||||
+ u32 val, rsts;
|
||||
+
|
||||
+ rsts = (partition & BIT(0)) | ((partition & BIT(1)) << 1) |
|
||||
+ ((partition & BIT(2)) << 2) | ((partition & BIT(3)) << 3) |
|
||||
+ ((partition & BIT(4)) << 4) | ((partition & BIT(5)) << 5);
|
||||
+
|
||||
+ val = readl_relaxed(wdt->base + PM_RSTS);
|
||||
+ val &= PM_RSTS_PARTITION_CLR;
|
||||
+ val |= PM_PASSWORD | rsts;
|
||||
+ writel_relaxed(val, wdt->base + PM_RSTS);
|
||||
|
||||
/* use a timeout of 10 ticks (~150us) */
|
||||
writel_relaxed(10 | PM_PASSWORD, wdt->base + PM_WDOG);
|
||||
@@ -118,7 +127,13 @@ static int bcm2835_restart(struct watchd
|
||||
{
|
||||
struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog);
|
||||
|
||||
- __bcm2835_restart(wdt);
|
||||
+ unsigned long long val;
|
||||
+ u8 partition = 0;
|
||||
+
|
||||
+ if (data && !kstrtoull(data, 0, &val) && val <= 63)
|
||||
+ partition = val;
|
||||
+
|
||||
+ __bcm2835_restart(wdt, partition);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -153,19 +168,9 @@ static struct watchdog_device bcm2835_wd
|
||||
static void bcm2835_power_off(void)
|
||||
{
|
||||
struct bcm2835_wdt *wdt = bcm2835_power_off_wdt;
|
||||
- u32 val;
|
||||
-
|
||||
- /*
|
||||
- * We set the watchdog hard reset bit here to distinguish this reset
|
||||
- * from the normal (full) reset. bootcode.bin will not reboot after a
|
||||
- * hard reset.
|
||||
- */
|
||||
- val = readl_relaxed(wdt->base + PM_RSTS);
|
||||
- val |= PM_PASSWORD | PM_RSTS_RASPBERRYPI_HALT;
|
||||
- writel_relaxed(val, wdt->base + PM_RSTS);
|
||||
|
||||
- /* Continue with normal reset mechanism */
|
||||
- __bcm2835_restart(wdt);
|
||||
+ /* Partition 63 tells the firmware that this is a halt */
|
||||
+ __bcm2835_restart(wdt, 63);
|
||||
}
|
||||
|
||||
static int bcm2835_wdt_probe(struct platform_device *pdev)
|
@ -0,0 +1,49 @@
|
||||
From 7b4fcaaaf4d7081c4c1be24b4961f59e14e2af6c Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Tue, 5 Apr 2016 19:40:12 +0100
|
||||
Subject: [PATCH 0074/1085] reboot: Use power off rather than busy spinning
|
||||
when halt is requested
|
||||
|
||||
reboot: Use power off rather than busy spinning when halt is requested
|
||||
|
||||
Busy spinning after halt is dumb
|
||||
We've previously applied this patch to arch/arm
|
||||
but it is currenltly missing in arch/arm64
|
||||
|
||||
Pi4 after "sudo halt" uses 520mA
|
||||
Pi4 after "sudo shutdown now" uses 310mA
|
||||
|
||||
Make them both use the lower powered option
|
||||
|
||||
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
|
||||
---
|
||||
arch/arm/kernel/reboot.c | 4 +---
|
||||
arch/arm64/kernel/process.c | 4 +---
|
||||
2 files changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/arch/arm/kernel/reboot.c
|
||||
+++ b/arch/arm/kernel/reboot.c
|
||||
@@ -102,9 +102,7 @@ void machine_shutdown(void)
|
||||
*/
|
||||
void machine_halt(void)
|
||||
{
|
||||
- local_irq_disable();
|
||||
- smp_send_stop();
|
||||
- while (1);
|
||||
+ machine_power_off();
|
||||
}
|
||||
|
||||
/*
|
||||
--- a/arch/arm64/kernel/process.c
|
||||
+++ b/arch/arm64/kernel/process.c
|
||||
@@ -96,9 +96,7 @@ void machine_shutdown(void)
|
||||
*/
|
||||
void machine_halt(void)
|
||||
{
|
||||
- local_irq_disable();
|
||||
- smp_send_stop();
|
||||
- while (1);
|
||||
+ machine_power_off();
|
||||
}
|
||||
|
||||
/*
|
@ -0,0 +1,19 @@
|
||||
From 32f7b1937744d92fd437ab6c1284ebc89b64d329 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Wed, 9 Nov 2016 13:02:52 +0000
|
||||
Subject: [PATCH 0075/1085] bcm: Make RASPBERRYPI_POWER depend on PM
|
||||
|
||||
---
|
||||
drivers/soc/bcm/Kconfig | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/soc/bcm/Kconfig
|
||||
+++ b/drivers/soc/bcm/Kconfig
|
||||
@@ -17,6 +17,7 @@ config RASPBERRYPI_POWER
|
||||
bool "Raspberry Pi power domain driver"
|
||||
depends on ARCH_BCM2835 || (COMPILE_TEST && OF)
|
||||
depends on RASPBERRYPI_FIRMWARE=y
|
||||
+ depends on PM
|
||||
select PM_GENERIC_DOMAINS if PM
|
||||
help
|
||||
This enables support for the RPi power domains which can be enabled
|
@ -0,0 +1,25 @@
|
||||
From bf03fa485094a2483bad7d27537f532d04e8d860 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Tue, 6 Dec 2016 17:05:39 +0000
|
||||
Subject: [PATCH 0076/1085] bcm2835-rng: Avoid initialising if already enabled
|
||||
|
||||
Avoids the 0x40000 cycles of warmup again if firmware has already used it
|
||||
---
|
||||
drivers/char/hw_random/bcm2835-rng.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/char/hw_random/bcm2835-rng.c
|
||||
+++ b/drivers/char/hw_random/bcm2835-rng.c
|
||||
@@ -105,8 +105,10 @@ static int bcm2835_rng_init(struct hwrng
|
||||
}
|
||||
|
||||
/* set warm-up count & enable */
|
||||
- rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
|
||||
- rng_writel(priv, RNG_RBGEN, RNG_CTRL);
|
||||
+ if (!(rng_readl(priv, RNG_CTRL) & RNG_RBGEN)) {
|
||||
+ rng_writel(priv, RNG_WARMUP_COUNT, RNG_STATUS);
|
||||
+ rng_writel(priv, RNG_RBGEN, RNG_CTRL);
|
||||
+ }
|
||||
|
||||
return ret;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
From fa657603e4de0f034eb9386089d9c0df758a5781 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Thu, 9 Feb 2017 14:36:44 +0000
|
||||
Subject: [PATCH 0077/1085] sound: Demote deferral errors to INFO level
|
||||
|
||||
At present there is no mechanism to specify driver load order,
|
||||
which can lead to deferrals and repeated retries until successful.
|
||||
Since this situation is expected, reduce the dmesg level to
|
||||
INFO and mention that the operation will be retried.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
sound/soc/soc-core.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/sound/soc/soc-core.c
|
||||
+++ b/sound/soc/soc-core.c
|
||||
@@ -1080,7 +1080,7 @@ static int snd_soc_add_pcm_runtime(struc
|
||||
for_each_link_cpus(dai_link, i, cpu) {
|
||||
asoc_rtd_to_cpu(rtd, i) = snd_soc_find_dai(cpu);
|
||||
if (!asoc_rtd_to_cpu(rtd, i)) {
|
||||
- dev_info(card->dev, "ASoC: CPU DAI %s not registered\n",
|
||||
+ dev_info(card->dev, "ASoC: CPU DAI %s not registered - will retry\n",
|
||||
cpu->dai_name);
|
||||
goto _err_defer;
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ static int snd_soc_add_pcm_runtime(struc
|
||||
for_each_link_codecs(dai_link, i, codec) {
|
||||
asoc_rtd_to_codec(rtd, i) = snd_soc_find_dai(codec);
|
||||
if (!asoc_rtd_to_codec(rtd, i)) {
|
||||
- dev_info(card->dev, "ASoC: CODEC DAI %s not registered\n",
|
||||
+ dev_info(card->dev, "ASoC: CODEC DAI %s not registered- will retry\n",
|
||||
codec->dai_name);
|
||||
goto _err_defer;
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
From 0f89f7ea9f51911ae43d92f06429bb0bc23adeca Mon Sep 17 00:00:00 2001
|
||||
From: Claggy3 <stephen.maclagan@hotmail.com>
|
||||
Date: Sat, 11 Feb 2017 14:00:30 +0000
|
||||
Subject: [PATCH 0078/1085] Update vfpmodule.c
|
||||
|
||||
Christopher Alexander Tobias Schulze - May 2, 2015, 11:57 a.m.
|
||||
This patch fixes a problem with VFP state save and restore related
|
||||
to exception handling (panic with message "BUG: unsupported FP
|
||||
instruction in kernel mode") present on VFP11 floating point units
|
||||
(as used with ARM1176JZF-S CPUs, e.g. on first generation Raspberry
|
||||
Pi boards). This patch was developed and discussed on
|
||||
|
||||
https://github.com/raspberrypi/linux/issues/859
|
||||
|
||||
A precondition to see the crashes is that floating point exception
|
||||
traps are enabled. In this case, the VFP11 might determine that a FPU
|
||||
operation needs to trap at a point in time when it is not possible to
|
||||
signal this to the ARM11 core any more. The VFP11 will then set the
|
||||
FPEXC.EX bit and store the trapped opcode in FPINST. (In some cases,
|
||||
a second opcode might have been accepted by the VFP11 before the
|
||||
exception was detected and could be reported to the ARM11 - in this
|
||||
case, the VFP11 also sets FPEXC.FP2V and stores the second opcode in
|
||||
FPINST2.)
|
||||
|
||||
If FPEXC.EX is set, the VFP11 will "bounce" the next FPU opcode issued
|
||||
by the ARM11 CPU, which will be seen by the ARM11 as an undefined opcode
|
||||
trap. The VFP support code examines the FPEXC.EX and FPEXC.FP2V bits
|
||||
to decide what actions to take, i.e., whether to emulate the opcodes
|
||||
found in FPINST and FPINST2, and whether to retry the bounced instruction.
|
||||
|
||||
If a user space application has left the VFP11 in this "pending trap"
|
||||
state, the next FPU opcode issued to the VFP11 might actually be the
|
||||
VSTMIA operation vfp_save_state() uses to store the FPU registers
|
||||
to memory (in our test cases, when building the signal stack frame).
|
||||
In this case, the kernel crashes as described above.
|
||||
|
||||
This patch fixes the problem by making sure that vfp_save_state() is
|
||||
always entered with FPEXC.EX cleared. (The current value of FPEXC has
|
||||
already been saved, so this does not corrupt the context. Clearing
|
||||
FPEXC.EX has no effects on FPINST or FPINST2. Also note that many
|
||||
callers already modify FPEXC by setting FPEXC.EN before invoking
|
||||
vfp_save_state().)
|
||||
|
||||
This patch also addresses a second problem related to FPEXC.EX: After
|
||||
returning from signal handling, the kernel reloads the VFP context
|
||||
from the user mode stack. However, the current code explicitly clears
|
||||
both FPEXC.EX and FPEXC.FP2V during reload. As VFP11 requires these
|
||||
bits to be preserved, this patch disables clearing them for VFP
|
||||
implementations belonging to architecture 1. There should be no
|
||||
negative side effects: the user can set both bits by executing FPU
|
||||
opcodes anyway, and while user code may now place arbitrary values
|
||||
into FPINST and FPINST2 (e.g., non-VFP ARM opcodes) the VFP support
|
||||
code knows which instructions can be emulated, and rejects other
|
||||
opcodes with "unhandled bounce" messages, so there should be no
|
||||
security impact from allowing reloading FPEXC.EX and FPEXC.FP2V.
|
||||
|
||||
Signed-off-by: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>
|
||||
---
|
||||
arch/arm/vfp/vfpmodule.c | 25 +++++++++++++++++++------
|
||||
1 file changed, 19 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/arch/arm/vfp/vfpmodule.c
|
||||
+++ b/arch/arm/vfp/vfpmodule.c
|
||||
@@ -176,8 +176,11 @@ static int vfp_notifier(struct notifier_
|
||||
* case the thread migrates to a different CPU. The
|
||||
* restoring is done lazily.
|
||||
*/
|
||||
- if ((fpexc & FPEXC_EN) && vfp_current_hw_state[cpu])
|
||||
+ if ((fpexc & FPEXC_EN) && vfp_current_hw_state[cpu]) {
|
||||
+ /* vfp_save_state oopses on VFP11 if EX bit set */
|
||||
+ fmxr(FPEXC, fpexc & ~FPEXC_EX);
|
||||
vfp_save_state(vfp_current_hw_state[cpu], fpexc);
|
||||
+ }
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -451,13 +454,16 @@ static int vfp_pm_suspend(void)
|
||||
/* if vfp is on, then save state for resumption */
|
||||
if (fpexc & FPEXC_EN) {
|
||||
pr_debug("%s: saving vfp state\n", __func__);
|
||||
+ /* vfp_save_state oopses on VFP11 if EX bit set */
|
||||
+ fmxr(FPEXC, fpexc & ~FPEXC_EX);
|
||||
vfp_save_state(&ti->vfpstate, fpexc);
|
||||
|
||||
/* disable, just in case */
|
||||
fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
|
||||
} else if (vfp_current_hw_state[ti->cpu]) {
|
||||
#ifndef CONFIG_SMP
|
||||
- fmxr(FPEXC, fpexc | FPEXC_EN);
|
||||
+ /* vfp_save_state oopses on VFP11 if EX bit set */
|
||||
+ fmxr(FPEXC, (fpexc & ~FPEXC_EX) | FPEXC_EN);
|
||||
vfp_save_state(vfp_current_hw_state[ti->cpu], fpexc);
|
||||
fmxr(FPEXC, fpexc);
|
||||
#endif
|
||||
@@ -522,7 +528,8 @@ void vfp_sync_hwstate(struct thread_info
|
||||
/*
|
||||
* Save the last VFP state on this CPU.
|
||||
*/
|
||||
- fmxr(FPEXC, fpexc | FPEXC_EN);
|
||||
+ /* vfp_save_state oopses on VFP11 if EX bit set */
|
||||
+ fmxr(FPEXC, (fpexc & ~FPEXC_EX) | FPEXC_EN);
|
||||
vfp_save_state(&thread->vfpstate, fpexc | FPEXC_EN);
|
||||
fmxr(FPEXC, fpexc);
|
||||
}
|
||||
@@ -589,6 +596,7 @@ int vfp_restore_user_hwstate(struct user
|
||||
struct thread_info *thread = current_thread_info();
|
||||
struct vfp_hard_struct *hwstate = &thread->vfpstate.hard;
|
||||
unsigned long fpexc;
|
||||
+ u32 fpsid = fmrx(FPSID);
|
||||
|
||||
/* Disable VFP to avoid corrupting the new thread state. */
|
||||
vfp_flush_hwstate(thread);
|
||||
@@ -611,8 +619,12 @@ int vfp_restore_user_hwstate(struct user
|
||||
/* Ensure the VFP is enabled. */
|
||||
fpexc |= FPEXC_EN;
|
||||
|
||||
- /* Ensure FPINST2 is invalid and the exception flag is cleared. */
|
||||
- fpexc &= ~(FPEXC_EX | FPEXC_FP2V);
|
||||
+ /* Mask FPXEC_EX and FPEXC_FP2V if not required by VFP arch */
|
||||
+ if ((fpsid & FPSID_ARCH_MASK) != (1 << FPSID_ARCH_BIT)) {
|
||||
+ /* Ensure FPINST2 is invalid and the exception flag is cleared. */
|
||||
+ fpexc &= ~(FPEXC_EX | FPEXC_FP2V);
|
||||
+ }
|
||||
+
|
||||
hwstate->fpexc = fpexc;
|
||||
|
||||
hwstate->fpinst = ufp_exc->fpinst;
|
||||
@@ -830,7 +842,8 @@ void kernel_neon_begin(void)
|
||||
cpu = __smp_processor_id();
|
||||
|
||||
fpexc = fmrx(FPEXC) | FPEXC_EN;
|
||||
- fmxr(FPEXC, fpexc);
|
||||
+ /* vfp_save_state oopses on VFP11 if EX bit set */
|
||||
+ fmxr(FPEXC, fpexc & ~FPEXC_EX);
|
||||
|
||||
/*
|
||||
* Save the userland NEON/VFP state. Under UP,
|
@ -0,0 +1,189 @@
|
||||
From 2af7f34c83c900d8bff6a9e4de6d9e33c7997606 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Tue, 1 Nov 2016 15:15:41 +0100
|
||||
Subject: [PATCH 0079/1085] i2c: bcm2835: Add debug support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This adds a debug module parameter to aid in debugging transfer issues
|
||||
by printing info to the kernel log. When enabled, status values are
|
||||
collected in the interrupt routine and msg info in
|
||||
bcm2835_i2c_start_transfer(). This is done in a way that tries to avoid
|
||||
affecting timing. Having printk in the isr can mask issues.
|
||||
|
||||
debug values (additive):
|
||||
1: Print info on error
|
||||
2: Print info on all transfers
|
||||
3: Print messages before transfer is started
|
||||
|
||||
The value can be changed at runtime:
|
||||
/sys/module/i2c_bcm2835/parameters/debug
|
||||
|
||||
Example output, debug=3:
|
||||
[ 747.114448] bcm2835_i2c_xfer: msg(1/2) write addr=0x54, len=2 flags= [i2c1]
|
||||
[ 747.114463] bcm2835_i2c_xfer: msg(2/2) read addr=0x54, len=32 flags= [i2c1]
|
||||
[ 747.117809] start_transfer: msg(1/2) write addr=0x54, len=2 flags= [i2c1]
|
||||
[ 747.117825] isr: remain=2, status=0x30000055 : TA TXW TXD TXE [i2c1]
|
||||
[ 747.117839] start_transfer: msg(2/2) read addr=0x54, len=32 flags= [i2c1]
|
||||
[ 747.117849] isr: remain=32, status=0xd0000039 : TA RXR TXD RXD [i2c1]
|
||||
[ 747.117861] isr: remain=20, status=0xd0000039 : TA RXR TXD RXD [i2c1]
|
||||
[ 747.117870] isr: remain=8, status=0x32 : DONE TXD RXD [i2c1]
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
---
|
||||
drivers/i2c/busses/i2c-bcm2835.c | 99 +++++++++++++++++++++++++++++++-
|
||||
1 file changed, 98 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/i2c/busses/i2c-bcm2835.c
|
||||
+++ b/drivers/i2c/busses/i2c-bcm2835.c
|
||||
@@ -56,6 +56,18 @@
|
||||
#define BCM2835_I2C_CDIV_MIN 0x0002
|
||||
#define BCM2835_I2C_CDIV_MAX 0xFFFE
|
||||
|
||||
+static unsigned int debug;
|
||||
+module_param(debug, uint, 0644);
|
||||
+MODULE_PARM_DESC(debug, "1=err, 2=isr, 3=xfer");
|
||||
+
|
||||
+#define BCM2835_DEBUG_MAX 512
|
||||
+struct bcm2835_debug {
|
||||
+ struct i2c_msg *msg;
|
||||
+ int msg_idx;
|
||||
+ size_t remain;
|
||||
+ u32 status;
|
||||
+};
|
||||
+
|
||||
struct bcm2835_i2c_dev {
|
||||
struct device *dev;
|
||||
void __iomem *regs;
|
||||
@@ -68,8 +80,78 @@ struct bcm2835_i2c_dev {
|
||||
u32 msg_err;
|
||||
u8 *msg_buf;
|
||||
size_t msg_buf_remaining;
|
||||
+ struct bcm2835_debug debug[BCM2835_DEBUG_MAX];
|
||||
+ unsigned int debug_num;
|
||||
+ unsigned int debug_num_msgs;
|
||||
};
|
||||
|
||||
+static inline void bcm2835_debug_add(struct bcm2835_i2c_dev *i2c_dev, u32 s)
|
||||
+{
|
||||
+ if (!i2c_dev->debug_num_msgs || i2c_dev->debug_num >= BCM2835_DEBUG_MAX)
|
||||
+ return;
|
||||
+
|
||||
+ i2c_dev->debug[i2c_dev->debug_num].msg = i2c_dev->curr_msg;
|
||||
+ i2c_dev->debug[i2c_dev->debug_num].msg_idx =
|
||||
+ i2c_dev->debug_num_msgs - i2c_dev->num_msgs;
|
||||
+ i2c_dev->debug[i2c_dev->debug_num].remain = i2c_dev->msg_buf_remaining;
|
||||
+ i2c_dev->debug[i2c_dev->debug_num].status = s;
|
||||
+ i2c_dev->debug_num++;
|
||||
+}
|
||||
+
|
||||
+static void bcm2835_debug_print_status(struct bcm2835_i2c_dev *i2c_dev,
|
||||
+ struct bcm2835_debug *d)
|
||||
+{
|
||||
+ u32 s = d->status;
|
||||
+
|
||||
+ pr_info("isr: remain=%zu, status=0x%x : %s%s%s%s%s%s%s%s%s%s [i2c%d]\n",
|
||||
+ d->remain, s,
|
||||
+ s & BCM2835_I2C_S_TA ? "TA " : "",
|
||||
+ s & BCM2835_I2C_S_DONE ? "DONE " : "",
|
||||
+ s & BCM2835_I2C_S_TXW ? "TXW " : "",
|
||||
+ s & BCM2835_I2C_S_RXR ? "RXR " : "",
|
||||
+ s & BCM2835_I2C_S_TXD ? "TXD " : "",
|
||||
+ s & BCM2835_I2C_S_RXD ? "RXD " : "",
|
||||
+ s & BCM2835_I2C_S_TXE ? "TXE " : "",
|
||||
+ s & BCM2835_I2C_S_RXF ? "RXF " : "",
|
||||
+ s & BCM2835_I2C_S_ERR ? "ERR " : "",
|
||||
+ s & BCM2835_I2C_S_CLKT ? "CLKT " : "",
|
||||
+ i2c_dev->adapter.nr);
|
||||
+}
|
||||
+
|
||||
+static void bcm2835_debug_print_msg(struct bcm2835_i2c_dev *i2c_dev,
|
||||
+ struct i2c_msg *msg, int i, int total,
|
||||
+ const char *fname)
|
||||
+{
|
||||
+ pr_info("%s: msg(%d/%d) %s addr=0x%02x, len=%u flags=%s%s%s%s%s%s%s [i2c%d]\n",
|
||||
+ fname, i, total,
|
||||
+ msg->flags & I2C_M_RD ? "read" : "write", msg->addr, msg->len,
|
||||
+ msg->flags & I2C_M_TEN ? "TEN" : "",
|
||||
+ msg->flags & I2C_M_RECV_LEN ? "RECV_LEN" : "",
|
||||
+ msg->flags & I2C_M_NO_RD_ACK ? "NO_RD_ACK" : "",
|
||||
+ msg->flags & I2C_M_IGNORE_NAK ? "IGNORE_NAK" : "",
|
||||
+ msg->flags & I2C_M_REV_DIR_ADDR ? "REV_DIR_ADDR" : "",
|
||||
+ msg->flags & I2C_M_NOSTART ? "NOSTART" : "",
|
||||
+ msg->flags & I2C_M_STOP ? "STOP" : "",
|
||||
+ i2c_dev->adapter.nr);
|
||||
+}
|
||||
+
|
||||
+static void bcm2835_debug_print(struct bcm2835_i2c_dev *i2c_dev)
|
||||
+{
|
||||
+ struct bcm2835_debug *d;
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < i2c_dev->debug_num; i++) {
|
||||
+ d = &i2c_dev->debug[i];
|
||||
+ if (d->status == ~0)
|
||||
+ bcm2835_debug_print_msg(i2c_dev, d->msg, d->msg_idx,
|
||||
+ i2c_dev->debug_num_msgs, "start_transfer");
|
||||
+ else
|
||||
+ bcm2835_debug_print_status(i2c_dev, d);
|
||||
+ }
|
||||
+ if (i2c_dev->debug_num >= BCM2835_DEBUG_MAX)
|
||||
+ pr_info("BCM2835_DEBUG_MAX reached\n");
|
||||
+}
|
||||
+
|
||||
static inline void bcm2835_i2c_writel(struct bcm2835_i2c_dev *i2c_dev,
|
||||
u32 reg, u32 val)
|
||||
{
|
||||
@@ -257,6 +339,7 @@ static void bcm2835_i2c_start_transfer(s
|
||||
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_A, msg->addr);
|
||||
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DLEN, msg->len);
|
||||
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, c);
|
||||
+ bcm2835_debug_add(i2c_dev, ~0);
|
||||
}
|
||||
|
||||
static void bcm2835_i2c_finish_transfer(struct bcm2835_i2c_dev *i2c_dev)
|
||||
@@ -283,6 +366,7 @@ static irqreturn_t bcm2835_i2c_isr(int t
|
||||
u32 val, err;
|
||||
|
||||
val = bcm2835_i2c_readl(i2c_dev, BCM2835_I2C_S);
|
||||
+ bcm2835_debug_add(i2c_dev, val);
|
||||
|
||||
err = val & (BCM2835_I2C_S_CLKT | BCM2835_I2C_S_ERR);
|
||||
if (err) {
|
||||
@@ -349,6 +433,13 @@ static int bcm2835_i2c_xfer(struct i2c_a
|
||||
unsigned long time_left;
|
||||
int i;
|
||||
|
||||
+ if (debug)
|
||||
+ i2c_dev->debug_num_msgs = num;
|
||||
+
|
||||
+ if (debug > 2)
|
||||
+ for (i = 0; i < num; i++)
|
||||
+ bcm2835_debug_print_msg(i2c_dev, &msgs[i], i + 1, num, __func__);
|
||||
+
|
||||
for (i = 0; i < (num - 1); i++)
|
||||
if (msgs[i].flags & I2C_M_RD) {
|
||||
dev_warn_once(i2c_dev->dev,
|
||||
@@ -367,6 +458,10 @@ static int bcm2835_i2c_xfer(struct i2c_a
|
||||
|
||||
bcm2835_i2c_finish_transfer(i2c_dev);
|
||||
|
||||
+ if (debug > 1 || (debug && (!time_left || i2c_dev->msg_err)))
|
||||
+ bcm2835_debug_print(i2c_dev);
|
||||
+ i2c_dev->debug_num_msgs = 0;
|
||||
+ i2c_dev->debug_num = 0;
|
||||
if (!time_left) {
|
||||
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C,
|
||||
BCM2835_I2C_C_CLEAR);
|
||||
@@ -377,7 +472,9 @@ static int bcm2835_i2c_xfer(struct i2c_a
|
||||
if (!i2c_dev->msg_err)
|
||||
return num;
|
||||
|
||||
- dev_dbg(i2c_dev->dev, "i2c transfer failed: %x\n", i2c_dev->msg_err);
|
||||
+ if (debug)
|
||||
+ dev_err(i2c_dev->dev, "i2c transfer failed: %x\n",
|
||||
+ i2c_dev->msg_err);
|
||||
|
||||
if (i2c_dev->msg_err & BCM2835_I2C_S_ERR)
|
||||
return -EREMOTEIO;
|
@ -0,0 +1,112 @@
|
||||
From e894a9f9bfde9ec7d49d81ab167180843d4d612e Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Tue, 23 Jan 2018 16:52:45 +0000
|
||||
Subject: [PATCH 0080/1085] irqchip: irq-bcm2836: Remove regmap and syscon use
|
||||
|
||||
The syscon node defines a register range that duplicates that used by
|
||||
the local_intc node on bcm2836/7. Since irq-bcm2835 and irq-bcm2836 are
|
||||
built in and always present together (both drivers are enabled by
|
||||
CONFIG_ARCH_BCM2835), it is possible to replace the syscon usage with a
|
||||
global variable that simplifies the code. Doing so does lose the
|
||||
locking provided by regmap, but as only one side is using the regmap
|
||||
interface (irq-bcm2835 uses readl and write) there is no loss of
|
||||
atomicity.
|
||||
|
||||
See: https://github.com/raspberrypi/firmware/issues/926
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/irqchip/irq-bcm2835.c | 32 ++++++++++++--------------------
|
||||
drivers/irqchip/irq-bcm2836.c | 5 +++++
|
||||
2 files changed, 17 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/drivers/irqchip/irq-bcm2835.c
|
||||
+++ b/drivers/irqchip/irq-bcm2835.c
|
||||
@@ -41,8 +41,6 @@
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/irqchip.h>
|
||||
#include <linux/irqdomain.h>
|
||||
-#include <linux/mfd/syscon.h>
|
||||
-#include <linux/regmap.h>
|
||||
|
||||
#include <asm/exception.h>
|
||||
#include <asm/mach/irq.h>
|
||||
@@ -92,7 +90,7 @@ struct armctrl_ic {
|
||||
void __iomem *enable[NR_BANKS];
|
||||
void __iomem *disable[NR_BANKS];
|
||||
struct irq_domain *domain;
|
||||
- struct regmap *local_regmap;
|
||||
+ void __iomem *local_base;
|
||||
};
|
||||
|
||||
static struct armctrl_ic intc __read_mostly;
|
||||
@@ -129,24 +127,20 @@ static void armctrl_unmask_irq(struct ir
|
||||
if (d->hwirq >= NUMBER_IRQS) {
|
||||
if (num_online_cpus() > 1) {
|
||||
unsigned int data;
|
||||
- int ret;
|
||||
|
||||
- if (!intc.local_regmap) {
|
||||
- pr_err("FIQ is disabled due to missing regmap\n");
|
||||
+ if (!intc.local_base) {
|
||||
+ pr_err("FIQ is disabled due to missing arm_local_intc\n");
|
||||
return;
|
||||
}
|
||||
|
||||
- ret = regmap_read(intc.local_regmap,
|
||||
- ARM_LOCAL_GPU_INT_ROUTING, &data);
|
||||
- if (ret) {
|
||||
- pr_err("Failed to read int routing %d\n", ret);
|
||||
- return;
|
||||
- }
|
||||
+ data = readl_relaxed(intc.local_base +
|
||||
+ ARM_LOCAL_GPU_INT_ROUTING);
|
||||
|
||||
data &= ~0xc;
|
||||
data |= (1 << 2);
|
||||
- regmap_write(intc.local_regmap,
|
||||
- ARM_LOCAL_GPU_INT_ROUTING, data);
|
||||
+ writel_relaxed(data,
|
||||
+ intc.local_base +
|
||||
+ ARM_LOCAL_GPU_INT_ROUTING);
|
||||
}
|
||||
|
||||
writel_relaxed(REG_FIQ_ENABLE | hwirq_to_fiq(d->hwirq),
|
||||
@@ -246,12 +240,10 @@ static int __init armctrl_of_init(struct
|
||||
}
|
||||
|
||||
if (is_2836) {
|
||||
- intc.local_regmap =
|
||||
- syscon_regmap_lookup_by_compatible("brcm,bcm2836-arm-local");
|
||||
- if (IS_ERR(intc.local_regmap)) {
|
||||
- pr_err("Failed to get local register map. FIQ is disabled for cpus > 1\n");
|
||||
- intc.local_regmap = NULL;
|
||||
- }
|
||||
+ extern void __iomem * __attribute__((weak)) arm_local_intc;
|
||||
+ intc.local_base = arm_local_intc;
|
||||
+ if (!intc.local_base)
|
||||
+ pr_err("Failed to get local intc base. FIQ is disabled for cpus > 1\n");
|
||||
}
|
||||
|
||||
/* Make a duplicate irq range which is used to enable FIQ */
|
||||
--- a/drivers/irqchip/irq-bcm2836.c
|
||||
+++ b/drivers/irqchip/irq-bcm2836.c
|
||||
@@ -22,6 +22,9 @@ struct bcm2836_arm_irqchip_intc {
|
||||
|
||||
static struct bcm2836_arm_irqchip_intc intc __read_mostly;
|
||||
|
||||
+void __iomem *arm_local_intc;
|
||||
+EXPORT_SYMBOL_GPL(arm_local_intc);
|
||||
+
|
||||
static void bcm2836_arm_irqchip_mask_per_cpu_irq(unsigned int reg_offset,
|
||||
unsigned int bit,
|
||||
int cpu)
|
||||
@@ -320,6 +323,8 @@ static int __init bcm2836_arm_irqchip_l1
|
||||
panic("%pOF: unable to map local interrupt registers\n", node);
|
||||
}
|
||||
|
||||
+ arm_local_intc = intc.base;
|
||||
+
|
||||
bcm2835_init_local_timer_frequency();
|
||||
|
||||
intc.domain = irq_domain_add_linear(node, LAST_IRQ + 1,
|
@ -0,0 +1,49 @@
|
||||
From 0c12fba01d3baf5040f6863eff793f1050220435 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Tue, 17 Oct 2017 15:04:29 +0100
|
||||
Subject: [PATCH 0081/1085] lan78xx: Enable LEDs and auto-negotiation
|
||||
|
||||
For applications of the LAN78xx that don't have valid programmed
|
||||
EEPROMs or OTPs, enabling both LEDs and auto-negotiation by default
|
||||
seems reasonable.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/net/usb/lan78xx.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/net/usb/lan78xx.c
|
||||
+++ b/drivers/net/usb/lan78xx.c
|
||||
@@ -2883,6 +2883,11 @@ static int lan78xx_reset(struct lan78xx_
|
||||
int ret;
|
||||
u32 buf;
|
||||
u8 sig;
|
||||
+ bool has_eeprom;
|
||||
+ bool has_otp;
|
||||
+
|
||||
+ has_eeprom = !lan78xx_read_eeprom(dev, 0, 0, NULL);
|
||||
+ has_otp = !lan78xx_read_otp(dev, 0, 0, NULL);
|
||||
|
||||
ret = lan78xx_read_reg(dev, HW_CFG, &buf);
|
||||
if (ret < 0)
|
||||
@@ -2947,6 +2952,10 @@ static int lan78xx_reset(struct lan78xx_
|
||||
|
||||
buf |= HW_CFG_MEF_;
|
||||
|
||||
+ /* If no valid EEPROM and no valid OTP, enable the LEDs by default */
|
||||
+ if (!has_eeprom && !has_otp)
|
||||
+ buf |= HW_CFG_LED0_EN_ | HW_CFG_LED1_EN_;
|
||||
+
|
||||
ret = lan78xx_write_reg(dev, HW_CFG, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
@@ -3046,6 +3055,9 @@ static int lan78xx_reset(struct lan78xx_
|
||||
buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
|
||||
}
|
||||
}
|
||||
+ /* If no valid EEPROM and no valid OTP, enable AUTO negotiation */
|
||||
+ if (!has_eeprom && !has_otp)
|
||||
+ buf |= MAC_CR_AUTO_DUPLEX_ | MAC_CR_AUTO_SPEED_;
|
||||
ret = lan78xx_write_reg(dev, MAC_CR, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
@ -0,0 +1,27 @@
|
||||
From 6424aad28c75df704981eb497e8c57379523e929 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Fri, 29 Sep 2017 10:32:19 +0100
|
||||
Subject: [PATCH 0082/1085] amba_pl011: Insert mb() for correct FIFO handling
|
||||
|
||||
The pl011 register accessor functions use the _relaxed versions of the
|
||||
standard readl() and writel() functions, meaning that there are no
|
||||
automatic memory barriers. When polling a FIFO status register to check
|
||||
for fullness, it is necessary to ensure that any outstanding writes have
|
||||
completed; otherwise the flags are effectively stale, making it possible
|
||||
that the next write is to a full FIFO.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/tty/serial/amba-pl011.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -1456,6 +1456,7 @@ static bool pl011_tx_char(struct uart_am
|
||||
return false; /* unable to transmit character */
|
||||
|
||||
pl011_write(c, uap, REG_DR);
|
||||
+ mb();
|
||||
uap->port.icount.tx++;
|
||||
|
||||
return true;
|
@ -0,0 +1,50 @@
|
||||
From 8541a70fd40ad2612f1a5471206726dea4e8b8c1 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Fri, 29 Sep 2017 10:32:19 +0100
|
||||
Subject: [PATCH 0083/1085] amba_pl011: Add cts-event-workaround DT property
|
||||
|
||||
The BCM2835 PL011 implementation seems to have a bug that can lead to a
|
||||
transmission lockup if CTS changes frequently. A workaround was added to
|
||||
the driver with a vendor-specific flag to enable it, but this flag is
|
||||
currently not set for ARM implementations.
|
||||
|
||||
Add a "cts-event-workaround" property to Pi DTBs and use the presence
|
||||
of that property to force the flag to be enabled in the driver.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/1280
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
Documentation/devicetree/bindings/serial/pl011.yaml | 6 ++++++
|
||||
drivers/tty/serial/amba-pl011.c | 5 +++++
|
||||
2 files changed, 11 insertions(+)
|
||||
|
||||
--- a/Documentation/devicetree/bindings/serial/pl011.yaml
|
||||
+++ b/Documentation/devicetree/bindings/serial/pl011.yaml
|
||||
@@ -101,6 +101,12 @@ properties:
|
||||
on the device.
|
||||
enum: [1, 4]
|
||||
|
||||
+ cts-event-workaround:
|
||||
+ description:
|
||||
+ Enables the (otherwise vendor-specific) workaround for the
|
||||
+ CTS-induced TX lockup.
|
||||
+ type: boolean
|
||||
+
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -2808,6 +2808,11 @@ static int pl011_probe(struct amba_devic
|
||||
if (IS_ERR(uap->clk))
|
||||
return PTR_ERR(uap->clk);
|
||||
|
||||
+ if (of_property_read_bool(dev->dev.of_node, "cts-event-workaround")) {
|
||||
+ vendor->cts_event_workaround = true;
|
||||
+ dev_info(&dev->dev, "cts_event_workaround enabled\n");
|
||||
+ }
|
||||
+
|
||||
uap->reg_offset = vendor->reg_offset;
|
||||
uap->vendor = vendor;
|
||||
uap->fifosize = vendor->get_fifosize(dev);
|
@ -0,0 +1,42 @@
|
||||
From 0c426d88e4a420dc025ee1cbfbd0ca4e56665f1a Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Wed, 29 Jan 2020 09:35:19 +0000
|
||||
Subject: [PATCH 0084/1085] tty: amba-pl011: Avoid rare write-when-full error
|
||||
|
||||
Under some circumstances on BCM283x processors data loss can be
|
||||
observed - a single byte missing from the TX output stream. These bytes
|
||||
are always the last byte of a batch of 8 written from pl011_tx_chars
|
||||
when from_irq is true, meaning that the FIFO full flag is not checked
|
||||
before writing.
|
||||
|
||||
The transmit optimisation relies on the FIFO being half-empty when the
|
||||
TX interrupt is raised. Instrumenting the driver further showed that
|
||||
the failure case correlated with the TX FIFO full flag being set at the
|
||||
point where the last byte was written to the data register, which
|
||||
explains the data loss but not how the FIFO appeared to be prematurely
|
||||
full. A possible explanation is that a FIFO write was in flight at the
|
||||
time the interrupt was raised, but as yet there is no hypothesis as to
|
||||
how this might occur.
|
||||
|
||||
In the absence of a clear understanding of the failure mechanism, avoid
|
||||
the problem by checking the FIFO levels before writing the last byte of
|
||||
the group, which will have minimal performance impact.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.org>
|
||||
---
|
||||
drivers/tty/serial/amba-pl011.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/tty/serial/amba-pl011.c
|
||||
+++ b/drivers/tty/serial/amba-pl011.c
|
||||
@@ -1487,6 +1487,10 @@ static bool pl011_tx_chars(struct uart_a
|
||||
if (likely(from_irq) && count-- == 0)
|
||||
break;
|
||||
|
||||
+ if (likely(from_irq) && count == 0 &&
|
||||
+ pl011_read(uap, REG_FR) & UART01x_FR_TXFF)
|
||||
+ break;
|
||||
+
|
||||
if (!pl011_tx_char(uap, xmit->buf[xmit->tail], from_irq))
|
||||
break;
|
||||
|
@ -0,0 +1,150 @@
|
||||
From 468129d64e78a1415f2fa40946103bbd24a2e367 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Sun, 12 May 2013 12:24:19 +0100
|
||||
Subject: [PATCH 0086/1085] Main bcm2708/bcm2709 linux port
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
bcm2709: Drop platform smp and timer init code
|
||||
|
||||
irq-bcm2836 handles this through these functions:
|
||||
bcm2835_init_local_timer_frequency()
|
||||
bcm2836_arm_irqchip_smp_init()
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
bcm270x: Use watchdog for reboot/poweroff
|
||||
|
||||
The watchdog driver already has support for reboot/poweroff.
|
||||
Make use of this and remove the code from the platform files.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
board_bcm2835: Remove coherent dma pool increase - API has gone
|
||||
---
|
||||
arch/arm/mach-bcm/Kconfig | 1 +
|
||||
arch/arm/mm/proc-v6.S | 15 ++++++++++++---
|
||||
drivers/irqchip/irq-bcm2835.c | 7 ++++++-
|
||||
drivers/mailbox/bcm2835-mailbox.c | 18 ++++++++++++++++--
|
||||
4 files changed, 35 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/arch/arm/mach-bcm/Kconfig
|
||||
+++ b/arch/arm/mach-bcm/Kconfig
|
||||
@@ -163,6 +163,7 @@ config ARCH_BCM2835
|
||||
select PINCTRL
|
||||
select PINCTRL_BCM2835
|
||||
select MFD_CORE
|
||||
+ select MFD_SYSCON if ARCH_MULTI_V7
|
||||
help
|
||||
This enables support for the Broadcom BCM2711 and BCM283x SoCs.
|
||||
This SoC is used in the Raspberry Pi and Roku 2 devices.
|
||||
--- a/arch/arm/mm/proc-v6.S
|
||||
+++ b/arch/arm/mm/proc-v6.S
|
||||
@@ -72,10 +72,19 @@ ENDPROC(cpu_v6_reset)
|
||||
*
|
||||
* IRQs are already disabled.
|
||||
*/
|
||||
+
|
||||
+/* See jira SW-5991 for details of this workaround */
|
||||
ENTRY(cpu_v6_do_idle)
|
||||
- mov r1, #0
|
||||
- mcr p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
|
||||
- mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
|
||||
+ .align 5
|
||||
+ mov r1, #2
|
||||
+1: subs r1, #1
|
||||
+ nop
|
||||
+ mcreq p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
|
||||
+ mcreq p15, 0, r1, c7, c0, 4 @ wait for interrupt
|
||||
+ nop
|
||||
+ nop
|
||||
+ nop
|
||||
+ bne 1b
|
||||
ret lr
|
||||
|
||||
ENTRY(cpu_v6_dcache_clean_area)
|
||||
--- a/drivers/irqchip/irq-bcm2835.c
|
||||
+++ b/drivers/irqchip/irq-bcm2835.c
|
||||
@@ -43,7 +43,9 @@
|
||||
#include <linux/irqdomain.h>
|
||||
|
||||
#include <asm/exception.h>
|
||||
+#ifndef CONFIG_ARM64
|
||||
#include <asm/mach/irq.h>
|
||||
+#endif
|
||||
|
||||
/* Put the bank and irq (32 bits) into the hwirq */
|
||||
#define MAKE_HWIRQ(b, n) (((b) << 5) | (n))
|
||||
@@ -72,6 +74,7 @@
|
||||
#define NR_BANKS 3
|
||||
#define IRQS_PER_BANK 32
|
||||
#define NUMBER_IRQS MAKE_HWIRQ(NR_BANKS, 0)
|
||||
+#undef FIQ_START
|
||||
#define FIQ_START (NR_IRQS_BANK0 + MAKE_HWIRQ(NR_BANKS - 1, 0))
|
||||
|
||||
static const int reg_pending[] __initconst = { 0x00, 0x04, 0x08 };
|
||||
@@ -253,10 +256,12 @@ static int __init armctrl_of_init(struct
|
||||
MAKE_HWIRQ(b, i) + NUMBER_IRQS);
|
||||
BUG_ON(irq <= 0);
|
||||
irq_set_chip(irq, &armctrl_chip);
|
||||
- set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
|
||||
+ irq_set_probe(irq);
|
||||
}
|
||||
}
|
||||
+#ifndef CONFIG_ARM64
|
||||
init_FIQ(FIQ_START);
|
||||
+#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
--- a/drivers/mailbox/bcm2835-mailbox.c
|
||||
+++ b/drivers/mailbox/bcm2835-mailbox.c
|
||||
@@ -45,12 +45,15 @@
|
||||
#define MAIL1_WRT (ARM_0_MAIL1 + 0x00)
|
||||
#define MAIL1_STA (ARM_0_MAIL1 + 0x18)
|
||||
|
||||
+/* On ARCH_BCM270x these come through <linux/interrupt.h> (arm_control.h ) */
|
||||
+#ifndef ARM_MS_FULL
|
||||
/* Status register: FIFO state. */
|
||||
#define ARM_MS_FULL BIT(31)
|
||||
#define ARM_MS_EMPTY BIT(30)
|
||||
|
||||
/* Configuration register: Enable interrupts. */
|
||||
#define ARM_MC_IHAVEDATAIRQEN BIT(0)
|
||||
+#endif
|
||||
|
||||
struct bcm2835_mbox {
|
||||
void __iomem *regs;
|
||||
@@ -144,7 +147,7 @@ static int bcm2835_mbox_probe(struct pla
|
||||
return -ENOMEM;
|
||||
spin_lock_init(&mbox->lock);
|
||||
|
||||
- ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
|
||||
+ ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
|
||||
bcm2835_mbox_irq, 0, dev_name(dev), mbox);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to register a mailbox IRQ handler: %d\n",
|
||||
@@ -192,7 +195,18 @@ static struct platform_driver bcm2835_mb
|
||||
},
|
||||
.probe = bcm2835_mbox_probe,
|
||||
};
|
||||
-module_platform_driver(bcm2835_mbox_driver);
|
||||
+
|
||||
+static int __init bcm2835_mbox_init(void)
|
||||
+{
|
||||
+ return platform_driver_register(&bcm2835_mbox_driver);
|
||||
+}
|
||||
+arch_initcall(bcm2835_mbox_init);
|
||||
+
|
||||
+static void __init bcm2835_mbox_exit(void)
|
||||
+{
|
||||
+ platform_driver_unregister(&bcm2835_mbox_driver);
|
||||
+}
|
||||
+module_exit(bcm2835_mbox_exit);
|
||||
|
||||
MODULE_AUTHOR("Lubomir Rintel <lkundrak@v3.sk>");
|
||||
MODULE_DESCRIPTION("BCM2835 mailbox IPC driver");
|
61027
target/linux/bcm27xx/patches-6.6/950-0087-Add-dwc_otg-driver.patch
Normal file
61027
target/linux/bcm27xx/patches-6.6/950-0087-Add-dwc_otg-driver.patch
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,778 @@
|
||||
From 63fb0fcc095dcca2e3f8d801b3a8d48bee343e81 Mon Sep 17 00:00:00 2001
|
||||
From: James Hughes <james.hughes@raspberrypi.org>
|
||||
Date: Thu, 14 Mar 2019 13:27:54 +0000
|
||||
Subject: [PATCH 0089/1085] Pulled in the multi frame buffer support from the
|
||||
Pi3 repo
|
||||
|
||||
---
|
||||
drivers/video/fbdev/bcm2708_fb.c | 457 ++++++++++++++++++++++---------
|
||||
1 file changed, 324 insertions(+), 133 deletions(-)
|
||||
|
||||
--- a/drivers/video/fbdev/bcm2708_fb.c
|
||||
+++ b/drivers/video/fbdev/bcm2708_fb.c
|
||||
@@ -2,6 +2,7 @@
|
||||
* linux/drivers/video/bcm2708_fb.c
|
||||
*
|
||||
* Copyright (C) 2010 Broadcom
|
||||
+ * Copyright (C) 2018 Raspberry Pi (Trading) Ltd
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file COPYING in the main directory of this archive
|
||||
@@ -13,6 +14,7 @@
|
||||
* Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>
|
||||
*
|
||||
*/
|
||||
+
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/errno.h>
|
||||
@@ -33,6 +35,7 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
+#include <linux/mutex.h>
|
||||
|
||||
//#define BCM2708_FB_DEBUG
|
||||
#define MODULE_NAME "bcm2708_fb"
|
||||
@@ -79,64 +82,150 @@ struct bcm2708_fb_stats {
|
||||
u32 dma_irqs;
|
||||
};
|
||||
|
||||
+struct vc4_display_settings_t {
|
||||
+ u32 display_num;
|
||||
+ u32 width;
|
||||
+ u32 height;
|
||||
+ u32 depth;
|
||||
+ u32 pitch;
|
||||
+ u32 virtual_width;
|
||||
+ u32 virtual_height;
|
||||
+ u32 virtual_width_offset;
|
||||
+ u32 virtual_height_offset;
|
||||
+ unsigned long fb_bus_address;
|
||||
+};
|
||||
+
|
||||
+struct bcm2708_fb_dev;
|
||||
+
|
||||
struct bcm2708_fb {
|
||||
struct fb_info fb;
|
||||
struct platform_device *dev;
|
||||
- struct rpi_firmware *fw;
|
||||
u32 cmap[16];
|
||||
u32 gpu_cmap[256];
|
||||
- int dma_chan;
|
||||
- int dma_irq;
|
||||
- void __iomem *dma_chan_base;
|
||||
- void *cb_base; /* DMA control blocks */
|
||||
- dma_addr_t cb_handle;
|
||||
struct dentry *debugfs_dir;
|
||||
- wait_queue_head_t dma_waitq;
|
||||
- struct bcm2708_fb_stats stats;
|
||||
+ struct dentry *debugfs_subdir;
|
||||
unsigned long fb_bus_address;
|
||||
- bool disable_arm_alloc;
|
||||
+ struct { u32 base, length; } gpu;
|
||||
+ struct vc4_display_settings_t display_settings;
|
||||
+ struct debugfs_regset32 screeninfo_regset;
|
||||
+ struct bcm2708_fb_dev *fbdev;
|
||||
unsigned int image_size;
|
||||
dma_addr_t dma_addr;
|
||||
void *cpuaddr;
|
||||
};
|
||||
|
||||
+#define MAX_FRAMEBUFFERS 3
|
||||
+
|
||||
+struct bcm2708_fb_dev {
|
||||
+ int firmware_supports_multifb;
|
||||
+ /* Protects the DMA system from multiple FB access */
|
||||
+ struct mutex dma_mutex;
|
||||
+ int dma_chan;
|
||||
+ int dma_irq;
|
||||
+ void __iomem *dma_chan_base;
|
||||
+ wait_queue_head_t dma_waitq;
|
||||
+ bool disable_arm_alloc;
|
||||
+ struct bcm2708_fb_stats dma_stats;
|
||||
+ void *cb_base; /* DMA control blocks */
|
||||
+ dma_addr_t cb_handle;
|
||||
+ int instance_count;
|
||||
+ int num_displays;
|
||||
+ struct rpi_firmware *fw;
|
||||
+ struct bcm2708_fb displays[MAX_FRAMEBUFFERS];
|
||||
+};
|
||||
+
|
||||
#define to_bcm2708(info) container_of(info, struct bcm2708_fb, fb)
|
||||
|
||||
static void bcm2708_fb_debugfs_deinit(struct bcm2708_fb *fb)
|
||||
{
|
||||
- debugfs_remove_recursive(fb->debugfs_dir);
|
||||
- fb->debugfs_dir = NULL;
|
||||
+ debugfs_remove_recursive(fb->debugfs_subdir);
|
||||
+ fb->debugfs_subdir = NULL;
|
||||
+
|
||||
+ fb->fbdev->instance_count--;
|
||||
+
|
||||
+ if (!fb->fbdev->instance_count) {
|
||||
+ debugfs_remove_recursive(fb->debugfs_dir);
|
||||
+ fb->debugfs_dir = NULL;
|
||||
+ }
|
||||
}
|
||||
|
||||
static int bcm2708_fb_debugfs_init(struct bcm2708_fb *fb)
|
||||
{
|
||||
+ char buf[3];
|
||||
+ struct bcm2708_fb_dev *fbdev = fb->fbdev;
|
||||
+
|
||||
static struct debugfs_reg32 stats_registers[] = {
|
||||
- {
|
||||
- "dma_copies",
|
||||
- offsetof(struct bcm2708_fb_stats, dma_copies)
|
||||
- },
|
||||
- {
|
||||
- "dma_irqs",
|
||||
- offsetof(struct bcm2708_fb_stats, dma_irqs)
|
||||
- },
|
||||
+ {"dma_copies", offsetof(struct bcm2708_fb_stats, dma_copies)},
|
||||
+ {"dma_irqs", offsetof(struct bcm2708_fb_stats, dma_irqs)},
|
||||
};
|
||||
|
||||
- fb->debugfs_dir = debugfs_create_dir(DRIVER_NAME, NULL);
|
||||
+ static struct debugfs_reg32 screeninfo[] = {
|
||||
+ {"width", offsetof(struct fb_var_screeninfo, xres)},
|
||||
+ {"height", offsetof(struct fb_var_screeninfo, yres)},
|
||||
+ {"bpp", offsetof(struct fb_var_screeninfo, bits_per_pixel)},
|
||||
+ {"xres_virtual", offsetof(struct fb_var_screeninfo, xres_virtual)},
|
||||
+ {"yres_virtual", offsetof(struct fb_var_screeninfo, yres_virtual)},
|
||||
+ {"xoffset", offsetof(struct fb_var_screeninfo, xoffset)},
|
||||
+ {"yoffset", offsetof(struct fb_var_screeninfo, yoffset)},
|
||||
+ };
|
||||
+
|
||||
+ fb->debugfs_dir = debugfs_lookup(DRIVER_NAME, NULL);
|
||||
+
|
||||
+ if (!fb->debugfs_dir)
|
||||
+ fb->debugfs_dir = debugfs_create_dir(DRIVER_NAME, NULL);
|
||||
+
|
||||
if (!fb->debugfs_dir) {
|
||||
- pr_warn("%s: could not create debugfs entry\n",
|
||||
- __func__);
|
||||
+ dev_warn(fb->fb.dev, "%s: could not create debugfs folder\n",
|
||||
+ __func__);
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
- fb->stats.regset.regs = stats_registers;
|
||||
- fb->stats.regset.nregs = ARRAY_SIZE(stats_registers);
|
||||
- fb->stats.regset.base = &fb->stats;
|
||||
+ snprintf(buf, sizeof(buf), "%u", fb->display_settings.display_num);
|
||||
+
|
||||
+ fb->debugfs_subdir = debugfs_create_dir(buf, fb->debugfs_dir);
|
||||
|
||||
debugfs_create_regset32("stats", 0444, fb->debugfs_dir,
|
||||
&fb->stats.regset);
|
||||
+
|
||||
+ if (!fb->debugfs_subdir) {
|
||||
+ dev_warn(fb->fb.dev, "%s: could not create debugfs entry %u\n",
|
||||
+ __func__, fb->display_settings.display_num);
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ fbdev->dma_stats.regset.regs = stats_registers;
|
||||
+ fbdev->dma_stats.regset.nregs = ARRAY_SIZE(stats_registers);
|
||||
+ fbdev->dma_stats.regset.base = &fbdev->dma_stats;
|
||||
+
|
||||
+ debugfs_create_regset32("dma_stats", 0444, fb->debugfs_subdir,
|
||||
+ &fbdev->dma_stats.regset);
|
||||
+
|
||||
+ fb->screeninfo_regset.regs = screeninfo;
|
||||
+ fb->screeninfo_regset.nregs = ARRAY_SIZE(screeninfo);
|
||||
+ fb->screeninfo_regset.base = &fb->fb.var;
|
||||
+
|
||||
+ debugfs_create_regset32("screeninfo", 0444, fb->debugfs_subdir,
|
||||
+ &fb->screeninfo_regset);
|
||||
+
|
||||
+ fbdev->instance_count++;
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void set_display_num(struct bcm2708_fb *fb)
|
||||
+{
|
||||
+ if (fb && fb->fbdev && fb->fbdev->firmware_supports_multifb) {
|
||||
+ u32 tmp = fb->display_settings.display_num;
|
||||
+
|
||||
+ if (rpi_firmware_property(fb->fbdev->fw,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_DISPLAY_NUM,
|
||||
+ &tmp,
|
||||
+ sizeof(tmp)))
|
||||
+ dev_warn_once(fb->fb.dev,
|
||||
+ "Set display number call failed. Old GPU firmware?");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int bcm2708_fb_set_bitfields(struct fb_var_screeninfo *var)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -214,11 +303,11 @@ static int bcm2708_fb_check_var(struct f
|
||||
struct fb_info *info)
|
||||
{
|
||||
/* info input, var output */
|
||||
- print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n",
|
||||
+ print_debug("%s(%p) %ux%u (%ux%u), %ul, %u\n",
|
||||
__func__, info, info->var.xres, info->var.yres,
|
||||
info->var.xres_virtual, info->var.yres_virtual,
|
||||
- (int)info->screen_size, info->var.bits_per_pixel);
|
||||
- print_debug("%s(%p) %dx%d (%dx%d), %d\n", __func__, var, var->xres,
|
||||
+ info->screen_size, info->var.bits_per_pixel);
|
||||
+ print_debug("%s(%p) %ux%u (%ux%u), %u\n", __func__, var, var->xres,
|
||||
var->yres, var->xres_virtual, var->yres_virtual,
|
||||
var->bits_per_pixel);
|
||||
|
||||
@@ -281,17 +370,24 @@ static int bcm2708_fb_set_par(struct fb_
|
||||
};
|
||||
int ret, image_size;
|
||||
|
||||
-
|
||||
- print_debug("%s(%p) %dx%d (%dx%d), %d, %d\n", __func__, info,
|
||||
+ print_debug("%s(%p) %dx%d (%dx%d), %d, %d (display %d)\n", __func__,
|
||||
+ info,
|
||||
info->var.xres, info->var.yres, info->var.xres_virtual,
|
||||
info->var.yres_virtual, (int)info->screen_size,
|
||||
- info->var.bits_per_pixel);
|
||||
+ info->var.bits_per_pixel, value);
|
||||
+
|
||||
+ /* Need to set the display number to act on first
|
||||
+ * Cannot do it in the tag list because on older firmware the call
|
||||
+ * will fail and stop the rest of the list being executed.
|
||||
+ * We can ignore this call failing as the default at other end is 0
|
||||
+ */
|
||||
+ set_display_num(fb);
|
||||
|
||||
/* Try allocating our own buffer. We can specify all the parameters */
|
||||
image_size = ((info->var.xres * info->var.yres) *
|
||||
info->var.bits_per_pixel) >> 3;
|
||||
|
||||
- if (!fb->disable_arm_alloc &&
|
||||
+ if (!fb->fbdev->disable_arm_alloc &&
|
||||
(image_size != fb->image_size || !fb->dma_addr)) {
|
||||
if (fb->dma_addr) {
|
||||
dma_free_coherent(info->device, fb->image_size,
|
||||
@@ -306,7 +402,7 @@ static int bcm2708_fb_set_par(struct fb_
|
||||
|
||||
if (!fb->cpuaddr) {
|
||||
fb->dma_addr = 0;
|
||||
- fb->disable_arm_alloc = true;
|
||||
+ fb->fbdev->disable_arm_alloc = true;
|
||||
} else {
|
||||
fb->image_size = image_size;
|
||||
}
|
||||
@@ -317,7 +413,7 @@ static int bcm2708_fb_set_par(struct fb_
|
||||
fbinfo.screen_size = image_size;
|
||||
fbinfo.pitch = (info->var.xres * info->var.bits_per_pixel) >> 3;
|
||||
|
||||
- ret = rpi_firmware_property_list(fb->fw, &fbinfo,
|
||||
+ ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
|
||||
sizeof(fbinfo));
|
||||
if (ret || fbinfo.base != fb->dma_addr) {
|
||||
/* Firmware either failed, or assigned a different base
|
||||
@@ -330,7 +426,7 @@ static int bcm2708_fb_set_par(struct fb_
|
||||
fb->image_size = 0;
|
||||
fb->cpuaddr = NULL;
|
||||
fb->dma_addr = 0;
|
||||
- fb->disable_arm_alloc = true;
|
||||
+ fb->fbdev->disable_arm_alloc = true;
|
||||
}
|
||||
} else {
|
||||
/* Our allocation failed - drop into the old scheme of
|
||||
@@ -349,7 +445,7 @@ static int bcm2708_fb_set_par(struct fb_
|
||||
fbinfo.tag6.tag = RPI_FIRMWARE_FRAMEBUFFER_GET_PITCH;
|
||||
fbinfo.pitch = 0;
|
||||
|
||||
- ret = rpi_firmware_property_list(fb->fw, &fbinfo,
|
||||
+ ret = rpi_firmware_property_list(fb->fbdev->fw, &fbinfo,
|
||||
sizeof(fbinfo));
|
||||
if (ret) {
|
||||
dev_err(info->device,
|
||||
@@ -439,7 +535,10 @@ static int bcm2708_fb_setcolreg(unsigned
|
||||
packet->length = regno + 1;
|
||||
memcpy(packet->cmap, fb->gpu_cmap,
|
||||
sizeof(packet->cmap));
|
||||
- ret = rpi_firmware_property(fb->fw,
|
||||
+
|
||||
+ set_display_num(fb);
|
||||
+
|
||||
+ ret = rpi_firmware_property(fb->fbdev->fw,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_PALETTE,
|
||||
packet,
|
||||
(2 + packet->length) * sizeof(u32));
|
||||
@@ -478,8 +577,11 @@ static int bcm2708_fb_blank(int blank_mo
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- ret = rpi_firmware_property(fb->fw, RPI_FIRMWARE_FRAMEBUFFER_BLANK,
|
||||
+ set_display_num(fb);
|
||||
+
|
||||
+ ret = rpi_firmware_property(fb->fbdev->fw, RPI_FIRMWARE_FRAMEBUFFER_BLANK,
|
||||
&value, sizeof(value));
|
||||
+
|
||||
if (ret)
|
||||
dev_err(info->device, "%s(%d) failed: %d\n", __func__,
|
||||
blank_mode, ret);
|
||||
@@ -496,12 +598,14 @@ static int bcm2708_fb_pan_display(struct
|
||||
info->var.yoffset = var->yoffset;
|
||||
result = bcm2708_fb_set_par(info);
|
||||
if (result != 0)
|
||||
- pr_err("%s(%d,%d) returns=%d\n", __func__, var->xoffset,
|
||||
+ pr_err("%s(%u,%u) returns=%d\n", __func__, var->xoffset,
|
||||
var->yoffset, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
|
||||
+static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd,
|
||||
+ unsigned long arg)
|
||||
{
|
||||
struct bcm2708_fb *fb = to_bcm2708(info);
|
||||
u32 dummy = 0;
|
||||
@@ -509,7 +613,9 @@ static int bcm2708_ioctl(struct fb_info
|
||||
|
||||
switch (cmd) {
|
||||
case FBIO_WAITFORVSYNC:
|
||||
- ret = rpi_firmware_property(fb->fw,
|
||||
+ set_display_num(fb);
|
||||
+
|
||||
+ ret = rpi_firmware_property(fb->fbdev->fw,
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC,
|
||||
&dummy, sizeof(dummy));
|
||||
break;
|
||||
@@ -526,23 +632,22 @@ static int bcm2708_ioctl(struct fb_info
|
||||
static void bcm2708_fb_fillrect(struct fb_info *info,
|
||||
const struct fb_fillrect *rect)
|
||||
{
|
||||
- /* (is called) print_debug("bcm2708_fb_fillrect\n"); */
|
||||
cfb_fillrect(info, rect);
|
||||
}
|
||||
|
||||
/* A helper function for configuring dma control block */
|
||||
static void set_dma_cb(struct bcm2708_dma_cb *cb,
|
||||
- int burst_size,
|
||||
- dma_addr_t dst,
|
||||
- int dst_stride,
|
||||
- dma_addr_t src,
|
||||
- int src_stride,
|
||||
- int w,
|
||||
- int h)
|
||||
+ int burst_size,
|
||||
+ dma_addr_t dst,
|
||||
+ int dst_stride,
|
||||
+ dma_addr_t src,
|
||||
+ int src_stride,
|
||||
+ int w,
|
||||
+ int h)
|
||||
{
|
||||
cb->info = BCM2708_DMA_BURST(burst_size) | BCM2708_DMA_S_WIDTH |
|
||||
- BCM2708_DMA_S_INC | BCM2708_DMA_D_WIDTH |
|
||||
- BCM2708_DMA_D_INC | BCM2708_DMA_TDMODE;
|
||||
+ BCM2708_DMA_S_INC | BCM2708_DMA_D_WIDTH |
|
||||
+ BCM2708_DMA_D_INC | BCM2708_DMA_TDMODE;
|
||||
cb->dst = dst;
|
||||
cb->src = src;
|
||||
/*
|
||||
@@ -560,15 +665,19 @@ static void bcm2708_fb_copyarea(struct f
|
||||
const struct fb_copyarea *region)
|
||||
{
|
||||
struct bcm2708_fb *fb = to_bcm2708(info);
|
||||
- struct bcm2708_dma_cb *cb = fb->cb_base;
|
||||
+ struct bcm2708_fb_dev *fbdev = fb->fbdev;
|
||||
+ struct bcm2708_dma_cb *cb = fbdev->cb_base;
|
||||
int bytes_per_pixel = (info->var.bits_per_pixel + 7) >> 3;
|
||||
|
||||
/* Channel 0 supports larger bursts and is a bit faster */
|
||||
- int burst_size = (fb->dma_chan == 0) ? 8 : 2;
|
||||
+ int burst_size = (fbdev->dma_chan == 0) ? 8 : 2;
|
||||
int pixels = region->width * region->height;
|
||||
|
||||
- /* Fallback to cfb_copyarea() if we don't like something */
|
||||
- if (bytes_per_pixel > 4 ||
|
||||
+ /* If DMA is currently in use (ie being used on another FB), then
|
||||
+ * rather than wait for it to finish, just use the cfb_copyarea
|
||||
+ */
|
||||
+ if (!mutex_trylock(&fbdev->dma_mutex) ||
|
||||
+ bytes_per_pixel > 4 ||
|
||||
info->var.xres * info->var.yres > 1920 * 1200 ||
|
||||
region->width <= 0 || region->width > info->var.xres ||
|
||||
region->height <= 0 || region->height > info->var.yres ||
|
||||
@@ -595,8 +704,8 @@ static void bcm2708_fb_copyarea(struct f
|
||||
* 1920x1200 resolution at 32bpp pixel depth.
|
||||
*/
|
||||
int y;
|
||||
- dma_addr_t control_block_pa = fb->cb_handle;
|
||||
- dma_addr_t scratchbuf = fb->cb_handle + 16 * 1024;
|
||||
+ dma_addr_t control_block_pa = fbdev->cb_handle;
|
||||
+ dma_addr_t scratchbuf = fbdev->cb_handle + 16 * 1024;
|
||||
int scanline_size = bytes_per_pixel * region->width;
|
||||
int scanlines_per_cb = (64 * 1024 - 16 * 1024) / scanline_size;
|
||||
|
||||
@@ -646,10 +755,10 @@ static void bcm2708_fb_copyarea(struct f
|
||||
}
|
||||
set_dma_cb(cb, burst_size,
|
||||
fb->fb_bus_address + dy * fb->fb.fix.line_length +
|
||||
- bytes_per_pixel * region->dx,
|
||||
+ bytes_per_pixel * region->dx,
|
||||
stride,
|
||||
fb->fb_bus_address + sy * fb->fb.fix.line_length +
|
||||
- bytes_per_pixel * region->sx,
|
||||
+ bytes_per_pixel * region->sx,
|
||||
stride,
|
||||
region->width * bytes_per_pixel,
|
||||
region->height);
|
||||
@@ -659,32 +768,33 @@ static void bcm2708_fb_copyarea(struct f
|
||||
cb->next = 0;
|
||||
|
||||
if (pixels < dma_busy_wait_threshold) {
|
||||
- bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
|
||||
- bcm_dma_wait_idle(fb->dma_chan_base);
|
||||
+ bcm_dma_start(fbdev->dma_chan_base, fbdev->cb_handle);
|
||||
+ bcm_dma_wait_idle(fbdev->dma_chan_base);
|
||||
} else {
|
||||
- void __iomem *dma_chan = fb->dma_chan_base;
|
||||
+ void __iomem *local_dma_chan = fbdev->dma_chan_base;
|
||||
|
||||
cb->info |= BCM2708_DMA_INT_EN;
|
||||
- bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
|
||||
- while (bcm_dma_is_busy(dma_chan)) {
|
||||
- wait_event_interruptible(fb->dma_waitq,
|
||||
- !bcm_dma_is_busy(dma_chan));
|
||||
+ bcm_dma_start(fbdev->dma_chan_base, fbdev->cb_handle);
|
||||
+ while (bcm_dma_is_busy(local_dma_chan)) {
|
||||
+ wait_event_interruptible(fbdev->dma_waitq,
|
||||
+ !bcm_dma_is_busy(local_dma_chan));
|
||||
}
|
||||
- fb->stats.dma_irqs++;
|
||||
+ fbdev->dma_stats.dma_irqs++;
|
||||
}
|
||||
- fb->stats.dma_copies++;
|
||||
+ fbdev->dma_stats.dma_copies++;
|
||||
+
|
||||
+ mutex_unlock(&fbdev->dma_mutex);
|
||||
}
|
||||
|
||||
static void bcm2708_fb_imageblit(struct fb_info *info,
|
||||
const struct fb_image *image)
|
||||
{
|
||||
- /* (is called) print_debug("bcm2708_fb_imageblit\n"); */
|
||||
cfb_imageblit(info, image);
|
||||
}
|
||||
|
||||
static irqreturn_t bcm2708_fb_dma_irq(int irq, void *cxt)
|
||||
{
|
||||
- struct bcm2708_fb *fb = cxt;
|
||||
+ struct bcm2708_fb_dev *fbdev = cxt;
|
||||
|
||||
/* FIXME: should read status register to check if this is
|
||||
* actually interrupting us or not, in case this interrupt
|
||||
@@ -694,9 +804,9 @@ static irqreturn_t bcm2708_fb_dma_irq(in
|
||||
*/
|
||||
|
||||
/* acknowledge the interrupt */
|
||||
- writel(BCM2708_DMA_INT, fb->dma_chan_base + BCM2708_DMA_CS);
|
||||
+ writel(BCM2708_DMA_INT, fbdev->dma_chan_base + BCM2708_DMA_CS);
|
||||
|
||||
- wake_up(&fb->dma_waitq);
|
||||
+ wake_up(&fbdev->dma_waitq);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
@@ -729,11 +839,23 @@ static int bcm2708_fb_register(struct bc
|
||||
fb->fb.fix.ywrapstep = 0;
|
||||
fb->fb.fix.accel = FB_ACCEL_NONE;
|
||||
|
||||
- fb->fb.var.xres = fbwidth;
|
||||
- fb->fb.var.yres = fbheight;
|
||||
- fb->fb.var.xres_virtual = fbwidth;
|
||||
- fb->fb.var.yres_virtual = fbheight;
|
||||
- fb->fb.var.bits_per_pixel = fbdepth;
|
||||
+ /* If we have data from the VC4 on FB's, use that, otherwise use the
|
||||
+ * module parameters
|
||||
+ */
|
||||
+ if (fb->display_settings.width) {
|
||||
+ fb->fb.var.xres = fb->display_settings.width;
|
||||
+ fb->fb.var.yres = fb->display_settings.height;
|
||||
+ fb->fb.var.xres_virtual = fb->fb.var.xres;
|
||||
+ fb->fb.var.yres_virtual = fb->fb.var.yres;
|
||||
+ fb->fb.var.bits_per_pixel = fb->display_settings.depth;
|
||||
+ } else {
|
||||
+ fb->fb.var.xres = fbwidth;
|
||||
+ fb->fb.var.yres = fbheight;
|
||||
+ fb->fb.var.xres_virtual = fbwidth;
|
||||
+ fb->fb.var.yres_virtual = fbheight;
|
||||
+ fb->fb.var.bits_per_pixel = fbdepth;
|
||||
+ }
|
||||
+
|
||||
fb->fb.var.vmode = FB_VMODE_NONINTERLACED;
|
||||
fb->fb.var.activate = FB_ACTIVATE_NOW;
|
||||
fb->fb.var.nonstd = 0;
|
||||
@@ -749,26 +871,23 @@ static int bcm2708_fb_register(struct bc
|
||||
fb->fb.monspecs.dclkmax = 100000000;
|
||||
|
||||
bcm2708_fb_set_bitfields(&fb->fb.var);
|
||||
- init_waitqueue_head(&fb->dma_waitq);
|
||||
|
||||
/*
|
||||
* Allocate colourmap.
|
||||
*/
|
||||
-
|
||||
fb_set_var(&fb->fb, &fb->fb.var);
|
||||
+
|
||||
ret = bcm2708_fb_set_par(&fb->fb);
|
||||
+
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- print_debug("BCM2708FB: registering framebuffer (%dx%d@%d) (%d)\n",
|
||||
- fbwidth, fbheight, fbdepth, fbswap);
|
||||
-
|
||||
ret = register_framebuffer(&fb->fb);
|
||||
- print_debug("BCM2708FB: register framebuffer (%d)\n", ret);
|
||||
+
|
||||
if (ret == 0)
|
||||
goto out;
|
||||
|
||||
- print_debug("BCM2708FB: cannot register framebuffer (%d)\n", ret);
|
||||
+ dev_warn(fb->fb.dev, "Unable to register framebuffer (%d)\n", ret);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
@@ -777,10 +896,18 @@ static int bcm2708_fb_probe(struct platf
|
||||
{
|
||||
struct device_node *fw_np;
|
||||
struct rpi_firmware *fw;
|
||||
- struct bcm2708_fb *fb;
|
||||
- int ret;
|
||||
+ int ret, i;
|
||||
+ u32 num_displays;
|
||||
+ struct bcm2708_fb_dev *fbdev;
|
||||
+ struct { u32 base, length; } gpu_mem;
|
||||
+
|
||||
+ fbdev = devm_kzalloc(&dev->dev, sizeof(*fbdev), GFP_KERNEL);
|
||||
+
|
||||
+ if (!fbdev)
|
||||
+ return -ENOMEM;
|
||||
|
||||
fw_np = of_parse_phandle(dev->dev.of_node, "firmware", 0);
|
||||
+
|
||||
/* Remove comment when booting without Device Tree is no longer supported
|
||||
* if (!fw_np) {
|
||||
* dev_err(&dev->dev, "Missing firmware node\n");
|
||||
@@ -788,90 +915,154 @@ static int bcm2708_fb_probe(struct platf
|
||||
* }
|
||||
*/
|
||||
fw = rpi_firmware_get(fw_np);
|
||||
+ fbdev->fw = fw;
|
||||
+
|
||||
if (!fw)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
- fb = kzalloc(sizeof(*fb), GFP_KERNEL);
|
||||
- if (!fb) {
|
||||
- ret = -ENOMEM;
|
||||
- goto free_region;
|
||||
+ ret = rpi_firmware_property(fw,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_NUM_DISPLAYS,
|
||||
+ &num_displays, sizeof(u32));
|
||||
+
|
||||
+ /* If we fail to get the number of displays, or it returns 0, then
|
||||
+ * assume old firmware that doesn't have the mailbox call, so just
|
||||
+ * set one display
|
||||
+ */
|
||||
+ if (ret || num_displays == 0) {
|
||||
+ num_displays = 1;
|
||||
+ dev_err(&dev->dev,
|
||||
+ "Unable to determine number of FB's. Assuming 1\n");
|
||||
+ ret = 0;
|
||||
+ } else {
|
||||
+ fbdev->firmware_supports_multifb = 1;
|
||||
+ }
|
||||
+
|
||||
+ if (num_displays > MAX_FRAMEBUFFERS) {
|
||||
+ dev_warn(&dev->dev,
|
||||
+ "More displays reported from firmware than supported in driver (%u vs %u)",
|
||||
+ num_displays, MAX_FRAMEBUFFERS);
|
||||
+ num_displays = MAX_FRAMEBUFFERS;
|
||||
}
|
||||
|
||||
- fb->fw = fw;
|
||||
- bcm2708_fb_debugfs_init(fb);
|
||||
+ dev_info(&dev->dev, "FB found %d display(s)\n", num_displays);
|
||||
+
|
||||
+ /* Set up the DMA information. Note we have just one set of DMA
|
||||
+ * parameters to work with all the FB's so requires synchronising when
|
||||
+ * being used
|
||||
+ */
|
||||
+
|
||||
+ mutex_init(&fbdev->dma_mutex);
|
||||
|
||||
- fb->cb_base = dma_alloc_wc(&dev->dev, SZ_64K,
|
||||
- &fb->cb_handle, GFP_KERNEL);
|
||||
- if (!fb->cb_base) {
|
||||
+ fbdev->cb_base = dma_alloc_wc(&dev->dev, SZ_64K,
|
||||
+ &fbdev->cb_handle,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!fbdev->cb_base) {
|
||||
dev_err(&dev->dev, "cannot allocate DMA CBs\n");
|
||||
ret = -ENOMEM;
|
||||
goto free_fb;
|
||||
}
|
||||
|
||||
- pr_info("BCM2708FB: allocated DMA memory %pad\n", &fb->cb_handle);
|
||||
-
|
||||
ret = bcm_dma_chan_alloc(BCM_DMA_FEATURE_BULK,
|
||||
- &fb->dma_chan_base, &fb->dma_irq);
|
||||
+ &fbdev->dma_chan_base,
|
||||
+ &fbdev->dma_irq);
|
||||
if (ret < 0) {
|
||||
- dev_err(&dev->dev, "couldn't allocate a DMA channel\n");
|
||||
+ dev_err(&dev->dev, "Couldn't allocate a DMA channel\n");
|
||||
goto free_cb;
|
||||
}
|
||||
- fb->dma_chan = ret;
|
||||
+ fbdev->dma_chan = ret;
|
||||
|
||||
- ret = request_irq(fb->dma_irq, bcm2708_fb_dma_irq,
|
||||
- 0, "bcm2708_fb dma", fb);
|
||||
+ ret = request_irq(fbdev->dma_irq, bcm2708_fb_dma_irq,
|
||||
+ 0, "bcm2708_fb DMA", fbdev);
|
||||
if (ret) {
|
||||
- pr_err("%s: failed to request DMA irq\n", __func__);
|
||||
+ dev_err(&dev->dev,
|
||||
+ "Failed to request DMA irq\n");
|
||||
goto free_dma_chan;
|
||||
}
|
||||
|
||||
- pr_info("BCM2708FB: allocated DMA channel %d\n", fb->dma_chan);
|
||||
+ rpi_firmware_property(fbdev->fw,
|
||||
+ RPI_FIRMWARE_GET_VC_MEMORY,
|
||||
+ &gpu_mem, sizeof(gpu_mem));
|
||||
+
|
||||
+ for (i = 0; i < num_displays; i++) {
|
||||
+ struct bcm2708_fb *fb = &fbdev->displays[i];
|
||||
+
|
||||
+ fb->display_settings.display_num = i;
|
||||
+ fb->dev = dev;
|
||||
+ fb->fb.device = &dev->dev;
|
||||
+ fb->fbdev = fbdev;
|
||||
+
|
||||
+ fb->gpu.base = gpu_mem.base;
|
||||
+ fb->gpu.length = gpu_mem.length;
|
||||
+
|
||||
+ if (fbdev->firmware_supports_multifb) {
|
||||
+ ret = rpi_firmware_property(fw,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_GET_DISPLAY_SETTINGS,
|
||||
+ &fb->display_settings,
|
||||
+ GET_DISPLAY_SETTINGS_PAYLOAD_SIZE);
|
||||
+ } else {
|
||||
+ memset(&fb->display_settings, 0,
|
||||
+ sizeof(fb->display_settings));
|
||||
+ }
|
||||
|
||||
- fb->dev = dev;
|
||||
- fb->fb.device = &dev->dev;
|
||||
+ ret = bcm2708_fb_register(fb);
|
||||
|
||||
- /* failure here isn't fatal, but we'll fail in vc_mem_copy if
|
||||
- * fb->gpu is not valid
|
||||
- */
|
||||
- rpi_firmware_property(fb->fw, RPI_FIRMWARE_GET_VC_MEMORY, &fb->gpu,
|
||||
- sizeof(fb->gpu));
|
||||
+ if (ret == 0) {
|
||||
+ bcm2708_fb_debugfs_init(fb);
|
||||
|
||||
- ret = bcm2708_fb_register(fb);
|
||||
- if (ret == 0) {
|
||||
- platform_set_drvdata(dev, fb);
|
||||
- goto out;
|
||||
+ fbdev->num_displays++;
|
||||
+
|
||||
+ dev_info(&dev->dev,
|
||||
+ "Registered framebuffer for display %u, size %ux%u\n",
|
||||
+ fb->display_settings.display_num,
|
||||
+ fb->fb.var.xres,
|
||||
+ fb->fb.var.yres);
|
||||
+ } else {
|
||||
+ // Use this to flag if this FB entry is in use.
|
||||
+ fb->fbdev = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Did we actually successfully create any FB's?
|
||||
+ if (fbdev->num_displays) {
|
||||
+ init_waitqueue_head(&fbdev->dma_waitq);
|
||||
+ platform_set_drvdata(dev, fbdev);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
free_dma_chan:
|
||||
- bcm_dma_chan_free(fb->dma_chan);
|
||||
+ bcm_dma_chan_free(fbdev->dma_chan);
|
||||
free_cb:
|
||||
- dma_free_wc(&dev->dev, SZ_64K, fb->cb_base, fb->cb_handle);
|
||||
+ dma_free_wc(&dev->dev, SZ_64K, fbdev->cb_base,
|
||||
+ fbdev->cb_handle);
|
||||
free_fb:
|
||||
- kfree(fb);
|
||||
-free_region:
|
||||
dev_err(&dev->dev, "probe failed, err %d\n", ret);
|
||||
-out:
|
||||
+
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bcm2708_fb_remove(struct platform_device *dev)
|
||||
{
|
||||
- struct bcm2708_fb *fb = platform_get_drvdata(dev);
|
||||
+ struct bcm2708_fb_dev *fbdev = platform_get_drvdata(dev);
|
||||
+ int i;
|
||||
|
||||
platform_set_drvdata(dev, NULL);
|
||||
|
||||
- if (fb->fb.screen_base)
|
||||
- iounmap(fb->fb.screen_base);
|
||||
- unregister_framebuffer(&fb->fb);
|
||||
-
|
||||
- dma_free_wc(&dev->dev, SZ_64K, fb->cb_base, fb->cb_handle);
|
||||
- bcm_dma_chan_free(fb->dma_chan);
|
||||
-
|
||||
- bcm2708_fb_debugfs_deinit(fb);
|
||||
+ for (i = 0; i < fbdev->num_displays; i++) {
|
||||
+ if (fbdev->displays[i].fb.screen_base)
|
||||
+ iounmap(fbdev->displays[i].fb.screen_base);
|
||||
+
|
||||
+ if (fbdev->displays[i].fbdev) {
|
||||
+ unregister_framebuffer(&fbdev->displays[i].fb);
|
||||
+ bcm2708_fb_debugfs_deinit(&fbdev->displays[i]);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- free_irq(fb->dma_irq, fb);
|
||||
+ dma_free_wc(&dev->dev, SZ_64K, fbdev->cb_base,
|
||||
+ fbdev->cb_handle);
|
||||
+ bcm_dma_chan_free(fbdev->dma_chan);
|
||||
+ free_irq(fbdev->dma_irq, fbdev);
|
||||
|
||||
- kfree(fb);
|
||||
+ mutex_destroy(&fbdev->dma_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -886,10 +1077,10 @@ static struct platform_driver bcm2708_fb
|
||||
.probe = bcm2708_fb_probe,
|
||||
.remove = bcm2708_fb_remove,
|
||||
.driver = {
|
||||
- .name = DRIVER_NAME,
|
||||
- .owner = THIS_MODULE,
|
||||
- .of_match_table = bcm2708_fb_of_match_table,
|
||||
- },
|
||||
+ .name = DRIVER_NAME,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .of_match_table = bcm2708_fb_of_match_table,
|
||||
+ },
|
||||
};
|
||||
|
||||
static int __init bcm2708_fb_init(void)
|
@ -0,0 +1,337 @@
|
||||
From ba7d542d535059fe6e1a19c2a7cff811c01513c7 Mon Sep 17 00:00:00 2001
|
||||
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
|
||||
Date: Mon, 17 Jun 2013 13:32:11 +0300
|
||||
Subject: [PATCH 0090/1085] fbdev: add FBIOCOPYAREA ioctl
|
||||
|
||||
Based on the patch authored by Ali Gholami Rudi at
|
||||
https://lkml.org/lkml/2009/7/13/153
|
||||
|
||||
Provide an ioctl for userspace applications, but only if this operation
|
||||
is hardware accelerated (otherwide it does not make any sense).
|
||||
|
||||
Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
|
||||
|
||||
bcm2708_fb: Add ioctl for reading gpu memory through dma
|
||||
|
||||
video: bcm2708_fb: Add compat_ioctl support.
|
||||
|
||||
When using a 64 bit kernel with 32 bit userspace we need
|
||||
compat ioctl handling for FBIODMACOPY as one of the
|
||||
parameters is a pointer.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
---
|
||||
drivers/video/fbdev/bcm2708_fb.c | 170 ++++++++++++++++++++++++++-
|
||||
drivers/video/fbdev/core/fb_chrdev.c | 35 ++++++
|
||||
include/uapi/linux/fb.h | 12 ++
|
||||
3 files changed, 213 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/video/fbdev/bcm2708_fb.c
|
||||
+++ b/drivers/video/fbdev/bcm2708_fb.c
|
||||
@@ -32,8 +32,10 @@
|
||||
#include <linux/printk.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/debugfs.h>
|
||||
+#include <linux/uaccess.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
+#include <linux/cred.h>
|
||||
#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
@@ -184,9 +186,6 @@ static int bcm2708_fb_debugfs_init(struc
|
||||
|
||||
fb->debugfs_subdir = debugfs_create_dir(buf, fb->debugfs_dir);
|
||||
|
||||
- debugfs_create_regset32("stats", 0444, fb->debugfs_dir,
|
||||
- &fb->stats.regset);
|
||||
-
|
||||
if (!fb->debugfs_subdir) {
|
||||
dev_warn(fb->fb.dev, "%s: could not create debugfs entry %u\n",
|
||||
__func__, fb->display_settings.display_num);
|
||||
@@ -603,7 +602,110 @@ static int bcm2708_fb_pan_display(struct
|
||||
return result;
|
||||
}
|
||||
|
||||
-static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
|
||||
+static void dma_memcpy(struct bcm2708_fb *fb, dma_addr_t dst, dma_addr_t src,
|
||||
+ int size)
|
||||
+{
|
||||
+ struct bcm2708_fb_dev *fbdev = fb->fbdev;
|
||||
+ struct bcm2708_dma_cb *cb = fbdev->cb_base;
|
||||
+ int burst_size = (fbdev->dma_chan == 0) ? 8 : 2;
|
||||
+
|
||||
+ cb->info = BCM2708_DMA_BURST(burst_size) | BCM2708_DMA_S_WIDTH |
|
||||
+ BCM2708_DMA_S_INC | BCM2708_DMA_D_WIDTH |
|
||||
+ BCM2708_DMA_D_INC;
|
||||
+ cb->dst = dst;
|
||||
+ cb->src = src;
|
||||
+ cb->length = size;
|
||||
+ cb->stride = 0;
|
||||
+ cb->pad[0] = 0;
|
||||
+ cb->pad[1] = 0;
|
||||
+ cb->next = 0;
|
||||
+
|
||||
+ // Not sure what to do if this gets a signal whilst waiting
|
||||
+ if (mutex_lock_interruptible(&fbdev->dma_mutex))
|
||||
+ return;
|
||||
+
|
||||
+ if (size < dma_busy_wait_threshold) {
|
||||
+ bcm_dma_start(fbdev->dma_chan_base, fbdev->cb_handle);
|
||||
+ bcm_dma_wait_idle(fbdev->dma_chan_base);
|
||||
+ } else {
|
||||
+ void __iomem *local_dma_chan = fbdev->dma_chan_base;
|
||||
+
|
||||
+ cb->info |= BCM2708_DMA_INT_EN;
|
||||
+ bcm_dma_start(fbdev->dma_chan_base, fbdev->cb_handle);
|
||||
+ while (bcm_dma_is_busy(local_dma_chan)) {
|
||||
+ wait_event_interruptible(fbdev->dma_waitq,
|
||||
+ !bcm_dma_is_busy(local_dma_chan));
|
||||
+ }
|
||||
+ fbdev->dma_stats.dma_irqs++;
|
||||
+ }
|
||||
+ fbdev->dma_stats.dma_copies++;
|
||||
+
|
||||
+ mutex_unlock(&fbdev->dma_mutex);
|
||||
+}
|
||||
+
|
||||
+/* address with no aliases */
|
||||
+#define INTALIAS_NORMAL(x) ((x) & ~0xc0000000)
|
||||
+/* cache coherent but non-allocating in L1 and L2 */
|
||||
+#define INTALIAS_L1L2_NONALLOCATING(x) (((x) & ~0xc0000000) | 0x80000000)
|
||||
+
|
||||
+static long vc_mem_copy(struct bcm2708_fb *fb, struct fb_dmacopy *ioparam)
|
||||
+{
|
||||
+ size_t size = PAGE_SIZE;
|
||||
+ u32 *buf = NULL;
|
||||
+ dma_addr_t bus_addr;
|
||||
+ long rc = 0;
|
||||
+ size_t offset;
|
||||
+
|
||||
+ /* restrict this to root user */
|
||||
+ if (!uid_eq(current_euid(), GLOBAL_ROOT_UID)) {
|
||||
+ rc = -EFAULT;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (!fb->gpu.base || !fb->gpu.length) {
|
||||
+ pr_err("[%s]: Unable to determine gpu memory (%x,%x)\n",
|
||||
+ __func__, fb->gpu.base, fb->gpu.length);
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ if (INTALIAS_NORMAL(ioparam->src) < fb->gpu.base ||
|
||||
+ INTALIAS_NORMAL(ioparam->src) >= fb->gpu.base + fb->gpu.length) {
|
||||
+ pr_err("[%s]: Invalid memory access %x (%x-%x)", __func__,
|
||||
+ INTALIAS_NORMAL(ioparam->src), fb->gpu.base,
|
||||
+ fb->gpu.base + fb->gpu.length);
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ buf = dma_alloc_coherent(fb->fb.device, PAGE_ALIGN(size), &bus_addr,
|
||||
+ GFP_ATOMIC);
|
||||
+ if (!buf) {
|
||||
+ pr_err("[%s]: failed to dma_alloc_coherent(%zd)\n", __func__,
|
||||
+ size);
|
||||
+ rc = -ENOMEM;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ for (offset = 0; offset < ioparam->length; offset += size) {
|
||||
+ size_t remaining = ioparam->length - offset;
|
||||
+ size_t s = min(size, remaining);
|
||||
+ u8 *p = (u8 *)((uintptr_t)ioparam->src + offset);
|
||||
+ u8 *q = (u8 *)ioparam->dst + offset;
|
||||
+
|
||||
+ dma_memcpy(fb, bus_addr,
|
||||
+ INTALIAS_L1L2_NONALLOCATING((dma_addr_t)p), size);
|
||||
+ if (copy_to_user(q, buf, s) != 0) {
|
||||
+ pr_err("[%s]: failed to copy-to-user\n", __func__);
|
||||
+ rc = -EFAULT;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ }
|
||||
+out:
|
||||
+ if (buf)
|
||||
+ dma_free_coherent(fb->fb.device, PAGE_ALIGN(size), buf,
|
||||
+ bus_addr);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static int bcm2708_ioctl(struct fb_info *info, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
@@ -619,6 +721,21 @@ static int bcm2708_ioctl(struct fb_info
|
||||
RPI_FIRMWARE_FRAMEBUFFER_SET_VSYNC,
|
||||
&dummy, sizeof(dummy));
|
||||
break;
|
||||
+
|
||||
+ case FBIODMACOPY:
|
||||
+ {
|
||||
+ struct fb_dmacopy ioparam;
|
||||
+ /* Get the parameter data.
|
||||
+ */
|
||||
+ if (copy_from_user
|
||||
+ (&ioparam, (void *)arg, sizeof(ioparam))) {
|
||||
+ pr_err("[%s]: failed to copy-from-user\n", __func__);
|
||||
+ ret = -EFAULT;
|
||||
+ break;
|
||||
+ }
|
||||
+ ret = vc_mem_copy(fb, &ioparam);
|
||||
+ break;
|
||||
+ }
|
||||
default:
|
||||
dev_dbg(info->device, "Unknown ioctl 0x%x\n", cmd);
|
||||
return -ENOTTY;
|
||||
@@ -629,6 +746,48 @@ static int bcm2708_ioctl(struct fb_info
|
||||
|
||||
return ret;
|
||||
}
|
||||
+
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+struct fb_dmacopy32 {
|
||||
+ compat_uptr_t dst;
|
||||
+ __u32 src;
|
||||
+ __u32 length;
|
||||
+};
|
||||
+
|
||||
+#define FBIODMACOPY32 _IOW('z', 0x22, struct fb_dmacopy32)
|
||||
+
|
||||
+static int bcm2708_compat_ioctl(struct fb_info *info, unsigned int cmd,
|
||||
+ unsigned long arg)
|
||||
+{
|
||||
+ struct bcm2708_fb *fb = to_bcm2708(info);
|
||||
+ int ret;
|
||||
+
|
||||
+ switch (cmd) {
|
||||
+ case FBIODMACOPY32:
|
||||
+ {
|
||||
+ struct fb_dmacopy32 param32;
|
||||
+ struct fb_dmacopy param;
|
||||
+ /* Get the parameter data.
|
||||
+ */
|
||||
+ if (copy_from_user(¶m32, (void *)arg, sizeof(param32))) {
|
||||
+ pr_err("[%s]: failed to copy-from-user\n", __func__);
|
||||
+ ret = -EFAULT;
|
||||
+ break;
|
||||
+ }
|
||||
+ param.dst = compat_ptr(param32.dst);
|
||||
+ param.src = param32.src;
|
||||
+ param.length = param32.length;
|
||||
+ ret = vc_mem_copy(fb, ¶m);
|
||||
+ break;
|
||||
+ }
|
||||
+ default:
|
||||
+ ret = bcm2708_ioctl(info, cmd, arg);
|
||||
+ break;
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void bcm2708_fb_fillrect(struct fb_info *info,
|
||||
const struct fb_fillrect *rect)
|
||||
{
|
||||
@@ -821,6 +980,9 @@ static struct fb_ops bcm2708_fb_ops = {
|
||||
.fb_imageblit = bcm2708_fb_imageblit,
|
||||
.fb_pan_display = bcm2708_fb_pan_display,
|
||||
.fb_ioctl = bcm2708_ioctl,
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+ .fb_compat_ioctl = bcm2708_compat_ioctl,
|
||||
+#endif
|
||||
};
|
||||
|
||||
static int bcm2708_fb_register(struct bcm2708_fb *fb)
|
||||
--- a/drivers/video/fbdev/core/fb_chrdev.c
|
||||
+++ b/drivers/video/fbdev/core/fb_chrdev.c
|
||||
@@ -59,6 +59,30 @@ static ssize_t fb_write(struct file *fil
|
||||
return fb_io_write(info, buf, count, ppos);
|
||||
}
|
||||
|
||||
+static int fb_copyarea_user(struct fb_info *info,
|
||||
+ struct fb_copyarea *copy)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+ lock_fb_info(info);
|
||||
+ if (copy->dx >= info->var.xres ||
|
||||
+ copy->sx >= info->var.xres ||
|
||||
+ copy->width > info->var.xres ||
|
||||
+ copy->dy >= info->var.yres ||
|
||||
+ copy->sy >= info->var.yres ||
|
||||
+ copy->height > info->var.yres ||
|
||||
+ copy->dx + copy->width > info->var.xres ||
|
||||
+ copy->sx + copy->width > info->var.xres ||
|
||||
+ copy->dy + copy->height > info->var.yres ||
|
||||
+ copy->sy + copy->height > info->var.yres) {
|
||||
+ ret = -EINVAL;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ info->fbops->fb_copyarea(info, copy);
|
||||
+out:
|
||||
+ unlock_fb_info(info);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
@@ -67,6 +91,7 @@ static long do_fb_ioctl(struct fb_info *
|
||||
struct fb_fix_screeninfo fix;
|
||||
struct fb_cmap cmap_from;
|
||||
struct fb_cmap_user cmap;
|
||||
+ struct fb_copyarea copy;
|
||||
void __user *argp = (void __user *)arg;
|
||||
long ret = 0;
|
||||
|
||||
@@ -148,6 +173,15 @@ static long do_fb_ioctl(struct fb_info *
|
||||
unlock_fb_info(info);
|
||||
console_unlock();
|
||||
break;
|
||||
+ case FBIOCOPYAREA:
|
||||
+ if (info->flags & FBINFO_HWACCEL_COPYAREA) {
|
||||
+ /* only provide this ioctl if it is accelerated */
|
||||
+ if (copy_from_user(©, argp, sizeof(copy)))
|
||||
+ return -EFAULT;
|
||||
+ ret = fb_copyarea_user(info, ©);
|
||||
+ break;
|
||||
+ }
|
||||
+ fallthrough;
|
||||
default:
|
||||
lock_fb_info(info);
|
||||
fb = info->fbops;
|
||||
@@ -287,6 +321,7 @@ static long fb_compat_ioctl(struct file
|
||||
case FBIOPAN_DISPLAY:
|
||||
case FBIOGET_CON2FBMAP:
|
||||
case FBIOPUT_CON2FBMAP:
|
||||
+ case FBIOCOPYAREA:
|
||||
arg = (unsigned long) compat_ptr(arg);
|
||||
fallthrough;
|
||||
case FBIOBLANK:
|
||||
--- a/include/uapi/linux/fb.h
|
||||
+++ b/include/uapi/linux/fb.h
|
||||
@@ -35,6 +35,12 @@
|
||||
#define FBIOPUT_MODEINFO 0x4617
|
||||
#define FBIOGET_DISPINFO 0x4618
|
||||
#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
|
||||
+/*
|
||||
+ * HACK: use 'z' in order not to clash with any other ioctl numbers which might
|
||||
+ * be concurrently added to the mainline kernel
|
||||
+ */
|
||||
+#define FBIOCOPYAREA _IOW('z', 0x21, struct fb_copyarea)
|
||||
+#define FBIODMACOPY _IOW('z', 0x22, struct fb_dmacopy)
|
||||
|
||||
#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
|
||||
#define FB_TYPE_PLANES 1 /* Non interleaved planes */
|
||||
@@ -348,6 +354,12 @@ struct fb_copyarea {
|
||||
__u32 sy;
|
||||
};
|
||||
|
||||
+struct fb_dmacopy {
|
||||
+ void *dst;
|
||||
+ __u32 src;
|
||||
+ __u32 length;
|
||||
+};
|
||||
+
|
||||
struct fb_fillrect {
|
||||
__u32 dx; /* screen-relative */
|
||||
__u32 dy;
|
@ -0,0 +1,652 @@
|
||||
From df4d44270dc3bcce85f017bc2ed988867d3ad930 Mon Sep 17 00:00:00 2001
|
||||
From: Florian Meier <florian.meier@koalo.de>
|
||||
Date: Fri, 22 Nov 2013 14:22:53 +0100
|
||||
Subject: [PATCH 0091/1085] dmaengine: Add support for BCM2708
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add support for DMA controller of BCM2708 as used in the Raspberry Pi.
|
||||
Currently it only supports cyclic DMA.
|
||||
|
||||
Signed-off-by: Florian Meier <florian.meier@koalo.de>
|
||||
|
||||
dmaengine: expand functionality by supporting scatter/gather transfers sdhci-bcm2708 and dma.c: fix for LITE channels
|
||||
|
||||
DMA: fix cyclic LITE length overflow bug
|
||||
|
||||
dmaengine: bcm2708: Remove chancnt affectations
|
||||
|
||||
Mirror bcm2835-dma.c commit 9eba5536a7434c69d8c185d4bd1c70734d92287d:
|
||||
chancnt is already filled by dma_async_device_register, which uses the channel
|
||||
list to know how much channels there is.
|
||||
|
||||
Since it's already filled, we can safely remove it from the drivers' probe
|
||||
function.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: overwrite dreq only if it is not set
|
||||
|
||||
dreq is set when the DMA channel is fetched from Device Tree.
|
||||
slave_id is set using dmaengine_slave_config().
|
||||
Only overwrite dreq with slave_id if it is not set.
|
||||
|
||||
dreq/slave_id in the cyclic DMA case is not touched, because I don't
|
||||
have hardware to test with.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: do device registration in the board file
|
||||
|
||||
Don't register the device in the driver. Do it in the board file.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: don't restrict DT support to ARCH_BCM2835
|
||||
|
||||
Both ARCH_BCM2835 and ARCH_BCM270x are built with OF now.
|
||||
Add Device Tree support to the non ARCH_BCM2835 case.
|
||||
Use the same driver name regardless of architecture.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
BCM270x_DT: add bcm2835-dma entry
|
||||
|
||||
Add Device Tree entry for bcm2835-dma.
|
||||
The entry doesn't contain any resources since they are handled
|
||||
by the arch/arm/mach-bcm270x/dma.c driver.
|
||||
In non-DT mode, don't add the device in the board file.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
bcm2708-dmaengine: Add debug options
|
||||
|
||||
BCM270x: Add memory and irq resources to dmaengine device and DT
|
||||
|
||||
Prepare for merging of the legacy DMA API arch driver dma.c
|
||||
with bcm2708-dmaengine by adding memory and irq resources both
|
||||
to platform file device and Device Tree node.
|
||||
Don't use BCM_DMAMAN_DRIVER_NAME so we don't have to include mach/dma.h
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: Merge with arch dma.c driver and disable dma.c
|
||||
|
||||
Merge the legacy DMA API driver with bcm2708-dmaengine.
|
||||
This is done so we can use bcm2708_fb on ARCH_BCM2835 (mailbox
|
||||
driver is also needed).
|
||||
|
||||
Changes to the dma.c code:
|
||||
- Use BIT() macro.
|
||||
- Cutdown some comments to one line.
|
||||
- Add mutex to vc_dmaman and use this, since the dev lock is locked
|
||||
during probing of the engine part.
|
||||
- Add global g_dmaman variable since drvdata is used by the engine part.
|
||||
- Restructure for readability:
|
||||
vc_dmaman_chan_alloc()
|
||||
vc_dmaman_chan_free()
|
||||
bcm_dma_chan_free()
|
||||
- Restructure bcm_dma_chan_alloc() to simplify error handling.
|
||||
- Use device irq resources instead of hardcoded bcm_dma_irqs table.
|
||||
- Remove dev_dmaman_register() and code it directly.
|
||||
- Remove dev_dmaman_deregister() and code it directly.
|
||||
- Simplify bcm_dmaman_probe() using devm_* functions.
|
||||
- Get dmachans from DT if available.
|
||||
- Keep 'dma.dmachans' module argument name for backwards compatibility.
|
||||
|
||||
Make it available on ARCH_BCM2835 as well.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: set residue_granularity field
|
||||
|
||||
bcm2708-dmaengine supports residue reporting at burst level
|
||||
but didn't report this via the residue_granularity field.
|
||||
|
||||
Without this field set properly we get playback issues with I2S cards.
|
||||
|
||||
dmaengine: bcm2708-dmaengine: Fix memory leak when stopping a running transfer
|
||||
|
||||
bcm2708-dmaengine: Use more DMA channels (but not 12)
|
||||
|
||||
1) Only the bcm2708_fb drivers uses the legacy DMA API, and
|
||||
it requires a BULK-capable channel, so all other types
|
||||
(FAST, NORMAL and LITE) can be made available to the regular
|
||||
DMA API.
|
||||
|
||||
2) DMA channels 11-14 share an interrupt. The driver can't
|
||||
handle this, so don't use channels 12-14 (12 was used, probably
|
||||
because it appears to have an interrupt, but in reality that
|
||||
interrupt is for activity on ANY channel). This may explain
|
||||
a lockup encountered when running out of DMA channels.
|
||||
|
||||
The combined effect of this patch is to leave 7 DMA channels
|
||||
available + channel 0 for bcm2708_fb via the legacy API.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/1110
|
||||
https://github.com/raspberrypi/linux/issues/1108
|
||||
|
||||
dmaengine: bcm2708: Make legacy API available for bcm2835-dma
|
||||
|
||||
bcm2708_fb uses the legacy DMA API, so in order to start using
|
||||
bcm2835-dma, bcm2835-dma has to support the legacy API. Make this
|
||||
possible by exporting bcm_dmaman_probe() and bcm_dmaman_remove().
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: Change DT compatible string
|
||||
|
||||
Both bcm2835-dma and bcm2708-dmaengine have the same compatible string.
|
||||
So change compatible to "brcm,bcm2708-dma".
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
dmaengine: bcm2708: Remove driver but keep legacy API
|
||||
|
||||
Dropping non-DT support means we don't need this driver,
|
||||
but we still need the legacy DMA API.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
bcm2708-dmaengine - Fix arm64 portability/build issues
|
||||
|
||||
dma-bcm2708: Fix module compilation of CONFIG_DMA_BCM2708
|
||||
|
||||
bcm2708-dmaengine.c defines functions like bcm_dma_start which are
|
||||
defined as well in dma-bcm2708.h as inline versions when
|
||||
CONFIG_DMA_BCM2708 is not defined. This works fine when
|
||||
CONFIG_DMA_BCM2708 is built in, but when it is selected as module build
|
||||
fails with redefinition errors because in the build system when
|
||||
CONFIG_DMA_BCM2708 is selected as module, the macro becomes
|
||||
CONFIG_DMA_BCM2708_MODULE.
|
||||
|
||||
This patch makes the header use CONFIG_DMA_BCM2708_MODULE too when
|
||||
available.
|
||||
|
||||
Fixes https://github.com/raspberrypi/linux/issues/2056
|
||||
|
||||
Signed-off-by: Andrei Gherzan <andrei@gherzan.com>
|
||||
|
||||
bcm2708-dmaengine: Use platform_get_irq
|
||||
|
||||
The platform driver framework no longer creates IRQ resources for
|
||||
platform devices because they are expected to use platform_get_irq.
|
||||
This causes the bcm2808_fb acceleration to fail.
|
||||
|
||||
Fix the problem by calling platform_get_irq as intended.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/5131
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
drivers/dma/Kconfig | 6 +-
|
||||
drivers/dma/Makefile | 1 +
|
||||
drivers/dma/bcm2708-dmaengine.c | 281 ++++++++++++++++++++++
|
||||
include/linux/platform_data/dma-bcm2708.h | 143 +++++++++++
|
||||
4 files changed, 430 insertions(+), 1 deletion(-)
|
||||
create mode 100644 drivers/dma/bcm2708-dmaengine.c
|
||||
create mode 100644 include/linux/platform_data/dma-bcm2708.h
|
||||
|
||||
--- a/drivers/dma/Kconfig
|
||||
+++ b/drivers/dma/Kconfig
|
||||
@@ -136,7 +136,7 @@ config BCM_SBA_RAID
|
||||
|
||||
config DMA_BCM2835
|
||||
tristate "BCM2835 DMA engine support"
|
||||
- depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
|
||||
+ depends on ARCH_BCM2835
|
||||
select DMA_ENGINE
|
||||
select DMA_VIRTUAL_CHANNELS
|
||||
|
||||
@@ -669,6 +669,10 @@ config UNIPHIER_XDMAC
|
||||
UniPhier platform. This DMA controller can transfer data from
|
||||
memory to memory, memory to peripheral and peripheral to memory.
|
||||
|
||||
+config DMA_BCM2708
|
||||
+ tristate "BCM2708 DMA legacy API support"
|
||||
+ depends on DMA_BCM2835
|
||||
+
|
||||
config XGENE_DMA
|
||||
tristate "APM X-Gene DMA support"
|
||||
depends on ARCH_XGENE || COMPILE_TEST
|
||||
--- a/drivers/dma/Makefile
|
||||
+++ b/drivers/dma/Makefile
|
||||
@@ -22,6 +22,7 @@ obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
|
||||
obj-$(CONFIG_AT_XDMAC) += at_xdmac.o
|
||||
obj-$(CONFIG_AXI_DMAC) += dma-axi-dmac.o
|
||||
obj-$(CONFIG_BCM_SBA_RAID) += bcm-sba-raid.o
|
||||
+obj-$(CONFIG_DMA_BCM2708) += bcm2708-dmaengine.o
|
||||
obj-$(CONFIG_DMA_BCM2835) += bcm2835-dma.o
|
||||
obj-$(CONFIG_DMA_JZ4780) += dma-jz4780.o
|
||||
obj-$(CONFIG_DMA_SA11X0) += sa11x0-dma.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/dma/bcm2708-dmaengine.c
|
||||
@@ -0,0 +1,281 @@
|
||||
+/*
|
||||
+ * BCM2708 legacy DMA API
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/list.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/platform_data/dma-bcm2708.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/spinlock.h>
|
||||
+
|
||||
+#include "virt-dma.h"
|
||||
+
|
||||
+#define CACHE_LINE_MASK 31
|
||||
+#define DEFAULT_DMACHAN_BITMAP 0x10 /* channel 4 only */
|
||||
+
|
||||
+/* valid only for channels 0 - 14, 15 has its own base address */
|
||||
+#define BCM2708_DMA_CHAN(n) ((n) << 8) /* base address */
|
||||
+#define BCM2708_DMA_CHANIO(dma_base, n) \
|
||||
+ ((void __iomem *)((char *)(dma_base) + BCM2708_DMA_CHAN(n)))
|
||||
+
|
||||
+struct vc_dmaman {
|
||||
+ void __iomem *dma_base;
|
||||
+ u32 chan_available; /* bitmap of available channels */
|
||||
+ u32 has_feature[BCM_DMA_FEATURE_COUNT]; /* bitmap of feature presence */
|
||||
+ struct mutex lock;
|
||||
+};
|
||||
+
|
||||
+static struct device *dmaman_dev; /* we assume there's only one! */
|
||||
+static struct vc_dmaman *g_dmaman; /* DMA manager */
|
||||
+
|
||||
+/* DMA Auxiliary Functions */
|
||||
+
|
||||
+/* A DMA buffer on an arbitrary boundary may separate a cache line into a
|
||||
+ section inside the DMA buffer and another section outside it.
|
||||
+ Even if we flush DMA buffers from the cache there is always the chance that
|
||||
+ during a DMA someone will access the part of a cache line that is outside
|
||||
+ the DMA buffer - which will then bring in unwelcome data.
|
||||
+ Without being able to dictate our own buffer pools we must insist that
|
||||
+ DMA buffers consist of a whole number of cache lines.
|
||||
+*/
|
||||
+extern int bcm_sg_suitable_for_dma(struct scatterlist *sg_ptr, int sg_len)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < sg_len; i++) {
|
||||
+ if (sg_ptr[i].offset & CACHE_LINE_MASK ||
|
||||
+ sg_ptr[i].length & CACHE_LINE_MASK)
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_sg_suitable_for_dma);
|
||||
+
|
||||
+extern void bcm_dma_start(void __iomem *dma_chan_base,
|
||||
+ dma_addr_t control_block)
|
||||
+{
|
||||
+ dsb(sy); /* ARM data synchronization (push) operation */
|
||||
+
|
||||
+ writel(control_block, dma_chan_base + BCM2708_DMA_ADDR);
|
||||
+ writel(BCM2708_DMA_ACTIVE, dma_chan_base + BCM2708_DMA_CS);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_start);
|
||||
+
|
||||
+extern void bcm_dma_wait_idle(void __iomem *dma_chan_base)
|
||||
+{
|
||||
+ dsb(sy);
|
||||
+
|
||||
+ /* ugly busy wait only option for now */
|
||||
+ while (readl(dma_chan_base + BCM2708_DMA_CS) & BCM2708_DMA_ACTIVE)
|
||||
+ cpu_relax();
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_wait_idle);
|
||||
+
|
||||
+extern bool bcm_dma_is_busy(void __iomem *dma_chan_base)
|
||||
+{
|
||||
+ dsb(sy);
|
||||
+
|
||||
+ return readl(dma_chan_base + BCM2708_DMA_CS) & BCM2708_DMA_ACTIVE;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_is_busy);
|
||||
+
|
||||
+/* Complete an ongoing DMA (assuming its results are to be ignored)
|
||||
+ Does nothing if there is no DMA in progress.
|
||||
+ This routine waits for the current AXI transfer to complete before
|
||||
+ terminating the current DMA. If the current transfer is hung on a DREQ used
|
||||
+ by an uncooperative peripheral the AXI transfer may never complete. In this
|
||||
+ case the routine times out and return a non-zero error code.
|
||||
+ Use of this routine doesn't guarantee that the ongoing or aborted DMA
|
||||
+ does not produce an interrupt.
|
||||
+*/
|
||||
+extern int bcm_dma_abort(void __iomem *dma_chan_base)
|
||||
+{
|
||||
+ unsigned long int cs;
|
||||
+ int rc = 0;
|
||||
+
|
||||
+ cs = readl(dma_chan_base + BCM2708_DMA_CS);
|
||||
+
|
||||
+ if (BCM2708_DMA_ACTIVE & cs) {
|
||||
+ long int timeout = 10000;
|
||||
+
|
||||
+ /* write 0 to the active bit - pause the DMA */
|
||||
+ writel(0, dma_chan_base + BCM2708_DMA_CS);
|
||||
+
|
||||
+ /* wait for any current AXI transfer to complete */
|
||||
+ while (0 != (cs & BCM2708_DMA_ISPAUSED) && --timeout >= 0)
|
||||
+ cs = readl(dma_chan_base + BCM2708_DMA_CS);
|
||||
+
|
||||
+ if (0 != (cs & BCM2708_DMA_ISPAUSED)) {
|
||||
+ /* we'll un-pause when we set of our next DMA */
|
||||
+ rc = -ETIMEDOUT;
|
||||
+
|
||||
+ } else if (BCM2708_DMA_ACTIVE & cs) {
|
||||
+ /* terminate the control block chain */
|
||||
+ writel(0, dma_chan_base + BCM2708_DMA_NEXTCB);
|
||||
+
|
||||
+ /* abort the whole DMA */
|
||||
+ writel(BCM2708_DMA_ABORT | BCM2708_DMA_ACTIVE,
|
||||
+ dma_chan_base + BCM2708_DMA_CS);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_abort);
|
||||
+
|
||||
+ /* DMA Manager Device Methods */
|
||||
+
|
||||
+static void vc_dmaman_init(struct vc_dmaman *dmaman, void __iomem *dma_base,
|
||||
+ u32 chans_available)
|
||||
+{
|
||||
+ dmaman->dma_base = dma_base;
|
||||
+ dmaman->chan_available = chans_available;
|
||||
+ dmaman->has_feature[BCM_DMA_FEATURE_FAST_ORD] = 0x0c; /* 2 & 3 */
|
||||
+ dmaman->has_feature[BCM_DMA_FEATURE_BULK_ORD] = 0x01; /* 0 */
|
||||
+ dmaman->has_feature[BCM_DMA_FEATURE_NORMAL_ORD] = 0xfe; /* 1 to 7 */
|
||||
+ dmaman->has_feature[BCM_DMA_FEATURE_LITE_ORD] = 0x7f00; /* 8 to 14 */
|
||||
+}
|
||||
+
|
||||
+static int vc_dmaman_chan_alloc(struct vc_dmaman *dmaman,
|
||||
+ unsigned required_feature_set)
|
||||
+{
|
||||
+ u32 chans;
|
||||
+ int chan = 0;
|
||||
+ int feature;
|
||||
+
|
||||
+ chans = dmaman->chan_available;
|
||||
+ for (feature = 0; feature < BCM_DMA_FEATURE_COUNT; feature++)
|
||||
+ /* select the subset of available channels with the desired
|
||||
+ features */
|
||||
+ if (required_feature_set & (1 << feature))
|
||||
+ chans &= dmaman->has_feature[feature];
|
||||
+
|
||||
+ if (!chans)
|
||||
+ return -ENOENT;
|
||||
+
|
||||
+ /* return the ordinal of the first channel in the bitmap */
|
||||
+ while (chans != 0 && (chans & 1) == 0) {
|
||||
+ chans >>= 1;
|
||||
+ chan++;
|
||||
+ }
|
||||
+ /* claim the channel */
|
||||
+ dmaman->chan_available &= ~(1 << chan);
|
||||
+
|
||||
+ return chan;
|
||||
+}
|
||||
+
|
||||
+static int vc_dmaman_chan_free(struct vc_dmaman *dmaman, int chan)
|
||||
+{
|
||||
+ if (chan < 0)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if ((1 << chan) & dmaman->chan_available)
|
||||
+ return -EIDRM;
|
||||
+
|
||||
+ dmaman->chan_available |= (1 << chan);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* DMA Manager Monitor */
|
||||
+
|
||||
+extern int bcm_dma_chan_alloc(unsigned required_feature_set,
|
||||
+ void __iomem **out_dma_base, int *out_dma_irq)
|
||||
+{
|
||||
+ struct vc_dmaman *dmaman = g_dmaman;
|
||||
+ struct platform_device *pdev = to_platform_device(dmaman_dev);
|
||||
+ int chan;
|
||||
+ int irq;
|
||||
+
|
||||
+ if (!dmaman_dev)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ mutex_lock(&dmaman->lock);
|
||||
+ chan = vc_dmaman_chan_alloc(dmaman, required_feature_set);
|
||||
+ if (chan < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, (unsigned int)chan);
|
||||
+ if (irq < 0) {
|
||||
+ dev_err(dmaman_dev, "failed to get irq for DMA channel %d\n",
|
||||
+ chan);
|
||||
+ vc_dmaman_chan_free(dmaman, chan);
|
||||
+ chan = -ENOENT;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ *out_dma_base = BCM2708_DMA_CHANIO(dmaman->dma_base, chan);
|
||||
+ *out_dma_irq = irq;
|
||||
+ dev_dbg(dmaman_dev,
|
||||
+ "Legacy API allocated channel=%d, base=%p, irq=%i\n",
|
||||
+ chan, *out_dma_base, *out_dma_irq);
|
||||
+
|
||||
+out:
|
||||
+ mutex_unlock(&dmaman->lock);
|
||||
+
|
||||
+ return chan;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_chan_alloc);
|
||||
+
|
||||
+extern int bcm_dma_chan_free(int channel)
|
||||
+{
|
||||
+ struct vc_dmaman *dmaman = g_dmaman;
|
||||
+ int rc;
|
||||
+
|
||||
+ if (!dmaman_dev)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ mutex_lock(&dmaman->lock);
|
||||
+ rc = vc_dmaman_chan_free(dmaman, channel);
|
||||
+ mutex_unlock(&dmaman->lock);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(bcm_dma_chan_free);
|
||||
+
|
||||
+int bcm_dmaman_probe(struct platform_device *pdev, void __iomem *base,
|
||||
+ u32 chans_available)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct vc_dmaman *dmaman;
|
||||
+
|
||||
+ dmaman = devm_kzalloc(dev, sizeof(*dmaman), GFP_KERNEL);
|
||||
+ if (!dmaman)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mutex_init(&dmaman->lock);
|
||||
+ vc_dmaman_init(dmaman, base, chans_available);
|
||||
+ g_dmaman = dmaman;
|
||||
+ dmaman_dev = dev;
|
||||
+
|
||||
+ dev_info(dev, "DMA legacy API manager, dmachans=0x%x\n",
|
||||
+ chans_available);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL(bcm_dmaman_probe);
|
||||
+
|
||||
+int bcm_dmaman_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ dmaman_dev = NULL;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+EXPORT_SYMBOL(bcm_dmaman_remove);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
--- /dev/null
|
||||
+++ b/include/linux/platform_data/dma-bcm2708.h
|
||||
@@ -0,0 +1,143 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2010 Broadcom
|
||||
+ *
|
||||
+ * 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.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _PLAT_BCM2708_DMA_H
|
||||
+#define _PLAT_BCM2708_DMA_H
|
||||
+
|
||||
+/* DMA CS Control and Status bits */
|
||||
+#define BCM2708_DMA_ACTIVE BIT(0)
|
||||
+#define BCM2708_DMA_INT BIT(2)
|
||||
+#define BCM2708_DMA_ISPAUSED BIT(4) /* Pause requested or not active */
|
||||
+#define BCM2708_DMA_ISHELD BIT(5) /* Is held by DREQ flow control */
|
||||
+#define BCM2708_DMA_ERR BIT(8)
|
||||
+#define BCM2708_DMA_ABORT BIT(30) /* stop current CB, go to next, WO */
|
||||
+#define BCM2708_DMA_RESET BIT(31) /* WO, self clearing */
|
||||
+
|
||||
+/* DMA control block "info" field bits */
|
||||
+#define BCM2708_DMA_INT_EN BIT(0)
|
||||
+#define BCM2708_DMA_TDMODE BIT(1)
|
||||
+#define BCM2708_DMA_WAIT_RESP BIT(3)
|
||||
+#define BCM2708_DMA_D_INC BIT(4)
|
||||
+#define BCM2708_DMA_D_WIDTH BIT(5)
|
||||
+#define BCM2708_DMA_D_DREQ BIT(6)
|
||||
+#define BCM2708_DMA_S_INC BIT(8)
|
||||
+#define BCM2708_DMA_S_WIDTH BIT(9)
|
||||
+#define BCM2708_DMA_S_DREQ BIT(10)
|
||||
+
|
||||
+#define BCM2708_DMA_BURST(x) (((x) & 0xf) << 12)
|
||||
+#define BCM2708_DMA_PER_MAP(x) ((x) << 16)
|
||||
+#define BCM2708_DMA_WAITS(x) (((x) & 0x1f) << 21)
|
||||
+
|
||||
+#define BCM2708_DMA_DREQ_EMMC 11
|
||||
+#define BCM2708_DMA_DREQ_SDHOST 13
|
||||
+
|
||||
+#define BCM2708_DMA_CS 0x00 /* Control and Status */
|
||||
+#define BCM2708_DMA_ADDR 0x04
|
||||
+/* the current control block appears in the following registers - read only */
|
||||
+#define BCM2708_DMA_INFO 0x08
|
||||
+#define BCM2708_DMA_SOURCE_AD 0x0c
|
||||
+#define BCM2708_DMA_DEST_AD 0x10
|
||||
+#define BCM2708_DMA_NEXTCB 0x1C
|
||||
+#define BCM2708_DMA_DEBUG 0x20
|
||||
+
|
||||
+#define BCM2708_DMA4_CS (BCM2708_DMA_CHAN(4) + BCM2708_DMA_CS)
|
||||
+#define BCM2708_DMA4_ADDR (BCM2708_DMA_CHAN(4) + BCM2708_DMA_ADDR)
|
||||
+
|
||||
+#define BCM2708_DMA_TDMODE_LEN(w, h) ((h) << 16 | (w))
|
||||
+
|
||||
+/* When listing features we can ask for when allocating DMA channels give
|
||||
+ those with higher priority smaller ordinal numbers */
|
||||
+#define BCM_DMA_FEATURE_FAST_ORD 0
|
||||
+#define BCM_DMA_FEATURE_BULK_ORD 1
|
||||
+#define BCM_DMA_FEATURE_NORMAL_ORD 2
|
||||
+#define BCM_DMA_FEATURE_LITE_ORD 3
|
||||
+#define BCM_DMA_FEATURE_FAST BIT(BCM_DMA_FEATURE_FAST_ORD)
|
||||
+#define BCM_DMA_FEATURE_BULK BIT(BCM_DMA_FEATURE_BULK_ORD)
|
||||
+#define BCM_DMA_FEATURE_NORMAL BIT(BCM_DMA_FEATURE_NORMAL_ORD)
|
||||
+#define BCM_DMA_FEATURE_LITE BIT(BCM_DMA_FEATURE_LITE_ORD)
|
||||
+#define BCM_DMA_FEATURE_COUNT 4
|
||||
+
|
||||
+struct bcm2708_dma_cb {
|
||||
+ u32 info;
|
||||
+ u32 src;
|
||||
+ u32 dst;
|
||||
+ u32 length;
|
||||
+ u32 stride;
|
||||
+ u32 next;
|
||||
+ u32 pad[2];
|
||||
+};
|
||||
+
|
||||
+struct scatterlist;
|
||||
+struct platform_device;
|
||||
+
|
||||
+#if defined(CONFIG_DMA_BCM2708) || defined(CONFIG_DMA_BCM2708_MODULE)
|
||||
+
|
||||
+int bcm_sg_suitable_for_dma(struct scatterlist *sg_ptr, int sg_len);
|
||||
+void bcm_dma_start(void __iomem *dma_chan_base, dma_addr_t control_block);
|
||||
+void bcm_dma_wait_idle(void __iomem *dma_chan_base);
|
||||
+bool bcm_dma_is_busy(void __iomem *dma_chan_base);
|
||||
+int bcm_dma_abort(void __iomem *dma_chan_base);
|
||||
+
|
||||
+/* return channel no or -ve error */
|
||||
+int bcm_dma_chan_alloc(unsigned preferred_feature_set,
|
||||
+ void __iomem **out_dma_base, int *out_dma_irq);
|
||||
+int bcm_dma_chan_free(int channel);
|
||||
+
|
||||
+int bcm_dmaman_probe(struct platform_device *pdev, void __iomem *base,
|
||||
+ u32 chans_available);
|
||||
+int bcm_dmaman_remove(struct platform_device *pdev);
|
||||
+
|
||||
+#else /* CONFIG_DMA_BCM2708 */
|
||||
+
|
||||
+static inline int bcm_sg_suitable_for_dma(struct scatterlist *sg_ptr,
|
||||
+ int sg_len)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void bcm_dma_start(void __iomem *dma_chan_base,
|
||||
+ dma_addr_t control_block) { }
|
||||
+
|
||||
+static inline void bcm_dma_wait_idle(void __iomem *dma_chan_base) { }
|
||||
+
|
||||
+static inline bool bcm_dma_is_busy(void __iomem *dma_chan_base)
|
||||
+{
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static inline int bcm_dma_abort(void __iomem *dma_chan_base)
|
||||
+{
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
+static inline int bcm_dma_chan_alloc(unsigned preferred_feature_set,
|
||||
+ void __iomem **out_dma_base,
|
||||
+ int *out_dma_irq)
|
||||
+{
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
+static inline int bcm_dma_chan_free(int channel)
|
||||
+{
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
+static inline int bcm_dmaman_probe(struct platform_device *pdev,
|
||||
+ void __iomem *base, u32 chans_available)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline int bcm_dmaman_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#endif /* CONFIG_DMA_BCM2708 || CONFIG_DMA_BCM2708_MODULE */
|
||||
+
|
||||
+#endif /* _PLAT_BCM2708_DMA_H */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
From 676ce1112f4e1023ed5e49501b6279190bdcb152 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Bell <jonathan@raspberrypi.com>
|
||||
Date: Mon, 16 May 2022 10:28:27 +0100
|
||||
Subject: [PATCH 0093/1085] mmc: block: Don't do single-sector reads during
|
||||
recovery
|
||||
|
||||
See https://github.com/raspberrypi/linux/issues/5019
|
||||
|
||||
If an SD card has degraded performance such that IO operations time out
|
||||
then the MMC block layer will leak SG DMA mappings in the swiotlb during
|
||||
recovery. It retries the same SG and this causes the leak, as it is
|
||||
mapped twice - once in sdhci_pre_req() and again during single-block
|
||||
reads in sdhci_prepare_data().
|
||||
|
||||
Resetting the card (including power-cycling if a regulator for vmmc is
|
||||
present) ought to be enough to recover a stuck state, so for now don't
|
||||
try single-block reads in the recovery path.
|
||||
|
||||
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
|
||||
---
|
||||
drivers/mmc/core/block.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/mmc/core/block.c
|
||||
+++ b/drivers/mmc/core/block.c
|
||||
@@ -1949,7 +1949,7 @@ static void mmc_blk_mq_rw_recovery(struc
|
||||
return;
|
||||
}
|
||||
|
||||
- if (rq_data_dir(req) == READ && brq->data.blocks >
|
||||
+ if (0 && rq_data_dir(req) == READ && brq->data.blocks >
|
||||
queue_physical_block_size(mq->queue) >> 9) {
|
||||
/* Read one (native) sector at a time */
|
||||
mmc_blk_read_single(mq, req);
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,497 @@
|
||||
From d1640c25080c3bd2b322b2330a9fba90e74d81fc Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Fri, 28 Oct 2016 15:36:43 +0100
|
||||
Subject: [PATCH 0095/1085] vc_mem: Add vc_mem driver for querying firmware
|
||||
memory addresses
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: popcornmix <popcornmix@gmail.com>
|
||||
|
||||
BCM270x: Move vc_mem
|
||||
|
||||
Make the vc_mem module available for ARCH_BCM2835 by moving it.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
char: vc_mem: Fix up compat ioctls for 64bit kernel
|
||||
|
||||
compat_ioctl wasn't defined, so 32bit user/64bit kernel
|
||||
always failed.
|
||||
VC_MEM_IOC_MEM_PHYS_ADDR was defined with parameter size
|
||||
unsigned long, so the ioctl cmd changes between sizes.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
|
||||
char: vc_mem: Fix all coding style issues.
|
||||
|
||||
Cleans up all checkpatch errors in vc_mem.c and vc_mem.h
|
||||
No functional change to the code.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
|
||||
char: vc_mem: Delete dead code
|
||||
|
||||
There are no error exists once device_create has succeeded, and
|
||||
therefore no need to call device_destroy from vc_mem_init.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
|
||||
char: broadcom: vc_mem: Fix preprocessor conditional
|
||||
|
||||
Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
|
||||
---
|
||||
drivers/char/broadcom/Kconfig | 18 ++
|
||||
drivers/char/broadcom/Makefile | 1 +
|
||||
drivers/char/broadcom/vc_mem.c | 373 ++++++++++++++++++++++++++++++++
|
||||
include/linux/broadcom/vc_mem.h | 39 ++++
|
||||
4 files changed, 431 insertions(+)
|
||||
create mode 100644 drivers/char/broadcom/Kconfig
|
||||
create mode 100644 drivers/char/broadcom/Makefile
|
||||
create mode 100644 drivers/char/broadcom/vc_mem.c
|
||||
create mode 100644 include/linux/broadcom/vc_mem.h
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/broadcom/Kconfig
|
||||
@@ -0,0 +1,18 @@
|
||||
+#
|
||||
+# Broadcom char driver config
|
||||
+#
|
||||
+
|
||||
+menuconfig BRCM_CHAR_DRIVERS
|
||||
+ bool "Broadcom Char Drivers"
|
||||
+ help
|
||||
+ Broadcom's char drivers
|
||||
+
|
||||
+if BRCM_CHAR_DRIVERS
|
||||
+
|
||||
+config BCM2708_VCMEM
|
||||
+ bool "Videocore Memory"
|
||||
+ default y
|
||||
+ help
|
||||
+ Helper for videocore memory access and total size allocation.
|
||||
+
|
||||
+endif
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/broadcom/Makefile
|
||||
@@ -0,0 +1 @@
|
||||
+obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/broadcom/vc_mem.c
|
||||
@@ -0,0 +1,373 @@
|
||||
+/*
|
||||
+ * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
|
||||
+ *
|
||||
+ * Unless you and Broadcom execute a separate written software license
|
||||
+ * agreement governing use of this software, this software is licensed to you
|
||||
+ * under the terms of the GNU General Public License version 2, available at
|
||||
+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
|
||||
+ *
|
||||
+ * Notwithstanding the above, under no circumstances may you combine this
|
||||
+ * software in any way with any other Broadcom software provided under a
|
||||
+ * license other than the GPL, without Broadcom's express prior written
|
||||
+ * consent.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/fs.h>
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/cdev.h>
|
||||
+#include <linux/mm.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/debugfs.h>
|
||||
+#include <linux/uaccess.h>
|
||||
+#include <linux/dma-mapping.h>
|
||||
+#include <linux/broadcom/vc_mem.h>
|
||||
+
|
||||
+#define DRIVER_NAME "vc-mem"
|
||||
+
|
||||
+/* Device (/dev) related variables */
|
||||
+static dev_t vc_mem_devnum;
|
||||
+static struct class *vc_mem_class;
|
||||
+static struct cdev vc_mem_cdev;
|
||||
+static int vc_mem_inited;
|
||||
+
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+static struct dentry *vc_mem_debugfs_entry;
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Videocore memory addresses and size
|
||||
+ *
|
||||
+ * Drivers that wish to know the videocore memory addresses and sizes should
|
||||
+ * use these variables instead of the MM_IO_BASE and MM_ADDR_IO defines in
|
||||
+ * headers. This allows the other drivers to not be tied down to a a certain
|
||||
+ * address/size at compile time.
|
||||
+ *
|
||||
+ * In the future, the goal is to have the videocore memory virtual address and
|
||||
+ * size be calculated at boot time rather than at compile time. The decision of
|
||||
+ * where the videocore memory resides and its size would be in the hands of the
|
||||
+ * bootloader (and/or kernel). When that happens, the values of these variables
|
||||
+ * would be calculated and assigned in the init function.
|
||||
+ */
|
||||
+/* In the 2835 VC in mapped above ARM, but ARM has full access to VC space */
|
||||
+unsigned long mm_vc_mem_phys_addr;
|
||||
+EXPORT_SYMBOL(mm_vc_mem_phys_addr);
|
||||
+unsigned int mm_vc_mem_size;
|
||||
+EXPORT_SYMBOL(mm_vc_mem_size);
|
||||
+unsigned int mm_vc_mem_base;
|
||||
+EXPORT_SYMBOL(mm_vc_mem_base);
|
||||
+
|
||||
+static uint phys_addr;
|
||||
+static uint mem_size;
|
||||
+static uint mem_base;
|
||||
+
|
||||
+static int
|
||||
+vc_mem_open(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ (void)inode;
|
||||
+
|
||||
+ pr_debug("%s: called file = 0x%p\n", __func__, file);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+vc_mem_release(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ (void)inode;
|
||||
+
|
||||
+ pr_debug("%s: called file = 0x%p\n", __func__, file);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+vc_mem_get_size(void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+vc_mem_get_base(void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+vc_mem_get_current_size(void)
|
||||
+{
|
||||
+ return mm_vc_mem_size;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(vc_mem_get_current_size);
|
||||
+
|
||||
+static long
|
||||
+vc_mem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+
|
||||
+ (void) cmd;
|
||||
+ (void) arg;
|
||||
+
|
||||
+ pr_debug("%s: called file = 0x%p, cmd %08x\n", __func__, file, cmd);
|
||||
+
|
||||
+ switch (cmd) {
|
||||
+ case VC_MEM_IOC_MEM_PHYS_ADDR:
|
||||
+ {
|
||||
+ pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR=0x%p\n",
|
||||
+ __func__, (void *)mm_vc_mem_phys_addr);
|
||||
+
|
||||
+ if (copy_to_user((void *)arg, &mm_vc_mem_phys_addr,
|
||||
+ sizeof(mm_vc_mem_phys_addr))) {
|
||||
+ rc = -EFAULT;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case VC_MEM_IOC_MEM_SIZE:
|
||||
+ {
|
||||
+ /* Get the videocore memory size first */
|
||||
+ vc_mem_get_size();
|
||||
+
|
||||
+ pr_debug("%s: VC_MEM_IOC_MEM_SIZE=%x\n", __func__,
|
||||
+ mm_vc_mem_size);
|
||||
+
|
||||
+ if (copy_to_user((void *)arg, &mm_vc_mem_size,
|
||||
+ sizeof(mm_vc_mem_size))) {
|
||||
+ rc = -EFAULT;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case VC_MEM_IOC_MEM_BASE:
|
||||
+ {
|
||||
+ /* Get the videocore memory base */
|
||||
+ vc_mem_get_base();
|
||||
+
|
||||
+ pr_debug("%s: VC_MEM_IOC_MEM_BASE=%x\n", __func__,
|
||||
+ mm_vc_mem_base);
|
||||
+
|
||||
+ if (copy_to_user((void *)arg, &mm_vc_mem_base,
|
||||
+ sizeof(mm_vc_mem_base))) {
|
||||
+ rc = -EFAULT;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ case VC_MEM_IOC_MEM_LOAD:
|
||||
+ {
|
||||
+ /* Get the videocore memory base */
|
||||
+ vc_mem_get_base();
|
||||
+
|
||||
+ pr_debug("%s: VC_MEM_IOC_MEM_LOAD=%x\n", __func__,
|
||||
+ mm_vc_mem_base);
|
||||
+
|
||||
+ if (copy_to_user((void *)arg, &mm_vc_mem_base,
|
||||
+ sizeof(mm_vc_mem_base))) {
|
||||
+ rc = -EFAULT;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ default:
|
||||
+ {
|
||||
+ return -ENOTTY;
|
||||
+ }
|
||||
+ }
|
||||
+ pr_debug("%s: file = 0x%p returning %d\n", __func__, file, rc);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+static long
|
||||
+vc_mem_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+
|
||||
+ switch (cmd) {
|
||||
+ case VC_MEM_IOC_MEM_PHYS_ADDR32:
|
||||
+ pr_debug("%s: VC_MEM_IOC_MEM_PHYS_ADDR32=0x%p\n",
|
||||
+ __func__, (void *)mm_vc_mem_phys_addr);
|
||||
+
|
||||
+ /* This isn't correct, but will cover us for now as
|
||||
+ * VideoCore is 32bit only.
|
||||
+ */
|
||||
+ if (copy_to_user((void *)arg, &mm_vc_mem_phys_addr,
|
||||
+ sizeof(compat_ulong_t)))
|
||||
+ rc = -EFAULT;
|
||||
+
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ rc = vc_mem_ioctl(file, cmd, arg);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+static int
|
||||
+vc_mem_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+ unsigned long length = vma->vm_end - vma->vm_start;
|
||||
+ unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
|
||||
+
|
||||
+ pr_debug("%s: vm_start = 0x%08lx vm_end = 0x%08lx vm_pgoff = 0x%08lx\n",
|
||||
+ __func__, (long)vma->vm_start, (long)vma->vm_end,
|
||||
+ (long)vma->vm_pgoff);
|
||||
+
|
||||
+ if (offset + length > mm_vc_mem_size) {
|
||||
+ pr_err("%s: length %ld is too big\n", __func__, length);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ /* Do not cache the memory map */
|
||||
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
|
||||
+
|
||||
+ rc = remap_pfn_range(vma, vma->vm_start,
|
||||
+ (mm_vc_mem_phys_addr >> PAGE_SHIFT) +
|
||||
+ vma->vm_pgoff, length, vma->vm_page_prot);
|
||||
+ if (rc)
|
||||
+ pr_err("%s: remap_pfn_range failed (rc=%d)\n", __func__, rc);
|
||||
+
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
+/* File Operations for the driver. */
|
||||
+static const struct file_operations vc_mem_fops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .open = vc_mem_open,
|
||||
+ .release = vc_mem_release,
|
||||
+ .unlocked_ioctl = vc_mem_ioctl,
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+ .compat_ioctl = vc_mem_compat_ioctl,
|
||||
+#endif
|
||||
+ .mmap = vc_mem_mmap,
|
||||
+};
|
||||
+
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+static void vc_mem_debugfs_deinit(void)
|
||||
+{
|
||||
+ debugfs_remove_recursive(vc_mem_debugfs_entry);
|
||||
+ vc_mem_debugfs_entry = NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int vc_mem_debugfs_init(
|
||||
+ struct device *dev)
|
||||
+{
|
||||
+ vc_mem_debugfs_entry = debugfs_create_dir(DRIVER_NAME, NULL);
|
||||
+ if (!vc_mem_debugfs_entry) {
|
||||
+ dev_warn(dev, "could not create debugfs entry\n");
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ debugfs_create_x32("vc_mem_phys_addr",
|
||||
+ 0444,
|
||||
+ vc_mem_debugfs_entry,
|
||||
+ (u32 *)&mm_vc_mem_phys_addr);
|
||||
+ debugfs_create_x32("vc_mem_size",
|
||||
+ 0444,
|
||||
+ vc_mem_debugfs_entry,
|
||||
+ (u32 *)&mm_vc_mem_size);
|
||||
+ debugfs_create_x32("vc_mem_base",
|
||||
+ 0444,
|
||||
+ vc_mem_debugfs_entry,
|
||||
+ (u32 *)&mm_vc_mem_base);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#endif /* CONFIG_DEBUG_FS */
|
||||
+
|
||||
+/* Module load/unload functions */
|
||||
+
|
||||
+static int __init
|
||||
+vc_mem_init(void)
|
||||
+{
|
||||
+ int rc = -EFAULT;
|
||||
+ struct device *dev;
|
||||
+
|
||||
+ pr_debug("%s: called\n", __func__);
|
||||
+
|
||||
+ mm_vc_mem_phys_addr = phys_addr;
|
||||
+ mm_vc_mem_size = mem_size;
|
||||
+ mm_vc_mem_base = mem_base;
|
||||
+
|
||||
+ vc_mem_get_size();
|
||||
+
|
||||
+ pr_info("vc-mem: phys_addr:0x%08lx mem_base=0x%08x mem_size:0x%08x(%u MiB)\n",
|
||||
+ mm_vc_mem_phys_addr, mm_vc_mem_base, mm_vc_mem_size,
|
||||
+ mm_vc_mem_size / (1024 * 1024));
|
||||
+
|
||||
+ rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME);
|
||||
+ if (rc < 0) {
|
||||
+ pr_err("%s: alloc_chrdev_region failed (rc=%d)\n",
|
||||
+ __func__, rc);
|
||||
+ goto out_err;
|
||||
+ }
|
||||
+
|
||||
+ cdev_init(&vc_mem_cdev, &vc_mem_fops);
|
||||
+ rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1);
|
||||
+ if (rc) {
|
||||
+ pr_err("%s: cdev_add failed (rc=%d)\n", __func__, rc);
|
||||
+ goto out_unregister;
|
||||
+ }
|
||||
+
|
||||
+ vc_mem_class = class_create(DRIVER_NAME);
|
||||
+ if (IS_ERR(vc_mem_class)) {
|
||||
+ rc = PTR_ERR(vc_mem_class);
|
||||
+ pr_err("%s: class_create failed (rc=%d)\n", __func__, rc);
|
||||
+ goto out_cdev_del;
|
||||
+ }
|
||||
+
|
||||
+ dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
|
||||
+ DRIVER_NAME);
|
||||
+ if (IS_ERR(dev)) {
|
||||
+ rc = PTR_ERR(dev);
|
||||
+ pr_err("%s: device_create failed (rc=%d)\n", __func__, rc);
|
||||
+ goto out_class_destroy;
|
||||
+ }
|
||||
+
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+ /* don't fail if the debug entries cannot be created */
|
||||
+ vc_mem_debugfs_init(dev);
|
||||
+#endif
|
||||
+
|
||||
+ vc_mem_inited = 1;
|
||||
+ return 0;
|
||||
+
|
||||
+out_class_destroy:
|
||||
+ class_destroy(vc_mem_class);
|
||||
+ vc_mem_class = NULL;
|
||||
+
|
||||
+out_cdev_del:
|
||||
+ cdev_del(&vc_mem_cdev);
|
||||
+
|
||||
+out_unregister:
|
||||
+ unregister_chrdev_region(vc_mem_devnum, 1);
|
||||
+
|
||||
+out_err:
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static void __exit
|
||||
+vc_mem_exit(void)
|
||||
+{
|
||||
+ pr_debug("%s: called\n", __func__);
|
||||
+
|
||||
+ if (vc_mem_inited) {
|
||||
+#ifdef CONFIG_DEBUG_FS
|
||||
+ vc_mem_debugfs_deinit();
|
||||
+#endif
|
||||
+ device_destroy(vc_mem_class, vc_mem_devnum);
|
||||
+ class_destroy(vc_mem_class);
|
||||
+ cdev_del(&vc_mem_cdev);
|
||||
+ unregister_chrdev_region(vc_mem_devnum, 1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+module_init(vc_mem_init);
|
||||
+module_exit(vc_mem_exit);
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Broadcom Corporation");
|
||||
+
|
||||
+module_param(phys_addr, uint, 0644);
|
||||
+module_param(mem_size, uint, 0644);
|
||||
+module_param(mem_base, uint, 0644);
|
||||
--- /dev/null
|
||||
+++ b/include/linux/broadcom/vc_mem.h
|
||||
@@ -0,0 +1,39 @@
|
||||
+/*
|
||||
+ * Copyright 2010 - 2011 Broadcom Corporation. All rights reserved.
|
||||
+ *
|
||||
+ * Unless you and Broadcom execute a separate written software license
|
||||
+ * agreement governing use of this software, this software is licensed to you
|
||||
+ * under the terms of the GNU General Public License version 2, available at
|
||||
+ * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
|
||||
+ *
|
||||
+ * Notwithstanding the above, under no circumstances may you combine this
|
||||
+ * software in any way with any other Broadcom software provided under a
|
||||
+ * license other than the GPL, without Broadcom's express prior written
|
||||
+ * consent.
|
||||
+ */
|
||||
+
|
||||
+#ifndef _VC_MEM_H
|
||||
+#define _VC_MEM_H
|
||||
+
|
||||
+#include <linux/ioctl.h>
|
||||
+
|
||||
+#define VC_MEM_IOC_MAGIC 'v'
|
||||
+
|
||||
+#define VC_MEM_IOC_MEM_PHYS_ADDR _IOR(VC_MEM_IOC_MAGIC, 0, unsigned long)
|
||||
+#define VC_MEM_IOC_MEM_SIZE _IOR(VC_MEM_IOC_MAGIC, 1, unsigned int)
|
||||
+#define VC_MEM_IOC_MEM_BASE _IOR(VC_MEM_IOC_MAGIC, 2, unsigned int)
|
||||
+#define VC_MEM_IOC_MEM_LOAD _IOR(VC_MEM_IOC_MAGIC, 3, unsigned int)
|
||||
+
|
||||
+#ifdef __KERNEL__
|
||||
+#define VC_MEM_TO_ARM_ADDR_MASK 0x3FFFFFFF
|
||||
+
|
||||
+extern unsigned long mm_vc_mem_phys_addr;
|
||||
+extern unsigned int mm_vc_mem_size;
|
||||
+extern int vc_mem_get_current_size(void);
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+#define VC_MEM_IOC_MEM_PHYS_ADDR32 _IOR(VC_MEM_IOC_MAGIC, 0, compat_ulong_t)
|
||||
+#endif
|
||||
+
|
||||
+#endif /* _VC_MEM_H */
|
@ -0,0 +1,300 @@
|
||||
From a7bebe53ea70778389d162a6a25aa5707f083747 Mon Sep 17 00:00:00 2001
|
||||
From: Luke Wren <luke@raspberrypi.org>
|
||||
Date: Fri, 21 Aug 2015 23:14:48 +0100
|
||||
Subject: [PATCH 0096/1085] Add /dev/gpiomem device for rootless user GPIO
|
||||
access
|
||||
|
||||
Signed-off-by: Luke Wren <luke@raspberrypi.org>
|
||||
|
||||
bcm2835-gpiomem: Fix for ARCH_BCM2835 builds
|
||||
|
||||
Build on ARCH_BCM2835, and fail to probe if no IO resource.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/1154
|
||||
---
|
||||
drivers/char/broadcom/Kconfig | 8 +
|
||||
drivers/char/broadcom/Makefile | 1 +
|
||||
drivers/char/broadcom/bcm2835-gpiomem.c | 258 ++++++++++++++++++++++++
|
||||
3 files changed, 267 insertions(+)
|
||||
create mode 100644 drivers/char/broadcom/bcm2835-gpiomem.c
|
||||
|
||||
--- a/drivers/char/broadcom/Kconfig
|
||||
+++ b/drivers/char/broadcom/Kconfig
|
||||
@@ -16,3 +16,11 @@ config BCM2708_VCMEM
|
||||
Helper for videocore memory access and total size allocation.
|
||||
|
||||
endif
|
||||
+
|
||||
+config BCM2835_DEVGPIOMEM
|
||||
+ tristate "/dev/gpiomem rootless GPIO access via mmap() on the BCM2835"
|
||||
+ default m
|
||||
+ help
|
||||
+ Provides users with root-free access to the GPIO registers
|
||||
+ on the 2835. Calling mmap(/dev/gpiomem) will map the GPIO
|
||||
+ register page to the user's pointer.
|
||||
--- a/drivers/char/broadcom/Makefile
|
||||
+++ b/drivers/char/broadcom/Makefile
|
||||
@@ -1 +1,2 @@
|
||||
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
|
||||
+obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/broadcom/bcm2835-gpiomem.c
|
||||
@@ -0,0 +1,258 @@
|
||||
+/**
|
||||
+ * GPIO memory device driver
|
||||
+ *
|
||||
+ * Creates a chardev /dev/gpiomem which will provide user access to
|
||||
+ * the BCM2835's GPIO registers when it is mmap()'d.
|
||||
+ * No longer need root for user GPIO access, but without relaxing permissions
|
||||
+ * on /dev/mem.
|
||||
+ *
|
||||
+ * Written by Luke Wren <luke@raspberrypi.org>
|
||||
+ * Copyright (c) 2015, Raspberry Pi (Trading) Ltd.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without
|
||||
+ * modification, are permitted provided that the following conditions
|
||||
+ * are met:
|
||||
+ * 1. Redistributions of source code must retain the above copyright
|
||||
+ * notice, this list of conditions, and the following disclaimer,
|
||||
+ * without modification.
|
||||
+ * 2. Redistributions in binary form must reproduce the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer in the
|
||||
+ * documentation and/or other materials provided with the distribution.
|
||||
+ * 3. The names of the above-listed copyright holders may not be used
|
||||
+ * to endorse or promote products derived from this software without
|
||||
+ * specific prior written permission.
|
||||
+ *
|
||||
+ * ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
+ * GNU General Public License ("GPL") version 2, as published by the Free
|
||||
+ * Software Foundation.
|
||||
+ *
|
||||
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/mm.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/cdev.h>
|
||||
+#include <linux/pagemap.h>
|
||||
+#include <linux/io.h>
|
||||
+
|
||||
+#define DEVICE_NAME "bcm2835-gpiomem"
|
||||
+#define DRIVER_NAME "gpiomem-bcm2835"
|
||||
+#define DEVICE_MINOR 0
|
||||
+
|
||||
+struct bcm2835_gpiomem_instance {
|
||||
+ unsigned long gpio_regs_phys;
|
||||
+ struct device *dev;
|
||||
+};
|
||||
+
|
||||
+static struct cdev bcm2835_gpiomem_cdev;
|
||||
+static dev_t bcm2835_gpiomem_devid;
|
||||
+static struct class *bcm2835_gpiomem_class;
|
||||
+static struct device *bcm2835_gpiomem_dev;
|
||||
+static struct bcm2835_gpiomem_instance *inst;
|
||||
+
|
||||
+
|
||||
+/****************************************************************************
|
||||
+*
|
||||
+* GPIO mem chardev file ops
|
||||
+*
|
||||
+***************************************************************************/
|
||||
+
|
||||
+static int bcm2835_gpiomem_open(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ int dev = iminor(inode);
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (dev != DEVICE_MINOR) {
|
||||
+ dev_err(inst->dev, "Unknown minor device: %d", dev);
|
||||
+ ret = -ENXIO;
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int bcm2835_gpiomem_release(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ int dev = iminor(inode);
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (dev != DEVICE_MINOR) {
|
||||
+ dev_err(inst->dev, "Unknown minor device %d", dev);
|
||||
+ ret = -ENXIO;
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static const struct vm_operations_struct bcm2835_gpiomem_vm_ops = {
|
||||
+#ifdef CONFIG_HAVE_IOREMAP_PROT
|
||||
+ .access = generic_access_phys
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+static int bcm2835_gpiomem_mmap(struct file *file, struct vm_area_struct *vma)
|
||||
+{
|
||||
+ /* Ignore what the user says - they're getting the GPIO regs
|
||||
+ whether they like it or not! */
|
||||
+ unsigned long gpio_page = inst->gpio_regs_phys >> PAGE_SHIFT;
|
||||
+
|
||||
+ vma->vm_page_prot = phys_mem_access_prot(file, gpio_page,
|
||||
+ PAGE_SIZE,
|
||||
+ vma->vm_page_prot);
|
||||
+ vma->vm_ops = &bcm2835_gpiomem_vm_ops;
|
||||
+ if (remap_pfn_range(vma, vma->vm_start,
|
||||
+ gpio_page,
|
||||
+ PAGE_SIZE,
|
||||
+ vma->vm_page_prot)) {
|
||||
+ return -EAGAIN;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct file_operations
|
||||
+bcm2835_gpiomem_fops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .open = bcm2835_gpiomem_open,
|
||||
+ .release = bcm2835_gpiomem_release,
|
||||
+ .mmap = bcm2835_gpiomem_mmap,
|
||||
+};
|
||||
+
|
||||
+
|
||||
+ /****************************************************************************
|
||||
+*
|
||||
+* Probe and remove functions
|
||||
+*
|
||||
+***************************************************************************/
|
||||
+
|
||||
+
|
||||
+static int bcm2835_gpiomem_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ int err;
|
||||
+ void *ptr_err;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct resource *ioresource;
|
||||
+
|
||||
+ /* Allocate buffers and instance data */
|
||||
+
|
||||
+ inst = kzalloc(sizeof(struct bcm2835_gpiomem_instance), GFP_KERNEL);
|
||||
+
|
||||
+ if (!inst) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto failed_inst_alloc;
|
||||
+ }
|
||||
+
|
||||
+ inst->dev = dev;
|
||||
+
|
||||
+ ioresource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
+ if (ioresource) {
|
||||
+ inst->gpio_regs_phys = ioresource->start;
|
||||
+ } else {
|
||||
+ dev_err(inst->dev, "failed to get IO resource");
|
||||
+ err = -ENOENT;
|
||||
+ goto failed_get_resource;
|
||||
+ }
|
||||
+
|
||||
+ /* Create character device entries */
|
||||
+
|
||||
+ err = alloc_chrdev_region(&bcm2835_gpiomem_devid,
|
||||
+ DEVICE_MINOR, 1, DEVICE_NAME);
|
||||
+ if (err != 0) {
|
||||
+ dev_err(inst->dev, "unable to allocate device number");
|
||||
+ goto failed_alloc_chrdev;
|
||||
+ }
|
||||
+ cdev_init(&bcm2835_gpiomem_cdev, &bcm2835_gpiomem_fops);
|
||||
+ bcm2835_gpiomem_cdev.owner = THIS_MODULE;
|
||||
+ err = cdev_add(&bcm2835_gpiomem_cdev, bcm2835_gpiomem_devid, 1);
|
||||
+ if (err != 0) {
|
||||
+ dev_err(inst->dev, "unable to register device");
|
||||
+ goto failed_cdev_add;
|
||||
+ }
|
||||
+
|
||||
+ /* Create sysfs entries */
|
||||
+
|
||||
+ bcm2835_gpiomem_class = class_create(DEVICE_NAME);
|
||||
+ ptr_err = bcm2835_gpiomem_class;
|
||||
+ if (IS_ERR(ptr_err))
|
||||
+ goto failed_class_create;
|
||||
+
|
||||
+ bcm2835_gpiomem_dev = device_create(bcm2835_gpiomem_class, NULL,
|
||||
+ bcm2835_gpiomem_devid, NULL,
|
||||
+ "gpiomem");
|
||||
+ ptr_err = bcm2835_gpiomem_dev;
|
||||
+ if (IS_ERR(ptr_err))
|
||||
+ goto failed_device_create;
|
||||
+
|
||||
+ dev_info(inst->dev, "Initialised: Registers at 0x%08lx",
|
||||
+ inst->gpio_regs_phys);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+failed_device_create:
|
||||
+ class_destroy(bcm2835_gpiomem_class);
|
||||
+failed_class_create:
|
||||
+ cdev_del(&bcm2835_gpiomem_cdev);
|
||||
+ err = PTR_ERR(ptr_err);
|
||||
+failed_cdev_add:
|
||||
+ unregister_chrdev_region(bcm2835_gpiomem_devid, 1);
|
||||
+failed_alloc_chrdev:
|
||||
+failed_get_resource:
|
||||
+ kfree(inst);
|
||||
+failed_inst_alloc:
|
||||
+ dev_err(inst->dev, "could not load bcm2835_gpiomem");
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int bcm2835_gpiomem_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = inst->dev;
|
||||
+
|
||||
+ kfree(inst);
|
||||
+ device_destroy(bcm2835_gpiomem_class, bcm2835_gpiomem_devid);
|
||||
+ class_destroy(bcm2835_gpiomem_class);
|
||||
+ cdev_del(&bcm2835_gpiomem_cdev);
|
||||
+ unregister_chrdev_region(bcm2835_gpiomem_devid, 1);
|
||||
+
|
||||
+ dev_info(dev, "GPIO mem driver removed - OK");
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+ /****************************************************************************
|
||||
+*
|
||||
+* Register the driver with device tree
|
||||
+*
|
||||
+***************************************************************************/
|
||||
+
|
||||
+static const struct of_device_id bcm2835_gpiomem_of_match[] = {
|
||||
+ {.compatible = "brcm,bcm2835-gpiomem",},
|
||||
+ { /* sentinel */ },
|
||||
+};
|
||||
+
|
||||
+MODULE_DEVICE_TABLE(of, bcm2835_gpiomem_of_match);
|
||||
+
|
||||
+static struct platform_driver bcm2835_gpiomem_driver = {
|
||||
+ .probe = bcm2835_gpiomem_probe,
|
||||
+ .remove = bcm2835_gpiomem_remove,
|
||||
+ .driver = {
|
||||
+ .name = DRIVER_NAME,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .of_match_table = bcm2835_gpiomem_of_match,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(bcm2835_gpiomem_driver);
|
||||
+
|
||||
+MODULE_ALIAS("platform:gpiomem-bcm2835");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("gpiomem driver for accessing GPIO from userspace");
|
||||
+MODULE_AUTHOR("Luke Wren <luke@raspberrypi.org>");
|
1973
target/linux/bcm27xx/patches-6.6/950-0097-Add-SMI-driver.patch
Normal file
1973
target/linux/bcm27xx/patches-6.6/950-0097-Add-SMI-driver.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,660 @@
|
||||
From 9c9cb5da42ce373216dea9368282c3d8f8da810d Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Wed, 17 Jun 2015 15:44:08 +0100
|
||||
Subject: [PATCH 0098/1085] Add Chris Boot's i2c driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
i2c-bcm2708: fixed baudrate
|
||||
|
||||
Fixed issue where the wrong CDIV value was set for baudrates below 3815 Hz (for 250MHz bus clock).
|
||||
In that case the computed CDIV value was more than 0xffff. However the CDIV register width is only 16 bits.
|
||||
This resulted in incorrect setting of CDIV and higher baudrate than intended.
|
||||
Example: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0x1704 -> 42430Hz
|
||||
After correction: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0xffff -> 3815Hz
|
||||
The correct baudrate is shown in the log after the cdiv > 0xffff correction.
|
||||
|
||||
Perform I2C combined transactions when possible
|
||||
|
||||
Perform I2C combined transactions whenever possible, within the
|
||||
restrictions of the Broadcomm Serial Controller.
|
||||
|
||||
Disable DONE interrupt during TA poll
|
||||
|
||||
Prevent interrupt from being triggered if poll is missed and transfer
|
||||
starts and finishes.
|
||||
|
||||
i2c: Make combined transactions optional and disabled by default
|
||||
|
||||
i2c: bcm2708: add device tree support
|
||||
|
||||
Add DT support to driver and add to .dtsi file.
|
||||
Setup pins in .dts file.
|
||||
i2c is disabled by default.
|
||||
|
||||
Signed-off-by: Noralf Tronnes <notro@tronnes.org>
|
||||
|
||||
bcm2708: don't register i2c controllers when using DT
|
||||
|
||||
The devices for the i2c controllers are in the Device Tree.
|
||||
Only register devices when not using DT.
|
||||
|
||||
Signed-off-by: Noralf Tronnes <notro@tronnes.org>
|
||||
|
||||
I2C: Only register the I2C device for the current board revision
|
||||
|
||||
i2c_bcm2708: Fix clock reference counting
|
||||
|
||||
Fix grabbing lock from atomic context in i2c driver
|
||||
|
||||
2 main changes:
|
||||
- check for timeouts in the bcm2708_bsc_setup function as indicated by this comment:
|
||||
/* poll for transfer start bit (should only take 1-20 polls) */
|
||||
This implies that the setup function can now fail so account for this everywhere it's called
|
||||
- Removed the clk_get_rate call from inside the setup function as it locks a mutex and that's not ok since we call it from under a spin lock.
|
||||
|
||||
i2c-bcm2708: When using DT, leave the GPIO setup to pinctrl
|
||||
|
||||
i2c-bcm2708: Increase timeouts to allow larger transfers
|
||||
|
||||
Use the timeout value provided by the I2C_TIMEOUT ioctl when waiting
|
||||
for completion. The default timeout is 1 second.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/260
|
||||
|
||||
i2c-bcm2708/BCM270X_DT: Add support for I2C2
|
||||
|
||||
The third I2C bus (I2C2) is normally reserved for HDMI use. Careless
|
||||
use of this bus can break an attached display - use with caution.
|
||||
|
||||
It is recommended to disable accesses by VideoCore by setting
|
||||
hdmi_ignore_edid=1 or hdmi_edid_file=1 in config.txt.
|
||||
|
||||
The interface is disabled by default - enable using the
|
||||
i2c2_iknowwhatimdoing DT parameter.
|
||||
|
||||
bcm2708-spi: Don't use static pin configuration with DT
|
||||
|
||||
Also remove superfluous error checking - the SPI framework ensures the
|
||||
validity of the chip_select value.
|
||||
|
||||
i2c-bcm2708: Remove non-DT support
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
Set the BSC_CLKT clock streching timeout to 35ms as per SMBus specs.
|
||||
|
||||
Fixes i2c_bcm2708: Write to FIFO correctly - v2 (#1574)
|
||||
|
||||
* i2c: fix i2c_bcm2708: Clear FIFO before sending data
|
||||
|
||||
Make sure FIFO gets cleared before trying to send
|
||||
data in case of a repeated start (COMBINED=Y).
|
||||
|
||||
* i2c: fix i2c_bcm2708: Only write to FIFO when not full
|
||||
|
||||
Check if FIFO can accept data before writing.
|
||||
To avoid a peripheral read on the last iteration of a loop,
|
||||
both bcm2708_bsc_fifo_fill and ~drain are changed as well.
|
||||
---
|
||||
drivers/i2c/busses/Kconfig | 19 ++
|
||||
drivers/i2c/busses/Makefile | 2 +
|
||||
drivers/i2c/busses/i2c-bcm2708.c | 512 +++++++++++++++++++++++++++++++
|
||||
3 files changed, 533 insertions(+)
|
||||
create mode 100644 drivers/i2c/busses/i2c-bcm2708.c
|
||||
|
||||
--- a/drivers/i2c/busses/Kconfig
|
||||
+++ b/drivers/i2c/busses/Kconfig
|
||||
@@ -16,6 +16,25 @@ config I2C_CCGX_UCSI
|
||||
for Cypress CCGx Type-C controller. Individual bus drivers
|
||||
need to select this one on demand.
|
||||
|
||||
+config I2C_BCM2708
|
||||
+ tristate "BCM2708 BSC"
|
||||
+ depends on ARCH_BCM2835
|
||||
+ help
|
||||
+ Enabling this option will add BSC (Broadcom Serial Controller)
|
||||
+ support for the BCM2708. BSC is a Broadcom proprietary bus compatible
|
||||
+ with I2C/TWI/SMBus.
|
||||
+
|
||||
+config I2C_BCM2708_BAUDRATE
|
||||
+ prompt "BCM2708 I2C baudrate"
|
||||
+ depends on I2C_BCM2708
|
||||
+ int
|
||||
+ default 100000
|
||||
+ help
|
||||
+ Set the I2C baudrate. This will alter the default value. A
|
||||
+ different baudrate can be set by using a module parameter as well. If
|
||||
+ no parameter is provided when loading, this is the value that will be
|
||||
+ used.
|
||||
+
|
||||
config I2C_ALI1535
|
||||
tristate "ALI 1535"
|
||||
depends on PCI
|
||||
--- a/drivers/i2c/busses/Makefile
|
||||
+++ b/drivers/i2c/busses/Makefile
|
||||
@@ -3,6 +3,8 @@
|
||||
# Makefile for the i2c bus drivers.
|
||||
#
|
||||
|
||||
+obj-$(CONFIG_I2C_BCM2708) += i2c-bcm2708.o
|
||||
+
|
||||
# ACPI drivers
|
||||
obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o
|
||||
|
||||
--- /dev/null
|
||||
+++ b/drivers/i2c/busses/i2c-bcm2708.c
|
||||
@@ -0,0 +1,512 @@
|
||||
+/*
|
||||
+ * Driver for Broadcom BCM2708 BSC Controllers
|
||||
+ *
|
||||
+ * Copyright (C) 2012 Chris Boot & Frank Buss
|
||||
+ *
|
||||
+ * This driver is inspired by:
|
||||
+ * i2c-ocores.c, by Peter Korsgaard <jacmet@sunsite.dk>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/spinlock.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/sched.h>
|
||||
+#include <linux/wait.h>
|
||||
+
|
||||
+/* BSC register offsets */
|
||||
+#define BSC_C 0x00
|
||||
+#define BSC_S 0x04
|
||||
+#define BSC_DLEN 0x08
|
||||
+#define BSC_A 0x0c
|
||||
+#define BSC_FIFO 0x10
|
||||
+#define BSC_DIV 0x14
|
||||
+#define BSC_DEL 0x18
|
||||
+#define BSC_CLKT 0x1c
|
||||
+
|
||||
+/* Bitfields in BSC_C */
|
||||
+#define BSC_C_I2CEN 0x00008000
|
||||
+#define BSC_C_INTR 0x00000400
|
||||
+#define BSC_C_INTT 0x00000200
|
||||
+#define BSC_C_INTD 0x00000100
|
||||
+#define BSC_C_ST 0x00000080
|
||||
+#define BSC_C_CLEAR_1 0x00000020
|
||||
+#define BSC_C_CLEAR_2 0x00000010
|
||||
+#define BSC_C_READ 0x00000001
|
||||
+
|
||||
+/* Bitfields in BSC_S */
|
||||
+#define BSC_S_CLKT 0x00000200
|
||||
+#define BSC_S_ERR 0x00000100
|
||||
+#define BSC_S_RXF 0x00000080
|
||||
+#define BSC_S_TXE 0x00000040
|
||||
+#define BSC_S_RXD 0x00000020
|
||||
+#define BSC_S_TXD 0x00000010
|
||||
+#define BSC_S_RXR 0x00000008
|
||||
+#define BSC_S_TXW 0x00000004
|
||||
+#define BSC_S_DONE 0x00000002
|
||||
+#define BSC_S_TA 0x00000001
|
||||
+
|
||||
+#define I2C_WAIT_LOOP_COUNT 200
|
||||
+
|
||||
+#define DRV_NAME "bcm2708_i2c"
|
||||
+
|
||||
+static unsigned int baudrate;
|
||||
+module_param(baudrate, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
|
||||
+MODULE_PARM_DESC(baudrate, "The I2C baudrate");
|
||||
+
|
||||
+static bool combined = false;
|
||||
+module_param(combined, bool, 0644);
|
||||
+MODULE_PARM_DESC(combined, "Use combined transactions");
|
||||
+
|
||||
+struct bcm2708_i2c {
|
||||
+ struct i2c_adapter adapter;
|
||||
+
|
||||
+ spinlock_t lock;
|
||||
+ void __iomem *base;
|
||||
+ int irq;
|
||||
+ struct clk *clk;
|
||||
+ u32 cdiv;
|
||||
+ u32 clk_tout;
|
||||
+
|
||||
+ struct completion done;
|
||||
+
|
||||
+ struct i2c_msg *msg;
|
||||
+ int pos;
|
||||
+ int nmsgs;
|
||||
+ bool error;
|
||||
+};
|
||||
+
|
||||
+static inline u32 bcm2708_rd(struct bcm2708_i2c *bi, unsigned reg)
|
||||
+{
|
||||
+ return readl(bi->base + reg);
|
||||
+}
|
||||
+
|
||||
+static inline void bcm2708_wr(struct bcm2708_i2c *bi, unsigned reg, u32 val)
|
||||
+{
|
||||
+ writel(val, bi->base + reg);
|
||||
+}
|
||||
+
|
||||
+static inline void bcm2708_bsc_reset(struct bcm2708_i2c *bi)
|
||||
+{
|
||||
+ bcm2708_wr(bi, BSC_C, 0);
|
||||
+ bcm2708_wr(bi, BSC_S, BSC_S_CLKT | BSC_S_ERR | BSC_S_DONE);
|
||||
+}
|
||||
+
|
||||
+static inline void bcm2708_bsc_fifo_drain(struct bcm2708_i2c *bi)
|
||||
+{
|
||||
+ while ((bi->pos < bi->msg->len) && (bcm2708_rd(bi, BSC_S) & BSC_S_RXD))
|
||||
+ bi->msg->buf[bi->pos++] = bcm2708_rd(bi, BSC_FIFO);
|
||||
+}
|
||||
+
|
||||
+static inline void bcm2708_bsc_fifo_fill(struct bcm2708_i2c *bi)
|
||||
+{
|
||||
+ while ((bi->pos < bi->msg->len) && (bcm2708_rd(bi, BSC_S) & BSC_S_TXD))
|
||||
+ bcm2708_wr(bi, BSC_FIFO, bi->msg->buf[bi->pos++]);
|
||||
+}
|
||||
+
|
||||
+static inline int bcm2708_bsc_setup(struct bcm2708_i2c *bi)
|
||||
+{
|
||||
+ u32 cdiv, s, clk_tout;
|
||||
+ u32 c = BSC_C_I2CEN | BSC_C_INTD | BSC_C_ST | BSC_C_CLEAR_1;
|
||||
+ int wait_loops = I2C_WAIT_LOOP_COUNT;
|
||||
+
|
||||
+ /* Can't call clk_get_rate as it locks a mutex and here we are spinlocked.
|
||||
+ * Use the value that we cached in the probe.
|
||||
+ */
|
||||
+ cdiv = bi->cdiv;
|
||||
+ clk_tout = bi->clk_tout;
|
||||
+
|
||||
+ if (bi->msg->flags & I2C_M_RD)
|
||||
+ c |= BSC_C_INTR | BSC_C_READ;
|
||||
+ else
|
||||
+ c |= BSC_C_INTT;
|
||||
+
|
||||
+ bcm2708_wr(bi, BSC_CLKT, clk_tout);
|
||||
+ bcm2708_wr(bi, BSC_DIV, cdiv);
|
||||
+ bcm2708_wr(bi, BSC_A, bi->msg->addr);
|
||||
+ bcm2708_wr(bi, BSC_DLEN, bi->msg->len);
|
||||
+ if (combined)
|
||||
+ {
|
||||
+ /* Do the next two messages meet combined transaction criteria?
|
||||
+ - Current message is a write, next message is a read
|
||||
+ - Both messages to same slave address
|
||||
+ - Write message can fit inside FIFO (16 bytes or less) */
|
||||
+ if ( (bi->nmsgs > 1) &&
|
||||
+ !(bi->msg[0].flags & I2C_M_RD) && (bi->msg[1].flags & I2C_M_RD) &&
|
||||
+ (bi->msg[0].addr == bi->msg[1].addr) && (bi->msg[0].len <= 16)) {
|
||||
+
|
||||
+ /* Clear FIFO */
|
||||
+ bcm2708_wr(bi, BSC_C, BSC_C_CLEAR_1);
|
||||
+
|
||||
+ /* Fill FIFO with entire write message (16 byte FIFO) */
|
||||
+ while (bi->pos < bi->msg->len) {
|
||||
+ bcm2708_wr(bi, BSC_FIFO, bi->msg->buf[bi->pos++]);
|
||||
+ }
|
||||
+ /* Start write transfer (no interrupts, don't clear FIFO) */
|
||||
+ bcm2708_wr(bi, BSC_C, BSC_C_I2CEN | BSC_C_ST);
|
||||
+
|
||||
+ /* poll for transfer start bit (should only take 1-20 polls) */
|
||||
+ do {
|
||||
+ s = bcm2708_rd(bi, BSC_S);
|
||||
+ } while (!(s & (BSC_S_TA | BSC_S_ERR | BSC_S_CLKT | BSC_S_DONE)) && --wait_loops >= 0);
|
||||
+
|
||||
+ /* did we time out or some error occured? */
|
||||
+ if (wait_loops < 0 || (s & (BSC_S_ERR | BSC_S_CLKT))) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Send next read message before the write transfer finishes. */
|
||||
+ bi->nmsgs--;
|
||||
+ bi->msg++;
|
||||
+ bi->pos = 0;
|
||||
+ bcm2708_wr(bi, BSC_DLEN, bi->msg->len);
|
||||
+ c = BSC_C_I2CEN | BSC_C_INTD | BSC_C_INTR | BSC_C_ST | BSC_C_READ;
|
||||
+ }
|
||||
+ }
|
||||
+ bcm2708_wr(bi, BSC_C, c);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t bcm2708_i2c_interrupt(int irq, void *dev_id)
|
||||
+{
|
||||
+ struct bcm2708_i2c *bi = dev_id;
|
||||
+ bool handled = true;
|
||||
+ u32 s;
|
||||
+ int ret;
|
||||
+
|
||||
+ spin_lock(&bi->lock);
|
||||
+
|
||||
+ /* we may see camera interrupts on the "other" I2C channel
|
||||
+ Just return if we've not sent anything */
|
||||
+ if (!bi->nmsgs || !bi->msg) {
|
||||
+ goto early_exit;
|
||||
+ }
|
||||
+
|
||||
+ s = bcm2708_rd(bi, BSC_S);
|
||||
+
|
||||
+ if (s & (BSC_S_CLKT | BSC_S_ERR)) {
|
||||
+ bcm2708_bsc_reset(bi);
|
||||
+ bi->error = true;
|
||||
+
|
||||
+ bi->msg = 0; /* to inform the that all work is done */
|
||||
+ bi->nmsgs = 0;
|
||||
+ /* wake up our bh */
|
||||
+ complete(&bi->done);
|
||||
+ } else if (s & BSC_S_DONE) {
|
||||
+ bi->nmsgs--;
|
||||
+
|
||||
+ if (bi->msg->flags & I2C_M_RD) {
|
||||
+ bcm2708_bsc_fifo_drain(bi);
|
||||
+ }
|
||||
+
|
||||
+ bcm2708_bsc_reset(bi);
|
||||
+
|
||||
+ if (bi->nmsgs) {
|
||||
+ /* advance to next message */
|
||||
+ bi->msg++;
|
||||
+ bi->pos = 0;
|
||||
+ ret = bcm2708_bsc_setup(bi);
|
||||
+ if (ret < 0) {
|
||||
+ bcm2708_bsc_reset(bi);
|
||||
+ bi->error = true;
|
||||
+ bi->msg = 0; /* to inform the that all work is done */
|
||||
+ bi->nmsgs = 0;
|
||||
+ /* wake up our bh */
|
||||
+ complete(&bi->done);
|
||||
+ goto early_exit;
|
||||
+ }
|
||||
+ } else {
|
||||
+ bi->msg = 0; /* to inform the that all work is done */
|
||||
+ bi->nmsgs = 0;
|
||||
+ /* wake up our bh */
|
||||
+ complete(&bi->done);
|
||||
+ }
|
||||
+ } else if (s & BSC_S_TXW) {
|
||||
+ bcm2708_bsc_fifo_fill(bi);
|
||||
+ } else if (s & BSC_S_RXR) {
|
||||
+ bcm2708_bsc_fifo_drain(bi);
|
||||
+ } else {
|
||||
+ handled = false;
|
||||
+ }
|
||||
+
|
||||
+early_exit:
|
||||
+ spin_unlock(&bi->lock);
|
||||
+
|
||||
+ return handled ? IRQ_HANDLED : IRQ_NONE;
|
||||
+}
|
||||
+
|
||||
+static int bcm2708_i2c_master_xfer(struct i2c_adapter *adap,
|
||||
+ struct i2c_msg *msgs, int num)
|
||||
+{
|
||||
+ struct bcm2708_i2c *bi = adap->algo_data;
|
||||
+ unsigned long flags;
|
||||
+ int ret;
|
||||
+
|
||||
+ spin_lock_irqsave(&bi->lock, flags);
|
||||
+
|
||||
+ reinit_completion(&bi->done);
|
||||
+ bi->msg = msgs;
|
||||
+ bi->pos = 0;
|
||||
+ bi->nmsgs = num;
|
||||
+ bi->error = false;
|
||||
+
|
||||
+ ret = bcm2708_bsc_setup(bi);
|
||||
+
|
||||
+ spin_unlock_irqrestore(&bi->lock, flags);
|
||||
+
|
||||
+ /* check the result of the setup */
|
||||
+ if (ret < 0)
|
||||
+ {
|
||||
+ dev_err(&adap->dev, "transfer setup timed out\n");
|
||||
+ goto error_timeout;
|
||||
+ }
|
||||
+
|
||||
+ ret = wait_for_completion_timeout(&bi->done, adap->timeout);
|
||||
+ if (ret == 0) {
|
||||
+ dev_err(&adap->dev, "transfer timed out\n");
|
||||
+ goto error_timeout;
|
||||
+ }
|
||||
+
|
||||
+ ret = bi->error ? -EIO : num;
|
||||
+ return ret;
|
||||
+
|
||||
+error_timeout:
|
||||
+ spin_lock_irqsave(&bi->lock, flags);
|
||||
+ bcm2708_bsc_reset(bi);
|
||||
+ bi->msg = 0; /* to inform the interrupt handler that there's nothing else to be done */
|
||||
+ bi->nmsgs = 0;
|
||||
+ spin_unlock_irqrestore(&bi->lock, flags);
|
||||
+ return -ETIMEDOUT;
|
||||
+}
|
||||
+
|
||||
+static u32 bcm2708_i2c_functionality(struct i2c_adapter *adap)
|
||||
+{
|
||||
+ return I2C_FUNC_I2C | /*I2C_FUNC_10BIT_ADDR |*/ I2C_FUNC_SMBUS_EMUL;
|
||||
+}
|
||||
+
|
||||
+static struct i2c_algorithm bcm2708_i2c_algorithm = {
|
||||
+ .master_xfer = bcm2708_i2c_master_xfer,
|
||||
+ .functionality = bcm2708_i2c_functionality,
|
||||
+};
|
||||
+
|
||||
+static int bcm2708_i2c_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct resource *regs;
|
||||
+ int irq, err = -ENOMEM;
|
||||
+ struct clk *clk;
|
||||
+ struct bcm2708_i2c *bi;
|
||||
+ struct i2c_adapter *adap;
|
||||
+ unsigned long bus_hz;
|
||||
+ u32 cdiv, clk_tout;
|
||||
+ u32 baud;
|
||||
+
|
||||
+ baud = CONFIG_I2C_BCM2708_BAUDRATE;
|
||||
+
|
||||
+ if (pdev->dev.of_node) {
|
||||
+ u32 bus_clk_rate;
|
||||
+ pdev->id = of_alias_get_id(pdev->dev.of_node, "i2c");
|
||||
+ if (pdev->id < 0) {
|
||||
+ dev_err(&pdev->dev, "alias is missing\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ if (!of_property_read_u32(pdev->dev.of_node,
|
||||
+ "clock-frequency", &bus_clk_rate))
|
||||
+ baud = bus_clk_rate;
|
||||
+ else
|
||||
+ dev_warn(&pdev->dev,
|
||||
+ "Could not read clock-frequency property\n");
|
||||
+ }
|
||||
+
|
||||
+ if (baudrate)
|
||||
+ baud = baudrate;
|
||||
+
|
||||
+ regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
+ if (!regs) {
|
||||
+ dev_err(&pdev->dev, "could not get IO memory\n");
|
||||
+ return -ENXIO;
|
||||
+ }
|
||||
+
|
||||
+ irq = platform_get_irq(pdev, 0);
|
||||
+ if (irq < 0) {
|
||||
+ dev_err(&pdev->dev, "could not get IRQ\n");
|
||||
+ return irq;
|
||||
+ }
|
||||
+
|
||||
+ clk = clk_get(&pdev->dev, NULL);
|
||||
+ if (IS_ERR(clk)) {
|
||||
+ dev_err(&pdev->dev, "could not find clk: %ld\n", PTR_ERR(clk));
|
||||
+ return PTR_ERR(clk);
|
||||
+ }
|
||||
+
|
||||
+ err = clk_prepare_enable(clk);
|
||||
+ if (err) {
|
||||
+ dev_err(&pdev->dev, "could not enable clk: %d\n", err);
|
||||
+ goto out_clk_put;
|
||||
+ }
|
||||
+
|
||||
+ bi = kzalloc(sizeof(*bi), GFP_KERNEL);
|
||||
+ if (!bi)
|
||||
+ goto out_clk_disable;
|
||||
+
|
||||
+ platform_set_drvdata(pdev, bi);
|
||||
+
|
||||
+ adap = &bi->adapter;
|
||||
+ adap->class = I2C_CLASS_HWMON | I2C_CLASS_DDC;
|
||||
+ adap->algo = &bcm2708_i2c_algorithm;
|
||||
+ adap->algo_data = bi;
|
||||
+ adap->dev.parent = &pdev->dev;
|
||||
+ adap->nr = pdev->id;
|
||||
+ strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name));
|
||||
+ adap->dev.of_node = pdev->dev.of_node;
|
||||
+
|
||||
+ switch (pdev->id) {
|
||||
+ case 0:
|
||||
+ adap->class = I2C_CLASS_HWMON;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ adap->class = I2C_CLASS_DDC;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ adap->class = I2C_CLASS_DDC;
|
||||
+ break;
|
||||
+ default:
|
||||
+ dev_err(&pdev->dev, "can only bind to BSC 0, 1 or 2\n");
|
||||
+ err = -ENXIO;
|
||||
+ goto out_free_bi;
|
||||
+ }
|
||||
+
|
||||
+ spin_lock_init(&bi->lock);
|
||||
+ init_completion(&bi->done);
|
||||
+
|
||||
+ bi->base = ioremap(regs->start, resource_size(regs));
|
||||
+ if (!bi->base) {
|
||||
+ dev_err(&pdev->dev, "could not remap memory\n");
|
||||
+ goto out_free_bi;
|
||||
+ }
|
||||
+
|
||||
+ bi->irq = irq;
|
||||
+ bi->clk = clk;
|
||||
+
|
||||
+ err = request_irq(irq, bcm2708_i2c_interrupt, IRQF_SHARED,
|
||||
+ dev_name(&pdev->dev), bi);
|
||||
+ if (err) {
|
||||
+ dev_err(&pdev->dev, "could not request IRQ: %d\n", err);
|
||||
+ goto out_iounmap;
|
||||
+ }
|
||||
+
|
||||
+ bcm2708_bsc_reset(bi);
|
||||
+
|
||||
+ err = i2c_add_numbered_adapter(adap);
|
||||
+ if (err < 0) {
|
||||
+ dev_err(&pdev->dev, "could not add I2C adapter: %d\n", err);
|
||||
+ goto out_free_irq;
|
||||
+ }
|
||||
+
|
||||
+ bus_hz = clk_get_rate(bi->clk);
|
||||
+ cdiv = bus_hz / baud;
|
||||
+ if (cdiv > 0xffff) {
|
||||
+ cdiv = 0xffff;
|
||||
+ baud = bus_hz / cdiv;
|
||||
+ }
|
||||
+
|
||||
+ clk_tout = 35/1000*baud; //35ms timeout as per SMBus specs.
|
||||
+ if (clk_tout > 0xffff)
|
||||
+ clk_tout = 0xffff;
|
||||
+
|
||||
+ bi->cdiv = cdiv;
|
||||
+ bi->clk_tout = clk_tout;
|
||||
+
|
||||
+ dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d) (baudrate %d)\n",
|
||||
+ pdev->id, (unsigned long)regs->start, irq, baud);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+out_free_irq:
|
||||
+ free_irq(bi->irq, bi);
|
||||
+out_iounmap:
|
||||
+ iounmap(bi->base);
|
||||
+out_free_bi:
|
||||
+ kfree(bi);
|
||||
+out_clk_disable:
|
||||
+ clk_disable_unprepare(clk);
|
||||
+out_clk_put:
|
||||
+ clk_put(clk);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int bcm2708_i2c_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct bcm2708_i2c *bi = platform_get_drvdata(pdev);
|
||||
+
|
||||
+ platform_set_drvdata(pdev, NULL);
|
||||
+
|
||||
+ i2c_del_adapter(&bi->adapter);
|
||||
+ free_irq(bi->irq, bi);
|
||||
+ iounmap(bi->base);
|
||||
+ clk_disable_unprepare(bi->clk);
|
||||
+ clk_put(bi->clk);
|
||||
+ kfree(bi);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id bcm2708_i2c_of_match[] = {
|
||||
+ { .compatible = "brcm,bcm2708-i2c" },
|
||||
+ {},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, bcm2708_i2c_of_match);
|
||||
+
|
||||
+static struct platform_driver bcm2708_i2c_driver = {
|
||||
+ .driver = {
|
||||
+ .name = DRV_NAME,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .of_match_table = bcm2708_i2c_of_match,
|
||||
+ },
|
||||
+ .probe = bcm2708_i2c_probe,
|
||||
+ .remove = bcm2708_i2c_remove,
|
||||
+};
|
||||
+
|
||||
+// module_platform_driver(bcm2708_i2c_driver);
|
||||
+
|
||||
+
|
||||
+static int __init bcm2708_i2c_init(void)
|
||||
+{
|
||||
+ return platform_driver_register(&bcm2708_i2c_driver);
|
||||
+}
|
||||
+
|
||||
+static void __exit bcm2708_i2c_exit(void)
|
||||
+{
|
||||
+ platform_driver_unregister(&bcm2708_i2c_driver);
|
||||
+}
|
||||
+
|
||||
+module_init(bcm2708_i2c_init);
|
||||
+module_exit(bcm2708_i2c_exit);
|
||||
+
|
||||
+
|
||||
+
|
||||
+MODULE_DESCRIPTION("BSC controller driver for Broadcom BCM2708");
|
||||
+MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_ALIAS("platform:" DRV_NAME);
|
@ -0,0 +1,273 @@
|
||||
From c06f4c20c2f65539c7f50a05396d5eca9a4ad5e8 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Fri, 26 Jun 2015 14:27:06 +0200
|
||||
Subject: [PATCH 0099/1085] char: broadcom: Add vcio module
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add module for accessing the mailbox property channel through
|
||||
/dev/vcio. Was previously in bcm2708-vcio.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
char: vcio: Add compat ioctl handling
|
||||
|
||||
There was no compat ioctl handler, so 32 bit userspace on a
|
||||
64 bit kernel failed as IOCTL_MBOX_PROPERTY used the size
|
||||
of char*.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
|
||||
char: vcio: Fail probe if rpi_firmware is not found.
|
||||
|
||||
Device Tree is now the only supported config mechanism, therefore
|
||||
uncomment the block of code that fails the probe if the
|
||||
firmware node can't be found.
|
||||
|
||||
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
|
||||
drivers: char: vcio: Use common compat header
|
||||
|
||||
The definition of compat_ptr is now common for most platforms, but
|
||||
requires the inclusion of <linux/compat.h>.
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
|
||||
char: vcio: Rewrite as a firmware node child
|
||||
|
||||
The old vcio driver is a simple character device that manually locates
|
||||
the firmware driver. Initialising it before the firmware driver causes
|
||||
a failure, and no retries are attempted.
|
||||
|
||||
Rewrite vcio as a platform driver that depends on a DT node for its
|
||||
instantiation and the location of the firmware driver, making use of
|
||||
the miscdevice framework to reduce the code size.
|
||||
|
||||
N.B. Using miscdevice changes the udev SUBSYSTEM string, so a change
|
||||
to the companion udev rule is required in order to continue to set
|
||||
the correct device permissions, e.g.:
|
||||
|
||||
KERNEL="vcio", GROUP="video", MODE="0660"
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/4620
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
drivers/char/broadcom/Kconfig | 6 ++
|
||||
drivers/char/broadcom/Makefile | 1 +
|
||||
drivers/char/broadcom/vcio.c | 186 +++++++++++++++++++++++++++++++++
|
||||
3 files changed, 193 insertions(+)
|
||||
create mode 100644 drivers/char/broadcom/vcio.c
|
||||
|
||||
--- a/drivers/char/broadcom/Kconfig
|
||||
+++ b/drivers/char/broadcom/Kconfig
|
||||
@@ -15,6 +15,12 @@ config BCM2708_VCMEM
|
||||
help
|
||||
Helper for videocore memory access and total size allocation.
|
||||
|
||||
+config BCM_VCIO
|
||||
+ tristate "Mailbox userspace access"
|
||||
+ depends on BCM2835_MBOX
|
||||
+ help
|
||||
+ Gives access to the mailbox property channel from userspace.
|
||||
+
|
||||
endif
|
||||
|
||||
config BCM2835_DEVGPIOMEM
|
||||
--- a/drivers/char/broadcom/Makefile
|
||||
+++ b/drivers/char/broadcom/Makefile
|
||||
@@ -1,3 +1,4 @@
|
||||
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
|
||||
+obj-$(CONFIG_BCM_VCIO) += vcio.o
|
||||
obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
|
||||
obj-$(CONFIG_BCM2835_SMI_DEV) += bcm2835_smi_dev.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/char/broadcom/vcio.c
|
||||
@@ -0,0 +1,186 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2010 Broadcom
|
||||
+ * Copyright (C) 2015 Noralf Trønnes
|
||||
+ * Copyright (C) 2021 Raspberry Pi (Trading) Ltd.
|
||||
+ *
|
||||
+ * 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/cdev.h>
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/fs.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/ioctl.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/uaccess.h>
|
||||
+#include <linux/compat.h>
|
||||
+#include <linux/miscdevice.h>
|
||||
+#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
+
|
||||
+#define MODULE_NAME "vcio"
|
||||
+#define VCIO_IOC_MAGIC 100
|
||||
+#define IOCTL_MBOX_PROPERTY _IOWR(VCIO_IOC_MAGIC, 0, char *)
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+#define IOCTL_MBOX_PROPERTY32 _IOWR(VCIO_IOC_MAGIC, 0, compat_uptr_t)
|
||||
+#endif
|
||||
+
|
||||
+struct vcio_data {
|
||||
+ struct rpi_firmware *fw;
|
||||
+ struct miscdevice misc_dev;
|
||||
+};
|
||||
+
|
||||
+static int vcio_user_property_list(struct vcio_data *vcio, void *user)
|
||||
+{
|
||||
+ u32 *buf, size;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* The first 32-bit is the size of the buffer */
|
||||
+ if (copy_from_user(&size, user, sizeof(size)))
|
||||
+ return -EFAULT;
|
||||
+
|
||||
+ buf = kmalloc(size, GFP_KERNEL);
|
||||
+ if (!buf)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ if (copy_from_user(buf, user, size)) {
|
||||
+ kfree(buf);
|
||||
+ return -EFAULT;
|
||||
+ }
|
||||
+
|
||||
+ /* Strip off protocol encapsulation */
|
||||
+ ret = rpi_firmware_property_list(vcio->fw, &buf[2], size - 12);
|
||||
+ if (ret) {
|
||||
+ kfree(buf);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ buf[1] = RPI_FIRMWARE_STATUS_SUCCESS;
|
||||
+ if (copy_to_user(user, buf, size))
|
||||
+ ret = -EFAULT;
|
||||
+
|
||||
+ kfree(buf);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int vcio_device_open(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ try_module_get(THIS_MODULE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int vcio_device_release(struct inode *inode, struct file *file)
|
||||
+{
|
||||
+ module_put(THIS_MODULE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static long vcio_device_ioctl(struct file *file, unsigned int ioctl_num,
|
||||
+ unsigned long ioctl_param)
|
||||
+{
|
||||
+ struct vcio_data *vcio = container_of(file->private_data,
|
||||
+ struct vcio_data, misc_dev);
|
||||
+
|
||||
+ switch (ioctl_num) {
|
||||
+ case IOCTL_MBOX_PROPERTY:
|
||||
+ return vcio_user_property_list(vcio, (void *)ioctl_param);
|
||||
+ default:
|
||||
+ pr_err("unknown ioctl: %x\n", ioctl_num);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+static long vcio_device_compat_ioctl(struct file *file, unsigned int ioctl_num,
|
||||
+ unsigned long ioctl_param)
|
||||
+{
|
||||
+ struct vcio_data *vcio = container_of(file->private_data,
|
||||
+ struct vcio_data, misc_dev);
|
||||
+
|
||||
+ switch (ioctl_num) {
|
||||
+ case IOCTL_MBOX_PROPERTY32:
|
||||
+ return vcio_user_property_list(vcio, compat_ptr(ioctl_param));
|
||||
+ default:
|
||||
+ pr_err("unknown ioctl: %x\n", ioctl_num);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+const struct file_operations vcio_fops = {
|
||||
+ .unlocked_ioctl = vcio_device_ioctl,
|
||||
+#ifdef CONFIG_COMPAT
|
||||
+ .compat_ioctl = vcio_device_compat_ioctl,
|
||||
+#endif
|
||||
+ .open = vcio_device_open,
|
||||
+ .release = vcio_device_release,
|
||||
+};
|
||||
+
|
||||
+static int vcio_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct device_node *np = dev->of_node;
|
||||
+ struct device_node *fw_node;
|
||||
+ struct rpi_firmware *fw;
|
||||
+ struct vcio_data *vcio;
|
||||
+
|
||||
+ fw_node = of_get_parent(np);
|
||||
+ if (!fw_node) {
|
||||
+ dev_err(dev, "Missing firmware node\n");
|
||||
+ return -ENOENT;
|
||||
+ }
|
||||
+
|
||||
+ fw = rpi_firmware_get(fw_node);
|
||||
+ of_node_put(fw_node);
|
||||
+ if (!fw)
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ vcio = devm_kzalloc(dev, sizeof(struct vcio_data), GFP_KERNEL);
|
||||
+ if (!vcio)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ vcio->fw = fw;
|
||||
+ vcio->misc_dev.fops = &vcio_fops;
|
||||
+ vcio->misc_dev.minor = MISC_DYNAMIC_MINOR;
|
||||
+ vcio->misc_dev.name = "vcio";
|
||||
+ vcio->misc_dev.parent = dev;
|
||||
+
|
||||
+ return misc_register(&vcio->misc_dev);
|
||||
+}
|
||||
+
|
||||
+static int vcio_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+
|
||||
+ misc_deregister(dev_get_drvdata(dev));
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id vcio_ids[] = {
|
||||
+ { .compatible = "raspberrypi,vcio" },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, vcio_ids);
|
||||
+
|
||||
+static struct platform_driver vcio_driver = {
|
||||
+ .driver = {
|
||||
+ .name = MODULE_NAME,
|
||||
+ .of_match_table = of_match_ptr(vcio_ids),
|
||||
+ },
|
||||
+ .probe = vcio_probe,
|
||||
+ .remove = vcio_remove,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(vcio_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Gray Girling");
|
||||
+MODULE_AUTHOR("Noralf Trønnes");
|
||||
+MODULE_DESCRIPTION("Mailbox userspace access");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_ALIAS("platform:rpi-vcio");
|
@ -0,0 +1,74 @@
|
||||
From 75fe4d48f81e03ff4201df164990cb85eb3084bc Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
|
||||
Date: Fri, 26 Jun 2015 14:25:01 +0200
|
||||
Subject: [PATCH 0100/1085] firmware: bcm2835: Support ARCH_BCM270x
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Support booting without Device Tree.
|
||||
Turn on USB power.
|
||||
Load driver early because of lacking support for deferred probing
|
||||
in many drivers.
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
|
||||
firmware: bcm2835: Don't turn on USB power
|
||||
|
||||
The raspberrypi-power driver is now used to turn on USB power.
|
||||
|
||||
This partly reverts commit:
|
||||
firmware: bcm2835: Support ARCH_BCM270x
|
||||
|
||||
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
|
||||
---
|
||||
drivers/firmware/raspberrypi.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/firmware/raspberrypi.c
|
||||
+++ b/drivers/firmware/raspberrypi.c
|
||||
@@ -34,6 +34,8 @@ struct rpi_firmware {
|
||||
struct kref consumers;
|
||||
};
|
||||
|
||||
+static struct platform_device *g_pdev;
|
||||
+
|
||||
static DEFINE_MUTEX(transaction_lock);
|
||||
|
||||
static void response_callback(struct mbox_client *cl, void *msg)
|
||||
@@ -300,6 +302,7 @@ static int rpi_firmware_probe(struct pla
|
||||
kref_init(&fw->consumers);
|
||||
|
||||
platform_set_drvdata(pdev, fw);
|
||||
+ g_pdev = pdev;
|
||||
|
||||
rpi_firmware_print_firmware_revision(fw);
|
||||
rpi_register_hwmon_driver(dev, fw);
|
||||
@@ -328,6 +331,7 @@ static int rpi_firmware_remove(struct pl
|
||||
rpi_clk = NULL;
|
||||
|
||||
rpi_firmware_put(fw);
|
||||
+ g_pdev = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -408,7 +412,18 @@ static struct platform_driver rpi_firmwa
|
||||
.shutdown = rpi_firmware_shutdown,
|
||||
.remove = rpi_firmware_remove,
|
||||
};
|
||||
-module_platform_driver(rpi_firmware_driver);
|
||||
+
|
||||
+static int __init rpi_firmware_init(void)
|
||||
+{
|
||||
+ return platform_driver_register(&rpi_firmware_driver);
|
||||
+}
|
||||
+subsys_initcall(rpi_firmware_init);
|
||||
+
|
||||
+static void __init rpi_firmware_exit(void)
|
||||
+{
|
||||
+ platform_driver_unregister(&rpi_firmware_driver);
|
||||
+}
|
||||
+module_exit(rpi_firmware_exit);
|
||||
|
||||
MODULE_AUTHOR("Eric Anholt <eric@anholt.net>");
|
||||
MODULE_DESCRIPTION("Raspberry Pi firmware driver");
|
@ -0,0 +1,168 @@
|
||||
From f4853446bd5a614678fd7dffb4f8c91c6ecf61dc Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Fri, 6 Feb 2015 13:50:57 +0000
|
||||
Subject: [PATCH 0101/1085] leds: Add the "input" trigger, for pwr_led
|
||||
|
||||
The "input" trigger makes the associated GPIO an input. This is to support
|
||||
the Raspberry Pi PWR LED, which is driven by external hardware in normal use.
|
||||
|
||||
N.B. pwr_led is not available on Model A or B boards.
|
||||
|
||||
leds-gpio: Implement the brightness_get method
|
||||
|
||||
The power LED uses some clever logic that means it is driven
|
||||
by a voltage measuring circuit when configured as input, otherwise
|
||||
it is driven by the GPIO output value. This patch wires up the
|
||||
brightness_get method for leds-gpio so that user-space can monitor
|
||||
the LED value via /sys/class/gpio/led1/brightness. Using the input
|
||||
trigger this returns an indication of the system power health,
|
||||
otherwise it is just whatever value the trigger has written most
|
||||
recently.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/1064
|
||||
---
|
||||
drivers/leds/leds-gpio.c | 17 ++++++++-
|
||||
drivers/leds/trigger/Kconfig | 7 ++++
|
||||
drivers/leds/trigger/Makefile | 1 +
|
||||
drivers/leds/trigger/ledtrig-input.c | 55 ++++++++++++++++++++++++++++
|
||||
include/linux/leds.h | 3 ++
|
||||
5 files changed, 82 insertions(+), 1 deletion(-)
|
||||
create mode 100644 drivers/leds/trigger/ledtrig-input.c
|
||||
|
||||
--- a/drivers/leds/leds-gpio.c
|
||||
+++ b/drivers/leds/leds-gpio.c
|
||||
@@ -48,8 +48,15 @@ static void gpio_led_set(struct led_clas
|
||||
led_dat->platform_gpio_blink_set(led_dat->gpiod, level,
|
||||
NULL, NULL);
|
||||
led_dat->blinking = 0;
|
||||
+ } else if (led_dat->cdev.flags & SET_GPIO_INPUT) {
|
||||
+ gpiod_direction_input(led_dat->gpiod);
|
||||
+ led_dat->cdev.flags &= ~SET_GPIO_INPUT;
|
||||
+ } else if (led_dat->cdev.flags & SET_GPIO_OUTPUT) {
|
||||
+ gpiod_direction_output(led_dat->gpiod, level);
|
||||
+ led_dat->cdev.flags &= ~SET_GPIO_OUTPUT;
|
||||
} else {
|
||||
- if (led_dat->can_sleep)
|
||||
+ if (led_dat->can_sleep ||
|
||||
+ (led_dat->cdev.flags & (SET_GPIO_INPUT | SET_GPIO_OUTPUT) ))
|
||||
gpiod_set_value_cansleep(led_dat->gpiod, level);
|
||||
else
|
||||
gpiod_set_value(led_dat->gpiod, level);
|
||||
@@ -63,6 +70,13 @@ static int gpio_led_set_blocking(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static enum led_brightness gpio_led_get(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ struct gpio_led_data *led_dat =
|
||||
+ container_of(led_cdev, struct gpio_led_data, cdev);
|
||||
+ return gpiod_get_value_cansleep(led_dat->gpiod) ? LED_FULL : LED_OFF;
|
||||
+}
|
||||
+
|
||||
static int gpio_blink_set(struct led_classdev *led_cdev,
|
||||
unsigned long *delay_on, unsigned long *delay_off)
|
||||
{
|
||||
@@ -92,6 +106,7 @@ static int create_gpio_led(const struct
|
||||
led_dat->platform_gpio_blink_set = blink_set;
|
||||
led_dat->cdev.blink_set = gpio_blink_set;
|
||||
}
|
||||
+ led_dat->cdev.brightness_get = gpio_led_get;
|
||||
if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP) {
|
||||
state = gpiod_get_value_cansleep(led_dat->gpiod);
|
||||
if (state < 0)
|
||||
--- a/drivers/leds/trigger/Kconfig
|
||||
+++ b/drivers/leds/trigger/Kconfig
|
||||
@@ -116,6 +116,13 @@ config LEDS_TRIGGER_CAMERA
|
||||
This enables direct flash/torch on/off by the driver, kernel space.
|
||||
If unsure, say Y.
|
||||
|
||||
+config LEDS_TRIGGER_INPUT
|
||||
+ tristate "LED Input Trigger"
|
||||
+ depends on LEDS_TRIGGERS
|
||||
+ help
|
||||
+ This allows the GPIOs assigned to be LEDs to be initialised to inputs.
|
||||
+ If unsure, say Y.
|
||||
+
|
||||
config LEDS_TRIGGER_PANIC
|
||||
bool "LED Panic Trigger"
|
||||
help
|
||||
--- a/drivers/leds/trigger/Makefile
|
||||
+++ b/drivers/leds/trigger/Makefile
|
||||
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_TRIGGER_ACTIVITY) += l
|
||||
obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
|
||||
+obj-$(CONFIG_LEDS_TRIGGER_INPUT) += ledtrig-input.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_NETDEV) += ledtrig-netdev.o
|
||||
obj-$(CONFIG_LEDS_TRIGGER_PATTERN) += ledtrig-pattern.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/leds/trigger/ledtrig-input.c
|
||||
@@ -0,0 +1,55 @@
|
||||
+/*
|
||||
+ * Set LED GPIO to Input "Trigger"
|
||||
+ *
|
||||
+ * Copyright 2015 Phil Elwell <phil@raspberrypi.org>
|
||||
+ *
|
||||
+ * Based on Nick Forbes's ledtrig-default-on.c.
|
||||
+ *
|
||||
+ * 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/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/leds.h>
|
||||
+#include <linux/gpio.h>
|
||||
+#include "../leds.h"
|
||||
+
|
||||
+static int input_trig_activate(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_cdev->flags |= SET_GPIO_INPUT;
|
||||
+ led_set_brightness(led_cdev, 0);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void input_trig_deactivate(struct led_classdev *led_cdev)
|
||||
+{
|
||||
+ led_cdev->flags |= SET_GPIO_OUTPUT;
|
||||
+ led_set_brightness(led_cdev, 0);
|
||||
+}
|
||||
+
|
||||
+static struct led_trigger input_led_trigger = {
|
||||
+ .name = "input",
|
||||
+ .activate = input_trig_activate,
|
||||
+ .deactivate = input_trig_deactivate,
|
||||
+};
|
||||
+
|
||||
+static int __init input_trig_init(void)
|
||||
+{
|
||||
+ return led_trigger_register(&input_led_trigger);
|
||||
+}
|
||||
+
|
||||
+static void __exit input_trig_exit(void)
|
||||
+{
|
||||
+ led_trigger_unregister(&input_led_trigger);
|
||||
+}
|
||||
+
|
||||
+module_init(input_trig_init);
|
||||
+module_exit(input_trig_exit);
|
||||
+
|
||||
+MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>");
|
||||
+MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\"");
|
||||
+MODULE_LICENSE("GPL");
|
||||
--- a/include/linux/leds.h
|
||||
+++ b/include/linux/leds.h
|
||||
@@ -115,6 +115,9 @@ struct led_classdev {
|
||||
#define LED_BRIGHT_HW_CHANGED BIT(21)
|
||||
#define LED_RETAIN_AT_SHUTDOWN BIT(22)
|
||||
#define LED_INIT_DEFAULT_TRIGGER BIT(23)
|
||||
+ /* Additions for Raspberry Pi PWR LED */
|
||||
+#define SET_GPIO_INPUT BIT(30)
|
||||
+#define SET_GPIO_OUTPUT BIT(31)
|
||||
|
||||
/* set_brightness_work / blink_timer flags, atomic, private. */
|
||||
unsigned long work_flags;
|
@ -0,0 +1,22 @@
|
||||
From f251929cebf81d69cf8fce73bde7e5808c9517c4 Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Wed, 3 Jul 2013 00:54:08 +0100
|
||||
Subject: [PATCH 0102/1085] Added Device IDs for August DVB-T 205
|
||||
|
||||
---
|
||||
drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
|
||||
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
|
||||
@@ -1964,6 +1964,10 @@ static const struct usb_device_id rtl28x
|
||||
&rtl28xxu_props, "Compro VideoMate U650F", NULL) },
|
||||
{ DVB_USB_DEVICE(USB_VID_KWORLD_2, 0xd394,
|
||||
&rtl28xxu_props, "MaxMedia HU394-T", NULL) },
|
||||
+ { DVB_USB_DEVICE(USB_VID_GTEK, 0xb803 /*USB_PID_AUGUST_DVBT205*/,
|
||||
+ &rtl28xxu_props, "August DVB-T 205", NULL) },
|
||||
+ { DVB_USB_DEVICE(USB_VID_GTEK, 0xa803 /*USB_PID_AUGUST_DVBT205*/,
|
||||
+ &rtl28xxu_props, "August DVB-T 205", NULL) },
|
||||
{ DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a03,
|
||||
&rtl28xxu_props, "Leadtek WinFast DTV Dongle mini", NULL) },
|
||||
{ DVB_USB_DEVICE(USB_VID_GTEK, USB_PID_CPYTO_REDI_PC50A,
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,43 @@
|
||||
From 2f6663e10a6111b3b66dcada9e9e2d64e86e67be Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <phil@raspberrypi.org>
|
||||
Date: Thu, 25 Jun 2015 12:16:11 +0100
|
||||
Subject: [PATCH 0104/1085] gpio-poweroff: Allow it to work on Raspberry Pi
|
||||
|
||||
The Raspberry Pi firmware manages the power-down and reboot
|
||||
process. To do this it installs a pm_power_off handler, causing
|
||||
the gpio-poweroff module to abort the probe function.
|
||||
|
||||
This patch introduces a "force" DT property that overrides that
|
||||
behaviour, and also adds a DT overlay to enable and control it.
|
||||
|
||||
Note that running in an active-low configuration (DT parameter
|
||||
"active_low") requires a custom dt-blob.bin and probably won't
|
||||
allow a reboot without switching off, so an external inversion
|
||||
of the trigger signal may be preferable.
|
||||
---
|
||||
drivers/power/reset/gpio-poweroff.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/power/reset/gpio-poweroff.c
|
||||
+++ b/drivers/power/reset/gpio-poweroff.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/platform_device.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
@@ -51,9 +52,11 @@ static int gpio_poweroff_probe(struct pl
|
||||
{
|
||||
bool input = false;
|
||||
enum gpiod_flags flags;
|
||||
+ bool force = false;
|
||||
|
||||
/* If a pm_power_off function has already been added, leave it alone */
|
||||
- if (pm_power_off != NULL) {
|
||||
+ force = of_property_read_bool(pdev->dev.of_node, "force");
|
||||
+ if (!force && (pm_power_off != NULL)) {
|
||||
dev_err(&pdev->dev,
|
||||
"%s: pm_power_off function already registered\n",
|
||||
__func__);
|
@ -0,0 +1,849 @@
|
||||
From 0ab51e2d6e1095c8066f61b07899a65b6a5eadd4 Mon Sep 17 00:00:00 2001
|
||||
From: Phil Elwell <pelwell@users.noreply.github.com>
|
||||
Date: Tue, 14 Jul 2015 14:32:47 +0100
|
||||
Subject: [PATCH 0105/1085] mfd: Add Raspberry Pi Sense HAT core driver
|
||||
|
||||
mfd: Add rpi_sense_core of compatible string
|
||||
---
|
||||
drivers/input/joystick/Kconfig | 8 +
|
||||
drivers/input/joystick/Makefile | 1 +
|
||||
drivers/input/joystick/rpisense-js.c | 153 ++++++++++++
|
||||
drivers/mfd/Kconfig | 8 +
|
||||
drivers/mfd/Makefile | 1 +
|
||||
drivers/mfd/rpisense-core.c | 163 +++++++++++++
|
||||
drivers/video/fbdev/Kconfig | 13 +
|
||||
drivers/video/fbdev/Makefile | 1 +
|
||||
drivers/video/fbdev/rpisense-fb.c | 293 +++++++++++++++++++++++
|
||||
include/linux/mfd/rpisense/core.h | 47 ++++
|
||||
include/linux/mfd/rpisense/framebuffer.h | 32 +++
|
||||
include/linux/mfd/rpisense/joystick.h | 35 +++
|
||||
12 files changed, 755 insertions(+)
|
||||
create mode 100644 drivers/input/joystick/rpisense-js.c
|
||||
create mode 100644 drivers/mfd/rpisense-core.c
|
||||
create mode 100644 drivers/video/fbdev/rpisense-fb.c
|
||||
create mode 100644 include/linux/mfd/rpisense/core.h
|
||||
create mode 100644 include/linux/mfd/rpisense/framebuffer.h
|
||||
create mode 100644 include/linux/mfd/rpisense/joystick.h
|
||||
|
||||
--- a/drivers/input/joystick/Kconfig
|
||||
+++ b/drivers/input/joystick/Kconfig
|
||||
@@ -412,4 +412,12 @@ config JOYSTICK_SENSEHAT
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called sensehat_joystick.
|
||||
|
||||
+config JOYSTICK_RPISENSE
|
||||
+ tristate "Raspberry Pi Sense HAT joystick"
|
||||
+ depends on GPIOLIB && INPUT
|
||||
+ select MFD_RPISENSE_CORE
|
||||
+
|
||||
+ help
|
||||
+ This is the joystick driver for the Raspberry Pi Sense HAT
|
||||
+
|
||||
endif
|
||||
--- a/drivers/input/joystick/Makefile
|
||||
+++ b/drivers/input/joystick/Makefile
|
||||
@@ -40,3 +40,4 @@ obj-$(CONFIG_JOYSTICK_WARRIOR) += warri
|
||||
obj-$(CONFIG_JOYSTICK_WALKERA0701) += walkera0701.o
|
||||
obj-$(CONFIG_JOYSTICK_XPAD) += xpad.o
|
||||
obj-$(CONFIG_JOYSTICK_ZHENHUA) += zhenhua.o
|
||||
+obj-$(CONFIG_JOYSTICK_RPISENSE) += rpisense-js.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/input/joystick/rpisense-js.c
|
||||
@@ -0,0 +1,153 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT joystick driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <linux/mfd/rpisense/joystick.h>
|
||||
+#include <linux/mfd/rpisense/core.h>
|
||||
+
|
||||
+static struct rpisense *rpisense;
|
||||
+static unsigned char keymap[5] = {KEY_DOWN, KEY_RIGHT, KEY_UP, KEY_ENTER, KEY_LEFT,};
|
||||
+
|
||||
+static void keys_work_fn(struct work_struct *work)
|
||||
+{
|
||||
+ int i;
|
||||
+ static s32 prev_keys;
|
||||
+ struct rpisense_js *rpisense_js = &rpisense->joystick;
|
||||
+ s32 keys = rpisense_reg_read(rpisense, RPISENSE_KEYS);
|
||||
+ s32 changes = keys ^ prev_keys;
|
||||
+
|
||||
+ prev_keys = keys;
|
||||
+ for (i = 0; i < 5; i++) {
|
||||
+ if (changes & 1) {
|
||||
+ input_report_key(rpisense_js->keys_dev,
|
||||
+ keymap[i], keys & 1);
|
||||
+ }
|
||||
+ changes >>= 1;
|
||||
+ keys >>= 1;
|
||||
+ }
|
||||
+ input_sync(rpisense_js->keys_dev);
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t keys_irq_handler(int irq, void *pdev)
|
||||
+{
|
||||
+ struct rpisense_js *rpisense_js = &rpisense->joystick;
|
||||
+
|
||||
+ schedule_work(&rpisense_js->keys_work_s);
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static int rpisense_js_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ int ret;
|
||||
+ int i;
|
||||
+ struct rpisense_js *rpisense_js;
|
||||
+
|
||||
+ rpisense = rpisense_get_dev();
|
||||
+ rpisense_js = &rpisense->joystick;
|
||||
+
|
||||
+ INIT_WORK(&rpisense_js->keys_work_s, keys_work_fn);
|
||||
+
|
||||
+ rpisense_js->keys_dev = input_allocate_device();
|
||||
+ if (!rpisense_js->keys_dev) {
|
||||
+ dev_err(&pdev->dev, "Could not allocate input device.\n");
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY);
|
||||
+ for (i = 0; i < ARRAY_SIZE(keymap); i++) {
|
||||
+ set_bit(keymap[i],
|
||||
+ rpisense_js->keys_dev->keybit);
|
||||
+ }
|
||||
+
|
||||
+ rpisense_js->keys_dev->name = "Raspberry Pi Sense HAT Joystick";
|
||||
+ rpisense_js->keys_dev->phys = "rpi-sense-joy/input0";
|
||||
+ rpisense_js->keys_dev->id.bustype = BUS_I2C;
|
||||
+ rpisense_js->keys_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
|
||||
+ rpisense_js->keys_dev->keycode = keymap;
|
||||
+ rpisense_js->keys_dev->keycodesize = sizeof(unsigned char);
|
||||
+ rpisense_js->keys_dev->keycodemax = ARRAY_SIZE(keymap);
|
||||
+
|
||||
+ ret = input_register_device(rpisense_js->keys_dev);
|
||||
+ if (ret) {
|
||||
+ dev_err(&pdev->dev, "Could not register input device.\n");
|
||||
+ goto err_keys_alloc;
|
||||
+ }
|
||||
+
|
||||
+ ret = gpiod_direction_input(rpisense_js->keys_desc);
|
||||
+ if (ret) {
|
||||
+ dev_err(&pdev->dev, "Could not set keys-int direction.\n");
|
||||
+ goto err_keys_reg;
|
||||
+ }
|
||||
+
|
||||
+ rpisense_js->keys_irq = gpiod_to_irq(rpisense_js->keys_desc);
|
||||
+ if (rpisense_js->keys_irq < 0) {
|
||||
+ dev_err(&pdev->dev, "Could not determine keys-int IRQ.\n");
|
||||
+ ret = rpisense_js->keys_irq;
|
||||
+ goto err_keys_reg;
|
||||
+ }
|
||||
+
|
||||
+ ret = devm_request_irq(&pdev->dev, rpisense_js->keys_irq,
|
||||
+ keys_irq_handler, IRQF_TRIGGER_RISING,
|
||||
+ "keys", &pdev->dev);
|
||||
+ if (ret) {
|
||||
+ dev_err(&pdev->dev, "IRQ request failed.\n");
|
||||
+ goto err_keys_reg;
|
||||
+ }
|
||||
+ return 0;
|
||||
+err_keys_reg:
|
||||
+ input_unregister_device(rpisense_js->keys_dev);
|
||||
+err_keys_alloc:
|
||||
+ input_free_device(rpisense_js->keys_dev);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int rpisense_js_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct rpisense_js *rpisense_js = &rpisense->joystick;
|
||||
+
|
||||
+ input_unregister_device(rpisense_js->keys_dev);
|
||||
+ input_free_device(rpisense_js->keys_dev);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_OF
|
||||
+static const struct of_device_id rpisense_js_id[] = {
|
||||
+ { .compatible = "rpi,rpi-sense-js" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, rpisense_js_id);
|
||||
+#endif
|
||||
+
|
||||
+static struct platform_device_id rpisense_js_device_id[] = {
|
||||
+ { .name = "rpi-sense-js" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(platform, rpisense_js_device_id);
|
||||
+
|
||||
+static struct platform_driver rpisense_js_driver = {
|
||||
+ .probe = rpisense_js_probe,
|
||||
+ .remove = rpisense_js_remove,
|
||||
+ .driver = {
|
||||
+ .name = "rpi-sense-js",
|
||||
+ .owner = THIS_MODULE,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(rpisense_js_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Raspberry Pi Sense HAT joystick driver");
|
||||
+MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
--- a/drivers/mfd/Kconfig
|
||||
+++ b/drivers/mfd/Kconfig
|
||||
@@ -11,6 +11,14 @@ config MFD_CORE
|
||||
select IRQ_DOMAIN
|
||||
default n
|
||||
|
||||
+config MFD_RPISENSE_CORE
|
||||
+ tristate "Raspberry Pi Sense HAT core functions"
|
||||
+ depends on I2C
|
||||
+ select MFD_CORE
|
||||
+ help
|
||||
+ This is the core driver for the Raspberry Pi Sense HAT. This provides
|
||||
+ the necessary functions to communicate with the hardware.
|
||||
+
|
||||
config MFD_CS5535
|
||||
tristate "AMD CS5535 and CS5536 southbridge core functions"
|
||||
select MFD_CORE
|
||||
--- a/drivers/mfd/Makefile
|
||||
+++ b/drivers/mfd/Makefile
|
||||
@@ -268,6 +268,7 @@ obj-$(CONFIG_MFD_STMFX) += stmfx.o
|
||||
obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o
|
||||
obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o
|
||||
obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o
|
||||
+obj-$(CONFIG_MFD_RPISENSE_CORE) += rpisense-core.o
|
||||
|
||||
obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o
|
||||
obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/mfd/rpisense-core.c
|
||||
@@ -0,0 +1,163 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT core driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ * This driver is based on wm8350 implementation.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/moduleparam.h>
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/mfd/rpisense/core.h>
|
||||
+#include <linux/slab.h>
|
||||
+
|
||||
+static struct rpisense *rpisense;
|
||||
+
|
||||
+static void rpisense_client_dev_register(struct rpisense *rpisense,
|
||||
+ const char *name,
|
||||
+ struct platform_device **pdev)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ *pdev = platform_device_alloc(name, -1);
|
||||
+ if (*pdev == NULL) {
|
||||
+ dev_err(rpisense->dev, "Failed to allocate %s\n", name);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ (*pdev)->dev.parent = rpisense->dev;
|
||||
+ platform_set_drvdata(*pdev, rpisense);
|
||||
+ ret = platform_device_add(*pdev);
|
||||
+ if (ret != 0) {
|
||||
+ dev_err(rpisense->dev, "Failed to register %s: %d\n",
|
||||
+ name, ret);
|
||||
+ platform_device_put(*pdev);
|
||||
+ *pdev = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int rpisense_probe(struct i2c_client *i2c)
|
||||
+{
|
||||
+ int ret;
|
||||
+ struct rpisense_js *rpisense_js;
|
||||
+
|
||||
+ rpisense = devm_kzalloc(&i2c->dev, sizeof(struct rpisense), GFP_KERNEL);
|
||||
+ if (rpisense == NULL)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ i2c_set_clientdata(i2c, rpisense);
|
||||
+ rpisense->dev = &i2c->dev;
|
||||
+ rpisense->i2c_client = i2c;
|
||||
+
|
||||
+ ret = rpisense_reg_read(rpisense, RPISENSE_WAI);
|
||||
+ if (ret > 0) {
|
||||
+ if (ret != 's')
|
||||
+ return -EINVAL;
|
||||
+ } else {
|
||||
+ return ret;
|
||||
+ }
|
||||
+ ret = rpisense_reg_read(rpisense, RPISENSE_VER);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ dev_info(rpisense->dev,
|
||||
+ "Raspberry Pi Sense HAT firmware version %i\n", ret);
|
||||
+
|
||||
+ rpisense_js = &rpisense->joystick;
|
||||
+ rpisense_js->keys_desc = devm_gpiod_get(&i2c->dev,
|
||||
+ "keys-int", GPIOD_IN);
|
||||
+ if (IS_ERR(rpisense_js->keys_desc)) {
|
||||
+ dev_warn(&i2c->dev, "Failed to get keys-int descriptor.\n");
|
||||
+ rpisense_js->keys_desc = gpio_to_desc(23);
|
||||
+ if (rpisense_js->keys_desc == NULL) {
|
||||
+ dev_err(&i2c->dev, "GPIO23 fallback failed.\n");
|
||||
+ return PTR_ERR(rpisense_js->keys_desc);
|
||||
+ }
|
||||
+ }
|
||||
+ rpisense_client_dev_register(rpisense, "rpi-sense-js",
|
||||
+ &(rpisense->joystick.pdev));
|
||||
+ rpisense_client_dev_register(rpisense, "rpi-sense-fb",
|
||||
+ &(rpisense->framebuffer.pdev));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void rpisense_remove(struct i2c_client *i2c)
|
||||
+{
|
||||
+ struct rpisense *rpisense = i2c_get_clientdata(i2c);
|
||||
+
|
||||
+ platform_device_unregister(rpisense->joystick.pdev);
|
||||
+}
|
||||
+
|
||||
+struct rpisense *rpisense_get_dev(void)
|
||||
+{
|
||||
+ return rpisense;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(rpisense_get_dev);
|
||||
+
|
||||
+s32 rpisense_reg_read(struct rpisense *rpisense, int reg)
|
||||
+{
|
||||
+ int ret = i2c_smbus_read_byte_data(rpisense->i2c_client, reg);
|
||||
+
|
||||
+ if (ret < 0)
|
||||
+ dev_err(rpisense->dev, "Read from reg %d failed\n", reg);
|
||||
+ /* Due to the BCM270x I2C clock stretching bug, some values
|
||||
+ * may have MSB set. Clear it to avoid incorrect values.
|
||||
+ * */
|
||||
+ return ret & 0x7F;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(rpisense_reg_read);
|
||||
+
|
||||
+int rpisense_block_write(struct rpisense *rpisense, const char *buf, int count)
|
||||
+{
|
||||
+ int ret = i2c_master_send(rpisense->i2c_client, buf, count);
|
||||
+
|
||||
+ if (ret < 0)
|
||||
+ dev_err(rpisense->dev, "Block write failed\n");
|
||||
+ return ret;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(rpisense_block_write);
|
||||
+
|
||||
+static const struct i2c_device_id rpisense_i2c_id[] = {
|
||||
+ { "rpi-sense", 0 },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(i2c, rpisense_i2c_id);
|
||||
+
|
||||
+#ifdef CONFIG_OF
|
||||
+static const struct of_device_id rpisense_core_id[] = {
|
||||
+ { .compatible = "rpi,rpi-sense" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, rpisense_core_id);
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+static struct i2c_driver rpisense_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "rpi-sense",
|
||||
+ .owner = THIS_MODULE,
|
||||
+ },
|
||||
+ .probe = rpisense_probe,
|
||||
+ .remove = rpisense_remove,
|
||||
+ .id_table = rpisense_i2c_id,
|
||||
+};
|
||||
+
|
||||
+module_i2c_driver(rpisense_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Raspberry Pi Sense HAT core driver");
|
||||
+MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
--- a/drivers/video/fbdev/Kconfig
|
||||
+++ b/drivers/video/fbdev/Kconfig
|
||||
@@ -1964,6 +1964,19 @@ config FB_SM712
|
||||
called sm712fb. If you want to compile it as a module, say M
|
||||
here and read <file:Documentation/kbuild/modules.rst>.
|
||||
|
||||
+config FB_RPISENSE
|
||||
+ tristate "Raspberry Pi Sense HAT framebuffer"
|
||||
+ depends on FB
|
||||
+ select MFD_RPISENSE_CORE
|
||||
+ select FB_SYS_FOPS
|
||||
+ select FB_SYS_FILLRECT
|
||||
+ select FB_SYS_COPYAREA
|
||||
+ select FB_SYS_IMAGEBLIT
|
||||
+ select FB_DEFERRED_IO
|
||||
+
|
||||
+ help
|
||||
+ This is the framebuffer driver for the Raspberry Pi Sense HAT
|
||||
+
|
||||
source "drivers/video/fbdev/omap/Kconfig"
|
||||
source "drivers/video/fbdev/omap2/Kconfig"
|
||||
source "drivers/video/fbdev/mmp/Kconfig"
|
||||
--- a/drivers/video/fbdev/Makefile
|
||||
+++ b/drivers/video/fbdev/Makefile
|
||||
@@ -126,6 +126,7 @@ obj-$(CONFIG_FB_OF) += off
|
||||
obj-$(CONFIG_FB_DA8XX) += da8xx-fb.o
|
||||
obj-$(CONFIG_FB_SSD1307) += ssd1307fb.o
|
||||
obj-$(CONFIG_FB_SIMPLE) += simplefb.o
|
||||
+obj-$(CONFIG_FB_RPISENSE) += rpisense-fb.o
|
||||
|
||||
# the test framebuffer is last
|
||||
obj-$(CONFIG_FB_VIRTUAL) += vfb.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/video/fbdev/rpisense-fb.c
|
||||
@@ -0,0 +1,293 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT framebuffer driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/errno.h>
|
||||
+#include <linux/string.h>
|
||||
+#include <linux/mm.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/uaccess.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/fb.h>
|
||||
+#include <linux/init.h>
|
||||
+
|
||||
+#include <linux/mfd/rpisense/framebuffer.h>
|
||||
+#include <linux/mfd/rpisense/core.h>
|
||||
+
|
||||
+static bool lowlight;
|
||||
+module_param(lowlight, bool, 0);
|
||||
+MODULE_PARM_DESC(lowlight, "Reduce LED matrix brightness to one third");
|
||||
+
|
||||
+static struct rpisense *rpisense;
|
||||
+
|
||||
+struct rpisense_fb_param {
|
||||
+ char __iomem *vmem;
|
||||
+ u8 *vmem_work;
|
||||
+ u32 vmemsize;
|
||||
+ u8 *gamma;
|
||||
+};
|
||||
+
|
||||
+static u8 gamma_default[32] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
+ 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0E, 0x0F, 0x11,
|
||||
+ 0x12, 0x14, 0x15, 0x17, 0x19, 0x1B, 0x1D, 0x1F,};
|
||||
+
|
||||
+static u8 gamma_low[32] = {0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02,
|
||||
+ 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06,
|
||||
+ 0x06, 0x07, 0x07, 0x08, 0x08, 0x09, 0x0A, 0x0A,};
|
||||
+
|
||||
+static u8 gamma_user[32];
|
||||
+
|
||||
+static struct rpisense_fb_param rpisense_fb_param = {
|
||||
+ .vmem = NULL,
|
||||
+ .vmemsize = 128,
|
||||
+ .gamma = gamma_default,
|
||||
+};
|
||||
+
|
||||
+static struct fb_deferred_io rpisense_fb_defio;
|
||||
+
|
||||
+static struct fb_fix_screeninfo rpisense_fb_fix = {
|
||||
+ .id = "RPi-Sense FB",
|
||||
+ .type = FB_TYPE_PACKED_PIXELS,
|
||||
+ .visual = FB_VISUAL_TRUECOLOR,
|
||||
+ .xpanstep = 0,
|
||||
+ .ypanstep = 0,
|
||||
+ .ywrapstep = 0,
|
||||
+ .accel = FB_ACCEL_NONE,
|
||||
+ .line_length = 16,
|
||||
+};
|
||||
+
|
||||
+static struct fb_var_screeninfo rpisense_fb_var = {
|
||||
+ .xres = 8,
|
||||
+ .yres = 8,
|
||||
+ .xres_virtual = 8,
|
||||
+ .yres_virtual = 8,
|
||||
+ .bits_per_pixel = 16,
|
||||
+ .red = {11, 5, 0},
|
||||
+ .green = {5, 6, 0},
|
||||
+ .blue = {0, 5, 0},
|
||||
+};
|
||||
+
|
||||
+static ssize_t rpisense_fb_write(struct fb_info *info,
|
||||
+ const char __user *buf, size_t count,
|
||||
+ loff_t *ppos)
|
||||
+{
|
||||
+ ssize_t res = fb_sys_write(info, buf, count, ppos);
|
||||
+
|
||||
+ schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+static void rpisense_fb_fillrect(struct fb_info *info,
|
||||
+ const struct fb_fillrect *rect)
|
||||
+{
|
||||
+ sys_fillrect(info, rect);
|
||||
+ schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
|
||||
+}
|
||||
+
|
||||
+static void rpisense_fb_copyarea(struct fb_info *info,
|
||||
+ const struct fb_copyarea *area)
|
||||
+{
|
||||
+ sys_copyarea(info, area);
|
||||
+ schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
|
||||
+}
|
||||
+
|
||||
+static void rpisense_fb_imageblit(struct fb_info *info,
|
||||
+ const struct fb_image *image)
|
||||
+{
|
||||
+ sys_imageblit(info, image);
|
||||
+ schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
|
||||
+}
|
||||
+
|
||||
+static void rpisense_fb_deferred_io(struct fb_info *info,
|
||||
+ struct list_head *pagelist)
|
||||
+{
|
||||
+ int i;
|
||||
+ int j;
|
||||
+ u8 *vmem_work = rpisense_fb_param.vmem_work;
|
||||
+ u16 *mem = (u16 *)rpisense_fb_param.vmem;
|
||||
+ u8 *gamma = rpisense_fb_param.gamma;
|
||||
+
|
||||
+ vmem_work[0] = 0;
|
||||
+ for (j = 0; j < 8; j++) {
|
||||
+ for (i = 0; i < 8; i++) {
|
||||
+ vmem_work[(j * 24) + i + 1] =
|
||||
+ gamma[(mem[(j * 8) + i] >> 11) & 0x1F];
|
||||
+ vmem_work[(j * 24) + (i + 8) + 1] =
|
||||
+ gamma[(mem[(j * 8) + i] >> 6) & 0x1F];
|
||||
+ vmem_work[(j * 24) + (i + 16) + 1] =
|
||||
+ gamma[(mem[(j * 8) + i]) & 0x1F];
|
||||
+ }
|
||||
+ }
|
||||
+ rpisense_block_write(rpisense, vmem_work, 193);
|
||||
+}
|
||||
+
|
||||
+static struct fb_deferred_io rpisense_fb_defio = {
|
||||
+ .delay = HZ/100,
|
||||
+ .deferred_io = rpisense_fb_deferred_io,
|
||||
+};
|
||||
+
|
||||
+static int rpisense_fb_ioctl(struct fb_info *info, unsigned int cmd,
|
||||
+ unsigned long arg)
|
||||
+{
|
||||
+ switch (cmd) {
|
||||
+ case SENSEFB_FBIOGET_GAMMA:
|
||||
+ if (copy_to_user((void __user *) arg, rpisense_fb_param.gamma,
|
||||
+ sizeof(u8[32])))
|
||||
+ return -EFAULT;
|
||||
+ return 0;
|
||||
+ case SENSEFB_FBIOSET_GAMMA:
|
||||
+ if (copy_from_user(gamma_user, (void __user *)arg,
|
||||
+ sizeof(u8[32])))
|
||||
+ return -EFAULT;
|
||||
+ rpisense_fb_param.gamma = gamma_user;
|
||||
+ schedule_delayed_work(&info->deferred_work,
|
||||
+ rpisense_fb_defio.delay);
|
||||
+ return 0;
|
||||
+ case SENSEFB_FBIORESET_GAMMA:
|
||||
+ switch (arg) {
|
||||
+ case 0:
|
||||
+ rpisense_fb_param.gamma = gamma_default;
|
||||
+ break;
|
||||
+ case 1:
|
||||
+ rpisense_fb_param.gamma = gamma_low;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ rpisense_fb_param.gamma = gamma_user;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ schedule_delayed_work(&info->deferred_work,
|
||||
+ rpisense_fb_defio.delay);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct fb_ops rpisense_fb_ops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .fb_read = fb_sys_read,
|
||||
+ .fb_write = rpisense_fb_write,
|
||||
+ .fb_fillrect = rpisense_fb_fillrect,
|
||||
+ .fb_copyarea = rpisense_fb_copyarea,
|
||||
+ .fb_imageblit = rpisense_fb_imageblit,
|
||||
+ .fb_ioctl = rpisense_fb_ioctl,
|
||||
+};
|
||||
+
|
||||
+static int rpisense_fb_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct fb_info *info;
|
||||
+ int ret = -ENOMEM;
|
||||
+ struct rpisense_fb *rpisense_fb;
|
||||
+
|
||||
+ rpisense = rpisense_get_dev();
|
||||
+ rpisense_fb = &rpisense->framebuffer;
|
||||
+
|
||||
+ rpisense_fb_param.vmem = vzalloc(rpisense_fb_param.vmemsize);
|
||||
+ if (!rpisense_fb_param.vmem)
|
||||
+ return ret;
|
||||
+
|
||||
+ rpisense_fb_param.vmem_work = devm_kmalloc(&pdev->dev, 193, GFP_KERNEL);
|
||||
+ if (!rpisense_fb_param.vmem_work)
|
||||
+ goto err_malloc;
|
||||
+
|
||||
+ info = framebuffer_alloc(0, &pdev->dev);
|
||||
+ if (!info) {
|
||||
+ dev_err(&pdev->dev, "Could not allocate framebuffer.\n");
|
||||
+ goto err_malloc;
|
||||
+ }
|
||||
+ rpisense_fb->info = info;
|
||||
+
|
||||
+ rpisense_fb_fix.smem_start = (unsigned long)rpisense_fb_param.vmem;
|
||||
+ rpisense_fb_fix.smem_len = rpisense_fb_param.vmemsize;
|
||||
+
|
||||
+ info->fbops = &rpisense_fb_ops;
|
||||
+ info->fix = rpisense_fb_fix;
|
||||
+ info->var = rpisense_fb_var;
|
||||
+ info->fbdefio = &rpisense_fb_defio;
|
||||
+ info->flags = FBINFO_VIRTFB;
|
||||
+ info->screen_base = rpisense_fb_param.vmem;
|
||||
+ info->screen_size = rpisense_fb_param.vmemsize;
|
||||
+
|
||||
+ if (lowlight)
|
||||
+ rpisense_fb_param.gamma = gamma_low;
|
||||
+
|
||||
+ fb_deferred_io_init(info);
|
||||
+
|
||||
+ ret = register_framebuffer(info);
|
||||
+ if (ret < 0) {
|
||||
+ dev_err(&pdev->dev, "Could not register framebuffer.\n");
|
||||
+ goto err_fballoc;
|
||||
+ }
|
||||
+
|
||||
+ fb_info(info, "%s frame buffer device\n", info->fix.id);
|
||||
+ schedule_delayed_work(&info->deferred_work, rpisense_fb_defio.delay);
|
||||
+ return 0;
|
||||
+err_fballoc:
|
||||
+ framebuffer_release(info);
|
||||
+err_malloc:
|
||||
+ vfree(rpisense_fb_param.vmem);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int rpisense_fb_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct rpisense_fb *rpisense_fb = &rpisense->framebuffer;
|
||||
+ struct fb_info *info = rpisense_fb->info;
|
||||
+
|
||||
+ if (info) {
|
||||
+ unregister_framebuffer(info);
|
||||
+ fb_deferred_io_cleanup(info);
|
||||
+ framebuffer_release(info);
|
||||
+ vfree(rpisense_fb_param.vmem);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+#ifdef CONFIG_OF
|
||||
+static const struct of_device_id rpisense_fb_id[] = {
|
||||
+ { .compatible = "rpi,rpi-sense-fb" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, rpisense_fb_id);
|
||||
+#endif
|
||||
+
|
||||
+static struct platform_device_id rpisense_fb_device_id[] = {
|
||||
+ { .name = "rpi-sense-fb" },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(platform, rpisense_fb_device_id);
|
||||
+
|
||||
+static struct platform_driver rpisense_fb_driver = {
|
||||
+ .probe = rpisense_fb_probe,
|
||||
+ .remove = rpisense_fb_remove,
|
||||
+ .driver = {
|
||||
+ .name = "rpi-sense-fb",
|
||||
+ .owner = THIS_MODULE,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(rpisense_fb_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Raspberry Pi Sense HAT framebuffer driver");
|
||||
+MODULE_AUTHOR("Serge Schneider <serge@raspberrypi.org>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/include/linux/mfd/rpisense/core.h
|
||||
@@ -0,0 +1,47 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT core driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef __LINUX_MFD_RPISENSE_CORE_H_
|
||||
+#define __LINUX_MFD_RPISENSE_CORE_H_
|
||||
+
|
||||
+#include <linux/mfd/rpisense/joystick.h>
|
||||
+#include <linux/mfd/rpisense/framebuffer.h>
|
||||
+
|
||||
+/*
|
||||
+ * Register values.
|
||||
+ */
|
||||
+#define RPISENSE_FB 0x00
|
||||
+#define RPISENSE_WAI 0xF0
|
||||
+#define RPISENSE_VER 0xF1
|
||||
+#define RPISENSE_KEYS 0xF2
|
||||
+#define RPISENSE_EE_WP 0xF3
|
||||
+
|
||||
+#define RPISENSE_ID 's'
|
||||
+
|
||||
+struct rpisense {
|
||||
+ struct device *dev;
|
||||
+ struct i2c_client *i2c_client;
|
||||
+
|
||||
+ /* Client devices */
|
||||
+ struct rpisense_js joystick;
|
||||
+ struct rpisense_fb framebuffer;
|
||||
+};
|
||||
+
|
||||
+struct rpisense *rpisense_get_dev(void);
|
||||
+s32 rpisense_reg_read(struct rpisense *rpisense, int reg);
|
||||
+int rpisense_reg_write(struct rpisense *rpisense, int reg, u16 val);
|
||||
+int rpisense_block_write(struct rpisense *rpisense, const char *buf, int count);
|
||||
+
|
||||
+#endif
|
||||
--- /dev/null
|
||||
+++ b/include/linux/mfd/rpisense/framebuffer.h
|
||||
@@ -0,0 +1,32 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT framebuffer driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef __LINUX_RPISENSE_FB_H_
|
||||
+#define __LINUX_RPISENSE_FB_H_
|
||||
+
|
||||
+#define SENSEFB_FBIO_IOC_MAGIC 0xF1
|
||||
+
|
||||
+#define SENSEFB_FBIOGET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 0)
|
||||
+#define SENSEFB_FBIOSET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 1)
|
||||
+#define SENSEFB_FBIORESET_GAMMA _IO(SENSEFB_FBIO_IOC_MAGIC, 2)
|
||||
+
|
||||
+struct rpisense;
|
||||
+
|
||||
+struct rpisense_fb {
|
||||
+ struct platform_device *pdev;
|
||||
+ struct fb_info *info;
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
--- /dev/null
|
||||
+++ b/include/linux/mfd/rpisense/joystick.h
|
||||
@@ -0,0 +1,35 @@
|
||||
+/*
|
||||
+ * Raspberry Pi Sense HAT joystick driver
|
||||
+ * http://raspberrypi.org
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Raspberry Pi
|
||||
+ *
|
||||
+ * Author: Serge Schneider
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License as published by the
|
||||
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||
+ * option) any later version.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#ifndef __LINUX_RPISENSE_JOYSTICK_H_
|
||||
+#define __LINUX_RPISENSE_JOYSTICK_H_
|
||||
+
|
||||
+#include <linux/input.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/gpio/consumer.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+struct rpisense;
|
||||
+
|
||||
+struct rpisense_js {
|
||||
+ struct platform_device *pdev;
|
||||
+ struct input_dev *keys_dev;
|
||||
+ struct gpio_desc *keys_desc;
|
||||
+ struct work_struct keys_work_s;
|
||||
+ int keys_irq;
|
||||
+};
|
||||
+
|
||||
+
|
||||
+#endif
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,172 @@
|
||||
From e5d030bb8bd115eec0d7bac3753096658b908d8f Mon Sep 17 00:00:00 2001
|
||||
From: P33M <P33M@github.com>
|
||||
Date: Wed, 21 Oct 2015 14:55:21 +0100
|
||||
Subject: [PATCH 0107/1085] rpi_display: add backlight driver and overlay
|
||||
|
||||
Add a mailbox-driven backlight controller for the Raspberry Pi DSI
|
||||
touchscreen display. Requires updated GPU firmware to recognise the
|
||||
mailbox request.
|
||||
|
||||
Signed-off-by: Gordon Hollingworth <gordon@raspberrypi.org>
|
||||
|
||||
Add Raspberry Pi firmware driver to the dependencies of backlight driver
|
||||
|
||||
Otherwise the backlight driver fails to build if the firmware
|
||||
loading driver is not in the kernel
|
||||
|
||||
Signed-off-by: Alex Riesen <alexander.riesen@cetitec.com>
|
||||
---
|
||||
drivers/video/backlight/Kconfig | 7 ++
|
||||
drivers/video/backlight/Makefile | 1 +
|
||||
drivers/video/backlight/rpi_backlight.c | 119 ++++++++++++++++++++++++
|
||||
3 files changed, 127 insertions(+)
|
||||
create mode 100644 drivers/video/backlight/rpi_backlight.c
|
||||
|
||||
--- a/drivers/video/backlight/Kconfig
|
||||
+++ b/drivers/video/backlight/Kconfig
|
||||
@@ -249,6 +249,13 @@ config BACKLIGHT_PWM
|
||||
If you have a LCD backlight adjustable by PWM, say Y to enable
|
||||
this driver.
|
||||
|
||||
+config BACKLIGHT_RPI
|
||||
+ tristate "Raspberry Pi display firmware driven backlight"
|
||||
+ depends on RASPBERRYPI_FIRMWARE
|
||||
+ help
|
||||
+ If you have the Raspberry Pi DSI touchscreen display, say Y to
|
||||
+ enable the mailbox-controlled backlight driver.
|
||||
+
|
||||
config BACKLIGHT_DA903X
|
||||
tristate "Backlight Driver for DA9030/DA9034 using WLED"
|
||||
depends on PMIC_DA903X
|
||||
--- a/drivers/video/backlight/Makefile
|
||||
+++ b/drivers/video/backlight/Makefile
|
||||
@@ -50,6 +50,7 @@ obj-$(CONFIG_BACKLIGHT_PANDORA) += pand
|
||||
obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_QCOM_WLED) += qcom-wled.o
|
||||
+obj-$(CONFIG_BACKLIGHT_RPI) += rpi_backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_RT4831) += rt4831-backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_SKY81452) += sky81452-backlight.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/video/backlight/rpi_backlight.c
|
||||
@@ -0,0 +1,119 @@
|
||||
+/*
|
||||
+ * rpi_bl.c - Backlight controller through VPU
|
||||
+ *
|
||||
+ * 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>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_gpio.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
+
|
||||
+struct rpi_backlight {
|
||||
+ struct device *dev;
|
||||
+ struct device *fbdev;
|
||||
+ struct rpi_firmware *fw;
|
||||
+};
|
||||
+
|
||||
+static int rpi_backlight_update_status(struct backlight_device *bl)
|
||||
+{
|
||||
+ struct rpi_backlight *gbl = bl_get_data(bl);
|
||||
+ int brightness = bl->props.brightness;
|
||||
+ int ret;
|
||||
+
|
||||
+ 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;
|
||||
+
|
||||
+ ret = rpi_firmware_property(gbl->fw,
|
||||
+ RPI_FIRMWARE_FRAMEBUFFER_SET_BACKLIGHT,
|
||||
+ &brightness, sizeof(brightness));
|
||||
+ if (ret) {
|
||||
+ dev_err(gbl->dev, "Failed to set brightness\n");
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (brightness < 0) {
|
||||
+ dev_err(gbl->dev, "Backlight change failed\n");
|
||||
+ return -EAGAIN;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct backlight_ops rpi_backlight_ops = {
|
||||
+ .options = BL_CORE_SUSPENDRESUME,
|
||||
+ .update_status = rpi_backlight_update_status,
|
||||
+};
|
||||
+
|
||||
+static int rpi_backlight_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct backlight_properties props;
|
||||
+ struct backlight_device *bl;
|
||||
+ struct rpi_backlight *gbl;
|
||||
+ struct device_node *fw_node;
|
||||
+
|
||||
+ gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
|
||||
+ if (gbl == NULL)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ gbl->dev = &pdev->dev;
|
||||
+
|
||||
+ fw_node = of_parse_phandle(pdev->dev.of_node, "firmware", 0);
|
||||
+ if (!fw_node) {
|
||||
+ dev_err(&pdev->dev, "Missing firmware node\n");
|
||||
+ return -ENOENT;
|
||||
+ }
|
||||
+
|
||||
+ gbl->fw = rpi_firmware_get(fw_node);
|
||||
+ if (!gbl->fw)
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ memset(&props, 0, sizeof(props));
|
||||
+ props.type = BACKLIGHT_RAW;
|
||||
+ props.max_brightness = 255;
|
||||
+ bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
|
||||
+ &pdev->dev, gbl, &rpi_backlight_ops,
|
||||
+ &props);
|
||||
+ if (IS_ERR(bl)) {
|
||||
+ dev_err(&pdev->dev, "failed to register backlight\n");
|
||||
+ return PTR_ERR(bl);
|
||||
+ }
|
||||
+
|
||||
+ bl->props.brightness = 255;
|
||||
+ backlight_update_status(bl);
|
||||
+
|
||||
+ platform_set_drvdata(pdev, bl);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id rpi_backlight_of_match[] = {
|
||||
+ { .compatible = "raspberrypi,rpi-backlight" },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, rpi_backlight_of_match);
|
||||
+
|
||||
+static struct platform_driver rpi_backlight_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "rpi-backlight",
|
||||
+ .of_match_table = of_match_ptr(rpi_backlight_of_match),
|
||||
+ },
|
||||
+ .probe = rpi_backlight_probe,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(rpi_backlight_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Gordon Hollingworth <gordon@raspberrypi.org>");
|
||||
+MODULE_DESCRIPTION("Raspberry Pi mailbox based Backlight Driver");
|
||||
+MODULE_LICENSE("GPL");
|
@ -0,0 +1,267 @@
|
||||
From fc4ca18200d0a884f75c132c9cd3bf9ab9db781e Mon Sep 17 00:00:00 2001
|
||||
From: popcornmix <popcornmix@gmail.com>
|
||||
Date: Tue, 23 Feb 2016 19:56:04 +0000
|
||||
Subject: [PATCH 0108/1085] bcm2835-virtgpio: Virtual GPIO driver
|
||||
|
||||
Add a virtual GPIO driver that uses the firmware mailbox interface to
|
||||
request that the VPU toggles LEDs.
|
||||
|
||||
gpio: bcm-virt: Fix the get() method
|
||||
|
||||
The get() method does not understand the on-the-wire encoding of the
|
||||
remote GPIO states, thinking they are simple on/off bits when they are
|
||||
really pairs of 16-bit counts. Rewrite the get() handler to return the
|
||||
value last written, which will eventually match the actual GPIO state
|
||||
if there are no other changes.
|
||||
|
||||
See: https://github.com/raspberrypi/linux/issues/4638
|
||||
|
||||
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
|
||||
---
|
||||
drivers/gpio/Kconfig | 6 +
|
||||
drivers/gpio/Makefile | 1 +
|
||||
drivers/gpio/gpio-bcm-virt.c | 213 +++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 220 insertions(+)
|
||||
create mode 100644 drivers/gpio/gpio-bcm-virt.c
|
||||
|
||||
--- a/drivers/gpio/Kconfig
|
||||
+++ b/drivers/gpio/Kconfig
|
||||
@@ -207,6 +207,12 @@ config GPIO_BCM_XGS_IPROC
|
||||
help
|
||||
Say yes here to enable GPIO support for Broadcom XGS iProc SoCs.
|
||||
|
||||
+config GPIO_BCM_VIRT
|
||||
+ bool "Broadcom Virt GPIO"
|
||||
+ depends on OF_GPIO && RASPBERRYPI_FIRMWARE && (ARCH_BCM2835 || COMPILE_TEST)
|
||||
+ help
|
||||
+ Turn on virtual GPIO support for Broadcom BCM283X chips.
|
||||
+
|
||||
config GPIO_BRCMSTB
|
||||
tristate "BRCMSTB GPIO support"
|
||||
default y if (ARCH_BRCMSTB || BMIPS_GENERIC)
|
||||
--- a/drivers/gpio/Makefile
|
||||
+++ b/drivers/gpio/Makefile
|
||||
@@ -38,6 +38,7 @@ obj-$(CONFIG_GPIO_ASPEED_SGPIO) += gpio
|
||||
obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o
|
||||
obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o
|
||||
obj-$(CONFIG_GPIO_BCM_XGS_IPROC) += gpio-xgs-iproc.o
|
||||
+obj-$(CONFIG_GPIO_BCM_VIRT) += gpio-bcm-virt.o
|
||||
obj-$(CONFIG_GPIO_BD71815) += gpio-bd71815.o
|
||||
obj-$(CONFIG_GPIO_BD71828) += gpio-bd71828.o
|
||||
obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/gpio/gpio-bcm-virt.c
|
||||
@@ -0,0 +1,213 @@
|
||||
+/*
|
||||
+ * brcmvirt GPIO driver
|
||||
+ *
|
||||
+ * Copyright (C) 2012,2013 Dom Cobley <popcornmix@gmail.com>
|
||||
+ * Based on gpio-clps711x.c by Alexander Shiyan <shc_work@mail.ru>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/gpio/driver.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/dma-mapping.h>
|
||||
+#include <soc/bcm2835/raspberrypi-firmware.h>
|
||||
+
|
||||
+#define MODULE_NAME "brcmvirt-gpio"
|
||||
+#define NUM_GPIO 2
|
||||
+
|
||||
+struct brcmvirt_gpio {
|
||||
+ struct gpio_chip gc;
|
||||
+ u32 __iomem *ts_base;
|
||||
+ /* two packed 16-bit counts of enabled and disables
|
||||
+ Allows host to detect a brief enable that was missed */
|
||||
+ u32 enables_disables[NUM_GPIO];
|
||||
+ dma_addr_t bus_addr;
|
||||
+};
|
||||
+
|
||||
+static int brcmvirt_gpio_dir_in(struct gpio_chip *gc, unsigned off)
|
||||
+{
|
||||
+ struct brcmvirt_gpio *gpio;
|
||||
+ gpio = container_of(gc, struct brcmvirt_gpio, gc);
|
||||
+ return -EINVAL;
|
||||
+}
|
||||
+
|
||||
+static int brcmvirt_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val)
|
||||
+{
|
||||
+ struct brcmvirt_gpio *gpio;
|
||||
+ gpio = container_of(gc, struct brcmvirt_gpio, gc);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int brcmvirt_gpio_get(struct gpio_chip *gc, unsigned off)
|
||||
+{
|
||||
+ struct brcmvirt_gpio *gpio;
|
||||
+ unsigned v;
|
||||
+ gpio = container_of(gc, struct brcmvirt_gpio, gc);
|
||||
+ v = readl(gpio->ts_base + off);
|
||||
+ return (s16)((v >> 16) - v) > 0;
|
||||
+}
|
||||
+
|
||||
+static void brcmvirt_gpio_set(struct gpio_chip *gc, unsigned off, int val)
|
||||
+{
|
||||
+ struct brcmvirt_gpio *gpio;
|
||||
+ u16 enables, disables;
|
||||
+ s16 diff;
|
||||
+ bool lit;
|
||||
+ gpio = container_of(gc, struct brcmvirt_gpio, gc);
|
||||
+ enables = gpio->enables_disables[off] >> 16;
|
||||
+ disables = gpio->enables_disables[off] >> 0;
|
||||
+ diff = (s16)(enables - disables);
|
||||
+ lit = diff > 0;
|
||||
+ if ((val && lit) || (!val && !lit))
|
||||
+ return;
|
||||
+ if (val)
|
||||
+ enables++;
|
||||
+ else
|
||||
+ disables++;
|
||||
+ diff = (s16)(enables - disables);
|
||||
+ BUG_ON(diff != 0 && diff != 1);
|
||||
+ gpio->enables_disables[off] = (enables << 16) | (disables << 0);
|
||||
+ writel(gpio->enables_disables[off], gpio->ts_base + off);
|
||||
+}
|
||||
+
|
||||
+static int brcmvirt_gpio_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ int err = 0;
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct device_node *np = dev_of_node(dev);
|
||||
+ struct device_node *fw_node;
|
||||
+ struct rpi_firmware *fw;
|
||||
+ struct brcmvirt_gpio *ucb;
|
||||
+ u32 gpiovirtbuf;
|
||||
+
|
||||
+ fw_node = of_parse_phandle(np, "firmware", 0);
|
||||
+ if (!fw_node) {
|
||||
+ dev_err(dev, "Missing firmware node\n");
|
||||
+ return -ENOENT;
|
||||
+ }
|
||||
+
|
||||
+ fw = rpi_firmware_get(fw_node);
|
||||
+ if (!fw)
|
||||
+ return -EPROBE_DEFER;
|
||||
+
|
||||
+ ucb = devm_kzalloc(dev, sizeof *ucb, GFP_KERNEL);
|
||||
+ if (!ucb) {
|
||||
+ err = -EINVAL;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ ucb->ts_base = dma_alloc_coherent(dev, PAGE_SIZE, &ucb->bus_addr, GFP_KERNEL);
|
||||
+ if (!ucb->ts_base) {
|
||||
+ pr_err("[%s]: failed to dma_alloc_coherent(%ld)\n",
|
||||
+ __func__, PAGE_SIZE);
|
||||
+ err = -ENOMEM;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ gpiovirtbuf = (u32)ucb->bus_addr;
|
||||
+ err = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_SET_GPIOVIRTBUF,
|
||||
+ &gpiovirtbuf, sizeof(gpiovirtbuf));
|
||||
+
|
||||
+ if (err || gpiovirtbuf != 0) {
|
||||
+ dev_warn(dev, "Failed to set gpiovirtbuf, trying to get err:%x\n", err);
|
||||
+ dma_free_coherent(dev, PAGE_SIZE, ucb->ts_base, ucb->bus_addr);
|
||||
+ ucb->ts_base = 0;
|
||||
+ ucb->bus_addr = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (!ucb->ts_base) {
|
||||
+ err = rpi_firmware_property(fw, RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF,
|
||||
+ &gpiovirtbuf, sizeof(gpiovirtbuf));
|
||||
+
|
||||
+ if (err) {
|
||||
+ dev_err(dev, "Failed to get gpiovirtbuf\n");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (!gpiovirtbuf) {
|
||||
+ dev_err(dev, "No virtgpio buffer\n");
|
||||
+ err = -ENOENT;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ // mmap the physical memory
|
||||
+ gpiovirtbuf &= ~0xc0000000;
|
||||
+ ucb->ts_base = ioremap(gpiovirtbuf, 4096);
|
||||
+ if (ucb->ts_base == NULL) {
|
||||
+ dev_err(dev, "Failed to map physical address\n");
|
||||
+ err = -ENOENT;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ ucb->bus_addr = 0;
|
||||
+ }
|
||||
+ ucb->gc.label = MODULE_NAME;
|
||||
+ ucb->gc.owner = THIS_MODULE;
|
||||
+ //ucb->gc.dev = dev;
|
||||
+ ucb->gc.base = 100;
|
||||
+ ucb->gc.ngpio = NUM_GPIO;
|
||||
+
|
||||
+ ucb->gc.direction_input = brcmvirt_gpio_dir_in;
|
||||
+ ucb->gc.direction_output = brcmvirt_gpio_dir_out;
|
||||
+ ucb->gc.get = brcmvirt_gpio_get;
|
||||
+ ucb->gc.set = brcmvirt_gpio_set;
|
||||
+ ucb->gc.can_sleep = true;
|
||||
+
|
||||
+ err = gpiochip_add(&ucb->gc);
|
||||
+ if (err)
|
||||
+ goto out;
|
||||
+
|
||||
+ platform_set_drvdata(pdev, ucb);
|
||||
+
|
||||
+ return 0;
|
||||
+out:
|
||||
+ if (ucb->bus_addr) {
|
||||
+ dma_free_coherent(dev, PAGE_SIZE, ucb->ts_base, ucb->bus_addr);
|
||||
+ ucb->bus_addr = 0;
|
||||
+ ucb->ts_base = NULL;
|
||||
+ } else if (ucb->ts_base) {
|
||||
+ iounmap(ucb->ts_base);
|
||||
+ ucb->ts_base = NULL;
|
||||
+ }
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int brcmvirt_gpio_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ int err = 0;
|
||||
+ struct brcmvirt_gpio *ucb = platform_get_drvdata(pdev);
|
||||
+
|
||||
+ gpiochip_remove(&ucb->gc);
|
||||
+ if (ucb->bus_addr)
|
||||
+ dma_free_coherent(dev, PAGE_SIZE, ucb->ts_base, ucb->bus_addr);
|
||||
+ else if (ucb->ts_base)
|
||||
+ iounmap(ucb->ts_base);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id __maybe_unused brcmvirt_gpio_ids[] = {
|
||||
+ { .compatible = "brcm,bcm2835-virtgpio" },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, brcmvirt_gpio_ids);
|
||||
+
|
||||
+static struct platform_driver brcmvirt_gpio_driver = {
|
||||
+ .driver = {
|
||||
+ .name = MODULE_NAME,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .of_match_table = of_match_ptr(brcmvirt_gpio_ids),
|
||||
+ },
|
||||
+ .probe = brcmvirt_gpio_probe,
|
||||
+ .remove = brcmvirt_gpio_remove,
|
||||
+};
|
||||
+module_platform_driver(brcmvirt_gpio_driver);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Dom Cobley <popcornmix@gmail.com>");
|
||||
+MODULE_DESCRIPTION("brcmvirt GPIO driver");
|
||||
+MODULE_ALIAS("platform:brcmvirt-gpio");
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user