summaryrefslogtreecommitdiff
path: root/common/usb_charge_commands.c
blob: ad0380186d79da9cdf1dcbf5e82ea6c8fb1b4dd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* USB charging control commands for Chrome EC */

#include "console.h"
#include "usb_charge.h"
#include "host_command.h"
#include "util.h"

/* Console output macros */
#define CPUTS(outstr) cputs(CC_USBCHARGE, outstr)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)


int usb_charge_command_set_mode(uint8_t *data, int *resp_size)
{
	struct lpc_params_usb_charge_set_mode *p =
			(struct lpc_params_usb_charge_set_mode *)data;
	int rv;

	CPRINTF("[Setting USB port %d to mode %d]\n",
		p->usb_port_id, p->mode);
	rv = usb_charge_set_mode(p->usb_port_id, p->mode);

	if (rv != EC_SUCCESS)
		return EC_LPC_RESULT_ERROR;

	return EC_LPC_RESULT_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_LPC_COMMAND_USB_CHARGE_SET_MODE,
		     usb_charge_command_set_mode);