blob: ae58a70877ff80fed535227f5f9dd93a1834b043 [file] [log] [blame]
Jan Kundrát25016432019-03-04 21:40:58 +01001diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt
Jan Kundráta12acd92022-01-13 12:53:30 +01002index 2fa5edac7a35..4906544628ec 100644
Jan Kundrát25016432019-03-04 21:40:58 +01003--- a/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt
4+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt
Jan Kundráta12acd92022-01-13 12:53:30 +01005@@ -146,3 +146,38 @@ gpio21: gpio@21 {
Jan Kundrát25016432019-03-04 21:40:58 +01006 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áte7d21622019-03-28 22:52:38 +010018+ compatible = "microchip,mcp23s17";
19+ gpio-controller;
20+ #gpio-cells = <2>;
Jan Kundrát25016432019-03-04 21:40:58 +010021+ /* this bitmask has bits #0 (0x01) and #2 (0x04) set */
Jan Kundráte7d21622019-03-28 22:52:38 +010022+ spi-present-mask = <0x05>;
23+ reg = <0>;
24+ spi-max-frequency = <1000000>;
Jan Kundrát25016432019-03-04 21:40:58 +010025+
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át25016432019-03-04 21:40:58 +010044diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
Jan Kundráta12acd92022-01-13 12:53:30 +010045index cb7bd1353f9f..85865f1628d7 100644
Jan Kundrát25016432019-03-04 21:40:58 +010046--- a/drivers/leds/leds-tlc591xx.c
47+++ b/drivers/leds/leds-tlc591xx.c
Jan Kundrátf97c81d2020-02-06 00:33:19 +010048@@ -40,6 +40,9 @@
Jan Kundrát25016432019-03-04 21:40:58 +010049
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átf97c81d2020-02-06 00:33:19 +010058@@ -51,21 +54,25 @@ struct tlc591xx_priv {
Jan Kundrát25016432019-03-04 21:40:58 +010059 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áta12acd92022-01-13 12:53:30 +010084@@ -180,6 +187,18 @@ tlc591xx_probe(struct i2c_client *client,
Jan Kundrát31bf7ae2020-02-14 17:03:53 +010085
86 i2c_set_clientdata(client, priv);
Jan Kundrát25016432019-03-04 21:40:58 +010087
Jan Kundrátf97c81d2020-02-06 00:33:19 +010088+ priv->swrst_client = devm_i2c_new_dummy_device(dev, client->adapter, tlc591xx->swrst_addr);
Jan Kundrát89b682a2020-03-08 13:03:33 -070089+ 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át25016432019-03-04 21:40:58 +010093+ 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át25016432019-03-04 21:40:58 +010098+ }
99+
Jan Kundrát31bf7ae2020-02-14 17:03:53 +0100100 err = tlc591xx_set_mode(priv->regmap, MODE2_DIM);
101 if (err < 0)
102 return err;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200103diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100104index 9ae10318f6f3..d378369bbeca 100644
Jan Kundrát0341eea2020-10-16 18:06:38 +0200105--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
106+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100107@@ -8,6 +8,7 @@
108 #include <linux/spi/spi.h>
Jan Kundrát0341eea2020-10-16 18:06:38 +0200109
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100110 #include "pinctrl-mcp23s08.h"
111+#include "../gpio/gpiolib.h"
Jan Kundrát0341eea2020-10-16 18:06:38 +0200112
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100113 #define MCP_MAX_DEV_PER_CS 8
Jan Kundrát0341eea2020-10-16 18:06:38 +0200114
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100115@@ -143,6 +144,10 @@ static int mcp23s08_probe(struct spi_device *spi)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200116 int type;
117 int ret;
118 u32 v;
119+ struct device_node *np;
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100120+ int line_name_count;
121+ const char **names;
122+ int i;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200123
124 match = device_get_match_data(dev);
Jan Kundrát25016432019-03-04 21:40:58 +0100125 if (match)
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100126@@ -192,6 +197,43 @@ static int mcp23s08_probe(struct spi_device *spi)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200127 return ret;
128
Jan Kundrát25016432019-03-04 21:40:58 +0100129 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át0341eea2020-10-16 18:06:38 +0200133+ ret = of_property_read_u32(np, "address", &chip_addr);
134+ if (ret)
Jan Kundrát25016432019-03-04 21:40:58 +0100135+ continue;
136+ if (chip_addr != addr)
137+ continue;
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100138+
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át25016432019-03-04 21:40:58 +0100166+ }
167 }
168 data->ngpio = ngpio;
169
Jan Kundráte7d21622019-03-28 22:52:38 +0100170diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
Jan Kundráta12acd92022-01-13 12:53:30 +0100171index 565cd4c48d7b..cb252d98184c 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100172--- a/drivers/spi/spi-orion.c
173+++ b/drivers/spi/spi-orion.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100174@@ -86,10 +86,6 @@ struct orion_direct_acc {
Jan Kundráte7d21622019-03-28 22:52:38 +0100175 u32 size;
176 };
177
178-struct orion_child_options {
179- struct orion_direct_acc direct_access;
180-};
181-
Jan Kundrát25016432019-03-04 21:40:58 +0100182 struct orion_spi {
Jan Kundráte7d21622019-03-28 22:52:38 +0100183 struct spi_master *master;
184 void __iomem *base;
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100185@@ -98,7 +94,7 @@ struct orion_spi {
Jan Kundráte7d21622019-03-28 22:52:38 +0100186 const struct orion_spi_dev *devdata;
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100187 struct device *dev;
Jan Kundráte7d21622019-03-28 22:52:38 +0100188
189- struct orion_child_options child[ORION_NUM_CHIPSELECTS];
190+ struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS];
191 };
192
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100193 #ifdef CONFIG_PM
Jan Kundráta12acd92022-01-13 12:53:30 +0100194@@ -473,7 +469,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
Jan Kundrát25016432019-03-04 21:40:58 +0100195 int cs = spi->chip_select;
Jan Kundrát549db872019-03-05 12:23:25 +0100196 void __iomem *vaddr;
Jan Kundrát25016432019-03-04 21:40:58 +0100197
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áta12acd92022-01-13 12:53:30 +0100203@@ -483,7 +479,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100204 * and SPI_CS_WORD flag is not set.
205 * Otherwise fall back to PIO mode for this transfer.
Jan Kundráte7d21622019-03-28 22:52:38 +0100206 */
207- vaddr = orion_spi->child[cs].direct_access.vaddr;
208+ vaddr = orion_spi->direct_access[cs].vaddr;
209
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100210 if (vaddr && xfer->tx_buf && word_len == 8 && (spi->mode & SPI_CS_WORD) == 0) {
Jan Kundráte7d21622019-03-28 22:52:38 +0100211 unsigned int cnt = count / 4;
Jan Kundráta12acd92022-01-13 12:53:30 +0100212@@ -736,7 +732,6 @@ static int orion_spi_probe(struct platform_device *pdev)
Jan Kundráte7d21622019-03-28 22:52:38 +0100213 }
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áte7d21622019-03-28 22:52:38 +0100218
Jan Kundrát0341eea2020-10-16 18:06:38 +0200219 /* Get chip-select number from the "reg" property */
Jan Kundráta12acd92022-01-13 12:53:30 +0100220@@ -765,14 +760,15 @@ static int orion_spi_probe(struct platform_device *pdev)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200221 * This needs to get extended for the direct SPI NOR / SPI NAND
Jan Kundráte7d21622019-03-28 22:52:38 +0100222 * 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áta12acd92022-01-13 12:53:30 +0100232 of_node_put(np);
Jan Kundráte7d21622019-03-28 22:52:38 +0100233 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áte7d21622019-03-28 22:52:38 +0100240diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
Jan Kundráta12acd92022-01-13 12:53:30 +0100241index dde0824b2fa5..bdfcd01401dd 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100242--- a/drivers/tty/serial/max310x.c
243+++ b/drivers/tty/serial/max310x.c
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100244@@ -235,6 +235,10 @@
245 #define MAX310x_REV_MASK (0xf8)
246 #define MAX310X_WRITE_BIT 0x80
Jan Kundráte7d21622019-03-28 22:52:38 +0100247
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100248+/* 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áte7d21622019-03-28 22:52:38 +0100254
Jan Kundráta12acd92022-01-13 12:53:30 +0100255@@ -610,11 +614,14 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100256
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áta12acd92022-01-13 12:53:30 +0100274@@ -1335,6 +1342,10 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
Jan Kundráte7d21622019-03-28 22:52:38 +0100275 }
276
277 uartclk = max310x_set_ref_clk(dev, s, freq, xtal);
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100278+ 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áte7d21622019-03-28 22:52:38 +0100283
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100284 for (i = 0; i < devtype->nr; i++) {