1 // license:BSD-3-Clause
2 // copyright-holders:David Haywood
3 
4 #ifndef MAME_CPU_ARM7_LPC2103_H
5 #define MAME_CPU_ARM7_LPC2103_H
6 
7 #pragma once
8 
9 #include "arm7.h"
10 #include "arm7core.h"
11 
12 /***************************************************************************
13     DEVICE CONFIGURATION MACROS
14 ***************************************************************************/
15 
16 
17 /***************************************************************************
18     TYPE DEFINITIONS
19 ***************************************************************************/
20 
21 class lpc210x_device : public arm7_cpu_device
22 {
23 public:
24 	lpc210x_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t);
25 
26 	uint32_t arm_E01FC088_r();
27 	uint32_t flash_r(offs_t offset);
28 	void flash_w(offs_t offset, uint32_t data);
29 
30 	// timer 0 / 1
31 	uint32_t timer0_r(offs_t offset, uint32_t mem_mask = ~0) { return read_timer(0, offset, mem_mask); }
32 	void timer0_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0) { write_timer(0, offset, data, mem_mask); }
33 
34 	uint32_t timer1_r(offs_t offset, uint32_t mem_mask = ~0) { return read_timer(1, offset, mem_mask); }
35 	void timer1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0) { write_timer(1, offset, data, mem_mask); }
36 
37 	void write_timer(int timer, int offset, uint32_t data, uint32_t mem_mask);
38 	uint32_t read_timer(int timer, int offset, uint32_t mem_mask);
39 
40 	// VIC
41 	uint32_t vic_r(offs_t offset, uint32_t mem_mask = ~0);
42 	void vic_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
43 
44 	// PIN select block
45 	uint32_t pin_r(offs_t offset, uint32_t mem_mask = ~0);
46 	void pin_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
47 
48 	//PLL Phase Locked Loop
49 	uint32_t pll_r(offs_t offset, uint32_t mem_mask = ~0);
50 	void pll_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
51 
52 	//MAM memory controller
53 	uint32_t mam_r(offs_t offset, uint32_t mem_mask = ~0);
54 	void mam_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
55 
56 	//APB divider
57 	uint32_t apbdiv_r(offs_t offset, uint32_t mem_mask = ~0);
58 	void apbdiv_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
59 
60 	//syscon misc
61 	uint32_t scs_r(offs_t offset, uint32_t mem_mask = ~0);
62 	void scs_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
63 
64 	// fio
65 	uint32_t fio_r(offs_t offset, uint32_t mem_mask = ~0);
66 	void fio_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
67 
68 	// todo, use an appropriate flash type instead
69 	uint8_t m_flash[0x8000]; // needs to be public because the harmony/melody device injects contents with memcpy, yuck
70 
71 	void lpc2103_map(address_map &map);
72 protected:
73 	// device-level overrides
74 	virtual void device_add_mconfig(machine_config &config) override;
75 	virtual void device_start() override;
76 	virtual void device_reset() override;
77 
78 	virtual space_config_vector memory_space_config() const override;
79 
80 	uint32_t m_TxPR[2];
81 
82 private:
83 	address_space_config m_program_config;
84 };
85 
86 
87 // device type definition
88 DECLARE_DEVICE_TYPE(LPC2103, lpc210x_device)
89 
90 #endif // MAME_CPU_ARM7_LPC2103_H
91