devicetree: Add USB device type

This commit adds support for describing USB ports in devicetree.cb.
It allows a USB port location to be described in the tree with
configuration information, and ACPI code to be generated that
provides this information to the OS.

A new scan_usb_bus() is added that will scan bridges for devices so
a tree of ports and hubs can be created.

The device address is computed with a 'port type' and a 'port id'
which is flexible for SOC to handle depending on their specific USB
setup and allows USB2 and USB3 ports to be described separately.

For example a board may have devices on two ports, one with a USB2
device and one with a USB3 device, both of which are connected to an
xHCI controller with a root hub:

     xHCI
       |
    RootHub
    |     |
USB2[0]  USB3[2]

device pci 14.0 on
  chip drivers/usb/acpi
    register "name" = ""Root Hub""
    device usb 0.0 on
      chip drivers/usb/acpi
        register "name" = ""USB 2.0 Port 0""
        device usb 2.0 on end
      end
      chip drivers/usb/acpi
        register "name" = ""USB 3.0 Port 2""
        device usb 3.2 on end
      end
    end
  end
end

Change-Id: I64e6eba503cdab49be393465b535e139a8c90ef4
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://review.coreboot.org/26169
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
This commit is contained in:
Duncan Laurie
2018-05-07 14:18:13 -07:00
committed by Patrick Georgi
parent 57df088816
commit bae9f85ddb
10 changed files with 173 additions and 126 deletions

View File

@@ -151,7 +151,8 @@ extern int yydebug;
PCIINT = 283,
GENERIC = 284,
SPI = 285,
MMIO = 286
USB = 286,
MMIO = 287
};
#endif
@@ -428,7 +429,7 @@ union yyalloc
#define YYLAST 39
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 32
#define YYNTOKENS 33
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 13
/* YYNRULES -- Number of rules. */
@@ -439,7 +440,7 @@ union yyalloc
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 286
#define YYMAXUTOK 287
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -476,7 +477,7 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 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
25, 26, 27, 28, 29, 30, 31, 32
};
#if YYDEBUG
@@ -498,7 +499,7 @@ static const char *const yytname[] =
"BUS", "RESOURCE", "END", "EQUALS", "HEX", "STRING", "PCI", "PNP", "I2C",
"APIC", "CPU_CLUSTER", "CPU", "DOMAIN", "IRQ", "DRQ", "IO", "NUMBER",
"SUBSYSTEMID", "INHERIT", "IOAPIC_IRQ", "IOAPIC", "PCIINT", "GENERIC",
"SPI", "MMIO", "$accept", "devtree", "$@1", "chipchildren",
"SPI", "USB", "MMIO", "$accept", "devtree", "$@1", "chipchildren",
"devicechildren", "chip", "@2", "device", "@3", "resource", "registers",
"subsystemid", "ioapic_irq", YY_NULLPTR
};
@@ -512,7 +513,7 @@ static const yytype_uint16 yytoknum[] =
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286
285, 286, 287
};
# endif
@@ -586,19 +587,19 @@ static const yytype_int8 yycheck[] =
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
0, 33, 34, 0, 3, 37, 12, 38, 35, 4,
5, 9, 37, 39, 42, 7, 12, 23, 10, 6,
12, 40, 36, 8, 9, 24, 26, 37, 39, 41,
43, 44, 23, 23, 23, 10, 23, 28, 23, 25,
0, 34, 35, 0, 3, 38, 12, 39, 36, 4,
5, 9, 38, 40, 43, 7, 12, 23, 10, 6,
12, 41, 37, 8, 9, 24, 26, 38, 40, 42,
44, 45, 23, 23, 23, 10, 23, 28, 23, 25,
23
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint8 yyr1[] =
{
0, 32, 34, 33, 35, 35, 35, 35, 36, 36,
36, 36, 36, 36, 38, 37, 40, 39, 41, 42,
43, 43, 44
0, 33, 35, 34, 36, 36, 36, 36, 37, 37,
37, 37, 37, 37, 39, 38, 41, 40, 42, 43,
44, 44, 45
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */