Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1156002rdb; Mon, 2 Oct 2023 00:11:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzMf7cpP72fORt+ZQndzKdAHtfP2JzMPn0D7v0DWtpca7V0Fpa0FnwKt+3T7+5HjoDZc73 X-Received: by 2002:a17:902:e88e:b0:1bc:25ed:374 with SMTP id w14-20020a170902e88e00b001bc25ed0374mr11840140plg.49.1696230711459; Mon, 02 Oct 2023 00:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696230711; cv=none; d=google.com; s=arc-20160816; b=aoSIhVrmvkxOtRmaabCqmassxthCyLDBXnOxsDn0FJODTNwwqMnxl8VdA7MGHaQN9y 8JxEbKToSRtUMFH0PlZsCm3vuo/0o9LjGPppkCRpBVguz3NZRp+BnP6T+ZGKPqbNIrEI yHLajhU6edBW9jNDDKgQUhaNvm1quyktVl7kUJ6CoUfg/PTDwKE4xlDMh43j3RxdIM/q /ye3ALweFezAbrSFQCRgKy53NbLdlCX1Cx4yAYc5F2xlf+WPaWptLU+wbP2Q74ZJTFX8 bYG5B18Ld3TTSEXHJCefP4cPWR8IhZJlPjDgR0LziHZEEO0YDwRyPwDL4hzGt2q3jpq7 UI9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id; bh=DJm2q62qrX+iVKV047NAIq/AT9zmpWfhQyKoz3ijfZc=; fh=yeily2bup8RCYu4BWVzXu7oBQWAjXVmX9Y1yZZcysJM=; b=Fx1WRI4qMQcQGexL0YapdFiJlz6Vcr08DCnzshx5R27ckzY8TB+6HnSPmcsx86hsDx QqMqBUxvS4hunfEEc+6WfhPoujBQufw8Tn9Lxb/PbD4Uoj9QSmOxH6fTRQcGqpW1qNzD QOkckTirDVP1dDTE1rIMCw6XzZCxSuMvBetGvfSQ1fLC6xisg3p0CbpadN08byTonx8f boMs00dOhI9KWRQ894BrCJdjLgW94mDvDLUUOD9CRKwsCeBuxvPpMosaQSPL/cccoVdw RN/mRCQtvhIcOMUlp6ERtnzTXRQqYpg0YX3zzsopO9p+1S+fjsmZ/WxRL2PHR+Wpvd0C 4gKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001c62ce41077si17934237plf.492.2023.10.02.00.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 00:11:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F199D80CF51F; Mon, 2 Oct 2023 00:05:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbjJBHFj (ORCPT + 99 others); Mon, 2 Oct 2023 03:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235601AbjJBHFi (ORCPT ); Mon, 2 Oct 2023 03:05:38 -0400 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA49A9F; Mon, 2 Oct 2023 00:05:34 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-313e742a787so1586169f8f.1; Mon, 02 Oct 2023 00:05:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696230333; x=1696835133; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DJm2q62qrX+iVKV047NAIq/AT9zmpWfhQyKoz3ijfZc=; b=HmP8blnRrSqfCvWJPwwERtj6zLg1wLuMFwkbbXOdwpS9XXGOsbAPEgx5aHrx7hIUFL VfXimrELvSmN96AJ55nZ6aciwGNrkr+03/+MtuB9Z1uQNZD0BmbiVLsFdpMa3FElXgAE sxk6s3Kq2MxnIl83PrTVeo2G1R8trYrx4t0lP/o7ziKPk4sELG5l286nr+betWneRhLW d7zO64CffamQkdLfTjn1yWxWdzT8p1P6l5p5E1eQaPHop15ocduLKabwOVGWd83NlD9y wi8JpnnHTkw9BISpJx4h7r/SwaUVo+xFyCb16Ypt4KrbxRMhMbq5zUIUY3Ip56lxr/M4 eRUQ== X-Gm-Message-State: AOJu0Yxp1zjvrqfej5rbD/3otD5I9naJFMol5IjKgZ9Wl29cDiRJv7+A usOpTcmKVA5gegvH8jo9r9Y= X-Received: by 2002:a5d:6a11:0:b0:324:84bc:d5ab with SMTP id m17-20020a5d6a11000000b0032484bcd5abmr9068418wru.1.1696230332822; Mon, 02 Oct 2023 00:05:32 -0700 (PDT) Received: from [192.168.1.58] (185-219-167-24-static.vivo.cz. [185.219.167.24]) by smtp.gmail.com with ESMTPSA id f21-20020a1c6a15000000b0040641a9d49bsm6550512wmc.17.2023.10.02.00.05.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Oct 2023 00:05:32 -0700 (PDT) Message-ID: <1e99f3c4-e0b8-4951-80c3-f3c5a1eb5277@kernel.org> Date: Mon, 2 Oct 2023 09:05:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] tty: serial: 8250: Add support for MOXA Mini PCIe boards Content-Language: en-US To: Crescent CY Hsieh , gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org References: <20231002015702.30509-1-crescentcy.hsieh@moxa.com> <20231002015702.30509-3-crescentcy.hsieh@moxa.com> From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7TKaVoOcL 9tE5aN3jQmIlrT7ZUX52Ff/hSdx/JKDP3YMNtt4B0cH6ejIjtqTd+Ge8sSttsnNM0CQUkXps w98jwz+Lxw/bKMr3NSnnFpUZaxwji3BC9vYyxKMAwNelBCHEgS/OAa3EJoTfuYOK6wT6nadm YqYjwYbZE5V/SwzMbpWu7Jwlvuwyfo5mh7w5iMfnZE+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yMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: <20231002015702.30509-3-crescentcy.hsieh@moxa.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 00:05:44 -0700 (PDT) On 02. 10. 23, 3:57, Crescent CY Hsieh wrote: > Add support for MOXA Mini PCIe serial boards: > > - CP102N: 2 ports | RS232 > - CP104N: 4 ports | RS232 > - CP112N: 2 ports | RS232/RS422/RS485 > - CP114N: 4 ports | RS232/RS422/RS485 > - CP132N: 2 ports | RS422/RS485 > - CP134N: 4 ports | RS422/RS485 > > Signed-off-by: Crescent CY Hsieh > --- > drivers/tty/serial/8250/8250_pci.c | 54 ++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c > index a010790ccfcd..a70546ac361e 100644 > --- a/drivers/tty/serial/8250/8250_pci.c > +++ b/drivers/tty/serial/8250/8250_pci.c > @@ -1887,6 +1887,42 @@ pci_sunix_setup(struct serial_private *priv, > return setup_port(priv, port, bar, offset, 0); > } > > +#define MOXA_PUART_GPIO_EN 0x09 > +#define MOXA_PUART_GPIO_OUT 0x0A > + > +#define MOXA_GPIO_SET_ALL_OUTPUT 0x0F > + > +static int pci_moxa_init(struct pci_dev *dev) > +{ > + unsigned short device = dev->device; > + unsigned long iobar_addr = pci_resource_start(dev, 2); resource_size_t > + int num_ports = (device & 0x00F0) >> 4; > + unsigned char val; u8 > + > + outb(MOXA_GPIO_SET_ALL_OUTPUT, iobar_addr + MOXA_PUART_GPIO_EN); You need to comment in the commit log why this doesn't matter for other moxa cards. > + /* > + * Enable hardware buffer to prevent break signal output when system boot up. boots up. > + * This hardware buffer is only supported on Mini PCIe series. > + */ > + if (device == 0x1027 || /* MOXA_CP102N */ > + device == 0x1046 || /* MOXA_CP104N */ > + device == 0x1121 || /* MOXA_CP112N */ > + device == 0x1145 || /* MOXA_CP114N */ > + device == 0x1323 || /* MOXA_CP132N */ > + device == 0x1343) { /* MOXA_CP134N */ Why not use the definitions below? You should define a function for this anyway. > + /* Set GPIO direction */ > + val = inb(iobar_addr + MOXA_PUART_GPIO_EN); > + val |= (1 << 2); Too magic constant. Use BIT() and define that 2 as some constant. > + outb(val, iobar_addr + MOXA_PUART_GPIO_EN); > + /* Enable low GPIO */ > + val = inb(iobar_addr + MOXA_PUART_GPIO_OUT); > + val &= ~(1 << 2); > + outb(val, iobar_addr + MOXA_PUART_GPIO_OUT); > + } One more \n here. > + return num_ports; > +} > + > static int pci_moxa_setup(struct serial_private *priv, > const struct pciserial_board *board, > struct uart_8250_port *port, > @@ -1973,6 +2009,13 @@ static int pci_moxa_setup(struct serial_private *priv, > #define PCI_DEVICE_ID_MOXA_CP134EL_A 0x1342 > #define PCI_DEVICE_ID_MOXA_CP138E_A 0x1381 > #define PCI_DEVICE_ID_MOXA_CP168EL_A 0x1683 > +/* MOXA Mini PCIe */ > +#define PCI_DEVICE_ID_MOXA_CP102N 0x1027 > +#define PCI_DEVICE_ID_MOXA_CP104N 0x1046 > +#define PCI_DEVICE_ID_MOXA_CP112N 0x1121 > +#define PCI_DEVICE_ID_MOXA_CP114N 0x1145 > +#define PCI_DEVICE_ID_MOXA_CP132N 0x1323 > +#define PCI_DEVICE_ID_MOXA_CP134N 0x1343 I am not sure it matters they are mini PCIe. I would sort them into the above preexisting list instead. > > /* Unknown vendors/cards - this should not be in linux/pci_ids.h */ > #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 > @@ -2638,6 +2681,7 @@ static struct pci_serial_quirk pci_serial_quirks[] = { > .device = PCI_ANY_ID, > .subvendor = PCI_ANY_ID, > .subdevice = PCI_ANY_ID, > + .init = pci_moxa_init, > .setup = pci_moxa_setup, > }, > { > @@ -5365,6 +5409,16 @@ static const struct pci_device_id serial_pci_tbl[] = { > { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP138E_A), 0, 0, pbn_moxa_8 }, > { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL_A), 0, 0, pbn_moxa_8 }, > > + /* > + * MOXA Mini PCIe > + */ > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102N), 0, 0, pbn_moxa_2 }, > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104N), 0, 0, pbn_moxa_4 }, > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP112N), 0, 0, pbn_moxa_2 }, > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114N), 0, 0, pbn_moxa_4 }, > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132N), 0, 0, pbn_moxa_2 }, > + { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134N), 0, 0, pbn_moxa_4 }, PCI_VDEVICE() again? thanks, -- js suse labs