blob: dd4c546222d57acc9312acc8c616ada0caf6364d [file] [log] [blame]
Neil Armstrongadd986c2018-07-24 17:45:28 +02001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Amlogic Meson Video Processing Unit driver
4 *
5 * Copyright (c) 2018 BayLibre, SAS.
6 * Author: Neil Armstrong <narmstrong@baylibre.com>
7 */
8
Simon Glassf74c7bd2019-10-27 09:54:03 -06009#include <dm.h>
10#include <asm/io.h>
11
Neil Armstrongadd986c2018-07-24 17:45:28 +020012#include "meson_vpu.h"
13
14/* DMC Registers */
15#define DMC_CAV_LUT_DATAL 0x48 /* 0x12 offset in data sheet */
16#define CANVAS_WIDTH_LBIT 29
17#define CANVAS_WIDTH_LWID 3
18#define DMC_CAV_LUT_DATAH 0x4c /* 0x13 offset in data sheet */
19#define CANVAS_WIDTH_HBIT 0
20#define CANVAS_HEIGHT_BIT 9
21#define CANVAS_BLKMODE_BIT 24
22#define DMC_CAV_LUT_ADDR 0x50 /* 0x14 offset in data sheet */
23#define CANVAS_LUT_WR_EN (0x2 << 8)
24#define CANVAS_LUT_RD_EN (0x1 << 8)
25
26void meson_canvas_setup(struct meson_vpu_priv *priv,
27 u32 canvas_index, u32 addr,
28 u32 stride, u32 height,
29 unsigned int wrap,
30 unsigned int blkmode)
31{
32 dmc_write(DMC_CAV_LUT_DATAL,
33 (((addr + 7) >> 3)) |
34 (((stride + 7) >> 3) << CANVAS_WIDTH_LBIT));
35
36 dmc_write(DMC_CAV_LUT_DATAH,
37 ((((stride + 7) >> 3) >> CANVAS_WIDTH_LWID) <<
38 CANVAS_WIDTH_HBIT) |
39 (height << CANVAS_HEIGHT_BIT) |
40 (wrap << 22) |
41 (blkmode << CANVAS_BLKMODE_BIT));
42
43 dmc_write(DMC_CAV_LUT_ADDR,
44 CANVAS_LUT_WR_EN | canvas_index);
45
46 /* Force a read-back to make sure everything is flushed. */
47 dmc_read(DMC_CAV_LUT_DATAH);
48}