0
     ˆÂÁ„_iß_†I|¥�+ÀÄ .«    /* SPDX-License-Identifier: GPL-2.0 */
#ifndef STICORE_H
#define STICORE_H

struct device;

/* generic STI structures & functions */

#define MAX_STI_ROMS 4		/* max no. of ROMs which this driver handles */

#define STI_REGION_MAX 8	/* hardcoded STI constants */
#define STI_DEV_NAME_LENGTH 32
#define STI_MONITOR_MAX 256

#define STI_FONT_HPROMAN8 1
#define STI_FONT_KANA8 2

#define ALT_CODE_TYPE_UNKNOWN 0x00	/* alt code type values */
#define ALT_CODE_TYPE_PA_RISC_64 0x01

/* The latency of the STI functions cannot really be reduced by setting
 * this to 0;  STI doesn't seem to be designed to allow calling a different
 * function (or the same function with different arguments) after a
 * function exited with 1 as return value.
 *
 * As all of the functions below could be called from interrupt context,
 * we have to spin_lock_irqsave around the do { ret = bla(); } while(ret==1)
 * block.  Really bad latency there.
 *
 * Probably the best solution to all this is have the generic code manage
 * the screen buffer and a kernel thread to call STI occasionally.
 * 
 * Luckily, the frame buffer guys have the same problem so we can just wait
 * for them to fix it and steal their solution.   prumpf
 */
 
#include <asm/io.h>

#define STI_WAIT 1

#define STI_PTR(p)	( virt_to_phys(p) )
#define PTR_STI(p)	( phys_to_virt((unsigned long)p) )

#define sti_onscreen_x(sti) (sti->glob_cfg->onscreen_x)
#define sti_onscreen_y(sti) (sti->glob_cfg->onscreen_y)

/* sti_font_xy() use the native font ROM ! */
#define sti_font_x(sti) (PTR_STI(sti->font)->width)
#define sti_font_y(sti) (PTR_STI(sti->font)->height)

#ifdef CONFIG_64BIT
#define STI_LOWMEM	(GFP_KERNEL | GFP_DMA)
#else
#define STI_LOWMEM	(GFP_KERNEL)
#endif


/* STI function configuration structs */

typedef union region {
	struct { 
		u32 offset	: 14;	/* offset in 4kbyte page */
		u32 sys_only	: 1;	/* don't map to user space */
		u32 cache	: 1;	/* map to data cache */
		u32 btlb	: 1;	/* map to block tlb */
		u32 last	: 1;	/* last region in list */
		u32 length	: 14;	/* length in 4kbyte page */
	} region_desc;

	u32 region;			/* complete region value */
} region_t;

#define REGION_OFFSET_TO_PHYS( rt, hpa ) \
	(((rt).region_desc.offset << 12) + (hpa))

struct sti_glob_cfg_ext {
	 u8 curr_mon;			/* current monitor configured */
	 u8 friendly_boot;		/* in friendly boot mode */
	s16 power;			/* power calculation (in Watts) */
	s32 freq_ref;			/* frequency reference */
	u32 sti_mem_addr;		/* pointer to global sti memory (size=sti_mem_request) */
	u32 future_ptr; 		/* pointer to future data */
};

struct sti_glob_cfg {
	s32 text_planes;		/* number of planes used for text */
	s16 onscreen_x;			/* screen width in pixels */
	s16 onscreen_y;			/* screen height in pixels */
	s16 offscreen_x;		/* offset width in pixels */
	s16 offscreen_y;		/* offset height in pixels */
	s16 total_x;			/* frame buffer width in pixels */
	s16 total_y;			/* frame buffer height in pixels */
	u32 region_ptrs[STI_REGION_MAX]; /* region pointers */
	s32 reent_lvl;			/* storage for reentry level value */
	u32 save_addr;			/* where to save or restore reentrant state */
	u32 ext_ptr;			/* pointer to extended glob_cfg data structure */
};


/* STI init function structs */

struct sti_init_flags {
	u32 wait : 1;		/* should routine idle wait or not */
	u32 reset : 1;		/* hard reset the device? */
	u32 text : 1;		/* turn on text display planes? */
	u32 nontext : 1;	/* turn on non-text display planes? */
	u32 clear : 1;		/* clear text display planes? */
	u32 cmap_blk : 1;	/* non-text planes cmap black? */
	u32 enable_be_timer : 1; /* enable bus error timer */
	u32 enable_be_int : 1;	/* enable bus error timer interrupt */
	u32 no_chg_tx : 1;	/* don't change text settings */
	u32 no_chg_ntx : 1;	/* don't change non-text settings */
	u32 no_chg_bet : 1;	/* don't change berr timer settings */
	u32 no_chg_bei : 1;	/* don't change berr int settings */
	u32 init_cmap_tx : 1;	/* initialize cmap for text planes */
	u32 cmt_chg : 1;	/* change current monitor type */
	u32 retain_ie : 1;	/* don't allow