Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'i2c-for-6.13-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull more i2c updates from Wolfram Sang:
"Andi was super busy the last weeks, so this pull requests contains one
series (nomadik) and a number of smaller additions which were ready to
go but nearly overlooked.

New feature support:

- Added support for frequencies up to 3.4 MHz on Nomadik I2C

- DesignWare now accounts for bus capacitance and clock optimisation
(declared as new parameters in the binding) to improve the
calculation of signal rise and fall times (t_high and t_low)

New Hardware support:

- DWAPB I2C controller on FUJITSU-MONAKA (new ACPI HID)

- Allwinner A523 (new compatible ID)

- Mobileye EyeQ6H (new compatible ID)"

* tag 'i2c-for-6.13-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
MAINTAINERS: transfer i2c-aspeed maintainership from Brendan to Ryan
i2c: designware: determine HS tHIGH and tLOW based on HW parameters
dt-bindings: i2c: snps,designware-i2c: declare bus capacitance and clk freq optimized
i2c: nomadik: support >=1MHz speed modes
i2c: nomadik: fix BRCR computation
i2c: nomadik: support Mobileye EyeQ6H I2C controller
i2c: nomadik: switch from of_device_is_compatible() to of_match_device()
dt-bindings: i2c: nomadik: support 400kHz < clock-frequency <= 3.4MHz
dt-bindings: i2c: nomadik: add mobileye,eyeq6h-i2c bindings
dt-bindings: i2c: mv64xxx: Add Allwinner A523 compatible string
i2c: designware: Add ACPI HID for DWAPB I2C controller on FUJITSU-MONAKA
i2c: qup: use generic device property accessors

