162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * OMAP3XXX L3 Interconnect Driver header
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2011 Texas Corporation
662306a36Sopenharmony_ci *	Felipe Balbi <balbi@ti.com>
762306a36Sopenharmony_ci *	Santosh Shilimkar <santosh.shilimkar@ti.com>
862306a36Sopenharmony_ci *	sricharan <r.sricharan@ti.com>
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci#ifndef __ARCH_ARM_MACH_OMAP2_L3_INTERCONNECT_3XXX_H
1162306a36Sopenharmony_ci#define __ARCH_ARM_MACH_OMAP2_L3_INTERCONNECT_3XXX_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* Register definitions. All 64-bit wide */
1462306a36Sopenharmony_ci#define L3_COMPONENT			0x000
1562306a36Sopenharmony_ci#define L3_CORE				0x018
1662306a36Sopenharmony_ci#define L3_AGENT_CONTROL		0x020
1762306a36Sopenharmony_ci#define L3_AGENT_STATUS			0x028
1862306a36Sopenharmony_ci#define L3_ERROR_LOG			0x058
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define L3_ERROR_LOG_MULTI		(1 << 31)
2162306a36Sopenharmony_ci#define L3_ERROR_LOG_SECONDARY		(1 << 30)
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define L3_ERROR_LOG_ADDR		0x060
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* Register definitions for Sideband Interconnect */
2662306a36Sopenharmony_ci#define L3_SI_CONTROL			0x020
2762306a36Sopenharmony_ci#define L3_SI_FLAG_STATUS_0		0x510
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_cistatic const u64 shift = 1;
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define L3_STATUS_0_MPUIA_BRST		(shift << 0)
3262306a36Sopenharmony_ci#define L3_STATUS_0_MPUIA_RSP		(shift << 1)
3362306a36Sopenharmony_ci#define L3_STATUS_0_MPUIA_INBAND	(shift << 2)
3462306a36Sopenharmony_ci#define L3_STATUS_0_IVAIA_BRST		(shift << 6)
3562306a36Sopenharmony_ci#define L3_STATUS_0_IVAIA_RSP		(shift << 7)
3662306a36Sopenharmony_ci#define L3_STATUS_0_IVAIA_INBAND	(shift << 8)
3762306a36Sopenharmony_ci#define L3_STATUS_0_SGXIA_BRST		(shift << 9)
3862306a36Sopenharmony_ci#define L3_STATUS_0_SGXIA_RSP		(shift << 10)
3962306a36Sopenharmony_ci#define L3_STATUS_0_SGXIA_MERROR	(shift << 11)
4062306a36Sopenharmony_ci#define L3_STATUS_0_CAMIA_BRST		(shift << 12)
4162306a36Sopenharmony_ci#define L3_STATUS_0_CAMIA_RSP		(shift << 13)
4262306a36Sopenharmony_ci#define L3_STATUS_0_CAMIA_INBAND	(shift << 14)
4362306a36Sopenharmony_ci#define L3_STATUS_0_DISPIA_BRST		(shift << 15)
4462306a36Sopenharmony_ci#define L3_STATUS_0_DISPIA_RSP		(shift << 16)
4562306a36Sopenharmony_ci#define L3_STATUS_0_DMARDIA_BRST	(shift << 18)
4662306a36Sopenharmony_ci#define L3_STATUS_0_DMARDIA_RSP		(shift << 19)
4762306a36Sopenharmony_ci#define L3_STATUS_0_DMAWRIA_BRST	(shift << 21)
4862306a36Sopenharmony_ci#define L3_STATUS_0_DMAWRIA_RSP		(shift << 22)
4962306a36Sopenharmony_ci#define L3_STATUS_0_USBOTGIA_BRST	(shift << 24)
5062306a36Sopenharmony_ci#define L3_STATUS_0_USBOTGIA_RSP	(shift << 25)
5162306a36Sopenharmony_ci#define L3_STATUS_0_USBOTGIA_INBAND	(shift << 26)
5262306a36Sopenharmony_ci#define L3_STATUS_0_USBHOSTIA_BRST	(shift << 27)
5362306a36Sopenharmony_ci#define L3_STATUS_0_USBHOSTIA_INBAND	(shift << 28)
5462306a36Sopenharmony_ci#define L3_STATUS_0_SMSTA_REQ		(shift << 48)
5562306a36Sopenharmony_ci#define L3_STATUS_0_GPMCTA_REQ		(shift << 49)
5662306a36Sopenharmony_ci#define L3_STATUS_0_OCMRAMTA_REQ	(shift << 50)
5762306a36Sopenharmony_ci#define L3_STATUS_0_OCMROMTA_REQ	(shift << 51)
5862306a36Sopenharmony_ci#define L3_STATUS_0_IVATA_REQ		(shift << 54)
5962306a36Sopenharmony_ci#define L3_STATUS_0_SGXTA_REQ		(shift << 55)
6062306a36Sopenharmony_ci#define L3_STATUS_0_SGXTA_SERROR	(shift << 56)
6162306a36Sopenharmony_ci#define L3_STATUS_0_GPMCTA_SERROR	(shift << 57)
6262306a36Sopenharmony_ci#define L3_STATUS_0_L4CORETA_REQ	(shift << 58)
6362306a36Sopenharmony_ci#define L3_STATUS_0_L4PERTA_REQ		(shift << 59)
6462306a36Sopenharmony_ci#define L3_STATUS_0_L4EMUTA_REQ		(shift << 60)
6562306a36Sopenharmony_ci#define L3_STATUS_0_MAD2DTA_REQ		(shift << 61)
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define L3_STATUS_0_TIMEOUT_MASK	(L3_STATUS_0_MPUIA_BRST		\
6862306a36Sopenharmony_ci					| L3_STATUS_0_MPUIA_RSP		\
6962306a36Sopenharmony_ci					| L3_STATUS_0_IVAIA_BRST	\
7062306a36Sopenharmony_ci					| L3_STATUS_0_IVAIA_RSP		\
7162306a36Sopenharmony_ci					| L3_STATUS_0_SGXIA_BRST	\
7262306a36Sopenharmony_ci					| L3_STATUS_0_SGXIA_RSP		\
7362306a36Sopenharmony_ci					| L3_STATUS_0_CAMIA_BRST	\
7462306a36Sopenharmony_ci					| L3_STATUS_0_CAMIA_RSP		\
7562306a36Sopenharmony_ci					| L3_STATUS_0_DISPIA_BRST	\
7662306a36Sopenharmony_ci					| L3_STATUS_0_DISPIA_RSP	\
7762306a36Sopenharmony_ci					| L3_STATUS_0_DMARDIA_BRST	\
7862306a36Sopenharmony_ci					| L3_STATUS_0_DMARDIA_RSP	\
7962306a36Sopenharmony_ci					| L3_STATUS_0_DMAWRIA_BRST	\
8062306a36Sopenharmony_ci					| L3_STATUS_0_DMAWRIA_RSP	\
8162306a36Sopenharmony_ci					| L3_STATUS_0_USBOTGIA_BRST	\
8262306a36Sopenharmony_ci					| L3_STATUS_0_USBOTGIA_RSP	\
8362306a36Sopenharmony_ci					| L3_STATUS_0_USBHOSTIA_BRST	\
8462306a36Sopenharmony_ci					| L3_STATUS_0_SMSTA_REQ		\
8562306a36Sopenharmony_ci					| L3_STATUS_0_GPMCTA_REQ	\
8662306a36Sopenharmony_ci					| L3_STATUS_0_OCMRAMTA_REQ	\
8762306a36Sopenharmony_ci					| L3_STATUS_0_OCMROMTA_REQ	\
8862306a36Sopenharmony_ci					| L3_STATUS_0_IVATA_REQ		\
8962306a36Sopenharmony_ci					| L3_STATUS_0_SGXTA_REQ		\
9062306a36Sopenharmony_ci					| L3_STATUS_0_L4CORETA_REQ	\
9162306a36Sopenharmony_ci					| L3_STATUS_0_L4PERTA_REQ	\
9262306a36Sopenharmony_ci					| L3_STATUS_0_L4EMUTA_REQ	\
9362306a36Sopenharmony_ci					| L3_STATUS_0_MAD2DTA_REQ)
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define L3_SI_FLAG_STATUS_1		0x530
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#define L3_STATUS_1_MPU_DATAIA		(1 << 0)
9862306a36Sopenharmony_ci#define L3_STATUS_1_DAPIA0		(1 << 3)
9962306a36Sopenharmony_ci#define L3_STATUS_1_DAPIA1		(1 << 4)
10062306a36Sopenharmony_ci#define L3_STATUS_1_IVAIA		(1 << 6)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define L3_PM_ERROR_LOG			0x020
10362306a36Sopenharmony_ci#define L3_PM_CONTROL			0x028
10462306a36Sopenharmony_ci#define L3_PM_ERROR_CLEAR_SINGLE	0x030
10562306a36Sopenharmony_ci#define L3_PM_ERROR_CLEAR_MULTI		0x038
10662306a36Sopenharmony_ci#define L3_PM_REQ_INFO_PERMISSION(n)	(0x048 + (0x020 * n))
10762306a36Sopenharmony_ci#define L3_PM_READ_PERMISSION(n)	(0x050 + (0x020 * n))
10862306a36Sopenharmony_ci#define L3_PM_WRITE_PERMISSION(n)	(0x058 + (0x020 * n))
10962306a36Sopenharmony_ci#define L3_PM_ADDR_MATCH(n)		(0x060 + (0x020 * n))
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci/* L3 error log bit fields. Common for IA and TA */
11262306a36Sopenharmony_ci#define L3_ERROR_LOG_CODE		24
11362306a36Sopenharmony_ci#define L3_ERROR_LOG_INITID		8
11462306a36Sopenharmony_ci#define L3_ERROR_LOG_CMD		0
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci/* L3 agent status bit fields. */
11762306a36Sopenharmony_ci#define L3_AGENT_STATUS_CLEAR_IA	0x10000000
11862306a36Sopenharmony_ci#define L3_AGENT_STATUS_CLEAR_TA	0x01000000
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci#define OMAP34xx_IRQ_L3_APP		10
12162306a36Sopenharmony_ci#define L3_APPLICATION_ERROR		0x0
12262306a36Sopenharmony_ci#define L3_DEBUG_ERROR			0x1
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_cienum omap3_l3_initiator_id {
12562306a36Sopenharmony_ci	/* LCD has 1 ID */
12662306a36Sopenharmony_ci	OMAP_L3_LCD = 29,
12762306a36Sopenharmony_ci	/* SAD2D has 1 ID */
12862306a36Sopenharmony_ci	OMAP_L3_SAD2D = 28,
12962306a36Sopenharmony_ci	/* MPU has 5 IDs */
13062306a36Sopenharmony_ci	OMAP_L3_IA_MPU_SS_1 = 27,
13162306a36Sopenharmony_ci	OMAP_L3_IA_MPU_SS_2 = 26,
13262306a36Sopenharmony_ci	OMAP_L3_IA_MPU_SS_3 = 25,
13362306a36Sopenharmony_ci	OMAP_L3_IA_MPU_SS_4 = 24,
13462306a36Sopenharmony_ci	OMAP_L3_IA_MPU_SS_5 = 23,
13562306a36Sopenharmony_ci	/* IVA2.2 SS has 3 IDs*/
13662306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_1 = 22,
13762306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_2 = 21,
13862306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_3 = 20,
13962306a36Sopenharmony_ci	/* IVA 2.2 SS DMA has 6 IDS */
14062306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_1 = 19,
14162306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_2 = 18,
14262306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_3 = 17,
14362306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_4 = 16,
14462306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_5 = 15,
14562306a36Sopenharmony_ci	OMAP_L3_IA_IVA_SS_DMA_6 = 14,
14662306a36Sopenharmony_ci	/* SGX has 1 ID */
14762306a36Sopenharmony_ci	OMAP_L3_IA_SGX = 13,
14862306a36Sopenharmony_ci	/* CAM has 3 ID */
14962306a36Sopenharmony_ci	OMAP_L3_IA_CAM_1 = 12,
15062306a36Sopenharmony_ci	OMAP_L3_IA_CAM_2 = 11,
15162306a36Sopenharmony_ci	OMAP_L3_IA_CAM_3 = 10,
15262306a36Sopenharmony_ci	/* DAP has 1 ID */
15362306a36Sopenharmony_ci	OMAP_L3_IA_DAP = 9,
15462306a36Sopenharmony_ci	/* SDMA WR has 2 IDs */
15562306a36Sopenharmony_ci	OMAP_L3_SDMA_WR_1 = 8,
15662306a36Sopenharmony_ci	OMAP_L3_SDMA_WR_2 = 7,
15762306a36Sopenharmony_ci	/* SDMA RD has 4 IDs */
15862306a36Sopenharmony_ci	OMAP_L3_SDMA_RD_1 = 6,
15962306a36Sopenharmony_ci	OMAP_L3_SDMA_RD_2 = 5,
16062306a36Sopenharmony_ci	OMAP_L3_SDMA_RD_3 = 4,
16162306a36Sopenharmony_ci	OMAP_L3_SDMA_RD_4 = 3,
16262306a36Sopenharmony_ci	/* HSUSB OTG has 1 ID */
16362306a36Sopenharmony_ci	OMAP_L3_USBOTG = 2,
16462306a36Sopenharmony_ci	/* HSUSB HOST has 1 ID */
16562306a36Sopenharmony_ci	OMAP_L3_USBHOST = 1,
16662306a36Sopenharmony_ci};
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cienum omap3_l3_code {
16962306a36Sopenharmony_ci	OMAP_L3_CODE_NOERROR = 0,
17062306a36Sopenharmony_ci	OMAP_L3_CODE_UNSUP_CMD = 1,
17162306a36Sopenharmony_ci	OMAP_L3_CODE_ADDR_HOLE = 2,
17262306a36Sopenharmony_ci	OMAP_L3_CODE_PROTECT_VIOLATION = 3,
17362306a36Sopenharmony_ci	OMAP_L3_CODE_IN_BAND_ERR = 4,
17462306a36Sopenharmony_ci	/* codes 5 and 6 are reserved */
17562306a36Sopenharmony_ci	OMAP_L3_CODE_REQ_TOUT_NOT_ACCEPT = 7,
17662306a36Sopenharmony_ci	OMAP_L3_CODE_REQ_TOUT_NO_RESP = 8,
17762306a36Sopenharmony_ci	/* codes 9 - 15 are also reserved */
17862306a36Sopenharmony_ci};
17962306a36Sopenharmony_ci
18062306a36Sopenharmony_cistruct omap3_l3 {
18162306a36Sopenharmony_ci	struct device *dev;
18262306a36Sopenharmony_ci	struct clk *ick;
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci	/* memory base*/
18562306a36Sopenharmony_ci	void __iomem *rt;
18662306a36Sopenharmony_ci
18762306a36Sopenharmony_ci	int debug_irq;
18862306a36Sopenharmony_ci	int app_irq;
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci	/* true when and inband functional error occurs */
19162306a36Sopenharmony_ci	unsigned inband:1;
19262306a36Sopenharmony_ci};
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci/* offsets for l3 agents in order with the Flag status register */
19562306a36Sopenharmony_cistatic unsigned int omap3_l3_app_bases[] = {
19662306a36Sopenharmony_ci	/* MPU IA */
19762306a36Sopenharmony_ci	0x1400,
19862306a36Sopenharmony_ci	0x1400,
19962306a36Sopenharmony_ci	0x1400,
20062306a36Sopenharmony_ci	/* RESERVED */
20162306a36Sopenharmony_ci	0,
20262306a36Sopenharmony_ci	0,
20362306a36Sopenharmony_ci	0,
20462306a36Sopenharmony_ci	/* IVA 2.2 IA */
20562306a36Sopenharmony_ci	0x1800,
20662306a36Sopenharmony_ci	0x1800,
20762306a36Sopenharmony_ci	0x1800,
20862306a36Sopenharmony_ci	/* SGX IA */
20962306a36Sopenharmony_ci	0x1c00,
21062306a36Sopenharmony_ci	0x1c00,
21162306a36Sopenharmony_ci	/* RESERVED */
21262306a36Sopenharmony_ci	0,
21362306a36Sopenharmony_ci	/* CAMERA IA */
21462306a36Sopenharmony_ci	0x5800,
21562306a36Sopenharmony_ci	0x5800,
21662306a36Sopenharmony_ci	0x5800,
21762306a36Sopenharmony_ci	/* DISPLAY IA */
21862306a36Sopenharmony_ci	0x5400,
21962306a36Sopenharmony_ci	0x5400,
22062306a36Sopenharmony_ci	/* RESERVED */
22162306a36Sopenharmony_ci	0,
22262306a36Sopenharmony_ci	/*SDMA RD IA */
22362306a36Sopenharmony_ci	0x4c00,
22462306a36Sopenharmony_ci	0x4c00,
22562306a36Sopenharmony_ci	/* RESERVED */
22662306a36Sopenharmony_ci	0,
22762306a36Sopenharmony_ci	/* SDMA WR IA */
22862306a36Sopenharmony_ci	0x5000,
22962306a36Sopenharmony_ci	0x5000,
23062306a36Sopenharmony_ci	/* RESERVED */
23162306a36Sopenharmony_ci	0,
23262306a36Sopenharmony_ci	/* USB OTG IA */
23362306a36Sopenharmony_ci	0x4400,
23462306a36Sopenharmony_ci	0x4400,
23562306a36Sopenharmony_ci	0x4400,
23662306a36Sopenharmony_ci	/* USB HOST IA */
23762306a36Sopenharmony_ci	0x4000,
23862306a36Sopenharmony_ci	0x4000,
23962306a36Sopenharmony_ci	/* RESERVED */
24062306a36Sopenharmony_ci	0,
24162306a36Sopenharmony_ci	0,
24262306a36Sopenharmony_ci	0,
24362306a36Sopenharmony_ci	0,
24462306a36Sopenharmony_ci	/* SAD2D IA */
24562306a36Sopenharmony_ci	0x3000,
24662306a36Sopenharmony_ci	0x3000,
24762306a36Sopenharmony_ci	0x3000,
24862306a36Sopenharmony_ci	/* RESERVED */
24962306a36Sopenharmony_ci	0,
25062306a36Sopenharmony_ci	0,
25162306a36Sopenharmony_ci	0,
25262306a36Sopenharmony_ci	0,
25362306a36Sopenharmony_ci	0,
25462306a36Sopenharmony_ci	0,
25562306a36Sopenharmony_ci	0,
25662306a36Sopenharmony_ci	0,
25762306a36Sopenharmony_ci	0,
25862306a36Sopenharmony_ci	0,
25962306a36Sopenharmony_ci	0,
26062306a36Sopenharmony_ci	0,
26162306a36Sopenharmony_ci	/* SMA TA */
26262306a36Sopenharmony_ci	0x2000,
26362306a36Sopenharmony_ci	/* GPMC TA */
26462306a36Sopenharmony_ci	0x2400,
26562306a36Sopenharmony_ci	/* OCM RAM TA */
26662306a36Sopenharmony_ci	0x2800,
26762306a36Sopenharmony_ci	/* OCM ROM TA */
26862306a36Sopenharmony_ci	0x2C00,
26962306a36Sopenharmony_ci	/* L4 CORE TA */
27062306a36Sopenharmony_ci	0x6800,
27162306a36Sopenharmony_ci	/* L4 PER TA */
27262306a36Sopenharmony_ci	0x6c00,
27362306a36Sopenharmony_ci	/* IVA 2.2 TA */
27462306a36Sopenharmony_ci	0x6000,
27562306a36Sopenharmony_ci	/* SGX TA */
27662306a36Sopenharmony_ci	0x6400,
27762306a36Sopenharmony_ci	/* L4 EMU TA */
27862306a36Sopenharmony_ci	0x7000,
27962306a36Sopenharmony_ci	/* GPMC TA */
28062306a36Sopenharmony_ci	0x2400,
28162306a36Sopenharmony_ci	/* L4 CORE TA */
28262306a36Sopenharmony_ci	0x6800,
28362306a36Sopenharmony_ci	/* L4 PER TA */
28462306a36Sopenharmony_ci	0x6c00,
28562306a36Sopenharmony_ci	/* L4 EMU TA */
28662306a36Sopenharmony_ci	0x7000,
28762306a36Sopenharmony_ci	/* MAD2D TA */
28862306a36Sopenharmony_ci	0x3400,
28962306a36Sopenharmony_ci	/* RESERVED */
29062306a36Sopenharmony_ci	0,
29162306a36Sopenharmony_ci	0,
29262306a36Sopenharmony_ci};
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_cistatic unsigned int omap3_l3_debug_bases[] = {
29562306a36Sopenharmony_ci	/* MPU DATA IA */
29662306a36Sopenharmony_ci	0x1400,
29762306a36Sopenharmony_ci	/* RESERVED */
29862306a36Sopenharmony_ci	0,
29962306a36Sopenharmony_ci	0,
30062306a36Sopenharmony_ci	/* DAP IA */
30162306a36Sopenharmony_ci	0x5c00,
30262306a36Sopenharmony_ci	0x5c00,
30362306a36Sopenharmony_ci	/* RESERVED */
30462306a36Sopenharmony_ci	0,
30562306a36Sopenharmony_ci	/* IVA 2.2 IA */
30662306a36Sopenharmony_ci	0x1800,
30762306a36Sopenharmony_ci	/* REST RESERVED */
30862306a36Sopenharmony_ci};
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_cistatic u32 *omap3_l3_bases[] = {
31162306a36Sopenharmony_ci	omap3_l3_app_bases,
31262306a36Sopenharmony_ci	omap3_l3_debug_bases,
31362306a36Sopenharmony_ci};
31462306a36Sopenharmony_ci
31562306a36Sopenharmony_ci/*
31662306a36Sopenharmony_ci * REVISIT define __raw_readll/__raw_writell here, but move them to
31762306a36Sopenharmony_ci * <asm/io.h> at some point
31862306a36Sopenharmony_ci */
31962306a36Sopenharmony_ci#define __raw_writell(v, a)	(__chk_io_ptr(a), \
32062306a36Sopenharmony_ci				*(volatile u64 __force *)(a) = (v))
32162306a36Sopenharmony_ci#define __raw_readll(a)		(__chk_io_ptr(a), \
32262306a36Sopenharmony_ci				*(volatile u64 __force *)(a))
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci#endif
325