Commit 74e154e0 authored by Mao Minkai's avatar Mao Minkai Committed by guzitao
Browse files

sw64: add some other headers

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8Y8CY



--------------------------------

Add some other uncommon headers for basic SW64 support.

Signed-off-by: default avatarMao Minkai <maominkai@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 7352cbe3
Loading
Loading
Loading
Loading
+168 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2015 Weiqiang Su <David.suwq@gmail.com>
 *
 * Both AST2400D and AST2400F package variants are supported.
 */

#ifndef _ASM_SW64_AST2400_H
#define _ASM_SW64_AST2400_H

#include <linux/device.h>

/* Logical Device Numbers (LDN). */
#define AST2400_FDC		0x00 /* Floppy */
#define AST2400_PP		0x01 /* Parallel port */
#define AST2400_SP1		0x02 /* Com1 */
#define AST2400_SP2		0x03 /* Com2 & IR */
#define AST2400_KBC		0x05 /* PS/2 keyboard and mouse */
#define AST2400_CIR		0x06
#define AST2400_GPIO6789_V	0x07
#define AST2400_WDT1_GPIO01A_V	0x08
#define AST2400_GPIO1234567_V	0x09
#define AST2400_ACPI		0x0A
#define AST2400_HWM_FPLED	0x0B /* Hardware monitor & front LED */
#define AST2400_VID		0x0D
#define AST2400_CIRWKUP		0x0E /* CIR wakeup */
#define AST2400_GPIO_PP_OD	0x0F /* GPIO Push-Pull/Open drain select */
#define AST2400_SVID		0x14
#define AST2400_DSLP		0x16 /* Deep sleep */
#define AST2400_GPIOA_LDN	0x17

/* virtual LDN for GPIO and WDT */
#define AST2400_WDT1		((0 << 8) | AST2400_WDT1_GPIO01A_V)

#define AST2400_GPIOBASE	((0 << 8) | AST2400_WDT1_GPIO01A_V) //?

#define AST2400_GPIO0		((1 << 8) | AST2400_WDT1_GPIO01A_V)
#define AST2400_GPIO1		((1 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO2		((2 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO3		((3 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO4		((4 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO5		((5 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO6		((6 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO7		((7 << 8) | AST2400_GPIO1234567_V)
#define AST2400_GPIO8		((0 << 8) | AST2400_GPIO6789_V)
#define AST2400_GPIO9		((1 << 8) | AST2400_GPIO6789_V)
#define AST2400_GPIOA		((2 << 8) | AST2400_WDT1_GPIO01A_V)

#define SUPERIO_PNP_PORT	0x2E
#define SUPERIO_CHIPID		0xC333

struct device_operations;
typedef struct pnp_device {
	unsigned int port;
	unsigned int device;

	struct device_operations *ops;
} *device_t;

struct pnp_mode_ops {
	void (*enter_conf_mode)(device_t dev);
	void (*exit_conf_mode)(device_t dev);
};


struct device_operations {
	void (*read_resources)(device_t dev);
	void (*set_resources)(device_t dev);
	void (*enable_resources)(device_t dev);
	void (*init)(device_t dev);
	void (*final)(device_t dev);
	void (*enable)(device_t dev);
	void (*disable)(device_t dev);

	const struct pnp_mode_ops *ops_pnp_mode;
};

/* PNP helper operations */
struct io_info {
	unsigned int mask, set;
};

struct pnp_info {
	bool enabled;		/* set if we should enable the device */
	struct pnp_device pnp_device;
	unsigned int function;	/* Must be at least 16 bits (virtual LDNs)! */
};

/* Chip operations */
struct chip_operations {
	void (*enable_dev)(struct device *dev);
	void (*init)(void *chip_info);
	void (*final)(void *chip_info);
	unsigned int initialized : 1;
	unsigned int finalized : 1;
	const char *name;
};

