1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
277b55e8cSThomas Abraham /*
377b55e8cSThomas Abraham  * Copyright (C) 2012 Samsung Electronics
477b55e8cSThomas Abraham  * Abhilash Kesavan <a.kesavan@samsung.com>
577b55e8cSThomas Abraham  */
677b55e8cSThomas Abraham 
777b55e8cSThomas Abraham #ifndef __ASM_ARM_ARCH_PINMUX_H
877b55e8cSThomas Abraham #define __ASM_ARM_ARCH_PINMUX_H
977b55e8cSThomas Abraham 
1077b55e8cSThomas Abraham #include "periph.h"
1177b55e8cSThomas Abraham 
1277b55e8cSThomas Abraham /*
1377b55e8cSThomas Abraham  * Flags for setting specific configarations of peripherals.
1477b55e8cSThomas Abraham  * List will grow with support for more devices getting added.
1577b55e8cSThomas Abraham  */
1677b55e8cSThomas Abraham enum {
1777b55e8cSThomas Abraham 	PINMUX_FLAG_NONE	= 0x00000000,
1877b55e8cSThomas Abraham 
1977b55e8cSThomas Abraham 	/* Flags for eMMC */
2077b55e8cSThomas Abraham 	PINMUX_FLAG_8BIT_MODE	= 1 << 0,       /* SDMMC 8-bit mode */
2177b55e8cSThomas Abraham 
2277b55e8cSThomas Abraham 	/* Flags for SROM controller */
2377b55e8cSThomas Abraham 	PINMUX_FLAG_BANK	= 3 << 0,       /* bank number (0-3) */
2477b55e8cSThomas Abraham 	PINMUX_FLAG_16BIT	= 1 << 2,       /* 16-bit width */
2577b55e8cSThomas Abraham 
2677b55e8cSThomas Abraham 	/* Flags for I2C */
2777b55e8cSThomas Abraham 	PINMUX_FLAG_HS_MODE	= 1 << 1,       /* I2C High Speed Mode */
2877b55e8cSThomas Abraham };
2977b55e8cSThomas Abraham 
3077b55e8cSThomas Abraham /**
3177b55e8cSThomas Abraham  * Configures the pinmux for a particular peripheral.
3277b55e8cSThomas Abraham  *
3377b55e8cSThomas Abraham  * Each gpio can be configured in many different ways (4 bits on exynos)
3477b55e8cSThomas Abraham  * such as "input", "output", "special function", "external interrupt"
3577b55e8cSThomas Abraham  * etc. This function will configure the peripheral pinmux along with
3677b55e8cSThomas Abraham  * pull-up/down and drive strength.
3777b55e8cSThomas Abraham  *
3877b55e8cSThomas Abraham  * @param peripheral	peripheral to be configured
3977b55e8cSThomas Abraham  * @param flags		configure flags
4077b55e8cSThomas Abraham  * @return 0 if ok, -1 on error (e.g. unsupported peripheral)
4177b55e8cSThomas Abraham  */
4277b55e8cSThomas Abraham int exynos_pinmux_config(int peripheral, int flags);
4377b55e8cSThomas Abraham 
4477b55e8cSThomas Abraham /**
4577b55e8cSThomas Abraham  * Decode the peripheral id using the interrpt numbers.
4677b55e8cSThomas Abraham  *
4777b55e8cSThomas Abraham  * @param blob  Device tree blob
4877b55e8cSThomas Abraham  * @param node  FDT I2C node to find
4977b55e8cSThomas Abraham  * @return peripheral id if ok, PERIPH_ID_NONE on error
5077b55e8cSThomas Abraham  */
5177b55e8cSThomas Abraham int pinmux_decode_periph_id(const void *blob, int node);
5277b55e8cSThomas Abraham #endif
53