summaryrefslogtreecommitdiffstats
path: root/external/common/arch_flash_arm_io.h
blob: a1ee1f3abe3e82ded76ebb65312274776b1867bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef __IO_H
#define __IO_H

#include <assert.h>
#include <stdint.h>
#include <stdbool.h>

#include <libflash/libflash.h>

/* AST AHB register base */
#define AHB_REGS_BASE		0x1E600000
#define AHB_REGS_SIZE		0x00200000

/* AST GPIO control regs */
#define GPIO_CTRL_BASE		0x1E780000
#define GPIO_CTRL_SIZE		0x1000

/* AST AHB mapping of PNOR */
#define PNOR_FLASH_BASE		0x30000000
#define PNOR_FLASH_SIZE		0x04000000

/* AST AHB mapping of BMC flash */
#define BMC_FLASH_BASE		0x20000000
#define BMC_FLASH_SIZE		0x04000000

/* Address of flash mapping on LPC FW space */
#define LPC_FLASH_BASE		0x0e000000
#define LPC_CTRL_BASE		0x1e789000

static inline uint8_t readb(void *addr)
{
	asm volatile("" : : : "memory");
	return *(volatile uint8_t *)addr;
}

static inline uint16_t readw(void *addr)
{
	asm volatile("" : : : "memory");
	return *(volatile uint16_t *)addr;
}

static inline uint32_t readl(void *addr)
{
	asm volatile("" : : : "memory");
	return *(volatile uint32_t *)addr;
}

static inline void writeb(uint8_t val, void *addr)
{
	asm volatile("" : : : "memory");
	*(volatile uint8_t *)addr = val;
}

static inline void writew(uint16_t val, void *addr)
{
	asm volatile("" : : : "memory");
	*(volatile uint16_t *)addr = val;
}

static inline void writel(uint32_t val, void *addr)
{
	asm volatile("" : : : "memory");
	*(volatile uint32_t *)addr = val;
}

/*
 * AHB register and flash access
 */

extern uint32_t ast_ahb_readl(uint32_t offset);
extern void ast_ahb_writel(uint32_t val, uint32_t offset);
extern int ast_copy_to_ahb(uint32_t reg, const void *src, uint32_t len);
extern int ast_copy_from_ahb(void *dst, uint32_t reg, uint32_t len);

static inline void check_platform(bool *has_sfc, bool *has_ast)
{
	*has_sfc = false;
	*has_ast = true;
}

#endif /* __IO_H */

OpenPOWER on IntegriCloud