mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
pd: move get_info to common file.
get_info command needs to be used by all type-C accessories that would entertain being updated in the field. This CL migrates function to common/usb_pd_protocol.c for other boards to use. Signed-off-by: Todd Broch <tbroch@chromium.org> BRANCH=samus BUG=chrome-os-partner:31192,chrome-os-partner:31193 TEST=manual, Using ectool --name=cros_pd infopddev <0|1> Port:1 Devid 1.1 Hash: 0x00ec9619 0x811f3e68 0x4b90c8e9 0xd5b98fa8 0xfd373777 Port:1 Devid 3.0 Hash: 0x682fd366 0x7213f55e 0xddefb802 0xbedfec42 0x5cdcc226 Port:0 Devid 4.0 Hash: 0x57b1e4e0 0x7204075f 0x65c0fa72 0xdcca15ed 0xf3231237 Change-Id: Iffa8699056351f62cf90fdecbc7ef5cee81e67bb Reviewed-on: https://chromium-review.googlesource.com/226891 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org> Commit-Queue: Todd Broch <tbroch@chromium.org> Tested-by: Todd Broch <tbroch@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
63704fd11b
commit
2bc0b68c86
@@ -27,8 +27,11 @@
|
||||
#define CONFIG_USB_INHIBIT_CONNECT
|
||||
#define CONFIG_USB_POWER_DELIVERY
|
||||
#define CONFIG_USB_PD_ALT_MODE
|
||||
#define CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR USB_PD_HW_DEV_ID_DINGDONG
|
||||
#define CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR 0
|
||||
#define CONFIG_USB_PD_DUAL_ROLE
|
||||
#define CONFIG_USB_PD_CUSTOM_VDM
|
||||
#define CONFIG_USB_PD_FLASH
|
||||
#define CONFIG_USB_PD_INTERNAL_COMP
|
||||
#define CONFIG_USB_PD_IDENTITY_HW_VERS 1
|
||||
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
#define CONFIG_TASK_LIST \
|
||||
TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(PD, pd_task, NULL, TASK_STACK_SIZE)
|
||||
TASK_ALWAYS(PD, pd_task, NULL, LARGER_TASK_STACK_SIZE)
|
||||
|
||||
@@ -296,6 +296,11 @@ static int pd_custom_vdm(int port, int cnt, uint32_t *payload,
|
||||
memcpy(payload + 1, &version_data.version, 24);
|
||||
rsize = 7;
|
||||
break;
|
||||
case VDO_CMD_READ_INFO:
|
||||
/* copy info into response */
|
||||
pd_get_info(payload + 1);
|
||||
rsize = 7;
|
||||
break;
|
||||
default:
|
||||
rsize = 0;
|
||||
}
|
||||
|
||||
@@ -35,8 +35,11 @@
|
||||
#define CONFIG_USB_INHIBIT_CONNECT
|
||||
#define CONFIG_USB_POWER_DELIVERY
|
||||
#define CONFIG_USB_PD_ALT_MODE
|
||||
#define CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR USB_PD_HW_DEV_ID_HOHO
|
||||
#define CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR 0
|
||||
#define CONFIG_USB_PD_DUAL_ROLE
|
||||
#define CONFIG_USB_PD_CUSTOM_VDM
|
||||
#define CONFIG_USB_PD_FLASH
|
||||
#define CONFIG_USB_PD_INTERNAL_COMP
|
||||
#define CONFIG_USB_PD_IDENTITY_HW_VERS 1
|
||||
#define CONFIG_USB_PD_IDENTITY_SW_VERS 1
|
||||
|
||||
@@ -19,4 +19,4 @@
|
||||
#define CONFIG_TASK_LIST \
|
||||
TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE) \
|
||||
TASK_ALWAYS(PD, pd_task, NULL, TASK_STACK_SIZE)
|
||||
TASK_ALWAYS(PD, pd_task, NULL, LARGER_TASK_STACK_SIZE)
|
||||
|
||||
@@ -295,6 +295,11 @@ static int pd_custom_vdm(int port, int cnt, uint32_t *payload,
|
||||
memcpy(payload + 1, &version_data.version, 24);
|
||||
rsize = 7;
|
||||
break;
|
||||
case VDO_CMD_READ_INFO:
|
||||
/* copy info into response */
|
||||
pd_get_info(payload + 1);
|
||||
rsize = 7;
|
||||
break;
|
||||
default:
|
||||
rsize = 0;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "registers.h"
|
||||
#include "rsa.h"
|
||||
#include "sha256.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
#include "util.h"
|
||||
@@ -409,12 +407,3 @@ exit_er:
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static struct sha256_ctx ctx;
|
||||
uint8_t *flash_hash_rw(void)
|
||||
{
|
||||
SHA256_init(&ctx);
|
||||
SHA256_update(&ctx, (void *)CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF,
|
||||
CONFIG_FW_RW_SIZE - RSANUMBYTES);
|
||||
return SHA256_final(&ctx);
|
||||
}
|
||||
|
||||
@@ -231,6 +231,14 @@ void panic_reboot(void)
|
||||
cpu_reset();
|
||||
}
|
||||
|
||||
enum system_image_copy_t system_get_image_copy(void)
|
||||
{
|
||||
if (is_ro_mode())
|
||||
return SYSTEM_IMAGE_RO;
|
||||
else
|
||||
return SYSTEM_IMAGE_RW;
|
||||
}
|
||||
|
||||
/* --- stubs --- */
|
||||
void __hw_timer_enable_clock(int n, int enable)
|
||||
{ /* Done in hardware init */ }
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
#include "hooks.h"
|
||||
#include "host_command.h"
|
||||
#include "registers.h"
|
||||
#include "rsa.h"
|
||||
#include "sha256.h"
|
||||
#include "system.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
#include "util.h"
|
||||
#include "usb_pd.h"
|
||||
#include "usb_pd_config.h"
|
||||
#include "version.h"
|
||||
|
||||
#ifdef CONFIG_COMMON_RUNTIME
|
||||
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
|
||||
@@ -1322,6 +1325,35 @@ void pd_dev_store_rw_hash(int port, uint16_t dev_id, uint32_t *rw_hash)
|
||||
pd_dev_dump_info(dev_id, (uint8_t *)rw_hash);
|
||||
}
|
||||
|
||||
uint8_t *flash_hash_rw(void)
|
||||
{
|
||||
static struct sha256_ctx ctx;
|
||||
SHA256_init(&ctx);
|
||||
SHA256_update(&ctx, (void *)CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF,
|
||||
CONFIG_FW_RW_SIZE - RSANUMBYTES);
|
||||
return SHA256_final(&ctx);
|
||||
}
|
||||
|
||||
void pd_get_info(uint32_t *info_data)
|
||||
{
|
||||
void *hash;
|
||||
|
||||
/* calculate RW hash */
|
||||
hash = flash_hash_rw();
|
||||
/* copy first 20 bytes of RW hash */
|
||||
memcpy(info_data, hash, 5 * sizeof(uint32_t));
|
||||
/* copy other info into data msg */
|
||||
#if defined(CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR) && \
|
||||
defined(CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR)
|
||||
info_data[5] = VDO_INFO(CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR,
|
||||
CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR,
|
||||
ver_get_numcommits(),
|
||||
(system_get_image_copy() != SYSTEM_IMAGE_RO));
|
||||
#else
|
||||
info_data[5] = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
void pd_set_dual_role(enum pd_dual_role_states state)
|
||||
{
|
||||
|
||||
@@ -791,6 +791,13 @@ void pd_new_contract(int port, int pr_role, int dr_role,
|
||||
*/
|
||||
void pd_execute_data_swap(int port, int data_role);
|
||||
|
||||
/**
|
||||
* Get PD device info used for VDO_CMD_SEND_INFO / VDO_CMD_READ_INFO
|
||||
*
|
||||
* @param info_data pointer to info data array
|
||||
*/
|
||||
void pd_get_info(uint32_t *info_data);
|
||||
|
||||
/**
|
||||
* Handle Vendor Defined Messages
|
||||
*
|
||||
|
||||
@@ -130,6 +130,7 @@ int board_discharge_on_ac(int enabled);
|
||||
#define CONFIG_USB_POWER_DELIVERY
|
||||
#define CONFIG_USB_PD_CUSTOM_VDM
|
||||
#define CONFIG_USB_PD_DUAL_ROLE
|
||||
#define CONFIG_SHA256
|
||||
#define CONFIG_SW_CRC
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user