kernel: fix regression in max310x/regmap/regcache

The kernel driver for our UART was buggy. The data that were written out
to the Nistica WSS were ending up in the kernel's regmap's regcache
layer, and as a result, the UART traffic was only sent the first time.
Subsequent opens of the port would end up in a total silence.

This turned out to be fixed independently on mainline, so just upgrade
to v6.6.3 to get that fix. The current branch is available form our
Gerrit copy of the kernel, branch `cesnet/2023-12-02`. I also used this
opportunity to bring in some max310x patches there were posted for
review -- see the changelog in the kernel repo if you're interested.
Here's what we're carrying now:

Hugo Villeneuve (2):
      serial: max310x: add macro for max number of ports
      serial: max310x: use separate regmap name for each port

Jan Kundrát (6):
      spi: orion: Respect per-transfer bits_per_word settings
      ARM: dts: armada-388-clearfog: support I2C recovery on i2c-1
      pinctrl: mcp23s08: work around GPIO line naming
      leds: tlc591xx: SW reset during initialization
      Revert "leds: Mark GPIO LED trigger broken"
      tty: max310x: Fail probe when external clock crystal is not stable

Bug: https://lore.kernel.org/linux-serial/bd91db46c50615bc1d1d62beb659fa7f62386446.1701446070.git.jan.kundrat@cesnet.cz/T/#u
Change-Id: Ibfcdfb995eeae6a60b81f313513194ca20220c18
diff --git a/board/czechlight/clearfog/linux.fragment b/board/czechlight/clearfog/linux.fragment
index 52f4309..59c45ca 100644
--- a/board/czechlight/clearfog/linux.fragment
+++ b/board/czechlight/clearfog/linux.fragment
@@ -52,4 +52,4 @@
 CONFIG_INPUT_MOUSE=n
 CONFIG_BPF_SYSCALL=y
 
-CONFIG_LOCALVERSION="-7-g9e090fe75fd8"
+CONFIG_LOCALVERSION="-8-g589edcf57c57"
diff --git a/board/czechlight/clearfog/patches/linux.patch b/board/czechlight/clearfog/patches/linux.patch
index ec20c40..acb3375 100644
--- a/board/czechlight/clearfog/patches/linux.patch
+++ b/board/czechlight/clearfog/patches/linux.patch
@@ -71,10 +71,10 @@
  		marvell,pins = "mpp20";
  		marvell,function = "gpio";
 diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
-index dfc6fb2b3e52..07be0741f873 100644
+index 945e831ef4ac..682ad60970d0 100644
 --- a/drivers/leds/leds-tlc591xx.c
 +++ b/drivers/leds/leds-tlc591xx.c
-@@ -40,6 +40,9 @@
+@@ -39,6 +39,9 @@
  
  #define ldev_to_led(c)		container_of(c, struct tlc591xx_led, ldev)
  
@@ -84,7 +84,7 @@
  struct tlc591xx_led {
  	bool active;
  	unsigned int led_no;
-@@ -51,21 +54,25 @@ struct tlc591xx_priv {
+@@ -50,21 +53,25 @@ struct tlc591xx_priv {
  	struct tlc591xx_led leds[TLC591XX_MAX_LEDS];
  	struct regmap *regmap;
  	unsigned int reg_ledout_offset;
@@ -110,7 +110,7 @@
  };
  
  static int
-@@ -179,6 +186,18 @@ tlc591xx_probe(struct i2c_client *client)
+@@ -178,6 +185,18 @@ tlc591xx_probe(struct i2c_client *client)
  
  	i2c_set_clientdata(client, priv);
  
@@ -209,10 +209,10 @@
  	data->ngpio = ngpio;
  
 diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
-index ad9e83e34297..dc5c60182ea5 100644
+index 1f10f5c8e34d..25bde84af1cc 100644
 --- a/drivers/spi/spi-orion.c
 +++ b/drivers/spi/spi-orion.c
-@@ -473,7 +473,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
+@@ -472,7 +472,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer)
  	int cs = spi_get_chipselect(spi, 0);
  	void __iomem *vaddr;
  
@@ -220,12 +220,24 @@
 +	word_len = xfer->bits_per_word;
  	count = xfer->len;
  
- 	orion_spi = spi_master_get_devdata(spi->master);
+ 	orion_spi = spi_controller_get_devdata(spi->controller);
 diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
-index 997e39449766..ccbb5b1bb0f4 100644
+index db3204d2a305..698567890e7b 100644
 --- a/drivers/tty/serial/max310x.c
 +++ b/drivers/tty/serial/max310x.c
-@@ -237,6 +237,10 @@
+@@ -27,9 +27,11 @@
+ #include <linux/uaccess.h>
+ 
+ #define MAX310X_NAME			"max310x"
++#define MAX310X_PORT_NAME_SUFFIX	"port"
+ #define MAX310X_MAJOR			204
+ #define MAX310X_MINOR			209
+ #define MAX310X_UART_NRMAX		16
++#define MAX310X_MAX_PORTS		4 /* Maximum number of UART ports per IC. */
+ 
+ /* MAX310X register definitions */
+ #define MAX310X_RHR_REG			(0x00) /* RX FIFO */
+@@ -237,6 +239,10 @@
  #define MAX310x_REV_MASK		(0xf8)
  #define MAX310X_WRITE_BIT		0x80
  
@@ -236,7 +248,7 @@
  /* MAX3107 specific */
  #define MAX3107_REV_ID			(0xa0)
  
-@@ -641,11 +645,14 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
+@@ -641,11 +647,14 @@ static u32 max310x_set_ref_clk(struct device *dev, struct max310x_port *s,
  
  	/* Wait for crystal */
  	if (xtal) {
@@ -255,7 +267,7 @@
  		}
  	}
  
-@@ -1348,6 +1355,10 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
+@@ -1349,6 +1358,10 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
  	}
  
  	uartclk = max310x_set_ref_clk(dev, s, freq, xtal);
