From patchwork Sun Feb 13 22:11:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaro Koskinen X-Patchwork-Id: 553501 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1DMI5HN020515 for ; Sun, 13 Feb 2011 22:18:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755164Ab1BMWSE (ORCPT ); Sun, 13 Feb 2011 17:18:04 -0500 Received: from filtteri6.pp.htv.fi ([213.243.153.189]:34928 "EHLO filtteri6.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755103Ab1BMWSC (ORCPT ); Sun, 13 Feb 2011 17:18:02 -0500 Received: from localhost (localhost [127.0.0.1]) by filtteri6.pp.htv.fi (Postfix) with ESMTP id B02D756E797; Mon, 14 Feb 2011 00:11:15 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp5.welho.com ([213.243.153.39]) by localhost (filtteri6.pp.htv.fi [213.243.153.189]) (amavisd-new, port 10024) with ESMTP id 4TeCvVzLWZxN; Mon, 14 Feb 2011 00:11:06 +0200 (EET) Received: from localhost.localdomain (cs109108020025.pp.htv.fi [109.108.20.25]) by smtp5.welho.com (Postfix) with ESMTP id 9E38C5BC046; Mon, 14 Feb 2011 00:11:05 +0200 (EET) From: Aaro Koskinen To: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Winischhofer Subject: [PATCH 2/6] sisfb: move XGI POST RAM type detection into a subroutine Date: Mon, 14 Feb 2011 00:11:24 +0200 Message-Id: <1297635088-13224-3-git-send-email-aaro.koskinen@iki.fi> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1297635088-13224-1-git-send-email-aaro.koskinen@iki.fi> References: <1297635088-13224-1-git-send-email-aaro.koskinen@iki.fi> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 13 Feb 2011 22:18:05 +0000 (UTC) diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c index 2c5de66..364559b 100644 --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c @@ -4936,6 +4936,40 @@ sisfb_post_xgi_setclocks(struct sis_video_info *ivideo, u8 regb) sisfb_post_xgi_delay(ivideo, 0x43); } +static u8 __devinit +sisfb_post_xgi_ramtype(struct sis_video_info *ivideo) +{ + unsigned char *bios = ivideo->bios_abase; + u8 ramtype; + u8 reg; + u8 v1; + + ramtype = 0x00; v1 = 0x10; + if (ivideo->haveXGIROM) { + ramtype = bios[0x62]; + v1 = bios[0x1d2]; + } + if (!(ramtype & 0x80)) { + if (ivideo->chip == XGI_20) { + SiS_SetReg(SISCR, 0x97, v1); + reg = SiS_GetReg(SISCR, 0x97); + if (reg & 0x10) { + ramtype = (reg & 0x01) << 1; + } + } else { + reg = SiS_GetReg(SISSR, 0x39); + ramtype = reg & 0x02; + if (!(ramtype)) { + reg = SiS_GetReg(SISSR, 0x3a); + ramtype = (reg >> 1) & 0x01; + } + } + } + ramtype &= 0x07; + + return ramtype; +} + static int __devinit sisfb_post_xgi(struct pci_dev *pdev) { @@ -5380,28 +5414,7 @@ sisfb_post_xgi(struct pci_dev *pdev) SiS_SetReg(SISSR, 0x1c, 0x00); } - ramtype = 0x00; v1 = 0x10; - if(ivideo->haveXGIROM) { - ramtype = bios[0x62]; - v1 = bios[0x1d2]; - } - if(!(ramtype & 0x80)) { - if(ivideo->chip == XGI_20) { - SiS_SetReg(SISCR, 0x97, v1); - reg = SiS_GetReg(SISCR, 0x97); - if(reg & 0x10) { - ramtype = (reg & 0x01) << 1; - } - } else { - reg = SiS_GetReg(SISSR, 0x39); - ramtype = reg & 0x02; - if(!(ramtype)) { - reg = SiS_GetReg(SISSR, 0x3a); - ramtype = (reg >> 1) & 0x01; - } - } - } - ramtype &= 0x07; + ramtype = sisfb_post_xgi_ramtype(ivideo); regb = 0; /* ! */