wifi: winc1500: Add Device Tree support

Add a dts binding for the Atmel WINC1500 WIFI chip.  Update the
quark_se_c1000_devboard to utilize this binding as well as the wifi
sample app.

We now get all the GPIOs related to the Atmel WINC1500 from the device
tree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2018-11-06 16:50:28 -06:00 committed by Anas Nashif
parent 67e4710598
commit 9730ca1852
8 changed files with 92 additions and 74 deletions

View File

@ -18,48 +18,12 @@ config WIFI_WINC1500_NAME
string "Driver name"
default "WINC1500"
config WIFI_WINC1500_SPI_DRV_NAME
string "SPI device where WINC1500 is connected"
default "SPI_1"
help
Specify the device name of the SPI device to which WINC1500 is
connected.
config WIFI_WINC1500_SPI_SLAVE
int "SPI Slave Select where WINC1500 is connected"
default 1
help
Specify the slave select pin of the SPI to which WINC1500 is
connected.
config WIFI_WINC1500_SPI_FREQ
int "SPI frequency to use with WINC1500"
default 8000000
help
SPI frequency to use with WINC1500
config WIFI_WINC1500_GPIO_SPI_CS
bool "Manage SPI CS through a GPIO pin"
help
This option is useful if one needs to manage SPI CS through a GPIO
pin to by-pass the SPI controller's CS logic.
config WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME
string "GPIO driver's name to use to drive SPI CS through"
default ""
depends on WIFI_WINC1500_GPIO_SPI_CS
help
This option is mandatory to set which GPIO controller to use in
order to actually emulate the SPI CS.
config WIFI_WINC1500_GPIO_SPI_CS_PIN
int "GPIO PIN to use to drive SPI CS through"
default 0
depends on WIFI_WINC1500_GPIO_SPI_CS
help
This option is mandatory to set which GPIO pin to use in order
to actually emulate the SPI CS.
config WIFI_WINC1500_THREAD_STACK_SIZE
int "HAL callback handler thread stack size"
default 2048

View File

@ -96,32 +96,32 @@ s8_t nm_bus_init(void *pvinit)
/* Not implemented */
#elif defined CONF_WINC_USE_SPI
/* setup SPI device */
winc1500.spi = device_get_binding(CONFIG_WIFI_WINC1500_SPI_DRV_NAME);
winc1500.spi = device_get_binding(DT_WIFI_WINC1500_SPI_DRV_NAME);
if (!winc1500.spi) {
LOG_ERR("spi device binding");
return -1;
}
winc1500.spi_cfg.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB;
winc1500.spi_cfg.frequency = CONFIG_WIFI_WINC1500_SPI_FREQ;
winc1500.spi_cfg.slave = CONFIG_WIFI_WINC1500_SPI_SLAVE;
winc1500.spi_cfg.frequency = DT_WIFI_WINC1500_SPI_FREQ;
winc1500.spi_cfg.slave = DT_WIFI_WINC1500_SPI_SLAVE;
#ifdef CONFIG_WIFI_WINC1500_GPIO_SPI_CS
cs_ctrl.gpio_dev = device_get_binding(
CONFIG_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME);
DT_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME);
if (!cs_ctrl.gpio_dev) {
LOG_ERR("Unable to get GPIO SPI CS device");
return -ENODEV;
}
cs_ctrl.gpio_pin = CONFIG_WIFI_WINC1500_GPIO_SPI_CS_PIN;
cs_ctrl.gpio_pin = DT_WIFI_WINC1500_GPIO_SPI_CS_PIN;
cs_ctrl.delay = 0;
winc1500.spi_cfg.cs = &cs_ctrl;
LOG_DBG("SPI GPIO CS configured on %s:%u",
CONFIG_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME,
CONFIG_WIFI_WINC1500_GPIO_SPI_CS_PIN);
DT_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME,
DT_WIFI_WINC1500_GPIO_SPI_CS_PIN);
#endif /* CONFIG_WIFI_WINC1500_GPIO_SPI_CS */
nm_bsp_reset();

View File

@ -0,0 +1,35 @@
#
# Copyright (c) 2018, Linaro Limited
#
# SPDX-License-Identifier: Apache-2.0
#
---
title: Atmel WINC1500 Wifi module
version: 0.1
description: >
This binding gives the base representation of the Atmel WINC1500 Wifi module
inherits:
!include spi-device.yaml
properties:
compatible:
constraint: "atmel,winc1500"
irq-gpios:
type: compound
category: required
generation: define, use-prop-name
reset-gpios:
type: compound
category: required
generation: define, use-prop-name
enable-gpios:
type: compound
category: required
generation: define, use-prop-name
...

View File