@@ -266,11 +278,62 @@
  	dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk);
  
  	for (i = 0; i < devtype->nr; i++) {
-@@ -1516,6 +1527,7 @@ static int max310x_spi_probe(struct spi_device *spi)
+@@ -1485,6 +1498,15 @@ static struct regmap_config regcfg = {
+ 	.max_raw_write = MAX310X_FIFO_SIZE,
+ };
+ 
++static const char *max310x_regmap_name(unsigned int port_id)
++{
++	static char buf[sizeof(MAX310X_PORT_NAME_SUFFIX __stringify(MAX310X_MAX_PORTS))];
++
++	snprintf(buf, sizeof(buf), MAX310X_PORT_NAME_SUFFIX "%u", port_id);
++
++	return buf;
++}
++
+ #ifdef CONFIG_SPI_MASTER
+ static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
+ {
+@@ -1502,7 +1524,7 @@ static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg = {
+ static int max310x_spi_probe(struct spi_device *spi)
+ {
+ 	const struct max310x_devtype *devtype;
+-	struct regmap *regmaps[4];
++	struct regmap *regmaps[MAX310X_MAX_PORTS];
+ 	unsigned int i;
+ 	int ret;
+ 
+@@ -1520,6 +1542,8 @@ static int max310x_spi_probe(struct spi_device *spi)
+ 
+ 	for (i = 0; i < devtype->nr; i++) {
  		u8 port_mask = i * 0x20;
++
++		regcfg.name = max310x_regmap_name(i);
  		regcfg.read_flag_mask = port_mask;
  		regcfg.write_flag_mask = port_mask | MAX310X_WRITE_BIT;
-+		regcfg.name = kasprintf(GFP_KERNEL, "port-%d", i);
  		regmaps[i] = devm_regmap_init_spi(spi, &regcfg);
+@@ -1605,7 +1629,7 @@ static int max310x_i2c_probe(struct i2c_client *client)
+ 	const struct max310x_devtype *devtype =
+ 			device_get_match_data(&client->dev);
+ 	struct i2c_client *port_client;
+-	struct regmap *regmaps[4];
++	struct regmap *regmaps[MAX310X_MAX_PORTS];
+ 	unsigned int i;
+ 	u8 port_addr;
+ 
+@@ -1616,6 +1640,7 @@ static int max310x_i2c_probe(struct i2c_client *client)
+ 				     client->addr, devtype->slave_addr.min,
+ 				     devtype->slave_addr.max);
+ 
++	regcfg_i2c.name = max310x_regmap_name(0);
+ 	regmaps[0] = devm_regmap_init_i2c(client, &regcfg_i2c);
+ 
+ 	for (i = 1; i < devtype->nr; i++) {
+@@ -1624,6 +1649,7 @@ static int max310x_i2c_probe(struct i2c_client *client)
+ 							client->adapter,
+ 							port_addr);
+ 
++		regcfg_i2c.name = max310x_regmap_name(i);
+ 		regmaps[i] = devm_regmap_init_i2c(port_client, &regcfg_i2c);
  	}
  
diff --git a/configs/czechlight_clearfog_defconfig b/configs/czechlight_clearfog_defconfig
index 87840c0..58d8823 100644
--- a/configs/czechlight_clearfog_defconfig
+++ b/configs/czechlight_clearfog_defconfig
@@ -28,7 +28,7 @@
 BR2_ROOTFS_POST_SCRIPT_ARGS="-c $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/genimage.cfg"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_VERSION=y
-BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.5.9"
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.3"
 BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/patches/linux.patch"
 BR2_LINUX_KERNEL_DEFCONFIG="mvebu_v7"
 BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/clearfog/linux.fragment $(BR2_EXTERNAL_CZECHLIGHT_PATH)/board/czechlight/common/linux.fragment"