Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

display_mcu: display_mcu@45
{
compatible = "raspberrypi,v2-touchscreen-panel-regulator";
compatible = "raspberrypi,touchscreen-panel-regulator-v2";
reg = <0x45>;
gpio-controller;
#gpio-cells = <2>;
#pwm-cells = <3>;
};

touch: ts@41 {
Expand Down Expand Up @@ -57,7 +58,7 @@
reg = <0>;
compatible = "raspberrypi,dsi-10-1inch";
power-supply = <&display_reg>;
backlight = <&display_mcu>;
backlight = <&backlight>;

port {
panel_in: endpoint {
Expand Down Expand Up @@ -93,6 +94,14 @@
startup-delay-us = <50000>;
enable-active-high;
};

backlight: panel_backlight@1 {
compatible = "pwm-backlight";
brightness-levels = <0 31>;
num-interpolated-steps = <31>;
default-brightness-level = <15>;
pwms = <&display_mcu 0 200000 0>;
};
};
};

Expand Down Expand Up @@ -121,6 +130,7 @@
dsi0 = <&dsi_frag>, "target:0=",<&dsi0>,
<&i2c_frag>, "target:0=",<&i2c_csi_dsi0>,
<&display_reg>, "reg:0=0",
<&display_reg>, "regulator-name=display_reg_0";
<&display_reg>, "regulator-name=display_reg_0",
<&backlight>, "reg:0=0";
};
};
61 changes: 57 additions & 4 deletions drivers/gpu/drm/drm_connector.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <drm/drm_utils.h>

#include <linux/export.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/uaccess.h>
Expand Down Expand Up @@ -85,6 +86,7 @@ struct drm_conn_prop_enum_list {
int type;
const char *name;
struct ida ida;
int first_dyn_num;
};

/*
Expand Down Expand Up @@ -114,12 +116,41 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] = {
{ DRM_MODE_CONNECTOR_USB, "USB" },
};

#define MAX_DT_NODE_NAME_LEN 20
#define DT_DRM_NODE_PREFIX "drm-"

static void drm_connector_get_of_name(int type, char *node_name, int length)
{
int i = 0;

strscpy(node_name, DT_DRM_NODE_PREFIX, length);

do {
node_name[i + strlen(DT_DRM_NODE_PREFIX)] =
tolower(drm_connector_enum_list[type].name[i]);

} while (drm_connector_enum_list[type].name[i++] &&
i < length);

node_name[length - 1] = '\0';
}

void drm_connector_ida_init(void)
{
int i;
int i, id;
char node_name[MAX_DT_NODE_NAME_LEN];

for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++)
for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++) {
ida_init(&drm_connector_enum_list[i].ida);

drm_connector_get_of_name(i, node_name, MAX_DT_NODE_NAME_LEN);

id = of_alias_get_highest_id(node_name);
if (id > 0)
drm_connector_enum_list[i].first_dyn_num = id + 1;
else
drm_connector_enum_list[i].first_dyn_num = 1;
}
}

void drm_connector_ida_destroy(void)
Expand Down Expand Up @@ -227,7 +258,9 @@ static int drm_connector_init_only(struct drm_device *dev,
struct i2c_adapter *ddc)
{
struct drm_mode_config *config = &dev->mode_config;
char node_name[MAX_DT_NODE_NAME_LEN];
int ret;
int id;
struct ida *connector_ida =
&drm_connector_enum_list[connector_type].ida;

Expand Down Expand Up @@ -257,8 +290,28 @@ static int drm_connector_init_only(struct drm_device *dev,
ret = 0;

connector->connector_type = connector_type;
connector->connector_type_id =
ida_alloc_min(connector_ida, 1, GFP_KERNEL);
connector->connector_type_id = 0;

drm_connector_get_of_name(connector_type, node_name, MAX_DT_NODE_NAME_LEN);
id = of_alias_get_id(dev->dev->of_node, node_name);
if (id > 0) {
/* Try and allocate the requested ID
* Valid range is 1 to 31, hence ignoring 0 as an error
*/
int type_id = ida_alloc_range(connector_ida, id, id, GFP_KERNEL);

if (type_id > 0)
connector->connector_type_id = type_id;
else
drm_err(dev, "Failed to acquire type ID %d for interface type %s, ret %d\n",
id, drm_connector_enum_list[connector_type].name,
type_id);
}
if (!connector->connector_type_id)
connector->connector_type_id =
ida_alloc_min(connector_ida,
drm_connector_enum_list[connector_type].first_dyn_num,
GFP_KERNEL);
if (connector->connector_type_id < 0) {
ret = connector->connector_type_id;
goto out_put_id;
Expand Down
3 changes: 3 additions & 0 deletions drivers/regulator/rpi-panel-v2-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static const struct regmap_config rpi_panel_regmap_config = {
.val_bits = 8,
.max_register = REG_PWM,
.can_sleep = true,
.cache_type = REGCACHE_MAPLE,
};

static int rpi_panel_v2_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
Expand Down Expand Up @@ -63,11 +64,13 @@ static const struct pwm_ops rpi_panel_v2_pwm_ops = {
*/
static int rpi_panel_v2_i2c_probe(struct i2c_client *i2c)
{
//unsigned long direction_bitmap = (1 << NUM_GPIO) - 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

struct gpio_regmap_config gconfig = {
.ngpio = NUM_GPIO,
.ngpio_per_reg = NUM_GPIO,
.parent = &i2c->dev,
.reg_set_base = REG_POWERON,
//.fixed_direction_output = &direction_bitmap,
};
struct regmap *regmap;
struct pwm_chip *pc;
Expand Down
Loading