summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorKarthikeyan Ramasubramanian <kramasub@google.com>2019-10-02 15:09:45 -0600
committerCommit Bot <commit-bot@chromium.org>2019-11-09 02:16:42 +0000
commit27db31e6d02a54d5706d8cb4d1b5db6ff757f659 (patch)
tree638e3c80f757205774cc62037b056dc9cab64132 /driver
parentffb96cd5ba990c8d6d91a044105eb225087781aa (diff)
downloadchrome-ec-27db31e6d02a54d5706d8cb4d1b5db6ff757f659.tar.gz
Add a board specific helper to return USB PD port count
Certain SKUs of certain boards have less number of USB PD ports than configured in CONFIG_USB_PD_PORT_MAX_COUNT. Hence define an overrideable board specific helper to return the number of USB PD ports. This helps to avoid initiating a PD firmware update in SKUs where there are less number of USB PD ports. Also update charge manager to ensure that absent/ invalid PD ports are skipped during port initialization and management. BUG=b:140816510, b:143196487 BRANCH=octopus TEST=make -j buildall; Boot to ChromeOS in bobba(2A + 2C config) and garg(2A + 1C + 1HDMI config). Change-Id: Ie345cef470ad878ec443ddf4797e5d17cfe1f61e Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1879338 Tested-by: Karthikeyan Ramasubramanian <kramasub@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Karthikeyan Ramasubramanian <kramasub@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/bc12/pi3usb9201.c2
-rw-r--r--driver/charger/bd9995x.c4
-rw-r--r--driver/ppc/aoz1380.c2
-rw-r--r--driver/ppc/nx20p348x.c2
-rw-r--r--driver/ppc/sn5s330.c2
-rw-r--r--driver/retimer/bb_retimer.c2
-rw-r--r--driver/tcpm/it83xx.c4
-rw-r--r--driver/tcpm/tcpci.c5
-rw-r--r--driver/usb_mux/usb_mux.c4
9 files changed, 15 insertions, 12 deletions
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index be2844e3e3..7f11e1da8a 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -244,7 +244,7 @@ void usb_charger_task(void *u)
* Set most recent bc1.2 detection supplier result to
* CHARGE_SUPPLIER_NONE for all ports.
*/
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ for (i = 0; i < board_get_usb_pd_port_count(); i++)
bc12_supplier[port] = CHARGE_SUPPLIER_NONE;
/*
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index dc3125928f..23303589b6 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -1273,7 +1273,7 @@ void usb_charger_task(void *u)
vbus_voltage = 0;
#endif
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
bc12_detected_type[port] = CHARGE_SUPPLIER_NONE;
bd9995x_enable_vbus_detect_interrupts(port, 1);
bc12_det_mark[port] = 0;
@@ -1282,7 +1282,7 @@ void usb_charger_task(void *u)
while (1) {
sleep_usec = -1;
changed = 0;
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) {
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
/* Get port interrupts */
interrupts = bd9995x_get_interrupts(port);
if (interrupts & BD9995X_CMD_INT_VBUS_DET ||
diff --git a/driver/ppc/aoz1380.c b/driver/ppc/aoz1380.c
index f077a5e07d..708d488e94 100644
--- a/driver/ppc/aoz1380.c
+++ b/driver/ppc/aoz1380.c
@@ -93,7 +93,7 @@ static void aoz1380_irq_deferred(void)
int i;
uint32_t pending = atomic_read_clear(&irq_pending);
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ for (i = 0; i < board_get_usb_pd_port_count(); i++)
if (BIT(i) & pending)
aoz1380_handle_interrupt(i);
}
diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c
index bdbd02d6b2..01c28f52eb 100644
--- a/driver/ppc/nx20p348x.c
+++ b/driver/ppc/nx20p348x.c
@@ -384,7 +384,7 @@ static void nx20p348x_irq_deferred(void)
int i;
uint32_t pending = atomic_read_clear(&irq_pending);
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ for (i = 0; i < board_get_usb_pd_port_count(); i++)
if (BIT(i) & pending)
nx20p348x_handle_interrupt(i);
}
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index 6a877b0808..cdc355a8ae 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -750,7 +750,7 @@ static void sn5s330_irq_deferred(void)
int i;
uint32_t pending = atomic_read_clear(&irq_pending);
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ for (i = 0; i < board_get_usb_pd_port_count(); i++)
if (BIT(i) & pending)
sn5s330_handle_interrupt(i);
}
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index e211c10d58..a6e7f87150 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -235,7 +235,7 @@ static int console_command_bb_retimer(int argc, char **argv)
/* Get port number */
port = strtoi(argv[1], &e, 0);
- if (*e || port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
+ if (*e || port < 0 || port > board_get_usb_pd_port_count())
return EC_ERROR_PARAM1;
/* Validate r/w selection */
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 4b2dc4fc6e..fd03426e33 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -544,11 +544,11 @@ static int it83xx_tcpm_set_rx_enable(int port, int enable)
}
/* If any PD port is connected, then disable deep sleep */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; ++i)
+ for (i = 0; i < board_get_usb_pd_port_count(); ++i)
if (IT83XX_USBPD_GCR(i) | USBPD_REG_MASK_BMC_PHY)
break;
- if (i == CONFIG_USB_PD_PORT_MAX_COUNT)
+ if (i == board_get_usb_pd_port_count())
enable_sleep(SLEEP_MASK_USB_PD);
else
disable_sleep(SLEEP_MASK_USB_PD);
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index ba8e9f2f42..21aa13cd5e 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -744,7 +744,7 @@ int tcpci_get_chip_info(int port, int live,
int error;
int val;
- if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ if (port >= board_get_usb_pd_port_count())
return EC_ERROR_INVAL;
i = &info[port];
@@ -816,6 +816,9 @@ int tcpci_tcpm_init(int port)
int power_status;
int tries = TCPM_INIT_TRIES;
+ if (port >= board_get_usb_pd_port_count())
+ return EC_ERROR_INVAL;
+
while (1) {
error = tcpc_read(port, TCPC_REG_POWER_STATUS, &power_status);
/*
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 0d08fbc99c..122f71d773 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -195,7 +195,7 @@ static int command_typec(int argc, char **argv)
return EC_ERROR_PARAM_COUNT;
port = strtoi(argv[1], &e, 10);
- if (*e || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ if (*e || port >= board_get_usb_pd_port_count())
return EC_ERROR_PARAM1;
if (argc < 3) {
@@ -234,7 +234,7 @@ static enum ec_status hc_usb_pd_mux_info(struct host_cmd_handler_args *args)
int port = p->port;
const struct usb_mux *mux;
- if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ if (port >= board_get_usb_pd_port_count())
return EC_RES_INVALID_PARAM;
mux = &usb_muxes[port];