pinmux: Move the Galileo board to the pinmux model
Change-Id: Ib58b1ea56d6c82c2e055bf4cb0df4b07b0dd936e Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
parent
649253c8a8
commit
41529e20e6
5 changed files with 198 additions and 214 deletions
|
@ -3,4 +3,3 @@ ccflags-y += -I$(srctree)/drivers
|
||||||
asflags-y := ${ccflags-y}
|
asflags-y := ${ccflags-y}
|
||||||
|
|
||||||
obj-y += board.o
|
obj-y += board.o
|
||||||
obj-$(CONFIG_PINMUX) += galileo_pinmux.o
|
|
||||||
|
|
|
@ -4,3 +4,4 @@ obj-$(CONFIG_PINMUX_K64) += pinmux_k64.o
|
||||||
obj-$(CONFIG_PINMUX_STM32) += pinmux_stm32.o
|
obj-$(CONFIG_PINMUX_STM32) += pinmux_stm32.o
|
||||||
obj-$(CONFIG_BOARD_ARDUINO_101) += quark_mcu/pinmux_board_arduino_101.o
|
obj-$(CONFIG_BOARD_ARDUINO_101) += quark_mcu/pinmux_board_arduino_101.o
|
||||||
obj-$(CONFIG_BOARD_ARDUINO_DUE) += sam3x/pinmux_board_arduino_due.o
|
obj-$(CONFIG_BOARD_ARDUINO_DUE) += sam3x/pinmux_board_arduino_due.o
|
||||||
|
obj-$(CONFIG_BOARD_GALILEO) += galileo/pinmux_board_galileo.o galileo/pinmux_galileo.o
|
||||||
|
|
128
drivers/pinmux/galileo/pinmux_board_galileo.c
Normal file
128
drivers/pinmux/galileo/pinmux_board_galileo.c
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
/* pinmux_board_galileo.c - pin out mapping for the Galileo board */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Intel Corporation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <nanokernel.h>
|
||||||
|
#include <device.h>
|
||||||
|
#include <init.h>
|
||||||
|
|
||||||
|
#include <pinmux.h>
|
||||||
|
#include <i2c.h>
|
||||||
|
#include <gpio.h>
|
||||||
|
#include <pwm.h>
|
||||||
|
|
||||||
|
#include <pinmux/pinmux.h>
|
||||||
|
|
||||||
|
#include "pinmux_galileo.h"
|
||||||
|
|
||||||
|
/* Alter this table to change the default pin settings on the Galileo Gen2
|
||||||
|
* boards. Specifically change the PINMUX_FUNC_* value to represent the
|
||||||
|
* functionaltiy desired
|
||||||
|
*/
|
||||||
|
static struct pin_config mux_config[CONFIG_PINMUX_NUM_PINS] = {
|
||||||
|
/* pin, selected mode <mode A, mode B, mode C, mode D> */
|
||||||
|
/* Analog Inputs */
|
||||||
|
{ 0, PINMUX_FUNC_C }, /* GPIO3 (out), GPIO3 (in), UART0_RXD, NA */
|
||||||
|
{ 1, PINMUX_FUNC_C }, /* GPIO4 (out), GPIO4 (in), UART0_TXD, NA */
|
||||||
|
{ 2, PINMUX_FUNC_C }, /* GPIO5 (out), GPIO5 (in), UART1_RXD, NA */
|
||||||
|
{ 3, PINMUX_FUNC_C }, /* GPIO6 (out), GPIO6 (in), UART1_TXD, PWM.LED1 */
|
||||||
|
{ 4, PINMUX_FUNC_B }, /* GPIO_SUS4 (out), GPIO_SUS4 (in), NA, NA */
|
||||||
|
{ 5, PINMUX_FUNC_B }, /* GPIO8 (out), GPIO8 (in), PWM.LED3, NA */
|
||||||
|
{ 6, PINMUX_FUNC_B }, /* GPIO9 (out), GPIO9 (in), PWM.LED5, NA */
|
||||||
|
{ 7, PINMUX_FUNC_A }, /* EXP1.P0_6 (out), EXP1.P0_6 (in), NA, NA */
|
||||||
|
{ 8, PINMUX_FUNC_A }, /* EXP1.P1_0 (out), EXP1.P1_0 (in), NA, NA */
|
||||||
|
{ 9, PINMUX_FUNC_B }, /* GPIO_SUS2 (out), GPIO_SUS2 (in), PWM.LED7, NA */
|
||||||
|
{ 10, PINMUX_FUNC_B }, /* GPIO2 (out), GPIO2 (in), PWM.LED11, NA */
|
||||||
|
{ 11, PINMUX_FUNC_B }, /* GPIO_SUS3 (out), GPIO_SUS3 (in), PWM.LED9, SPI1_MOSI */
|
||||||
|
{ 12, PINMUX_FUNC_B }, /* GPIO7 (out), GPIO7 (in), SPI1_MISO, NA */
|
||||||
|
{ 13, PINMUX_FUNC_B }, /* GPIO_SUS5 (out), GPIO_SUS5(in), SPI1_SCK, NA */
|
||||||
|
{ 14, PINMUX_FUNC_B }, /* EXP2.P0_0 (out)/ADC.IN0, EXP2.P0_0 (in)/ADC.IN0, NA, NA */
|
||||||
|
{ 15, PINMUX_FUNC_B }, /* EXP2.P0_2 (out)/ADC.IN1, EXP2.P0_2 (in)/ADC.IN1, NA, NA */
|
||||||
|
{ 16, PINMUX_FUNC_B }, /* EXP2.P0_4 (out)/ADC.IN2, EXP2.P0_4 (in)/ADC.IN2, NA, NA */
|
||||||
|
{ 17, PINMUX_FUNC_B }, /* EXP2.P0_6 (out)/ADC.IN3, EXP2.P0_6 (in)/ADC.IN3, NA, NA */
|
||||||
|
{ 18, PINMUX_FUNC_C }, /* EXP2.P1_0 (out), ADC.IN4, I2C_SDA, NA */
|
||||||
|
{ 19, PINMUX_FUNC_C }, /* EXP2.P1_2 (out), ADC.IN5, I2C_SCL, NA */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct galileo_data galileo_pinmux_driver = {
|
||||||
|
.exp0 = NULL,
|
||||||
|
.exp1 = NULL,
|
||||||
|
.exp2 = NULL,
|
||||||
|
.pwm0 = NULL,
|
||||||
|
.mux_config = mux_config,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int pinmux_galileo_initialize(struct device *port)
|
||||||
|
{
|
||||||
|
struct galileo_data *dev = port->driver_data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* Grab the EXP0, EXP1, EXP2, and PWM0 now by name */
|
||||||
|
dev->exp0 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP0_NAME);
|
||||||
|
if (!dev->exp0) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->exp1 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP1_NAME);
|
||||||
|
if (!dev->exp1) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->exp2 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP2_NAME);
|
||||||
|
if (!dev->exp2) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->pwm0 = device_get_binding(CONFIG_PINMUX_GALILEO_PWM0_NAME);
|
||||||
|
if (!dev->pwm0) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->gpio_dw = device_get_binding(CONFIG_PINMUX_GALILEO_GPIO_DW_NAME);
|
||||||
|
if (!dev->gpio_dw) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->gpio_core = device_get_binding(
|
||||||
|
CONFIG_PINMUX_GALILEO_GPIO_INTEL_CW_NAME);
|
||||||
|
if (!dev->gpio_core) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
dev->gpio_resume = device_get_binding(
|
||||||
|
CONFIG_PINMUX_GALILEO_GPIO_INTEL_RW_NAME);
|
||||||
|
if (!dev->gpio_resume) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now that we have everything, let us start parsing everything
|
||||||
|
* from the above mapping as selected by the end user
|
||||||
|
*/
|
||||||
|
for (i = 0; i < CONFIG_PINMUX_NUM_PINS; i++) {
|
||||||
|
_galileo_pinmux_set_pin(port,
|
||||||
|
mux_config[i].pin_num,
|
||||||
|
mux_config[i].mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
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_INIT(pmux, PINMUX_NAME, &pinmux_galileo_initialize,
|
||||||
|
&galileo_pinmux_driver, NULL,
|
||||||
|
SECONDARY, CONFIG_PINMUX_INIT_PRIORITY);
|
|
@ -1,7 +1,7 @@
|
||||||
/* galileo_pinmux.c - pin out mapping for the Galileo board */
|
/* pinmux_galileo.c - pin out mapping for the Galileo board */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2015 Intel Corporation
|
* Copyright (c) 2016 Intel Corporation
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,51 +16,22 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nanokernel.h>
|
#include <board.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <init.h>
|
|
||||||
|
|
||||||
#include <pinmux.h>
|
|
||||||
#include <i2c.h>
|
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
|
#include <init.h>
|
||||||
|
#include <misc/util.h>
|
||||||
|
#include <nanokernel.h>
|
||||||
|
#include <pinmux.h>
|
||||||
#include <pwm.h>
|
#include <pwm.h>
|
||||||
|
|
||||||
#include <pinmux/pinmux.h>
|
#include "pinmux/pinmux.h"
|
||||||
|
|
||||||
|
#include "pinmux_galileo.h"
|
||||||
|
|
||||||
/* max number of functions per pin */
|
/* max number of functions per pin */
|
||||||
#define NUM_PIN_FUNCS 4
|
#define NUM_PIN_FUNCS 4
|
||||||
|
|
||||||
|
|
||||||
/* Alter this table to change the default pin settings on the Galileo Gen2
|
|
||||||
* boards. Specifically change the PINMUX_FUNC_* value to represent the
|
|
||||||
* functionaltiy desired
|
|
||||||
*/
|
|
||||||
struct pin_config mux_config[CONFIG_PINMUX_NUM_PINS] = {
|
|
||||||
/* pin, selected mode <mode A, mode B, mode C, mode D> */
|
|
||||||
/* Analog Inputs */
|
|
||||||
{ 0, PINMUX_FUNC_C }, /* GPIO3 (out), GPIO3 (in), UART0_RXD, NA */
|
|
||||||
{ 1, PINMUX_FUNC_C }, /* GPIO4 (out), GPIO4 (in), UART0_TXD, NA */
|
|
||||||
{ 2, PINMUX_FUNC_C }, /* GPIO5 (out), GPIO5 (in), UART1_RXD, NA */
|
|
||||||
{ 3, PINMUX_FUNC_C }, /* GPIO6 (out), GPIO6 (in), UART1_TXD, PWM.LED1 */
|
|
||||||
{ 4, PINMUX_FUNC_B }, /* GPIO_SUS4 (out), GPIO_SUS4 (in), NA, NA */
|
|
||||||
{ 5, PINMUX_FUNC_B }, /* GPIO8 (out), GPIO8 (in), PWM.LED3, NA */
|
|
||||||
{ 6, PINMUX_FUNC_B }, /* GPIO9 (out), GPIO9 (in), PWM.LED5, NA */
|
|
||||||
{ 7, PINMUX_FUNC_A }, /* EXP1.P0_6 (out), EXP1.P0_6 (in), NA, NA */
|
|
||||||
{ 8, PINMUX_FUNC_A }, /* EXP1.P1_0 (out), EXP1.P1_0 (in), NA, NA */
|
|
||||||
{ 9, PINMUX_FUNC_B }, /* GPIO_SUS2 (out), GPIO_SUS2 (in), PWM.LED7, NA */
|
|
||||||
{ 10, PINMUX_FUNC_B }, /* GPIO2 (out), GPIO2 (in), PWM.LED11, NA */
|
|
||||||
{ 11, PINMUX_FUNC_B }, /* GPIO_SUS3 (out), GPIO_SUS3 (in), PWM.LED9, SPI1_MOSI */
|
|
||||||
{ 12, PINMUX_FUNC_B }, /* GPIO7 (out), GPIO7 (in), SPI1_MISO, NA */
|
|
||||||
{ 13, PINMUX_FUNC_B }, /* GPIO_SUS5 (out), GPIO_SUS5(in), SPI1_SCK, NA */
|
|
||||||
{ 14, PINMUX_FUNC_B }, /* EXP2.P0_0 (out)/ADC.IN0, EXP2.P0_0 (in)/ADC.IN0, NA, NA */
|
|
||||||
{ 15, PINMUX_FUNC_B }, /* EXP2.P0_2 (out)/ADC.IN1, EXP2.P0_2 (in)/ADC.IN1, NA, NA */
|
|
||||||
{ 16, PINMUX_FUNC_B }, /* EXP2.P0_4 (out)/ADC.IN2, EXP2.P0_4 (in)/ADC.IN2, NA, NA */
|
|
||||||
{ 17, PINMUX_FUNC_B }, /* EXP2.P0_6 (out)/ADC.IN3, EXP2.P0_6 (in)/ADC.IN3, NA, NA */
|
|
||||||
{ 18, PINMUX_FUNC_C }, /* EXP2.P1_0 (out), ADC.IN4, I2C_SDA, NA */
|
|
||||||
{ 19, PINMUX_FUNC_C }, /* EXP2.P1_2 (out), ADC.IN5, I2C_SCL, NA */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum gpio_chip {
|
enum gpio_chip {
|
||||||
NONE,
|
NONE,
|
||||||
EXP0,
|
EXP0,
|
||||||
|
@ -87,35 +58,18 @@ struct mux_pin {
|
||||||
uint32_t cfg;
|
uint32_t cfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure provides the breakdown mapping for the pinmux to follow to
|
||||||
|
* enable each functionality within the hardware. There should be nothing to
|
||||||
|
* edit here unless you absolutely know what you are doing
|
||||||
|
*/
|
||||||
struct mux_path {
|
struct mux_path {
|
||||||
uint8_t io_pin;
|
uint8_t io_pin;
|
||||||
uint8_t func;
|
uint8_t func;
|
||||||
struct mux_pin path[5];
|
struct mux_pin path[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct galileo_data {
|
static struct mux_path _galileo_path[CONFIG_PINMUX_NUM_PINS * NUM_PIN_FUNCS] = {
|
||||||
struct device *exp0;
|
|
||||||
struct device *exp1;
|
|
||||||
struct device *exp2;
|
|
||||||
struct device *pwm0;
|
|
||||||
|
|
||||||
/* GPIO<0>..GPIO<7> */
|
|
||||||
struct device *gpio_dw;
|
|
||||||
|
|
||||||
/* GPIO<8>..GPIO<9>, which means to pin 0 and 1 on core well. */
|
|
||||||
struct device *gpio_core;
|
|
||||||
|
|
||||||
/* GPIO_SUS<0>..GPIO_SUS<5> */
|
|
||||||
struct device *gpio_resume;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure provides the breakdown mapping for the pinmux to follow to
|
|
||||||
* enable each functionality within the hardware. There should be nothing to
|
|
||||||
* edit here unless you absolutely know what you are doing
|
|
||||||
*/
|
|
||||||
struct mux_path _galileo_path[CONFIG_PINMUX_NUM_PINS * NUM_PIN_FUNCS] = {
|
|
||||||
{0, PINMUX_FUNC_A, {{ EXP1, 0, PIN_HIGH, (GPIO_DIR_OUT) }, /* GPIO3 out */
|
{0, PINMUX_FUNC_A, {{ EXP1, 0, PIN_HIGH, (GPIO_DIR_OUT) }, /* GPIO3 out */
|
||||||
{ EXP1, 1, PIN_LOW, (GPIO_DIR_OUT) },
|
{ EXP1, 1, PIN_LOW, (GPIO_DIR_OUT) },
|
||||||
{ G_DW, 3, PIN_LOW, (GPIO_DIR_OUT) },
|
{ G_DW, 3, PIN_LOW, (GPIO_DIR_OUT) },
|
||||||
|
@ -537,19 +491,21 @@ struct mux_path _galileo_path[CONFIG_PINMUX_NUM_PINS * NUM_PIN_FUNCS] = {
|
||||||
{ NONE, 0, DONT_CARE, (GPIO_DIR_IN) } } },
|
{ NONE, 0, DONT_CARE, (GPIO_DIR_IN) } } },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int _galileo_pinmux_set_pin(struct device *port, uint8_t pin, uint32_t func)
|
||||||
int _galileo_set_pin(struct device *port, uint8_t pin, uint8_t func)
|
|
||||||
{
|
{
|
||||||
struct galileo_data * const drv_data = port->driver_data;
|
struct galileo_data * const drv_data = port->driver_data;
|
||||||
|
|
||||||
uint8_t mux_index = 0;
|
uint8_t mux_index = 0;
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
struct mux_path *enable = NULL;
|
struct mux_path *enable = NULL;
|
||||||
|
struct pin_config *mux_config = drv_data->mux_config;
|
||||||
|
|
||||||
if (pin > CONFIG_PINMUX_NUM_PINS) {
|
if (pin > CONFIG_PINMUX_NUM_PINS) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mux_config[pin].mode = func;
|
||||||
|
|
||||||
/* NUM_PIN_FUNCS being the number of alt functions */
|
/* NUM_PIN_FUNCS being the number of alt functions */
|
||||||
mux_index = NUM_PIN_FUNCS * pin;
|
mux_index = NUM_PIN_FUNCS * pin;
|
||||||
/*
|
/*
|
||||||
|
@ -627,158 +583,12 @@ int _galileo_set_pin(struct device *port, uint8_t pin, uint8_t func)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PINMUX_DEV
|
int _galileo_pinmux_get_pin(struct device *port, uint32_t pin, uint32_t *func)
|
||||||
static int galileo_dev_set(struct device *dev,
|
|
||||||
uint32_t pin,
|
|
||||||
uint32_t func)
|
|
||||||
{
|
{
|
||||||
if (pin > CONFIG_PINMUX_NUM_PINS) {
|
struct galileo_data * const drv_data = port->driver_data;
|
||||||
return -EINVAL;
|
struct pin_config *mux_config = drv_data->mux_config;
|
||||||
}
|
|
||||||
|
|
||||||
mux_config[pin].mode = func;
|
|
||||||
|
|
||||||
return _galileo_set_pin(dev, pin, (uint8_t)func);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int galileo_dev_get(struct device *dev,
|
|
||||||
uint32_t pin,
|
|
||||||
uint32_t *func)
|
|
||||||
{
|
|
||||||
if (pin > CONFIG_PINMUX_NUM_PINS) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*func = mux_config[pin].mode;
|
*func = mux_config[pin].mode;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static int galileo_dev_set(struct device *dev,
|
|
||||||
uint32_t pin,
|
|
||||||
uint32_t func)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(dev);
|
|
||||||
ARG_UNUSED(pin);
|
|
||||||
ARG_UNUSED(func);
|
|
||||||
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int galileo_dev_get(struct device *dev,
|
|
||||||
uint32_t pin,
|
|
||||||
uint32_t *func)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(dev);
|
|
||||||
ARG_UNUSED(pin);
|
|
||||||
ARG_UNUSED(func);
|
|
||||||
|
|
||||||
return -ENOTSUP;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pinmux_driver_api api_funcs = {
|
|
||||||
.set = galileo_dev_set,
|
|
||||||
.get = galileo_dev_get,
|
|
||||||
.pullup = galileo_dev_pullup,
|
|
||||||
.input = galileo_dev_input_enable
|
|
||||||
};
|
|
||||||
|
|
||||||
int pinmux_galileo_initialize(struct device *port)
|
|
||||||
{
|
|
||||||
struct galileo_data *dev = port->driver_data;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
port->driver_api = &api_funcs;
|
|
||||||
|
|
||||||
/* Grab the EXP0, EXP1, EXP2, and PWM0 now by name */
|
|
||||||
dev->exp0 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP0_NAME);
|
|
||||||
if (!dev->exp0) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->exp1 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP1_NAME);
|
|
||||||
if (!dev->exp1) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->exp2 = device_get_binding(CONFIG_PINMUX_GALILEO_EXP2_NAME);
|
|
||||||
if (!dev->exp2) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->pwm0 = device_get_binding(CONFIG_PINMUX_GALILEO_PWM0_NAME);
|
|
||||||
if (!dev->pwm0) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->gpio_dw = device_get_binding(CONFIG_PINMUX_GALILEO_GPIO_DW_NAME);
|
|
||||||
if (!dev->gpio_dw) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->gpio_core = device_get_binding(
|
|
||||||
CONFIG_PINMUX_GALILEO_GPIO_INTEL_CW_NAME);
|
|
||||||
if (!dev->gpio_core) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
dev->gpio_resume = device_get_binding(
|
|
||||||
CONFIG_PINMUX_GALILEO_GPIO_INTEL_RW_NAME);
|
|
||||||
if (!dev->gpio_resume) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now that we have everything, let us start parsing everything
|
|
||||||
* from the above mapping as selected by the end user
|
|
||||||
*/
|
|
||||||
for (i = 0; i < CONFIG_PINMUX_NUM_PINS; i++) {
|
|
||||||
_galileo_set_pin(port,
|
|
||||||
mux_config[i].pin_num,
|
|
||||||
mux_config[i].mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct pinmux_config galileo_pmux = {
|
|
||||||
.base_address = 0x00000000,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct galileo_data galileo_pinmux_driver = {
|
|
||||||
.exp0 = NULL,
|
|
||||||
.exp1 = NULL,
|
|
||||||
.exp2 = NULL,
|
|
||||||
.pwm0 = NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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_INIT(pmux, PINMUX_NAME, &pinmux_galileo_initialize,
|
|
||||||
&galileo_pinmux_driver, &galileo_pmux,
|
|
||||||
SECONDARY, CONFIG_PINMUX_INIT_PRIORITY);
|
|
46
drivers/pinmux/galileo/pinmux_galileo.h
Normal file
46
drivers/pinmux/galileo/pinmux_galileo.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/* pinmux_galileo.h */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Intel Corporation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PINMUX_GALILEO_PRIV_H
|
||||||
|
#define __PINMUX_GALILEO_PRIV_H
|
||||||
|
|
||||||
|
struct galileo_data {
|
||||||
|
struct device *exp0;
|
||||||
|
struct device *exp1;
|
||||||
|
struct device *exp2;
|
||||||
|
struct device *pwm0;
|
||||||
|
|
||||||
|
/* GPIO<0>..GPIO<7> */
|
||||||
|
struct device *gpio_dw;
|
||||||
|
|
||||||
|
/* GPIO<8>..GPIO<9>, which means to pin 0 and 1 on core well. */
|
||||||
|
struct device *gpio_core;
|
||||||
|
|
||||||
|
/* GPIO_SUS<0>..GPIO_SUS<5> */
|
||||||
|
struct device *gpio_resume;
|
||||||
|
|
||||||
|
struct pin_config *mux_config;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct galileo_data galileo_pinmux_driver;
|
||||||
|
|
||||||
|
int _galileo_pinmux_set_pin(struct device *port, uint8_t pin, uint32_t func);
|
||||||
|
|
||||||
|
int _galileo_pinmux_get_pin(struct device *port, uint32_t pin, uint32_t *func);
|
||||||
|
|
||||||
|
#endif /* __PINMUX_GALILEO_PRIV_H */
|
Loading…
Add table
Add a link
Reference in a new issue