From owner-svn-src-stable-8@FreeBSD.ORG Wed Jun 8 20:57:23 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0961C1065672; Wed, 8 Jun 2011 20:57:23 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC0E98FC08; Wed, 8 Jun 2011 20:57:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p58KvMVe046915; Wed, 8 Jun 2011 20:57:22 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p58KvMod046913; Wed, 8 Jun 2011 20:57:22 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201106082057.p58KvMod046913@svn.freebsd.org> From: John Baldwin Date: Wed, 8 Jun 2011 20:57:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222871 - stable/8/sys/dev/puc X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2011 20:57:23 -0000 Author: jhb Date: Wed Jun 8 20:57:22 2011 New Revision: 222871 URL: http://svn.freebsd.org/changeset/base/222871 Log: MFC 221182,222760: Add support for Oxford PCI Express Expresso family devices. For these devices, the number of supported ports is read from a register in BAR 0. Modified: stable/8/sys/dev/puc/pucdata.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/puc/pucdata.c ============================================================================== --- stable/8/sys/dev/puc/pucdata.c Wed Jun 8 20:12:38 2011 (r222870) +++ stable/8/sys/dev/puc/pucdata.c Wed Jun 8 20:57:22 2011 (r222871) @@ -51,6 +51,7 @@ static puc_config_f puc_config_amc; static puc_config_f puc_config_cronyx; static puc_config_f puc_config_diva; static puc_config_f puc_config_icbook; +static puc_config_f puc_config_oxford_pcie; static puc_config_f puc_config_quatech; static puc_config_f puc_config_syba; static puc_config_f puc_config_siig; @@ -619,7 +620,7 @@ const struct puc_cfg puc_pci_devices[] = * Boards with an Oxford Semiconductor chip. * * Oxford Semiconductor provides documentation for their chip at: - * + * * * As sold by Kouwell . * I/O Flex PCI I/O Card Model-223 with 4 serial and 1 parallel ports. @@ -679,6 +680,63 @@ const struct puc_cfg puc_pci_devices[] = PUC_PORT_4S, 0x10, 0, 8, }, + /* + * Oxford Semiconductor PCI Express Expresso family + * + * Found in many 'native' PCI Express serial boards such as: + * + * eMegatech MP954ER4 (4 port) and MP958ER8 (8 port) + * + * + * Lindy 51189 (4 port) + * + * + * StarTech.com PEX4S952 (4 port) and PEX8S952 (8 port) + * + */ + + { 0x1415, 0xc158, 0xffff, 0, + "Oxford Semiconductor OXPCIe952 UARTs", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + + { 0x1415, 0xc15d, 0xffff, 0, + "Oxford Semiconductor OXPCIe952 UARTs (function 1)", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + + { 0x1415, 0xc208, 0xffff, 0, + "Oxford Semiconductor OXPCIe954 UARTs", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + + { 0x1415, 0xc20d, 0xffff, 0, + "Oxford Semiconductor OXPCIe954 UARTs (function 1)", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + + { 0x1415, 0xc308, 0xffff, 0, + "Oxford Semiconductor OXPCIe958 UARTs", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + + { 0x1415, 0xc30d, 0xffff, 0, + "Oxford Semiconductor OXPCIe958 UARTs (function 1)", + DEFAULT_RCLK * 0x22, + PUC_PORT_NONSTANDARD, 0x10, 0, -1, + .config_function = puc_config_oxford_pcie + }, + { 0x14d2, 0x8010, 0xffff, 0, "VScom PCI-100L", DEFAULT_RCLK * 8, @@ -1253,6 +1311,79 @@ puc_config_timedia(struct puc_softc *sc, } static int +puc_config_oxford_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, + intptr_t *res) +{ + const struct puc_cfg *cfg = sc->sc_cfg; + int idx; + struct puc_bar *bar; + uint8_t value; + + switch (cmd) { + case PUC_CFG_SETUP: + device_printf(sc->sc_dev, "%d UARTs detected\n", + sc->sc_nports); + + /* Set UARTs to enhanced mode */ + bar = puc_get_bar(sc, cfg->rid); + if (bar == NULL) + return (ENXIO); + for (idx = 0; idx < sc->sc_nports; idx++) { + value = bus_read_1(bar->b_res, 0x1000 + (idx << 9) + + 0x92); + bus_write_1(bar->b_res, 0x1000 + (idx << 9) + 0x92, + value | 0x10); + } + return (0); + case PUC_CFG_GET_LEN: + *res = 0x200; + return (0); + case PUC_CFG_GET_NPORTS: + /* + * Check if we are being called from puc_bfe_attach() + * or puc_bfe_probe(). If puc_bfe_probe(), we cannot + * puc_get_bar(), so we return a value of 16. This has cosmetic + * side-effects at worst; in PUC_CFG_GET_DESC, + * (int)sc->sc_cfg_data will not contain the true number of + * ports in PUC_CFG_GET_DESC, but we are not implementing that + * call for this device family anyway. + * + * The check is for initialisation of sc->sc_bar[idx], which is + * only done in puc_bfe_attach(). + */ + idx = 0; + do { + if (sc->sc_bar[idx++].b_rid != -1) { + sc->sc_cfg_data = 16; + *res = sc->sc_cfg_data; + return (0); + } + } while (idx < PUC_PCI_BARS); + + bar = puc_get_bar(sc, cfg->rid); + if (bar == NULL) + return (ENXIO); + + value = bus_read_1(bar->b_res, 0x04); + if (value == 0) + return (ENXIO); + + sc->sc_cfg_data = value; + *res = sc->sc_cfg_data; + return (0); + case PUC_CFG_GET_OFS: + *res = 0x1000 + (port << 9); + return (0); + case PUC_CFG_GET_TYPE: + *res = PUC_TYPE_SERIAL; + return (0); + default: + break; + } + return (ENXIO); +} + +static int puc_config_titan(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port, intptr_t *res) {