From patchwork Fri Aug 24 16:17:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 1371961 Return-Path: X-Original-To: patchwork-linux-media@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 7AD70DF28C for ; Fri, 24 Aug 2012 16:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759809Ab2HXQSL (ORCPT ); Fri, 24 Aug 2012 12:18:11 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:49281 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759703Ab2HXQSI (ORCPT ); Fri, 24 Aug 2012 12:18:08 -0400 Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1T4waD-0000Zn-Fk; Fri, 24 Aug 2012 18:18:05 +0200 From: Philipp Zabel To: linux-media@vger.kernel.org Cc: Javier Martin , Mauro Carvalho Chehab , Richard Zhao , Laurent Pinchart , Sylwester Nawrocki , Kyungmin Park , Hans Verkuil , kernel@pengutronix.de, Philipp Zabel Subject: [PATCH 01/12] coda: firmware loading for 64-bit AXI bus width Date: Fri, 24 Aug 2012 18:17:47 +0200 Message-Id: <1345825078-3688-2-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1345825078-3688-1-git-send-email-p.zabel@pengutronix.de> References: <1345825078-3688-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for loading a raw firmware with 16-bit chars ordered in little-endian 64-bit words, corresponding to the memory access pattern of CODA7 and above: When writing the boot code into the code download register, the chars have to be reordered back. Signed-off-by: Philipp Zabel --- drivers/media/video/coda.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/media/video/coda.c b/drivers/media/video/coda.c index 0d6e0a0..86dae17 100644 --- a/drivers/media/video/coda.c +++ b/drivers/media/video/coda.c @@ -1510,7 +1510,7 @@ static char *coda_product_name(int product) } } -static int coda_hw_init(struct coda_dev *dev, const struct firmware *fw) +static int coda_hw_init(struct coda_dev *dev) { u16 product, major, minor, release; u32 data; @@ -1520,21 +1520,27 @@ static int coda_hw_init(struct coda_dev *dev, const struct firmware *fw) clk_prepare_enable(dev->clk_per); clk_prepare_enable(dev->clk_ahb); - /* Copy the whole firmware image to the code buffer */ - memcpy(dev->codebuf.vaddr, fw->data, fw->size); /* * Copy the first CODA_ISRAM_SIZE in the internal SRAM. - * This memory seems to be big-endian here, which is weird, since - * the internal ARM processor of the coda is little endian. + * The 16-bit chars in the code buffer are in memory access + * order, re-sort them to CODA order for register download. * Data in this SRAM survives a reboot. */ - p = (u16 *)fw->data; - for (i = 0; i < (CODA_ISRAM_SIZE / 2); i++) { - data = CODA_DOWN_ADDRESS_SET(i) | - CODA_DOWN_DATA_SET(p[i ^ 1]); - coda_write(dev, data, CODA_REG_BIT_CODE_DOWN); + p = (u16 *)dev->codebuf.vaddr; + if (dev->devtype->product == CODA_DX6) { + for (i = 0; i < (CODA_ISRAM_SIZE / 2); i++) { + data = CODA_DOWN_ADDRESS_SET(i) | + CODA_DOWN_DATA_SET(p[i ^ 1]); + coda_write(dev, data, CODA_REG_BIT_CODE_DOWN); + } + } else { + for (i = 0; i < (CODA_ISRAM_SIZE / 2); i++) { + data = CODA_DOWN_ADDRESS_SET(i) | + CODA_DOWN_DATA_SET(p[round_down(i, 4) + + 3 - (i % 4)]); + coda_write(dev, data, CODA_REG_BIT_CODE_DOWN); + } } - release_firmware(fw); /* Tell the BIT where to find everything it needs */ coda_write(dev, dev->workbuf.paddr, @@ -1630,7 +1636,11 @@ static void coda_fw_callback(const struct firmware *fw, void *context) return; } - ret = coda_hw_init(dev, fw); + /* Copy the whole firmware image to the code buffer */ + memcpy(dev->codebuf.vaddr, fw->data, fw->size); + release_firmware(fw); + + ret = coda_hw_init(dev); if (ret) { v4l2_err(&dev->v4l2_dev, "HW initialization failed\n"); return;