summaryrefslogtreecommitdiff
path: root/chip/stm32/usb-stm32g4.c
blob: b4402f670d93cb113a421fee0170f879ca4b2403 (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
/* Copyright 2021 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.
 *
 * STM32G4 Family specific USB functionality
 */

#include "registers.h"
#include "system.h"
#include "usb_api.h"

void usb_connect(void)
{
	/* USB is in use */
	disable_sleep(SLEEP_MASK_USB_DEVICE);

	STM32_USB_BCDR |= STM32_USB_BCDR_DPPU;
}

void usb_disconnect(void)
{
	/* disable pull-up on DP to disconnect */
	STM32_USB_BCDR &= ~STM32_USB_BCDR_DPPU;

	/* USB is off, so sleep whenever */
	enable_sleep(SLEEP_MASK_USB_DEVICE);
}