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