Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: 8250_dw: add dw8250_quirks function

Merging the DT and ACPI specific probe functions into
dw8250_quirks. Those functions did not have that much code
any more and some of the quirks need to be shared. This
will also allow platforms without DT or ACPI to use the
driver.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Heikki Krogerus and committed by
Greg Kroah-Hartman
9e08fa50 4f042054

+33 -53
+33 -53
drivers/tty/serial/8250/8250_dw.c
··· 283 283 up->capabilities |= UART_CAP_AFE; 284 284 } 285 285 286 - static int dw8250_probe_of(struct uart_port *p, 287 - struct dw8250_data *data) 288 - { 289 - struct device_node *np = p->dev->of_node; 290 - int id; 291 - 292 - #ifdef CONFIG_64BIT 293 - if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { 294 - p->serial_in = dw8250_serial_inq; 295 - p->serial_out = dw8250_serial_outq; 296 - p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; 297 - p->type = PORT_OCTEON; 298 - data->usr_reg = 0x27; 299 - data->skip_autocfg = true; 300 - } 301 - #endif 302 - /* get index of serial line, if found in DT aliases */ 303 - id = of_alias_get_id(np, "serial"); 304 - if (id >= 0) 305 - p->line = id; 306 - 307 - return 0; 308 - } 309 - 310 286 static bool dw8250_idma_filter(struct dma_chan *chan, void *param) 311 287 { 312 288 struct device *dev = param; ··· 293 317 return true; 294 318 } 295 319 296 - static int dw8250_probe_acpi(struct uart_8250_port *up, 297 - struct dw8250_data *data) 320 + static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) 298 321 { 299 - struct uart_port *p = &up->port; 322 + if (p->dev->of_node) { 323 + struct device_node *np = p->dev->of_node; 324 + int id; 300 325 301 - p->iotype = UPIO_MEM32; 302 - p->serial_in = dw8250_serial_in32; 303 - p->serial_out = dw8250_serial_out32; 304 - p->regshift = 2; 305 - 306 - /* Platforms with iDMA */ 307 - if (platform_get_resource_byname(to_platform_device(up->port.dev), 308 - IORESOURCE_MEM, "lpss_priv")) { 309 - data->dma.rx_param = up->port.dev->parent; 310 - data->dma.tx_param = up->port.dev->parent; 311 - data->dma.fn = dw8250_idma_filter; 326 + /* get index of serial line, if found in DT aliases */ 327 + id = of_alias_get_id(np, "serial"); 328 + if (id >= 0) 329 + p->line = id; 330 + #ifdef CONFIG_64BIT 331 + if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { 332 + p->serial_in = dw8250_serial_inq; 333 + p->serial_out = dw8250_serial_outq; 334 + p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; 335 + p->type = PORT_OCTEON; 336 + data->usr_reg = 0x27; 337 + data->skip_autocfg = true; 338 + } 339 + #endif 340 + } else if (has_acpi_companion(p->dev)) { 341 + p->iotype = UPIO_MEM32; 342 + p->regshift = 2; 343 + p->serial_in = dw8250_serial_in32; 344 + p->serial_out = dw8250_serial_out32; 345 + p->set_termios = dw8250_set_termios; 312 346 } 313 347 314 - up->port.set_termios = dw8250_set_termios; 315 - 316 - return 0; 348 + /* Platforms with iDMA */ 349 + if (platform_get_resource_byname(to_platform_device(p->dev), 350 + IORESOURCE_MEM, "lpss_priv")) { 351 + p->set_termios = dw8250_set_termios; 352 + data->dma.rx_param = p->dev->parent; 353 + data->dma.tx_param = p->dev->parent; 354 + data->dma.fn = dw8250_idma_filter; 355 + } 317 356 } 318 357 319 358 static int dw8250_probe(struct platform_device *pdev) ··· 459 468 data->dma.tx_param = data; 460 469 data->dma.fn = dw8250_dma_filter; 461 470 462 - if (pdev->dev.of_node) { 463 - err = dw8250_probe_of(p, data); 464 - if (err) 465 - goto err_reset; 466 - } else if (ACPI_HANDLE(&pdev->dev)) { 467 - err = dw8250_probe_acpi(&uart, data); 468 - if (err) 469 - goto err_reset; 470 - } else { 471 - err = -ENODEV; 472 - goto err_reset; 473 - } 471 + dw8250_quirks(p, data); 474 472 475 473 if (!data->skip_autocfg) 476 474 dw8250_setup_port(&uart);