From 0a3738019ffba2072b5d53ca1afd30e57a72b4de Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 25 Jan 2017 09:00:55 -0500 Subject: [PATCH] pinmux: unify galileo pinmux driver Remove dev driver and integrate it in the default pinmux driver. Jira: ZEP-958 Change-Id: I55670240f8a21749d3a6ae22e300e16ba80a2fb6 Signed-off-by: Anas Nashif --- boards/x86/galileo/Makefile | 1 - boards/x86/galileo/pinmux.c | 65 +++++++++++++++- boards/x86/galileo/pinmux_dev.c | 102 -------------------------- drivers/pinmux/dev/Kconfig | 7 -- tests/drivers/pinmux/prj_galileo.conf | 2 - tests/drivers/pinmux/testcase.ini | 2 +- 6 files changed, 64 insertions(+), 115 deletions(-) delete mode 100644 boards/x86/galileo/pinmux_dev.c delete mode 100644 tests/drivers/pinmux/prj_galileo.conf diff --git a/boards/x86/galileo/Makefile b/boards/x86/galileo/Makefile index 749ef5f0e98..a6aa30f1cd5 100644 --- a/boards/x86/galileo/Makefile +++ b/boards/x86/galileo/Makefile @@ -3,4 +3,3 @@ ccflags-y += -I$(srctree)/drivers asflags-y := ${ccflags-y} obj-$(CONFIG_PINMUX) += pinmux.o -obj-$(CONFIG_PINMUX_DEV_GALILEO) += pinmux_dev.o diff --git a/boards/x86/galileo/pinmux.c b/boards/x86/galileo/pinmux.c index e76da0b4d20..317aee8de71 100644 --- a/boards/x86/galileo/pinmux.c +++ b/boards/x86/galileo/pinmux.c @@ -620,6 +620,67 @@ static struct pin_config mux_config[PINMUX_NUM_PINS] = { { 19, PINMUX_FUNC_C }, /* EXP2.P1_2 (out), ADC.IN5, I2C_SCL, NA */ }; +static int pinmux_pullup(struct device *dev, + uint32_t pin, + uint8_t func) +{ + /* + * Nothing to do. + * On Galileo the pullup operation is handled through the selection + * of an actual pin + */ + ARG_UNUSED(dev); + ARG_UNUSED(pin); + ARG_UNUSED(func); + + return 0; +} + +static int pinmux_input_enable(struct device *dev, + uint32_t pin, + uint8_t func) +{ + /* + * Nothing to do. + * On Galileo select a pin for input enabling is handled through the + * selection of an actual pin user configuration. + */ + ARG_UNUSED(dev); + ARG_UNUSED(pin); + ARG_UNUSED(func); + + return 0; +} + +static int pinmux_set(struct device *dev, + uint32_t pin, + uint32_t func) +{ + if (pin > PINMUX_NUM_PINS) { + return -EINVAL; + } + + return _galileo_pinmux_set_pin(dev, pin, func); +} + +static int pinmux_get(struct device *dev, + uint32_t pin, + uint32_t *func) +{ + if (pin > PINMUX_NUM_PINS) { + return -EINVAL; + } + + return _galileo_pinmux_get_pin(dev, pin, func); +} + +static struct pinmux_driver_api api_funcs = { + .set = pinmux_set, + .get = pinmux_get, + .pullup = pinmux_pullup, + .input = pinmux_input_enable +}; + struct galileo_data galileo_pinmux_driver = { .exp0 = NULL, .exp1 = NULL, @@ -685,6 +746,6 @@ static int pinmux_galileo_initialize(struct device *port) * 1 - PCA9535 and PCAL9685 * 2 - pinmux */ -DEVICE_INIT(pmux, CONFIG_PINMUX_NAME, &pinmux_galileo_initialize, +DEVICE_AND_API_INIT(pmux, CONFIG_PINMUX_NAME, &pinmux_galileo_initialize, &galileo_pinmux_driver, NULL, - POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY); + POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY, &api_funcs); diff --git a/boards/x86/galileo/pinmux_dev.c b/boards/x86/galileo/pinmux_dev.c deleted file mode 100644 index b645925651b..00000000000 --- a/boards/x86/galileo/pinmux_dev.c +++ /dev/null @@ -1,102 +0,0 @@ -/* pinmux_dev_galileo.c - pinmux_dev driver for Galileo */ - -/* - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "pinmux_galileo.h" - -static int galileo_dev_pullup(struct device *dev, - uint32_t pin, - uint8_t func) -{ - /* - * Nothing to do. - * On Galileo the pullup operation is handled through the selection - * of an actual pin - */ - ARG_UNUSED(dev); - ARG_UNUSED(pin); - ARG_UNUSED(func); - - return 0; -} - -static int galileo_dev_input_enable(struct device *dev, - uint32_t pin, - uint8_t func) -{ - /* - * Nothing to do. - * On Galileo select a pin for input enabling is handled through the - * selection of an actual pin user configuration. - */ - ARG_UNUSED(dev); - ARG_UNUSED(pin); - ARG_UNUSED(func); - - return 0; -} - -static int galileo_dev_set(struct device *dev, - uint32_t pin, - uint32_t func) -{ - if (pin > PINMUX_NUM_PINS) { - return -EINVAL; - } - - return _galileo_pinmux_set_pin(dev, pin, func); -} - -static int galileo_dev_get(struct device *dev, - uint32_t pin, - uint32_t *func) -{ - if (pin > PINMUX_NUM_PINS) { - return -EINVAL; - } - - return _galileo_pinmux_get_pin(dev, pin, func); -} - -static struct pinmux_driver_api api_funcs = { - .set = galileo_dev_set, - .get = galileo_dev_get, - .pullup = galileo_dev_pullup, - .input = galileo_dev_input_enable -}; - -static int pinmux_dev_galileo_initialize(struct device *port) -{ - ARG_UNUSED(port); - - return 0; -} - -/* - * This needs to be a level 2 or later init process due to the following - * dependency chain: - * 0 - I2C - * 1 - PCA9535 and PCAL9685 - * 2 - pinmux - */ -DEVICE_AND_API_INIT(pmux_dev, CONFIG_PINMUX_DEV_NAME, - &pinmux_dev_galileo_initialize, - &galileo_pinmux_driver, NULL, - POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY, - &api_funcs); diff --git a/drivers/pinmux/dev/Kconfig b/drivers/pinmux/dev/Kconfig index 64a17564a51..418b5eaa3cc 100644 --- a/drivers/pinmux/dev/Kconfig +++ b/drivers/pinmux/dev/Kconfig @@ -37,13 +37,6 @@ config PINMUX_DEV_K64 Enables the pinmux dev driver for Freescale K64. default n -config PINMUX_DEV_GALILEO - bool "Enable pinmux dev driver for Galileo" - depends on PINMUX_DEV && BOARD_GALILEO - help - Enables the pinmux dev driver for the Galileo board. - default n - config PINMUX_DEV_STM32 bool "Enable pinmux dev driver for the ST STM32 family." depends on PINMUX_DEV && SOC_FAMILY_STM32 diff --git a/tests/drivers/pinmux/prj_galileo.conf b/tests/drivers/pinmux/prj_galileo.conf deleted file mode 100644 index 25c5c77bbad..00000000000 --- a/tests/drivers/pinmux/prj_galileo.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_PINMUX_DEV=y -CONFIG_PINMUX_DEV_GALILEO=y diff --git a/tests/drivers/pinmux/testcase.ini b/tests/drivers/pinmux/testcase.ini index eacbae9562c..5fea875c509 100644 --- a/tests/drivers/pinmux/testcase.ini +++ b/tests/drivers/pinmux/testcase.ini @@ -1,4 +1,4 @@ [test_pinmux_dev] build_only = true tags = drivers -platform_whitelist = arduino_due galileo nucleo_f103rb stm32_mini_a15 olimexino_stm32 +platform_whitelist = arduino_due nucleo_f103rb stm32_mini_a15 olimexino_stm32