Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 1 | Microchip MCP2308/MCP23S08/MCP23017/MCP23S17 driver for |
| 2 | 8-/16-bit I/O expander with serial interface (I2C/SPI) |
| 3 | |
| 4 | Required properties: |
| 5 | - compatible : Should be |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 6 | - "mcp,mcp23s08" (DEPRECATED) for 8 GPIO SPI version |
| 7 | - "mcp,mcp23s17" (DEPRECATED) for 16 GPIO SPI version |
| 8 | - "mcp,mcp23008" (DEPRECATED) for 8 GPIO I2C version or |
| 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 |
Phil Reid | 28c5a41 | 2016-03-01 14:25:41 +0800 | [diff] [blame] | 13 | - "microchip,mcp23s18" for 16 GPIO SPI version |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 14 | - "microchip,mcp23008" for 8 GPIO I2C version or |
| 15 | - "microchip,mcp23017" for 16 GPIO I2C version of the chip |
| 16 | NOTE: Do not use the old mcp prefix any more. It is deprecated and will be |
| 17 | removed. |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 18 | - #gpio-cells : Should be two. |
| 19 | - first cell is the pin number |
| 20 | - second cell is used to specify flags. Flags are currently unused. |
| 21 | - gpio-controller : Marks the device node as a GPIO controller. |
| 22 | - reg : For an address on its bus. I2C uses this a the I2C address of the chip. |
| 23 | SPI uses this to specify the chipselect line which the chip is |
| 24 | connected to. The driver and the SPI variant of the chip support |
| 25 | multiple chips on the same chipselect. Have a look at |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 26 | microchip,spi-present-mask below. |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 27 | |
| 28 | Required device specific properties (only for SPI chips): |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 29 | - mcp,spi-present-mask (DEPRECATED) |
| 30 | - microchip,spi-present-mask : This is a present flag, that makes only sense for SPI |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 31 | chips - as the name suggests. Multiple SPI chips can share the same |
| 32 | SPI chipselect. Set a bit in bit0-7 in this mask to 1 if there is a |
| 33 | chip connected with the corresponding spi address set. For example if |
| 34 | you have a chip with address 3 connected, you have to set bit3 to 1, |
| 35 | which is 0x08. mcp23s08 chip variant only supports bits 0-3. It is not |
| 36 | possible to mix mcp23s08 and mcp23s17 on the same chipselect. Set at |
| 37 | least one bit to 1 for SPI chips. |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 38 | NOTE: Do not use the old mcp prefix any more. It is deprecated and will be |
| 39 | removed. |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 40 | - spi-max-frequency = The maximum frequency this chip is able to handle |
| 41 | |
Lars Poeschel | 4e47f91 | 2014-01-16 11:44:15 +0100 | [diff] [blame] | 42 | Optional properties: |
| 43 | - #interrupt-cells : Should be two. |
| 44 | - first cell is the pin number |
| 45 | - second cell is used to specify flags. |
| 46 | - interrupt-controller: Marks the device node as a interrupt controller. |
Lars Poeschel | 4e47f91 | 2014-01-16 11:44:15 +0100 | [diff] [blame] | 47 | |
| 48 | Optional device specific properties: |
| 49 | - microchip,irq-mirror: Sets the mirror flag in the IOCON register. Devices |
| 50 | with two interrupt outputs (these are the devices ending with 17 and |
| 51 | those that have 16 IOs) have two IO banks: IO 0-7 form bank 1 and |
| 52 | IO 8-15 are bank 2. These chips have two different interrupt outputs: |
| 53 | One for bank 1 and another for bank 2. If irq-mirror is set, both |
| 54 | interrupts are generated regardless of the bank that an input change |
Carlos Garcia | c98be0c | 2014-04-04 22:31:00 -0400 | [diff] [blame] | 55 | occurred on. If it is not set, the interrupt are only generated for the |
Lars Poeschel | 4e47f91 | 2014-01-16 11:44:15 +0100 | [diff] [blame] | 56 | bank they belong to. |
| 57 | On devices with only one interrupt output this property is useless. |
Alexander Stein | a4e6355 | 2014-12-01 08:26:00 +0100 | [diff] [blame] | 58 | - microchip,irq-active-high: Sets the INTPOL flag in the IOCON register. This |
| 59 | configures the IRQ output polarity as active high. |
Lars Poeschel | 4e47f91 | 2014-01-16 11:44:15 +0100 | [diff] [blame] | 60 | |
| 61 | Example I2C (with interrupt): |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 62 | gpiom1: gpio@20 { |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 63 | compatible = "microchip,mcp23017"; |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 64 | gpio-controller; |
| 65 | #gpio-cells = <2>; |
| 66 | reg = <0x20>; |
Lars Poeschel | 4e47f91 | 2014-01-16 11:44:15 +0100 | [diff] [blame] | 67 | |
| 68 | interrupt-parent = <&gpio1>; |
| 69 | interrupts = <17 IRQ_TYPE_LEVEL_LOW>; |
| 70 | interrupt-controller; |
| 71 | #interrupt-cells=<2>; |
| 72 | microchip,irq-mirror; |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | Example SPI: |
| 76 | gpiom1: gpio@0 { |
Lars Poeschel | 4597168 | 2013-08-28 10:38:50 +0200 | [diff] [blame] | 77 | compatible = "microchip,mcp23s17"; |
Lars Poeschel | 97ddb1c | 2013-04-04 12:02:02 +0200 | [diff] [blame] | 78 | gpio-controller; |
| 79 | #gpio-cells = <2>; |
| 80 | spi-present-mask = <0x01>; |
| 81 | reg = <0>; |
| 82 | spi-max-frequency = <1000000>; |
| 83 | }; |