Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 1 | diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 2 | index 2fa5edac7a35..4906544628ec 100644 |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 3 | --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt |
| 4 | +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 5 | @@ -146,3 +146,38 @@ gpio21: gpio@21 { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 6 | bias-pull-up; |
| 7 | }; |
| 8 | }; |
| 9 | + |
| 10 | +Line naming |
| 11 | +=========== |
| 12 | + |
| 13 | +Because several gpio_chip instances are hidden below a single device tree |
| 14 | +node, it is necessary to split the names into several child nodes. Ensure |
| 15 | +that the configured addresses match those in the microchip,spi-present-mask: |
| 16 | + |
| 17 | +gpio@0 { |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 18 | + compatible = "microchip,mcp23s17"; |
| 19 | + gpio-controller; |
| 20 | + #gpio-cells = <2>; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 21 | + /* this bitmask has bits #0 (0x01) and #2 (0x04) set */ |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 22 | + spi-present-mask = <0x05>; |
| 23 | + reg = <0>; |
| 24 | + spi-max-frequency = <1000000>; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 25 | + |
| 26 | + gpio-bank@1 { |
| 27 | + address = <0>; |
| 28 | + gpio-line-names = |
| 29 | + "GPA0", |
| 30 | + "GPA1", |
| 31 | + ... |
| 32 | + "GPA7", |
| 33 | + "GPB0", |
| 34 | + "GPB1", |
| 35 | + ... |
| 36 | + "GPB7"; |
| 37 | + }; |
| 38 | + |
| 39 | + gpio-bank@2 { |
| 40 | + address = <2>; |
| 41 | + gpio-line-names = ... |
| 42 | + }; |
| 43 | +}; |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 44 | diff --git a/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi b/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
Jan Kundrát | 9ce4f9e | 2022-02-17 16:38:57 +0100 | [diff] [blame] | 45 | index f8a06ae4a3c9..8f32e05b6d87 100644 |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 46 | --- a/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
| 47 | +++ b/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
Jan Kundrát | 9ce4f9e | 2022-02-17 16:38:57 +0100 | [diff] [blame] | 48 | @@ -196,8 +196,12 @@ &i2c1 { |
| 49 | */ |
| 50 | clock-frequency = <100000>; |
| 51 | pinctrl-0 = <&clearfog_i2c1_pins>; |
| 52 | - pinctrl-names = "default"; |
| 53 | + pinctrl-1 = <&clearfog_i2c1_recovery_pins>; |
| 54 | + pinctrl-names = "default", "gpio"; |
| 55 | status = "okay"; |
| 56 | + single-master; |
| 57 | + scl-gpios = <&gpio0 26 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 58 | + sda-gpios = <&gpio0 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 59 | }; |
| 60 | |
| 61 | &pinctrl { |
| 62 | @@ -206,6 +210,10 @@ clearfog_i2c1_pins: i2c1-pins { |
| 63 | marvell,pins = "mpp26", "mpp27"; |
| 64 | marvell,function = "i2c1"; |
| 65 | }; |
| 66 | + clearfog_i2c1_recovery_pins: i2c1-recovery-pins { |
| 67 | + marvell,pins = "mpp26", "mpp27"; |
| 68 | + marvell,function = "gpio"; |
| 69 | + }; |
| 70 | clearfog_sdhci_cd_pins: clearfog-sdhci-cd-pins { |
| 71 | marvell,pins = "mpp20"; |
| 72 | marvell,function = "gpio"; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 73 | diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 74 | index dfc6fb2b3e52..07be0741f873 100644 |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 75 | --- a/drivers/leds/leds-tlc591xx.c |
| 76 | +++ b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 77 | @@ -40,6 +40,9 @@ |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 78 | |
| 79 | #define ldev_to_led(c) container_of(c, struct tlc591xx_led, ldev) |
| 80 | |
| 81 | +#define TLC591XX_RESET_BYTE_0 0xa5 |
| 82 | +#define TLC591XX_RESET_BYTE_1 0x5a |
| 83 | + |
| 84 | struct tlc591xx_led { |
| 85 | bool active; |
| 86 | unsigned int led_no; |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 87 | @@ -51,21 +54,25 @@ struct tlc591xx_priv { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 88 | struct tlc591xx_led leds[TLC591XX_MAX_LEDS]; |
| 89 | struct regmap *regmap; |
| 90 | unsigned int reg_ledout_offset; |
| 91 | + struct i2c_client *swrst_client; |
| 92 | }; |
| 93 | |
| 94 | struct tlc591xx { |
| 95 | unsigned int max_leds; |
| 96 | unsigned int reg_ledout_offset; |
| 97 | + u8 swrst_addr; |
| 98 | }; |
| 99 | |
| 100 | static const struct tlc591xx tlc59116 = { |
| 101 | .max_leds = 16, |
| 102 | .reg_ledout_offset = 0x14, |
| 103 | + .swrst_addr = 0x6b, |
| 104 | }; |
| 105 | |
| 106 | static const struct tlc591xx tlc59108 = { |
| 107 | .max_leds = 8, |
| 108 | .reg_ledout_offset = 0x0c, |
| 109 | + .swrst_addr = 0x4b, |
| 110 | }; |
| 111 | |
| 112 | static int |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 113 | @@ -179,6 +186,18 @@ tlc591xx_probe(struct i2c_client *client) |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 114 | |
| 115 | i2c_set_clientdata(client, priv); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 116 | |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 117 | + priv->swrst_client = devm_i2c_new_dummy_device(dev, client->adapter, tlc591xx->swrst_addr); |
Jan Kundrát | 89b682a | 2020-03-08 13:03:33 -0700 | [diff] [blame] | 118 | + if (IS_ERR(priv->swrst_client)) { |
| 119 | + dev_info(dev, "Skipping reset: address %02x already used\n", |
| 120 | + tlc591xx->swrst_addr); |
| 121 | + } else { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 122 | + err = i2c_smbus_write_byte_data(priv->swrst_client, |
| 123 | + TLC591XX_RESET_BYTE_0, TLC591XX_RESET_BYTE_1); |
| 124 | + if (err) { |
| 125 | + dev_warn(dev, "SW reset failed\n"); |
| 126 | + } |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 127 | + } |
| 128 | + |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 129 | err = tlc591xx_set_mode(priv->regmap, MODE2_DIM); |
| 130 | if (err < 0) |
| 131 | return err; |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 132 | diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig |
| 133 | index 2a57328eca20..dc6816d36d06 100644 |
| 134 | --- a/drivers/leds/trigger/Kconfig |
| 135 | +++ b/drivers/leds/trigger/Kconfig |
| 136 | @@ -83,7 +83,6 @@ config LEDS_TRIGGER_ACTIVITY |
| 137 | config LEDS_TRIGGER_GPIO |
| 138 | tristate "LED GPIO Trigger" |
| 139 | depends on GPIOLIB || COMPILE_TEST |
| 140 | - depends on BROKEN |
| 141 | help |
| 142 | This allows LEDs to be controlled by gpio events. It's good |
| 143 | when using gpios as switches and triggering the needed LEDs |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 144 | diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 145 | index ea059b9c5542..d58c6e631942 100644 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 146 | --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
| 147 | +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 148 | @@ -8,6 +8,7 @@ |
| 149 | #include <linux/spi/spi.h> |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 150 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 151 | #include "pinctrl-mcp23s08.h" |
| 152 | +#include "../gpio/gpiolib.h" |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 153 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 154 | #define MCP_MAX_DEV_PER_CS 8 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 155 | |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 156 | @@ -153,6 +154,10 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 157 | int type; |
| 158 | int ret; |
| 159 | u32 v; |
| 160 | + struct device_node *np; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 161 | + int line_name_count; |
| 162 | + const char **names; |
| 163 | + int i; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 164 | |
| 165 | match = device_get_match_data(dev); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 166 | if (match) |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 167 | @@ -202,6 +207,43 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 168 | return ret; |
| 169 | |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 170 | ngpio += data->mcp[addr]->chip.ngpio; |
| 171 | + |
| 172 | + for_each_available_child_of_node(spi->dev.of_node, np) { |
| 173 | + u32 chip_addr; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 174 | + ret = of_property_read_u32(np, "address", &chip_addr); |
| 175 | + if (ret) |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 176 | + continue; |
| 177 | + if (chip_addr != addr) |
| 178 | + continue; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 179 | + |
| 180 | + line_name_count = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", NULL, 0); |
| 181 | + if (line_name_count < 0) |
| 182 | + continue; |
| 183 | + |
| 184 | + if (line_name_count > data->mcp[addr]->chip.ngpio) { |
| 185 | + dev_warn(&spi->dev, "gpio-line-names is length %d but should be at most length %d", |
| 186 | + line_name_count, data->mcp[addr]->chip.ngpio); |
| 187 | + line_name_count = data->mcp[addr]->chip.ngpio; |
| 188 | + } |
| 189 | + |
| 190 | + names = kcalloc(line_name_count, sizeof(*names), GFP_KERNEL); |
| 191 | + if (!names) { |
| 192 | + dev_warn(&spi->dev, "cannot allocate gpio-line-names"); |
| 193 | + continue; |
| 194 | + } |
| 195 | + |
| 196 | + ret = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", names, line_name_count); |
| 197 | + if (ret < 0) { |
| 198 | + dev_warn(&spi->dev, "failed to read GPIO line names"); |
| 199 | + kfree(names); |
| 200 | + continue; |
| 201 | + } |
| 202 | + |
| 203 | + for (i = 0; i < line_name_count; i++) |
| 204 | + data->mcp[addr]->chip.gpiodev->descs[i].name = names[i]; |
| 205 | + |
| 206 | + kfree(names); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 207 | + } |
| 208 | } |
| 209 | data->ngpio = ngpio; |
| 210 | |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 211 | diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 212 | index ad9e83e34297..dc5c60182ea5 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 213 | --- a/drivers/spi/spi-orion.c |
| 214 | +++ b/drivers/spi/spi-orion.c |
Jan Kundrát | 277991e | 2023-02-24 21:12:13 +0100 | [diff] [blame] | 215 | @@ -473,7 +473,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 216 | int cs = spi_get_chipselect(spi, 0); |
Jan Kundrát | 549db87 | 2019-03-05 12:23:25 +0100 | [diff] [blame] | 217 | void __iomem *vaddr; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 218 | |
| 219 | - word_len = spi->bits_per_word; |
| 220 | + word_len = xfer->bits_per_word; |
| 221 | count = xfer->len; |
| 222 | |
| 223 | orion_spi = spi_master_get_devdata(spi->master); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 224 | diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 225 | index 997e39449766..ccbb5b1bb0f4 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 226 | --- a/drivers/tty/serial/max310x.c |
| 227 | +++ b/drivers/tty/serial/max310x.c |
Jan Kundrát | 277991e | 2023-02-24 21:12:13 +0100 | [diff] [blame] | 228 | @@ -237,6 +237,10 @@ |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 229 | #define MAX310x_REV_MASK (0xf8) |
| 230 | #define MAX310X_WRITE_BIT 0x80 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 231 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 232 | +/* Timeout for external crystal stability */ |
| 233 | +#define MAX310X_XTAL_WAIT_RETRIES 20 |
| 234 | +#define MAX310X_XTAL_WAIT_DELAY_MS 10 |
| 235 | + |
| 236 | /* MAX3107 specific */ |
| 237 | #define MAX3107_REV_ID (0xa0) |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 238 | |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 239 | @@ -641,11 +645,14 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s, |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 240 | |
| 241 | /* Wait for crystal */ |
| 242 | if (xtal) { |
| 243 | - unsigned int val; |
| 244 | - msleep(10); |
| 245 | - regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 246 | + unsigned int val = 0, i; |
| 247 | + for (i = 0; i < MAX310X_XTAL_WAIT_RETRIES && !(val & MAX310X_STS_CLKREADY_BIT); ++i) { |
| 248 | + msleep(MAX310X_XTAL_WAIT_DELAY_MS); |
| 249 | + regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 250 | + } |
| 251 | if (!(val & MAX310X_STS_CLKREADY_BIT)) { |
| 252 | - dev_warn(dev, "clock is not stable yet\n"); |
| 253 | + dev_err(dev, "clock is not stable\n"); |
| 254 | + return -EAGAIN; |
| 255 | } |
| 256 | } |
| 257 | |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 258 | @@ -1348,6 +1355,10 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | uartclk = max310x_set_ref_clk(dev, s, freq, xtal); |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 262 | + if (uartclk < 0) { |
| 263 | + ret = uartclk; |
| 264 | + goto out_uart; |
| 265 | + } |
| 266 | dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 267 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 268 | for (i = 0; i < devtype->nr; i++) { |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 269 | @@ -1516,6 +1527,7 @@ static int max310x_spi_probe(struct spi_device *spi) |
| 270 | u8 port_mask = i * 0x20; |
| 271 | regcfg.read_flag_mask = port_mask; |
| 272 | regcfg.write_flag_mask = port_mask | MAX310X_WRITE_BIT; |
| 273 | + regcfg.name = kasprintf(GFP_KERNEL, "port-%d", i); |
| 274 | regmaps[i] = devm_regmap_init_spi(spi, ®cfg); |
| 275 | } |
Jan Kundrát | 277991e | 2023-02-24 21:12:13 +0100 | [diff] [blame] | 276 | |