Debian Codegraph @

Documentation/superio/common/pnp.md

raw symbols SCIP
1 # PNP devices
2
3 Typical PNP devices are Super I/Os, LPC-connected TPMs and board
4 management controllers.
5
6 PNP devices are usually connected to the LPC or eSPI bus of a system
7 and shouldn't be confused with PCI(e) devices that use a completely
8 different plug and play mechanism. PNP originates in the ISA plug and
9 play specification. Since the original ISA bus is more or less extinct,
10 the auto-detection part of ISA PNP is mostly irrelevant nowadays. For
11 the register offsets for different functionality, appendix A of that
12 specification is still the main reference though.
13
14 ## Configuration access and config mode
15
16 Super I/O chips connected via LPC to the southbridge usually have their
17 I/O-mapped configuration interface with a size of two bytes at the base
18 address `0x2e` or `0x4e`. Other PNP devices have their configuration
19 interface at other addresses.
20
21 The two byte registers allow access to an indirect 256 bytes big
22 register space that contains the configuration. By writing the index to
23 the lower byte (e.g. `0x2e`), you can access the register contents at
24 that index by reading/writing the higher byte (e.g. `0x2f`).
25
26 To prevent accidental changes of the Super I/O (SIO) configuration,
27 the SIOs need a configuration mode unlock sequence. After changing the
28 configuration, the configuration mode should be left again, by sending
29 the configuration mode lock sequence.
30
31 ## Logical device numbers (LDN)
32
33 Each PNP device can contain multiple logical devices. The bytes from
34 `0x00` to `0x2f` in the indirect configuration register space are common
35 for all LDNs, but some SIO chips require a certain LDN to be selected in
36 order to write certain registers in there. An LDN gets selected by
37 writing the LDN number to the LDN select register `0x07`. Registers
38 `0x30` to `0xff` are specific to each LDN number.
39
40 coreboot encodes the physical LDN number in the lower byte of the LDN
41 number.
42
43 ### Virtual logical device numbers
44
45 Register `0x30` is the LDN enable register and since it is an 8 bit
46 register, it can contain up to 8 enable bits for different parts of
47 the functionality of that logical device. To set a certain enable bit
48 in one physical LDN, the concept of virtual LDNs was introduced.
49 Virtual LDNs share the registers of their base LDN, but allow to
50 specify which part of a LDN should be enabled.
51
52 coreboot encodes the enable bit number and by that the virtual LDN
53 part in the lower 3 bits of the higher byte of the LDN number.
54
55 ## I/O resources
56
57 Starting at register address `0x60`, each LDN has 2 byte wide I/O base
58 address registers. The size of an I/O resource is always a power of
59 two.
60
61 ### I/O resource masks
62
63 The I/O resource masks encode both the size and the maximum base
64 address of the corresponding IO resource. The number of zeros counted
65 from the least significant bit encode the resource size. If N is the
66 number of LSBs being zero, which can also be zero if the LSB is a one,
67 the resource has N address bits and a size of 2\*\*N bytes. The mask
68 address is also the highest possible address to map the I/O region.
69
70 A typical example for an I/O resource mask is `0x07f8` which is
71 `0b0000011111111000` in binary notation. The three LSBs are zeros here,
72 so it's an eight byte I/O resource with three address offset bits
73 inside the resource. The highest base address it can be mapped to is
74 `0x07f8`, so the region will end at `0x07ff`.
75
76 The Super I/O datasheets typically contain the information about the
77 I/O resource masks. On most Super I/O chips the mask can also be found
78 out by writing `0xffff` to the corresponding I/O base address register
79 and reading back the value; since the lowest and highest bits are
80 hard-wired to zero according to the I/O resource size and maximal
81 possible I/O address, this gives the mask.
82
83 ## IRQ resources
84
85 Each physical LDN has up to two configurable interrupt request register
86 pairs `0x70`, `0x71` and `0x72`, `0x73`. Each pair can be configured to
87 use a certain IRQ number. Writing 1 to 15 into the first register
88 selects the IRQ number generated by the corresponding IRQ source and
89 enables IRQ generation; writing 0 to it disables the generation of IRQs
90 for the source. The second register selects the IRQ type (level or edge)
91 and IRQ level (high or low). For LPC SIOs the IRQ type is hard-wired to
92 edge.
93
94 On the LPC bus a shared SERIRQ line is used to signal IRQs to the
95 host; the IRQ number gets encoded by the number of LPC clock cycles
96 after the start frame before the device pulls the open drain
97 connection low.
98
99 SERIRQ can be used in two different modes: In the continuous SERIRQ
100 mode the host continuously sends IRQ frame starts and the devices
101 signal their IRQ request by pulling low the SERIRQ line at the right
102 time. In quiet SERIRQ mode the host doesn't send IRQ frame starts, so
103 the devices have to send both the IRQ frame start and the encoded IRQ
104 number. The quiet mode is often broken.
105
106 ## DRQ resources
107
108 Each physical LDN has two legacy ISA-style DMA request channel
109 registers at `0x74` and `0x75`. Those are only used for legacy devices
110 like parallel printer ports or floppy disk controllers.
111
112 Each device using LPC legacy DMA needs its own LDMA line to the host.
113 Some newer chipsets have dropped the LDMA line and with that the
114 legacy DMA capability on LPC.