mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-01 00:50:43 +09:00
sunxi: usbc: Add support for usb-vbus0 controller by axp drivebus pin
The axp221 / axp223's N_VBUSEN pin can be configured as an output rather then an input, and this is used on some boards to control usb-vbus0, add support for this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk>
This commit is contained in:
parent
4458b7a6e1
commit
a90e77dbeb
@ -17,6 +17,15 @@
|
|||||||
#include <asm/gpio.h>
|
#include <asm/gpio.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#ifdef CONFIG_AXP152_POWER
|
||||||
|
#include <axp152.h>
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_AXP209_POWER
|
||||||
|
#include <axp209.h>
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_AXP221_POWER
|
||||||
|
#include <axp221.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SUNXI_USB_PMU_IRQ_ENABLE 0x800
|
#define SUNXI_USB_PMU_IRQ_ENABLE 0x800
|
||||||
#define SUNXI_USB_CSR 0x404
|
#define SUNXI_USB_CSR 0x404
|
||||||
@ -71,6 +80,12 @@ static struct sunxi_usbc_hcd {
|
|||||||
|
|
||||||
static int enabled_hcd_count;
|
static int enabled_hcd_count;
|
||||||
|
|
||||||
|
static bool use_axp_drivebus(int index)
|
||||||
|
{
|
||||||
|
return index == 0 &&
|
||||||
|
strcmp(CONFIG_USB0_VBUS_PIN, "axp_drivebus") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
void *sunxi_usbc_get_io_base(int index)
|
void *sunxi_usbc_get_io_base(int index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
@ -87,6 +102,9 @@ void *sunxi_usbc_get_io_base(int index)
|
|||||||
|
|
||||||
static int get_vbus_gpio(int index)
|
static int get_vbus_gpio(int index)
|
||||||
{
|
{
|
||||||
|
if (use_axp_drivebus(index))
|
||||||
|
return -1;
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_PIN);
|
case 0: return sunxi_name_to_gpio(CONFIG_USB0_VBUS_PIN);
|
||||||
case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN);
|
case 1: return sunxi_name_to_gpio(CONFIG_USB1_VBUS_PIN);
|
||||||
@ -233,6 +251,10 @@ void sunxi_usbc_vbus_enable(int index)
|
|||||||
{
|
{
|
||||||
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
|
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
|
||||||
|
|
||||||
|
#ifdef AXP_DRIVEBUS
|
||||||
|
if (use_axp_drivebus(index))
|
||||||
|
axp_drivebus_enable();
|
||||||
|
#endif
|
||||||
if (sunxi_usbc->gpio_vbus != -1)
|
if (sunxi_usbc->gpio_vbus != -1)
|
||||||
gpio_direction_output(sunxi_usbc->gpio_vbus, 1);
|
gpio_direction_output(sunxi_usbc->gpio_vbus, 1);
|
||||||
}
|
}
|
||||||
@ -241,6 +263,10 @@ void sunxi_usbc_vbus_disable(int index)
|
|||||||
{
|
{
|
||||||
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
|
struct sunxi_usbc_hcd *sunxi_usbc = &sunxi_usbc_hcd[index];
|
||||||
|
|
||||||
|
#ifdef AXP_DRIVEBUS
|
||||||
|
if (use_axp_drivebus(index))
|
||||||
|
axp_drivebus_disable();
|
||||||
|
#endif
|
||||||
if (sunxi_usbc->gpio_vbus != -1)
|
if (sunxi_usbc->gpio_vbus != -1)
|
||||||
gpio_direction_output(sunxi_usbc->gpio_vbus, 0);
|
gpio_direction_output(sunxi_usbc->gpio_vbus, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user