drivers: add bindings for all existing mcp23xxx variants
This allows getting rid of the ngpios property, which is implicit in the part number. It also prepares for configuring pins as open-drain on supporting chips in the next commit. Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
This commit is contained in:
parent
75b3bf5b6c
commit
054cc09c88
16 changed files with 146 additions and 46 deletions
|
@ -45,6 +45,12 @@ Device Drivers and Devicetree
|
||||||
* The ``compatible`` of the LiteX uart controller has been renamed from
|
* The ``compatible`` of the LiteX uart controller has been renamed from
|
||||||
``litex,uart0`` to :dtcompatible:`litex,uart`. (:github:`74522`)
|
``litex,uart0`` to :dtcompatible:`litex,uart`. (:github:`74522`)
|
||||||
|
|
||||||
|
* The devicetree bindings for the Microchip ``mcp23xxx`` series have been split up. Users of
|
||||||
|
``microchip,mcp230xx`` and ``microchip,mcp23sxx`` should change their devicetree ``compatible``
|
||||||
|
values to the specific chip variant, e.g. :dtcompatible:`microchip,mcp23017`.
|
||||||
|
The ``ngpios`` devicetree property has been removed, since it is implied by the model name.
|
||||||
|
(:github:`65797`)
|
||||||
|
|
||||||
Controller Area Network (CAN)
|
Controller Area Network (CAN)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,11 @@ config GPIO_MCP23XXX
|
||||||
menuconfig GPIO_MCP230XX
|
menuconfig GPIO_MCP230XX
|
||||||
bool "MCP230XX I2C-based GPIO chip"
|
bool "MCP230XX I2C-based GPIO chip"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_MCP230XX_ENABLED
|
depends on DT_HAS_MICROCHIP_MCP23008_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23009_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23016_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23017_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23018_ENABLED
|
||||||
depends on I2C
|
depends on I2C
|
||||||
select GPIO_MCP23XXX
|
select GPIO_MCP23XXX
|
||||||
help
|
help
|
||||||
|
@ -31,7 +35,10 @@ endif #GPIO_MCP230XX
|
||||||
menuconfig GPIO_MCP23SXX
|
menuconfig GPIO_MCP23SXX
|
||||||
bool "MCP23SXX SPI-based GPIO chip"
|
bool "MCP23SXX SPI-based GPIO chip"
|
||||||
default y
|
default y
|
||||||
depends on DT_HAS_MICROCHIP_MCP23SXX_ENABLED
|
depends on DT_HAS_MICROCHIP_MCP23S08_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23S09_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23S17_ENABLED || \
|
||||||
|
DT_HAS_MICROCHIP_MCP23S18_ENABLED
|
||||||
depends on SPI
|
depends on SPI
|
||||||
select GPIO_MCP23XXX
|
select GPIO_MCP23XXX
|
||||||
help
|
help
|
||||||
|
|
|
@ -75,9 +75,7 @@ static int mcp230xx_bus_is_ready(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DT_DRV_COMPAT microchip_mcp230xx
|
#define GPIO_MCP230XX_DEVICE(inst, num_gpios) \
|
||||||
|
|
||||||
#define GPIO_MCP230XX_DEVICE(inst) \
|
|
||||||
static struct mcp23xxx_drv_data mcp230xx_##inst##_drvdata = { \
|
static struct mcp23xxx_drv_data mcp230xx_##inst##_drvdata = { \
|
||||||
/* Default for registers according to datasheet */ \
|
/* Default for registers according to datasheet */ \
|
||||||
.reg_cache.iodir = 0xFFFF, .reg_cache.ipol = 0x0, .reg_cache.gpinten = 0x0, \
|
.reg_cache.iodir = 0xFFFF, .reg_cache.ipol = 0x0, .reg_cache.gpinten = 0x0, \
|
||||||
|
@ -94,7 +92,7 @@ static int mcp230xx_bus_is_ready(const struct device *dev)
|
||||||
}, \
|
}, \
|
||||||
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}), \
|
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}), \
|
||||||
.gpio_reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
|
.gpio_reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
|
||||||
.ngpios = DT_INST_PROP(inst, ngpios), \
|
.ngpios = num_gpios, \
|
||||||
.read_fn = mcp230xx_read_port_regs, \
|
.read_fn = mcp230xx_read_port_regs, \
|
||||||
.write_fn = mcp230xx_write_port_regs, \
|
.write_fn = mcp230xx_write_port_regs, \
|
||||||
.bus_fn = mcp230xx_bus_is_ready, \
|
.bus_fn = mcp230xx_bus_is_ready, \
|
||||||
|
@ -103,4 +101,18 @@ static int mcp230xx_bus_is_ready(const struct device *dev)
|
||||||
&mcp230xx_##inst##_config, POST_KERNEL, \
|
&mcp230xx_##inst##_config, POST_KERNEL, \
|
||||||
CONFIG_GPIO_MCP230XX_INIT_PRIORITY, &gpio_mcp23xxx_api_table);
|
CONFIG_GPIO_MCP230XX_INIT_PRIORITY, &gpio_mcp23xxx_api_table);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(GPIO_MCP230XX_DEVICE)
|
#define DT_DRV_COMPAT microchip_mcp23008
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP230XX_DEVICE, 8)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23009
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP230XX_DEVICE, 8)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23016
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP230XX_DEVICE, 16)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23017
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP230XX_DEVICE, 16)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23018
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP230XX_DEVICE, 16)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
|
|
@ -113,9 +113,7 @@ static int mcp23sxx_bus_is_ready(const struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DT_DRV_COMPAT microchip_mcp23sxx
|
#define GPIO_MCP23SXX_DEVICE(inst, num_gpios) \
|
||||||
|
|
||||||
#define GPIO_MCP23SXX_DEVICE(inst) \
|
|
||||||
static struct mcp23xxx_drv_data mcp23sxx_##inst##_drvdata = { \
|
static struct mcp23xxx_drv_data mcp23sxx_##inst##_drvdata = { \
|
||||||
/* Default for registers according to datasheet */ \
|
/* Default for registers according to datasheet */ \
|
||||||
.reg_cache.iodir = 0xFFFF, .reg_cache.ipol = 0x0, .reg_cache.gpinten = 0x0, \
|
.reg_cache.iodir = 0xFFFF, .reg_cache.ipol = 0x0, .reg_cache.gpinten = 0x0, \
|
||||||
|
@ -134,7 +132,7 @@ static int mcp23sxx_bus_is_ready(const struct device *dev)
|
||||||
}, \
|
}, \
|
||||||
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}), \
|
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}), \
|
||||||
.gpio_reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
|
.gpio_reset = GPIO_DT_SPEC_INST_GET_OR(inst, reset_gpios, {0}), \
|
||||||
.ngpios = DT_INST_PROP(inst, ngpios), \
|
.ngpios = num_gpios, \
|
||||||
.read_fn = mcp23sxx_read_port_regs, \
|
.read_fn = mcp23sxx_read_port_regs, \
|
||||||
.write_fn = mcp23sxx_write_port_regs, \
|
.write_fn = mcp23sxx_write_port_regs, \
|
||||||
.bus_fn = mcp23sxx_bus_is_ready \
|
.bus_fn = mcp23sxx_bus_is_ready \
|
||||||
|
@ -143,4 +141,16 @@ static int mcp23sxx_bus_is_ready(const struct device *dev)
|
||||||
&mcp23sxx_##inst##_config, POST_KERNEL, \
|
&mcp23sxx_##inst##_config, POST_KERNEL, \
|
||||||
CONFIG_GPIO_MCP23SXX_INIT_PRIORITY, &gpio_mcp23xxx_api_table);
|
CONFIG_GPIO_MCP23SXX_INIT_PRIORITY, &gpio_mcp23xxx_api_table);
|
||||||
|
|
||||||
DT_INST_FOREACH_STATUS_OKAY(GPIO_MCP23SXX_DEVICE)
|
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23s08
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP23SXX_DEVICE, 8)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23s09
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP23SXX_DEVICE, 8)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23s17
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP23SXX_DEVICE, 16)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
#define DT_DRV_COMPAT microchip_mcp23s18
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY_VARGS(GPIO_MCP23SXX_DEVICE, 16)
|
||||||
|
#undef DT_DRV_COMPAT
|
||||||
|
|
11
dts/bindings/gpio/microchip,mcp23008.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23008.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23008 I2C GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23008"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23009.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23009.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23009 I2C GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23009"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23016.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23016.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23016 I2C GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23016"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23017.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23017.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23017 I2C GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23017"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23018.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23018.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23018 I2C GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23018"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
|
@ -1,12 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2021 metraTec GmbH
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
description: |
|
|
||||||
This is a representation of the Microchip MCP230xx I2C Gpio Expander.
|
|
||||||
|
|
||||||
compatible: "microchip,mcp230xx"
|
|
||||||
|
|
||||||
include: ["microchip,mcp23xxx.yaml", i2c-device.yaml]
|
|
11
dts/bindings/gpio/microchip,mcp23s08.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23s08.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23S08 SPI GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23s08"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", spi-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23s09.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23s09.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23S09 SPI GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23s09"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", spi-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23s17.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23s17.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23S17 SPI GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23s17"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", spi-device.yaml]
|
11
dts/bindings/gpio/microchip,mcp23s18.yaml
Normal file
11
dts/bindings/gpio/microchip,mcp23s18.yaml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024 SILA Embedded Solutions GmbH
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
description: This is a representation of the Microchip MCP23S18 SPI GPIO Expander.
|
||||||
|
|
||||||
|
compatible: "microchip,mcp23s18"
|
||||||
|
|
||||||
|
include: ["microchip,mcp23xxx.yaml", spi-device.yaml]
|
|
@ -1,13 +0,0 @@
|
||||||
#
|
|
||||||
# Copyright (c) 2020 Geanix ApS
|
|
||||||
# Copyright (c) 2021 Peter Johanson
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
description: |
|
|
||||||
This is a representation of the Microchip MCP23SXX SPI Gpio Expander.
|
|
||||||
|
|
||||||
compatible: "microchip,mcp23sxx"
|
|
||||||
|
|
||||||
include: ["microchip,mcp23xxx.yaml", spi-device.yaml]
|
|
|
@ -22,15 +22,6 @@ properties:
|
||||||
description: |
|
description: |
|
||||||
GPIO connected to the controller RESET pin. This pin is active-low.
|
GPIO connected to the controller RESET pin. This pin is active-low.
|
||||||
|
|
||||||
ngpios:
|
|
||||||
type: int
|
|
||||||
enum:
|
|
||||||
- 8
|
|
||||||
- 16
|
|
||||||
required: true
|
|
||||||
description: |
|
|
||||||
Number of gpios supported by the chip.
|
|
||||||
|
|
||||||
gpio-cells:
|
gpio-cells:
|
||||||
- pin
|
- pin
|
||||||
- flags
|
- flags
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue