From 3a065f1a76feb4f23af6708caef5f912292610fd Mon Sep 17 00:00:00 2001 From: Chuanjia Liu Date: Mon, 26 Nov 2018 14:20:09 +0800 Subject: mediatek: Share GPIO external interrupts (EINT) code among similar SoCs Refactor GPIO EINT code which can be reused among similar SoCs. BUG=b:80501386 BRANCH=none TEST=emerge-elm coreboot; emerge-kukui coreboot Change-Id: Ib01b43cf1aa4082d7d968fe1ef82f75e8cf05b8b Signed-off-by: Chuanjia Liu Reviewed-on: https://review.coreboot.org/c/29837 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/soc/mediatek/mt8173/include/soc/gpio.h | 58 ------------------------- src/soc/mediatek/mt8173/include/soc/gpio_base.h | 24 ++++++++++ 2 files changed, 24 insertions(+), 58 deletions(-) create mode 100644 src/soc/mediatek/mt8173/include/soc/gpio_base.h (limited to 'src/soc/mediatek/mt8173/include') diff --git a/src/soc/mediatek/mt8173/include/soc/gpio.h b/src/soc/mediatek/mt8173/include/soc/gpio.h index a78c8b4fa0..ec0833408e 100644 --- a/src/soc/mediatek/mt8173/include/soc/gpio.h +++ b/src/soc/mediatek/mt8173/include/soc/gpio.h @@ -31,10 +31,6 @@ enum external_power { GPIO_EINT_1P8V = 1, }; -typedef struct { - u32 id; -} gpio_t; - #define PIN(id, name, func1, func2, func3, func4, func5, func6, func7) \ PAD_##name##_ID = id, \ PAD_##name##_FUNC_##func1 = 1, \ @@ -364,60 +360,6 @@ check_member(gpio_regs, hsic_ctrl[3], 0xe50); static struct gpio_regs *const mtk_gpio = (void *)(GPIO_BASE); -void gpio_set_pull(gpio_t gpio, enum pull_enable enable, - enum pull_select select); -void gpio_set_mode(gpio_t gpio, int mode); void gpio_init(enum external_power); -enum gpio_irq_type { - IRQ_TYPE_EDGE_RISING, - IRQ_TYPE_EDGE_FALLING, - IRQ_TYPE_LEVEL_HIGH, - IRQ_TYPE_LEVEL_LOW, -}; - -struct eint_section { - uint32_t regs[7]; - uint32_t align1[9]; -}; - -struct eint_regs { - struct eint_section sta; - struct eint_section ack; - struct eint_section mask; - struct eint_section mask_set; - struct eint_section mask_clr; - struct eint_section sens; - struct eint_section sens_set; - struct eint_section sens_clr; - struct eint_section soft; - struct eint_section soft_set; - struct eint_section soft_clr; - struct eint_section rsv00; - struct eint_section pol; - struct eint_section pol_set; - struct eint_section pol_clr; - struct eint_section rsv01; - uint32_t d0en[7]; - uint32_t rsv02; - uint32_t d1en[7]; -}; - -check_member(eint_regs, d1en, 0x420); - -static struct eint_regs *const mt8173_eint = (void *)(EINT_BASE); - -/* - * Firmware never enables interrupts on this platform. This function - * reads current EINT status and clears the pending interrupt. - * - * Returns 1 if the interrupt was pending, else 0. - */ -int gpio_eint_poll(gpio_t gpio); - -/* - * Configure a GPIO to handle external interrupts (EINT) of given irq type. - */ -void gpio_eint_configure(gpio_t gpio, enum gpio_irq_type type); - #endif /* SOC_MEDIATEK_MT8173_GPIO_H */ diff --git a/src/soc/mediatek/mt8173/include/soc/gpio_base.h b/src/soc/mediatek/mt8173/include/soc/gpio_base.h new file mode 100644 index 0000000000..ac7f46a017 --- /dev/null +++ b/src/soc/mediatek/mt8173/include/soc/gpio_base.h @@ -0,0 +1,24 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2018 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#ifndef SOC_MEDIATEK_MT8173_GPIO_BASE_H +#define SOC_MEDIATEK_MT8173_GPIO_BASE_H + +#include + +typedef struct { + u32 id; +} gpio_t; + +#endif -- cgit v1.2.3