Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SoundWire: mipi-disco: add partial 2.1 support #4857

Merged
merged 17 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
101 changes: 87 additions & 14 deletions drivers/soundwire/mipi_disco.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ int sdw_master_read_prop(struct sdw_bus *bus)
{
struct sdw_master_prop *prop = &bus->prop;
struct fwnode_handle *link;
const char *scales_prop;
char name[32];
int nval, i;
int nval;
int ret;
int i;

device_property_read_u32(bus->dev,
"mipi-sdw-sw-interface-revision",
Expand Down Expand Up @@ -71,9 +74,11 @@ int sdw_master_read_prop(struct sdw_bus *bus)
return -ENOMEM;
}

fwnode_property_read_u32_array(link,
ret = fwnode_property_read_u32_array(link,
"mipi-sdw-clock-frequencies-supported",
prop->clk_freq, prop->num_clk_freq);
if (ret < 0)
return ret;
}

/*
Expand All @@ -88,7 +93,12 @@ int sdw_master_read_prop(struct sdw_bus *bus)
}
}

nval = fwnode_property_count_u32(link, "mipi-sdw-supported-clock-gears");
scales_prop = "mipi-sdw-supported-clock-scales";
plbossart marked this conversation as resolved.
Show resolved Hide resolved
nval = fwnode_property_count_u32(link, scales_prop);
if (nval == 0) {
scales_prop = "mipi-sdw-supported-clock-gears";
nval = fwnode_property_count_u32(link, scales_prop);
}
if (nval > 0) {
prop->num_clk_gears = nval;
prop->clk_gears = devm_kcalloc(bus->dev, prop->num_clk_gears,
Expand All @@ -99,10 +109,12 @@ int sdw_master_read_prop(struct sdw_bus *bus)
return -ENOMEM;
}

fwnode_property_read_u32_array(link,
"mipi-sdw-supported-clock-gears",
ret = fwnode_property_read_u32_array(link,
scales_prop,
plbossart marked this conversation as resolved.
Show resolved Hide resolved
prop->clk_gears,
prop->num_clk_gears);
if (ret < 0)
return ret;
}

fwnode_property_read_u32(link, "mipi-sdw-default-frame-rate",
Expand Down Expand Up @@ -131,6 +143,7 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
struct sdw_dp0_prop *dp0)
{
int nval;
int ret;

fwnode_property_read_u32(port, "mipi-sdw-port-max-wordlength",
&dp0->max_word);
Expand All @@ -148,9 +161,11 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
if (!dp0->words)
return -ENOMEM;

fwnode_property_read_u32_array(port,
ret = fwnode_property_read_u32_array(port,
"mipi-sdw-port-wordlength-configs",
dp0->words, dp0->num_words);
if (ret < 0)
return ret;
}

dp0->BRA_flow_controlled = fwnode_property_read_bool(port,
Expand All @@ -162,6 +177,22 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
dp0->imp_def_interrupts = fwnode_property_read_bool(port,
"mipi-sdw-imp-def-dp0-interrupts-supported");

nval = fwnode_property_count_u32(port, "mipi-sdw-lane-list");
if (nval > 0) {
dp0->num_lanes = nval;
dp0->lane_list = devm_kcalloc(&slave->dev,
dp0->num_lanes, sizeof(*dp0->lane_list),
GFP_KERNEL);
if (!dp0->lane_list)
return -ENOMEM;

ret = fwnode_property_read_u32_array(port,
"mipi-sdw-lane-list",
dp0->lane_list, dp0->num_lanes);
if (ret < 0)
return ret;
}

return 0;
}

Expand All @@ -171,9 +202,10 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
{
struct fwnode_handle *node;
u32 bit, i = 0;
int nval;
unsigned long addr;
char name[40];
int nval;
int ret;

addr = ports;
/* valid ports are 1 to 14 so apply mask */
Expand Down Expand Up @@ -208,9 +240,11 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
return -ENOMEM;
}

