From owner-p4-projects@FreeBSD.ORG Fri Nov 24 14:29:52 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8820A16A47C; Fri, 24 Nov 2006 14:29:52 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6471A16A412 for ; Fri, 24 Nov 2006 14:29:52 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 620C043D5F for ; Fri, 24 Nov 2006 14:29:10 +0000 (GMT) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kAOETppR046051 for ; Fri, 24 Nov 2006 14:29:51 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kAOETpHc046027 for perforce@freebsd.org; Fri, 24 Nov 2006 14:29:51 GMT (envelope-from gonzo@FreeBSD.org) Date: Fri, 24 Nov 2006 14:29:51 GMT Message-Id: <200611241429.kAOETpHc046027@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 110481 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Nov 2006 14:29:52 -0000 http://perforce.freebsd.org/chv.cgi?CH=110481 Change 110481 by gonzo@gonzo_hq on 2006/11/24 14:28:53 o Elminate limitation on 4-bytes only pci_config write for GT chip. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips4k/malta/gt_pci.c#3 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips4k/malta/gt_pci.c#3 (text+ko) ==== @@ -459,11 +459,56 @@ { struct gt_pci_softc *sc = device_get_softc(dev); uint32_t addr; + uint32_t reg_data; + uint32_t shift, mask; + + if(bytes != 4) + { + reg_data = gt_pci_read_config(dev, bus, slot, func, reg, 4); + + /* + * XXX: We assume that words readed from GT chip are BE. + * Should we set the mode explicitly during chip + * Initialization? + */ + switch(reg % 4) + { + case 3: + shift = 24; + break; + case 2: + shift = 16; + break; + case 1: + shift = 8; + break; + default: + shift = 0; + break; + } - /* - * It's possible to write only 4 bytes at the moment - */ - KASSERT(bytes == 4, ("Unsupport write size")); + switch(bytes) + { + case 1: + mask = 0xff; + data = (reg_data & ~ (mask << shift)) | (data << shift); + break; + case 2: + mask = 0xffff; + if(reg % 4 == 0) + data = (reg_data & ~mask) | data; + else + data = (reg_data & ~ (mask << shift)) | + (data << shift); + break; + case 4: + break; + default: + panic("gt_pci_readconfig: wrong bytes count"); + break; + } + } + if (gt_pci_conf_setup(sc, bus, slot, func, reg & ~3, &addr)) return;