From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>,
aravind.gopalakrishnan@amd.com, xen-devel@lists.xenproject.org,
andrew.cooper3@citrix.com
Subject: Re: [PATCH v2 4/7] serial: Seperate the PCI device ids and parameters
Date: Mon, 10 Mar 2014 12:23:16 -0400 [thread overview]
Message-ID: <20140310162316.GF4262@phenom.dumpdata.com> (raw)
In-Reply-To: <531D96E4020000780012242C@nat28.tlf.novell.com>
On Mon, Mar 10, 2014 at 09:41:40AM +0000, Jan Beulich wrote:
> >>> On 07.03.14 at 20:01, Konrad Rzeszutek Wilk <konrad@kernel.org> wrote:
> > @@ -96,28 +100,27 @@ struct ns16550_config_mmio {
> >
> >
> > #ifdef HAS_PCI
> > +enum ns16550_config_param_nr {
>
> Perhaps better e.g. _kind or _idx rather than _nr? But in the end
> you don't use the enum tag anyway, so you could as well leave out
> the tag altogether.
OK, will replace it with #defines.
>
> > + param_default = 0,
> > + param_trumanage,
> > + param_oxford,
> > +};
> > /*
> > * Create lookup tables for specific MMIO devices..
> > * It is assumed that if the device found is MMIO,
> > * then you have indexed it here. Else, the driver
> > * does nothing.
> > */
> > -static struct ns16550_config_mmio __initdata uart_config[] =
> > -{
> > - /* Broadcom TruManage device */
> > - {
> > - .vendor_id = 0x14e4,
> > - .dev_id = 0x160a,
> > +static struct ns16550_config_param __initdata uart_param[] = {
>
> If you need to touch this anyway, please make both this ...
>
> > + [param_default] = { }, /* Ignored. */
> > + [param_trumanage] = {
> > .reg_shift = 2,
> > .reg_width = 1,
> > .fifo_size = 16,
> > .lsr_mask = (UART_LSR_THRE | UART_LSR_TEMT),
> > .max_bars = 1,
> > },
> > - /* OXPCIe952 1 Native UART */
> > - {
> > - .vendor_id = 0x1415,
> > - .dev_id = 0xc138,
> > + [param_oxford] = {
> > .base_baud = 4000000,
> > .uart_offset = 0x200,
> > .first_offset = 0x1000,
> > @@ -128,6 +131,21 @@ static struct ns16550_config_mmio __initdata uart_config[] =
> > .max_bars = 1, /* It can do more, but we would need more custom
> > code.*/
> > }
> > };
> > +static struct ns16550_config_mmio __initdata uart_config[] =
>
> ... and this it "const ... __initconst" now that we have the latter.
> (Sorry for not noticing the first time through.)
How does that look to you?
>From d85150bae12257fca7576261e4cc2bedb05e0cf1 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Fri, 7 Mar 2014 12:44:30 -0500
Subject: [PATCH] serial: Seperate the PCI device ids and parameters
This will allow us to re-use the parameters for multiple PCI
devices.
No functional change.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[v1: Use #defines instead of enum, use __initconst and const by Jan's review]
---
xen/drivers/char/ns16550.c | 69 +++++++++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index ac509f9..6003331 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -80,10 +80,14 @@ static struct ns16550 {
#endif
} ns16550_com[2] = { { 0 } };
-/* Defining uart config options for MMIO devices */
struct ns16550_config_mmio {
u16 vendor_id;
u16 dev_id;
+ unsigned int param;
+};
+
+/* Defining uart config options for MMIO devices */
+struct ns16550_config_param {
unsigned int reg_shift;
unsigned int reg_width;
unsigned int fifo_size;
@@ -96,28 +100,26 @@ struct ns16550_config_mmio {
#ifdef HAS_PCI
+#define PARAM_DEFAULT 0
+#define PARAM_TRUMANAGE 1
+#define PARAM_OXFORD 2
+
/*
* Create lookup tables for specific MMIO devices..
* It is assumed that if the device found is MMIO,
* then you have indexed it here. Else, the driver
* does nothing.
*/
-static struct ns16550_config_mmio __initdata uart_config[] =
-{
- /* Broadcom TruManage device */
- {
- .vendor_id = 0x14e4,
- .dev_id = 0x160a,
+static const struct ns16550_config_param __initconst uart_param[] = {
+ [PARAM_DEFAULT] = { }, /* Ignored. */
+ [PARAM_TRUMANAGE] = {
.reg_shift = 2,
.reg_width = 1,
.fifo_size = 16,
.lsr_mask = (UART_LSR_THRE | UART_LSR_TEMT),
.max_bars = 1,
},
- /* OXPCIe952 1 Native UART */
- {
- .vendor_id = 0x1415,
- .dev_id = 0xc138,
+ [PARAM_OXFORD] = {
.base_baud = 4000000,
.uart_offset = 0x200,
.first_offset = 0x1000,
@@ -128,6 +130,24 @@ static struct ns16550_config_mmio __initdata uart_config[] =
.max_bars = 1, /* It can do more, but we would need more custom code.*/
}
};
+static const struct ns16550_config_mmio __initconst uart_config[] =
+{
+ /* Broadcom TruManage device */
+ {
+ .vendor_id = 0x14e4,
+ .dev_id = 0x160a,
+ .param = PARAM_TRUMANAGE,
+ },
+ /* OXPCIe952 1 Native UART */
+ {
+ .vendor_id = 0x1415,
+ .dev_id = 0xc138,
+ .param = PARAM_OXFORD,
+ }
+};
+#undef PARAM_DEFAULT
+#undef PARAM_TRUMANAGE
+#undef PARAM_OXFORD
#endif
static void ns16550_delayed_resume(void *data);
@@ -692,37 +712,40 @@ pci_uart_config (struct ns16550 *uart, int skip_amt, int bar_idx)
size &= -size;
- /* Check for quirks in uart_config lookup table */
+ /* Check for params in uart_config lookup table */
for ( i = 0; i < ARRAY_SIZE(uart_config); i++)
{
+ unsigned int p;
+
if ( uart_config[i].vendor_id != vendor )
continue;
if ( uart_config[i].dev_id != device )
continue;
+ p = uart_config[i].param;
/*
* Force length of mmio region to be at least
* 8 bytes times (1 << reg_shift)
*/
- if ( size < (0x8 * (1 << uart_config[i].reg_shift)) )
+ if ( size < (0x8 * (1 << uart_param[p].reg_shift)) )
continue;
- if ( bar_idx >= uart_config[i].max_bars )
+ if ( bar_idx >= uart_param[p].max_bars )
continue;
- if ( uart_config[i].fifo_size )
- uart->fifo_size = uart_config[i].fifo_size;
+ if ( uart_param[p].fifo_size )
+ uart->fifo_size = uart_param[p].fifo_size;
- uart->reg_shift = uart_config[i].reg_shift;
- uart->reg_width = uart_config[i].reg_width;
- uart->lsr_mask = uart_config[i].lsr_mask;
+ uart->reg_shift = uart_param[p].reg_shift;
+ uart->reg_width = uart_param[p].reg_width;
+ uart->lsr_mask = uart_param[p].lsr_mask;
uart->io_base = ((u64)bar_64 << 32) |
(bar & PCI_BASE_ADDRESS_MEM_MASK);
- uart->io_base += uart_config[i].first_offset;
- uart->io_base += bar_idx * uart_config[i].uart_offset;
- if ( uart_config[i].base_baud )
- uart->clock_hz = uart_config[i].base_baud * 16;
+ uart->io_base += uart_param[p].first_offset;
+ uart->io_base += bar_idx * uart_param[p].uart_offset;
+ if ( uart_param[p].base_baud )
+ uart->clock_hz = uart_param[p].base_baud * 16;
/* Set device and MMIO region read only to Dom0 */
uart->enable_ro = 1;
break;
--
1.7.7.6
next prev parent reply other threads:[~2014-03-10 16:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 19:01 [PATCH v2] Enable serial output for Oxford Semiconductor PCIe cards and fixes Konrad Rzeszutek Wilk
2014-03-07 19:01 ` [PATCH v2 1/7] serial: Skip over PCIe device which have no quirks (fix AMT regression) Konrad Rzeszutek Wilk
2014-03-10 9:26 ` Jan Beulich
2014-03-07 19:01 ` [PATCH v2 2/7] serial: Fix COM1 assumption if pci_uart_config did not find the PCI serial card Konrad Rzeszutek Wilk
2014-03-10 9:35 ` Jan Beulich
2014-03-10 16:07 ` Konrad Rzeszutek Wilk
2014-03-10 16:20 ` Jan Beulich
2014-03-10 16:13 ` Konrad Rzeszutek Wilk
2014-03-10 16:23 ` Jan Beulich
2014-03-10 16:45 ` Konrad Rzeszutek Wilk
2014-03-10 17:06 ` Jan Beulich
2014-03-07 19:01 ` [PATCH v2 3/7] serial: Support OXPCIe952 aka Oxford Semiconductor Ltd Device c138 (1415:c138) Konrad Rzeszutek Wilk
2014-03-07 19:01 ` [PATCH v2 4/7] serial: Seperate the PCI device ids and parameters Konrad Rzeszutek Wilk
2014-03-10 9:41 ` Jan Beulich
2014-03-10 16:23 ` Konrad Rzeszutek Wilk [this message]
2014-03-10 16:30 ` Jan Beulich
2014-03-10 16:38 ` Konrad Rzeszutek Wilk
2014-03-10 16:51 ` Konrad Rzeszutek Wilk
2014-03-10 17:07 ` Jan Beulich
2014-03-07 19:01 ` [PATCH v2 5/7] serial: Use #defines for PCI vendors Konrad Rzeszutek Wilk
2014-03-10 9:44 ` Jan Beulich
2014-03-07 19:01 ` [PATCH v2 6/7] serial: Expand the PCI serial quirks for OXPCIe200 and OXPCIe952 1 Native UART Konrad Rzeszutek Wilk
2014-03-07 19:01 ` [PATCH v2 7/7] pci: Put all PCI device vendor and models in one file Konrad Rzeszutek Wilk
2014-03-10 9:46 ` Jan Beulich
2014-03-07 21:27 ` [PATCH v2] Enable serial output for Oxford Semiconductor PCIe cards and fixes Aravind Gopalakrishnan
2014-03-07 22:06 ` Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140310162316.GF4262@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=aravind.gopalakrishnan@amd.com \
--cc=konrad@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.