coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
uart.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/aoac.h>
4 #include <amdblocks/gpio.h>
5 #include <amdblocks/uart.h>
6 #include <commonlib/helpers.h>
7 #include <console/console.h>
8 #include <device/device.h>
9 #include <device/mmio.h>
10 #include <soc/aoac_defs.h>
11 #include <soc/gpio.h>
12 #include <soc/southbridge.h>
13 #include <soc/uart.h>
14 #include <types.h>
15 
16 static const struct {
18  struct soc_amd_gpio mux[2];
19 } uart_info[] = {
20  [0] = { APU_UART0_BASE, {
21  PAD_NF(GPIO_143, UART0_TXD, PULL_NONE),
22  PAD_NF(GPIO_141, UART0_RXD, PULL_NONE),
23  } },
24  [1] = { APU_UART1_BASE, {
25  PAD_NF(GPIO_140, UART1_TXD, PULL_NONE),
26  PAD_NF(GPIO_142, UART1_RXD, PULL_NONE),
27  } },
28 };
29 
30 uintptr_t get_uart_base(unsigned int idx)
31 {
32  if (idx >= ARRAY_SIZE(uart_info))
33  return 0;
34 
35  return uart_info[idx].base;
36 }
37 
39 {
40  write16((void *)FCH_LEGACY_UART_DECODE, 0);
41 }
42 
43 void set_uart_config(unsigned int idx)
44 {
45  if (idx >= ARRAY_SIZE(uart_info))
46  return;
47 
49 }
50 
51 static const char *uart_acpi_name(const struct device *dev)
52 {
53  switch (dev->path.mmio.addr) {
54  case APU_UART0_BASE:
55  return "FUR0";
56  case APU_UART1_BASE:
57  return "FUR1";
58  default:
59  return NULL;
60  }
61 }
62 
63 /* Even though this is called enable, it gets called for both enabled and disabled devices. */
64 static void uart_enable(struct device *dev)
65 {
66  unsigned int dev_id;
67 
68  switch (dev->path.mmio.addr) {
69  case APU_UART0_BASE:
71  break;
72  case APU_UART1_BASE:
74  break;
75  default:
76  printk(BIOS_ERR, "%s: Unknown device: %s\n", __func__, dev_path(dev));
77  return;
78  }
79 
80  if (dev->enabled) {
83  } else {
85  }
86 }
87 
88 static void uart_read_resources(struct device *dev)
89 {
90  mmio_resource(dev, 0, dev->path.mmio.addr / KiB, 4);
91 }
92 
95  .set_resources = noop_set_resources,
96  .scan_bus = scan_static_bus,
97  .enable = uart_enable,
98  .acpi_name = uart_acpi_name,
99  .acpi_fill_ssdt = uart_inject_ssdt,
100 };
#define APU_UART0_BASE
Definition: iomap.h:19
#define APU_UART1_BASE
Definition: iomap.h:20
static void write16(void *addr, uint16_t val)
Definition: mmio.h:35
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define KiB
Definition: helpers.h:75
void wait_for_aoac_enabled(unsigned int dev)
Definition: aoac.c:35
#define FCH_AOAC_DEV_UART1
Definition: aoac_defs.h:15
#define FCH_AOAC_DEV_UART0
Definition: aoac_defs.h:14
#define FCH_LEGACY_UART_DECODE
Definition: southbridge.h:86
void power_off_aoac_device(unsigned int dev)
Definition: aoac.c:17
void power_on_aoac_device(unsigned int dev)
Definition: aoac.c:8
#define printk(level,...)
Definition: stdlib.h:16
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
#define PULL_NONE
Definition: buildOpts.c:72
static void noop_set_resources(struct device *dev)
Definition: device.h:74
#define mmio_resource(dev, idx, basek, sizek)
Definition: device.h:334
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
u16 dev_id
void scan_static_bus(struct device *bus)
Definition: root_device.c:89
#define GPIO_143
Definition: gpio.h:90
#define GPIO_141
Definition: gpio.h:88
#define GPIO_140
Definition: gpio.h:87
#define GPIO_142
Definition: gpio.h:89
uintptr_t get_uart_base(unsigned int idx)
Definition: uart.c:9
static void uart_enable(struct device *dev)
Definition: uart.c:64
struct device_operations cezanne_uart_mmio_ops
Definition: uart.c:93
static void uart_read_resources(struct device *dev)
Definition: uart.c:88
static const struct @397 uart_info[]
static const char * uart_acpi_name(const struct device *dev)
Definition: uart.c:51
void set_uart_config(unsigned int idx)
Definition: uart.c:43
uintptr_t base
Definition: uart.c:17
void clear_uart_legacy_config(void)
Definition: uart.c:38
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
program a particular set of GPIO
Definition: gpio.c:307
#define PAD_NF(pin, func, pull)
Definition: gpio_defs.h:208
void uart_inject_ssdt(const struct device *dev)
Definition: uart_acpi.c:8
#define NULL
Definition: stddef.h:19
unsigned long uintptr_t
Definition: stdint.h:21
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct mmio_path mmio
Definition: path.h:128
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int enabled
Definition: device.h:122
uintptr_t addr
Definition: path.h:106
Definition: pll_common.h:22