From patchwork Fri May 31 12:55:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 2643891 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8C86CDFB79 for ; Fri, 31 May 2013 12:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754325Ab3EaM5O (ORCPT ); Fri, 31 May 2013 08:57:14 -0400 Received: from mail-we0-f177.google.com ([74.125.82.177]:35202 "EHLO mail-we0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753785Ab3EaM4J (ORCPT ); Fri, 31 May 2013 08:56:09 -0400 Received: by mail-we0-f177.google.com with SMTP id n57so1167688wev.8 for ; Fri, 31 May 2013 05:56:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:content-type:x-gm-message-state; bh=Tyuyx0++BlOnymwgYmMka+CcUQUPSL+tYMT6ijM+/nA=; b=S4JH6HuckZ6dz24EFhmlWaebdNmOk1897ZGg7am5xcAAjpiyhI5wXHcka/hNSmLILo K3zuRbEEItxkS/hLNtcEKnS345zAtHru9wZkT41aVe5dRdiC8xZbBKwjwfkET9x+KlhB Cas6hV5uDkG8Jbt1XbEXoARYTuxO2n+lzGV8oHG2u0LT/5wiYbukpcihTtQ1RtOeaedm nGHzanXEx8apx4iZJd/CsziUxvDmcVwWB6ahzw/K+aGGM2qgGIOR7Zp/VvsQbedRDQA4 roFdxDE0vPFqHM+Se1nYYF+/0+r6cx6rdk8k8+fJ0DDAaZw6pU88sdd0gA/UZ5cpEJ/0 hj3g== X-Received: by 10.194.87.71 with SMTP id v7mr9291562wjz.33.1370004968345; Fri, 31 May 2013 05:56:08 -0700 (PDT) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id h8sm3769026wiz.9.2013.05.31.05.56.06 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Fri, 31 May 2013 05:56:07 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org Cc: Michal Simek , Michal Simek , Arnd Bergmann , Timur Tabi , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org Subject: [PATCH v3 6/8] video: xilinxfb: Add support for little endian accesses Date: Fri, 31 May 2013 14:55:36 +0200 Message-Id: X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQmJJ/BPzVV8J3qYNNsk5HiEnoK/RAODVivXg0ORaAsELf+QRVxWy1cRgL8UJHDMCY8bX/WJ Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Dynamically detect endianess on IP and use ioread/iowrite functions instead of powerpc and microblaze specific out_be32. Signed-off-by: Michal Simek Acked-by: Arnd Bergmann --- Changes in v3: - New patch in this patchset based on discussions Changes in v2: None drivers/video/xilinxfb.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) -- 1.8.2.3 diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c index bd3b85d..f3d4a69 100644 --- a/drivers/video/xilinxfb.c +++ b/drivers/video/xilinxfb.c @@ -117,6 +117,7 @@ static struct fb_var_screeninfo xilinx_fb_var = { #define BUS_ACCESS_FLAG 0x1 /* 1 = BUS, 0 = DCR */ +#define LITTLE_ENDIAN_ACCESS 0x2 /* LITTLE ENDIAN IO functions */ struct xilinxfb_drvdata { @@ -153,14 +154,33 @@ struct xilinxfb_drvdata { static void xilinx_fb_out32(struct xilinxfb_drvdata *drvdata, u32 offset, u32 val) { - if (drvdata->flags & BUS_ACCESS_FLAG) - out_be32(drvdata->regs + (offset << 2), val); + if (drvdata->flags & BUS_ACCESS_FLAG) { + if (drvdata->flags & LITTLE_ENDIAN_ACCESS) + iowrite32(val, drvdata->regs + (offset << 2)); + else + iowrite32be(val, drvdata->regs + (offset << 2)); + } #ifdef CONFIG_PPC_DCR else dcr_write(drvdata->dcr_host, offset, val); #endif } +static u32 xilinx_fb_in32(struct xilinxfb_drvdata *drvdata, u32 offset) +{ + if (drvdata->flags & BUS_ACCESS_FLAG) { + if (drvdata->flags & LITTLE_ENDIAN_ACCESS) + return ioread32(drvdata->regs + (offset << 2)); + else + return ioread32be(drvdata->regs + (offset << 2)); + } +#ifdef CONFIG_PPC_DCR + else + return dcr_read(drvdata->dcr_host, offset); +#endif + return 0; +} + static int xilinx_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, struct fb_info *fbi) @@ -271,6 +291,12 @@ static int xilinxfb_assign(struct platform_device *pdev, /* Tell the hardware where the frame buffer is */ xilinx_fb_out32(drvdata, REG_FB_ADDR, drvdata->fb_phys); + rc = xilinx_fb_in32(drvdata, REG_FB_ADDR); + /* Endianess detection */ + if (rc != drvdata->fb_phys) { + drvdata->flags |= LITTLE_ENDIAN_ACCESS; + xilinx_fb_out32(drvdata, REG_FB_ADDR, drvdata->fb_phys); + } /* Turn on the display */ drvdata->reg_ctrl_default = REG_CTRL_ENABLE;