From patchwork Wed Apr 13 07:51:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 563080 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14E53C433FE for ; Wed, 13 Apr 2022 07:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233510AbiDMHyV (ORCPT ); Wed, 13 Apr 2022 03:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbiDMHyM (ORCPT ); Wed, 13 Apr 2022 03:54:12 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D46802AE2C; Wed, 13 Apr 2022 00:51:51 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id D2A09FF806; Wed, 13 Apr 2022 07:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1649836310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BEXVWsaDwRLXPaV0JvlxSGsK3e+q5MmOU/HFk1qgThw=; b=IOW+zcIEBYPJnG6COUdKCwDOebjJqrelDO7jX3KsbhjOm6iJt27f07+XDqvWJj7KVUt/79 VfjUi0AmUwv1YaQ7r7YaqT6nk/36X+Y0Nu/WFopRRAHNZCoKW4Gj+kepH85vOlNkhIctgK bJM26j8CRtQ61DJvlifnNB/deGzP8Ig6WcLFnifC+WeBMEhhskuNybyxw/5umcwBLN/TFy dtUSLI1sQ6Z0OP8xw+s8bcJymiSWMYUYwJu4fCWTkVbP9JCdkf3Fw2Nn2kN4Qm922ybz6a 314qGiu9pZf2NJejGOTYArK7ouRa3xbMt6huv4hdXq5d/lwOctWMmrbtgrTlGw== From: Miquel Raynal To: Geert Uytterhoeven , Magnus Damm , Greg Kroah-Hartman , Jiri Slaby Cc: Miquel Raynal , Andy Shevchenko , linux-renesas-soc@vger.kernel.org, linux-serial@vger.kernel.org, Milan Stevanovic , Jimmy Lalande , Pascal Eberhard , Thomas Petazzoni , Herve Codina , Clement Leger , Ilpo Jarvinen , Emil Renner Berthing Subject: [PATCH v5 03/11] serial: 8250: dw: Create a more generic platform data structure Date: Wed, 13 Apr 2022 09:51:33 +0200 Message-Id: <20220413075141.72777-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220413075141.72777-1-miquel.raynal@bootlin.com> References: <20220413075141.72777-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Before adding more platform data information, let's turn the quirks information as being a member of a wider structure. More fields will be added later. At the same time, change the quirks type to unsigned int, as its size won't change between setups and we don't really need this variable to be more than a few bits wide anyway. Provide a stub to the compatibles without quirks to simplify handling. Keep two different empty structure for the base DW compatible and the Renesas one because the latter will soon be fulfilled anyway. Cc: Emil Renner Berthing Suggested-by: Andy Shevchenko Signed-off-by: Miquel Raynal Reviewed-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko --- drivers/tty/serial/8250/8250_dw.c | 33 ++++++++++++++++++++++------ drivers/tty/serial/8250/8250_dwlib.h | 5 +++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index e9f8b65563a1..93b112f3bc49 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c @@ -372,7 +372,7 @@ static bool dw8250_idma_filter(struct dma_chan *chan, void *param) static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) { struct device_node *np = p->dev->of_node; - unsigned long quirks = (unsigned long)device_get_match_data(p->dev); + unsigned int quirks = data->pdata->quirks; if (np) { int id; @@ -463,6 +463,7 @@ static int dw8250_probe(struct platform_device *pdev) data->data.dma.fn = dw8250_fallback_dma_filter; data->usr_reg = DW_UART_USR; + data->pdata = device_get_match_data(p->dev); p->private_data = &data->data; data->uart_16550_compatible = device_property_read_bool(dev, @@ -679,13 +680,31 @@ static const struct dev_pm_ops dw8250_pm_ops = { SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL) }; +static const struct dw8250_platform_data dw8250_dw_apb = { +}; + +static const struct dw8250_platform_data dw8250_octeon_3860_data = { + .quirks = DW_UART_QUIRK_OCTEON, +}; + +static const struct dw8250_platform_data dw8250_armada_38x_data = { + .quirks = DW_UART_QUIRK_ARMADA_38X, +}; + +static const struct dw8250_platform_data dw8250_renesas_rzn1_data = { +}; + +static const struct dw8250_platform_data dw8250_starfive_jh7100_data = { + .quirks = DW_UART_QUIRK_SKIP_SET_RATE, +}; + static const struct of_device_id dw8250_of_match[] = { - { .compatible = "snps,dw-apb-uart" }, - { .compatible = "cavium,octeon-3860-uart", .data = (void *)DW_UART_QUIRK_OCTEON }, - { .compatible = "marvell,armada-38x-uart", .data = (void *)DW_UART_QUIRK_ARMADA_38X }, - { .compatible = "renesas,rzn1-uart" }, - { .compatible = "starfive,jh7100-hsuart", .data = (void *)DW_UART_QUIRK_SKIP_SET_RATE }, - { .compatible = "starfive,jh7100-uart", .data = (void *)DW_UART_QUIRK_SKIP_SET_RATE }, + { .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb }, + { .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data }, + { .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data }, + { .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data }, + { .compatible = "starfive,jh7100-hsuart", .data = &dw8250_starfive_jh7100_data }, + { .compatible = "starfive,jh7100-uart", .data = &dw8250_starfive_jh7100_data }, { /* Sentinel */ } }; MODULE_DEVICE_TABLE(of, dw8250_of_match); diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h index 72e7dbcccad0..68bb81bee660 100644 --- a/drivers/tty/serial/8250/8250_dwlib.h +++ b/drivers/tty/serial/8250/8250_dwlib.h @@ -21,8 +21,13 @@ struct dw8250_port_data { u8 dlf_size; }; +struct dw8250_platform_data { + unsigned int quirks; +}; + struct dw8250_data { struct dw8250_port_data data; + const struct dw8250_platform_data *pdata; u8 usr_reg; int msr_mask_on;