+116 -46
+1
Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml
··· 33 33 - allwinner,sun50i-a100-i2c 34 34 - allwinner,sun50i-h616-i2c 35 35 - allwinner,sun50i-r329-i2c 36 + - allwinner,sun55i-a523-i2c 36 37 - const: allwinner,sun8i-v536-i2c 37 38 - const: allwinner,sun6i-a31-i2c 38 39 - const: marvell,mv64xxx-i2c
+18
Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml
··· 97 97 - const: tx 98 98 - const: rx 99 99 100 + snps,bus-capacitance-pf: 101 + $ref: /schemas/types.yaml#/definitions/uint32 102 + description: 103 + This property indicates the bus capacitance in picofarads (pF). 104 + This value is used to compute the tHIGH and tLOW periods for high speed 105 + mode. 106 + enum: [100, 400] 107 + default: 100 108 + 109 + snps,clk-freq-optimized: 110 + description: 111 + This property indicates whether the hardware reduce its clock frequency 112 + by reducing the internal latency required to generate the high period and 113 + low period of SCL line. 114 + type: boolean 115 + 100 116 unevaluatedProperties: false 101 117 102 118 required: ··· 137 121 i2c-sda-hold-time-ns = <300>; 138 122 i2c-sda-falling-time-ns = <300>; 139 123 i2c-scl-falling-time-ns = <300>; 124 + snps,bus-capacitance-pf = <400>; 125 + snps,clk-freq-optimized; 140 126 }; 141 127 - | 142 128 i2c@2000 {
+7 -6
Documentation/devicetree/bindings/i2c/st,nomadik-i2c.yaml
··· 22 22 enum: 23 23 - st,nomadik-i2c 24 24 - mobileye,eyeq5-i2c 25 + - mobileye,eyeq6h-i2c 25 26 required: 26 27 - compatible 27 28 ··· 30 29 compatible: 31 30 oneOf: 32 31 - items: 33 - - const: st,nomadik-i2c 32 + - enum: 33 + - st,nomadik-i2c 34 + - mobileye,eyeq5-i2c 35 + - mobileye,eyeq6h-i2c 34 36 - const: arm,primecell 35 37 - items: 36 38 - const: stericsson,db8500-i2c 37 39 - const: st,nomadik-i2c 38 - - const: arm,primecell 39 - - items: 40 - - const: mobileye,eyeq5-i2c 41 40 - const: arm,primecell 42 41 43 42 reg: ··· 55 54 - items: 56 55 - const: mclk 57 56 - const: apb_pclk 58 - # Clock name in DB8500 or EyeQ5 57 + # Clock name in DB8500 or EyeQ 59 58 - items: 60 59 - const: i2cclk 61 60 - const: apb_pclk ··· 68 67 69 68 clock-frequency: 70 69 minimum: 1 71 - maximum: 400000 70 + maximum: 3400000 72 71 73 72 mobileye,olb: 74 73 $ref: /schemas/types.yaml#/definitions/phandle-array
+1 -1
MAINTAINERS
··· 2213 2213 F: drivers/pinctrl/pinctrl-artpec* 2214 2214 2215 2215 ARM/ASPEED I2C DRIVER 2216 - M: Brendan Higgins <brendanhiggins@google.com> 2216 + M: Ryan Chen <ryan_chen@aspeedtech.com> 2217 2217 R: Benjamin Herrenschmidt <benh@kernel.crashing.org> 2218 2218 R: Joel Stanley <joel@jms.id.au> 2219 2219 L: linux-i2c@vger.kernel.org
+5
drivers/i2c/busses/i2c-designware-common.c
··· 382 382 383 383 i2c_parse_fw_timings(device, t, false); 384 384 385 + if (device_property_read_u32(device, "snps,bus-capacitance-pf", &dev->bus_capacitance_pF)) 386 + dev->bus_capacitance_pF = 100; 387 + 388 + dev->clk_freq_optimized = device_property_read_bool(device, "snps,clk-freq-optimized"); 389 + 385 390 i2c_dw_adjust_bus_speed(dev); 386 391 387 392 if (is_of_node(fwnode))
+6
drivers/i2c/busses/i2c-designware-core.h
··· 242 242 * @set_sda_hold_time: callback to retrieve IP specific SDA hold timing 243 243 * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE 244 244 * @rinfo: I²C GPIO recovery information 245 + * @bus_capacitance_pF: bus capacitance in picofarads 246 + * @clk_freq_optimized: if this value is true, it means the hardware reduces 247 + * its internal clock frequency by reducing the internal latency required 248 + * to generate the high period and low period of SCL line. 245 249 * 246 250 * HCNT and LCNT parameters can be used if the platform knows more accurate 247 251 * values than the one computed based only on the input clock frequency. ··· 303 299 int (*set_sda_hold_time)(struct dw_i2c_dev *dev); 304 300 int mode; 305 301 struct i2c_bus_recovery_info rinfo; 302 + u32 bus_capacitance_pF; 303 + bool clk_freq_optimized; 306 304 }; 307 305 308 306 #define ACCESS_INTR_MASK BIT(0)
+21 -2
drivers/i2c/busses/i2c-designware-master.c
··· 151 151 dev->hs_hcnt = 0; 152 152 dev->hs_lcnt = 0; 153 153 } else if (!dev->hs_hcnt || !dev->hs_lcnt) { 154 + u32 t_high, t_low; 155 + 156 + /* 157 + * The legal values stated in the databook for bus 158 + * capacitance are only 100pF and 400pF. 159 + * If dev->bus_capacitance_pF is greater than or equals 160 + * to 400, t_high and t_low are assumed to be 161 + * appropriate values for 400pF, otherwise 100pF. 162 + */ 163 + if (dev->bus_capacitance_pF >= 400) { 164 + /* assume bus capacitance is 400pF */ 165 + t_high = dev->clk_freq_optimized ? 160 : 120; 166 + t_low = 320; 167 + } else { 168 + /* assume bus capacitance is 100pF */ 169 + t_high = 60; 170 + t_low = dev->clk_freq_optimized ? 120 : 160; 171 + } 172 + 154 173 ic_clk = i2c_dw_clk_rate(dev); 155 174 dev->hs_hcnt = 156 175 i2c_dw_scl_hcnt(dev, 157 176 DW_IC_HS_SCL_HCNT, 158 177 ic_clk, 159 - 160, /* tHIGH = 160 ns */ 178 + t_high, 160 179 sda_falling_time, 161 180 0); /* No offset */ 162 181 dev->hs_lcnt = 163 182 i2c_dw_scl_lcnt(dev, 164 183 DW_IC_HS_SCL_LCNT, 165 184 ic_clk, 166 - 320, /* tLOW = 320 ns */ 185 + t_low, 167 186 scl_falling_time, 168 187 0); /* No offset */ 169 188 }
+1
drivers/i2c/busses/i2c-designware-platdrv.c
··· 349 349 { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE }, 350 350 { "AMDI0510", 0 }, 351 351 { "APMC0D0F", 0 }, 352 + { "FUJI200B", 0 }, 352 353 { "HISI02A1", 0 }, 353 354 { "HISI02A2", 0 }, 354 355 { "HISI02A3", 0 },
+54 -35
drivers/i2c/busses/i2c-nomadik.c
··· 6 6 * I2C master mode controller driver, used in Nomadik 8815 7 7 * and Ux500 platforms. 8 8 * 9 - * The Mobileye EyeQ5 platform is also supported; it uses 9 + * The Mobileye EyeQ5 and EyeQ6H platforms are also supported; they use 10 10 * the same Ux500/DB8500 IP block with two quirks: 11 11 * - The memory bus only supports 32-bit accesses. 12 - * - A register must be configured for the I2C speed mode; 12 + * - (only EyeQ5) A register must be configured for the I2C speed mode; 13 13 * it is located in a shared register region called OLB. 14 14 * 15 15 * Author: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> ··· 26 26 #include <linux/mfd/syscon.h> 27 27 #include <linux/module.h> 28 28 #include <linux/of.h> 29 + #include <linux/of_device.h> 29 30 #include <linux/pinctrl/consumer.h> 30 31 #include <linux/pm_runtime.h> 31 32 #include <linux/regmap.h> ··· 397 396 */ 398 397 static void setup_i2c_controller(struct nmk_i2c_dev *priv) 399 398 { 400 - u32 brcr1, brcr2; 399 + u32 brcr; 401 400 u32 i2c_clk, div; 402 401 u32 ns; 403 402 u16 slsu; ··· 444 443 /* 445 444 * The spec says, in case of std. mode the divider is 446 445 * 2 whereas it is 3 for fast and fastplus mode of 447 - * operation. TODO - high speed support. 446 + * operation. 448 447 */ 449 448 div = (priv->clk_freq > I2C_MAX_STANDARD_MODE_FREQ) ? 3 : 2; 450 449 ··· 452 451 * generate the mask for baud rate counters. The controller 453 452 * has two baud rate counters. One is used for High speed 454 453 * operation, and the other is for std, fast mode, fast mode 455 - * plus operation. Currently we do not supprt high speed mode 456 - * so set brcr1 to 0. 454 + * plus operation. 455 + * 456 + * BRCR is a clock divider amount. Pick highest value that 457 + * leads to rate strictly below target. Eg when asking for 458 + * 400kHz you want a bus rate <=400kHz (and not >=400kHz). 457 459 */ 458 - brcr1 = FIELD_PREP(I2C_BRCR_BRCNT1, 0); 459 - brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, i2c_clk / (priv->clk_freq * div)); 460 + brcr = DIV_ROUND_UP(i2c_clk, priv->clk_freq * div); 461 + 462 + if (priv->sm == I2C_FREQ_MODE_HIGH_SPEED) 463 + brcr = FIELD_PREP(I2C_BRCR_BRCNT1, brcr); 464 + else 465 + brcr = FIELD_PREP(I2C_BRCR_BRCNT2, brcr); 460 466 461 467 /* set the baud rate counter register */ 462 - writel((brcr1 | brcr2), priv->virtbase + I2C_BRCR); 468 + writel(brcr, priv->virtbase + I2C_BRCR); 463 469 464 - /* 465 - * set the speed mode. Currently we support 466 - * only standard and fast mode of operation 467 - * TODO - support for fast mode plus (up to 1Mb/s) 468 - * and high speed (up to 3.4 Mb/s) 469 - */ 470 - if (priv->sm > I2C_FREQ_MODE_FAST) { 471 - dev_err(&priv->adev->dev, 472 - "do not support this mode defaulting to std. mode\n"); 473 - brcr2 = FIELD_PREP(I2C_BRCR_BRCNT2, 474 - i2c_clk / (I2C_MAX_STANDARD_MODE_FREQ * 2)); 475 - writel((brcr1 | brcr2), priv->virtbase + I2C_BRCR); 476 - writel(FIELD_PREP(I2C_CR_SM, I2C_FREQ_MODE_STANDARD), 477 - priv->virtbase + I2C_CR); 478 - } 470 + /* set the speed mode */ 479 471 writel(FIELD_PREP(I2C_CR_SM, priv->sm), priv->virtbase + I2C_CR); 480 472 481 473 /* set the Tx and Rx FIFO threshold */ ··· 1009 1015 if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) 1010 1016 priv->clk_freq = I2C_MAX_STANDARD_MODE_FREQ; 1011 1017 1012 - /* This driver only supports 'standard' and 'fast' modes of operation. */ 1013 1018 if (priv->clk_freq <= I2C_MAX_STANDARD_MODE_FREQ) 1014 1019 priv->sm = I2C_FREQ_MODE_STANDARD; 1015 - else 1020 + else if (priv->clk_freq <= I2C_MAX_FAST_MODE_FREQ) 1016 1021 priv->sm = I2C_FREQ_MODE_FAST; 1022 + else if (priv->clk_freq <= I2C_MAX_FAST_MODE_PLUS_FREQ) 1023 + priv->sm = I2C_FREQ_MODE_FAST_PLUS; 1024 + else 1025 + priv->sm = I2C_FREQ_MODE_HIGH_SPEED; 1017 1026 priv->tft = 1; /* Tx FIFO threshold */ 1018 1027 priv->rft = 8; /* Rx FIFO threshold */ 1019 1028 ··· 1043 1046 struct regmap *olb; 1044 1047 unsigned int id; 1045 1048 1046 - priv->has_32b_bus = true; 1047 - 1048 1049 olb = syscon_regmap_lookup_by_phandle_args(np, "mobileye,olb", 1, &id); 1049 1050 if (IS_ERR(olb)) 1050 1051 return PTR_ERR(olb); ··· 1063 1068 return 0; 1064 1069 } 1065 1070 1071 + #define NMK_I2C_EYEQ_FLAG_32B_BUS BIT(0) 1072 + #define NMK_I2C_EYEQ_FLAG_IS_EYEQ5 BIT(1) 1073 + 1074 + static const struct of_device_id nmk_i2c_eyeq_match_table[] = { 1075 + { 1076 + .compatible = "mobileye,eyeq5-i2c", 1077 + .data = (void *)(NMK_I2C_EYEQ_FLAG_32B_BUS | NMK_I2C_EYEQ_FLAG_IS_EYEQ5), 1078 + }, 1079 + { 1080 + .compatible = "mobileye,eyeq6h-i2c", 1081 + .data = (void *)NMK_I2C_EYEQ_FLAG_32B_BUS, 1082 + }, 1083 + }; 1084 + 1066 1085 static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) 1067 1086 { 1068 - int ret = 0; 1069 - struct nmk_i2c_dev *priv; 1070 - struct device_node *np = adev->dev.of_node; 1071 - struct device *dev = &adev->dev; 1072 - struct i2c_adapter *adap; 1073 1087 struct i2c_vendor_data *vendor = id->data; 1074 1088 u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; 1089 + struct device_node *np = adev->dev.of_node; 1090 + const struct of_device_id *match; 1091 + struct device *dev = &adev->dev; 1092 + unsigned long match_flags = 0; 1093 + struct nmk_i2c_dev *priv; 1094 + struct i2c_adapter *adap; 1095 + int ret = 0; 1096 + 1097 + /* 1098 + * We do not want to attach a .of_match_table to our amba driver. 1099 + * Do not convert to device_get_match_data(). 1100 + */ 1101 + match = of_match_device(nmk_i2c_eyeq_match_table, dev); 1102 + if (match) 1103 + match_flags = (unsigned long)match->data; 1075 1104 1076 1105 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 1077 1106 if (!priv) ··· 1103 1084 1104 1085 priv->vendor = vendor; 1105 1086 priv->adev = adev; 1106 - priv->has_32b_bus = false; 1087 + priv->has_32b_bus = match_flags & NMK_I2C_EYEQ_FLAG_32B_BUS; 1107 1088 nmk_i2c_of_probe(np, priv); 1108 1089 1109 - if (of_device_is_compatible(np, "mobileye,eyeq5-i2c")) { 1090 + if (match_flags & NMK_I2C_EYEQ_FLAG_IS_EYEQ5) { 1110 1091 ret = nmk_i2c_eyeq5_probe(priv); 1111 1092 if (ret) 1112 1093 return dev_err_probe(dev, ret, "failed OLB lookup\n");
+2 -2
drivers/i2c/busses/i2c-qup.c
··· 17 17 #include <linux/interrupt.h> 18 18 #include <linux/io.h> 19 19 #include <linux/module.h> 20 - #include <linux/of.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/pm_runtime.h> 22 + #include <linux/property.h> 23 23 #include <linux/scatterlist.h> 24 24 25 25 /* QUP Registers */ ··· 1683 1683 } 1684 1684 } 1685 1685 1686 - if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) { 1686 + if (device_is_compatible(&pdev->dev, "qcom,i2c-qup-v1.1.1")) { 1687 1687 qup->adap.algo = &qup_i2c_algo; 1688 1688 qup->adap.quirks = &qup_i2c_quirks; 1689 1689 is_qup_v1 = true;