blob: 95a595ab8d418c6c9275eb0cf77399352a1ec1c5 [file] [log] [blame]
Hans de Goede66ebea02014-11-29 13:38:35 +01001/*
2 * (C) Copyright 2014 Hans de Goede <hdegoede@redhat.com>
3 *
4 * Based on allwinner u-boot sources rsb code which is:
5 * (C) Copyright 2007-2013
6 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
7 * lixiang <lixiang@allwinnertech.com>
8 *
9 * SPDX-License-Identifier: GPL-2.0+
10 */
11
12#ifndef __SUNXI_RSB_H
13#define __SUNXI_RSB_H
14
15#include <common.h>
16#include <asm/io.h>
17
18struct sunxi_rsb_reg {
19 u32 ctrl; /* 0x00 */
20 u32 ccr; /* 0x04 */
21 u32 inte; /* 0x08 */
22 u32 stat; /* 0x0c */
23 u32 addr; /* 0x10 */
24 u8 res0[8]; /* 0x14 */
25 u32 data; /* 0x1c */
26 u8 res1[4]; /* 0x20 */
27 u32 lcr; /* 0x24 */
28 u32 dmcr; /* 0x28 */
29 u32 cmd; /* 0x2c */
30 u32 devaddr; /* 0x30 */
31};
32
33#define RSB_CTRL_SOFT_RST (1 << 0)
34#define RSB_CTRL_START_TRANS (1 << 7)
35
36#define RSB_STAT_TOVER_INT (1 << 0)
37#define RSB_STAT_TERR_INT (1 << 1)
38#define RSB_STAT_LBSY_INT (1 << 2)
39
40#define RSB_DMCR_DEVICE_MODE_START (1 << 31)
41
42#define RSB_CMD_BYTE_WRITE 0x4e
43#define RSB_CMD_BYTE_READ 0x8b
44#define RSB_CMD_SET_RTSADDR 0xe8
45
46#define RSB_DEVADDR_RUNTIME_ADDR(x) ((x) << 16)
47#define RSB_DEVADDR_DEVICE_ADDR(x) ((x) << 0)
48
49void rsb_init(void);
50int rsb_set_device_mode(u32 device_mode_data);
51int rsb_set_device_address(u16 device_addr, u16 runtime_addr);
52int rsb_write(const u16 runtime_device_addr, const u8 reg_addr, u8 data);
53int rsb_read(const u16 runtime_device_addr, const u8 reg_addr, u8 *data);
54
55#endif