Debian Codegraph @

src/mainboard/getac/p470/early_init.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <arch/io.h>
4 #include <bootblock_common.h>
5 #include <console/console.h>
6 #include <device/pnp_ops.h>
7 #include <device/pci_ops.h>
8 #include <gpio.h>
9 #include <northbridge/intel/i945/i945.h>
10 #include <option.h>
11 #include <stdint.h>
12 #include <southbridge/intel/i82801gx/i82801gx.h>
13
14 void mainboard_pre_raminit_config(int s3_resume)
15 {
16 printk(BIOS_SPEW, "\n Initializing drive bay...\n");
17 gpio_set(33, 1); // GPIO33 = ODD
18 gpio_set(34, 1); // GPIO34 = IDE_RST#
19 gpio_set(13, 0); // ??
20
21 printk(BIOS_SPEW, "\n Initializing Ethernet NIC...\n");
22 gpio_set(24, 0); // Enable LAN Power
23 }
24
25 /* Override the default lpc decode ranges */
26 void mainboard_lpc_decode(void)
27 {
28 int lpt_en = 0;
29
30 if (get_uint_option("lpt", 0))
31 lpt_en = LPT_LPC_EN; /* enable LPT */
32
33 // decode range
34 pci_write_config16(PCI_DEV(0, 0x1f, 0), LPC_IO_DEC, 0x0007);
35 // decode range
36 pci_update_config32(PCI_DEV(0, 0x1f, 0), LPC_EN, ~LPT_LPC_EN, lpt_en);
37 }
38
39 /* This box has two superios, so enabling serial becomes slightly excessive.
40 * We disable a lot of stuff to make sure that there are no conflicts between
41 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
42 * but safe anyways" method.
43 */
44 static void pnp_enter_ext_func_mode(pnp_devfn_t dev)
45 {
46 unsigned int port = dev >> 8;
47 outb(0x55, port);
48 }
49
50 static void pnp_exit_ext_func_mode(pnp_devfn_t dev)
51 {
52 unsigned int port = dev >> 8;
53 outb(0xaa, port);
54 }
55
56 void bootblock_mainboard_early_init(void)
57 {
58 const pnp_devfn_t dev = PNP_DEV(0x4e, 0x00);
59
60 pnp_enter_ext_func_mode(dev);
61 pnp_write_config(dev, 0x02, 0x0e); // UART power
62 pnp_write_config(dev, 0x1b, (0x3e8 >> 2)); // UART3 base
63 pnp_write_config(dev, 0x1c, (0x2e8 >> 2)); // UART4 base
64 pnp_write_config(dev, 0x1d, (5 << 4) | 11); // UART3,4 IRQ
65 pnp_write_config(dev, 0x1e, 1); // no 32khz clock
66 pnp_write_config(dev, 0x24, (0x3f8 >> 2)); // UART1 base
67 pnp_write_config(dev, 0x28, (4 << 4) | 0); // UART1,2 IRQ
68 pnp_write_config(dev, 0x2c, 0); // DMA0 FIR
69 pnp_write_config(dev, 0x30, (0x600 >> 4)); // Runtime Register Block Base
70
71 pnp_write_config(dev, 0x31, 0xce); // GPIO1 DIR
72 pnp_write_config(dev, 0x32, 0x00); // GPIO1 POL
73 pnp_write_config(dev, 0x33, 0x0f); // GPIO2 DIR
74 pnp_write_config(dev, 0x34, 0x00); // GPIO2 POL
75 pnp_write_config(dev, 0x35, 0xa8); // GPIO3 DIR
76 pnp_write_config(dev, 0x36, 0x00); // GPIO3 POL
77 pnp_write_config(dev, 0x37, 0xa8); // GPIO4 DIR
78 pnp_write_config(dev, 0x38, 0x00); // GPIO4 POL
79
80 pnp_write_config(dev, 0x39, 0x00); // GPIO1 OUT
81 pnp_write_config(dev, 0x40, 0x80); // GPIO2/MISC OUT
82 pnp_write_config(dev, 0x41, 0x00); // GPIO5 OUT
83 pnp_write_config(dev, 0x42, 0xa8); // GPIO5 DIR
84 pnp_write_config(dev, 0x43, 0x00); // GPIO5 POL
85 pnp_write_config(dev, 0x44, 0x00); // GPIO ALT1
86 pnp_write_config(dev, 0x45, 0x50); // GPIO ALT2
87 pnp_write_config(dev, 0x46, 0x00); // GPIO ALT3
88
89 pnp_write_config(dev, 0x48, 0x55); // GPIO ALT5
90 pnp_write_config(dev, 0x49, 0x55); // GPIO ALT6
91 pnp_write_config(dev, 0x4a, 0x55); // GPIO ALT7
92 pnp_write_config(dev, 0x4b, 0x55); // GPIO ALT8
93 pnp_write_config(dev, 0x4c, 0x55); // GPIO ALT9
94 pnp_write_config(dev, 0x4d, 0x55); // GPIO ALT10
95
96 pnp_exit_ext_func_mode(dev);
97 }
98
99 void mainboard_late_rcba_config(void)
100 {
101 /* Device 1f interrupt pin register */
102 RCBA32(D31IP) = 0x00042220;
103 /* Device 1d interrupt pin register */
104 RCBA32(D28IP) = 0x00214321;
105
106 /* dev irq route register */
107 RCBA16(D31IR) = 0x0232;
108 RCBA16(D30IR) = 0x3246;
109 RCBA16(D29IR) = 0x0237;
110 RCBA16(D28IR) = 0x3201;
111 RCBA16(D27IR) = 0x3216;
112
113 /* Disable unused devices */
114 RCBA32(FD) |= FD_INTLAN;
115
116 /* This should probably go into the ACPI enable trap */
117
118 /* Set up I/O Trap #3 for 0x800-0x80c (Trap) */
119 RCBA32(0x1e9c) = 0x000200f0;
120 RCBA32(0x1e98) = 0x000c0801;
121 }