162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * arch/arm/mach-ep93xx/include/mach/ts72xx.h
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci/*
762306a36Sopenharmony_ci * TS72xx memory map:
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * virt		phys		size
1062306a36Sopenharmony_ci * febff000	22000000	4K	model number register (bits 0-2)
1162306a36Sopenharmony_ci * febfe000	22400000	4K	options register
1262306a36Sopenharmony_ci * febfd000	22800000	4K	options register #2
1362306a36Sopenharmony_ci * febfc000     23400000        4K      CPLD version register
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#ifndef __TS72XX_H_
1762306a36Sopenharmony_ci#define __TS72XX_H_
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#define TS72XX_MODEL_PHYS_BASE		0x22000000
2062306a36Sopenharmony_ci#define TS72XX_MODEL_VIRT_BASE		IOMEM(0xfebff000)
2162306a36Sopenharmony_ci#define TS72XX_MODEL_SIZE		0x00001000
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci#define TS72XX_MODEL_TS7200		0x00
2462306a36Sopenharmony_ci#define TS72XX_MODEL_TS7250		0x01
2562306a36Sopenharmony_ci#define TS72XX_MODEL_TS7260		0x02
2662306a36Sopenharmony_ci#define TS72XX_MODEL_TS7300		0x03
2762306a36Sopenharmony_ci#define TS72XX_MODEL_TS7400		0x04
2862306a36Sopenharmony_ci#define TS72XX_MODEL_MASK		0x07
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define TS72XX_OPTIONS_PHYS_BASE	0x22400000
3262306a36Sopenharmony_ci#define TS72XX_OPTIONS_VIRT_BASE	IOMEM(0xfebfe000)
3362306a36Sopenharmony_ci#define TS72XX_OPTIONS_SIZE		0x00001000
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define TS72XX_OPTIONS_COM2_RS485	0x02
3662306a36Sopenharmony_ci#define TS72XX_OPTIONS_MAX197		0x01
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define TS72XX_OPTIONS2_PHYS_BASE	0x22800000
4062306a36Sopenharmony_ci#define TS72XX_OPTIONS2_VIRT_BASE	IOMEM(0xfebfd000)
4162306a36Sopenharmony_ci#define TS72XX_OPTIONS2_SIZE		0x00001000
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#define TS72XX_OPTIONS2_TS9420		0x04
4462306a36Sopenharmony_ci#define TS72XX_OPTIONS2_TS9420_BOOT	0x02
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define TS72XX_CPLDVER_PHYS_BASE	0x23400000
4762306a36Sopenharmony_ci#define TS72XX_CPLDVER_VIRT_BASE	IOMEM(0xfebfc000)
4862306a36Sopenharmony_ci#define TS72XX_CPLDVER_SIZE		0x00001000
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#ifndef __ASSEMBLY__
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistatic inline int ts72xx_model(void)
5362306a36Sopenharmony_ci{
5462306a36Sopenharmony_ci	return __raw_readb(TS72XX_MODEL_VIRT_BASE) & TS72XX_MODEL_MASK;
5562306a36Sopenharmony_ci}
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistatic inline int board_is_ts7200(void)
5862306a36Sopenharmony_ci{
5962306a36Sopenharmony_ci	return ts72xx_model() == TS72XX_MODEL_TS7200;
6062306a36Sopenharmony_ci}
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistatic inline int board_is_ts7250(void)
6362306a36Sopenharmony_ci{
6462306a36Sopenharmony_ci	return ts72xx_model() == TS72XX_MODEL_TS7250;
6562306a36Sopenharmony_ci}
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistatic inline int board_is_ts7260(void)
6862306a36Sopenharmony_ci{
6962306a36Sopenharmony_ci	return ts72xx_model() == TS72XX_MODEL_TS7260;
7062306a36Sopenharmony_ci}
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_cistatic inline int board_is_ts7300(void)
7362306a36Sopenharmony_ci{
7462306a36Sopenharmony_ci	return ts72xx_model()  == TS72XX_MODEL_TS7300;
7562306a36Sopenharmony_ci}
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_cistatic inline int board_is_ts7400(void)
7862306a36Sopenharmony_ci{
7962306a36Sopenharmony_ci	return ts72xx_model() == TS72XX_MODEL_TS7400;
8062306a36Sopenharmony_ci}
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_cistatic inline int is_max197_installed(void)
8362306a36Sopenharmony_ci{
8462306a36Sopenharmony_ci	return !!(__raw_readb(TS72XX_OPTIONS_VIRT_BASE) &
8562306a36Sopenharmony_ci					TS72XX_OPTIONS_MAX197);
8662306a36Sopenharmony_ci}
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistatic inline int is_ts9420_installed(void)
8962306a36Sopenharmony_ci{
9062306a36Sopenharmony_ci	return !!(__raw_readb(TS72XX_OPTIONS2_VIRT_BASE) &
9162306a36Sopenharmony_ci					TS72XX_OPTIONS2_TS9420);
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci#endif
9462306a36Sopenharmony_ci#endif /* __TS72XX_H_ */
95