18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __MB862XX_H__
38c2ecf20Sopenharmony_ci#define __MB862XX_H__
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_cistruct mb862xx_l1_cfg {
68c2ecf20Sopenharmony_ci	unsigned short sx;
78c2ecf20Sopenharmony_ci	unsigned short sy;
88c2ecf20Sopenharmony_ci	unsigned short sw;
98c2ecf20Sopenharmony_ci	unsigned short sh;
108c2ecf20Sopenharmony_ci	unsigned short dx;
118c2ecf20Sopenharmony_ci	unsigned short dy;
128c2ecf20Sopenharmony_ci	unsigned short dw;
138c2ecf20Sopenharmony_ci	unsigned short dh;
148c2ecf20Sopenharmony_ci	int mirror;
158c2ecf20Sopenharmony_ci};
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define MB862XX_BASE		'M'
188c2ecf20Sopenharmony_ci#define MB862XX_L1_GET_CFG	_IOR(MB862XX_BASE, 0, struct mb862xx_l1_cfg*)
198c2ecf20Sopenharmony_ci#define MB862XX_L1_SET_CFG	_IOW(MB862XX_BASE, 1, struct mb862xx_l1_cfg*)
208c2ecf20Sopenharmony_ci#define MB862XX_L1_ENABLE	_IOW(MB862XX_BASE, 2, int)
218c2ecf20Sopenharmony_ci#define MB862XX_L1_CAP_CTL	_IOW(MB862XX_BASE, 3, int)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifdef __KERNEL__
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_FUJITSU_LIMITED	0x10cf
268c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_FUJITSU_CORALP	0x2019
278c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_FUJITSU_CORALPA	0x201e
288c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_FUJITSU_CARMINE	0x202b
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define GC_MMR_CORALP_EVB_VAL		0x11d7fa13
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cienum gdctype {
338c2ecf20Sopenharmony_ci	BT_NONE,
348c2ecf20Sopenharmony_ci	BT_LIME,
358c2ecf20Sopenharmony_ci	BT_MINT,
368c2ecf20Sopenharmony_ci	BT_CORAL,
378c2ecf20Sopenharmony_ci	BT_CORALP,
388c2ecf20Sopenharmony_ci	BT_CARMINE,
398c2ecf20Sopenharmony_ci};
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistruct mb862xx_gc_mode {
428c2ecf20Sopenharmony_ci	struct fb_videomode	def_mode;	/* mode of connected display */
438c2ecf20Sopenharmony_ci	unsigned int		def_bpp;	/* default depth */
448c2ecf20Sopenharmony_ci	unsigned long		max_vram;	/* connected SDRAM size */
458c2ecf20Sopenharmony_ci	unsigned long		ccf;		/* gdc clk */
468c2ecf20Sopenharmony_ci	unsigned long		mmr;		/* memory mode for SDRAM */
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* private data */
508c2ecf20Sopenharmony_cistruct mb862xxfb_par {
518c2ecf20Sopenharmony_ci	struct fb_info		*info;		/* fb info head */
528c2ecf20Sopenharmony_ci	struct device		*dev;
538c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
548c2ecf20Sopenharmony_ci	struct resource		*res;		/* framebuffer/mmio resource */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci	resource_size_t		fb_base_phys;	/* fb base, 36-bit PPC440EPx */
578c2ecf20Sopenharmony_ci	resource_size_t		mmio_base_phys;	/* io base addr */
588c2ecf20Sopenharmony_ci	void __iomem		*fb_base;	/* remapped framebuffer */
598c2ecf20Sopenharmony_ci	void __iomem		*mmio_base;	/* remapped registers */
608c2ecf20Sopenharmony_ci	size_t			mapped_vram;	/* length of remapped vram */
618c2ecf20Sopenharmony_ci	size_t			mmio_len;	/* length of register region */
628c2ecf20Sopenharmony_ci	unsigned long		cap_buf;	/* capture buffers offset */
638c2ecf20Sopenharmony_ci	size_t			cap_len;	/* length of capture buffers */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	void __iomem		*host;		/* relocatable reg. bases */
668c2ecf20Sopenharmony_ci	void __iomem		*i2c;
678c2ecf20Sopenharmony_ci	void __iomem		*disp;
688c2ecf20Sopenharmony_ci	void __iomem		*disp1;
698c2ecf20Sopenharmony_ci	void __iomem		*cap;
708c2ecf20Sopenharmony_ci	void __iomem		*cap1;
718c2ecf20Sopenharmony_ci	void __iomem		*draw;
728c2ecf20Sopenharmony_ci	void __iomem		*geo;
738c2ecf20Sopenharmony_ci	void __iomem		*pio;
748c2ecf20Sopenharmony_ci	void __iomem		*ctrl;
758c2ecf20Sopenharmony_ci	void __iomem		*dram_ctrl;
768c2ecf20Sopenharmony_ci	void __iomem		*wrback;
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	unsigned int		irq;
798c2ecf20Sopenharmony_ci	unsigned int		type;		/* GDC type */
808c2ecf20Sopenharmony_ci	unsigned int		refclk;		/* disp. reference clock */
818c2ecf20Sopenharmony_ci	struct mb862xx_gc_mode	*gc_mode;	/* GDC mode init data */
828c2ecf20Sopenharmony_ci	int			pre_init;	/* don't init display if 1 */
838c2ecf20Sopenharmony_ci	struct i2c_adapter	*adap;		/* GDC I2C bus adapter */
848c2ecf20Sopenharmony_ci	int			i2c_rs;
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	struct mb862xx_l1_cfg	l1_cfg;
878c2ecf20Sopenharmony_ci	int			l1_stride;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	u32			pseudo_palette[16];
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ciextern void mb862xxfb_init_accel(struct fb_info *info, struct fb_ops *fbops, int xres);
938c2ecf20Sopenharmony_ci#ifdef CONFIG_FB_MB862XX_I2C
948c2ecf20Sopenharmony_ciextern int mb862xx_i2c_init(struct mb862xxfb_par *par);
958c2ecf20Sopenharmony_ciextern void mb862xx_i2c_exit(struct mb862xxfb_par *par);
968c2ecf20Sopenharmony_ci#else
978c2ecf20Sopenharmony_cistatic inline int mb862xx_i2c_init(struct mb862xxfb_par *par) { return 0; }
988c2ecf20Sopenharmony_cistatic inline void mb862xx_i2c_exit(struct mb862xxfb_par *par) { }
998c2ecf20Sopenharmony_ci#endif
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_MB862XX_LIME) && defined(CONFIG_FB_MB862XX_PCI_GDC)
1028c2ecf20Sopenharmony_ci#error	"Select Lime GDC or CoralP/Carmine support, but not both together"
1038c2ecf20Sopenharmony_ci#endif
1048c2ecf20Sopenharmony_ci#if defined(CONFIG_FB_MB862XX_LIME)
1058c2ecf20Sopenharmony_ci#define gdc_read	__raw_readl
1068c2ecf20Sopenharmony_ci#define gdc_write	__raw_writel
1078c2ecf20Sopenharmony_ci#else
1088c2ecf20Sopenharmony_ci#define gdc_read	readl
1098c2ecf20Sopenharmony_ci#define gdc_write	writel
1108c2ecf20Sopenharmony_ci#endif
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define inreg(type, off)	\
1138c2ecf20Sopenharmony_ci	gdc_read((par->type + (off)))
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define outreg(type, off, val)	\
1168c2ecf20Sopenharmony_ci	gdc_write((val), (par->type + (off)))
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define pack(a, b)	(((a) << 16) | (b))
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci#endif
123