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> |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 12 | #include <intelblocks/lpss.h> |
| 13 | #include <intelblocks/uart.h> |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 14 | #include <soc/pci_devs.h> |
| 15 | #include <soc/iomap.h> |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 16 | #include <soc/irq.h> |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 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 | } |
| 130 | } |
| 131 | |
| 132 | /* |
| 133 | * Check if UART debug port controller needs to be initialized on resume. |
| 134 | * |
| 135 | * Returns: |
| 136 | * true = when SoC wants debug port initialization on resume |
| 137 | * false = otherwise |
| 138 | */ |
| 139 | static bool pch_uart_init_debug_controller_on_resume(void) |
| 140 | { |
Kyösti Mälkki | 0c1dd9c | 2020-06-17 23:37:49 +0300 | [diff] [blame] | 141 | struct global_nvs *gnvs = acpi_get_gnvs(); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 142 | |
| 143 | if (gnvs) |
| 144 | return !!gnvs->uior; |
| 145 | |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 146 | return false; |
| 147 | } |
| 148 | |
| 149 | bool uart_is_debug_controller(struct device *dev) |
| 150 | { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 151 | return dev == uart_get_device(); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /* |
| 155 | * This is a workaround to enable UART controller for the debug port if: |
| 156 | * 1. CONSOLE_SERIAL is not enabled in coreboot, and |
| 157 | * 2. This boot is S3 resume, and |
| 158 | * 3. SoC wants to initialize debug UART controller. |
| 159 | * |
| 160 | * This workaround is required because Linux kernel hangs on resume if console |
| 161 | * is not enabled in coreboot, but it is enabled in kernel and not suspended. |
| 162 | */ |
| 163 | static bool uart_controller_needs_init(struct device *dev) |
| 164 | { |
| 165 | /* |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 166 | * If coreboot has CONSOLE_SERIAL enabled, the skip re-initializing |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 167 | * controller here. |
| 168 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 169 | if (CONFIG(CONSOLE_SERIAL)) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 170 | return false; |
| 171 | |
| 172 | /* If this device does not correspond to debug port, then skip. */ |
| 173 | if (!uart_is_debug_controller(dev)) |
| 174 | return false; |
| 175 | |
| 176 | /* Initialize UART controller only on S3 resume. */ |
| 177 | if (!acpi_is_wakeup_s3()) |
| 178 | return false; |
| 179 | |
| 180 | /* |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 181 | * check if SOC wants to initialize UART on resume |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 182 | */ |
| 183 | return pch_uart_init_debug_controller_on_resume(); |
| 184 | } |
| 185 | |
| 186 | static void uart_common_enable_resources(struct device *dev) |
| 187 | { |
| 188 | pci_dev_enable_resources(dev); |
| 189 | |
| 190 | if (uart_controller_needs_init(dev)) { |
| 191 | uintptr_t base; |
| 192 | |
| 193 | base = pci_read_config32(dev, PCI_BASE_ADDRESS_0) & ~0xFFF; |
| 194 | if (base) |
Furquan Shaikh | 582a0e2 | 2021-01-07 00:16:35 -0800 | [diff] [blame] | 195 | uart_lpss_init(PCI_BDF(dev), base); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 199 | static void uart_acpi_write_irq(const struct device *dev) |
| 200 | { |
| 201 | struct acpi_irq irq; |
| 202 | |
| 203 | switch (dev->path.pci.devfn) { |
| 204 | case PCH_DEVFN_UART0: |
| 205 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART0_IRQ); |
| 206 | break; |
| 207 | case PCH_DEVFN_UART1: |
| 208 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART1_IRQ); |
| 209 | break; |
| 210 | case PCH_DEVFN_UART2: |
| 211 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART2_IRQ); |
| 212 | break; |
| 213 | default: |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | acpi_device_write_interrupt(&irq); |
| 218 | } |
| 219 | |
| 220 | /* |
| 221 | * Generate an ACPI entry if the device is enabled in devicetree for the ACPI |
| 222 | * LPSS driver. In this mode the device and vendor ID reads as 0xffff, but the |
| 223 | * PCI device is still there. |
| 224 | */ |
| 225 | static void uart_fill_ssdt(const struct device *dev) |
| 226 | { |
| 227 | const char *scope = acpi_device_scope(dev); |
| 228 | const char *hid = acpi_device_hid(dev); |
| 229 | struct resource *res; |
| 230 | |
| 231 | /* In ACPI mode the device is "invisible" */ |
| 232 | if (!dev->hidden) |
| 233 | return; |
| 234 | |
| 235 | if (!scope || !hid) |
| 236 | return; |
| 237 | |
| 238 | res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
| 239 | if (!res) |
| 240 | return; |
| 241 | |
| 242 | /* Scope */ |
| 243 | acpigen_write_scope(scope); |
| 244 | |
| 245 | /* Device */ |
| 246 | acpigen_write_device(acpi_device_name(dev)); |
| 247 | acpigen_write_name_string("_HID", hid); |
| 248 | /* |
| 249 | * Advertise compatibility to Sunrise Point, as the Linux kernel doesn't support |
| 250 | * CannonPoint yet... |
| 251 | */ |
| 252 | if (strcmp(hid, "INT34B8") == 0) |
| 253 | acpigen_write_name_string("_CID", "INT3448"); |
| 254 | else if (strcmp(hid, "INT34B9") == 0) |
| 255 | acpigen_write_name_string("_CID", "INT3449"); |
| 256 | else if (strcmp(hid, "INT34BA") == 0) |
| 257 | acpigen_write_name_string("_CID", "INT344A"); |
| 258 | |
| 259 | acpi_device_write_uid(dev); |
| 260 | acpigen_write_name_string("_DDN", "LPSS ACPI UART"); |
| 261 | acpigen_write_STA(acpi_device_status(dev)); |
| 262 | |
| 263 | /* Resources */ |
| 264 | acpigen_write_name("_CRS"); |
| 265 | acpigen_write_resourcetemplate_header(); |
| 266 | |
| 267 | uart_acpi_write_irq(dev); |
| 268 | acpigen_write_mem32fixed(1, res->base, res->size); |
| 269 | |
| 270 | acpigen_write_resourcetemplate_footer(); |
| 271 | |
| 272 | acpigen_pop_len(); /* Device */ |
| 273 | acpigen_pop_len(); /* Scope */ |
| 274 | } |
| 275 | |
| 276 | static const char *uart_acpi_hid(const struct device *dev) |
| 277 | { |
| 278 | switch (dev->device) { |
| 279 | case PCI_DEVICE_ID_INTEL_APL_UART0: |
| 280 | return "80865abc"; |
| 281 | case PCI_DEVICE_ID_INTEL_APL_UART1: |
| 282 | return "80865abe"; |
| 283 | case PCI_DEVICE_ID_INTEL_APL_UART2: |
| 284 | return "80865ac0"; |
| 285 | case PCI_DEVICE_ID_INTEL_GLK_UART0: |
| 286 | return "808631bc"; |
| 287 | case PCI_DEVICE_ID_INTEL_GLK_UART1: |
| 288 | return "808631be"; |
| 289 | case PCI_DEVICE_ID_INTEL_GLK_UART2: |
| 290 | return "808631c0"; |
| 291 | case PCI_DEVICE_ID_INTEL_GLK_UART3: |
| 292 | return "808631ee"; |
| 293 | case PCI_DEVICE_ID_INTEL_SPT_UART0: |
| 294 | case PCI_DEVICE_ID_INTEL_SPT_H_UART0: |
| 295 | return "INT3448"; |
| 296 | case PCI_DEVICE_ID_INTEL_SPT_UART1: |
| 297 | case PCI_DEVICE_ID_INTEL_SPT_H_UART1: |
| 298 | return "INT3449"; |
| 299 | case PCI_DEVICE_ID_INTEL_SPT_UART2: |
| 300 | case PCI_DEVICE_ID_INTEL_SPT_H_UART2: |
| 301 | return "INT344A"; |
| 302 | case PCI_DEVICE_ID_INTEL_CNP_H_UART0: |
| 303 | return "INT34B8"; |
| 304 | case PCI_DEVICE_ID_INTEL_CNP_H_UART1: |
| 305 | return "INT34B9"; |
| 306 | case PCI_DEVICE_ID_INTEL_CNP_H_UART2: |
| 307 | return "INT34BA"; |
| 308 | default: |
| 309 | return NULL; |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | static const char *uart_acpi_name(const struct device *dev) |
| 314 | { |
| 315 | switch (dev->device) { |
| 316 | case PCI_DEVICE_ID_INTEL_APL_UART0: |
| 317 | case PCI_DEVICE_ID_INTEL_GLK_UART0: |
| 318 | case PCI_DEVICE_ID_INTEL_SPT_UART0: |
| 319 | case PCI_DEVICE_ID_INTEL_SPT_H_UART0: |
| 320 | case PCI_DEVICE_ID_INTEL_CNP_H_UART0: |
| 321 | return "UAR0"; |
| 322 | case PCI_DEVICE_ID_INTEL_APL_UART1: |
| 323 | case PCI_DEVICE_ID_INTEL_GLK_UART1: |
| 324 | case PCI_DEVICE_ID_INTEL_SPT_UART1: |
| 325 | case PCI_DEVICE_ID_INTEL_SPT_H_UART1: |
| 326 | case PCI_DEVICE_ID_INTEL_CNP_H_UART1: |
| 327 | return "UAR1"; |
| 328 | case PCI_DEVICE_ID_INTEL_APL_UART2: |
| 329 | case PCI_DEVICE_ID_INTEL_GLK_UART2: |
| 330 | case PCI_DEVICE_ID_INTEL_SPT_UART2: |
| 331 | case PCI_DEVICE_ID_INTEL_SPT_H_UART2: |
| 332 | case PCI_DEVICE_ID_INTEL_CNP_H_UART2: |
| 333 | return "UAR2"; |
| 334 | case PCI_DEVICE_ID_INTEL_GLK_UART3: |
| 335 | return "UAR3"; |
| 336 | default: |
| 337 | return NULL; |
| 338 | } |
| 339 | } |
| 340 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 341 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 342 | .read_resources = uart_read_resources, |
| 343 | .set_resources = pci_dev_set_resources, |
| 344 | .enable_resources = uart_common_enable_resources, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 345 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 346 | .acpi_fill_ssdt = uart_fill_ssdt, |
| 347 | .acpi_hid = uart_acpi_hid, |
| 348 | .acpi_name = uart_acpi_name, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 349 | }; |
| 350 | |
| 351 | static const unsigned short pci_device_ids[] = { |
| 352 | PCI_DEVICE_ID_INTEL_SPT_UART0, |
| 353 | PCI_DEVICE_ID_INTEL_SPT_UART1, |
| 354 | PCI_DEVICE_ID_INTEL_SPT_UART2, |
V Sowmya | 7c15047 | 2018-01-23 14:44:45 +0530 | [diff] [blame] | 355 | PCI_DEVICE_ID_INTEL_SPT_H_UART0, |
| 356 | PCI_DEVICE_ID_INTEL_SPT_H_UART1, |
| 357 | PCI_DEVICE_ID_INTEL_SPT_H_UART2, |
Angel Pons | f530e36 | 2021-04-27 10:20:04 +0200 | [diff] [blame^] | 358 | PCI_DEVICE_ID_INTEL_UPT_H_UART0, |
| 359 | PCI_DEVICE_ID_INTEL_UPT_H_UART1, |
| 360 | PCI_DEVICE_ID_INTEL_UPT_H_UART2, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 361 | PCI_DEVICE_ID_INTEL_APL_UART0, |
| 362 | PCI_DEVICE_ID_INTEL_APL_UART1, |
| 363 | PCI_DEVICE_ID_INTEL_APL_UART2, |
| 364 | PCI_DEVICE_ID_INTEL_APL_UART3, |
Lijian Zhao | bbedef9 | 2017-07-29 16:38:38 -0700 | [diff] [blame] | 365 | PCI_DEVICE_ID_INTEL_CNL_UART0, |
| 366 | PCI_DEVICE_ID_INTEL_CNL_UART1, |
| 367 | PCI_DEVICE_ID_INTEL_CNL_UART2, |
Hannah Williams | f714965 | 2017-05-13 16:18:02 -0700 | [diff] [blame] | 368 | PCI_DEVICE_ID_INTEL_GLK_UART0, |
| 369 | PCI_DEVICE_ID_INTEL_GLK_UART1, |
| 370 | PCI_DEVICE_ID_INTEL_GLK_UART2, |
| 371 | PCI_DEVICE_ID_INTEL_GLK_UART3, |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 372 | PCI_DEVICE_ID_INTEL_CNP_H_UART0, |
| 373 | PCI_DEVICE_ID_INTEL_CNP_H_UART1, |
| 374 | PCI_DEVICE_ID_INTEL_CNP_H_UART2, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 375 | PCI_DEVICE_ID_INTEL_ICP_UART0, |
| 376 | PCI_DEVICE_ID_INTEL_ICP_UART1, |
| 377 | PCI_DEVICE_ID_INTEL_ICP_UART2, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 378 | PCI_DEVICE_ID_INTEL_CMP_UART0, |
| 379 | PCI_DEVICE_ID_INTEL_CMP_UART1, |
| 380 | PCI_DEVICE_ID_INTEL_CMP_UART2, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 381 | PCI_DEVICE_ID_INTEL_CMP_H_UART0, |
| 382 | PCI_DEVICE_ID_INTEL_CMP_H_UART1, |
| 383 | PCI_DEVICE_ID_INTEL_CMP_H_UART2, |
Ravi Sarawadi | 6b5bf40 | 2019-10-21 22:25:04 -0700 | [diff] [blame] | 384 | PCI_DEVICE_ID_INTEL_TGP_UART0, |
| 385 | PCI_DEVICE_ID_INTEL_TGP_UART1, |
| 386 | PCI_DEVICE_ID_INTEL_TGP_UART2, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 387 | PCI_DEVICE_ID_INTEL_MCC_UART0, |
| 388 | PCI_DEVICE_ID_INTEL_MCC_UART1, |
| 389 | PCI_DEVICE_ID_INTEL_MCC_UART2, |
Meera Ravindranath | 3f4af0d | 2020-02-12 16:01:22 +0530 | [diff] [blame] | 390 | PCI_DEVICE_ID_INTEL_JSP_UART0, |
| 391 | PCI_DEVICE_ID_INTEL_JSP_UART1, |
| 392 | PCI_DEVICE_ID_INTEL_JSP_UART2, |
Subrata Banik | f672f7f | 2020-08-03 14:29:25 +0530 | [diff] [blame] | 393 | PCI_DEVICE_ID_INTEL_ADP_S_UART0, |
| 394 | PCI_DEVICE_ID_INTEL_ADP_S_UART1, |
| 395 | PCI_DEVICE_ID_INTEL_ADP_S_UART2, |
| 396 | PCI_DEVICE_ID_INTEL_ADP_S_UART3, |
| 397 | PCI_DEVICE_ID_INTEL_ADP_S_UART4, |
| 398 | PCI_DEVICE_ID_INTEL_ADP_S_UART5, |
| 399 | PCI_DEVICE_ID_INTEL_ADP_S_UART6, |
| 400 | PCI_DEVICE_ID_INTEL_ADP_P_UART0, |
| 401 | PCI_DEVICE_ID_INTEL_ADP_P_UART1, |
| 402 | PCI_DEVICE_ID_INTEL_ADP_P_UART2, |
| 403 | PCI_DEVICE_ID_INTEL_ADP_P_UART3, |
| 404 | PCI_DEVICE_ID_INTEL_ADP_P_UART4, |
| 405 | PCI_DEVICE_ID_INTEL_ADP_P_UART5, |
| 406 | PCI_DEVICE_ID_INTEL_ADP_P_UART6, |
Varshit Pandya | f4d98fdd2 | 2021-01-17 18:39:29 +0530 | [diff] [blame] | 407 | PCI_DEVICE_ID_INTEL_ADP_M_UART0, |
| 408 | PCI_DEVICE_ID_INTEL_ADP_M_UART1, |
| 409 | PCI_DEVICE_ID_INTEL_ADP_M_UART2, |
| 410 | PCI_DEVICE_ID_INTEL_ADP_M_UART3, |
Hannah Williams | f714965 | 2017-05-13 16:18:02 -0700 | [diff] [blame] | 411 | 0, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 412 | }; |
| 413 | |
| 414 | static const struct pci_driver pch_uart __pci_driver = { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 415 | .ops = &device_ops, |
| 416 | .vendor = PCI_VENDOR_ID_INTEL, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 417 | .devices = pci_device_ids, |
| 418 | }; |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 419 | |
| 420 | static void uart_enable(struct device *dev) |
| 421 | { |
| 422 | struct soc_intel_common_block_uart_config *conf = dev->chip_info; |
| 423 | dev->ops = &device_ops; |
| 424 | dev->device = conf ? conf->devid : 0; |
| 425 | } |
| 426 | |
| 427 | struct chip_operations soc_intel_common_block_uart_ops = { |
| 428 | CHIP_NAME("LPSS UART in ACPI mode") |
| 429 | .enable_dev = uart_enable |
| 430 | }; |
| 431 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 432 | #endif /* ENV_RAMSTAGE */ |