Source
x
/* note: matching works on string prefix, so "apu2" must come before "apu" */
// SPDX-License-Identifier: GPL-2.0+
/*
* PC-Engines APUv2/APUv3 board platform driver
* for gpio buttons and LEDs
*
* Copyright (C) 2018 metux IT consult
* Author: Enrico Weigelt <info@metux.net>
*/
/*
* NOTE: this driver only supports APUv2/3 - not APUv1, as this one
* has completely different register layouts
*/
/* register mappings */
/* order in which the gpio lines are defined in the register list */
/* gpio device */
static int apu2_gpio_regs[] = {
[APU2_GPIO_LINE_LED1] = APU2_GPIO_REG_LED1,
[APU2_GPIO_LINE_LED2] = APU2_GPIO_REG_LED2,
[APU2_GPIO_LINE_LED3] = APU2_GPIO_REG_LED3,
[APU2_GPIO_LINE_MODESW] = APU2_GPIO_REG_MODESW,
[APU2_GPIO_LINE_SIMSWAP] = APU2_GPIO_REG_SIMSWAP,
};
static const char * const apu2_gpio_names[] = {
[APU2_GPIO_LINE_LED1] = "front-led1",
[APU2_GPIO_LINE_LED2] = "front-led2",
[APU2_GPIO_LINE_LED3] = "front-led3",
[APU2_GPIO_LINE_MODESW] = "front-button",
[APU2_GPIO_LINE_SIMSWAP] = "simswap",
};
static const struct amd_fch_gpio_pdata board_apu2 = {
.gpio_num = ARRAY_SIZE(apu2_gpio_regs),
.gpio_reg = apu2_gpio_regs,
.gpio_names = apu2_gpio_names,
};
/* gpio leds device */
static const struct gpio_led apu2_leds[] = {
{ .name = "apu:green:1" },
{ .name = "apu:green:2" },
{ .name = "apu:green:3" }
};
static const struct gpio_led_platform_data apu2_leds_pdata = {
.num_leds = ARRAY_SIZE(apu2_leds),
.leds = apu2_leds,
};
struct gpiod_lookup_table gpios_led_table = {
.dev_id = "leds-gpio",
.table = {
GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_LINE_LED1,
NULL, 0, GPIO_ACTIVE_LOW),
GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_LINE_LED2,
NULL, 1, GPIO_ACTIVE_LOW),
GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_LINE_LED3,
NULL, 2, GPIO_ACTIVE_LOW),
}
};
/* gpio keyboard device */