intel/common/block: Move mainboard api to tcss common block
As per the comments in CB:54090 mainboard api mainboard_tcss_get_port_info() is simplified and moved to tcss common block code. Signed-off-by: Deepti Deshatty <deepti.deshatty@intel.com> Change-Id: I7894363df4862f7cfe733d93e6160677fb8a9e31 Reviewed-on: https://review.coreboot.org/c/coreboot/+/54733 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com>
This commit is contained in:
parent
7014efd8cf
commit
c146daf8a3
|
@ -23,4 +23,12 @@ struct drivers_intel_pmc_mux_conn_config {
|
||||||
enum typec_orientation hsl_orientation;
|
enum typec_orientation hsl_orientation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method verifies input "conn" device.
|
||||||
|
* Returns 'true' if device passed is Intel PMC MUX Conn device else returns 'false'.
|
||||||
|
* Method also outputs the usb2 and usb3 port numbers associated with the 'conn' device
|
||||||
|
*/
|
||||||
|
bool intel_pmc_mux_conn_get_ports(const struct device *conn, unsigned int *usb2_port,
|
||||||
|
unsigned int *usb3_port);
|
||||||
|
|
||||||
#endif /* __DRIVERS_INTEL_PMC_MUX_CONN_H__ */
|
#endif /* __DRIVERS_INTEL_PMC_MUX_CONN_H__ */
|
||||||
|
|
|
@ -85,3 +85,18 @@ struct chip_operations drivers_intel_pmc_mux_conn_ops = {
|
||||||
CHIP_NAME("Intel PMC MUX CONN Driver")
|
CHIP_NAME("Intel PMC MUX CONN Driver")
|
||||||
.enable_dev = conn_enable,
|
.enable_dev = conn_enable,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool intel_pmc_mux_conn_get_ports(const struct device *conn, unsigned int *usb2_port,
|
||||||
|
unsigned int *usb3_port)
|
||||||
|
{
|
||||||
|
const struct drivers_intel_pmc_mux_conn_config *mux_config;
|
||||||
|
|
||||||
|
if (!conn->chip_info || conn->chip_ops != &drivers_intel_pmc_mux_conn_ops)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mux_config = conn->chip_info;
|
||||||
|
*usb2_port = mux_config->usb2_port_number;
|
||||||
|
*usb3_port = mux_config->usb3_port_number;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
|
@ -142,63 +142,6 @@ void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *cfg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_correct_port(const struct device *dev, int port)
|
|
||||||
{
|
|
||||||
return dev->path.type == DEVICE_PATH_GENERIC && dev->path.generic.id == port
|
|
||||||
&& dev->chip_ops == &drivers_intel_pmc_mux_conn_ops;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct drivers_intel_pmc_mux_conn_config *get_connector_config(
|
|
||||||
const struct device *mux,
|
|
||||||
int port)
|
|
||||||
{
|
|
||||||
const struct drivers_intel_pmc_mux_conn_config *config = NULL;
|
|
||||||
DEVTREE_CONST struct device *conn = NULL;
|
|
||||||
|
|
||||||
while ((conn = dev_bus_each_child(mux->link_list, conn)) != NULL) {
|
|
||||||
if (is_correct_port(conn, port))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conn)
|
|
||||||
config = (const struct drivers_intel_pmc_mux_conn_config *) conn->chip_info;
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct tcss_port_map *mainboard_tcss_get_port_info(size_t *num_ports)
|
|
||||||
{
|
|
||||||
static struct tcss_port_map port_map[MAX_TYPE_C_PORTS];
|
|
||||||
size_t port;
|
|
||||||
const struct device *pmc;
|
|
||||||
const struct device *mux;
|
|
||||||
const struct drivers_intel_pmc_mux_conn_config *mux_config;
|
|
||||||
size_t active_ports = 0;
|
|
||||||
|
|
||||||
pmc = pcidev_path_on_root(PCH_DEVFN_PMC);
|
|
||||||
if (!pmc || !pmc->link_list) {
|
|
||||||
printk(BIOS_ERR, "%s: unable to find PMC device or its mux\n", __func__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
mux = pmc->link_list->children;
|
|
||||||
if (!mux)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (port = 0; port < MAX_TYPE_C_PORTS; port++) {
|
|
||||||
mux_config = get_connector_config(mux, port);
|
|
||||||
if (mux_config == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
port_map[active_ports].usb2_port = mux_config->usb2_port_number;
|
|
||||||
port_map[active_ports].usb3_port = mux_config->usb3_port_number;
|
|
||||||
active_ports++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*num_ports = active_ports;
|
|
||||||
return port_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mainboard_chip_init(void *chip_info)
|
static void mainboard_chip_init(void *chip_info)
|
||||||
{
|
{
|
||||||
const struct pad_config *base_pads;
|
const struct pad_config *base_pads;
|
||||||
|
|
|
@ -161,10 +161,10 @@ void tcss_configure(const struct typec_aux_bias_pads pads[MAX_TYPE_C_PORTS]);
|
||||||
const struct tcss_mux_info *mainboard_tcss_get_mux_info(int port);
|
const struct tcss_mux_info *mainboard_tcss_get_mux_info(int port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mainboard method to get only the port information to initialize the muxes to
|
* Method to get only the port information to initialize the muxes to
|
||||||
* disconnect mode during boot.
|
* disconnect mode during boot.
|
||||||
* returns tscc_port_map of all ports on system
|
* returns tscc_port_map of all ports on system
|
||||||
*/
|
*/
|
||||||
const struct tcss_port_map *mainboard_tcss_get_port_info(size_t *num_ports);
|
const struct tcss_port_map *tcss_get_port_info(size_t *num_ports);
|
||||||
|
|
||||||
#endif /* _TCSS_H_ */
|
#endif /* _TCSS_H_ */
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <soc/pcr_ids.h>
|
#include <soc/pcr_ids.h>
|
||||||
#include <soc/tcss.h>
|
#include <soc/tcss.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <drivers/intel/pmc_mux/conn/chip.h>
|
||||||
|
|
||||||
#define BIAS_CTRL_VW_INDEX_SHIFT 16
|
#define BIAS_CTRL_VW_INDEX_SHIFT 16
|
||||||
#define BIAS_CTRL_BIT_POS_SHIFT 8
|
#define BIAS_CTRL_BIT_POS_SHIFT 8
|
||||||
|
@ -338,13 +339,44 @@ static void tcss_configure_aux_bias_pads(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct tcss_port_map *tcss_get_port_info(size_t *num_ports)
|
||||||
|
{
|
||||||
|
static struct tcss_port_map port_map[MAX_TYPE_C_PORTS];
|
||||||
|
size_t active_ports = 0;
|
||||||
|
size_t port;
|
||||||
|
|
||||||
|
for (port = 0; port < MAX_TYPE_C_PORTS; port++) {
|
||||||
|
const struct device_path conn_path[] = {
|
||||||
|
{.type = DEVICE_PATH_PCI, .pci.devfn = PCH_DEVFN_PMC},
|
||||||
|
{.type = DEVICE_PATH_GENERIC, .generic.id = 0, .generic.subid = 0},
|
||||||
|
{.type = DEVICE_PATH_GENERIC, .generic.id = port},
|
||||||
|
};
|
||||||
|
const struct device *conn = find_dev_nested_path(pci_root_bus(), conn_path,
|
||||||
|
ARRAY_SIZE(conn_path));
|
||||||
|
unsigned int usb2_port, usb3_port;
|
||||||
|
|
||||||
|
if (!conn)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (CONFIG(DRIVERS_INTEL_PMC) &&
|
||||||
|
intel_pmc_mux_conn_get_ports(conn, &usb2_port, &usb3_port)) {
|
||||||
|
port_map[active_ports].usb2_port = usb2_port;
|
||||||
|
port_map[active_ports].usb3_port = usb3_port;
|
||||||
|
++active_ports;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*num_ports = active_ports;
|
||||||
|
return port_map;
|
||||||
|
}
|
||||||
|
|
||||||
void tcss_configure(const struct typec_aux_bias_pads aux_bias_pads[MAX_TYPE_C_PORTS])
|
void tcss_configure(const struct typec_aux_bias_pads aux_bias_pads[MAX_TYPE_C_PORTS])
|
||||||
{
|
{
|
||||||
const struct tcss_port_map *port_map;
|
const struct tcss_port_map *port_map;
|
||||||
size_t num_ports;
|
size_t num_ports;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
port_map = mainboard_tcss_get_port_info(&num_ports);
|
port_map = tcss_get_port_info(&num_ports);
|
||||||
if (port_map == NULL)
|
if (port_map == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue