dt-bindings: mtd: ingenic: Use standard ecc-engine property
[linux/fpc-iii.git] / drivers / gpu / drm / meson / meson_canvas.c
blob5de11aa7c775ec8f191c7d3bc1b740f2b1ecfb28
1 /*
2 * Copyright (C) 2016 BayLibre, SAS
3 * Author: Neil Armstrong <narmstrong@baylibre.com>
4 * Copyright (C) 2015 Amlogic, Inc. All rights reserved.
5 * Copyright (C) 2014 Endless Mobile
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include "meson_drv.h"
24 #include "meson_canvas.h"
25 #include "meson_registers.h"
27 /**
28 * DOC: Canvas
30 * CANVAS is a memory zone where physical memory frames information
31 * are stored for the VIU to scanout.
34 /* DMC Registers */
35 #define DMC_CAV_LUT_DATAL 0x48 /* 0x12 offset in data sheet */
36 #define CANVAS_WIDTH_LBIT 29
37 #define CANVAS_WIDTH_LWID 3
38 #define DMC_CAV_LUT_DATAH 0x4c /* 0x13 offset in data sheet */
39 #define CANVAS_WIDTH_HBIT 0
40 #define CANVAS_HEIGHT_BIT 9
41 #define CANVAS_BLKMODE_BIT 24
42 #define CANVAS_ENDIAN_BIT 26
43 #define DMC_CAV_LUT_ADDR 0x50 /* 0x14 offset in data sheet */
44 #define CANVAS_LUT_WR_EN (0x2 << 8)
45 #define CANVAS_LUT_RD_EN (0x1 << 8)
47 void meson_canvas_setup(struct meson_drm *priv,
48 uint32_t canvas_index, uint32_t addr,
49 uint32_t stride, uint32_t height,
50 unsigned int wrap,
51 unsigned int blkmode,
52 unsigned int endian)
54 unsigned int val;
56 regmap_write(priv->dmc, DMC_CAV_LUT_DATAL,
57 (((addr + 7) >> 3)) |
58 (((stride + 7) >> 3) << CANVAS_WIDTH_LBIT));
60 regmap_write(priv->dmc, DMC_CAV_LUT_DATAH,
61 ((((stride + 7) >> 3) >> CANVAS_WIDTH_LWID) <<
62 CANVAS_WIDTH_HBIT) |
63 (height << CANVAS_HEIGHT_BIT) |
64 (wrap << 22) |
65 (blkmode << CANVAS_BLKMODE_BIT) |
66 (endian << CANVAS_ENDIAN_BIT));
68 regmap_write(priv->dmc, DMC_CAV_LUT_ADDR,
69 CANVAS_LUT_WR_EN | canvas_index);
71 /* Force a read-back to make sure everything is flushed. */
72 regmap_read(priv->dmc, DMC_CAV_LUT_DATAH, &val);