typedef struct superio_ast2400_device {
	struct device	*dev;
	const char	*name;
	unsigned int	enabled : 1;		/* set if we should enable the device */
	unsigned int	superio_ast2400_efir;	/* extended function index register */
	unsigned int	superio_ast2400_efdr;	/* extended function data register */
	struct chip_operations *chip_ops;
	const void	*chip_info;
} *superio_device_t;


static inline void pnp_enter_conf_mode_a5a5(device_t dev)
{
	outb(0xa5, dev->port);
	outb(0xa5, dev->port);
}

static inline void pnp_exit_conf_mode_aa(device_t dev)
{
	outb(0xaa, dev->port);
}

/* PNP config mode wrappers */

static inline void pnp_enter_conf_mode(device_t dev)
{
	if (dev->ops->ops_pnp_mode)
		dev->ops->ops_pnp_mode->enter_conf_mode(dev);
}

static inline void pnp_exit_conf_mode(device_t dev)
{
	if (dev->ops->ops_pnp_mode)
		dev->ops->ops_pnp_mode->exit_conf_mode(dev);
}

/* PNP device operations */
static inline u8 pnp_read_config(device_t dev, u8 reg)
{
	outb(reg, dev->port);
	return inb(dev->port + 1);
}

static inline void pnp_write_config(device_t dev, u8 reg, u8 value)
{
	outb(reg, dev->port);
	outb(value, dev->port + 1);
}

static inline void pnp_set_logical_device(device_t dev)
{
	pnp_write_config(dev, 0x07, dev->device & 0xff);
//	pnp_write_config(dev, 0x07, 0x3);
}

static inline void pnp_set_enable(device_t dev, int enable)
{
	u8 tmp;

	tmp = pnp_read_config(dev, 0x30);

	if (enable)
		tmp |= 1;
	else
		tmp &= ~1;

	pnp_write_config(dev, 0x30, tmp);
}

#endif /* _ASM_SW64_AST2400_H */
+11 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_SW64_SOCKET_H
#define _ASM_SW64_SOCKET_H

#include <uapi/asm/socket.h>

/* O_NONBLOCK clashes with the bits used for socket types.  Therefore we
 * have to define SOCK_NONBLOCK to a different value here.
 */
#define SOCK_NONBLOCK	0x40000000
#endif /* _ASM_SW64_SOCKET_H */
+58 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_ASM_SW64_FCNTL_H
#define _UAPI_ASM_SW64_FCNTL_H

#define O_CREAT		01000		/* not fcntl */
#define O_TRUNC		02000		/* not fcntl */
#define O_EXCL		04000		/* not fcntl */
#define O_NOCTTY	010000		/* not fcntl */

#define O_NONBLOCK	00004
#define O_APPEND	00010
#define O_DSYNC		040000		/* used to be O_SYNC, see below */
#define O_DIRECTORY	0100000		/* must be a directory */
#define O_NOFOLLOW	0200000		/* don't follow links */
#define O_LARGEFILE	0400000		/* will be set by the kernel on every open */
#define O_DIRECT	02000000	/* direct disk access */
#define O_NOATIME	04000000
#define O_CLOEXEC	010000000	/* set close_on_exec */
/*
 * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
 * the O_SYNC flag.  We continue to use the existing numerical value
 * for O_DSYNC semantics now, but using the correct symbolic name for it.
 * This new value is used to request true Posix O_SYNC semantics.  It is
 * defined in this strange way to make sure applications compiled against
 * new headers get at least O_DSYNC semantics on older kernels.
 *
 * This has the nice side-effect that we can simply test for O_DSYNC
 * wherever we do not care if O_DSYNC or O_SYNC is used.
 *
 * Note: __O_SYNC must never be used directly.
 */
#define __O_SYNC	020000000
#define O_SYNC		(__O_SYNC|O_DSYNC)

#define O_PATH		040000000
#define __O_TMPFILE	0100000000

#define F_GETLK		7
#define F_SETLK		8
#define F_SETLKW	9

