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 | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 44 | diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 45 | index cb7bd1353f9f..85865f1628d7 100644 |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 46 | --- a/drivers/leds/leds-tlc591xx.c |
| 47 | +++ b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 48 | @@ -40,6 +40,9 @@ |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 49 | |
| 50 | #define ldev_to_led(c) container_of(c, struct tlc591xx_led, ldev) |
| 51 | |
| 52 | +#define TLC591XX_RESET_BYTE_0 0xa5 |
| 53 | +#define TLC591XX_RESET_BYTE_1 0x5a |
| 54 | + |
| 55 | struct tlc591xx_led { |
| 56 | bool active; |
| 57 | unsigned int led_no; |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 58 | @@ -51,21 +54,25 @@ struct tlc591xx_priv { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 59 | struct tlc591xx_led leds[TLC591XX_MAX_LEDS]; |
| 60 | struct regmap *regmap; |
| 61 | unsigned int reg_ledout_offset; |
| 62 | + struct i2c_client *swrst_client; |
| 63 | }; |
| 64 | |
| 65 | struct tlc591xx { |
| 66 | unsigned int max_leds; |
| 67 | unsigned int reg_ledout_offset; |
| 68 | + u8 swrst_addr; |
| 69 | }; |
| 70 | |
| 71 | static const struct tlc591xx tlc59116 = { |
| 72 | .max_leds = 16, |
| 73 | .reg_ledout_offset = 0x14, |
| 74 | + .swrst_addr = 0x6b, |
| 75 | }; |
| 76 | |
| 77 | static const struct tlc591xx tlc59108 = { |
| 78 | .max_leds = 8, |
| 79 | .reg_ledout_offset = 0x0c, |
| 80 | + .swrst_addr = 0x4b, |
| 81 | }; |
| 82 | |
| 83 | static int |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 84 | @@ -180,6 +187,18 @@ tlc591xx_probe(struct i2c_client *client, |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 85 | |
| 86 | i2c_set_clientdata(client, priv); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 87 | |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 88 | + 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] | 89 | + if (IS_ERR(priv->swrst_client)) { |
| 90 | + dev_info(dev, "Skipping reset: address %02x already used\n", |
| 91 | + tlc591xx->swrst_addr); |
| 92 | + } else { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 93 | + err = i2c_smbus_write_byte_data(priv->swrst_client, |
| 94 | + TLC591XX_RESET_BYTE_0, TLC591XX_RESET_BYTE_1); |
| 95 | + if (err) { |
| 96 | + dev_warn(dev, "SW reset failed\n"); |
| 97 | + } |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 98 | + } |
| 99 | + |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 100 | err = tlc591xx_set_mode(priv->regmap, MODE2_DIM); |
| 101 | if (err < 0) |
| 102 | return err; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 103 | diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 104 | index 9ae10318f6f3..d378369bbeca 100644 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 105 | --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
| 106 | +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 107 | @@ -8,6 +8,7 @@ |
| 108 | #include <linux/spi/spi.h> |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 109 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 110 | #include "pinctrl-mcp23s08.h" |
| 111 | +#include "../gpio/gpiolib.h" |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 112 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 113 | #define MCP_MAX_DEV_PER_CS 8 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 114 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 115 | @@ -143,6 +144,10 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 116 | int type; |
| 117 | int ret; |
| 118 | u32 v; |
| 119 | + struct device_node *np; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 120 | + int line_name_count; |
| 121 | + const char **names; |
| 122 | + int i; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 123 | |
| 124 | match = device_get_match_data(dev); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 125 | if (match) |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 126 | @@ -192,6 +197,43 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 127 | return ret; |
| 128 | |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 129 | ngpio += data->mcp[addr]->chip.ngpio; |
| 130 | + |
| 131 | + for_each_available_child_of_node(spi->dev.of_node, np) { |
| 132 | + u32 chip_addr; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 133 | + ret = of_property_read_u32(np, "address", &chip_addr); |
| 134 | + if (ret) |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 135 | + continue; |
| 136 | + if (chip_addr != addr) |
| 137 | + continue; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 138 | + |
| 139 | + line_name_count = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", NULL, 0); |
| 140 | + if (line_name_count < 0) |
| 141 | + continue; |
| 142 | + |
| 143 | + if (line_name_count > data->mcp[addr]->chip.ngpio) { |
| 144 | + dev_warn(&spi->dev, "gpio-line-names is length %d but should be at most length %d", |
| 145 | + line_name_count, data->mcp[addr]->chip.ngpio); |
| 146 | + line_name_count = data->mcp[addr]->chip.ngpio; |
| 147 | + } |
| 148 | + |
| 149 | + names = kcalloc(line_name_count, sizeof(*names), GFP_KERNEL); |
| 150 | + if (!names) { |
| 151 | + dev_warn(&spi->dev, "cannot allocate gpio-line-names"); |
| 152 | + continue; |
| 153 | + } |
| 154 | + |
| 155 | + ret = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", names, line_name_count); |
| 156 | + if (ret < 0) { |
| 157 | + dev_warn(&spi->dev, "failed to read GPIO line names"); |
| 158 | + kfree(names); |
| 159 | + continue; |
| 160 | + } |
| 161 | + |
| 162 | + for (i = 0; i < line_name_count; i++) |
| 163 | + data->mcp[addr]->chip.gpiodev->descs[i].name = names[i]; |
| 164 | + |
| 165 | + kfree(names); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 166 | + } |
| 167 | } |
| 168 | data->ngpio = ngpio; |
| 169 | |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 170 | diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 171 | index 565cd4c48d7b..cb252d98184c 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 172 | --- a/drivers/spi/spi-orion.c |
| 173 | +++ b/drivers/spi/spi-orion.c |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 174 | @@ -86,10 +86,6 @@ struct orion_direct_acc { |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 175 | u32 size; |
| 176 | }; |
| 177 | |
| 178 | -struct orion_child_options { |
| 179 | - struct orion_direct_acc direct_access; |
| 180 | -}; |
| 181 | - |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 182 | struct orion_spi { |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 183 | struct spi_master *master; |
| 184 | void __iomem *base; |
Václav Kubernát | f1b92ff | 2021-03-24 07:41:23 +0100 | [diff] [blame] | 185 | @@ -98,7 +94,7 @@ struct orion_spi { |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 186 | const struct orion_spi_dev *devdata; |
Václav Kubernát | f1b92ff | 2021-03-24 07:41:23 +0100 | [diff] [blame] | 187 | struct device *dev; |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 188 | |
| 189 | - struct orion_child_options child[ORION_NUM_CHIPSELECTS]; |
| 190 | + struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS]; |
| 191 | }; |
| 192 | |
Václav Kubernát | f1b92ff | 2021-03-24 07:41:23 +0100 | [diff] [blame] | 193 | #ifdef CONFIG_PM |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 194 | @@ -473,7 +469,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 195 | int cs = spi->chip_select; |
Jan Kundrát | 549db87 | 2019-03-05 12:23:25 +0100 | [diff] [blame] | 196 | void __iomem *vaddr; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 197 | |
| 198 | - word_len = spi->bits_per_word; |
| 199 | + word_len = xfer->bits_per_word; |
| 200 | count = xfer->len; |
| 201 | |
| 202 | orion_spi = spi_master_get_devdata(spi->master); |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 203 | @@ -483,7 +479,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) |
Václav Kubernát | f1b92ff | 2021-03-24 07:41:23 +0100 | [diff] [blame] | 204 | * and SPI_CS_WORD flag is not set. |
| 205 | * Otherwise fall back to PIO mode for this transfer. |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 206 | */ |
| 207 | - vaddr = orion_spi->child[cs].direct_access.vaddr; |
| 208 | + vaddr = orion_spi->direct_access[cs].vaddr; |
| 209 | |
Václav Kubernát | f1b92ff | 2021-03-24 07:41:23 +0100 | [diff] [blame] | 210 | if (vaddr && xfer->tx_buf && word_len == 8 && (spi->mode & SPI_CS_WORD) == 0) { |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 211 | unsigned int cnt = count / 4; |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 212 | @@ -736,7 +732,6 @@ static int orion_spi_probe(struct platform_device *pdev) |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | for_each_available_child_of_node(pdev->dev.of_node, np) { |
| 216 | - struct orion_direct_acc *dir_acc; |
| 217 | u32 cs; |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 218 | |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 219 | /* Get chip-select number from the "reg" property */ |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 220 | @@ -765,14 +760,15 @@ static int orion_spi_probe(struct platform_device *pdev) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 221 | * This needs to get extended for the direct SPI NOR / SPI NAND |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 222 | * support, once this gets implemented. |
| 223 | */ |
| 224 | - dir_acc = &spi->child[cs].direct_access; |
| 225 | - dir_acc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); |
| 226 | - if (!dir_acc->vaddr) { |
| 227 | + spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev, |
| 228 | + r->start, |
| 229 | + PAGE_SIZE); |
| 230 | + if (!spi->direct_access[cs].vaddr) { |
| 231 | status = -ENOMEM; |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 232 | of_node_put(np); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 233 | goto out_rel_axi_clk; |
| 234 | } |
| 235 | - dir_acc->size = PAGE_SIZE; |
| 236 | + spi->direct_access[cs].size = PAGE_SIZE; |
| 237 | |
| 238 | dev_info(&pdev->dev, "CS%d configured for direct access\n", cs); |
| 239 | } |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 240 | diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 241 | index dde0824b2fa5..bdfcd01401dd 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 242 | --- a/drivers/tty/serial/max310x.c |
| 243 | +++ b/drivers/tty/serial/max310x.c |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 244 | @@ -235,6 +235,10 @@ |
| 245 | #define MAX310x_REV_MASK (0xf8) |
| 246 | #define MAX310X_WRITE_BIT 0x80 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 247 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 248 | +/* Timeout for external crystal stability */ |
| 249 | +#define MAX310X_XTAL_WAIT_RETRIES 20 |
| 250 | +#define MAX310X_XTAL_WAIT_DELAY_MS 10 |
| 251 | + |
| 252 | /* MAX3107 specific */ |
| 253 | #define MAX3107_REV_ID (0xa0) |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 254 | |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 255 | @@ -610,11 +614,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] | 256 | |
| 257 | /* Wait for crystal */ |
| 258 | if (xtal) { |
| 259 | - unsigned int val; |
| 260 | - msleep(10); |
| 261 | - regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 262 | + unsigned int val = 0, i; |
| 263 | + for (i = 0; i < MAX310X_XTAL_WAIT_RETRIES && !(val & MAX310X_STS_CLKREADY_BIT); ++i) { |
| 264 | + msleep(MAX310X_XTAL_WAIT_DELAY_MS); |
| 265 | + regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 266 | + } |
| 267 | if (!(val & MAX310X_STS_CLKREADY_BIT)) { |
| 268 | - dev_warn(dev, "clock is not stable yet\n"); |
| 269 | + dev_err(dev, "clock is not stable\n"); |
| 270 | + return -EAGAIN; |
| 271 | } |
| 272 | } |
| 273 | |
Jan Kundrát | a12acd9 | 2022-01-13 12:53:30 +0100 | [diff] [blame] | 274 | @@ -1335,6 +1342,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] | 275 | } |
| 276 | |
| 277 | uartclk = max310x_set_ref_clk(dev, s, freq, xtal); |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 278 | + if (uartclk < 0) { |
| 279 | + ret = uartclk; |
| 280 | + goto out_uart; |
| 281 | + } |
| 282 | dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 283 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 284 | for (i = 0; i < devtype->nr; i++) { |