xref: /aosp_15_r20/external/gsc-utils/include/gpio.wrap (revision 4f2df630800bdcf1d4f0decf95d8a1cb87344f5f)
1*4f2df630SAndroid Build Coastguard Worker/* -*- mode:c -*-
2*4f2df630SAndroid Build Coastguard Worker *
3*4f2df630SAndroid Build Coastguard Worker * Copyright 2014 The ChromiumOS Authors
4*4f2df630SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license that can be
5*4f2df630SAndroid Build Coastguard Worker * found in the LICENSE file.
6*4f2df630SAndroid Build Coastguard Worker */
7*4f2df630SAndroid Build Coastguard Worker
8*4f2df630SAndroid Build Coastguard Worker/**
9*4f2df630SAndroid Build Coastguard Worker * @file gpio.wrap
10*4f2df630SAndroid Build Coastguard Worker * @brief Include the board specific *gpio.inc* file.
11*4f2df630SAndroid Build Coastguard Worker *
12*4f2df630SAndroid Build Coastguard Worker * This file is included in many different contexts.
13*4f2df630SAndroid Build Coastguard Worker * The macros defined outside of the file (before including)
14*4f2df630SAndroid Build Coastguard Worker * determine what parts of *gpio.inc* will be emitted.
15*4f2df630SAndroid Build Coastguard Worker *
16*4f2df630SAndroid Build Coastguard Worker * @see include/gpio_list.h
17*4f2df630SAndroid Build Coastguard Worker * @see common/gpio.c
18*4f2df630SAndroid Build Coastguard Worker * @see include/gpio_signal.h
19*4f2df630SAndroid Build Coastguard Worker */
20*4f2df630SAndroid Build Coastguard Worker
21*4f2df630SAndroid Build Coastguard Worker#ifndef GPIO_PIN
22*4f2df630SAndroid Build Coastguard Worker#error "Your architecture must define GPIO_PIN and it did not."
23*4f2df630SAndroid Build Coastguard Worker#endif
24*4f2df630SAndroid Build Coastguard Worker
25*4f2df630SAndroid Build Coastguard Worker#ifndef GPIO_PIN_MASK
26*4f2df630SAndroid Build Coastguard Worker#error "Your architecture must define GPIO_PIN_MASK and it did not."
27*4f2df630SAndroid Build Coastguard Worker#endif
28*4f2df630SAndroid Build Coastguard Worker
29*4f2df630SAndroid Build Coastguard Worker/**
30*4f2df630SAndroid Build Coastguard Worker * @def GPIO
31*4f2df630SAndroid Build Coastguard Worker * @brief The GPIO macro is used to define a new GPIO pin name and function.
32*4f2df630SAndroid Build Coastguard Worker *
33*4f2df630SAndroid Build Coastguard Worker * The name is used to populate the gpio_signal enum by first
34*4f2df630SAndroid Build Coastguard Worker * prepending GPIO_ to the name.  It is also used to construct the
35*4f2df630SAndroid Build Coastguard Worker * string name that is presented in the shell interface.  The pin
36*4f2df630SAndroid Build Coastguard Worker * parameter should use PIN macro and will be expand to GPIO_PIN
37*4f2df630SAndroid Build Coastguard Worker * defined on each board.  The flags parameter is passed on to the
38*4f2df630SAndroid Build Coastguard Worker * gpio_info directly.
39*4f2df630SAndroid Build Coastguard Worker */
40*4f2df630SAndroid Build Coastguard Worker#ifndef GPIO
41*4f2df630SAndroid Build Coastguard Worker#define GPIO(name, pin, flags)
42*4f2df630SAndroid Build Coastguard Worker#endif
43*4f2df630SAndroid Build Coastguard Worker
44*4f2df630SAndroid Build Coastguard Worker/**
45*4f2df630SAndroid Build Coastguard Worker * @def GPIO_INT
46*4f2df630SAndroid Build Coastguard Worker * @brief The GPIO_INT macro is used to define a GPIOs that have an IRQ handler.
47*4f2df630SAndroid Build Coastguard Worker *
48*4f2df630SAndroid Build Coastguard Worker * The IRQ handler pointers are stored as elements in the gpio_irq_handlers
49*4f2df630SAndroid Build Coastguard Worker * array.
50*4f2df630SAndroid Build Coastguard Worker */
51*4f2df630SAndroid Build Coastguard Worker#ifndef GPIO_INT
52*4f2df630SAndroid Build Coastguard Worker#define GPIO_INT(name, pin, flags, signal)
53*4f2df630SAndroid Build Coastguard Worker#endif
54*4f2df630SAndroid Build Coastguard Worker
55*4f2df630SAndroid Build Coastguard Worker/**
56*4f2df630SAndroid Build Coastguard Worker * @def ALTERNATE
57*4f2df630SAndroid Build Coastguard Worker * @brief The ALTERNATE macro is used associate a GPIO with an alternate
58*4f2df630SAndroid Build Coastguard Worker *        function.
59*4f2df630SAndroid Build Coastguard Worker *
60*4f2df630SAndroid Build Coastguard Worker * Alternate functions allow hardware peripherals access to GPIO pins.
61*4f2df630SAndroid Build Coastguard Worker * Modules use gpio_config_module to enable and disable the alternate functions
62*4f2df630SAndroid Build Coastguard Worker * of GPIOs assigned to that module.  So if the module parameter is MODULE_UART
63*4f2df630SAndroid Build Coastguard Worker * then when the uart_init function is called the GPIO will be switched to its
64*4f2df630SAndroid Build Coastguard Worker * alternate function mode.  The function parameter is chip/variant specific
65*4f2df630SAndroid Build Coastguard Worker * and will usually need to be looked up in the datasheet.  The flags parameter
66*4f2df630SAndroid Build Coastguard Worker * has the same meaning as in the GPIO macro above.  This macro can assign
67*4f2df630SAndroid Build Coastguard Worker * multiple pins on the same port to a module, pinmasks should use PIN_MASK
68*4f2df630SAndroid Build Coastguard Worker * and will be expanded as GPIO_PIN_MASK defined in each config_chip.h.
69*4f2df630SAndroid Build Coastguard Worker */
70*4f2df630SAndroid Build Coastguard Worker#ifndef ALTERNATE
71*4f2df630SAndroid Build Coastguard Worker#define ALTERNATE(pinmask, function, module, flags)
72*4f2df630SAndroid Build Coastguard Worker#endif
73*4f2df630SAndroid Build Coastguard Worker
74*4f2df630SAndroid Build Coastguard Worker/**
75*4f2df630SAndroid Build Coastguard Worker * @def UNIMPLEMENTED
76*4f2df630SAndroid Build Coastguard Worker * @brief The UNIMPLEMENTED macro is used to define a GPIO that doesn't actually exist.
77*4f2df630SAndroid Build Coastguard Worker *
78*4f2df630SAndroid Build Coastguard Worker * Some GPIO names are well known and used by generic code, ENTERING_RW and WP_L
79*4f2df630SAndroid Build Coastguard Worker * are examples.  If a particular board doesn't have a GPIO assigned to such a
80*4f2df630SAndroid Build Coastguard Worker * function/name then it should specify that that GPIO is not implemented using
81*4f2df630SAndroid Build Coastguard Worker * the UNIMPLEMENTED macro below in the board gpio.inc file.  This macro creates
82*4f2df630SAndroid Build Coastguard Worker * an entry in the gpio_signal enum and the gpio_list array that is initialized
83*4f2df630SAndroid Build Coastguard Worker * to use the PLACEHOLDER_GPIO_BANK and a bitmask of zero.  The chip GPIO layer
84*4f2df630SAndroid Build Coastguard Worker * is implemented such that writes to and reads from PLACEHOLDER_GPIO_BANK with
85*4f2df630SAndroid Build Coastguard Worker * a bitmask of zero are harmless.
86*4f2df630SAndroid Build Coastguard Worker *
87*4f2df630SAndroid Build Coastguard Worker * This allows common code that expects these GPIOs to exist to compile and have
88*4f2df630SAndroid Build Coastguard Worker * some reduced functionality.
89*4f2df630SAndroid Build Coastguard Worker */
90*4f2df630SAndroid Build Coastguard Worker#ifndef UNIMPLEMENTED
91*4f2df630SAndroid Build Coastguard Worker#define UNIMPLEMENTED(name)
92*4f2df630SAndroid Build Coastguard Worker#endif
93*4f2df630SAndroid Build Coastguard Worker
94*4f2df630SAndroid Build Coastguard Worker#include "gpio.inc"
95*4f2df630SAndroid Build Coastguard Worker
96*4f2df630SAndroid Build Coastguard Worker/*
97*4f2df630SAndroid Build Coastguard Worker * Once the gpio.inc file has been included these macros are no longer needed.
98*4f2df630SAndroid Build Coastguard Worker */
99*4f2df630SAndroid Build Coastguard Worker#undef GPIO
100*4f2df630SAndroid Build Coastguard Worker#undef GPIO_INT
101*4f2df630SAndroid Build Coastguard Worker#undef ALTERNATE
102*4f2df630SAndroid Build Coastguard Worker#undef UNIMPLEMENTED
103