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