From nobody@FreeBSD.org  Wed Feb 19 11:29:58 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 831C51A4
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Feb 2014 11:29:58 +0000 (UTC)
Received: from newred.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 6E8B91A80
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Feb 2014 11:29:58 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by newred.freebsd.org (8.14.7/8.14.7) with ESMTP id s1JBTvpR098969
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 19 Feb 2014 11:29:57 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.7/8.14.7/Submit) id s1JBTviC098962;
	Wed, 19 Feb 2014 11:29:57 GMT
	(envelope-from nobody)
Message-Id: <201402191129.s1JBTviC098962@cgiserv.freebsd.org>
Date: Wed, 19 Feb 2014 11:29:57 GMT
From: Milan Obuch <bsd@dino.sk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: MCS9922 based card not known
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         186891
>Category:       kern
>Synopsis:       [puc] [patch] MCS9922 based card not known
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 19 11:40:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Fri Apr 18 09:20:00 UTC 2014
>Originator:     Milan Obuch
>Release:        8.4-STABLE, 9.2-STABLE, 10.0-STABLE, 11-CURRENT
>Organization:
>Environment:
>Description:
MCS9922 chip from ASIX, formerly MosChip, is not yet recognised in any FreeBSD. It has two serial ports and PCIe bridge. Simple patch shown below makes it work for me in any of 8.4-STABLE, 9.2-STABLE, 10.0-STABLE, 11-CURRENT version on both i386 and amd64 architecture. Tested lightly with both cu from base and minicom prom ports.
>How-To-Repeat:
Put any MCS9922 based PCIe card into PCIe slot and see it not recognised.
>Fix:
Index: /data/src/11/sys/dev/puc/pucdata.c
===================================================================
--- /usr/src/sys/dev/puc/pucdata.c  (revision 262219)
+++ /usr/src/sys/dev/puc/pucdata.c  (working copy)
@@ -1094,6 +1094,13 @@
            PUC_PORT_2P, 0x10, 4, 0,
        },
 
+       {   0x9710, 0x9922, 0xffff, 0,
+           "NetMos NM9922 Dual UART",
+           DEFAULT_RCLK,
+           PUC_PORT_2S, 0x10, 0, 0,
+           .config_function = puc_config_saturn
+       },
+
        {   0xb00c, 0x021c, 0xffff, 0,
            "IC Book Labs Gunboat x4 Lite",
            DEFAULT_RCLK,


>Release-Note:
>Audit-Trail:

From: Marius Strobl <marius@freebsd.org>
To: bug-followup@FreeBSD.org, bsd@dino.sk
Cc:  
Subject: Re: kern/186891: [puc] [patch] MCS9922 based card not known
Date: Thu, 10 Apr 2014 23:26:56 +0200

 --0rSojgWGcpz+ezC3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 The submitted patch seems inherently bogus; the referenced function
 puc_config_saturn() doesn't exist/isn't provided and it's always a bad
 idea to add an entry for a device that potentially is part of a line
 of controllers with different port configurations and all having the
 same vendor and device ID combination as a wildcard match to puc(4).
 However, most importantly, MCS9922 apparently are multi-function
 devices providing one UART per function so puc(4) shouldn't be used
 in the first place but uart(4) should be tought to probe and attach
 these controllers directly instead. Could you please revert your
 patch for puc(4) and test whether the attached one provies you with
 two instances of uart(4) for that card?
 
 Marius
 
 
 --0rSojgWGcpz+ezC3
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="uart_mc9904.diff"
 
 Index: uart_bus_pci.c
 ===================================================================
 --- uart_bus_pci.c	(revision 264257)
 +++ uart_bus_pci.c	(working copy)
 @@ -135,6 +135,8 @@
  	"MosChip MCS9901 PCIe to Peripheral Controller", 0x10 },
  { 0x9710, 0x9904, 0xa000, 0x1000,
  	"MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
 +{ 0x9710, 0x9922, 0x0000, 0x0000,
 +	"MosChip MCS9922 PCIe to Peripheral Controller", 0x10 },
  { 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
  { 0xffff, 0, 0xffff, 0, NULL, 0, 0}
  };
 
 --0rSojgWGcpz+ezC3--

From: Marius Strobl <marius@freebsd.org>
To: bug-followup@FreeBSD.org, bsd@dino.sk
Cc:  
Subject: Re: kern/186891: [puc] [patch] MCS9922 based card not known
Date: Fri, 11 Apr 2014 00:13:18 +0200

 On Thu, Apr 10, 2014 at 11:26:56PM +0200, Marius Strobl wrote:
 > Could you please revert your
 > patch for puc(4) and test whether the attached one provies you with
 > two instances of uart(4) for that card?
 > 
 > Index: uart_bus_pci.c
 > ===================================================================
 > --- uart_bus_pci.c	(revision 264257)
 > +++ uart_bus_pci.c	(working copy)
 > @@ -135,6 +135,8 @@
 >  	"MosChip MCS9901 PCIe to Peripheral Controller", 0x10 },
 >  { 0x9710, 0x9904, 0xa000, 0x1000,
 >  	"MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
 > +{ 0x9710, 0x9922, 0x0000, 0x0000,
 > +	"MosChip MCS9922 PCIe to Peripheral Controller", 0x10 },
 >  { 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
 >  { 0xffff, 0, 0xffff, 0, NULL, 0, 0}
 >  };
 
 I'm not sure whether the sub vendor and sub device IDs taken from NetBSD
 actually are correct. The MCS9922 datasheet suggests that the following
 should be used instead:
 +{ 0x9710, 0x9922, 0xa000, 0x1000,
 +	"MosChip MCS9922 PCIe to Peripheral Controller", 0x10 },
 
 Marius
 

From: Milan Obuch <bsd@dino.sk>
To: Marius Strobl <marius@freebsd.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/186891: [puc] [patch] MCS9922 based card not known
Date: Fri, 18 Apr 2014 11:05:25 +0200

 On Thu, 10 Apr 2014 23:26:56 +0200
 Marius Strobl <marius@freebsd.org> wrote:
 
 > The submitted patch seems inherently bogus; the referenced function
 > puc_config_saturn() doesn't exist/isn't provided and it's always a bad
 > idea to add an entry for a device that potentially is part of a line
 > of controllers with different port configurations and all having the
 > same vendor and device ID combination as a wildcard match to puc(4).
 > However, most importantly, MCS9922 apparently are multi-function
 > devices providing one UART per function so puc(4) shouldn't be used
 > in the first place but uart(4) should be tought to probe and attach
 > these controllers directly instead. Could you please revert your
 > patch for puc(4) and test whether the attached one provies you with
 > two instances of uart(4) for that card?
 > 
 > Marius
 > 
 
 I will test your patch, allow some time to do so, but you are only
 partially right - MCS9922 provides not only one UART per function,
 there is also GPIO (and possibly I2C) available to. On my board only
 UARTs are used, but some time later I am considering some hardware
 modification to access GPIO too. Not known yet is how to use that on
 software side...
 
 Milan
>Unformatted:
