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 | #define UART_CONSOLE_INVALID_INDEX 0xFF |
| 22 | |
Furquan Shaikh | 4fa183f | 2021-01-06 20:30:35 -0800 | [diff] [blame^] | 23 | extern const struct uart_controller_config uart_ctrlr_config[]; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 24 | extern const int uart_max_index; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 25 | |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 26 | static void uart_lpss_init(const struct device *dev, uintptr_t baseaddr) |
Furquan Shaikh | 3406dd6 | 2017-08-04 15:58:26 -0700 | [diff] [blame] | 27 | { |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 28 | /* Ensure controller is in D0 state */ |
Furquan Shaikh | fb29ca0 | 2021-01-02 00:03:00 -0800 | [diff] [blame] | 29 | lpss_set_power_state(PCI_BDF(dev), STATE_D0); |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 30 | |
Furquan Shaikh | 3406dd6 | 2017-08-04 15:58:26 -0700 | [diff] [blame] | 31 | /* Take UART out of reset */ |
| 32 | lpss_reset_release(baseaddr); |
| 33 | |
| 34 | /* Set M and N divisor inputs and enable clock */ |
| 35 | lpss_clk_update(baseaddr, CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_M_VAL, |
| 36 | CONFIG_SOC_INTEL_COMMON_LPSS_UART_CLK_N_VAL); |
| 37 | } |
| 38 | |
Nico Huber | 62ddc49 | 2019-05-29 18:39:31 +0200 | [diff] [blame] | 39 | #if CONFIG(INTEL_LPSS_UART_FOR_CONSOLE) |
Felix Held | e3a1247 | 2020-09-11 15:47:09 +0200 | [diff] [blame] | 40 | uintptr_t uart_platform_base(unsigned int idx) |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 41 | { |
Nico Huber | ce8eebd | 2019-05-29 18:33:35 +0200 | [diff] [blame] | 42 | if (idx == CONFIG_UART_FOR_CONSOLE) |
Nico Huber | 9995418 | 2019-05-29 23:33:06 +0200 | [diff] [blame] | 43 | return CONFIG_CONSOLE_UART_BASE_ADDRESS; |
Nico Huber | ce8eebd | 2019-05-29 18:33:35 +0200 | [diff] [blame] | 44 | return 0; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 45 | } |
| 46 | #endif |
| 47 | |
| 48 | static int uart_get_valid_index(void) |
| 49 | { |
| 50 | int index; |
| 51 | |
| 52 | for (index = 0; index < uart_max_index; index++) { |
Furquan Shaikh | 4fa183f | 2021-01-06 20:30:35 -0800 | [diff] [blame^] | 53 | if (uart_ctrlr_config[index].console_index == |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 54 | CONFIG_UART_FOR_CONSOLE) |
| 55 | return index; |
| 56 | } |
| 57 | /* For valid index, code should not reach here */ |
| 58 | return UART_CONSOLE_INVALID_INDEX; |
| 59 | } |
| 60 | |
Furquan Shaikh | d3b7e2f | 2021-01-02 00:15:23 -0800 | [diff] [blame] | 61 | static void uart_common_init(const struct device *device, uintptr_t baseaddr) |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 62 | { |
| 63 | #if defined(__SIMPLE_DEVICE__) |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 64 | pci_devfn_t dev = PCI_BDF(device); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 65 | #else |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 66 | const struct device *dev = device; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 67 | #endif |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 68 | |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 69 | /* Set UART base address */ |
| 70 | pci_write_config32(dev, PCI_BASE_ADDRESS_0, baseaddr); |
| 71 | |
| 72 | /* Enable memory access and bus master */ |
Elyes HAOUAS | 2ec1c13 | 2020-04-29 09:57:05 +0200 | [diff] [blame] | 73 | pci_write_config16(dev, PCI_COMMAND, UART_PCI_ENABLE); |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 74 | |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 75 | uart_lpss_init(device, baseaddr); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 76 | } |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 77 | |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 78 | const struct device *uart_get_device(void) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 79 | { |
| 80 | /* |
Nico Huber | a96e66a | 2018-11-11 02:51:14 +0100 | [diff] [blame] | 81 | * This function will get called even if INTEL_LPSS_UART_FOR_CONSOLE |
| 82 | * config option is not selected. |
| 83 | * By default return NULL in this case to avoid compilation errors. |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 84 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 85 | if (!CONFIG(INTEL_LPSS_UART_FOR_CONSOLE)) |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 86 | return NULL; |
| 87 | |
| 88 | int console_index = uart_get_valid_index(); |
| 89 | |
| 90 | if (console_index != UART_CONSOLE_INVALID_INDEX) |
Furquan Shaikh | 4fa183f | 2021-01-06 20:30:35 -0800 | [diff] [blame^] | 91 | return pcidev_path_on_root(uart_ctrlr_config[console_index].devfn); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 92 | else |
| 93 | return NULL; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 96 | bool uart_is_controller_initialized(void) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 97 | { |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 98 | uintptr_t base; |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 99 | const struct device *dev_uart = uart_get_device(); |
| 100 | |
| 101 | if (!dev_uart) |
| 102 | return false; |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 103 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 104 | #if defined(__SIMPLE_DEVICE__) |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 105 | pci_devfn_t dev = PCI_BDF(dev_uart); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 106 | #else |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 107 | const struct device *dev = dev_uart; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 108 | #endif |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 109 | |
| 110 | base = pci_read_config32(dev, PCI_BASE_ADDRESS_0) & ~0xFFF; |
| 111 | if (!base) |
| 112 | return false; |
| 113 | |
Elyes HAOUAS | 2ec1c13 | 2020-04-29 09:57:05 +0200 | [diff] [blame] | 114 | if ((pci_read_config16(dev, PCI_COMMAND) & UART_PCI_ENABLE) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 115 | != UART_PCI_ENABLE) |
| 116 | return false; |
| 117 | |
| 118 | return !lpss_is_controller_in_reset(base); |
Aamir Bohra | 01d75f4 | 2017-03-30 20:12:21 +0530 | [diff] [blame] | 119 | } |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 120 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 121 | static void uart_configure_gpio_pads(void) |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 122 | { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 123 | int index = uart_get_valid_index(); |
| 124 | |
| 125 | if (index != UART_CONSOLE_INVALID_INDEX) |
Furquan Shaikh | 4fa183f | 2021-01-06 20:30:35 -0800 | [diff] [blame^] | 126 | gpio_configure_pads(uart_ctrlr_config[index].gpios, |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 127 | MAX_GPIO_PAD_PER_UART); |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 128 | } |
| 129 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 130 | void uart_bootblock_init(void) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 131 | { |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 132 | const struct device *dev_uart; |
| 133 | |
| 134 | dev_uart = uart_get_device(); |
| 135 | |
| 136 | if (!dev_uart) |
| 137 | return; |
| 138 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 139 | /* Program UART BAR0, command, reset and clock register */ |
Aamir Bohra | 17cfba6 | 2019-07-25 20:56:54 +0530 | [diff] [blame] | 140 | uart_common_init(dev_uart, CONFIG_CONSOLE_UART_BASE_ADDRESS); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 141 | |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 142 | /* Configure the 2 pads per UART. */ |
| 143 | uart_configure_gpio_pads(); |
| 144 | } |
| 145 | |
| 146 | #if ENV_RAMSTAGE |
| 147 | |
| 148 | static void uart_read_resources(struct device *dev) |
| 149 | { |
| 150 | pci_dev_read_resources(dev); |
| 151 | |
| 152 | /* Set the configured UART base address for the debug port */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 153 | if (CONFIG(INTEL_LPSS_UART_FOR_CONSOLE) && |
Nico Huber | a96e66a | 2018-11-11 02:51:14 +0100 | [diff] [blame] | 154 | uart_is_debug_controller(dev)) { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 155 | struct resource *res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 156 | /* Need to set the base and size for the resource allocator. */ |
Nico Huber | 9995418 | 2019-05-29 23:33:06 +0200 | [diff] [blame] | 157 | res->base = CONFIG_CONSOLE_UART_BASE_ADDRESS; |
| 158 | res->size = 0x1000; |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 159 | res->flags = IORESOURCE_MEM | IORESOURCE_ASSIGNED | |
| 160 | IORESOURCE_FIXED; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | /* |
| 165 | * Check if UART debug port controller needs to be initialized on resume. |
| 166 | * |
| 167 | * Returns: |
| 168 | * true = when SoC wants debug port initialization on resume |
| 169 | * false = otherwise |
| 170 | */ |
| 171 | static bool pch_uart_init_debug_controller_on_resume(void) |
| 172 | { |
Kyösti Mälkki | 0c1dd9c | 2020-06-17 23:37:49 +0300 | [diff] [blame] | 173 | struct global_nvs *gnvs = acpi_get_gnvs(); |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 174 | |
| 175 | if (gnvs) |
| 176 | return !!gnvs->uior; |
| 177 | |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 178 | return false; |
| 179 | } |
| 180 | |
| 181 | bool uart_is_debug_controller(struct device *dev) |
| 182 | { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 183 | return dev == uart_get_device(); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | /* |
| 187 | * This is a workaround to enable UART controller for the debug port if: |
| 188 | * 1. CONSOLE_SERIAL is not enabled in coreboot, and |
| 189 | * 2. This boot is S3 resume, and |
| 190 | * 3. SoC wants to initialize debug UART controller. |
| 191 | * |
| 192 | * This workaround is required because Linux kernel hangs on resume if console |
| 193 | * is not enabled in coreboot, but it is enabled in kernel and not suspended. |
| 194 | */ |
| 195 | static bool uart_controller_needs_init(struct device *dev) |
| 196 | { |
| 197 | /* |
Jonathan Neuschäfer | 5268b76 | 2018-02-12 12:24:25 +0100 | [diff] [blame] | 198 | * If coreboot has CONSOLE_SERIAL enabled, the skip re-initializing |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 199 | * controller here. |
| 200 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 201 | if (CONFIG(CONSOLE_SERIAL)) |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 202 | return false; |
| 203 | |
| 204 | /* If this device does not correspond to debug port, then skip. */ |
| 205 | if (!uart_is_debug_controller(dev)) |
| 206 | return false; |
| 207 | |
| 208 | /* Initialize UART controller only on S3 resume. */ |
| 209 | if (!acpi_is_wakeup_s3()) |
| 210 | return false; |
| 211 | |
| 212 | /* |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 213 | * check if SOC wants to initialize UART on resume |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 214 | */ |
| 215 | return pch_uart_init_debug_controller_on_resume(); |
| 216 | } |
| 217 | |
| 218 | static void uart_common_enable_resources(struct device *dev) |
| 219 | { |
| 220 | pci_dev_enable_resources(dev); |
| 221 | |
| 222 | if (uart_controller_needs_init(dev)) { |
| 223 | uintptr_t base; |
| 224 | |
| 225 | base = pci_read_config32(dev, PCI_BASE_ADDRESS_0) & ~0xFFF; |
| 226 | if (base) |
Usha P | 5e59a82 | 2019-08-09 18:42:00 +0530 | [diff] [blame] | 227 | uart_lpss_init(dev, base); |
Furquan Shaikh | a8198eb | 2017-08-04 16:12:19 -0700 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 231 | static void uart_acpi_write_irq(const struct device *dev) |
| 232 | { |
| 233 | struct acpi_irq irq; |
| 234 | |
| 235 | switch (dev->path.pci.devfn) { |
| 236 | case PCH_DEVFN_UART0: |
| 237 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART0_IRQ); |
| 238 | break; |
| 239 | case PCH_DEVFN_UART1: |
| 240 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART1_IRQ); |
| 241 | break; |
| 242 | case PCH_DEVFN_UART2: |
| 243 | irq = (struct acpi_irq)ACPI_IRQ_LEVEL_LOW(LPSS_UART2_IRQ); |
| 244 | break; |
| 245 | default: |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | acpi_device_write_interrupt(&irq); |
| 250 | } |
| 251 | |
| 252 | /* |
| 253 | * Generate an ACPI entry if the device is enabled in devicetree for the ACPI |
| 254 | * LPSS driver. In this mode the device and vendor ID reads as 0xffff, but the |
| 255 | * PCI device is still there. |
| 256 | */ |
| 257 | static void uart_fill_ssdt(const struct device *dev) |
| 258 | { |
| 259 | const char *scope = acpi_device_scope(dev); |
| 260 | const char *hid = acpi_device_hid(dev); |
| 261 | struct resource *res; |
| 262 | |
| 263 | /* In ACPI mode the device is "invisible" */ |
| 264 | if (!dev->hidden) |
| 265 | return; |
| 266 | |
| 267 | if (!scope || !hid) |
| 268 | return; |
| 269 | |
| 270 | res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
| 271 | if (!res) |
| 272 | return; |
| 273 | |
| 274 | /* Scope */ |
| 275 | acpigen_write_scope(scope); |
| 276 | |
| 277 | /* Device */ |
| 278 | acpigen_write_device(acpi_device_name(dev)); |
| 279 | acpigen_write_name_string("_HID", hid); |
| 280 | /* |
| 281 | * Advertise compatibility to Sunrise Point, as the Linux kernel doesn't support |
| 282 | * CannonPoint yet... |
| 283 | */ |
| 284 | if (strcmp(hid, "INT34B8") == 0) |
| 285 | acpigen_write_name_string("_CID", "INT3448"); |
| 286 | else if (strcmp(hid, "INT34B9") == 0) |
| 287 | acpigen_write_name_string("_CID", "INT3449"); |
| 288 | else if (strcmp(hid, "INT34BA") == 0) |
| 289 | acpigen_write_name_string("_CID", "INT344A"); |
| 290 | |
| 291 | acpi_device_write_uid(dev); |
| 292 | acpigen_write_name_string("_DDN", "LPSS ACPI UART"); |
| 293 | acpigen_write_STA(acpi_device_status(dev)); |
| 294 | |
| 295 | /* Resources */ |
| 296 | acpigen_write_name("_CRS"); |
| 297 | acpigen_write_resourcetemplate_header(); |
| 298 | |
| 299 | uart_acpi_write_irq(dev); |
| 300 | acpigen_write_mem32fixed(1, res->base, res->size); |
| 301 | |
| 302 | acpigen_write_resourcetemplate_footer(); |
| 303 | |
| 304 | acpigen_pop_len(); /* Device */ |
| 305 | acpigen_pop_len(); /* Scope */ |
| 306 | } |
| 307 | |
| 308 | static const char *uart_acpi_hid(const struct device *dev) |
| 309 | { |
| 310 | switch (dev->device) { |
| 311 | case PCI_DEVICE_ID_INTEL_APL_UART0: |
| 312 | return "80865abc"; |
| 313 | case PCI_DEVICE_ID_INTEL_APL_UART1: |
| 314 | return "80865abe"; |
| 315 | case PCI_DEVICE_ID_INTEL_APL_UART2: |
| 316 | return "80865ac0"; |
| 317 | case PCI_DEVICE_ID_INTEL_GLK_UART0: |
| 318 | return "808631bc"; |
| 319 | case PCI_DEVICE_ID_INTEL_GLK_UART1: |
| 320 | return "808631be"; |
| 321 | case PCI_DEVICE_ID_INTEL_GLK_UART2: |
| 322 | return "808631c0"; |
| 323 | case PCI_DEVICE_ID_INTEL_GLK_UART3: |
| 324 | return "808631ee"; |
| 325 | case PCI_DEVICE_ID_INTEL_SPT_UART0: |
| 326 | case PCI_DEVICE_ID_INTEL_SPT_H_UART0: |
| 327 | return "INT3448"; |
| 328 | case PCI_DEVICE_ID_INTEL_SPT_UART1: |
| 329 | case PCI_DEVICE_ID_INTEL_SPT_H_UART1: |
| 330 | return "INT3449"; |
| 331 | case PCI_DEVICE_ID_INTEL_SPT_UART2: |
| 332 | case PCI_DEVICE_ID_INTEL_SPT_H_UART2: |
| 333 | return "INT344A"; |
| 334 | case PCI_DEVICE_ID_INTEL_CNP_H_UART0: |
| 335 | return "INT34B8"; |
| 336 | case PCI_DEVICE_ID_INTEL_CNP_H_UART1: |
| 337 | return "INT34B9"; |
| 338 | case PCI_DEVICE_ID_INTEL_CNP_H_UART2: |
| 339 | return "INT34BA"; |
| 340 | default: |
| 341 | return NULL; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | static const char *uart_acpi_name(const struct device *dev) |
| 346 | { |
| 347 | switch (dev->device) { |
| 348 | case PCI_DEVICE_ID_INTEL_APL_UART0: |
| 349 | case PCI_DEVICE_ID_INTEL_GLK_UART0: |
| 350 | case PCI_DEVICE_ID_INTEL_SPT_UART0: |
| 351 | case PCI_DEVICE_ID_INTEL_SPT_H_UART0: |
| 352 | case PCI_DEVICE_ID_INTEL_CNP_H_UART0: |
| 353 | return "UAR0"; |
| 354 | case PCI_DEVICE_ID_INTEL_APL_UART1: |
| 355 | case PCI_DEVICE_ID_INTEL_GLK_UART1: |
| 356 | case PCI_DEVICE_ID_INTEL_SPT_UART1: |
| 357 | case PCI_DEVICE_ID_INTEL_SPT_H_UART1: |
| 358 | case PCI_DEVICE_ID_INTEL_CNP_H_UART1: |
| 359 | return "UAR1"; |
| 360 | case PCI_DEVICE_ID_INTEL_APL_UART2: |
| 361 | case PCI_DEVICE_ID_INTEL_GLK_UART2: |
| 362 | case PCI_DEVICE_ID_INTEL_SPT_UART2: |
| 363 | case PCI_DEVICE_ID_INTEL_SPT_H_UART2: |
| 364 | case PCI_DEVICE_ID_INTEL_CNP_H_UART2: |
| 365 | return "UAR2"; |
| 366 | case PCI_DEVICE_ID_INTEL_GLK_UART3: |
| 367 | return "UAR3"; |
| 368 | default: |
| 369 | return NULL; |
| 370 | } |
| 371 | } |
| 372 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 373 | static struct device_operations device_ops = { |
Elyes HAOUAS | 1d19127 | 2018-11-27 12:23:48 +0100 | [diff] [blame] | 374 | .read_resources = uart_read_resources, |
| 375 | .set_resources = pci_dev_set_resources, |
| 376 | .enable_resources = uart_common_enable_resources, |
Subrata Banik | 6bbc91a | 2017-12-07 14:55:51 +0530 | [diff] [blame] | 377 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 378 | .acpi_fill_ssdt = uart_fill_ssdt, |
| 379 | .acpi_hid = uart_acpi_hid, |
| 380 | .acpi_name = uart_acpi_name, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | static const unsigned short pci_device_ids[] = { |
| 384 | PCI_DEVICE_ID_INTEL_SPT_UART0, |
| 385 | PCI_DEVICE_ID_INTEL_SPT_UART1, |
| 386 | PCI_DEVICE_ID_INTEL_SPT_UART2, |
V Sowmya | 7c15047 | 2018-01-23 14:44:45 +0530 | [diff] [blame] | 387 | PCI_DEVICE_ID_INTEL_SPT_H_UART0, |
| 388 | PCI_DEVICE_ID_INTEL_SPT_H_UART1, |
| 389 | PCI_DEVICE_ID_INTEL_SPT_H_UART2, |
V Sowmya | acc2a48 | 2018-01-23 15:27:23 +0530 | [diff] [blame] | 390 | PCI_DEVICE_ID_INTEL_KBP_H_UART0, |
| 391 | PCI_DEVICE_ID_INTEL_KBP_H_UART1, |
| 392 | PCI_DEVICE_ID_INTEL_KBP_H_UART2, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 393 | PCI_DEVICE_ID_INTEL_APL_UART0, |
| 394 | PCI_DEVICE_ID_INTEL_APL_UART1, |
| 395 | PCI_DEVICE_ID_INTEL_APL_UART2, |
| 396 | PCI_DEVICE_ID_INTEL_APL_UART3, |
Lijian Zhao | bbedef9 | 2017-07-29 16:38:38 -0700 | [diff] [blame] | 397 | PCI_DEVICE_ID_INTEL_CNL_UART0, |
| 398 | PCI_DEVICE_ID_INTEL_CNL_UART1, |
| 399 | PCI_DEVICE_ID_INTEL_CNL_UART2, |
Hannah Williams | f714965 | 2017-05-13 16:18:02 -0700 | [diff] [blame] | 400 | PCI_DEVICE_ID_INTEL_GLK_UART0, |
| 401 | PCI_DEVICE_ID_INTEL_GLK_UART1, |
| 402 | PCI_DEVICE_ID_INTEL_GLK_UART2, |
| 403 | PCI_DEVICE_ID_INTEL_GLK_UART3, |
praveen hodagatta pranesh | e26c4a4 | 2018-09-20 03:49:45 +0800 | [diff] [blame] | 404 | PCI_DEVICE_ID_INTEL_CNP_H_UART0, |
| 405 | PCI_DEVICE_ID_INTEL_CNP_H_UART1, |
| 406 | PCI_DEVICE_ID_INTEL_CNP_H_UART2, |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 407 | PCI_DEVICE_ID_INTEL_ICP_UART0, |
| 408 | PCI_DEVICE_ID_INTEL_ICP_UART1, |
| 409 | PCI_DEVICE_ID_INTEL_ICP_UART2, |
Ronak Kanabar | da7ffb48 | 2019-02-05 01:51:13 +0530 | [diff] [blame] | 410 | PCI_DEVICE_ID_INTEL_CMP_UART0, |
| 411 | PCI_DEVICE_ID_INTEL_CMP_UART1, |
| 412 | PCI_DEVICE_ID_INTEL_CMP_UART2, |
Gaggery Tsai | 12a651c | 2019-12-05 11:23:20 -0800 | [diff] [blame] | 413 | PCI_DEVICE_ID_INTEL_CMP_H_UART0, |
| 414 | PCI_DEVICE_ID_INTEL_CMP_H_UART1, |
| 415 | PCI_DEVICE_ID_INTEL_CMP_H_UART2, |
Ravi Sarawadi | 6b5bf40 | 2019-10-21 22:25:04 -0700 | [diff] [blame] | 416 | PCI_DEVICE_ID_INTEL_TGP_UART0, |
| 417 | PCI_DEVICE_ID_INTEL_TGP_UART1, |
| 418 | PCI_DEVICE_ID_INTEL_TGP_UART2, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 419 | PCI_DEVICE_ID_INTEL_MCC_UART0, |
| 420 | PCI_DEVICE_ID_INTEL_MCC_UART1, |
| 421 | PCI_DEVICE_ID_INTEL_MCC_UART2, |
Meera Ravindranath | 3f4af0d | 2020-02-12 16:01:22 +0530 | [diff] [blame] | 422 | PCI_DEVICE_ID_INTEL_JSP_UART0, |
| 423 | PCI_DEVICE_ID_INTEL_JSP_UART1, |
| 424 | PCI_DEVICE_ID_INTEL_JSP_UART2, |
Subrata Banik | f672f7f | 2020-08-03 14:29:25 +0530 | [diff] [blame] | 425 | PCI_DEVICE_ID_INTEL_ADP_S_UART0, |
| 426 | PCI_DEVICE_ID_INTEL_ADP_S_UART1, |
| 427 | PCI_DEVICE_ID_INTEL_ADP_S_UART2, |
| 428 | PCI_DEVICE_ID_INTEL_ADP_S_UART3, |
| 429 | PCI_DEVICE_ID_INTEL_ADP_S_UART4, |
| 430 | PCI_DEVICE_ID_INTEL_ADP_S_UART5, |
| 431 | PCI_DEVICE_ID_INTEL_ADP_S_UART6, |
| 432 | PCI_DEVICE_ID_INTEL_ADP_P_UART0, |
| 433 | PCI_DEVICE_ID_INTEL_ADP_P_UART1, |
| 434 | PCI_DEVICE_ID_INTEL_ADP_P_UART2, |
| 435 | PCI_DEVICE_ID_INTEL_ADP_P_UART3, |
| 436 | PCI_DEVICE_ID_INTEL_ADP_P_UART4, |
| 437 | PCI_DEVICE_ID_INTEL_ADP_P_UART5, |
| 438 | PCI_DEVICE_ID_INTEL_ADP_P_UART6, |
Hannah Williams | f714965 | 2017-05-13 16:18:02 -0700 | [diff] [blame] | 439 | 0, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 440 | }; |
| 441 | |
| 442 | static const struct pci_driver pch_uart __pci_driver = { |
Subrata Banik | afa07f7 | 2018-05-24 12:21:06 +0530 | [diff] [blame] | 443 | .ops = &device_ops, |
| 444 | .vendor = PCI_VENDOR_ID_INTEL, |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 445 | .devices = pci_device_ids, |
| 446 | }; |
Patrick Rudolph | 49ae596 | 2020-04-15 11:19:31 +0200 | [diff] [blame] | 447 | |
| 448 | static void uart_enable(struct device *dev) |
| 449 | { |
| 450 | struct soc_intel_common_block_uart_config *conf = dev->chip_info; |
| 451 | dev->ops = &device_ops; |
| 452 | dev->device = conf ? conf->devid : 0; |
| 453 | } |
| 454 | |
| 455 | struct chip_operations soc_intel_common_block_uart_ops = { |
| 456 | CHIP_NAME("LPSS UART in ACPI mode") |
| 457 | .enable_dev = uart_enable |
| 458 | }; |
| 459 | |
Aamir Bohra | 83f7bae | 2017-04-26 19:30:41 +0530 | [diff] [blame] | 460 | #endif /* ENV_RAMSTAGE */ |