blob: 934e3e58963fb52d63b23f98e2231daba7bf0c66 [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át9ce4f9e2022-02-17 16:38:57 +010044diff --git a/arch/arm/boot/dts/armada-388-clearfog.dtsi b/arch/arm/boot/dts/armada-388-clearfog.dtsi
45index f8a06ae4a3c9..8f32e05b6d87 100644
46--- a/arch/arm/boot/dts/armada-388-clearfog.dtsi
47+++ b/arch/arm/boot/dts/armada-388-clearfog.dtsi
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át25016432019-03-04 21:40:58 +010073diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
Jan Kundráta12acd92022-01-13 12:53:30 +010074index cb7bd1353f9f..85865f1628d7 100644
Jan Kundrát25016432019-03-04 21:40:58 +010075--- a/drivers/leds/leds-tlc591xx.c
76+++ b/drivers/leds/leds-tlc591xx.c
Jan Kundrátf97c81d2020-02-06 00:33:19 +010077@@ -40,6 +40,9 @@
Jan Kundrát25016432019-03-04 21:40:58 +010078
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átf97c81d2020-02-06 00:33:19 +010087@@ -51,21 +54,25 @@ struct tlc591xx_priv {
Jan Kundrát25016432019-03-04 21:40:58 +010088 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áta12acd92022-01-13 12:53:30 +0100113@@ -180,6 +187,18 @@ tlc591xx_probe(struct i2c_client *client,
Jan Kundrát31bf7ae2020-02-14 17:03:53 +0100114
115 i2c_set_clientdata(client, priv);
Jan Kundrát25016432019-03-04 21:40:58 +0100116
Jan Kundrátf97c81d2020-02-06 00:33:19 +0100117+ priv->swrst_client = devm_i2c_new_dummy_device(dev, client->adapter, tlc591xx->swrst_addr);
Jan Kundrát89b682a2020-03-08 13:03:33 -0700118+ 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át25016432019-03-04 21:40:58 +0100122+ 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át25016432019-03-04 21:40:58 +0100127+ }
128+
Jan Kundrát31bf7ae2020-02-14 17:03:53 +0100129 err = tlc591xx_set_mode(priv->regmap, MODE2_DIM);
130 if (err < 0)
131 return err;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200132diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100133index 9ae10318f6f3..d378369bbeca 100644
Jan Kundrát0341eea2020-10-16 18:06:38 +0200134--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
135+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100136@@ -8,6 +8,7 @@
137 #include <linux/spi/spi.h>
Jan Kundrát0341eea2020-10-16 18:06:38 +0200138
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100139 #include "pinctrl-mcp23s08.h"
140+#include "../gpio/gpiolib.h"
Jan Kundrát0341eea2020-10-16 18:06:38 +0200141
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100142 #define MCP_MAX_DEV_PER_CS 8
Jan Kundrát0341eea2020-10-16 18:06:38 +0200143
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100144@@ -143,6 +144,10 @@ static int mcp23s08_probe(struct spi_device *spi)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200145 int type;
146 int ret;
147 u32 v;
148+ struct device_node *np;
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100149+ int line_name_count;
150+ const char **names;
151+ int i;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200152
153 match = device_get_match_data(dev);
Jan Kundrát25016432019-03-04 21:40:58 +0100154 if (match)
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100155@@ -192,6 +197,43 @@ static int mcp23s08_probe(struct spi_device *spi)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200156 return ret;
157
Jan Kundrát25016432019-03-04 21:40:58 +0100158 ngpio += data->mcp[addr]->chip.ngpio;
159+
160+ for_each_available_child_of_node(spi->dev.of_node, np) {
161+ u32 chip_addr;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200162+ ret = of_property_read_u32(np, "address", &chip_addr);
163+ if (ret)
Jan Kundrát25016432019-03-04 21:40:58 +0100164+ continue;
165+ if (chip_addr != addr)
166+ continue;
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100167+
168+ line_name_count = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", NULL, 0);
169+ if (line_name_count < 0)
170+ continue;
171+
172+ if (line_name_count > data->mcp[addr]->chip.ngpio) {
173+ dev_warn(&spi->dev, "gpio-line-names is length %d but should be at most length %d",
174+ line_name_count, data->mcp[addr]->chip.ngpio);
175+ line_name_count = data->mcp[addr]->chip.ngpio;
176+ }
177+
178+ names = kcalloc(line_name_count, sizeof(*names), GFP_KERNEL);
179+ if (!names) {
180+ dev_warn(&spi->dev, "cannot allocate gpio-line-names");
181+ continue;
182+ }
183+
184+ ret = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", names, line_name_count);
185+ if (ret < 0) {
186+ dev_warn(&spi->dev, "failed to read GPIO line names");
187+ kfree(names);
188+ continue;
189+ }
190+
191+ for (i = 0; i < line_name_count; i++)
192+ data->mcp[addr]->chip.gpiodev->descs[i].name = names[i];
193+
194+ kfree(names);
Jan Kundrát25016432019-03-04 21:40:58 +0100195+ }
196 }
197 data->ngpio = ngpio;
198
Jan Kundráte7d21622019-03-28 22:52:38 +0100199diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
Jan Kundráta12acd92022-01-13 12:53:30 +0100200index 565cd4c48d7b..cb252d98184c 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100201--- a/drivers/spi/spi-orion.c
202+++ b/drivers/spi/spi-orion.c
Jan Kundrátbf1e0912021-03-05 12:45:23 +0100203@@ -86,10 +86,6 @@ struct orion_direct_acc {
Jan Kundráte7d21622019-03-28 22:52:38 +0100204 u32 size;
205 };
206
207-struct orion_child_options {
208- struct orion_direct_acc direct_access;
209-};
210-
Jan Kundrát25016432019-03-04 21:40:58 +0100211 struct orion_spi {
Jan Kundráte7d21622019-03-28 22:52:38 +0100212 struct spi_master *master;
213 void __iomem *base;
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100214@@ -98,7 +94,7 @@ struct orion_spi {
Jan Kundráte7d21622019-03-28 22:52:38 +0100215 const struct orion_spi_dev *devdata;
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100216 struct device *dev;
Jan Kundráte7d21622019-03-28 22:52:38 +0100217
218- struct orion_child_options child[ORION_NUM_CHIPSELECTS];
219+ struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS];
220 };
221
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100222 #ifdef CONFIG_PM
Jan Kundráta12acd92022-01-13 12:53:30 +0100223@@ -473,7 +469,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
Jan Kundrát25016432019-03-04 21:40:58 +0100224 int cs = spi->chip_select;
Jan Kundrát549db872019-03-05 12:23:25 +0100225 void __iomem *vaddr;
Jan Kundrát25016432019-03-04 21:40:58 +0100226
227- word_len = spi->bits_per_word;
228+ word_len = xfer->bits_per_word;
229 count = xfer->len;
230
231 orion_spi = spi_master_get_devdata(spi->master);
Jan Kundráta12acd92022-01-13 12:53:30 +0100232@@ -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 +0100233 * and SPI_CS_WORD flag is not set.
234 * Otherwise fall back to PIO mode for this transfer.
Jan Kundráte7d21622019-03-28 22:52:38 +0100235 */
236- vaddr = orion_spi->child[cs].direct_access.vaddr;
237+ vaddr = orion_spi->direct_access[cs].vaddr;
238
Václav Kubernátf1b92ff2021-03-24 07:41:23 +0100239 if (vaddr && xfer->tx_buf && word_len == 8 && (spi->mode & SPI_CS_WORD) == 0) {
Jan Kundráte7d21622019-03-28 22:52:38 +0100240 unsigned int cnt = count / 4;
Jan Kundráta12acd92022-01-13 12:53:30 +0100241@@ -736,7 +732,6 @@ static int orion_spi_probe(struct platform_device *pdev)
Jan Kundráte7d21622019-03-28 22:52:38 +0100242 }
243
244 for_each_available_child_of_node(pdev->dev.of_node, np) {
245- struct orion_direct_acc *dir_acc;
246 u32 cs;
Jan Kundráte7d21622019-03-28 22:52:38 +0100247
Jan Kundrát0341eea2020-10-16 18:06:38 +0200248 /* Get chip-select number from the "reg" property */
Jan Kundráta12acd92022-01-13 12:53:30 +0100249@@ -765,14 +760,15 @@ static int orion_spi_probe(struct platform_device *pdev)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200250 * This needs to get extended for the direct SPI NOR / SPI NAND
Jan Kundráte7d21622019-03-28 22:52:38 +0100251 * support, once this gets implemented.
252 */
253- dir_acc = &spi->child[cs].direct_access;
254- dir_acc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
255- if (!dir_acc->vaddr) {
256+ spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev,
257+ r->start,
258+ PAGE_SIZE);
259+ if (!spi->direct_access[cs].vaddr) {
260 status = -ENOMEM;
Jan Kundráta12acd92022-01-13 12:53:30 +0100261 of_node_put(np);
Jan Kundráte7d21622019-03-28 22:52:38 +0100262 goto out_rel_axi_clk;
263 }
264- dir_acc->size = PAGE_SIZE;
265+ spi->direct_access[cs].size = PAGE_SIZE;
266
267 dev_info(&pdev->dev, "CS%d configured for direct access\n", cs);
268 }
Jan Kundráte7d21622019-03-28 22:52:38 +0100269diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
Jan Kundráta12acd92022-01-13 12:53:30 +0100270index dde0824b2fa5..bdfcd01401dd 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100271--- a/drivers/tty/serial/max310x.c
272+++ b/drivers/tty/serial/max310x.c
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100273@@ -235,6 +235,10 @@
274 #define MAX310x_REV_MASK (0xf8)
275 #define MAX310X_WRITE_BIT 0x80
Jan Kundráte7d21622019-03-28 22:52:38 +0100276
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100277+/* Timeout for external crystal stability */
278+#define MAX310X_XTAL_WAIT_RETRIES 20
279+#define MAX310X_XTAL_WAIT_DELAY_MS 10
280+
281 /* MAX3107 specific */
282 #define MAX3107_REV_ID (0xa0)
Jan Kundráte7d21622019-03-28 22:52:38 +0100283
Jan Kundráta12acd92022-01-13 12:53:30 +0100284@@ -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 +0100285
286 /* Wait for crystal */
287 if (xtal) {
288- unsigned int val;
289- msleep(10);
290- regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val);
291+ unsigned int val = 0, i;
292+ for (i = 0; i < MAX310X_XTAL_WAIT_RETRIES && !(val & MAX310X_STS_CLKREADY_BIT); ++i) {
293+ msleep(MAX310X_XTAL_WAIT_DELAY_MS);
294+ regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val);
295+ }
296 if (!(val & MAX310X_STS_CLKREADY_BIT)) {
297- dev_warn(dev, "clock is not stable yet\n");
298+ dev_err(dev, "clock is not stable\n");
299+ return -EAGAIN;
300 }
301 }
302
Jan Kundráta12acd92022-01-13 12:53:30 +0100303@@ -1335,6 +1342,10 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
Jan Kundráte7d21622019-03-28 22:52:38 +0100304 }
305
306 uartclk = max310x_set_ref_clk(dev, s, freq, xtal);
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100307+ if (uartclk < 0) {
308+ ret = uartclk;
309+ goto out_uart;
310+ }
311 dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk);
Jan Kundráte7d21622019-03-28 22:52:38 +0100312
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100313 for (i = 0; i < devtype->nr; i++) {