#define F_SETOWN	5	/*  for sockets. */
#define F_GETOWN	6	/*  for sockets. */
#define F_SETSIG	10	/*  for sockets. */
#define F_GETSIG	11	/*  for sockets. */

/* for posix fcntl() and lockf() */
#define F_RDLCK		1
#define F_WRLCK		2
#define F_UNLCK		8

/* for old implementation of bsd flock () */
#define F_EXLCK		16	/* or 3 */
#define F_SHLCK		32	/* or 4 */

#include <asm-generic/fcntl.h>

#endif /* _UAPI_ASM_SW64_FCNTL_H */
+19 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_ASM_SW64_IOCTL_H
#define _UAPI_ASM_SW64_IOCTL_H

#define _IOC_SIZEBITS	13
#define _IOC_DIRBITS	3

/*
 * Direction bits _IOC_NONE could be 0, but legacy version gives it a bit.
 * And this turns out useful to catch old ioctl numbers in header files for
 * us.
 */
#define _IOC_NONE	1U
#define _IOC_READ	2U
#define _IOC_WRITE	4U

#include <asm-generic/ioctl.h>

#endif /* _UAPI_ASM_SW64_IOCTL_H */
+128 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _UAPI_ASM_SW64_IOCTLS_H
#define _UAPI_ASM_SW64_IOCTLS_H

#include <asm/ioctl.h>

#define FIOCLEX		_IO('f', 1)
#define FIONCLEX	_IO('f', 2)
#define FIOASYNC	_IOW('f', 125, int)
#define FIONBIO		_IOW('f', 126, int)
#define FIONREAD	_IOR('f', 127, int)
#define TIOCINQ		FIONREAD
#define FIOQSIZE	_IOR('f', 128, loff_t)

#define TIOCGETP	_IOR('t', 8, struct sgttyb)
#define TIOCSETP	_IOW('t', 9, struct sgttyb)
#define TIOCSETN	_IOW('t', 10, struct sgttyb)	/* TIOCSETP wo flush */

#define TIOCSETC	_IOW('t', 17, struct tchars)
#define TIOCGETC	_IOR('t', 18, struct tchars)
#define TCGETS		_IOR('t', 19, struct termios)
#define TCSETS		_IOW('t', 20, struct termios)
#define TCSETSW		_IOW('t', 21, struct termios)
#define TCSETSF		_IOW('t', 22, struct termios)

#define TCGETA		_IOR('t', 23, struct termio)
#define TCSETA		_IOW('t', 24, struct termio)
#define TCSETAW		_IOW('t', 25, struct termio)
#define TCSETAF		_IOW('t', 28, struct termio)

#define TCSBRK		_IO('t', 29)
#define TCXONC		_IO('t', 30)
#define TCFLSH		_IO('t', 31)

#define TCGETS2		_IOR('T', 42, struct termios2)
#define TCSETS2		_IOW('T', 43, struct termios2)
#define TCSETSW2	_IOW('T', 44, struct termios2)
#define TCSETSF2	_IOW('T', 45, struct termios2)

#define TIOCSWINSZ	_IOW('t', 103, struct winsize)
#define TIOCGWINSZ	_IOR('t', 104, struct winsize)
#define TIOCSTART	_IO('t', 110)		/* start output, like ^Q */
#define TIOCSTOP	_IO('t', 111)		/* stop output, like ^S */
#define TIOCOUTQ	_IOR('t', 115, int)	/* output queue size */

#define TIOCGLTC	_IOR('t', 116, struct ltchars)
#define TIOCSLTC	_IOW('t', 117, struct ltchars)
#define TIOCSPGRP	_IOW('t', 118, int)
#define TIOCGPGRP	_IOR('t', 119, int)

#define TIOCEXCL	0x540C
#define TIOCNXCL	0x540D
#define TIOCSCTTY	0x540E

#define TIOCSTI		0x5412
#define TIOCMGET	0x5415
#define TIOCMBIS	0x5416
#define TIOCMBIC	0x5417
#define TIOCMSET	0x5418
#define TIOCM_LE	0x001
#define TIOCM_DTR	0x002
#define TIOCM_RTS	0x004
#define TIOCM_ST	0x008
#define TIOCM_SR	0x010
#define TIOCM_CTS	0x020
#define TIOCM_CAR	0x040
#define TIOCM_RNG	0x080
#define TIOCM_DSR	0x100
#define TIOCM_CD	TIOCM_CAR
#define TIOCM_RI	TIOCM_RNG
#define TIOCM_OUT1	0x2000
#define TIOCM_OUT2	0x4000
#define TIOCM_LOOP	0x8000

#define TIOCGSOFTCAR	0x5419
#define TIOCSSOFTCAR	0x541A
#define TIOCLINUX	0x541C
#define TIOCCONS	0x541D
#define TIOCGSERIAL	0x541E
#define TIOCSSERIAL	0x541F
#define TIOCPKT		0x5420
#define TIOCPKT_DATA		 0
#define TIOCPKT_FLUSHREAD	 1
#define TIOCPKT_FLUSHWRITE	 2
#define TIOCPKT_STOP		 4
#define TIOCPKT_START		 8
#define TIOCPKT_NOSTOP		16
#define TIOCPKT_DOSTOP		32
#define TIOCPKT_IOCTL		64


#define TIOCNOTTY	0x5422
#define TIOCSETD	0x5423
#define TIOCGETD	0x5424
#define TCSBRKP		0x5425				/* Needed for POSIX tcsendbreak() */
#define TIOCSBRK	0x5427				/* BSD compatibility */
#define TIOCCBRK	0x5428				/* BSD compatibility */
#define TIOCGSID	0x5429				/* Return the session ID of FD */
#define TIOCGRS485	_IOR('T', 0x2E, struct serial_rs485)
#define TIOCSRS485	_IOWR('T', 0x2F, struct serial_rs485)
#define TIOCGPTN	_IOR('T', 0x30, unsigned int)	/* Get Pty Number (of pty-mux device) */
#define TIOCSPTLCK	_IOW('T', 0x31, int)		/* Lock/unlock Pty */
#define TIOCGDEV	_IOR('T', 0x32, unsigned int)	/* Get primary device node of /dev/console */
#define TIOCSIG		_IOW('T', 0x36, int)		/* Generate signal on Pty slave */
#define TIOCVHANGUP	0x5437
#define TIOCGPKT	_IOR('T', 0x38, int)		/* Get packet mode state */
#define TIOCGPTLCK	_IOR('T', 0x39, int)		/* Get Pty lock state */
#define TIOCGEXCL	_IOR('T', 0x40, int)		/* Get exclusive mode state */
#define TIOCGPTPEER	_IO('T', 0x41)			/* Safely open the slave */
#define TIOCGISO7816	_IOR('T', 0x42, struct serial_iso7816)
#define TIOCSISO7816	_IOWR('T', 0x43, struct serial_iso7816)

#define TIOCSERCONFIG	0x5453
#define TIOCSERGWILD	0x5454
#define TIOCSERSWILD	0x5455
#define TIOCGLCKTRMIOS	0x5456
#define TIOCSLCKTRMIOS	0x5457
#define TIOCSERGSTRUCT	0x5458				/* For debugging only */
#define TIOCSERGETLSR	0x5459				/* Get line status register */
/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
#define TIOCSER_TEMT	0x01				/* Transmitter physically empty */
#define TIOCSERGETMULTI	0x545A				/* Get multiport config  */
#define TIOCSERSETMULTI	0x545B				/* Set multiport config */

#define TIOCMIWAIT	0x545C				/* wait for a change on serial input line(s) */
#define TIOCGICOUNT	0x545D				/* read serial port inline interrupt counts */

#endif /* _UAPI_ASM_SW64_IOCTLS_H */
Loading