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 | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 44 | diff --git a/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi b/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
Jan Kundrát | b4138fc | 2024-01-03 14:34:22 +0100 | [diff] [blame^] | 45 | index f8a06ae4a3c9..e14020e653a1 100644 |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 46 | --- a/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
| 47 | +++ b/arch/arm/boot/dts/marvell/armada-388-clearfog.dtsi |
Jan Kundrát | b4138fc | 2024-01-03 14:34:22 +0100 | [diff] [blame^] | 48 | @@ -111,6 +111,12 @@ ð2 { |
| 49 | }; |
| 50 | |
| 51 | &i2c0 { |
| 52 | + pinctrl-0 = <&clearfog_i2c0_pins>; |
| 53 | + pinctrl-1 = <&clearfog_i2c0_recovery_pins>; |
| 54 | + pinctrl-names = "default", "gpio"; |
| 55 | + scl-gpios = <&gpio0 2 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 56 | + sda-gpios = <&gpio0 3 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 57 | + |
| 58 | /* |
| 59 | * PCA9655 GPIO expander, up to 1MHz clock. |
| 60 | * 0-CON3 CLKREQ# |
| 61 | @@ -196,16 +202,32 @@ &i2c1 { |
Jan Kundrát | 9ce4f9e | 2022-02-17 16:38:57 +0100 | [diff] [blame] | 62 | */ |
| 63 | clock-frequency = <100000>; |
| 64 | pinctrl-0 = <&clearfog_i2c1_pins>; |
| 65 | - pinctrl-names = "default"; |
| 66 | + pinctrl-1 = <&clearfog_i2c1_recovery_pins>; |
| 67 | + pinctrl-names = "default", "gpio"; |
| 68 | status = "okay"; |
| 69 | + single-master; |
| 70 | + scl-gpios = <&gpio0 26 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 71 | + sda-gpios = <&gpio0 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; |
| 72 | }; |
| 73 | |
| 74 | &pinctrl { |
Jan Kundrát | b4138fc | 2024-01-03 14:34:22 +0100 | [diff] [blame^] | 75 | + clearfog_i2c0_pins: i2c0-pins { |
| 76 | + marvell,pins = "mpp2", "mpp3"; |
| 77 | + marvell,function = "i2c0"; |
| 78 | + }; |
| 79 | + clearfog_i2c0_recovery_pins: i2c0-recovery-pins { |
| 80 | + marvell,pins = "mpp2", "mpp3"; |
| 81 | + marvell,function = "gpio"; |
| 82 | + }; |
| 83 | clearfog_i2c1_pins: i2c1-pins { |
| 84 | /* SFP, PCIe, mSATA, mikrobus */ |
Jan Kundrát | 9ce4f9e | 2022-02-17 16:38:57 +0100 | [diff] [blame] | 85 | marvell,pins = "mpp26", "mpp27"; |
| 86 | marvell,function = "i2c1"; |
| 87 | }; |
| 88 | + clearfog_i2c1_recovery_pins: i2c1-recovery-pins { |
| 89 | + marvell,pins = "mpp26", "mpp27"; |
| 90 | + marvell,function = "gpio"; |
| 91 | + }; |
| 92 | clearfog_sdhci_cd_pins: clearfog-sdhci-cd-pins { |
| 93 | marvell,pins = "mpp20"; |
| 94 | marvell,function = "gpio"; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 95 | diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 96 | index 945e831ef4ac..682ad60970d0 100644 |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 97 | --- a/drivers/leds/leds-tlc591xx.c |
| 98 | +++ b/drivers/leds/leds-tlc591xx.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 99 | @@ -39,6 +39,9 @@ |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 100 | |
| 101 | #define ldev_to_led(c) container_of(c, struct tlc591xx_led, ldev) |
| 102 | |
| 103 | +#define TLC591XX_RESET_BYTE_0 0xa5 |
| 104 | +#define TLC591XX_RESET_BYTE_1 0x5a |
| 105 | + |
| 106 | struct tlc591xx_led { |
| 107 | bool active; |
| 108 | unsigned int led_no; |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 109 | @@ -50,21 +53,25 @@ struct tlc591xx_priv { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 110 | struct tlc591xx_led leds[TLC591XX_MAX_LEDS]; |
| 111 | struct regmap *regmap; |
| 112 | unsigned int reg_ledout_offset; |
| 113 | + struct i2c_client *swrst_client; |
| 114 | }; |
| 115 | |
| 116 | struct tlc591xx { |
| 117 | unsigned int max_leds; |
| 118 | unsigned int reg_ledout_offset; |
| 119 | + u8 swrst_addr; |
| 120 | }; |
| 121 | |
| 122 | static const struct tlc591xx tlc59116 = { |
| 123 | .max_leds = 16, |
| 124 | .reg_ledout_offset = 0x14, |
| 125 | + .swrst_addr = 0x6b, |
| 126 | }; |
| 127 | |
| 128 | static const struct tlc591xx tlc59108 = { |
| 129 | .max_leds = 8, |
| 130 | .reg_ledout_offset = 0x0c, |
| 131 | + .swrst_addr = 0x4b, |
| 132 | }; |
| 133 | |
| 134 | static int |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 135 | @@ -178,6 +185,18 @@ tlc591xx_probe(struct i2c_client *client) |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 136 | |
| 137 | i2c_set_clientdata(client, priv); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 138 | |
Jan Kundrát | f97c81d | 2020-02-06 00:33:19 +0100 | [diff] [blame] | 139 | + 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] | 140 | + if (IS_ERR(priv->swrst_client)) { |
| 141 | + dev_info(dev, "Skipping reset: address %02x already used\n", |
| 142 | + tlc591xx->swrst_addr); |
| 143 | + } else { |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 144 | + err = i2c_smbus_write_byte_data(priv->swrst_client, |
| 145 | + TLC591XX_RESET_BYTE_0, TLC591XX_RESET_BYTE_1); |
| 146 | + if (err) { |
| 147 | + dev_warn(dev, "SW reset failed\n"); |
| 148 | + } |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 149 | + } |
| 150 | + |
Jan Kundrát | 31bf7ae | 2020-02-14 17:03:53 +0100 | [diff] [blame] | 151 | err = tlc591xx_set_mode(priv->regmap, MODE2_DIM); |
| 152 | if (err < 0) |
| 153 | return err; |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 154 | diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig |
| 155 | index 2a57328eca20..dc6816d36d06 100644 |
| 156 | --- a/drivers/leds/trigger/Kconfig |
| 157 | +++ b/drivers/leds/trigger/Kconfig |
| 158 | @@ -83,7 +83,6 @@ config LEDS_TRIGGER_ACTIVITY |
| 159 | config LEDS_TRIGGER_GPIO |
| 160 | tristate "LED GPIO Trigger" |
| 161 | depends on GPIOLIB || COMPILE_TEST |
| 162 | - depends on BROKEN |
| 163 | help |
| 164 | This allows LEDs to be controlled by gpio events. It's good |
| 165 | when using gpios as switches and triggering the needed LEDs |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 166 | diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 167 | index ea059b9c5542..d58c6e631942 100644 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 168 | --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
| 169 | +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 170 | @@ -8,6 +8,7 @@ |
| 171 | #include <linux/spi/spi.h> |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 172 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 173 | #include "pinctrl-mcp23s08.h" |
| 174 | +#include "../gpio/gpiolib.h" |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 175 | |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 176 | #define MCP_MAX_DEV_PER_CS 8 |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 177 | |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 178 | @@ -153,6 +154,10 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 179 | int type; |
| 180 | int ret; |
| 181 | u32 v; |
| 182 | + struct device_node *np; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 183 | + int line_name_count; |
| 184 | + const char **names; |
| 185 | + int i; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 186 | |
| 187 | match = device_get_match_data(dev); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 188 | if (match) |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 189 | @@ -202,6 +207,43 @@ static int mcp23s08_probe(struct spi_device *spi) |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 190 | return ret; |
| 191 | |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 192 | ngpio += data->mcp[addr]->chip.ngpio; |
| 193 | + |
| 194 | + for_each_available_child_of_node(spi->dev.of_node, np) { |
| 195 | + u32 chip_addr; |
Jan Kundrát | 0341eea | 2020-10-16 18:06:38 +0200 | [diff] [blame] | 196 | + ret = of_property_read_u32(np, "address", &chip_addr); |
| 197 | + if (ret) |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 198 | + continue; |
| 199 | + if (chip_addr != addr) |
| 200 | + continue; |
Jan Kundrát | bf1e091 | 2021-03-05 12:45:23 +0100 | [diff] [blame] | 201 | + |
| 202 | + line_name_count = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", NULL, 0); |
| 203 | + if (line_name_count < 0) |
| 204 | + continue; |
| 205 | + |
| 206 | + if (line_name_count > data->mcp[addr]->chip.ngpio) { |
| 207 | + dev_warn(&spi->dev, "gpio-line-names is length %d but should be at most length %d", |
| 208 | + line_name_count, data->mcp[addr]->chip.ngpio); |
| 209 | + line_name_count = data->mcp[addr]->chip.ngpio; |
| 210 | + } |
| 211 | + |
| 212 | + names = kcalloc(line_name_count, sizeof(*names), GFP_KERNEL); |
| 213 | + if (!names) { |
| 214 | + dev_warn(&spi->dev, "cannot allocate gpio-line-names"); |
| 215 | + continue; |
| 216 | + } |
| 217 | + |
| 218 | + ret = fwnode_property_read_string_array(of_fwnode_handle(np), "gpio-line-names", names, line_name_count); |
| 219 | + if (ret < 0) { |
| 220 | + dev_warn(&spi->dev, "failed to read GPIO line names"); |
| 221 | + kfree(names); |
| 222 | + continue; |
| 223 | + } |
| 224 | + |
| 225 | + for (i = 0; i < line_name_count; i++) |
| 226 | + data->mcp[addr]->chip.gpiodev->descs[i].name = names[i]; |
| 227 | + |
| 228 | + kfree(names); |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 229 | + } |
| 230 | } |
| 231 | data->ngpio = ngpio; |
| 232 | |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 233 | diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 234 | index 1f10f5c8e34d..25bde84af1cc 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 235 | --- a/drivers/spi/spi-orion.c |
| 236 | +++ b/drivers/spi/spi-orion.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 237 | @@ -472,7 +472,7 @@ orion_spi_write_read(struct spi_device *spi, struct spi_transfer *xfer) |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 238 | int cs = spi_get_chipselect(spi, 0); |
Jan Kundrát | 549db87 | 2019-03-05 12:23:25 +0100 | [diff] [blame] | 239 | void __iomem *vaddr; |
Jan Kundrát | 2501643 | 2019-03-04 21:40:58 +0100 | [diff] [blame] | 240 | |
| 241 | - word_len = spi->bits_per_word; |
| 242 | + word_len = xfer->bits_per_word; |
| 243 | count = xfer->len; |
| 244 | |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 245 | orion_spi = spi_controller_get_devdata(spi->controller); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 246 | diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 247 | index db3204d2a305..698567890e7b 100644 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 248 | --- a/drivers/tty/serial/max310x.c |
| 249 | +++ b/drivers/tty/serial/max310x.c |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 250 | @@ -27,9 +27,11 @@ |
| 251 | #include <linux/uaccess.h> |
| 252 | |
| 253 | #define MAX310X_NAME "max310x" |
| 254 | +#define MAX310X_PORT_NAME_SUFFIX "port" |
| 255 | #define MAX310X_MAJOR 204 |
| 256 | #define MAX310X_MINOR 209 |
| 257 | #define MAX310X_UART_NRMAX 16 |
| 258 | +#define MAX310X_MAX_PORTS 4 /* Maximum number of UART ports per IC. */ |
| 259 | |
| 260 | /* MAX310X register definitions */ |
| 261 | #define MAX310X_RHR_REG (0x00) /* RX FIFO */ |
| 262 | @@ -237,6 +239,10 @@ |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 263 | #define MAX310x_REV_MASK (0xf8) |
| 264 | #define MAX310X_WRITE_BIT 0x80 |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 265 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 266 | +/* Timeout for external crystal stability */ |
| 267 | +#define MAX310X_XTAL_WAIT_RETRIES 20 |
| 268 | +#define MAX310X_XTAL_WAIT_DELAY_MS 10 |
| 269 | + |
| 270 | /* MAX3107 specific */ |
| 271 | #define MAX3107_REV_ID (0xa0) |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 272 | |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 273 | @@ -641,11 +647,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] | 274 | |
| 275 | /* Wait for crystal */ |
| 276 | if (xtal) { |
| 277 | - unsigned int val; |
| 278 | - msleep(10); |
| 279 | - regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 280 | + unsigned int val = 0, i; |
| 281 | + for (i = 0; i < MAX310X_XTAL_WAIT_RETRIES && !(val & MAX310X_STS_CLKREADY_BIT); ++i) { |
| 282 | + msleep(MAX310X_XTAL_WAIT_DELAY_MS); |
| 283 | + regmap_read(s->regmap, MAX310X_STS_IRQSTS_REG, &val); |
| 284 | + } |
| 285 | if (!(val & MAX310X_STS_CLKREADY_BIT)) { |
| 286 | - dev_warn(dev, "clock is not stable yet\n"); |
| 287 | + dev_err(dev, "clock is not stable\n"); |
| 288 | + return -EAGAIN; |
| 289 | } |
| 290 | } |
| 291 | |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 292 | @@ -1349,6 +1358,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] | 293 | } |
| 294 | |
| 295 | uartclk = max310x_set_ref_clk(dev, s, freq, xtal); |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 296 | + if (uartclk < 0) { |
| 297 | + ret = uartclk; |
| 298 | + goto out_uart; |
| 299 | + } |
| 300 | dev_dbg(dev, "Reference clock set to %i Hz\n", uartclk); |
Jan Kundrát | e7d2162 | 2019-03-28 22:52:38 +0100 | [diff] [blame] | 301 | |
Jan Kundrát | 2bfe9ee | 2019-12-04 13:42:07 +0100 | [diff] [blame] | 302 | for (i = 0; i < devtype->nr; i++) { |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 303 | @@ -1485,6 +1498,15 @@ static struct regmap_config regcfg = { |
| 304 | .max_raw_write = MAX310X_FIFO_SIZE, |
| 305 | }; |
| 306 | |
| 307 | +static const char *max310x_regmap_name(unsigned int port_id) |
| 308 | +{ |
| 309 | + static char buf[sizeof(MAX310X_PORT_NAME_SUFFIX __stringify(MAX310X_MAX_PORTS))]; |
| 310 | + |
| 311 | + snprintf(buf, sizeof(buf), MAX310X_PORT_NAME_SUFFIX "%u", port_id); |
| 312 | + |
| 313 | + return buf; |
| 314 | +} |
| 315 | + |
| 316 | #ifdef CONFIG_SPI_MASTER |
| 317 | static int max310x_spi_extended_reg_enable(struct device *dev, bool enable) |
| 318 | { |
| 319 | @@ -1502,7 +1524,7 @@ static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg = { |
| 320 | static int max310x_spi_probe(struct spi_device *spi) |
| 321 | { |
| 322 | const struct max310x_devtype *devtype; |
| 323 | - struct regmap *regmaps[4]; |
| 324 | + struct regmap *regmaps[MAX310X_MAX_PORTS]; |
| 325 | unsigned int i; |
| 326 | int ret; |
| 327 | |
| 328 | @@ -1520,6 +1542,8 @@ static int max310x_spi_probe(struct spi_device *spi) |
| 329 | |
| 330 | for (i = 0; i < devtype->nr; i++) { |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 331 | u8 port_mask = i * 0x20; |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 332 | + |
| 333 | + regcfg.name = max310x_regmap_name(i); |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 334 | regcfg.read_flag_mask = port_mask; |
| 335 | regcfg.write_flag_mask = port_mask | MAX310X_WRITE_BIT; |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 336 | regmaps[i] = devm_regmap_init_spi(spi, ®cfg); |
Jan Kundrát | da81940 | 2023-12-02 11:20:56 +0100 | [diff] [blame] | 337 | @@ -1605,7 +1629,7 @@ static int max310x_i2c_probe(struct i2c_client *client) |
| 338 | const struct max310x_devtype *devtype = |
| 339 | device_get_match_data(&client->dev); |
| 340 | struct i2c_client *port_client; |
| 341 | - struct regmap *regmaps[4]; |
| 342 | + struct regmap *regmaps[MAX310X_MAX_PORTS]; |
| 343 | unsigned int i; |
| 344 | u8 port_addr; |
| 345 | |
| 346 | @@ -1616,6 +1640,7 @@ static int max310x_i2c_probe(struct i2c_client *client) |
| 347 | client->addr, devtype->slave_addr.min, |
| 348 | devtype->slave_addr.max); |
| 349 | |
| 350 | + regcfg_i2c.name = max310x_regmap_name(0); |
| 351 | regmaps[0] = devm_regmap_init_i2c(client, ®cfg_i2c); |
| 352 | |
| 353 | for (i = 1; i < devtype->nr; i++) { |
| 354 | @@ -1624,6 +1649,7 @@ static int max310x_i2c_probe(struct i2c_client *client) |
| 355 | client->adapter, |
| 356 | port_addr); |
| 357 | |
| 358 | + regcfg_i2c.name = max310x_regmap_name(i); |
| 359 | regmaps[i] = devm_regmap_init_i2c(port_client, ®cfg_i2c); |
Jan Kundrát | 0ef140f | 2023-09-14 12:14:43 +0200 | [diff] [blame] | 360 | } |
Jan Kundrát | 277991e | 2023-02-24 21:12:13 +0100 | [diff] [blame] | 361 | |