xref: /freebsd/sys/dev/qcom_tlmm/qcom_tlmm_ipq4018_reg.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
14abe6533SAdrian Chadd /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
34abe6533SAdrian Chadd  *
44abe6533SAdrian Chadd  * Copyright (c) 2021 Adrian Chadd <adrian@FreeBSD.org>
54abe6533SAdrian Chadd  *
64abe6533SAdrian Chadd  * Redistribution and use in source and binary forms, with or without
74abe6533SAdrian Chadd  * modification, are permitted provided that the following conditions
84abe6533SAdrian Chadd  * are met:
94abe6533SAdrian Chadd  * 1. Redistributions of source code must retain the above copyright
104abe6533SAdrian Chadd  *    notice, this list of conditions and the following disclaimer.
114abe6533SAdrian Chadd  * 2. Redistributions in binary form must reproduce the above copyright
124abe6533SAdrian Chadd  *    notice, this list of conditions and the following disclaimer in the
134abe6533SAdrian Chadd  *    documentation and/or other materials provided with the distribution.
144abe6533SAdrian Chadd  *
154abe6533SAdrian Chadd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
164abe6533SAdrian Chadd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
174abe6533SAdrian Chadd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
184abe6533SAdrian Chadd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
194abe6533SAdrian Chadd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
204abe6533SAdrian Chadd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
214abe6533SAdrian Chadd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
224abe6533SAdrian Chadd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
234abe6533SAdrian Chadd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
244abe6533SAdrian Chadd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
254abe6533SAdrian Chadd  * SUCH DAMAGE.
264abe6533SAdrian Chadd  */
274abe6533SAdrian Chadd 
284abe6533SAdrian Chadd #ifndef	__QCOM_TLMM_IPQ4018_REG_H__
294abe6533SAdrian Chadd #define	__QCOM_TLMM_IPQ4018_REG_H__
304abe6533SAdrian Chadd 
314abe6533SAdrian Chadd /*
324abe6533SAdrian Chadd  * Each GPIO pin configuration block exists in a 0x1000 sized window.
334abe6533SAdrian Chadd  */
344abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_CONFIG_PIN_BASE		0x0
354abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_CONFIG_PIN_SIZE		0x1000
364abe6533SAdrian Chadd 
374abe6533SAdrian Chadd /*
384abe6533SAdrian Chadd  * Inside each configuration block are the following registers for
394abe6533SAdrian Chadd  * controlling the pin.
404abe6533SAdrian Chadd  */
414abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_PIN_CONTROL		0x00
424abe6533SAdrian Chadd 			/* 1 = output gpio pin, 0 = input gpio pin */
434abe6533SAdrian Chadd 
444abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_MASK	0x3
454abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_SHIFT	0x0
464abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_DISABLE	0
474abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_PULLDOWN	1
484abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_PULLUP	2
494abe6533SAdrian Chadd 			/* There's no BUSHOLD on IPQ4018 */
504abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_PUPD_BUSHOLD	0
514abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_MUX_MASK	0x7
524abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_MUX_SHIFT	2
534abe6533SAdrian Chadd 			/* function/mux control */
544abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_DRIVE_STRENGTH_SHIFT	6
554abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_DRIVE_STRENGTH_MASK	0x7
564abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_OE_ENABLE	(1U << 9)
574abe6533SAdrian Chadd 			/* output enable */
584abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_VM_ENABLE	(1U << 11)
594abe6533SAdrian Chadd 			/* VM passthrough enable */
604abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_OD_ENABLE	(1U << 12)
614abe6533SAdrian Chadd 			/* open drain */
624abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_RES_MASK	0x3
634abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_RES_SHIFT	13
644abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_10K	0x0
654abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_1K5	0x1
664abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_35K	0x2
674abe6533SAdrian Chadd #define			QCOM_TLMM_IPQ4018_REG_PIN_CONTROL_20K	0x3
684abe6533SAdrian Chadd 
694abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_PIN_IO			0x04
704abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_IO_INPUT_STATUS	(1U << 0)
714abe6533SAdrian Chadd 			/* read gpio input status */
724abe6533SAdrian Chadd #define		QCOM_TLMM_IPQ4018_REG_PIN_IO_OUTPUT_EN		(1U << 1)
734abe6533SAdrian Chadd 			/* set gpio output high or low */
744abe6533SAdrian Chadd 
754abe6533SAdrian Chadd 
764abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_PIN_INTR_CONFIG		0x08
774abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_PIN_INTR_STATUS		0x0c
784abe6533SAdrian Chadd 
794abe6533SAdrian Chadd #define	QCOM_TLMM_IPQ4018_REG_PIN(p, reg)		\
804abe6533SAdrian Chadd 	    (((p) * QCOM_TLMM_IPQ4018_REG_CONFIG_PIN_SIZE) + \
814abe6533SAdrian Chadd 	      QCOM_TLMM_IPQ4018_REG_CONFIG_PIN_BASE + (reg))
824abe6533SAdrian Chadd 
834abe6533SAdrian Chadd #endif	/* __QCOM_TLMM_IPQ4018_REG_H__ */
84