aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt26
-rw-r--r--drivers/gpio/gpio-mcp23s08.c41
2 files changed, 52 insertions, 15 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
index 629d0ef17308..daa30174bcc1 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
@@ -3,10 +3,17 @@ Microchip MCP2308/MCP23S08/MCP23017/MCP23S17 driver for
3 3
4Required properties: 4Required properties:
5- compatible : Should be 5- compatible : Should be
6 - "mcp,mcp23s08" for 8 GPIO SPI version 6 - "mcp,mcp23s08" (DEPRECATED) for 8 GPIO SPI version
7 - "mcp,mcp23s17" for 16 GPIO SPI version 7 - "mcp,mcp23s17" (DEPRECATED) for 16 GPIO SPI version
8 - "mcp,mcp23008" for 8 GPIO I2C version or 8 - "mcp,mcp23008" (DEPRECATED) for 8 GPIO I2C version or
9 - "mcp,mcp23017" for 16 GPIO I2C version of the chip 9 - "mcp,mcp23017" (DEPRECATED) for 16 GPIO I2C version of the chip
10
11 - "microchip,mcp23s08" for 8 GPIO SPI version
12 - "microchip,mcp23s17" for 16 GPIO SPI version
13 - "microchip,mcp23008" for 8 GPIO I2C version or
14 - "microchip,mcp23017" for 16 GPIO I2C version of the chip
15 NOTE: Do not use the old mcp prefix any more. It is deprecated and will be
16 removed.
10- #gpio-cells : Should be two. 17- #gpio-cells : Should be two.
11 - first cell is the pin number 18 - first cell is the pin number
12 - second cell is used to specify flags. Flags are currently unused. 19 - second cell is used to specify flags. Flags are currently unused.
@@ -15,10 +22,11 @@ Required properties:
15 SPI uses this to specify the chipselect line which the chip is 22 SPI uses this to specify the chipselect line which the chip is
16 connected to. The driver and the SPI variant of the chip support 23 connected to. The driver and the SPI variant of the chip support
17 multiple chips on the same chipselect. Have a look at 24 multiple chips on the same chipselect. Have a look at
18 mcp,spi-present-mask below. 25 microchip,spi-present-mask below.
19 26
20Required device specific properties (only for SPI chips): 27Required device specific properties (only for SPI chips):
21- mcp,spi-present-mask : This is a present flag, that makes only sense for SPI 28- mcp,spi-present-mask (DEPRECATED)
29- microchip,spi-present-mask : This is a present flag, that makes only sense for SPI
22 chips - as the name suggests. Multiple SPI chips can share the same 30 chips - as the name suggests. Multiple SPI chips can share the same
23 SPI chipselect. Set a bit in bit0-7 in this mask to 1 if there is a 31 SPI chipselect. Set a bit in bit0-7 in this mask to 1 if there is a
24 chip connected with the corresponding spi address set. For example if 32 chip connected with the corresponding spi address set. For example if
@@ -26,11 +34,13 @@ Required device specific properties (only for SPI chips):
26 which is 0x08. mcp23s08 chip variant only supports bits 0-3. It is not 34 which is 0x08. mcp23s08 chip variant only supports bits 0-3. It is not
27 possible to mix mcp23s08 and mcp23s17 on the same chipselect. Set at 35 possible to mix mcp23s08 and mcp23s17 on the same chipselect. Set at
28 least one bit to 1 for SPI chips. 36 least one bit to 1 for SPI chips.
37 NOTE: Do not use the old mcp prefix any more. It is deprecated and will be
38 removed.
29- spi-max-frequency = The maximum frequency this chip is able to handle 39- spi-max-frequency = The maximum frequency this chip is able to handle
30 40
31Example I2C: 41Example I2C:
32gpiom1: gpio@20 { 42gpiom1: gpio@20 {
33 compatible = "mcp,mcp23017"; 43 compatible = "microchip,mcp23017";
34 gpio-controller; 44 gpio-controller;
35 #gpio-cells = <2>; 45 #gpio-cells = <2>;
36 reg = <0x20>; 46 reg = <0x20>;
@@ -38,7 +48,7 @@ gpiom1: gpio@20 {
38 48
39Example SPI: 49Example SPI:
40gpiom1: gpio@0 { 50gpiom1: gpio@0 {
41 compatible = "mcp,mcp23s17"; 51 compatible = "microchip,mcp23s17";
42 gpio-controller; 52 gpio-controller;
43 #gpio-cells = <2>; 53 #gpio-cells = <2>;
44 spi-present-mask = <0x01>; 54 spi-present-mask = <0x01>;
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index d96bf8a76f5c..2deb0c5e54a4 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -483,10 +483,21 @@ fail:
483#ifdef CONFIG_SPI_MASTER 483#ifdef CONFIG_SPI_MASTER
484static struct of_device_id mcp23s08_spi_of_match[] = { 484static struct of_device_id mcp23s08_spi_of_match[] = {
485 { 485 {
486 .compatible = "mcp,mcp23s08", .data = (void *) MCP_TYPE_S08, 486 .compatible = "microchip,mcp23s08",
487 .data = (void *) MCP_TYPE_S08,
487 }, 488 },
488 { 489 {
489 .compatible = "mcp,mcp23s17", .data = (void *) MCP_TYPE_S17, 490 .compatible = "microchip,mcp23s17",
491 .data = (void *) MCP_TYPE_S17,
492 },
493/* NOTE: The use of the mcp prefix is deprecated and will be removed. */
494 {
495 .compatible = "mcp,mcp23s08",
496 .data = (void *) MCP_TYPE_S08,
497 },
498 {
499 .compatible = "mcp,mcp23s17",
500 .data = (void *) MCP_TYPE_S17,
490 }, 501 },
491 { }, 502 { },
492}; 503};
@@ -496,10 +507,21 @@ MODULE_DEVICE_TABLE(of, mcp23s08_spi_of_match);
496#if IS_ENABLED(CONFIG_I2C) 507#if IS_ENABLED(CONFIG_I2C)
497static struct of_device_id mcp23s08_i2c_of_match[] = { 508static struct of_device_id mcp23s08_i2c_of_match[] = {
498 { 509 {
499 .compatible = "mcp,mcp23008", .data = (void *) MCP_TYPE_008, 510 .compatible = "microchip,mcp23008",
511 .data = (void *) MCP_TYPE_008,
512 },
513 {
514 .compatible = "microchip,mcp23017",
515 .data = (void *) MCP_TYPE_017,
500 }, 516 },
517/* NOTE: The use of the mcp prefix is deprecated and will be removed. */
501 { 518 {
502 .compatible = "mcp,mcp23017", .data = (void *) MCP_TYPE_017, 519 .compatible = "mcp,mcp23008",
520 .data = (void *) MCP_TYPE_008,
521 },
522 {
523 .compatible = "mcp,mcp23017",
524 .data = (void *) MCP_TYPE_017,
503 }, 525 },
504 { }, 526 { },
505}; 527};
@@ -620,10 +642,15 @@ static int mcp23s08_probe(struct spi_device *spi)
620 if (match) { 642 if (match) {
621 type = (int)match->data; 643 type = (int)match->data;
622 status = of_property_read_u32(spi->dev.of_node, 644 status = of_property_read_u32(spi->dev.of_node,
623 "mcp,spi-present-mask", &spi_present_mask); 645 "microchip,spi-present-mask", &spi_present_mask);
624 if (status) { 646 if (status) {
625 dev_err(&spi->dev, "DT has no spi-present-mask\n"); 647 status = of_property_read_u32(spi->dev.of_node,
626 return -ENODEV; 648 "mcp,spi-present-mask", &spi_present_mask);
649 if (status) {
650 dev_err(&spi->dev,
651 "DT has no spi-present-mask\n");
652 return -ENODEV;
653 }
627 } 654 }
628 if ((spi_present_mask <= 0) || (spi_present_mask >= 256)) { 655 if ((spi_present_mask <= 0) || (spi_present_mask >= 256)) {
629 dev_err(&spi->dev, "invalid spi-present-mask\n"); 656 dev_err(&spi->dev, "invalid spi-present-mask\n");