@ -1,20 +0,0 @@
mainmenu "Wi-Fi sample"
if WIFI_WINC1500
config WINC1500_GPIO_DRV_NAME
string "GPIO device name"
config WINC1500_GPIO_CHIP_EN
int "Pin number for Winc1500 CHIP_EN signal"
config WINC1500_GPIO_IRQN
int "Pin number for Winc1500 IRQn signal"
config WINC1500_GPIO_RESET_N
int "Pin number for Winc1500 RESET_N signal"
endif # WIFI_WINC1500
source "Kconfig.zephyr"

View File

@ -6,10 +6,3 @@ CONFIG_SPI_DW=y
CONFIG_WIFI_WINC1500=y
CONFIG_WIFI_WINC1500_REGION_EUROPE=y
CONFIG_WIFI_WINC1500_GPIO_SPI_CS=y
CONFIG_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME="GPIO_0"
CONFIG_WIFI_WINC1500_GPIO_SPI_CS_PIN=13
CONFIG_WINC1500_GPIO_DRV_NAME="GPIO_0"
CONFIG_WINC1500_GPIO_CHIP_EN=19
CONFIG_WINC1500_GPIO_IRQN=18
CONFIG_WINC1500_GPIO_RESET_N=26

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2018 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Board level DTS fixup file */
#if defined(CONFIG_BOARD_QUARK_SE_C1000_DEVBOARD)
#define DT_WIFI_WINC1500_SPI_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_BUS_NAME
#define DT_WIFI_WINC1500_SPI_SLAVE DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_BASE_ADDRESS
#define DT_WIFI_WINC1500_SPI_FREQ DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_SPI_MAX_FREQUENCY
#define DT_WIFI_WINC1500_GPIO_SPI_CS_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001400_CS_GPIOS_CONTROLLER
#define DT_WIFI_WINC1500_GPIO_SPI_CS_PIN DT_SNPS_DESIGNWARE_SPI_B0001400_CS_GPIOS_PIN
#define DT_WINC1500_GPIO_CHIP_EN_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_ENABLE_GPIOS_CONTROLLER
#define DT_WINC1500_GPIO_CHIP_EN DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_ENABLE_GPIOS_PIN
#define DT_WINC1500_GPIO_IRQN_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_IRQ_GPIOS_CONTROLLER
#define DT_WINC1500_GPIO_IRQN DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_IRQ_GPIOS_PIN
#define DT_WINC1500_GPIO_RESET_N_DRV_NAME DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_RESET_GPIOS_CONTROLLER
#define DT_WINC1500_GPIO_RESET_N DT_SNPS_DESIGNWARE_SPI_B0001400_ATMEL_WINC1500_0_RESET_GPIOS_PIN
/* For now we assume that all the GPIOs are on the same controller */
#define DT_WINC1500_GPIO_DRV_NAME DT_WINC1500_GPIO_CHIP_EN_DRV_NAME
#endif /* CONFIG_BOARD_QUARK_SE_C1000_DEVBOARD */

View File

@ -0,0 +1,18 @@
&spi1 {
status = "ok";
cs-gpios = <&gpio0 13 0>;
winc1500@0 {
status = "ok";
compatible = "atmel,winc1500";
reg = <0x0>;
label = "winc1500";
spi-max-frequency = <8000000>;
irq-gpios = <&gpio0 18 0>;
reset-gpios = <&gpio0 26 0>;
enable-gpios = <&gpio0 19 0>;
};
};

View File

@ -15,9 +15,9 @@
static
struct winc1500_gpio_configuration winc1500_gpios[WINC1500_GPIO_IDX_MAX] = {
{ .dev = NULL, .pin = CONFIG_WINC1500_GPIO_CHIP_EN },
{ .dev = NULL, .pin = CONFIG_WINC1500_GPIO_IRQN },
{ .dev = NULL, .pin = CONFIG_WINC1500_GPIO_RESET_N },
{ .dev = NULL, .pin = DT_WINC1500_GPIO_CHIP_EN },
{ .dev = NULL, .pin = DT_WINC1500_GPIO_IRQN },
{ .dev = NULL, .pin = DT_WINC1500_GPIO_RESET_N },
};
struct winc1500_gpio_configuration *winc1500_configure_gpios(void)
@ -28,7 +28,7 @@ struct winc1500_gpio_configuration *winc1500_configure_gpios(void)
const int flags_noint_out = GPIO_DIR_OUT;
struct device *gpio;
gpio = device_get_binding(CONFIG_WINC1500_GPIO_DRV_NAME);
gpio = device_get_binding(DT_WINC1500_GPIO_DRV_NAME);
gpio_pin_configure(gpio, winc1500_gpios[WINC1500_GPIO_IDX_CHIP_EN].pin,
flags_noint_out);