blob: e1a9c708f009ea02daced5ba535757e791e0cc8e [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át2bfe9ee2019-12-04 13:42:07 +01002index 8b94aa8f5971..2723e6143aa9 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
5@@ -144,3 +144,38 @@ gpio21: gpio@21 {
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á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át0341eea2020-10-16 18:06:38 +020044diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
45index 80137c1b3cdc..8d1c49a289eb 100644
46--- a/drivers/gpio/gpiolib.c
47+++ b/drivers/gpio/gpiolib.c
48@@ -1727,11 +1727,6 @@ static inline void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gc)
49 */
50 int gpiochip_generic_request(struct gpio_chip *gc, unsigned offset)
51 {
52-#ifdef CONFIG_PINCTRL
53- if (list_empty(&gc->gpiodev->pin_ranges))
54- return 0;
55-#endif
56-
57 return pinctrl_gpio_request(gc->gpiodev->base + offset);
58 }
59 EXPORT_SYMBOL_GPL(gpiochip_generic_request);
Jan Kundrát6406d512020-11-18 18:24:36 +010060diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
61index 117fb79ef294..610f62eab72a 100644
62--- a/drivers/hwmon/max31790.c
63+++ b/drivers/hwmon/max31790.c
64@@ -489,11 +489,18 @@ static const struct i2c_device_id max31790_id[] = {
65 };
66 MODULE_DEVICE_TABLE(i2c, max31790_id);
67
68+static const struct of_device_id __maybe_unused max31790_of_match[] = {
69+ { .compatible = "maxim,max31790" },
70+ { }
71+};
72+MODULE_DEVICE_TABLE(of, max31790_of_match);
73+
74 static struct i2c_driver max31790_driver = {
75 .class = I2C_CLASS_HWMON,
76 .probe = max31790_probe,
77 .driver = {
78 .name = "max31790",
79+ .of_match_table = of_match_ptr(max31790_of_match),
80 },
81 .id_table = max31790_id,
82 };
Jan Kundrát0341eea2020-10-16 18:06:38 +020083diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
84index 18e06fc6c53f..5c0f429ed7ad 100644
85--- a/drivers/hwmon/pmbus/pmbus.h
86+++ b/drivers/hwmon/pmbus/pmbus.h
87@@ -361,7 +361,7 @@ enum pmbus_sensor_classes {
88 PSC_NUM_CLASSES /* Number of power sensor classes */
89 };
90
91-#define PMBUS_PAGES 32 /* Per PMBus specification */
92+#define PMBUS_PAGES 255 /* Per PMBus specification */
93 #define PMBUS_PHASES 8 /* Maximum number of phases per page */
94
95 /* Functionality bit mask */
Jan Kundrát25016432019-03-04 21:40:58 +010096diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
Jan Kundrát0341eea2020-10-16 18:06:38 +020097index 0929f1275814..710c56cba818 100644
Jan Kundrát25016432019-03-04 21:40:58 +010098--- a/drivers/leds/leds-tlc591xx.c
99+++ b/drivers/leds/leds-tlc591xx.c
Jan Kundrátf97c81d2020-02-06 00:33:19 +0100100@@ -40,6 +40,9 @@
Jan Kundrát25016432019-03-04 21:40:58 +0100101
102 #define ldev_to_led(c) container_of(c, struct tlc591xx_led, ldev)
103
104+#define TLC591XX_RESET_BYTE_0 0xa5
105+#define TLC591XX_RESET_BYTE_1 0x5a
106+
107 struct tlc591xx_led {
108 bool active;
109 unsigned int led_no;
Jan Kundrátf97c81d2020-02-06 00:33:19 +0100110@@ -51,21 +54,25 @@ struct tlc591xx_priv {
Jan Kundrát25016432019-03-04 21:40:58 +0100111 struct tlc591xx_led leds[TLC591XX_MAX_LEDS];
112 struct regmap *regmap;
113 unsigned int reg_ledout_offset;
114+ struct i2c_client *swrst_client;
115 };
116
117 struct tlc591xx {
118 unsigned int max_leds;
119 unsigned int reg_ledout_offset;
120+ u8 swrst_addr;
121 };
122
123 static const struct tlc591xx tlc59116 = {
124 .max_leds = 16,
125 .reg_ledout_offset = 0x14,
126+ .swrst_addr = 0x6b,
127 };
128
129 static const struct tlc591xx tlc59108 = {
130 .max_leds = 8,
131 .reg_ledout_offset = 0x0c,
132+ .swrst_addr = 0x4b,
133 };
134
135 static int
Jan Kundrát31bf7ae2020-02-14 17:03:53 +0100136@@ -181,6 +188,18 @@ tlc591xx_probe(struct i2c_client *client,
137
138 i2c_set_clientdata(client, priv);
Jan Kundrát25016432019-03-04 21:40:58 +0100139
Jan Kundrátf97c81d2020-02-06 00:33:19 +0100140+ priv->swrst_client = devm_i2c_new_dummy_device(dev, client->adapter, tlc591xx->swrst_addr);
Jan Kundrát89b682a2020-03-08 13:03:33 -0700141+ if (IS_ERR(priv->swrst_client)) {
142+ dev_info(dev, "Skipping reset: address %02x already used\n",
143+ tlc591xx->swrst_addr);
144+ } else {
Jan Kundrát25016432019-03-04 21:40:58 +0100145+ err = i2c_smbus_write_byte_data(priv->swrst_client,
146+ TLC591XX_RESET_BYTE_0, TLC591XX_RESET_BYTE_1);
147+ if (err) {
148+ dev_warn(dev, "SW reset failed\n");
149+ }
Jan Kundrát25016432019-03-04 21:40:58 +0100150+ }
151+
Jan Kundrát31bf7ae2020-02-14 17:03:53 +0100152 err = tlc591xx_set_mode(priv->regmap, MODE2_DIM);
153 if (err < 0)
154 return err;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200155diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
156index c39978b750ec..653c0b3d2912 100644
157--- a/drivers/pci/controller/pci-mvebu.c
158+++ b/drivers/pci/controller/pci-mvebu.c
159@@ -960,25 +960,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
160 }
161
162 /*
163- * We can't use devm_of_pci_get_host_bridge_resources() because we
164- * need to parse our special DT properties encoding the MEM and IO
165- * apertures.
166+ * devm_of_pci_get_host_bridge_resources() only sets up translateable resources,
167+ * so we need extra resource setup parsing our special DT properties encoding
168+ * the MEM and IO apertures.
169 */
170 static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
171 {
172 struct device *dev = &pcie->pdev->dev;
173- struct device_node *np = dev->of_node;
174 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
175 int ret;
176
177- /* Get the bus range */
178- ret = of_pci_parse_bus_range(np, &pcie->busn);
179- if (ret) {
180- dev_err(dev, "failed to parse bus-range property: %d\n", ret);
181- return ret;
182- }
183- pci_add_resource(&bridge->windows, &pcie->busn);
184-
185 /* Get the PCIe memory aperture */
186 mvebu_mbus_get_pcie_mem_aperture(&pcie->mem);
187 if (resource_size(&pcie->mem) == 0) {
188@@ -988,6 +979,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
189
190 pcie->mem.name = "PCI MEM";
191 pci_add_resource(&bridge->windows, &pcie->mem);
192+ ret = devm_request_resource(dev, &iomem_resource, &pcie->mem);
193+ if (ret)
194+ return ret;
195
196 /* Get the PCIe IO aperture */
197 mvebu_mbus_get_pcie_io_aperture(&pcie->io);
198@@ -1001,9 +995,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
199 pcie->realio.name = "PCI I/O";
200
201 pci_add_resource(&bridge->windows, &pcie->realio);
202+ ret = devm_request_resource(dev, &ioport_resource, &pcie->realio);
203+ if (ret)
204+ return ret;
205 }
206
207- return devm_request_pci_bus_resources(dev, &bridge->windows);
208+ return 0;
209 }
210
211 /*
Jan Kundrát25016432019-03-04 21:40:58 +0100212diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
Jan Kundrát0e9469d2020-11-03 01:33:10 +0100213index 7edb067f5e76..ce2d8014b7e0 100644
Jan Kundrát25016432019-03-04 21:40:58 +0100214--- a/drivers/pinctrl/pinctrl-mcp23s08.c
215+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
Jan Kundrát0341eea2020-10-16 18:06:38 +0200216@@ -564,7 +564,7 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
217
218 ret = mcp_read(mcp, MCP_IOCON, &status);
219 if (ret < 0)
220- goto fail;
221+ return dev_err_probe(dev, ret, "can't identify chip %d\n", addr);
222
223 mcp->irq_controller =
224 device_property_read_bool(dev, "interrupt-controller");
225@@ -598,7 +598,7 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
226
227 ret = mcp_write(mcp, MCP_IOCON, status);
228 if (ret < 0)
229- goto fail;
230+ return dev_err_probe(dev, ret, "can't write IOCON %d\n", addr);
231 }
232
233 if (mcp->irq && mcp->irq_controller) {
234@@ -616,7 +616,7 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
235
236 ret = devm_gpiochip_add_data(dev, &mcp->chip, mcp);
237 if (ret < 0)
238- goto fail;
239+ return dev_err_probe(dev, ret, "can't add GPIO chip\n");
240
241 mcp->pinctrl_desc.pctlops = &mcp_pinctrl_ops;
242 mcp->pinctrl_desc.confops = &mcp_pinconf_ops;
243@@ -628,18 +628,17 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
244 mcp->pinctrl_desc.owner = THIS_MODULE;
245
246 mcp->pctldev = devm_pinctrl_register(dev, &mcp->pinctrl_desc, mcp);
247- if (IS_ERR(mcp->pctldev)) {
248- ret = PTR_ERR(mcp->pctldev);
249- goto fail;
250- }
251+ if (IS_ERR(mcp->pctldev))
252+ return dev_err_probe(dev, PTR_ERR(mcp->pctldev), "can't register controller\n");
253
254- if (mcp->irq)
255+ if (mcp->irq) {
256 ret = mcp23s08_irq_setup(mcp);
257+ if (ret)
258+ return dev_err_probe(dev, ret, "can't setup IRQ\n");
259+ }
260
261-fail:
262- if (ret < 0)
263- dev_dbg(dev, "can't setup chip %d, --> %d\n", addr, ret);
264- return ret;
265+ return 0;
266 }
267 EXPORT_SYMBOL_GPL(mcp23s08_probe_one);
268+
269 MODULE_LICENSE("GPL");
270diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
271index 1f47a661b0a7..3271e304c985 100644
272--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
273+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
274@@ -119,13 +119,15 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,
275 return -EINVAL;
276 }
277
278- copy = devm_kmemdup(dev, &config, sizeof(config), GFP_KERNEL);
279+ copy = devm_kmemdup(dev, config, sizeof(*config), GFP_KERNEL);
280 if (!copy)
281 return -ENOMEM;
282
283 copy->name = name;
284
285 mcp->regmap = devm_regmap_init(dev, &mcp23sxx_spi_regmap, mcp, copy);
286+ if (IS_ERR(mcp->regmap))
287+ dev_err(dev, "regmap init failed for %s\n", mcp->chip.label);
288 return PTR_ERR_OR_ZERO(mcp->regmap);
289 }
290
291@@ -141,6 +143,7 @@ static int mcp23s08_probe(struct spi_device *spi)
292 int type;
293 int ret;
294 u32 v;
295+ struct device_node *np;
296
297 match = device_get_match_data(dev);
Jan Kundrát25016432019-03-04 21:40:58 +0100298 if (match)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200299@@ -190,6 +193,16 @@ static int mcp23s08_probe(struct spi_device *spi)
300 return ret;
301
Jan Kundrát25016432019-03-04 21:40:58 +0100302 ngpio += data->mcp[addr]->chip.ngpio;
303+
304+ for_each_available_child_of_node(spi->dev.of_node, np) {
305+ u32 chip_addr;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200306+ ret = of_property_read_u32(np, "address", &chip_addr);
307+ if (ret)
Jan Kundrát25016432019-03-04 21:40:58 +0100308+ continue;
309+ if (chip_addr != addr)
310+ continue;
311+ devprop_gpiochip_set_names(&data->mcp[addr]->chip, of_fwnode_handle(np));
312+ }
313 }
314 data->ngpio = ngpio;
315
Jan Kundráte7d21622019-03-28 22:52:38 +0100316diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
Jan Kundrát0341eea2020-10-16 18:06:38 +0200317index b57b8b3cc26e..5dc323643522 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100318--- a/drivers/spi/spi-orion.c
319+++ b/drivers/spi/spi-orion.c
Jan Kundrát0341eea2020-10-16 18:06:38 +0200320@@ -17,8 +17,10 @@
321 #include <linux/of.h>
322 #include <linux/of_address.h>
323 #include <linux/of_device.h>
324+#include <linux/of_gpio.h>
325 #include <linux/clk.h>
326 #include <linux/sizes.h>
327+#include <linux/gpio.h>
328 #include <asm/unaligned.h>
329
330 #define DRIVER_NAME "orion_spi"
331@@ -86,18 +88,15 @@ struct orion_direct_acc {
Jan Kundráte7d21622019-03-28 22:52:38 +0100332 u32 size;
333 };
334
335-struct orion_child_options {
336- struct orion_direct_acc direct_access;
337-};
338-
Jan Kundrát25016432019-03-04 21:40:58 +0100339 struct orion_spi {
Jan Kundráte7d21622019-03-28 22:52:38 +0100340 struct spi_master *master;
341 void __iomem *base;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200342 struct clk *clk;
343 struct clk *axi_clk;
Jan Kundráte7d21622019-03-28 22:52:38 +0100344 const struct orion_spi_dev *devdata;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200345+ int unused_hw_gpio;
Jan Kundráte7d21622019-03-28 22:52:38 +0100346
347- struct orion_child_options child[ORION_NUM_CHIPSELECTS];
348+ struct orion_direct_acc direct_access[ORION_NUM_CHIPSELECTS];
349 };
350
351 static inline void __iomem *spi_reg(struct orion_spi *orion_spi, u32 reg)
Jan Kundrát0341eea2020-10-16 18:06:38 +0200352@@ -322,27 +321,20 @@ orion_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
353 static void orion_spi_set_cs(struct spi_device *spi, bool enable)
354 {
355 struct orion_spi *orion_spi;
356+ int cs;
357
358 orion_spi = spi_master_get_devdata(spi->master);
359
360- /*
361- * If this line is using a GPIO to control chip select, this internal
362- * .set_cs() function will still be called, so we clear any previous
363- * chip select. The CS we activate will not have any elecrical effect,
364- * as it is handled by a GPIO, but that doesn't matter. What we need
365- * is to deassert the old chip select and assert some other chip select.
366- */
367+ if (gpio_is_valid(spi->cs_gpio))
368+ cs = orion_spi->unused_hw_gpio;
369+ else
370+ cs = spi->chip_select;
371+
372 orion_spi_clrbits(orion_spi, ORION_SPI_IF_CTRL_REG, ORION_SPI_CS_MASK);
373 orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG,
374- ORION_SPI_CS(spi->chip_select));
375+ ORION_SPI_CS(cs));
376
377- /*
378- * Chip select logic is inverted from spi_set_cs(). For lines using a
379- * GPIO to do chip select SPI_CS_HIGH is enforced and inversion happens
380- * in the GPIO library, but we don't care about that, because in those
381- * cases we are dealing with an unused native CS anyways so the polarity
382- * doesn't matter.
383- */
384+ /* Chip select logic is inverted from spi_set_cs */
385 if (!enable)
386 orion_spi_setbits(orion_spi, ORION_SPI_IF_CTRL_REG, 0x1);
387 else
388@@ -434,7 +426,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
Jan Kundrát25016432019-03-04 21:40:58 +0100389 int cs = spi->chip_select;
Jan Kundrát549db872019-03-05 12:23:25 +0100390 void __iomem *vaddr;
Jan Kundrát25016432019-03-04 21:40:58 +0100391
392- word_len = spi->bits_per_word;
393+ word_len = xfer->bits_per_word;
394 count = xfer->len;
395
396 orion_spi = spi_master_get_devdata(spi->master);
Jan Kundrát0341eea2020-10-16 18:06:38 +0200397@@ -443,7 +435,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
Jan Kundráte7d21622019-03-28 22:52:38 +0100398 * Use SPI direct write mode if base address is available. Otherwise
399 * fall back to PIO mode for this transfer.
400 */
401- vaddr = orion_spi->child[cs].direct_access.vaddr;
402+ vaddr = orion_spi->direct_access[cs].vaddr;
403
404 if (vaddr && xfer->tx_buf && word_len == 8) {
405 unsigned int cnt = count / 4;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200406@@ -507,6 +499,9 @@ static int orion_spi_transfer_one(struct spi_master *master,
407
408 static int orion_spi_setup(struct spi_device *spi)
409 {
410+ if (gpio_is_valid(spi->cs_gpio)) {
411+ gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
412+ }
413 return orion_spi_setup_transfer(spi, NULL);
414 }
415
416@@ -623,13 +618,13 @@ static int orion_spi_probe(struct platform_device *pdev)
417 master->setup = orion_spi_setup;
418 master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16);
419 master->auto_runtime_pm = true;
420- master->use_gpio_descriptors = true;
421 master->flags = SPI_MASTER_GPIO_SS;
422
423 platform_set_drvdata(pdev, master);
424
425 spi = spi_master_get_devdata(master);
426 spi->master = master;
427+ spi->unused_hw_gpio = -1;
428
429 of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
430 devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
431@@ -682,8 +677,8 @@ static int orion_spi_probe(struct platform_device *pdev)
Jan Kundráte7d21622019-03-28 22:52:38 +0100432 }
433
434 for_each_available_child_of_node(pdev->dev.of_node, np) {
435- struct orion_direct_acc *dir_acc;
436 u32 cs;
Jan Kundrát0341eea2020-10-16 18:06:38 +0200437+ int cs_gpio;
Jan Kundráte7d21622019-03-28 22:52:38 +0100438
Jan Kundrát0341eea2020-10-16 18:06:38 +0200439 /* Get chip-select number from the "reg" property */
440 status = of_property_read_u32(np, "reg", &cs);
441@@ -694,6 +689,44 @@ static int orion_spi_probe(struct platform_device *pdev)
442 continue;
443 }
444
445+ /*
446+ * Initialize the CS GPIO:
447+ * - properly request the actual GPIO signal
448+ * - de-assert the logical signal so that all GPIO CS lines
449+ * are inactive when probing for slaves
450+ * - find an unused physical CS which will be driven for any
451+ * slave which uses a CS GPIO
452+ */
453+ cs_gpio = of_get_named_gpio(pdev->dev.of_node, "cs-gpios", cs);
454+ if (cs_gpio > 0) {
455+ char *gpio_name;
456+ int cs_flags;
457+
458+ if (spi->unused_hw_gpio == -1) {
459+ dev_info(&pdev->dev,
460+ "Selected unused HW CS#%d for any GPIO CSes\n",
461+ cs);
462+ spi->unused_hw_gpio = cs;
463+ }
464+
465+ gpio_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
466+ "%s-CS%d", dev_name(&pdev->dev), cs);
467+ if (!gpio_name) {
468+ status = -ENOMEM;
469+ goto out_rel_axi_clk;
470+ }
471+
472+ cs_flags = of_property_read_bool(np, "spi-cs-high") ?
473+ GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH;
474+ status = devm_gpio_request_one(&pdev->dev, cs_gpio,
475+ cs_flags, gpio_name);
476+ if (status) {
477+ dev_err(&pdev->dev,
478+ "Can't request GPIO for CS %d\n", cs);
479+ goto out_rel_axi_clk;
480+ }
481+ }
482+
483 /*
484 * Check if an address is configured for this SPI device. If
485 * not, the MBus mapping via the 'ranges' property in the 'soc'
486@@ -711,13 +744,14 @@ static int orion_spi_probe(struct platform_device *pdev)
487 * This needs to get extended for the direct SPI NOR / SPI NAND
Jan Kundráte7d21622019-03-28 22:52:38 +0100488 * support, once this gets implemented.
489 */
490- dir_acc = &spi->child[cs].direct_access;
491- dir_acc->vaddr = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE);
492- if (!dir_acc->vaddr) {
493+ spi->direct_access[cs].vaddr = devm_ioremap(&pdev->dev,
494+ r->start,
495+ PAGE_SIZE);
496+ if (!spi->direct_access[cs].vaddr) {
497 status = -ENOMEM;
498 goto out_rel_axi_clk;
499 }
500- dir_acc->size = PAGE_SIZE;
501+ spi->direct_access[cs].size = PAGE_SIZE;
502
503 dev_info(&pdev->dev, "CS%d configured for direct access\n", cs);
504 }
Jan Kundráte7d21622019-03-28 22:52:38 +0100505diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
Jan Kundrát0341eea2020-10-16 18:06:38 +0200506index 8434bd5a8ec7..7db66392fcd5 100644
Jan Kundráte7d21622019-03-28 22:52:38 +0100507--- a/drivers/tty/serial/max310x.c
508+++ b/drivers/tty/serial/max310x.c
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100509@@ -235,6 +235,10 @@
510 #define MAX310x_REV_MASK (0xf8)
511 #define MAX310X_WRITE_BIT 0x80
Jan Kundráte7d21622019-03-28 22:52:38 +0100512
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100513+/* Timeout for external crystal stability */
514+#define MAX310X_XTAL_WAIT_RETRIES 20
515+#define MAX310X_XTAL_WAIT_DELAY_MS 10
516+
517 /* MAX3107 specific */
518 #define MAX3107_REV_ID (0xa0)
Jan Kundráte7d21622019-03-28 22:52:38 +0100519
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100520@@ -610,11 +614,14 @@ static int max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
521
522 /* Wait for crystal */
523 if (xtal) {
524- unsigned int val;
525- msleep(10);
526- regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val);
527+ unsigned int val = 0, i;
528+ for (i = 0; i < MAX310X_XTAL_WAIT_RETRIES && !(val & MAX310X_STS_CLKREADY_BIT); ++i) {
529+ msleep(MAX310X_XTAL_WAIT_DELAY_MS);
530+ regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val);
531+ }
532 if (!(val & MAX310X_STS_CLKREADY_BIT)) {
533- dev_warn(dev, "clock is not stable yet\n");
534+ dev_err(dev, "clock is not stable\n");
535+ return -EAGAIN;
536 }
537 }
538
Jan Kundrát0341eea2020-10-16 18:06:38 +0200539@@ -1056,9 +1063,9 @@ static int max310x_startup(struct uart_port *port)
540 max310x_port_update(port, MAX310X_MODE1_REG,
541 MAX310X_MODE1_TRNSCVCTRL_BIT, 0);
542
543- /* Configure MODE2 register & Reset FIFOs*/
544- val = MAX310X_MODE2_RXEMPTINV_BIT | MAX310X_MODE2_FIFORST_BIT;
545- max310x_port_write(port, MAX310X_MODE2_REG, val);
546+ /* Reset FIFOs */
547+ max310x_port_write(port, MAX310X_MODE2_REG,
548+ MAX310X_MODE2_FIFORST_BIT);
549 max310x_port_update(port, MAX310X_MODE2_REG,
550 MAX310X_MODE2_FIFORST_BIT, 0);
551
552@@ -1086,8 +1093,27 @@ static int max310x_startup(struct uart_port *port)
553 /* Clear IRQ status register */
554 max310x_port_read(port, MAX310X_IRQSTS_REG);
555
556- /* Enable RX, TX, CTS change interrupts */
557- val = MAX310X_IRQ_RXEMPTY_BIT | MAX310X_IRQ_TXEMPTY_BIT;
558+ /*
559+ * Let's ask for an interrupt after a timeout equivalent to
560+ * the receiving time of 4 characters after the last character
561+ * has been received.
562+ */
563+ max310x_port_write(port, MAX310X_RXTO_REG, 4);
564+
565+ /*
566+ * Make sure we also get RX interrupts when the RX FIFO is
567+ * filling up quickly, so get an interrupt when half of the RX
568+ * FIFO has been filled in.
569+ */
570+ max310x_port_write(port, MAX310X_FIFOTRIGLVL_REG,
571+ MAX310X_FIFOTRIGLVL_RX(MAX310X_FIFO_SIZE / 2));
572+
573+ /* Enable RX timeout interrupt in LSR */
574+ max310x_port_write(port, MAX310X_LSR_IRQEN_REG,
575+ MAX310X_LSR_RXTO_BIT);
576+
577+ /* Enable LSR, RX FIFO trigger, CTS change interrupts */
578+ val = MAX310X_IRQ_LSR_BIT | MAX310X_IRQ_RXFIFO_BIT | MAX310X_IRQ_TXEMPTY_BIT;
579 max310x_port_write(port, MAX310X_IRQEN_REG, val | MAX310X_IRQ_CTS_BIT);
580
581 return 0;
582@@ -1327,6 +1353,10 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
Jan Kundráte7d21622019-03-28 22:52:38 +0100583 }
584
585 uartclk = max310x_set_ref_clk(dev, s, freq, xtal);
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100586+ if (uartclk < 0) {
587+ ret = uartclk;
588+ goto out_uart;
589+ }
590 dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk);
Jan Kundráte7d21622019-03-28 22:52:38 +0100591
Jan Kundrát2bfe9ee2019-12-04 13:42:07 +0100592 for (i = 0; i < devtype->nr; i++) {