From owner-freebsd-hackers@freebsd.org Tue Mar 6 07:27:36 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4292CF3991C for ; Tue, 6 Mar 2018 07:27:36 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from david.siemens.de (david.siemens.de [192.35.17.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "david.siemens.de", Issuer "Siemens Issuing CA Internet Server 2017" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BCE3387004; Tue, 6 Mar 2018 07:27:35 +0000 (UTC) (envelope-from Andre.Albsmeier@siemens.com) Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w267RRMM016999 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Mar 2018 08:27:27 +0100 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.40.130]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w267RRe8017019; Tue, 6 Mar 2018 08:27:27 +0100 Received: (from user@localhost) by curry.mchp.siemens.de (8.15.2/8.15.2) id w267RRNH024137; Date: Tue, 6 Mar 2018 08:27:27 +0100 From: Andre Albsmeier To: Daniel Eischen Cc: Andre Albsmeier , freebsd-hackers@FreeBSD.org Subject: Re: Adding support for MosChip 9912 PCIe (serial/parallel) cards Message-ID: <20180306072727.GA86364@bali> References: <20180302061852.GA7887@bali> <20180303064400.GA27337@bali> <20180303184359.GA29745@bali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2018 07:27:36 -0000 On Sat, 03-Mar-2018 at 14:41:58 -0500, Daniel Eischen wrote: > On Sat, 3 Mar 2018, Andre Albsmeier wrote: > > > On Sat, 03-Mar-2018 at 10:53:20 -0500, Daniel Eischen wrote: > >> On Sat, 3 Mar 2018, Andre Albsmeier wrote: > >> > >>> On Fri, 02-Mar-2018 at 08:36:40 -0500, Daniel Eischen wrote: > >>>> On Fri, 2 Mar 2018, Andre Albsmeier wrote: > >>>> > >>>>> I have a MosChip 9912 card (PCIe card with 1 parallel and 2 serial > >>>>> ports) sitting here which does not get detected on 11.1. I tried > >>>>> to simply add it to the uart and ppc drivers with > >>>>> > >>>> [ ... ] > >>>> > >>>> Do you try adding similar support to puc_pci_devices[] in > >>>> sys/dev/puc/pucdata.c? > >>> > >>> Just tried that: > >>> > >>> @@ -1204,6 +1204,11 @@ > >>> PUC_PORT_1S1P, 0x10, 4, 0, > >>> }, > >>> > >>> +{ 0x9710, 0x9912, 0xa000, 0x3012, > >>> + "NetMos NM9912 Dual UART and 1284 Printer port", > >>> + DEFAULT_RCLK, > >>> + PUC_PORT_2S1P, 0x10, 4, 0, > >>> +}, > >>> { 0x9710, 0x9865, 0xa000, 0x3012, > >>> "NetMos NM9865 Dual UART and 1284 Printer port", > >>> DEFAULT_RCLK, > >>> > >>> But the results are exactly the same. It also doesn't > >>> matter if puc.ko is loaded at all. > >> > >> Are you sure your subvendor and subdevice are correct? I would > > > > No ;-). I have to use: 0x9710, 0x9912, 0xa000, 0x2000, > > > > Now I have the following behaviour: > > > > When I load puc.ko I get: > > puc0: at device 0.2 on pci9 > > > > If I load ppc.ko now, I get: > > ppc0: parallel port not found. > > > > But if I unload puc and ppc and load ppc again, I get: > > > > ppc0: port 0xd000-0xd007,0xd008-0xd00f mem 0x89200000-0x89200fff irq 20 at device 0.2 on pci9 > > ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode > > ppbus0: on ppc0 > > lpt0: on ppbus0 > > lpt0: Interrupt-driven port > > > > For all this I have to disable /boot/device.hints -- otherwise > > the messages "driver bug: Unable to set devclass" comes back. > > > > So I think there are two problems: > > > > First the settings of the ISA stuff in /boot/device.hints conflicted > > with the settings the driver probed. This would be easy to solve -- > > just disable them in /boot/device.hints. > > > > Second it appears that ppc only attaches if puc did some kind of > > initialisation first. But we have to detach puc so the ppc can attach. > > Strange. Did you try setting puc_load="YES" in /boot/loader.conf > and rebooting? Or are you just loading and unloading modules > for now? I am now using this diff to access the MCS9912. I am (mis)using puc to initialise whatever is needed for the printer port to work and let ppc attach to puc. As puc does not attach to single port devices, I have removed this check. uart works by simply adding the device. This is all quite ugly but it works... --- ./puc/puc.c.ORI 2018-03-06 06:21:35.939042000 +0100 +++ ./puc/puc.c 2018-03-06 06:21:10.337686000 +0100 @@ -458,8 +458,10 @@ sc->sc_cfg = cfg; /* We don't attach to single-port serial cards. */ +#if 0 if (cfg->ports == PUC_PORT_1S || cfg->ports == PUC_PORT_1P) return (EDOOFUS); +#endif error = puc_config(sc, PUC_CFG_GET_NPORTS, 0, &res); if (error) return (error); --- ./puc/pucdata.c.ORI 2016-12-27 14:33:54.000000000 +0100 +++ ./puc/pucdata.c 2018-03-06 06:19:26.764167000 +0100 @@ -1216,6 +1216,12 @@ PUC_PORT_2P, 0x10, 4, 0, }, +{ 0x9710, 0x9912, 0xa000, 0x2000, + "NetMos NM9912 Printer port", + DEFAULT_RCLK, + PUC_PORT_1P, 0x10, 4, 0, +}, + { 0xb00c, 0x021c, 0xffff, 0, "IC Book Labs Gunboat x4 Lite", DEFAULT_RCLK, --- ./uart/uart_bus_pci.c.ORI 2018-02-12 06:17:57.000000000 +0100 +++ ./uart/uart_bus_pci.c 2018-03-06 06:23:20.886245000 +0100 @@ -158,6 +158,8 @@ "MosChip MCS9904 PCIe to Peripheral Controller", 0x10 }, { 0x9710, 0x9922, 0xa000, 0x1000, "MosChip MCS9922 PCIe to Peripheral Controller", 0x10 }, +{ 0x9710, 0x9912, 0xa000, 0x1000, + "MosChip MCS9912 PCIe to Peripheral Controller", 0x10 }, { 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 }, { 0xffff, 0, 0xffff, 0, NULL, 0, 0} }; -Andre