mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
In the gpio_info struct, we had a irq_handler pointer defined even
though a majority of the GPIOs did not have irq handlers associated. By
removing the irq_handler pointer out of the struct, we can save some
space with some targets saving more than others. (For example, ~260
bytes for samus_pd).
This change also brings about a new define:
GPIO_INT(name, port, pin, flags, signal)
And the existing GPIO macro has had the signal parameter removed since
they were just NULL.
GPIO(name, port, pin, flags)
In each of the gpio.inc files, all the GPIOs with irq handlers must be
defined at the top of the file. This is because their enum values from
gpio_signal are used as the index to the gpio_irq_handlers table.
BUG=chromium:471331
BRANCH=none
TEST=Flashed ec to samus and samus_pd, verified lightbar tap, lid, power
button, keyboard, charging, all still working.
TEST=Moved a GPIO_INT declaration after a GPIO declaration and watched the build
fail.
TEST=make -j BOARD=peppy tests
TEST=make -j BOARD=auron tests
TEST=make -j BOARD=link tests
Change-Id: Id6e261b0a3cd63223ca92f2e96a80c95e85cdefb
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/263973
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Trybot-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
78 lines
2.8 KiB
C
78 lines
2.8 KiB
C
/* -*- mode:c -*-
|
|
*
|
|
* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/*
|
|
* The GPIO macro is used to define a new GPIO pin name and function.
|
|
*
|
|
* The name is used to populate the gpio_signal enum by first
|
|
* prepending GPIO_ to the name. It is also used to construct the
|
|
* string name that is presented in the shell interface. Similarly,
|
|
* the port parameter has GPIO_ prepended to it before it is used to
|
|
* initialize the port base address of a gpio_info struct. The pin
|
|
* number is used to create a bitmask. The flags parameter is passed
|
|
* on to the gpio_info directly.
|
|
*/
|
|
#ifndef GPIO
|
|
#define GPIO(name, port, pin, flags)
|
|
#endif
|
|
|
|
/*
|
|
* The GPIO_INT macro is used to define a GPIOs that have an IRQ handler.
|
|
*
|
|
* The IRQ handler pointers are stored as elements in the gpio_irq_handlers
|
|
* array.
|
|
*/
|
|
#ifndef GPIO_INT
|
|
#define GPIO_INT(name, port, pin, flags, signal)
|
|
#endif
|
|
|
|
/*
|
|
* The ALTERNATE macro is used associate a GPIO with an alternate function.
|
|
*
|
|
* Alternate functions allow hardware peripherals access to GPIO pins.
|
|
* Modules use gpio_config_module to enable and disable the alternate functions
|
|
* of GPIOs assigned to that module. So if the module parameter is MODULE_UART
|
|
* then when the uart_init function is called the GPIO will be switched to its
|
|
* alternate function mode. The function parameter is chip/variant specific
|
|
* and will usually need to be looked up in the datasheet. The flags parameter
|
|
* has the same meaning as in the GPIO macro above. This macro can assign
|
|
* multiple pins on the same port to a module, the second parameter is the
|
|
* bitmask of pins to be assigned.
|
|
*/
|
|
#ifndef ALTERNATE
|
|
#define ALTERNATE(port, mask, function, module, flags)
|
|
#endif
|
|
|
|
/*
|
|
* The UNIMPLEMENTED macro is used to define a GPIO that doesn't actually exist.
|
|
*
|
|
* Some GPIO names are well known and used by generic code, ENTERING_RW and WP_L
|
|
* are examples. If a particular board doesn't have a GPIO assigned to such a
|
|
* function/name then it should specify that that GPIO is not implemented using
|
|
* the UNIMPLEMENTED macro below in the board gpio.inc file. This macro creates
|
|
* an entry in the gpio_signal enum and the gpio_list array that is initialized
|
|
* to use the DUMMY_GPIO_BANK and a bitmask of zero. The chip GPIO layer is
|
|
* implemented such that writes to and reads from DUMMY_GPIO_BANK with a bitmask
|
|
* of zero are harmless.
|
|
*
|
|
* This allows common code that expects these GPIOs to exist to compile and have
|
|
* some reduced functionality.
|
|
*/
|
|
#ifndef UNIMPLEMENTED
|
|
#define UNIMPLEMENTED(name)
|
|
#endif
|
|
|
|
#include "gpio.inc"
|
|
|
|
/*
|
|
* Once the gpio.inc file has been included these macros are no longer needed.
|
|
*/
|
|
#undef GPIO
|
|
#undef GPIO_INT
|
|
#undef ALTERNATE
|
|
#undef UNIMPLEMENTED
|