fwnode_property_read_u32_array(node,
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-port-wordlength-configs",
dpn[i].words, dpn[i].num_words);
if (ret < 0)
return ret;
}

fwnode_property_read_u32(node, "mipi-sdw-data-port-type",
Expand Down Expand Up @@ -249,9 +283,11 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
return -ENOMEM;
}

fwnode_property_read_u32_array(node,
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-channel-number-list",
dpn[i].channels, dpn[i].num_channels);
if (ret < 0)
return ret;
}

nval = fwnode_property_count_u32(node, "mipi-sdw-channel-combination-list");
Expand All @@ -266,10 +302,12 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
return -ENOMEM;
}

fwnode_property_read_u32_array(node,
ret = fwnode_property_read_u32_array(node,
"mipi-sdw-channel-combination-list",
dpn[i].ch_combinations,
dpn[i].num_ch_combinations);
if (ret < 0)
return ret;
}

fwnode_property_read_u32(node,
plbossart marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -284,7 +322,21 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
fwnode_property_read_u32(node, "mipi-sdw-port-encoding-type",
&dpn[i].port_encoding);

/* TODO: Read audio mode */
nval = fwnode_property_count_u32(node, "mipi-sdw-lane-list");
if (nval > 0) {
dpn[i].num_lanes = nval;
dpn[i].lane_list = devm_kcalloc(&slave->dev,
dpn[i].num_lanes, sizeof(*dpn[i].lane_list),
GFP_KERNEL);
if (!dpn[i].lane_list)
return -ENOMEM;

ret = fwnode_property_read_u32_array(node,
"mipi-sdw-lane-list",
dpn[i].lane_list, dpn[i].num_lanes);
if (ret < 0)
return ret;
}

fwnode_handle_put(node);

Expand All @@ -304,6 +356,7 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
struct device *dev = &slave->dev;
struct fwnode_handle *port;
int nval;
int ret;

device_property_read_u32(dev, "mipi-sdw-sw-interface-revision",
&prop->mipi_revision);
Expand All @@ -326,8 +379,11 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
device_property_read_u32(dev, "mipi-sdw-clockstopprepare-timeout",
&prop->clk_stop_timeout);

device_property_read_u32(dev, "mipi-sdw-slave-channelprepare-timeout",
&prop->ch_prep_timeout);
ret = device_property_read_u32(dev, "mipi-sdw-peripheral-channelprepare-timeout",
plbossart marked this conversation as resolved.
Show resolved Hide resolved
&prop->ch_prep_timeout);
if (ret < 0)
device_property_read_u32(dev, "mipi-sdw-slave-channelprepare-timeout",
&prop->ch_prep_timeout);

device_property_read_u32(dev,
"mipi-sdw-clockstopprepare-hard-reset-behavior",
Expand All @@ -354,7 +410,24 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
device_property_read_u32(dev, "mipi-sdw-sink-port-list",
&prop->sink_ports);

/* Read dp0 properties */
device_property_read_u32(dev, "mipi-sdw-sdca-interrupt-register-list",
&prop->sdca_interrupt_register_list);

/*
* The specification defines the property value as boolean, but
* the value can be defined as zero. This is not aligned the
* implementation of device_property_read_bool() which only checks
* the presence of the property.
* Let's use read_u8 to work-around this conceptual disconnect.
*/
device_property_read_u8(dev, "mipi-sdw-commit-register-supported",
&prop->commit_register_supported);

/*
* Read dp0 properties - we don't rely on the 'mipi-sdw-dp-0-supported'
* property since the 'mipi-sdw-dp0-subproperties' property is logically
* equivalent.
*/
port = device_get_named_child_node(dev, "mipi-sdw-dp-0-subproperties");
if (!port) {
dev_dbg(dev, "DP0 node not found!!\n");
Expand Down
Loading
Loading