Angel Pons | 0612b27 | 2020-04-05 15:46:56 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 4 | #include <acpi/acpigen.h> |
Kyösti Mälkki | 5daa1d3 | 2020-06-14 12:01:58 +0300 | [diff] [blame] | 5 | #include <acpi/acpi_gnvs.h> |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 6 | #include <console/uart.h> |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 7 | #include <device/device.h> |
| 8 | #include <device/pci.h> |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 9 | #include <device/pci_def.h> |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 10 | #include <device/pci_ids.h> |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 11 | #include <device/pci_ops.h> |
Tim Wawrzynczak | f9bb1b4 | 2021-06-25 13:02:16 -0600 | [diff] [blame] | 12 | #include <intelblocks/irq.h> |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 13 | #include <intelblocks/lpss.h> |
| 14 | #include <intelblocks/uart.h> |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 15 | #include <soc/pci_devs.h> |
| 16 | #include <soc/iomap.h> |
| 17 | #include <soc/nvs.h> |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 18 | #include "chip.h" |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 19 | |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 20 | #define UART_PCI_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER) |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 21 | |
Michael Niewöhner | 405f229 | 2020-12-21 03:46:58 +0100 | [diff] [blame] | 22 | extern const unsigned int uart_devices[]; |
| 23 | extern const int uart_devices_size; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 24 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 25 | static void uart_lpss_init(pci_devfn_t dev, uintptr_t baseaddr) |
Furquan Shaikh | 3406dd6 | 2017-08-04 15:58:26 -0700 | [diff] [blame] | 26 | { |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 27 | /* Ensure controller is in D0 state */ |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 28 | lpss_set_power_state(dev, STATE_D0); |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 29 | |
Furquan Shaikh | 3406dd6 | 2017-08-04 15:58:26 -0700 | [diff] [blame] | 30 | /* Take UART out of reset */ |
| 31 | lpss_reset_release(baseaddr); |
| 32 | |
| 33 | /* Set M and N divisor inputs and enable clock */ |
| 34 | lpss_clk_update(baseaddr, CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_M_VAL, |
| 35 | CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_N_VAL); |
| 36 | } |
| 37 | |
Nico Huber | 62ddc49 | 2019-05-29 18:39:31 +0200 | [diff] [blame] | 38 | #if CONFIG(INTEL_LPSS_UART_FOR_CONSOLE) |
Felix Held | e3a1247 | 2020-09-11 15:47:09 +0200 | [diff] [blame] | 39 | uintptr_t uart_platform_base(unsigned int idx) |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 40 | { |
Nico Huber | ce8eebd | 2019-05-29 18:33:35 +0200 | [diff] [blame] | 41 | if (idx == CONFIG_UART_FOR_CONSOLE) |
Nico Huber | 9995418 | 2019-05-29 23:33:06 +0200 | [diff] [blame] | 42 | return CONFIG_CONSOLE_UART_BASE_ADDRESS; |
Nico Huber | ce8eebd | 2019-05-29 18:33:35 +0200 | [diff] [blame] | 43 | return 0; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 44 | } |
| 45 | #endif |
| 46 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 47 | static pci_devfn_t uart_console_get_pci_bdf(void) |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 48 | { |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 49 | int devfn; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 50 | |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 51 | /* |
Nico Huber | a96e66a | 2018-11-11 02:51:14 +0100 | [diff] [blame] | 52 | * This function will get called even if INTEL_LPSS_UART_FOR_CONSOLE |
| 53 | * config option is not selected. |
| 54 | * By default return NULL in this case to avoid compilation errors. |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 55 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 56 | if (!CONFIG(INTEL_LPSS_UART_FOR_CONSOLE)) |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 57 | return PCI_DEV_INVALID; |
| 58 | |
Michael Niewöhner | 405f229 | 2020-12-21 03:46:58 +0100 | [diff] [blame] | 59 | if (CONFIG_UART_FOR_CONSOLE > uart_devices_size) |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 60 | return PCI_DEV_INVALID; |
| 61 | |
Michael Niewöhner | 405f229 | 2020-12-21 03:46:58 +0100 | [diff] [blame] | 62 | devfn = uart_devices[CONFIG_UART_FOR_CONSOLE]; |
| 63 | if (devfn == PCI_DEVFN_INVALID) |
| 64 | return PCI_DEV_INVALID; |
| 65 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 66 | return PCI_DEV(0, PCI_SLOT(devfn), PCI_FUNC(devfn)); |
| 67 | } |
| 68 | |
| 69 | const struct device *uart_get_device(void) |
| 70 | { |
| 71 | pci_devfn_t dev = uart_console_get_pci_bdf(); |
| 72 | if (dev == PCI_DEV_INVALID) |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 73 | return NULL; |
| 74 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 75 | return pcidev_path_on_root(PCI_DEV2DEVFN(dev)); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 78 | bool uart_is_controller_initialized(void) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 79 | { |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 80 | uintptr_t base; |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 81 | pci_devfn_t dev = uart_console_get_pci_bdf(); |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 82 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 83 | if (dev == PCI_DEV_INVALID) |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 84 | return false; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 85 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 86 | base = pci_s_read_config32(dev, PCI_BASE_ADDRESS_0) & ~0xFFF; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 87 | if (!base) |
| 88 | return false; |
| 89 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 90 | if ((pci_s_read_config16(dev, PCI_COMMAND) & UART_PCI_ENABLE) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 91 | != UART_PCI_ENABLE) |
| 92 | return false; |
| 93 | |
| 94 | return !lpss_is_controller_in_reset(base); |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 95 | } |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 96 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 97 | void uart_bootblock_init(void) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 98 | { |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 99 | const uint32_t baseaddr = CONFIG_CONSOLE_UART_BASE_ADDRESS; |
| 100 | pci_devfn_t dev = uart_console_get_pci_bdf(); |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 101 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 102 | if (dev == PCI_DEV_INVALID) |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 103 | return; |
| 104 | |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 105 | /* Set UART base address */ |
| 106 | pci_s_write_config32(dev, PCI_BASE_ADDRESS_0, baseaddr); |
| 107 | |
| 108 | /* Enable memory access and bus master */ |
| 109 | pci_s_write_config16(dev, PCI_COMMAND, UART_PCI_ENABLE); |
| 110 | |
| 111 | uart_lpss_init(dev, baseaddr); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | #if ENV_RAMSTAGE |
| 115 | |
| 116 | static void uart_read_resources(struct device *dev) |
| 117 | { |
| 118 | pci_dev_read_resources(dev); |
| 119 | |
| 120 | /* Set the configured UART base address for the debug port */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 121 | if (CONFIG(INTEL_LPSS_UART_FOR_CONSOLE) && |
Nico Huber | a96e66a | 2018-11-11 02:51:14 +0100 | [diff] [blame] | 122 | uart_is_debug_controller(dev)) { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 123 | struct resource *res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 124 | /* Need to set the base and size for the resource allocator. */ |
Nico Huber | 9995418 | 2019-05-29 23:33:06 +0200 | [diff] [blame] | 125 | res->base = CONFIG_CONSOLE_UART_BASE_ADDRESS; |
| 126 | res->size = 0x1000; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 127 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 128 | IORESOURCE_FIXED; |
| 129 | } |
Patrick Rudolph | e42ce6b | 2021-06-07 16:46:40 +0200 | [diff] [blame] | 130 | /* In ACPI mode mark the decoded region as reserved */ |
| 131 | if (dev->hidden) { |
| 132 | struct resource *res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 133 | res->flags |= IORESOURCE_RESERVE; |
| 134 | } |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /* |
| 138 | * Check if UART debug port controller needs to be initialized on resume. |
| 139 | * |
| 140 | * Returns: |
| 141 | * true = when SoC wants debug port initialization on resume |
| 142 | * false = otherwise |
| 143 | */ |
| 144 | static bool pch_uart_init_debug_controller_on_resume(void) |
| 145 | { |
Kyösti Mälkki | 0c1dd9c | 2020-06-17 23:37:49 +0300 | [diff] [blame] | 146 | struct global_nvs *gnvs = acpi_get_gnvs(); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 147 | |
| 148 | if (gnvs) |
| 149 | return !!gnvs->uior; |
| 150 | |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | |
| 154 | bool uart_is_debug_controller(struct device *dev) |
| 155 | { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 156 | return dev == uart_get_device(); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /* |
| 160 | * This is a workaround to enable UART controller for the debug port if: |
| 161 | * 1. CONSOLE_SERIAL is not enabled in coreboot, and |
| 162 | * 2. This boot is S3 resume, and |
| 163 | * 3. SoC wants to initialize debug UART controller. |
| 164 | * |
| 165 | * This workaround is required because Linux kernel hangs on resume if console |
| 166 | * is not enabled in coreboot, but it is enabled in kernel and not suspended. |
| 167 | */ |
| 168 | static bool uart_controller_needs_init(struct device *dev) |
| 169 | { |
| 170 | /* |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 171 | * If coreboot has CONSOLE_SERIAL enabled, the skip re-initializing |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 172 | * controller here. |
| 173 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 174 | if (CONFIG(CONSOLE_SERIAL)) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 175 | return false; |
| 176 | |
| 177 | /* If this device does not correspond to debug port, then skip. */ |
| 178 | if (!uart_is_debug_controller(dev)) |
| 179 | return false; |
| 180 | |
| 181 | /* Initialize UART controller only on S3 resume. */ |
| 182 | if (!acpi_is_wakeup_s3()) |
| 183 | return false; |
| 184 | |
| 185 | /* |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 186 | * check if SOC wants to initialize UART on resume |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 187 | */ |
| 188 | return pch_uart_init_debug_controller_on_resume(); |
| 189 | } |
| 190 | |
| 191 | static void uart_common_enable_resources(struct device *dev) |
| 192 | { |
| 193 | pci_dev_enable_resources(dev); |
| 194 | |
| 195 | if (uart_controller_needs_init(dev)) { |
| 196 | uintptr_t base; |
| 197 | |
| 198 | base = pci_read_config32(dev, PCI_BASE_ADDRESS_0) & ~0xFFF; |
| 199 | if (base) |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 200 | uart_lpss_init(PCI_BDF(dev), base); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 204 | static void uart_acpi_write_irq(const struct device *dev) |
| 205 | { |
Tim Wawrzynczak | f9bb1b4 | 2021-06-25 13:02:16 -0600 | [diff] [blame] | 206 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_IRQ)) { |
| 207 | const int irq = get_pci_devfn_irq(dev->path.pci.devfn); |
| 208 | if (irq != INVALID_IRQ) { |
| 209 | struct acpi_irq airq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(irq); |
| 210 | acpi_device_write_interrupt(&airq); |
| 211 | } |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 212 | } |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /* |
| 216 | * Generate an ACPI entry if the device is enabled in devicetree for the ACPI |
| 217 | * LPSS driver. In this mode the device and vendor ID reads as 0xffff, but the |
| 218 | * PCI device is still there. |
| 219 | */ |
| 220 | static void uart_fill_ssdt(const struct device *dev) |
| 221 | { |
| 222 | const char *scope = acpi_device_scope(dev); |
| 223 | const char *hid = acpi_device_hid(dev); |
| 224 | struct resource *res; |
| 225 | |
| 226 | /* In ACPI mode the device is "invisible" */ |
| 227 | if (!dev->hidden) |
| 228 | return; |
| 229 | |
| 230 | if (!scope || !hid) |
| 231 | return; |
| 232 | |
| 233 | res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
| 234 | if (!res) |
| 235 | return; |
| 236 | |
| 237 | /* Scope */ |
| 238 | acpigen_write_scope(scope); |
| 239 | |
| 240 | /* Device */ |
| 241 | acpigen_write_device(acpi_device_name(dev)); |
| 242 | acpigen_write_name_string("_HID", hid); |
| 243 | /* |
| 244 | * Advertise compatibility to Sunrise Point, as the Linux kernel doesn't support |
| 245 | * CannonPoint yet... |
| 246 | */ |
| 247 | if (strcmp(hid, "INT34B8") == 0) |
| 248 | acpigen_write_name_string("_CID", "INT3448"); |
| 249 | else if (strcmp(hid, "INT34B9") == 0) |
| 250 | acpigen_write_name_string("_CID", "INT3449"); |
| 251 | else if (strcmp(hid, "INT34BA") == 0) |
| 252 | acpigen_write_name_string("_CID", "INT344A"); |
| 253 | |
| 254 | acpi_device_write_uid(dev); |
| 255 | acpigen_write_name_string("_DDN", "LPSS ACPI UART"); |
| 256 | acpigen_write_STA(acpi_device_status(dev)); |
| 257 | |
| 258 | /* Resources */ |
| 259 | acpigen_write_name("_CRS"); |
| 260 | acpigen_write_resourcetemplate_header(); |
| 261 | |
| 262 | uart_acpi_write_irq(dev); |
| 263 | acpigen_write_mem32fixed(1, res->base, res->size); |
| 264 | |
| 265 | acpigen_write_resourcetemplate_footer(); |
| 266 | |
| 267 | acpigen_pop_len(); /* Device */ |
| 268 | acpigen_pop_len(); /* Scope */ |
| 269 | } |
| 270 | |
| 271 | static const char *uart_acpi_hid(const struct device *dev) |
| 272 | { |
| 273 | switch (dev->device) { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 274 | case PCI_DID_INTEL_APL_UART0: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 275 | return "80865abc"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 276 | case PCI_DID_INTEL_APL_UART1: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 277 | return "80865abe"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 278 | case PCI_DID_INTEL_APL_UART2: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 279 | return "80865ac0"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 280 | case PCI_DID_INTEL_GLK_UART0: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 281 | return "808631bc"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 282 | case PCI_DID_INTEL_GLK_UART1: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 283 | return "808631be"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 284 | case PCI_DID_INTEL_GLK_UART2: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 285 | return "808631c0"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 286 | case PCI_DID_INTEL_GLK_UART3: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 287 | return "808631ee"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 288 | case PCI_DID_INTEL_SPT_UART0: |
| 289 | case PCI_DID_INTEL_SPT_H_UART0: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 290 | return "INT3448"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 291 | case PCI_DID_INTEL_SPT_UART1: |
| 292 | case PCI_DID_INTEL_SPT_H_UART1: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 293 | return "INT3449"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 294 | case PCI_DID_INTEL_SPT_UART2: |
| 295 | case PCI_DID_INTEL_SPT_H_UART2: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 296 | return "INT344A"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 297 | case PCI_DID_INTEL_CNP_H_UART0: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 298 | return "INT34B8"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 299 | case PCI_DID_INTEL_CNP_H_UART1: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 300 | return "INT34B9"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 301 | case PCI_DID_INTEL_CNP_H_UART2: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 302 | return "INT34BA"; |
| 303 | default: |
| 304 | return NULL; |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | static const char *uart_acpi_name(const struct device *dev) |
| 309 | { |
| 310 | switch (dev->device) { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 311 | case PCI_DID_INTEL_APL_UART0: |
| 312 | case PCI_DID_INTEL_GLK_UART0: |
| 313 | case PCI_DID_INTEL_SPT_UART0: |
| 314 | case PCI_DID_INTEL_SPT_H_UART0: |
| 315 | case PCI_DID_INTEL_CNP_H_UART0: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 316 | return "UAR0"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 317 | case PCI_DID_INTEL_APL_UART1: |
| 318 | case PCI_DID_INTEL_GLK_UART1: |
| 319 | case PCI_DID_INTEL_SPT_UART1: |
| 320 | case PCI_DID_INTEL_SPT_H_UART1: |
| 321 | case PCI_DID_INTEL_CNP_H_UART1: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 322 | return "UAR1"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 323 | case PCI_DID_INTEL_APL_UART2: |
| 324 | case PCI_DID_INTEL_GLK_UART2: |
| 325 | case PCI_DID_INTEL_SPT_UART2: |
| 326 | case PCI_DID_INTEL_SPT_H_UART2: |
| 327 | case PCI_DID_INTEL_CNP_H_UART2: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 328 | return "UAR2"; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 329 | case PCI_DID_INTEL_GLK_UART3: |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 330 | return "UAR3"; |
| 331 | default: |
| 332 | return NULL; |
| 333 | } |
| 334 | } |
| 335 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 336 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 337 | .read_resources = uart_read_resources, |
| 338 | .set_resources = pci_dev_set_resources, |
| 339 | .enable_resources = uart_common_enable_resources, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 340 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 341 | .acpi_fill_ssdt = uart_fill_ssdt, |
| 342 | .acpi_hid = uart_acpi_hid, |
| 343 | .acpi_name = uart_acpi_name, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | static const unsigned short pci_device_ids[] = { |
Wonkyu Kim | 9f40107 | 2020-11-13 15:16:32 -0800 | [diff] [blame] | 347 | PCI_DID_INTEL_MTL_UART0, |
| 348 | PCI_DID_INTEL_MTL_UART1, |
| 349 | PCI_DID_INTEL_MTL_UART2, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 350 | PCI_DID_INTEL_SPT_UART0, |
| 351 | PCI_DID_INTEL_SPT_UART1, |
| 352 | PCI_DID_INTEL_SPT_UART2, |
| 353 | PCI_DID_INTEL_SPT_H_UART0, |
| 354 | PCI_DID_INTEL_SPT_H_UART1, |
| 355 | PCI_DID_INTEL_SPT_H_UART2, |
| 356 | PCI_DID_INTEL_UPT_H_UART0, |
| 357 | PCI_DID_INTEL_UPT_H_UART1, |
| 358 | PCI_DID_INTEL_UPT_H_UART2, |
| 359 | PCI_DID_INTEL_APL_UART0, |
| 360 | PCI_DID_INTEL_APL_UART1, |
| 361 | PCI_DID_INTEL_APL_UART2, |
| 362 | PCI_DID_INTEL_APL_UART3, |
| 363 | PCI_DID_INTEL_CNL_UART0, |
| 364 | PCI_DID_INTEL_CNL_UART1, |
| 365 | PCI_DID_INTEL_CNL_UART2, |
| 366 | PCI_DID_INTEL_GLK_UART0, |
| 367 | PCI_DID_INTEL_GLK_UART1, |
| 368 | PCI_DID_INTEL_GLK_UART2, |
| 369 | PCI_DID_INTEL_GLK_UART3, |
| 370 | PCI_DID_INTEL_CNP_H_UART0, |
| 371 | PCI_DID_INTEL_CNP_H_UART1, |
| 372 | PCI_DID_INTEL_CNP_H_UART2, |
| 373 | PCI_DID_INTEL_ICP_UART0, |
| 374 | PCI_DID_INTEL_ICP_UART1, |
| 375 | PCI_DID_INTEL_ICP_UART2, |
| 376 | PCI_DID_INTEL_CMP_UART0, |
| 377 | PCI_DID_INTEL_CMP_UART1, |
| 378 | PCI_DID_INTEL_CMP_UART2, |
| 379 | PCI_DID_INTEL_CMP_H_UART0, |
| 380 | PCI_DID_INTEL_CMP_H_UART1, |
| 381 | PCI_DID_INTEL_CMP_H_UART2, |
| 382 | PCI_DID_INTEL_TGP_UART0, |
| 383 | PCI_DID_INTEL_TGP_UART1, |
| 384 | PCI_DID_INTEL_TGP_UART2, |
| 385 | PCI_DID_INTEL_TGP_H_UART0, |
| 386 | PCI_DID_INTEL_TGP_H_UART1, |
| 387 | PCI_DID_INTEL_TGP_H_UART2, |
| 388 | PCI_DID_INTEL_TGP_H_UART3, |
| 389 | PCI_DID_INTEL_MCC_UART0, |
| 390 | PCI_DID_INTEL_MCC_UART1, |
| 391 | PCI_DID_INTEL_MCC_UART2, |
| 392 | PCI_DID_INTEL_JSP_UART0, |
| 393 | PCI_DID_INTEL_JSP_UART1, |
| 394 | PCI_DID_INTEL_JSP_UART2, |
| 395 | PCI_DID_INTEL_ADP_S_UART0, |
| 396 | PCI_DID_INTEL_ADP_S_UART1, |
| 397 | PCI_DID_INTEL_ADP_S_UART2, |
| 398 | PCI_DID_INTEL_ADP_S_UART3, |
| 399 | PCI_DID_INTEL_ADP_S_UART4, |
| 400 | PCI_DID_INTEL_ADP_S_UART5, |
| 401 | PCI_DID_INTEL_ADP_S_UART6, |
| 402 | PCI_DID_INTEL_ADP_P_UART0, |
| 403 | PCI_DID_INTEL_ADP_P_UART1, |
| 404 | PCI_DID_INTEL_ADP_P_UART2, |
| 405 | PCI_DID_INTEL_ADP_P_UART3, |
| 406 | PCI_DID_INTEL_ADP_P_UART4, |
| 407 | PCI_DID_INTEL_ADP_P_UART5, |
| 408 | PCI_DID_INTEL_ADP_P_UART6, |
| 409 | PCI_DID_INTEL_ADP_M_N_UART0, |
| 410 | PCI_DID_INTEL_ADP_M_N_UART1, |
| 411 | PCI_DID_INTEL_ADP_M_N_UART2, |
| 412 | PCI_DID_INTEL_ADP_M_N_UART3, |
Hannah Williams | f714965 | 2017-05-13 16:18:02 -0700 | [diff] [blame] | 413 | 0, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 414 | }; |
| 415 | |
| 416 | static const struct pci_driver pch_uart __pci_driver = { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 417 | .ops = &device_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 418 | .vendor = PCI_VID_INTEL, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 419 | .devices = pci_device_ids, |
| 420 | }; |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 421 | |
| 422 | static void uart_enable(struct device *dev) |
| 423 | { |
| 424 | struct soc_intel_common_block_uart_config *conf = dev->chip_info; |
| 425 | dev->ops = &device_ops; |
| 426 | dev->device = conf ? conf->devid : 0; |
| 427 | } |
| 428 | |
| 429 | struct chip_operations soc_intel_common_block_uart_ops = { |
| 430 | CHIP_NAME("LPSS UART in ACPI mode") |
| 431 | .enable_dev = uart_enable |
| 432 | }; |
| 433 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 434 | #endif /* ENV_RAMSTAGE */ |