i2c: qup: Move bus frequency definitions to i2c.h
Subsystems (37)
Andy Shevchenko
reviewerPATCH 2/40 i2c: algo: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/algos/i2c-algo-pca.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-pca.c +3 -3
@@ -459,17 +459,17 @@ static int pca_init(struct i2c_adapter *adap)/* To avoid integer overflow, use clock/100 for calculations */ clock =pca_clock (pca_data) /100 ; -if (pca_data->i2c_clock >1000000 ) { +if (pca_data->i2c_clock >I2C_FAST_MODE_PLUS_FREQ ) { mode =I2C_PCA_MODE_TURBO ; min_tlow =14 ; min_thi =5 ; raise_fall_time =22 ;/* Raise 11e-8s, Fall 11e-8s */ - }else if (pca_data->i2c_clock >400000 ) { + }else if (pca_data->i2c_clock >I2C_FAST_MODE_FREQ ) { mode =I2C_PCA_MODE_FASTP ; min_tlow =17 ; min_thi =9 ; raise_fall_time =22 ;/* Raise 11e-8s, Fall 11e-8s */ - }else if (pca_data->i2c_clock >100000 ) { + }else if (pca_data->i2c_clock >I2C_STANDARD_MODE_FREQ ) { mode =I2C_PCA_MODE_FAST ; min_tlow =44 ; min_thi =20 ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 4/40 i2c: altera: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-altera.c | 8 ++++---- include/linux/i2c.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-altera.c +4 -4
@@ -142,12 +142,12 @@ static inline void altr_i2c_stop(struct altr_i2c_dev *idev)static void altr_i2c_init (struct altr_i2c_dev *idev) {u32 divisor =clk_get_rate (idev->i2c_clk) / idev->bus_clk_rate; -u32 clk_mhz =clk_get_rate (idev->i2c_clk) /1000000 ; +u32 clk_mhz =clk_get_rate (idev->i2c_clk) /HZ_PER_MHZ ;u32 tmp = (ALTR_I2C_THRESHOLD <<ALTR_I2C_CTRL_RXT_SHFT ) | (ALTR_I2C_THRESHOLD <<ALTR_I2C_CTRL_TCT_SHFT );u32 t_high, t_low; -if (idev->bus_clk_rate <=100000 ) { +if (idev->bus_clk_rate <=I2C_STANDARD_MODE_FREQ ) { tmp &= ~ALTR_I2C_CTRL_BSPEED ;/* Standard mode SCL 50/50 */ t_high = divisor *1 /2 ;
@@ -423,10 +423,10 @@ static int altr_i2c_probe(struct platform_device *pdev) &idev->bus_clk_rate);if (val) {dev_err (&pdev->dev,"Default to 100kHz\n" ); - idev->bus_clk_rate =100000 ;/* default clock rate */ + idev->bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* default clock rate */ } -if (idev->bus_clk_rate >400000 ) { +if (idev->bus_clk_rate >I2C_FAST_MODE_FREQ ) {dev_err (&pdev->dev,"invalid clock-frequency %d\n" , idev->bus_clk_rate);return -EINVAL ;
include/linux/i2c.h +1 -0
@@ -40,6 +40,7 @@ typedef int (*i2c_slave_cb_t)(struct i2c_client *client, enum i2c_slave_event event, u8 *val);#define HZ_PER_KHZ 1000 +#define HZ_PER_MHZ 1000000/* I2C Frequency Modes */ #define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ)
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 5/40 i2c: amd-mp2: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 ++++++++++++++++----------- include/linux/i2c.h | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-amd-mp2-plat.c +16 -11
@@ -201,32 +201,37 @@ static int i2c_amd_resume(struct amd_i2c_common *i2c_common) }#endif +static const u32 supported_speeds[] = { +I2C_HIGH_SPEED_MODE_FREQ , +I2C_TURBO_MODE_FREQ , +I2C_FAST_MODE_PLUS_FREQ , +I2C_FAST_MODE_FREQ , +I2C_STANDARD_MODE_FREQ , +}; +static enum speed_enum i2c_amd_get_bus_speed (struct platform_device *pdev) {u32 acpi_speed;int i; -static const u32 supported_speeds[] = { -0 ,100000 ,400000 ,1000000 ,1400000 ,3400000 - }; acpi_speed =i2c_acpi_find_bus_speed (&pdev->dev);/* round down to the lowest standard speed */ -for (i =1 ; i <ARRAY_SIZE (supported_speeds); i++) { -if (acpi_speed < supported_speeds[i]) +for (i =0 ; i <ARRAY_SIZE (supported_speeds); i++) { +if (acpi_speed >= supported_speeds[i])break ; } - acpi_speed = supported_speeds[i -1 ]; + acpi_speed = i <ARRAY_SIZE (supported_speeds) ? supported_speeds[i] :0 ;switch (acpi_speed) { -case 100000 : +case I2C_STANDARD_MODE_FREQ :return speed100k; -case 400000 : +case I2C_FAST_MODE_FREQ :return speed400k; -case 1000000 : +case I2C_FAST_MODE_PLUS_FREQ :return speed1000k; -case 1400000 : +case I2C_TURBO_MODE_FREQ :return speed1400k; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ :return speed3400k;default :return speed400k;
include/linux/i2c.h +2 -0
@@ -46,6 +46,8 @@ typedef int (*i2c_slave_cb_t)(struct i2c_client *client,#define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ)#define I2C_FAST_MODE_FREQ (400 * HZ_PER_KHZ)#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ) +#define I2C_TURBO_MODE_FREQ (1400 * HZ_PER_KHZ) +#define I2C_HIGH_SPEED_MODE_FREQ (3400 * HZ_PER_KHZ)struct module ;struct property_entry ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 1/40 i2c: qup: Move bus frequency definitions to i2c.h
Move bus frequency definitions to i2c.h for wider use.
--- drivers/i2c/busses/i2c-qup.c | 9 ++------- include/linux/i2c.h | 7 +++++++ 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-qup.c +2 -7
@@ -136,13 +136,8 @@*/ #define TOUT_MIN 2 -/* I2C Frequency Modes */ -#define I2C_STANDARD_FREQ 100000 -#define I2C_FAST_MODE_FREQ 400000 -#define I2C_FAST_MODE_PLUS_FREQ 1000000 -/* Default values. Use these if FW query fails */ -#define DEFAULT_CLK_FREQ I2C_STANDARD_FREQ +#define DEFAULT_CLK_FREQ I2C_STANDARD_MODE_FREQ#define DEFAULT_SRC_CLK 20000000/*
@@ -1861,7 +1856,7 @@ static int qup_i2c_probe(struct platform_device *pdev) qup->in_fifo_sz = qup->in_blk_sz * (2 << size); hs_div =3 ; -if (clk_freq <=I2C_STANDARD_FREQ ) { +if (clk_freq <=I2C_STANDARD_MODE_FREQ ) { fs_div = ((src_clk_freq / clk_freq) /2 ) -3 ; qup->clk_ctl = (hs_div <<8 ) | (fs_div &0xff ); }else {
include/linux/i2c.h +7 -0
@@ -39,6 +39,13 @@ enum i2c_slave_event;typedef int (*i2c_slave_cb_t )(struct i2c_client *client,enum i2c_slave_event event,u8 *val); +#define HZ_PER_KHZ 1000 + +/* I2C Frequency Modes */ +#define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ) +#define I2C_FAST_MODE_FREQ (400 * HZ_PER_KHZ) +#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ) +struct module ;struct property_entry ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 10/40 i2c: cadence: Use generic definitions for bus frequencies
Since we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-cadence.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-cadence.c +2 -5
@@ -104,9 +104,6 @@#define DRIVER_NAME "cdns-i2c" -#define CDNS_I2C_SPEED_MAX 400000 -#define CDNS_I2C_SPEED_DEFAULT 100000 -#define CDNS_I2C_DIVA_MAX 4#define CDNS_I2C_DIVB_MAX 64
@@ -949,8 +946,8 @@ static int cdns_i2c_probe(struct platform_device *pdev) ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &id->i2c_clk); -if (ret || (id->i2c_clk >CDNS_I2C_SPEED_MAX )) - id->i2c_clk =CDNS_I2C_SPEED_DEFAULT ; +if (ret || (id->i2c_clk >I2C_FAST_MODE_FREQ )) + id->i2c_clk =I2C_STANDARD_MODE_FREQ ;cdns_i2c_writereg (CDNS_I2C_CR_ACK_EN |CDNS_I2C_CR_NEA |CDNS_I2C_CR_MS ,CDNS_I2C_CR_OFFSET );
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 6/40 i2c: aspeed: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-aspeed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-aspeed.c +1 -1
@@ -997,7 +997,7 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)if (ret <0 ) {dev_err (&pdev->dev,"Could not read bus-frequency property\n" ); - bus->bus_frequency =100000 ; + bus->bus_frequency =I2C_STANDARD_MODE_FREQ ; } match =of_match_node (aspeed_i2c_bus_of_table, pdev->dev.of_node);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 9/40 i2c: bcm-kona: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-bcm-kona.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-bcm-kona.c +4 -4
@@ -722,16 +722,16 @@ static int bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev) }switch (bus_speed) { -case 100000 : +case I2C_STANDARD_MODE_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_100K ];break ; -case 400000 : +case I2C_FAST_MODE_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_400K ];break ; -case 1000000 : +case I2C_FAST_MODE_PLUS_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ ];break ; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ :/* Send mastercode at 100k */ dev->std_cfg = &std_cfg_table[BCM_SPD_100K ]; dev->hs_cfg = &hs_cfg_table[BCM_SPD_3P4MHZ ];
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 11/40 i2c: designware: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-designware-platdrv.c | 37 ++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +22 -15
@@ -99,16 +99,16 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)dw_i2c_acpi_params (pdev,"FMCN" , &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht);switch (t->bus_freq_hz) { -case 100000 : +case I2C_STANDARD_MODE_FREQ : dev->sda_hold_time = ss_ht;break ; -case 1000000 : +case I2C_FAST_MODE_PLUS_FREQ : dev->sda_hold_time = fp_ht;break ; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ : dev->sda_hold_time = hs_ht;break ; -case 400000 : +case I2C_FAST_MODE_FREQ :default : dev->sda_hold_time = fs_ht;break ;
@@ -198,10 +198,10 @@ static void i2c_dw_configure_master(struct dw_i2c_dev *dev) dev->mode =DW_IC_MASTER ;switch (t->bus_freq_hz) { -case 100000 : +case I2C_STANDARD_MODE_FREQ : dev->master_cfg |=DW_IC_CON_SPEED_STD ;break ; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ : dev->master_cfg |=DW_IC_CON_SPEED_HIGH ;break ;default :
@@ -249,6 +249,13 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)pm_runtime_put_noidle (dev->dev); } +static const u32 supported_speeds[] = { +I2C_HIGH_SPEED_MODE_FREQ , +I2C_FAST_MODE_PLUS_FREQ , +I2C_FAST_MODE_FREQ , +I2C_STANDARD_MODE_FREQ , +}; +static int dw_i2c_plat_probe (struct platform_device *pdev) {struct dw_i2c_platform_data *pdata =dev_get_platdata (&pdev->dev);
@@ -258,9 +265,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)u32 acpi_speed;struct resource *mem;int i, irq, ret; -static const int supported_speeds[] = { -0 ,100000 ,400000 ,1000000 ,3400000 - }; irq =platform_get_irq (pdev,0 );if (irq <0 )
@@ -296,11 +300,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)* Some DSTDs use a non standard speed, round down to the lowest * standard speed. */ -for (i =1 ; i <ARRAY_SIZE (supported_speeds); i++) { -if (acpi_speed < supported_speeds[i]) +for (i =0 ; i <ARRAY_SIZE (supported_speeds); i++) { +if (acpi_speed >= supported_speeds[i])break ; } - acpi_speed = supported_speeds[i -1 ]; + acpi_speed = i <ARRAY_SIZE (supported_speeds) ? supported_speeds[i] :0 ;/* * Find bus speed from the "clock-frequency" device property, ACPI
@@ -311,7 +315,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)else if (acpi_speed || t->bus_freq_hz) t->bus_freq_hz =max (t->bus_freq_hz, acpi_speed);else - t->bus_freq_hz =400000 ; + t->bus_freq_hz =I2C_FAST_MODE_FREQ ; dev->flags |= (uintptr_t )device_get_match_data (&pdev->dev);
@@ -325,8 +329,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)* Only standard mode at 100kHz, fast mode at 400kHz, * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported. */ -if (t->bus_freq_hz !=100000 && t->bus_freq_hz !=400000 && - t->bus_freq_hz !=1000000 && t->bus_freq_hz !=3400000 ) { +for (i =0 ; i <ARRAY_SIZE (supported_speeds); i++) { +if (t->bus_freq_hz == supported_speeds[i]) +break ; + } +if (i ==ARRAY_SIZE (supported_speeds)) {dev_err (&pdev->dev,"%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n" , t->bus_freq_hz);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 12/40 i2c: digicolor: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-digicolor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-digicolor.c +1 -2
@@ -18,7 +18,6 @@#include <linux/of.h> #include <linux/platform_device.h> -#define DEFAULT_FREQ 100000#define TIMEOUT_MS 100#define II_CONTROL 0x0
@@ -300,7 +299,7 @@ static int dc_i2c_probe(struct platform_device *pdev)if (of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &i2c->frequency)) - i2c->frequency =DEFAULT_FREQ ; + i2c->frequency =I2C_STANDARD_MODE_FREQ ; i2c->dev = &pdev->dev;platform_set_drvdata (pdev, i2c);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 14/40 i2c: exynos5: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-exynos5.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-exynos5.c +7 -11
@@ -164,13 +164,6 @@#define HSI2C_MASTER_ID (x) ((x & 0xff) << 24)#define MASTER_ID (x) ((x & 0x7) + 0x08) -/* -* Controller operating frequency, timing values for operation -* are calculated against this frequency -*/ -#define HSI2C_HS_TX_CLOCK 1000000 -#define HSI2C_FS_TX_CLOCK 100000 -#define EXYNOS5_I2C_TIMEOUT (msecs_to_jiffies(100))enum i2c_type_exynos {
@@ -264,6 +257,9 @@ static void exynos5_i2c_clr_pend_irq(struct exynos5_i2c *i2c)* exynos5_i2c_set_timing: updates the registers with appropriate * timing values calculated * +* Controller operating frequency, timing values for operation +* are calculated against either 100kHz or 1MHz frequency. +* * Returns 0 on success, -EINVAL if the cycle length cannot * be calculated. */
@@ -281,7 +277,7 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, bool hs_timings)unsigned int t_ftl_cycle;unsigned int clkin =clk_get_rate (i2c->clk);unsigned int op_clk = hs_timings ? i2c->op_clock : - (i2c->op_clock >=HSI2C_HS_TX_CLOCK ) ?HSI2C_FS_TX_CLOCK : + (i2c->op_clock >=I2C_FAST_MODE_PLUS_FREQ ) ?I2C_STANDARD_MODE_FREQ : i2c->op_clock;int div, clk_cycle, temp;
@@ -353,7 +349,7 @@ static int exynos5_hsi2c_clock_setup(struct exynos5_i2c *i2c)/* always set Fast Speed timings */ int ret =exynos5_i2c_set_timing (i2c, false); -if (ret <0 || i2c->op_clock <HSI2C_HS_TX_CLOCK ) +if (ret <0 || i2c->op_clock <I2C_FAST_MODE_PLUS_FREQ )return ret;return exynos5_i2c_set_timing (i2c, true);
@@ -376,7 +372,7 @@ static void exynos5_i2c_init(struct exynos5_i2c *i2c) i2c->regs + HSI2C_CTL);writel (HSI2C_TRAILING_COUNT , i2c->regs +HSI2C_TRAILIG_CTL ); -if (i2c->op_clock >=HSI2C_HS_TX_CLOCK ) { +if (i2c->op_clock >=I2C_FAST_MODE_PLUS_FREQ ) {writel (HSI2C_MASTER_ID (MASTER_ID (i2c->adap.nr)), i2c->regs +HSI2C_ADDR ); i2c_conf |=HSI2C_HS_MODE ;
@@ -748,7 +744,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)return -ENOMEM ;if (of_property_read_u32 (np,"clock-frequency" , &i2c->op_clock)) - i2c->op_clock =HSI2C_FS_TX_CLOCK ; + i2c->op_clock =I2C_STANDARD_MODE_FREQ ;strlcpy (i2c->adap.name,"exynos5-i2c" ,sizeof (i2c->adap.name)); i2c->adap.owner =THIS_MODULE ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 16/40 i2c: img-scb: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-img-scb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-img-scb.c +2 -2
@@ -304,7 +304,7 @@ static struct img_i2c_timings timings[] = {/* Standard mode */ { .name = "standard", - .max_bitrate = 100000, + .max_bitrate = I2C_STANDARD_MODE_FREQ, .tckh = 4000, .tckl = 4700, .tsdh = 4700,
@@ -316,7 +316,7 @@ static struct img_i2c_timings timings[] = {/* Fast mode */ { .name = "fast", - .max_bitrate = 400000, + .max_bitrate = I2C_FAST_MODE_FREQ, .tckh = 600, .tckl = 1300, .tsdh = 600,
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 20/40 i2c: mt65xx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-mt65xx.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/i2c/busses/i2c-mt65xx.c +9 -12
@@ -56,9 +56,6 @@#define I2C_DMA_4G_MODE 0x0001#define I2C_DEFAULT_CLK_DIV 5 -#define I2C_DEFAULT_SPEED 100000/* hz */ -#define MAX_FS_MODE_SPEED 400000 -#define MAX_HS_MODE_SPEED 3400000#define MAX_SAMPLE_CNT_DIV 8#define MAX_STEP_CNT_DIV 64#define MAX_HS_STEP_CNT_DIV 8
@@ -450,10 +447,10 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,unsigned int best_mul;unsigned int cnt_mul; -if (target_speed >MAX_HS_MODE_SPEED ) - target_speed =MAX_HS_MODE_SPEED ; +if (target_speed >I2C_FAST_MODE_PLUS_FREQ ) + target_speed =I2C_FAST_MODE_PLUS_FREQ ; -if (target_speed >MAX_FS_MODE_SPEED ) +if (target_speed >I2C_FAST_MODE_FREQ ) max_step_cnt =MAX_HS_STEP_CNT_DIV ;else max_step_cnt =MAX_STEP_CNT_DIV ;
@@ -514,9 +511,9 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk) clk_src = parent_clk / i2c->clk_src_div; target_speed = i2c->speed_hz; -if (target_speed >MAX_FS_MODE_SPEED ) { +if (target_speed >I2C_FAST_MODE_FREQ ) {/* Set master code speed register */ - ret =mtk_i2c_calculate_speed (i2c, clk_src,MAX_FS_MODE_SPEED , + ret =mtk_i2c_calculate_speed (i2c, clk_src,I2C_FAST_MODE_FREQ , &l_step_cnt, &l_sample_cnt);if (ret <0 )return ret;
@@ -581,7 +578,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, control_reg =mtk_i2c_readw (i2c,OFFSET_CONTROL ) & ~(I2C_CONTROL_DIR_CHANGE |I2C_CONTROL_RS ); -if ((i2c->speed_hz >MAX_FS_MODE_SPEED ) || (left_num >=1 )) +if ((i2c->speed_hz >I2C_FAST_MODE_FREQ ) || (left_num >=1 )) control_reg |=I2C_CONTROL_RS ;if (i2c->op ==I2C_MASTER_WRRD )
@@ -590,7 +587,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,mtk_i2c_writew (i2c, control_reg,OFFSET_CONTROL );/* set start condition */ -if (i2c->speed_hz <=I2C_DEFAULT_SPEED ) +if (i2c->speed_hz <=I2C_STANDARD_MODE_FREQ )mtk_i2c_writew (i2c,I2C_ST_START_CON ,OFFSET_EXT_CONF );else mtk_i2c_writew (i2c,I2C_FS_START_CON ,OFFSET_EXT_CONF );
@@ -798,7 +795,7 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap, } } -if (i2c->auto_restart && num >=2 && i2c->speed_hz >MAX_FS_MODE_SPEED ) +if (i2c->auto_restart && num >=2 && i2c->speed_hz >I2C_FAST_MODE_FREQ )/* ignore the first restart irq after the master code, * otherwise the first transfer will be discarded. */
@@ -893,7 +890,7 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c) ret =of_property_read_u32 (np,"clock-frequency" , &i2c->speed_hz);if (ret <0 ) - i2c->speed_hz =I2C_DEFAULT_SPEED ; + i2c->speed_hz =I2C_STANDARD_MODE_FREQ ; ret =of_property_read_u32 (np,"clock-div" , &i2c->clk_src_div);if (ret <0 )
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 18/40 i2c: imx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-imx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +1 -4
@@ -49,9 +49,6 @@/* This will be the driver name the kernel reports */ #define DRIVER_NAME "imx-i2c" -/* Default value */ -#define IMX_I2C_BIT_RATE 100000/* 100kHz */ -/* * Enable DMA if transfer byte size is bigger than this threshold. * As the hardware request, it must bigger than 4 bytes.\
@@ -1139,7 +1136,7 @@ static int i2c_imx_probe(struct platform_device *pdev) goto rpm_disable;/* Set up clock divider */ - i2c_imx->bitrate =IMX_I2C_BIT_RATE ; + i2c_imx->bitrate =I2C_STANDARD_MODE_FREQ ; ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &i2c_imx->bitrate);if (ret <0 && pdata && pdata->bitrate)
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 19/40 i2c: lpc2k: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-lpc2k.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-lpc2k.c +3 -3
@@ -396,7 +396,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev) ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &bus_clk_rate);if (ret) - bus_clk_rate =100000 ;/* 100 kHz default clock rate */ + bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* 100 kHz default clock rate */ clkrate =clk_get_rate (i2c->clk);if (clkrate ==0 ) {
@@ -407,9 +407,9 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)/* Setup I2C dividers to generate clock with proper duty cycle */ clkrate = clkrate / bus_clk_rate; -if (bus_clk_rate <=100000 ) +if (bus_clk_rate <=I2C_STANDARD_MODE_FREQ ) scl_high = (clkrate *I2C_STD_MODE_DUTY ) /100 ; -else if (bus_clk_rate <=400000 ) +else if (bus_clk_rate <=I2C_FAST_MODE_FREQ ) scl_high = (clkrate *I2C_FAST_MODE_DUTY ) /100 ;else scl_high = (clkrate *I2C_FAST_MODE_PLUS_DUTY ) /100 ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 21/40 i2c: mv64xxx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-mv64xxx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-mv64xxx.c +3 -3
@@ -810,7 +810,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, tclk =clk_get_rate (drv_data->clk);if (of_property_read_u32 (np,"clock-frequency" , &bus_freq)) - bus_freq =100000 ;/* 100kHz by default */ + bus_freq =I2C_STANDARD_MODE_FREQ ;/* 100kHz by default */ if (of_device_is_compatible (np,"allwinner,sun4i-a10-i2c" ) ||of_device_is_compatible (np,"allwinner,sun6i-a31-i2c" ))
@@ -846,14 +846,14 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,if (of_device_is_compatible (np,"marvell,mv78230-i2c" )) { drv_data->offload_enabled = true;/* The delay is only needed in standard mode (100kHz) */ -if (bus_freq <=100000 ) +if (bus_freq <=I2C_STANDARD_MODE_FREQ ) drv_data->errata_delay = true; }if (of_device_is_compatible (np,"marvell,mv78230-a0-i2c" )) { drv_data->offload_enabled = false;/* The delay is only needed in standard mode (100kHz) */ -if (bus_freq <=100000 ) +if (bus_freq <=I2C_STANDARD_MODE_FREQ ) drv_data->errata_delay = true; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 22/40 i2c: mxs: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-mxs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-mxs.c +6 -6
@@ -731,18 +731,18 @@ static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, uint32_t speed)* This is compensated for by subtracting the respective constants * from the values written to the timing registers. */ -if (speed >100000 ) { +if (speed >I2C_STANDARD_MODE_FREQ ) {/* fast mode */ low_count =DIV_ROUND_CLOSEST (divider *13 , (13 +6 )); high_count =DIV_ROUND_CLOSEST (divider *6 , (13 +6 )); - leadin =DIV_ROUND_UP (600 * (clk /1000000 ),1000 ); - bus_free =DIV_ROUND_UP (1300 * (clk /1000000 ),1000 ); + leadin =DIV_ROUND_UP (600 * (clk /HZ_PER_MHZ ),1000 ); + bus_free =DIV_ROUND_UP (1300 * (clk /HZ_PER_MHZ ),1000 ); }else {/* normal mode */ low_count =DIV_ROUND_CLOSEST (divider *47 , (47 +40 )); high_count =DIV_ROUND_CLOSEST (divider *40 , (47 +40 )); - leadin =DIV_ROUND_UP (4700 * (clk /1000000 ),1000 ); - bus_free =DIV_ROUND_UP (4700 * (clk /1000000 ),1000 ); + leadin =DIV_ROUND_UP (4700 * (clk /HZ_PER_MHZ ),1000 ); + bus_free =DIV_ROUND_UP (4700 * (clk /HZ_PER_MHZ ),1000 ); } rcv_count = high_count *3 /8 ; xmit_count = low_count *3 /8 ;
@@ -769,7 +769,7 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c) ret =of_property_read_u32 (node,"clock-frequency" , &speed);if (ret) {dev_warn (dev,"No I2C speed selected, using 100kHz\n" ); - speed =100000 ; + speed =I2C_STANDARD_MODE_FREQ ; }mxs_i2c_derive_timing (i2c, speed);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 24/40 i2c: owl: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-owl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-owl.c +3 -6
@@ -87,9 +87,6 @@#define OWL_I2C_MAX_RETRIES 50 -#define OWL_I2C_DEF_SPEED_HZ 100000 -#define OWL_I2C_MAX_SPEED_HZ 400000 -struct owl_i2c_dev {struct i2c_adapter adap;struct i2c_msg *msg;
@@ -419,11 +416,11 @@ static int owl_i2c_probe(struct platform_device *pdev)if (of_property_read_u32 (dev->of_node,"clock-frequency" , &i2c_dev->bus_freq)) - i2c_dev->bus_freq =OWL_I2C_DEF_SPEED_HZ ; + i2c_dev->bus_freq =I2C_STANDARD_MODE_FREQ ;/* We support only frequencies of 100k and 400k for now */ -if (i2c_dev->bus_freq !=OWL_I2C_DEF_SPEED_HZ && - i2c_dev->bus_freq !=OWL_I2C_MAX_SPEED_HZ ) { +if (i2c_dev->bus_freq !=I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_freq !=I2C_FAST_MODE_FREQ ) {dev_err (dev,"invalid clock-frequency %d\n" , i2c_dev->bus_freq);return -EINVAL ; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 25/40 i2c: rcar: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-rcar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-rcar.c +1 -1
@@ -242,7 +242,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timinstruct device *dev =rcar_i2c_priv_to_dev (priv);/* Fall back to previously used values if not supplied */ - t->bus_freq_hz = t->bus_freq_hz ?:100000 ; + t->bus_freq_hz = t->bus_freq_hz ?:I2C_STANDARD_MODE_FREQ ; t->scl_fall_ns = t->scl_fall_ns ?:35 ; t->scl_rise_ns = t->scl_rise_ns ?:200 ; t->scl_int_delay_ns = t->scl_int_delay_ns ?:50 ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 28/40 i2c: s3c2410: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-s3c2410.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-s3c2410.c +3 -3
@@ -835,13 +835,13 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)int freq; i2c->clkrate = clkin; - clkin /=1000 ;/* clkin now in KHz */ + clkin /=HZ_PER_KHZ ;/* clkin now in KHz */ dev_dbg (i2c->dev,"pdata desired frequency %lu\n" , pdata->frequency); - target_frequency = pdata->frequency ? pdata->frequency :100000 ; + target_frequency = pdata->frequency ?:I2C_STANDARD_MODE_FREQ ; - target_frequency /=1000 ;/* Target frequency now in KHz */ + target_frequency /=HZ_PER_KHZ ;/* Target frequency now in KHz */ freq =s3c24xx_i2c_calcdivisor (clkin, target_frequency, &div1, &divs);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 29/40 i2c: sh_mobile: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-sh_mobile.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-sh_mobile.c +3 -6
@@ -145,9 +145,6 @@ struct sh_mobile_dt_config {#define IIC_FLAG_HAS_ICIC67 (1 << 0) -#define STANDARD_MODE 100000 -#define FAST_MODE 400000 -/* Register offsets */ #define ICDR 0x00#define ICCR 0x04
@@ -270,11 +267,11 @@ static int sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd) i2c_clk_khz =clk_get_rate (pd->clk) /1000 / pd->clks_per_count; -if (pd->bus_speed ==STANDARD_MODE ) { +if (pd->bus_speed ==I2C_STANDARD_MODE_FREQ ) { tLOW =47 ;/* tLOW = 4.7 us */ tHIGH =40 ;/* tHD;STA = tHIGH = 4.0 us */ tf =3 ;/* tf = 0.3 us */ - }else if (pd->bus_speed ==FAST_MODE ) { + }else if (pd->bus_speed ==I2C_FAST_MODE_FREQ ) { tLOW =13 ;/* tLOW = 1.3 us */ tHIGH =6 ;/* tHD;STA = tHIGH = 0.6 us */ tf =3 ;/* tf = 0.3 us */
@@ -851,7 +848,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)return PTR_ERR (pd->reg); ret =of_property_read_u32 (dev->dev.of_node,"clock-frequency" , &bus_speed); - pd->bus_speed = (ret || !bus_speed) ?STANDARD_MODE : bus_speed; + pd->bus_speed = (ret || !bus_speed) ?I2C_STANDARD_MODE_FREQ : bus_speed; pd->clks_per_count =1 ;/* Newer variants come with two new bits in ICIC */
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 33/40 i2c: stm32f7: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-stm32f7.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +12 -12
@@ -334,9 +334,9 @@ struct stm32f7_i2c_dev {*/ static struct stm32f7_i2c_spec i2c_specs[] = { [STM32_I2C_SPEED_STANDARD ] = { - .rate =100000 , - .rate_min =80000 , - .rate_max =100000 , + .rate =I2C_STANDARD_MODE_FREQ , + .rate_min =I2C_STANDARD_MODE_FREQ *8 /10 ,/* 80% */ + .rate_max =I2C_STANDARD_MODE_FREQ , .fall_max =300 , .rise_max =1000 , .hddat_min =0 ,
@@ -346,9 +346,9 @@ static struct stm32f7_i2c_spec i2c_specs[] = { .h_min = 4000, }, [STM32_I2C_SPEED_FAST] = { - .rate = 400000, - .rate_min = 320000, - .rate_max = 400000, + .rate = I2C_FAST_MODE_FREQ, + .rate_min = I2C_FAST_MODE_FREQ * 8 / 10, /* 80% */ + .rate_max = I2C_FAST_MODE_FREQ, .fall_max = 300, .rise_max = 300, .hddat_min = 0,
@@ -358,9 +358,9 @@ static struct stm32f7_i2c_spec i2c_specs[] = { .h_min = 600, }, [STM32_I2C_SPEED_FAST_PLUS] = { - .rate = 1000000, - .rate_min = 800000, - .rate_max = 1000000, + .rate = I2C_FAST_MODE_PLUS_FREQ, + .rate_min = I2C_FAST_MODE_PLUS_FREQ * 8 / 10, /* 80% */ + .rate_max = I2C_FAST_MODE_PLUS_FREQ, .fall_max = 100, .rise_max = 120, .hddat_min = 0,
@@ -1894,14 +1894,14 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; ret =device_property_read_u32 (&pdev->dev,"clock-frequency" , &clk_rate); -if (!ret && clk_rate >=1000000 ) { +if (!ret && clk_rate >=I2C_FAST_MODE_PLUS_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_FAST_PLUS ; ret =stm32f7_i2c_setup_fm_plus_bits (pdev, i2c_dev);if (ret) goto clk_free; - }else if (!ret && clk_rate >=400000 ) { + }else if (!ret && clk_rate >=I2C_FAST_MODE_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_FAST ; - }else if (!ret && clk_rate >=100000 ) { + }else if (!ret && clk_rate >=I2C_STANDARD_MODE_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 34/40 i2c: stu300: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-stu300.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-stu300.c +3 -3
@@ -132,7 +132,7 @@ enum stu300_error {#define NUM_ADDR_RESEND_ATTEMPTS 12/* I2C clock speed, in Hz 0-400kHz*/ -static unsigned int scl_frequency =100000 ; +static unsigned int scl_frequency =I2C_STANDARD_MODE_FREQ ;module_param (scl_frequency, uint,0644 );/**
@@ -497,7 +497,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)dev_dbg (&dev->pdev->dev,"Clock rate %lu Hz, I2C bus speed %d Hz " "virtbase %p\n" , clkrate, dev->speed, dev->virtbase); -if (dev->speed >100000 ) +if (dev->speed >I2C_STANDARD_MODE_FREQ )/* Fast Mode I2C */ val = ((clkrate/dev->speed) -9 )/3 +1 ;else
@@ -518,7 +518,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)return -EINVAL ; } -if (dev->speed >100000 ) { +if (dev->speed >I2C_STANDARD_MODE_FREQ ) {/* CC6..CC0 */ stu300_wr8 ((val &I2C_CCR_CC_MASK ) |I2C_CCR_FMSM , dev->virtbase +I2C_CCR );
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 17/40 i2c: imx-lpi2c: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-imx-lpi2c.c | 16 +++++----------- include/linux/i2c.h | 1 + 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-imx-lpi2c.c +5 -11
@@ -75,12 +75,6 @@#define I2C_CLK_RATIO 2#define CHUNK_DATA 256 -#define LPI2C_DEFAULT_RATE 100000 -#define STARDARD_MAX_BITRATE 400000 -#define FAST_MAX_BITRATE 1000000 -#define FAST_PLUS_MAX_BITRATE 3400000 -#define HIGHSPEED_MAX_BITRATE 5000000 -#define I2C_PM_TIMEOUT 10/* ms */ enum lpi2c_imx_mode {
@@ -152,13 +146,13 @@ static void lpi2c_imx_set_mode(struct lpi2c_imx_struct *lpi2c_imx)unsigned int bitrate = lpi2c_imx->bitrate;enum lpi2c_imx_mode mode; -if (bitrate <STARDARD_MAX_BITRATE ) +if (bitrate <I2C_FAST_MODE_FREQ ) mode =STANDARD ; -else if (bitrate <FAST_MAX_BITRATE ) +else if (bitrate <I2C_FAST_MODE_PLUS_FREQ ) mode =FAST ; -else if (bitrate <FAST_PLUS_MAX_BITRATE ) +else if (bitrate <I2C_HIGH_SPEED_MODE_FREQ ) mode =FAST_PLUS ; -else if (bitrate <HIGHSPEED_MAX_BITRATE ) +else if (bitrate <I2C_ULTRA_SPEED_MODE_FREQ ) mode =HS ;else mode =ULTRA_FAST ;
@@ -578,7 +572,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev) ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &lpi2c_imx->bitrate);if (ret) - lpi2c_imx->bitrate =LPI2C_DEFAULT_RATE ; + lpi2c_imx->bitrate =I2C_STANDARD_MODE_FREQ ; ret =devm_request_irq (&pdev->dev, irq, lpi2c_imx_isr,0 , pdev->name, lpi2c_imx);
include/linux/i2c.h +1 -0
@@ -48,6 +48,7 @@ typedef int (*i2c_slave_cb_t)(struct i2c_client *client,#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ)#define I2C_TURBO_MODE_FREQ (1400 * HZ_PER_KHZ)#define I2C_HIGH_SPEED_MODE_FREQ (3400 * HZ_PER_KHZ) +#define I2C_ULTRA_SPEED_MODE_FREQ (5000 * HZ_PER_KHZ)struct module ;struct property_entry ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 31/40 i2c: spdr: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-sprd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-sprd.c +5 -4
@@ -337,9 +337,9 @@ static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)writel (div1, i2c_dev->base +ADDR_DVD1 );/* Start hold timing = hold time(us) * source clock */ -if (freq ==400000 ) +if (freq ==I2C_FAST_MODE_FREQ )writel ((6 * apb_clk) /10000000 , i2c_dev->base +ADDR_STA0_DVD ); -else if (freq ==100000 ) +else if (freq ==I2C_STANDARD_MODE_FREQ )writel ((4 * apb_clk) /1000000 , i2c_dev->base +ADDR_STA0_DVD ); }
@@ -502,7 +502,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)snprintf (i2c_dev->adap.name,sizeof (i2c_dev->adap.name),"%s" ,"sprd-i2c" ); - i2c_dev->bus_freq =100000 ; + i2c_dev->bus_freq =I2C_STANDARD_MODE_FREQ ; i2c_dev->adap.owner =THIS_MODULE ; i2c_dev->dev = dev; i2c_dev->adap.retries =3 ;
@@ -516,7 +516,8 @@ static int sprd_i2c_probe(struct platform_device *pdev) i2c_dev->bus_freq = prop;/* We only support 100k and 400k now, otherwise will return error. */ -if (i2c_dev->bus_freq !=100000 && i2c_dev->bus_freq !=400000 ) +if (i2c_dev->bus_freq !=I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_freq !=I2C_FAST_MODE_FREQ )return -EINVAL ; ret =sprd_i2c_clk_init (i2c_dev);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 35/40 i2c: st: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-st.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-st.c +3 -3
@@ -213,7 +213,7 @@ static inline void st_i2c_clr_bits(void __iomem *reg, u32 mask)*/ static struct st_i2c_timings i2c_timings[] = { [I2C_MODE_STANDARD ] = { - .rate =100000 , + .rate =I2C_STANDARD_MODE_FREQ , .rep_start_hold =4400 , .rep_start_setup =5170 , .start_hold =4400 ,
@@ -222,7 +222,7 @@ static struct st_i2c_timings i2c_timings[] = { .bus_free_time = 5170, }, [I2C_MODE_FAST] = { - .rate = 400000, + .rate = I2C_FAST_MODE_FREQ, .rep_start_hold = 660, .rep_start_setup = 660, .start_hold = 660,
@@ -835,7 +835,7 @@ static int st_i2c_probe(struct platform_device *pdev) i2c_dev->mode =I2C_MODE_STANDARD ; ret =of_property_read_u32 (np,"clock-frequency" , &clk_rate); -if ((!ret) && (clk_rate ==400000 )) +if (!ret && (clk_rate ==I2C_FAST_MODE_FREQ )) i2c_dev->mode =I2C_MODE_FAST ; i2c_dev->dev = &pdev->dev;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 37/40 i2c: tegra: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-tegra.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/i2c/busses/i2c-tegra.c +7 -11
@@ -123,10 +123,6 @@#define I2C_THIGH_SHIFT 8#define I2C_INTERFACE_TIMING_1 0x98 -#define I2C_STANDARD_MODE 100000 -#define I2C_FAST_MODE 400000 -#define I2C_FAST_PLUS_MODE 1000000 -/* Packet header size in bytes */ #define I2C_PACKET_HEADER_SIZE 12
@@ -737,8 +733,8 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit)I2C_CLK_DIVISOR_STD_FAST_MODE_SHIFT ;i2c_writel (i2c_dev, clk_divisor,I2C_CLK_DIVISOR ); -if (i2c_dev->bus_clk_rate >I2C_STANDARD_MODE && - i2c_dev->bus_clk_rate <=I2C_FAST_PLUS_MODE ) { +if (i2c_dev->bus_clk_rate >I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_clk_rate <=I2C_FAST_MODE_PLUS_FREQ ) { tlow = i2c_dev->hw->tlow_fast_fastplus_mode; thigh = i2c_dev->hw->thigh_fast_fastplus_mode; tsu_thd = i2c_dev->hw->setup_hold_time_fast_fast_plus_mode;
@@ -1341,7 +1337,7 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev) ret =of_property_read_u32 (np,"clock-frequency" , &i2c_dev->bus_clk_rate);if (ret) - i2c_dev->bus_clk_rate =100000 ;/* default clock rate */ + i2c_dev->bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* default clock rate */ multi_mode =of_property_read_bool (np,"multi-master" ); i2c_dev->is_multimaster_mode = multi_mode;
@@ -1640,12 +1636,12 @@ static int tegra_i2c_probe(struct platform_device *pdev) } } -if (i2c_dev->bus_clk_rate >I2C_FAST_MODE && - i2c_dev->bus_clk_rate <=I2C_FAST_PLUS_MODE ) +if (i2c_dev->bus_clk_rate >I2C_FAST_MODE_FREQ && + i2c_dev->bus_clk_rate <=I2C_FAST_MODE_PLUS_FREQ ) i2c_dev->clk_divisor_non_hs_mode = i2c_dev->hw->clk_divisor_fast_plus_mode; -else if (i2c_dev->bus_clk_rate >I2C_STANDARD_MODE && - i2c_dev->bus_clk_rate <=I2C_FAST_MODE ) +else if (i2c_dev->bus_clk_rate >I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_clk_rate <=I2C_FAST_MODE_FREQ ) i2c_dev->clk_divisor_non_hs_mode = i2c_dev->hw->clk_divisor_fast_mode;else
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 38/40 i2c: uniphier-f: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-uniphier-f.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-uniphier-f.c +2 -4
@@ -73,8 +73,6 @@#define UNIPHIER_FI2C_BYTE_WISE BIT(3)#define UNIPHIER_FI2C_DEFER_STOP_COMP BIT(4) -#define UNIPHIER_FI2C_DEFAULT_SPEED 100000 -#define UNIPHIER_FI2C_MAX_SPEED 400000#define UNIPHIER_FI2C_FIFO_SIZE 8struct uniphier_fi2c_priv {
@@ -537,9 +535,9 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) }if (of_property_read_u32 (dev->of_node,"clock-frequency" , &bus_speed)) - bus_speed =UNIPHIER_FI2C_DEFAULT_SPEED ; + bus_speed =I2C_STANDARD_MODE_FREQ ; -if (!bus_speed || bus_speed >UNIPHIER_FI2C_MAX_SPEED ) { +if (!bus_speed || bus_speed >I2C_FAST_MODE_FREQ ) {dev_err (dev,"invalid clock-frequency %d\n" , bus_speed);return -EINVAL ; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 40/40 i2c: xlp9xx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-xlp9xx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-xlp9xx.c +3 -5
@@ -71,8 +71,6 @@#define XLP9XX_I2C_SLAVEADDR_ADDR_SHIFT 1#define XLP9XX_I2C_IP_CLK_FREQ 133000000UL -#define XLP9XX_I2C_DEFAULT_FREQ 100000 -#define XLP9XX_I2C_HIGH_FREQ 400000#define XLP9XX_I2C_FIFO_SIZE 0x80U#define XLP9XX_I2C_TIMEOUT_MS 1000#define XLP9XX_I2C_BUSY_TIMEOUT 50
@@ -476,12 +474,12 @@ static int xlp9xx_i2c_get_frequency(struct platform_device *pdev, err =device_property_read_u32 (&pdev->dev,"clock-frequency" , &freq);if (err) { - freq =XLP9XX_I2C_DEFAULT_FREQ ; + freq =I2C_STANDARD_MODE_FREQ ;dev_dbg (&pdev->dev,"using default frequency %u\n" , freq); - }else if (freq ==0 || freq >XLP9XX_I2C_HIGH_FREQ ) { + }else if (freq ==0 || freq >I2C_FAST_MODE_FREQ ) {dev_warn (&pdev->dev,"invalid frequency %u, using default\n" , freq); - freq =XLP9XX_I2C_DEFAULT_FREQ ; + freq =I2C_STANDARD_MODE_FREQ ; } priv->clk_hz = freq;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 36/40 i2c: synquacer: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-synquacer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-synquacer.c +6 -6
@@ -67,10 +67,10 @@/* STANDARD MODE frequency */ #define SYNQUACER_I2C_CLK_MASTER_STD (rate) \ - DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2) + DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_STANDARD_MODE_FREQ) - 2, 2)/* FAST MODE frequency */ #define SYNQUACER_I2C_CLK_MASTER_FAST (rate) \ - DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3) + DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_FAST_MODE_FREQ) - 2) * 2, 3)/* (clkrate <= 18000000) */ /* calculate the value of CS bits in CCR register on standard mode */
@@ -111,11 +111,11 @@ & SYNQUACER_I2C_CSR_CS_MASK)/* min I2C clock frequency 14M */ -#define SYNQUACER_I2C_MIN_CLK_RATE (14 * 1000000) +#define SYNQUACER_I2C_MIN_CLK_RATE (14 * HZ_PER_MHZ)/* max I2C clock frequency 200M */ -#define SYNQUACER_I2C_MAX_CLK_RATE (200 * 1000000) +#define SYNQUACER_I2C_MAX_CLK_RATE (200 * HZ_PER_MHZ)/* I2C clock frequency 18M */ -#define SYNQUACER_I2C_CLK_RATE_18M (18 * 1000000) +#define SYNQUACER_I2C_CLK_RATE_18M (18 * HZ_PER_MHZ)#define SYNQUACER_I2C_SPEED_FM 400 // Fast Mode#define SYNQUACER_I2C_SPEED_SM 100 // Standard Mode
@@ -602,7 +602,7 @@ static int synquacer_i2c_probe(struct platform_device *pdev) i2c->adapter.nr = pdev->id;init_completion (&i2c->completion); -if (bus_speed <400000 ) +if (bus_speed <I2C_FAST_MODE_FREQ ) i2c->speed_khz =SYNQUACER_I2C_SPEED_SM ;else i2c->speed_khz =SYNQUACER_I2C_SPEED_FM ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 3/40 i2c: core: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/i2c-core-acpi.c | 2 +- drivers/i2c/i2c-core-base.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/i2c/i2c-core-acpi.c +1 -1
@@ -318,7 +318,7 @@ static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level, lookup->min_speed = lookup->speed;if (acpi_match_device_ids (adev, i2c_acpi_force_400khz_device_ids) ==0 ) - lookup->force_speed =400000 ; + lookup->force_speed =I2C_FAST_MODE_FREQ ;return AE_OK ; }
drivers/i2c/i2c-core-base.c +4 -4
@@ -1612,13 +1612,13 @@ void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_de ret =device_property_read_u32 (dev,"clock-frequency" , &t->bus_freq_hz);if (ret && use_defaults) - t->bus_freq_hz =100000 ; + t->bus_freq_hz =I2C_STANDARD_MODE_FREQ ; ret =device_property_read_u32 (dev,"i2c-scl-rising-time-ns" , &t->scl_rise_ns);if (ret && use_defaults) { -if (t->bus_freq_hz <=100000 ) +if (t->bus_freq_hz <=I2C_STANDARD_MODE_FREQ ) t->scl_rise_ns =1000 ; -else if (t->bus_freq_hz <=400000 ) +else if (t->bus_freq_hz <=I2C_FAST_MODE_FREQ ) t->scl_rise_ns =300 ;else t->scl_rise_ns =120 ;
@@ -1626,7 +1626,7 @@ void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_de ret =device_property_read_u32 (dev,"i2c-scl-falling-time-ns" , &t->scl_fall_ns);if (ret && use_defaults) { -if (t->bus_freq_hz <=400000 ) +if (t->bus_freq_hz <=I2C_FAST_MODE_FREQ ) t->scl_fall_ns =300 ;else t->scl_fall_ns =120 ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 8/40 i2c: bcm-iproc: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-bcm-iproc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-bcm-iproc.c +7 -7
@@ -858,25 +858,25 @@ static int bcm_iproc_i2c_cfg_speed(struct bcm_iproc_i2c_dev *iproc_i2c)if (ret <0 ) {dev_info (iproc_i2c->device,"unable to interpret clock-frequency DT property\n" ); - bus_speed =100000 ; + bus_speed =I2C_STANDARD_MODE_FREQ ; } -if (bus_speed <100000 ) { +if (bus_speed <I2C_STANDARD_MODE_FREQ ) {dev_err (iproc_i2c->device,"%d Hz bus speed not supported\n" , bus_speed);dev_err (iproc_i2c->device,"valid speeds are 100khz and 400khz\n" );return -EINVAL ; - }else if (bus_speed <400000 ) { - bus_speed =100000 ; + }else if (bus_speed <I2C_FAST_MODE_FREQ ) { + bus_speed =I2C_STANDARD_MODE_FREQ ; }else { - bus_speed =400000 ; + bus_speed =I2C_FAST_MODE_FREQ ; } iproc_i2c->bus_speed = bus_speed; val =iproc_i2c_rd_reg (iproc_i2c,TIM_CFG_OFFSET ); val &= ~BIT (TIM_CFG_MODE_400_SHIFT ); - val |= (bus_speed ==400000 ) <<TIM_CFG_MODE_400_SHIFT ; + val |= (bus_speed ==I2C_FAST_MODE_FREQ ) <<TIM_CFG_MODE_400_SHIFT ;iproc_i2c_wr_reg (iproc_i2c,TIM_CFG_OFFSET , val);dev_info (iproc_i2c->device,"bus set to %u Hz\n" , bus_speed);
@@ -1029,7 +1029,7 @@ static int bcm_iproc_i2c_resume(struct device *dev)/* configure to the desired bus speed */ val =iproc_i2c_rd_reg (iproc_i2c,TIM_CFG_OFFSET ); val &= ~BIT (TIM_CFG_MODE_400_SHIFT ); - val |= (iproc_i2c->bus_speed ==400000 ) <<TIM_CFG_MODE_400_SHIFT ; + val |= (iproc_i2c->bus_speed ==I2C_FAST_MODE_FREQ ) <<TIM_CFG_MODE_400_SHIFT ;iproc_i2c_wr_reg (iproc_i2c,TIM_CFG_OFFSET , val);bcm_iproc_i2c_enable_disable (iproc_i2c, true);
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 7/40 i2c: axxia: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-axxia.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-axxia.c +3 -3
@@ -176,7 +176,7 @@ static u32 ns_to_clk(u64 ns, u32 clk_mhz)static int axxia_i2c_init (struct axxia_i2c_dev *idev) {u32 divisor =clk_get_rate (idev->i2c_clk) / idev->bus_clk_rate; -u32 clk_mhz =clk_get_rate (idev->i2c_clk) /1000000 ; +u32 clk_mhz =clk_get_rate (idev->i2c_clk) /HZ_PER_MHZ ;u32 t_setup;u32 t_high, t_low;u32 tmo_clk;
@@ -199,7 +199,7 @@ static int axxia_i2c_init(struct axxia_i2c_dev *idev)/* Enable Master Mode */ writel (0x1 , idev->base +GLOBAL_CONTROL ); -if (idev->bus_clk_rate <=100000 ) { +if (idev->bus_clk_rate <=I2C_STANDARD_MODE_FREQ ) {/* Standard mode SCL 50/50, tSU:DAT = 250 ns */ t_high = divisor *1 /2 ; t_low = divisor *1 /2 ;
@@ -765,7 +765,7 @@ static int axxia_i2c_probe(struct platform_device *pdev)of_property_read_u32 (np,"clock-frequency" , &idev->bus_clk_rate);if (idev->bus_clk_rate ==0 ) - idev->bus_clk_rate =100000 ;/* default clock rate */ + idev->bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* default clock rate */ ret =clk_prepare_enable (idev->i2c_clk);if (ret) {
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 13/40 i2c: diolan-u2c: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-diolan-u2c.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-diolan-u2c.c +5 -7
@@ -64,8 +64,6 @@#define U2C_I2C_SPEED_2KHZ 242/* 2 kHz, minimum speed */ #define U2C_I2C_SPEED (f) ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1) -#define U2C_I2C_FREQ_FAST 400000 -#define U2C_I2C_FREQ_STD 100000#define U2C_I2C_FREQ (s) (1000000 / (2 * (s - 1) + 10))#define DIOLAN_USB_TIMEOUT 100/* in ms */
@@ -87,7 +85,7 @@ struct i2c_diolan_u2c {int ocount;/* Number of enqueued messages */ }; -static uint frequency =U2C_I2C_FREQ_STD ;/* I2C clock frequency in Hz */ +static uint frequency =I2C_STANDARD_MODE_FREQ ;/* I2C clock frequency in Hz */ module_param (frequency, uint,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (frequency,"I2C clock frequency in hertz" );
@@ -299,12 +297,12 @@ static int diolan_init(struct i2c_diolan_u2c *dev) {int speed, ret; -if (frequency >=200000 ) { +if (frequency >=2 *I2C_STANDARD_MODE_FREQ ) { speed =U2C_I2C_SPEED_FAST ; - frequency =U2C_I2C_FREQ_FAST ; - }else if (frequency >=100000 || frequency ==0 ) { + frequency =I2C_FAST_MODE_FREQ ; + }else if (frequency >=I2C_STANDARD_MODE_FREQ || frequency ==0 ) { speed =U2C_I2C_SPEED_STD ; - frequency =U2C_I2C_FREQ_STD ; + frequency =I2C_STANDARD_MODE_FREQ ; }else { speed =U2C_I2C_SPEED (frequency);if (speed >U2C_I2C_SPEED_2KHZ )
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 15/40 i2c: hix5hd2: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-hix5hd2.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-hix5hd2.c +4 -6
@@ -68,8 +68,6 @@#define I2C_ARBITRATE_INTR BIT(1)#define I2C_OVER_INTR BIT(0) -#define HIX5I2C_MAX_FREQ 400000/* 400k */ -enum hix5hd2_i2c_state {HIX5I2C_STAT_RW_ERR =-1 ,HIX5I2C_STAT_INIT ,
@@ -400,12 +398,12 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)if (of_property_read_u32 (np,"clock-frequency" , &freq)) {/* use 100k as default value */ - priv->freq =100000 ; + priv->freq =I2C_STANDARD_MODE_FREQ ; }else { -if (freq >HIX5I2C_MAX_FREQ ) { - priv->freq =HIX5I2C_MAX_FREQ ; +if (freq >I2C_FAST_MODE_FREQ ) { + priv->freq =I2C_FAST_MODE_FREQ ;dev_warn (priv->dev,"use max freq %d instead\n" , -HIX5I2C_MAX_FREQ ); +I2C_FAST_MODE_FREQ ); }else { priv->freq = freq; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 23/40 i2c: nomadik: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-nomadik.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-nomadik.c +4 -4
@@ -396,7 +396,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)* 2 whereas it is 3 for fast and fastplus mode of * operation. TODO - high speed support. */ - div = (dev->clk_freq >100000 ) ?3 :2 ; + div = (dev->clk_freq >I2C_STANDARD_MODE_FREQ ) ?3 :2 ;/* * generate the mask for baud rate counters. The controller
@@ -420,7 +420,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)if (dev->sm >I2C_FREQ_MODE_FAST ) {dev_err (&dev->adev->dev,"do not support this mode defaulting to std. mode\n" ); - brcr2 = i2c_clk/(100000 *2 ) &0xffff ; + brcr2 = i2c_clk / (I2C_STANDARD_MODE_FREQ *2 ) &0xffff ;writel ((brcr1 | brcr2), dev->virtbase +I2C_BRCR );writel (I2C_FREQ_MODE_STANDARD <<4 , dev->virtbase +I2C_CR );
@@ -949,10 +949,10 @@ static void nmk_i2c_of_probe(struct device_node *np, {/* Default to 100 kHz if no frequency is given in the node */ if (of_property_read_u32 (np,"clock-frequency" , &nmk->clk_freq)) - nmk->clk_freq =100000 ; + nmk->clk_freq =I2C_STANDARD_MODE_FREQ ;/* This driver only supports 'standard' and 'fast' modes of operation. */ -if (nmk->clk_freq <=100000 ) +if (nmk->clk_freq <=I2C_STANDARD_MODE_FREQ ) nmk->sm =I2C_FREQ_MODE_STANDARD ;else nmk->sm =I2C_FREQ_MODE_FAST ;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 26/40 i2c: riic: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-riic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-riic.c +3 -3
@@ -287,10 +287,10 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)pm_runtime_get_sync (riic->adapter.dev.parent); -if (t->bus_freq_hz >400000 ) { +if (t->bus_freq_hz >I2C_FAST_MODE_FREQ ) {dev_err (&riic->adapter.dev, -"unsupported bus speed (%dHz). 400000 max\n" , - t->bus_freq_hz); +"unsupported bus speed (%dHz). %d max\n" , + t->bus_freq_hz,I2C_FAST_MODE_FREQ ); ret = -EINVAL ; goto out; }
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 27/40 i2c: rk3x: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-rk3x.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-rk3x.c +6 -6
@@ -539,9 +539,9 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id)*/ static const struct i2c_spec_values *rk3x_i2c_get_spec (unsigned int speed) { -if (speed <=100000 ) +if (speed <=I2C_STANDARD_MODE_FREQ )return &standard_mode_spec; -else if (speed <=400000 ) +else if (speed <=I2C_FAST_MODE_FREQ )return &fast_mode_spec;else return &fast_mode_plus_spec;
@@ -578,8 +578,8 @@ static int rk3x_i2c_v0_calc_timings(unsigned long clk_rate,int ret =0 ;/* Only support standard-mode and fast-mode */ -if (WARN_ON (t->bus_freq_hz >400000 )) - t->bus_freq_hz =400000 ; +if (WARN_ON (t->bus_freq_hz >I2C_FAST_MODE_FREQ )) + t->bus_freq_hz =I2C_FAST_MODE_FREQ ;/* prevent scl_rate_khz from becoming 0 */ if (WARN_ON (t->bus_freq_hz <1000 ))
@@ -758,8 +758,8 @@ static int rk3x_i2c_v1_calc_timings(unsigned long clk_rate,int ret =0 ;/* Support standard-mode, fast-mode and fast-mode plus */ -if (WARN_ON (t->bus_freq_hz >1000000 )) - t->bus_freq_hz =1000000 ; +if (WARN_ON (t->bus_freq_hz >I2C_FAST_MODE_PLUS_FREQ )) + t->bus_freq_hz =I2C_FAST_MODE_PLUS_FREQ ;/* prevent scl_rate_khz from becoming 0 */ if (WARN_ON (t->bus_freq_hz <1000 ))
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 30/40 i2c: sirf: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-sirf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-sirf.c +1 -2
@@ -62,7 +62,6 @@#define SIRFSOC_I2C_STOP BIT(6)#define SIRFSOC_I2C_START BIT(7) -#define SIRFSOC_I2C_DEFAULT_SPEED 100000#define SIRFSOC_I2C_ERR_NOACK 1#define SIRFSOC_I2C_ERR_TIMEOUT 2
@@ -353,7 +352,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev) err =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &bitrate);if (err <0 ) - bitrate =SIRFSOC_I2C_DEFAULT_SPEED ; + bitrate =I2C_STANDARD_MODE_FREQ ;/* * Due to some hardware design issues, we need to tune the formula.
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 32/40 i2c: stm32f4: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-stm32f4.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-stm32f4.c +5 -6
@@ -91,7 +91,6 @@#define STM32F4_I2C_MIN_STANDARD_FREQ 2U#define STM32F4_I2C_MIN_FAST_FREQ 6U#define STM32F4_I2C_MAX_FREQ 46U -#define HZ_TO_MHZ 1000000/** * struct stm32f4_i2c_msg - client specific data
@@ -154,7 +153,7 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)u32 cr2 =0 ; i2c_dev->parent_rate =clk_get_rate (i2c_dev->clk); - freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_TO_MHZ ); + freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_PER_MHZ );if (i2c_dev->speed ==STM32_I2C_SPEED_STANDARD ) {/*
@@ -190,7 +189,7 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)static void stm32f4_i2c_set_rise_time (struct stm32f4_i2c_dev *i2c_dev) { -u32 freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_TO_MHZ ); +u32 freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_PER_MHZ );u32 trise;/*
@@ -243,7 +242,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)* parent rate is not higher than 46 MHz . As a result val * is at most 8 bits wide and so fits into the CCR bits [11:0]. */ - val = i2c_dev->parent_rate / (100000 <<1 ); + val = i2c_dev->parent_rate / (I2C_STANDARD_MODE_FREQ <<1 ); }else {/* * In fast mode, we compute CCR with duty = 0 as with low
@@ -263,7 +262,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)* parent rate is not higher than 46 MHz . As a result val * is at most 6 bits wide and so fits into the CCR bits [11:0]. */ - val =DIV_ROUND_UP (i2c_dev->parent_rate,400000 *3 ); + val =DIV_ROUND_UP (i2c_dev->parent_rate,I2C_FAST_MODE_FREQ *3 );/* Select Fast mode */ ccr |=STM32F4_I2C_CCR_FS ;
@@ -807,7 +806,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; ret =of_property_read_u32 (np,"clock-frequency" , &clk_rate); -if (!ret && clk_rate >=400000 ) +if (!ret && clk_rate >=I2C_FAST_MODE_FREQ ) i2c_dev->speed =STM32_I2C_SPEED_FAST ; i2c_dev->dev = &pdev->dev;
Signature · 1 line
2.25.0
Andy Shevchenko
reviewerPATCH 39/40 i2c: uniphier: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoSince we have generic definitions for bus frequencies, let's use them.
--- drivers/i2c/busses/i2c-uniphier.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/i2c/busses/i2c-uniphier.c +2 -5
@@ -35,9 +35,6 @@#define UNIPHIER_I2C_NOISE 0x1c/* noise filter control */ #define UNIPHIER_I2C_SETUP 0x20/* setup time control */ -#define UNIPHIER_I2C_DEFAULT_SPEED 100000 -#define UNIPHIER_I2C_MAX_SPEED 400000 -struct uniphier_i2c_priv {struct completion comp;struct i2c_adapter adap;
@@ -333,9 +330,9 @@ static int uniphier_i2c_probe(struct platform_device *pdev) }if (of_property_read_u32 (dev->of_node,"clock-frequency" , &bus_speed)) - bus_speed =UNIPHIER_I2C_DEFAULT_SPEED ; + bus_speed =I2C_STANDARD_MODE_FREQ ; -if (!bus_speed || bus_speed >UNIPHIER_I2C_MAX_SPEED ) { +if (!bus_speed || bus_speed >I2C_FAST_MODE_FREQ ) {dev_err (dev,"invalid clock-frequency %d\n" , bus_speed);return -EINVAL ; }
Signature · 1 line
2.25.0
Re: [PATCH v1 36/40] i2c: synquacer: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Ard Biesheuvel <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 48 lines
--- drivers/i2c/busses/i2c-synquacer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/i2c/busses/i2c-synquacer.c +6
-7@@ -67,10 +67,10 @@/* STANDARD MODE frequency */ #define SYNQUACER_I2C_CLK_MASTER_STD (rate) \ - DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2) + DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_STANDARD_MODE_FREQ) - 2, 2)/* FAST MODE frequency */ #define SYNQUACER_I2C_CLK_MASTER_FAST (rate) \ - DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3) + DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_FAST_MODE_FREQ) - 2) * 2, 3)/* (clkrate <= 18000000) */ /* calculate the value of CS bits in CCR register on standard mode */ @@ -111,11 +111,11 @@ & SYNQUACER_I2C_CSR_CS_MASK)/* min I2C clock frequency 14M */ -#define SYNQUACER_I2C_MIN_CLK_RATE (14 * 1000000) +#define SYNQUACER_I2C_MIN_CLK_RATE (14 * HZ_PER_MHZ)/* max I2C clock frequency 200M */ -#define SYNQUACER_I2C_MAX_CLK_RATE (200 * 1000000) +#define SYNQUACER_I2C_MAX_CLK_RATE (200 * HZ_PER_MHZ)/* I2C clock frequency 18M */ -#define SYNQUACER_I2C_CLK_RATE_18M (18 * 1000000) +#define SYNQUACER_I2C_CLK_RATE_18M (18 * HZ_PER_MHZ)#define SYNQUACER_I2C_SPEED_FM 400 // Fast Mode#define SYNQUACER_I2C_SPEED_SM 100 // Standard Mode@@ -602,7 +602,7 @@ static int synquacer_i2c_probe(struct platform_device *pdev) i2c->adapter.nr = pdev->id;init_completion (&i2c->completion); -if (bus_speed <400000 ) +if (bus_speed <I2C_FAST_MODE_FREQ ) i2c->speed_khz =SYNQUACER_I2C_SPEED_SM ;else i2c->speed_khz =SYNQUACER_I2C_SPEED_FM ; --2.25.0
Re: [PATCH v1 24/40] i2c: owl: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc "Andreas Färber" <[email protected]>Cc Manivannan Sadhasivam <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Thanks,
Mani
Quoted 36 lines
--- drivers/i2c/busses/i2c-owl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/i2c/busses/i2c-owl.c +3
-6@@ -87,9 +87,6 @@#define OWL_I2C_MAX_RETRIES 50 -#define OWL_I2C_DEF_SPEED_HZ 100000 -#define OWL_I2C_MAX_SPEED_HZ 400000 -struct owl_i2c_dev {struct i2c_adapter adap;struct i2c_msg *msg;@@ -419,11 +416,11 @@ static int owl_i2c_probe(struct platform_device *pdev)if (of_property_read_u32 (dev->of_node,"clock-frequency" , &i2c_dev->bus_freq)) - i2c_dev->bus_freq =OWL_I2C_DEF_SPEED_HZ ; + i2c_dev->bus_freq =I2C_STANDARD_MODE_FREQ ;/* We support only frequencies of 100k and 400k for now */ -if (i2c_dev->bus_freq !=OWL_I2C_DEF_SPEED_HZ && - i2c_dev->bus_freq !=OWL_I2C_MAX_SPEED_HZ ) { +if (i2c_dev->bus_freq !=I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_freq !=I2C_FAST_MODE_FREQ ) {dev_err (dev,"invalid clock-frequency %d\n" , i2c_dev->bus_freq);return -EINVAL ; }Signature · 1 line
2.25.0
Re: [PATCH v1 19/40] i2c: lpc2k: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi Andy!
Quoted 13 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Vladimir Zapolskiy <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-lpc2k.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-lpc2k.c +0
-0
drivers/i2c/busses/i2c-lpc2k.c static int i2c_lpc2k_probe(struct platform_device *pdev) · line 399
Quoted 5 lines
drivers/i2c/busses/i2c-lpc2k.c +1
-1@@ -396,7 +396,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev) ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &bus_clk_rate);if (ret) - bus_clk_rate =100000 ;/* 100 kHz default clock rate */ + bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* 100 kHz default clock rate */
The line above becomes longer than 80 symbols, please fix it by simply removing the comment, note that it might be an issue through the series.
Could I2C_STD_MODE_FREQ be a shorter and still acceptable name?
Quoted 6 lines
drivers/i2c/busses/i2c-lpc2k.c +0
-0clkrate =clk_get_rate (i2c->clk);if (clkrate ==0 ) {@@ -407,9 +407,9 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
drivers/i2c/busses/i2c-lpc2k.c static int i2c_lpc2k_probe(struct platform_device *pdev) · line 415
Quoted 10 lines
drivers/i2c/busses/i2c-lpc2k.c +2
-2/* Setup I2C dividers to generate clock with proper duty cycle */ clkrate = clkrate / bus_clk_rate; -if (bus_clk_rate <=100000 ) +if (bus_clk_rate <=I2C_STANDARD_MODE_FREQ ) scl_high = (clkrate *I2C_STD_MODE_DUTY ) /100 ; -else if (bus_clk_rate <=400000 ) +else if (bus_clk_rate <=I2C_FAST_MODE_FREQ ) scl_high = (clkrate *I2C_FAST_MODE_DUTY ) /100 ;else scl_high = (clkrate *I2C_FAST_MODE_PLUS_DUTY ) /100 ;
After the requested fix:
Andy Shevchenko
reviewerRe: [PATCH v1 19/40] i2c: lpc2k: Use generic definitions for bus frequencies
Quoted 8 lines · Vladimir Zapolskiy
drivers/i2c/busses/i2c-lpc2k.c static int i2c_lpc2k_probe(struct platform_device *pdev) · line 399
Quoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
drivers/i2c/busses/i2c-lpc2k.c +1
-1- bus_clk_rate =100000 ;/* 100 kHz default clock rate */ + bus_clk_rate =I2C_STANDARD_MODE_FREQ ;/* 100 kHz default clock rate */ The line above becomes longer than 80 symbols, please fix it by simply removing the comment, note that it might be an issue through the series.
Will do.
Quoted 1 line
Could
I2C_STD_MODE_FREQbe a shorter and still acceptable name?
I/m fine with it, but I will wait for Wolfram and others to comment.
Quoted 3 lines
After the requested fix:
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 03/40] i2c: core: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 3 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Mika Westerberg <[email protected]>
Re: [PATCH v1 11/40] i2c: designware: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Jarkko Nikula <[email protected]>Cc Mika Westerberg <[email protected]>
RE: [PATCH v1 26/40] i2c: riic: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 10 lines · Andy Shevchenko
Subject: [PATCH v1 26/40] i2c: riic: Use generic definitions for bus frequencies
Since we have generic definitions for bus frequencies, let's use them.
Cc Chris Brandt <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-riic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Re: [PATCH v1 08/40] i2c: bcm-iproc: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoThanks Andy.
Quoted 5 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Ray Jui <[email protected]>Cc Scott Branden <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 49 lines
--- drivers/i2c/busses/i2c-bcm-iproc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-bcm-iproc.c +7
-7@@ -858,25 +858,25 @@ static int bcm_iproc_i2c_cfg_speed(struct bcm_iproc_i2c_dev *iproc_i2c)if (ret <0 ) {dev_info (iproc_i2c->device,"unable to interpret clock-frequency DT property\n" ); - bus_speed =100000 ; + bus_speed =I2C_STANDARD_MODE_FREQ ; } -if (bus_speed <100000 ) { +if (bus_speed <I2C_STANDARD_MODE_FREQ ) {dev_err (iproc_i2c->device,"%d Hz bus speed not supported\n" , bus_speed);dev_err (iproc_i2c->device,"valid speeds are 100khz and 400khz\n" );return -EINVAL ; - }else if (bus_speed <400000 ) { - bus_speed =100000 ; + }else if (bus_speed <I2C_FAST_MODE_FREQ ) { + bus_speed =I2C_STANDARD_MODE_FREQ ; }else { - bus_speed =400000 ; + bus_speed =I2C_FAST_MODE_FREQ ; } iproc_i2c->bus_speed = bus_speed; val =iproc_i2c_rd_reg (iproc_i2c,TIM_CFG_OFFSET ); val &= ~BIT (TIM_CFG_MODE_400_SHIFT ); - val |= (bus_speed ==400000 ) <<TIM_CFG_MODE_400_SHIFT ; + val |= (bus_speed ==I2C_FAST_MODE_FREQ ) <<TIM_CFG_MODE_400_SHIFT ;iproc_i2c_wr_reg (iproc_i2c,TIM_CFG_OFFSET , val);dev_info (iproc_i2c->device,"bus set to %u Hz\n" , bus_speed);@@ -1029,7 +1029,7 @@ static int bcm_iproc_i2c_resume(struct device *dev)/* configure to the desired bus speed */ val =iproc_i2c_rd_reg (iproc_i2c,TIM_CFG_OFFSET ); val &= ~BIT (TIM_CFG_MODE_400_SHIFT ); - val |= (iproc_i2c->bus_speed ==400000 ) <<TIM_CFG_MODE_400_SHIFT ; + val |= (iproc_i2c->bus_speed ==I2C_FAST_MODE_FREQ ) <<TIM_CFG_MODE_400_SHIFT ;iproc_i2c_wr_reg (iproc_i2c,TIM_CFG_OFFSET , val);bcm_iproc_i2c_enable_disable (iproc_i2c, true);
Re: [PATCH v1 09/40] i2c: bcm-kona: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Florian Fainelli <[email protected]>Cc Ray Jui <[email protected]>Cc Scott Branden <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 29 lines
--- drivers/i2c/busses/i2c-bcm-kona.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/i2c/busses/i2c-bcm-kona.c +4
-4@@ -722,16 +722,16 @@ static int bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev) }switch (bus_speed) { -case 100000 : +case I2C_STANDARD_MODE_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_100K ];break ; -case 400000 : +case I2C_FAST_MODE_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_400K ];break ; -case 1000000 : +case I2C_FAST_MODE_PLUS_FREQ : dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ ];break ; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ :/* Send mastercode at 100k */ dev->std_cfg = &std_cfg_table[BCM_SPD_100K ]; dev->hs_cfg = &hs_cfg_table[BCM_SPD_3P4MHZ ];
Re: [PATCH v1 12/40] i2c: digicolor: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi Andy,
Quoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Baruch Siach <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
baruch
Quoted 25 lines
--- drivers/i2c/busses/i2c-digicolor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/i2c/busses/i2c-digicolor.c +1
-2@@ -18,7 +18,6 @@#include <linux/of.h> #include <linux/platform_device.h> -#define DEFAULT_FREQ 100000#define TIMEOUT_MS 100#define II_CONTROL 0x0@@ -300,7 +299,7 @@ static int dc_i2c_probe(struct platform_device *pdev)if (of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &i2c->frequency)) - i2c->frequency =DEFAULT_FREQ ; + i2c->frequency =I2C_STANDARD_MODE_FREQ ; i2c->dev = &pdev->dev;platform_set_drvdata (pdev, i2c);
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.52.368.4656, http://www.tkos.co.il -Re: [PATCH v1 31/40] i2c: spdr: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi Andy,
Quoted 7 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Orson Zhai <[email protected]>Cc Baolin Wang <[email protected]>Cc Chunyan Zhang <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Can you fix the typo in the subject line by changing 'spdr' to 'sprd'? Otherwise looks good to me. Thanks.
Quoted 42 lines
--- drivers/i2c/busses/i2c-sprd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/i2c/busses/i2c-sprd.c +5
-5@@ -337,9 +337,9 @@ static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)writel (div1, i2c_dev->base +ADDR_DVD1 );/* Start hold timing = hold time(us) * source clock */ -if (freq ==400000 ) +if (freq ==I2C_FAST_MODE_FREQ )writel ((6 * apb_clk) /10000000 , i2c_dev->base +ADDR_STA0_DVD ); -else if (freq ==100000 ) +else if (freq ==I2C_STANDARD_MODE_FREQ )writel ((4 * apb_clk) /1000000 , i2c_dev->base +ADDR_STA0_DVD ); }@@ -502,7 +502,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)snprintf (i2c_dev->adap.name,sizeof (i2c_dev->adap.name),"%s" ,"sprd-i2c" ); - i2c_dev->bus_freq =100000 ; + i2c_dev->bus_freq =I2C_STANDARD_MODE_FREQ ; i2c_dev->adap.owner =THIS_MODULE ; i2c_dev->dev = dev; i2c_dev->adap.retries =3 ;@@ -516,7 +516,8 @@ static int sprd_i2c_probe(struct platform_device *pdev) i2c_dev->bus_freq = prop;/* We only support 100k and 400k now, otherwise will return error. */ -if (i2c_dev->bus_freq !=100000 && i2c_dev->bus_freq !=400000 ) +if (i2c_dev->bus_freq !=I2C_STANDARD_MODE_FREQ && + i2c_dev->bus_freq !=I2C_FAST_MODE_FREQ )return -EINVAL ; ret =sprd_i2c_clk_init (i2c_dev); --2.25.0
Re: [PATCH v1 04/40] i2c: altera: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi
Quoted 14 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Thor Thayer <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-altera.c | 8 ++++---- include/linux/i2c.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)drivers/i2c/busses/i2c-altera.c +0
-0
drivers/i2c/busses/i2c-altera.c static inline void altr_i2c_stop(struct altr_i2c_dev *idev) · line 145
Quoted 5 lines
drivers/i2c/busses/i2c-altera.c +1
-1@@ -142,12 +142,12 @@ static inline void altr_i2c_stop(struct altr_i2c_dev *idev)static void altr_i2c_init (struct altr_i2c_dev *idev) {u32 divisor =clk_get_rate (idev->i2c_clk) / idev->bus_clk_rate; -u32 clk_mhz =clk_get_rate (idev->i2c_clk) /1000000 ; +u32 clk_mhz =clk_get_rate (idev->i2c_clk) /HZ_PER_MHZ ;
IMHO these kind of defines don't improve readability in formulas. What is HZ_PER_MHZ? You have to go and grep it first in order to be sure. Of course it protects against typos like "100000" or "10000000" that are difficult to spot at quick look.
Better would be just "1MHz" or even better calc_something_MHz().
Signature · 1 line
Jarkko
Jarkko Nikula
Acked-byRe: [PATCH v1 11/40] i2c: designware: Use generic definitions for bus frequencies
In reply to Mika WesterbergQuoted 8 lines · Mika Westerberg
Quoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Jarkko Nikula <[email protected]>Cc Mika Westerberg <[email protected]>Reviewed-by Mika Westerberg <[email protected]>
Re: [PATCH v1 18/40] i2c: imx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 6 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Oleksij Rempel <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 20 lines
--- drivers/i2c/busses/i2c-imx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/i2c/busses/i2c-imx.c +0
-3@@ -49,9 +49,6 @@/* This will be the driver name the kernel reports */ #define DRIVER_NAME "imx-i2c" -/* Default value */ -#define IMX_I2C_BIT_RATE 100000/* 100kHz */ -/* * Enable DMA if transfer byte size is bigger than this threshold. * As the hardware request, it must bigger than 4 bytes.\
drivers/i2c/busses/i2c-imx.c static int i2c_imx_probe(struct platform_device *pdev) · line 1142
Quoted 8 lines
drivers/i2c/busses/i2c-imx.c +1
-1@@ -1139,7 +1136,7 @@ static int i2c_imx_probe(struct platform_device *pdev) goto rpm_disable;/* Set up clock divider */ - i2c_imx->bitrate =IMX_I2C_BIT_RATE ; + i2c_imx->bitrate =I2C_STANDARD_MODE_FREQ ; ret =of_property_read_u32 (pdev->dev.of_node,"clock-frequency" , &i2c_imx->bitrate);if (ret <0 && pdata && pdata->bitrate)
Kind regards,
Oleksij Rempel
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi Andy,
Quoted 5 lines · Andy Shevchenko
Move bus frequency definitions to
i2c.hfor wider use.Cc Andy Gross <[email protected]>Cc Bjorn Andersson <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
A cover letter would have been nice so we could discuss the general appraoch there. And to read more about the motivation.
include/linux/i2c.h enum i2c_slave_event; · line 42
Quoted 7 lines
include/linux/i2c.h +1
-0@@ -39,6 +39,13 @@ enum i2c_slave_event;typedef int (*i2c_slave_cb_t )(struct i2c_client *client,enum i2c_slave_event event,u8 *val); +#define HZ_PER_KHZ 1000
Unlike Jarkko, I think such macros help readability when calculating frequencies within drivers. However, they shouldn't be local to I2C if we agree on them. They should be available Linux-wide. There are some other (few) local implementations already.
include/linux/i2c.h enum i2c_slave_event; · line 47
Quoted 5 lines
include/linux/i2c.h +5
-0+ +/* I2C Frequency Modes */ +#define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ) +#define I2C_FAST_MODE_FREQ (400 * HZ_PER_KHZ) +#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ)
For such a header, I'd prefer the plain number, though. There will be enough review to make sure we get it right ;) Furthermore, I'd prefer to have 'MAX' in there, e.g. I2C_MAX_STANDARD_MODE_FREQ etc. Just to make clear that I2C can have other bus speeds as well.
And finally, I'd think all driver patches should be squashed into one, and all core ones into one etc. Or?
Thanks,
Wolfram
Andy Shevchenko
reviewerRe: [PATCH v1 31/40] i2c: spdr: Use generic definitions for bus frequencies
In reply to Baolin WangQuoted 11 lines · Baolin Wang
Quoted 7 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Orson Zhai <[email protected]>Cc Baolin Wang <[email protected]>Cc Chunyan Zhang <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>Can you fix the typo in the subject line by changing 'spdr' to 'sprd'?
Sure.
Quoted 2 lines
Otherwise looks good to me. Thanks.
Reviewed-by Baolin Wang <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Andy Shevchenko
reviewerQuoted 9 lines · Wolfram Sang
Quoted 5 lines · Andy Shevchenko
Move bus frequency definitions to
i2c.hfor wider use.Cc Andy Gross <[email protected]>Cc Bjorn Andersson <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>A cover letter would have been nice so we could discuss the general appraoch there. And to read more about the motivation.
Motivation is simple:
- Standardize the (small) set of mostly used bus frequences
- Get rid of repetition of (subset) of above in many drivers
- Reduce amount of potential typos
Let's discuss it here. I don't think new version of this would be good to have without initial settlement.
Quoted 6 lines
Quoted 6 lines
include/linux/i2c.h +0
-0@@ -39,6 +39,13 @@ enum i2c_slave_event;typedef int (*i2c_slave_cb_t )(struct i2c_client *client,enum i2c_slave_event event,u8 *val);
Quoted 6 lines
include/linux/i2c.h enum i2c_slave_event; · line 42
Quoted 1 line
include/linux/i2c.h +1
-0+#define HZ_PER_KHZ 1000Unlike Jarkko, I think such macros help readability when calculating frequencies within drivers. However, they shouldn't be local to I2C if we agree on them. They should be available Linux-wide. There are some other (few) local implementations already.
I aware about that, but I would like to avoid I²C subsystem storming for another change like this. So, let's consider this as a trampoline when in the future we will switch entire subsystem to Linux wide header at once.
We have already same/similar definitions in the other drivers and I really would like to avoid cross subsystem collisions.
Quoted 7 lines
include/linux/i2c.h enum i2c_slave_event; · line 47
Quoted 4 lines
include/linux/i2c.h +4
-0+/* I2C Frequency Modes */ +#define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ) +#define I2C_FAST_MODE_FREQ (400 * HZ_PER_KHZ) +#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ)For such a header, I'd prefer the plain number, though. There will be enough review to make sure we get it right ;)
No problem. I'm fine with either.
Quoted 3 lines
Furthermore, I'd prefer to
have 'MAX' in there, e.g.I2C_MAX_STANDARD_MODE_FREQetc. Just to make clear that I2C can have other bus speeds as well.
Works for me.
Btw, what about Vladimir's comment WRT STANDARD -> STD? My personal opinion that STD is a bit too short.
Quoted 2 lines
And finally, I'd think all driver patches should be squashed into one, and all core ones into one etc. Or?
I'm fine with either. For reviewers it would be better I think to see only their portion. Since I got a lot of tags already I consider I may squash it together. So, what do you prefer?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy,
Quoted 7 lines
Motivation is simple:
- Standardize the (small) set of mostly used bus frequences
- Get rid of repetition of (subset) of above in many drivers
- Reduce amount of potential typosLet's discuss it here. I don't think new version of this would be good to have without initial settlement.
Well, for me, this works. I agree to the typo thing and having less magic values. It's all OK; I think it is just nice to have some things in a coverletter.
Quoted 3 lines
I aware about that, but I would like to avoid I²C subsystem storming for another change like this. So, let's consider this as a trampoline when in the future we will switch entire subsystem to Linux wide header at once.
I can agree to that.
Quoted 5 lines
Quoted 3 lines
Furthermore, I'd prefer to
have 'MAX' in there, e.g.I2C_MAX_STANDARD_MODE_FREQetc. Just to make clear that I2C can have other bus speeds as well.Works for me.
Thanks, that's the most important point to me.
Quoted 2 lines
Btw, what about Vladimir's comment WRT STANDARD -> STD? My personal opinion that STD is a bit too short.
No real opinion here. I think STD is understandable enough and I encounter it regularly. However, I also don't think the saving is huge enough to matter. Your call here.
Quoted 3 lines
I'm fine with either. For reviewers it would be better I think to see only their portion. Since I got a lot of tags already I consider I may squash it together. So, what do you prefer?
Sounds good to me. Keep collecting acks and squash all patches and tags in v2.
Thanks,
Wolfram
Andy Shevchenko
reviewerQuoted 11 lines · Wolfram Sang
Quoted 7 lines
Motivation is simple:
- Standardize the (small) set of mostly used bus frequences
- Get rid of repetition of (subset) of above in many drivers
- Reduce amount of potential typosLet's discuss it here. I don't think new version of this would be good to have without initial settlement.
Well, for me, this works. I agree to the typo thing and having less magic values. It's all OK; I think it is just nice to have some things in a coverletter.
Since it looks like we will have only few patches at the end, I think the commit message for the first one would be good enough to describe this all.
Quoted 12 lines
Quoted 3 lines
I aware about that, but I would like to avoid I²C subsystem storming for another change like this. So, let's consider this as a trampoline when in the future we will switch entire subsystem to Linux wide header at once.
I can agree to that.
Quoted 5 lines
Quoted 3 lines
Furthermore, I'd prefer to
have 'MAX' in there, e.g.I2C_MAX_STANDARD_MODE_FREQetc. Just to make clear that I2C can have other bus speeds as well.Works for me.
Quoted 8 lines
Thanks, that's the most important point to me.
Quoted 2 lines
Btw, what about Vladimir's comment WRT STANDARD -> STD? My personal opinion that STD is a bit too short.
No real opinion here. I think STD is understandable enough and I encounter it regularly. However, I also don't think the saving is huge enough to matter. Your call here.
I prefer STANDARD over STD due to consistency (we don't have good abbreviations for Fast, Fast+, High Speed, etc, anyway).
Quoted 6 lines
Quoted 3 lines
I'm fine with either. For reviewers it would be better I think to see only their portion. Since I got a lot of tags already I consider I may squash it together. So, what do you prefer?
Sounds good to me. Keep collecting acks and squash all patches and tags in v2.
Good, thanks for review!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 13/40] i2c: diolan-u2c: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Guenter Roeck <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Quoted 46 lines
--- drivers/i2c/busses/i2c-diolan-u2c.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)drivers/i2c/busses/i2c-diolan-u2c.c +5
-7@@ -64,8 +64,6 @@#define U2C_I2C_SPEED_2KHZ 242/* 2 kHz, minimum speed */ #define U2C_I2C_SPEED (f) ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1) -#define U2C_I2C_FREQ_FAST 400000 -#define U2C_I2C_FREQ_STD 100000#define U2C_I2C_FREQ (s) (1000000 / (2 * (s - 1) + 10))#define DIOLAN_USB_TIMEOUT 100/* in ms */ @@ -87,7 +85,7 @@ struct i2c_diolan_u2c {int ocount;/* Number of enqueued messages */ }; -static uint frequency =U2C_I2C_FREQ_STD ;/* I2C clock frequency in Hz */ +static uint frequency =I2C_STANDARD_MODE_FREQ ;/* I2C clock frequency in Hz */ module_param (frequency, uint,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (frequency,"I2C clock frequency in hertz" );@@ -299,12 +297,12 @@ static int diolan_init(struct i2c_diolan_u2c *dev) {int speed, ret; -if (frequency >=200000 ) { +if (frequency >=2 *I2C_STANDARD_MODE_FREQ ) { speed =U2C_I2C_SPEED_FAST ; - frequency =U2C_I2C_FREQ_FAST ; - }else if (frequency >=100000 || frequency ==0 ) { + frequency =I2C_FAST_MODE_FREQ ; + }else if (frequency >=I2C_STANDARD_MODE_FREQ || frequency ==0 ) { speed =U2C_I2C_SPEED_STD ; - frequency =U2C_I2C_FREQ_STD ; + frequency =I2C_STANDARD_MODE_FREQ ; }else { speed =U2C_I2C_SPEED (frequency);if (speed >U2C_I2C_SPEED_2KHZ )Signature · 1 line
2.25.0
Re: [PATCH v1 23/40] i2c: nomadik: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Linus Walleij <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Neat!
Yours,
Linus Walleij
Re: [PATCH v1 34/40] i2c: stu300: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Linus Walleij <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Re: [PATCH v1 06/40] i2c: aspeed: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 5 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Brendan Higgins <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Thanks!
Re: [PATCH v1 05/40] i2c: amd-mp2: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 11 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Elie Morisse <[email protected]>Cc Nehal Shah <[email protected]>Cc Shyam Sundar S K <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 ++++++++++++++++----------- include/linux/i2c.h | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-)
Looks good to me.
Re: [PATCH v1 05/40] i2c: amd-mp2: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi
Quoted 69 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Elie Morisse <[email protected]>Cc Nehal Shah <[email protected]>Cc Shyam Sundar S K <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 ++++++++++++++++----------- include/linux/i2c.h | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-)drivers/i2c/busses/i2c-amd-mp2-plat.c +16
-11@@ -201,32 +201,37 @@ static int i2c_amd_resume(struct amd_i2c_common *i2c_common) }#endif +static const u32 supported_speeds[] = { +I2C_HIGH_SPEED_MODE_FREQ , +I2C_TURBO_MODE_FREQ , +I2C_FAST_MODE_PLUS_FREQ , +I2C_FAST_MODE_FREQ , +I2C_STANDARD_MODE_FREQ , +}; +static enum speed_enum i2c_amd_get_bus_speed (struct platform_device *pdev) {u32 acpi_speed;int i; -static const u32 supported_speeds[] = { -0 ,100000 ,400000 ,1000000 ,1400000 ,3400000 - }; acpi_speed =i2c_acpi_find_bus_speed (&pdev->dev);/* round down to the lowest standard speed */ -for (i =1 ; i <ARRAY_SIZE (supported_speeds); i++) { -if (acpi_speed < supported_speeds[i]) +for (i =0 ; i <ARRAY_SIZE (supported_speeds); i++) { +if (acpi_speed >= supported_speeds[i])break ; } - acpi_speed = supported_speeds[i -1 ]; + acpi_speed = i <ARRAY_SIZE (supported_speeds) ? supported_speeds[i] :0 ;switch (acpi_speed) { -case 100000 : +case I2C_STANDARD_MODE_FREQ :return speed100k; -case 400000 : +case I2C_FAST_MODE_FREQ :return speed400k; -case 1000000 : +case I2C_FAST_MODE_PLUS_FREQ :return speed1000k; -case 1400000 : +case I2C_TURBO_MODE_FREQ :return speed1400k; -case 3400000 : +case I2C_HIGH_SPEED_MODE_FREQ :return speed3400k;default :return speed400k;include/linux/i2c.h +0
-0
include/linux/i2c.h typedef int (*i2c_slave_cb_t)(struct i2c_client *client, · line 53
Quoted 8 lines
include/linux/i2c.h +2
-0@@ -46,6 +46,8 @@ typedef int (*i2c_slave_cb_t)(struct i2c_client *client,#define I2C_STANDARD_MODE_FREQ (100 * HZ_PER_KHZ)#define I2C_FAST_MODE_FREQ (400 * HZ_PER_KHZ)#define I2C_FAST_MODE_PLUS_FREQ (1000 * HZ_PER_KHZ) +#define I2C_TURBO_MODE_FREQ (1400 * HZ_PER_KHZ) +#define I2C_HIGH_SPEED_MODE_FREQ (3400 * HZ_PER_KHZ)struct module ;struct property_entry ;
Fine for me.
Thanks
Nehal Shah
Re: [PATCH v1 32/40] i2c: stm32f4: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi
Look good to me.
Thanks
Quoted 68 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Pierre-Yves MORDRET <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-stm32f4.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/i2c/busses/i2c-stm32f4.c +5
-6@@ -91,7 +91,6 @@#define STM32F4_I2C_MIN_STANDARD_FREQ 2U#define STM32F4_I2C_MIN_FAST_FREQ 6U#define STM32F4_I2C_MAX_FREQ 46U -#define HZ_TO_MHZ 1000000/** * struct stm32f4_i2c_msg - client specific data @@ -154,7 +153,7 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)u32 cr2 =0 ; i2c_dev->parent_rate =clk_get_rate (i2c_dev->clk); - freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_TO_MHZ ); + freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_PER_MHZ );if (i2c_dev->speed ==STM32_I2C_SPEED_STANDARD ) {/* @@ -190,7 +189,7 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)static void stm32f4_i2c_set_rise_time (struct stm32f4_i2c_dev *i2c_dev) { -u32 freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_TO_MHZ ); +u32 freq =DIV_ROUND_UP (i2c_dev->parent_rate,HZ_PER_MHZ );u32 trise;/* @@ -243,7 +242,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)* parent rate is not higher than 46 MHz . As a result val * is at most 8 bits wide and so fits into the CCR bits [11:0]. */ - val = i2c_dev->parent_rate / (100000 <<1 ); + val = i2c_dev->parent_rate / (I2C_STANDARD_MODE_FREQ <<1 ); }else {/* * In fast mode, we compute CCR with duty = 0 as with low @@ -263,7 +262,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)* parent rate is not higher than 46 MHz . As a result val * is at most 6 bits wide and so fits into the CCR bits [11:0]. */ - val =DIV_ROUND_UP (i2c_dev->parent_rate,400000 *3 ); + val =DIV_ROUND_UP (i2c_dev->parent_rate,I2C_FAST_MODE_FREQ *3 );/* Select Fast mode */ ccr |=STM32F4_I2C_CCR_FS ;@@ -807,7 +806,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; ret =of_property_read_u32 (np,"clock-frequency" , &clk_rate); -if (!ret && clk_rate >=400000 ) +if (!ret && clk_rate >=I2C_FAST_MODE_FREQ ) i2c_dev->speed =STM32_I2C_SPEED_FAST ; i2c_dev->dev = &pdev->dev;
Re: [PATCH v1 33/40] i2c: stm32f7: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoHi
Look good to me.
Thanks
Quoted 72 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Pierre-Yves MORDRET <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- drivers/i2c/busses/i2c-stm32f7.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)drivers/i2c/busses/i2c-stm32f7.c +12
-12@@ -334,9 +334,9 @@ struct stm32f7_i2c_dev {*/ static struct stm32f7_i2c_spec i2c_specs[] = { [STM32_I2C_SPEED_STANDARD ] = { - .rate =100000 , - .rate_min =80000 , - .rate_max =100000 , + .rate =I2C_STANDARD_MODE_FREQ , + .rate_min =I2C_STANDARD_MODE_FREQ *8 /10 ,/* 80% */ + .rate_max =I2C_STANDARD_MODE_FREQ , .fall_max =300 , .rise_max =1000 , .hddat_min =0 ,@@ -346,9 +346,9 @@ static struct stm32f7_i2c_spec i2c_specs[] = { .h_min = 4000, }, [STM32_I2C_SPEED_FAST] = { - .rate = 400000, - .rate_min = 320000, - .rate_max = 400000, + .rate = I2C_FAST_MODE_FREQ, + .rate_min = I2C_FAST_MODE_FREQ * 8 / 10, /* 80% */ + .rate_max = I2C_FAST_MODE_FREQ, .fall_max = 300, .rise_max = 300, .hddat_min = 0,@@ -358,9 +358,9 @@ static struct stm32f7_i2c_spec i2c_specs[] = { .h_min = 600, }, [STM32_I2C_SPEED_FAST_PLUS] = { - .rate = 1000000, - .rate_min = 800000, - .rate_max = 1000000, + .rate = I2C_FAST_MODE_PLUS_FREQ, + .rate_min = I2C_FAST_MODE_PLUS_FREQ * 8 / 10, /* 80% */ + .rate_max = I2C_FAST_MODE_PLUS_FREQ, .fall_max = 100, .rise_max = 120, .hddat_min = 0,@@ -1894,14 +1894,14 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; ret =device_property_read_u32 (&pdev->dev,"clock-frequency" , &clk_rate); -if (!ret && clk_rate >=1000000 ) { +if (!ret && clk_rate >=I2C_FAST_MODE_PLUS_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_FAST_PLUS ; ret =stm32f7_i2c_setup_fm_plus_bits (pdev, i2c_dev);if (ret) goto clk_free; - }else if (!ret && clk_rate >=400000 ) { + }else if (!ret && clk_rate >=I2C_FAST_MODE_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_FAST ; - }else if (!ret && clk_rate >=100000 ) { + }else if (!ret && clk_rate >=I2C_STANDARD_MODE_FREQ ) { i2c_dev->speed =STM32_I2C_SPEED_STANDARD ; }
Re: [PATCH v1 21/40] i2c: mv64xxx: Use generic definitions for bus frequencies
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Since we have generic definitions for bus frequencies, let's use them.
Cc Gregory CLEMENT <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Thanks,
Gregory
Quoted 37 lines
--- drivers/i2c/busses/i2c-mv64xxx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i2c/busses/i2c-mv64xxx.c +3
-3@@ -810,7 +810,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, tclk =clk_get_rate (drv_data->clk);if (of_property_read_u32 (np,"clock-frequency" , &bus_freq)) - bus_freq =100000 ;/* 100kHz by default */ + bus_freq =I2C_STANDARD_MODE_FREQ ;/* 100kHz by default */ if (of_device_is_compatible (np,"allwinner,sun4i-a10-i2c" ) ||of_device_is_compatible (np,"allwinner,sun6i-a31-i2c" ))@@ -846,14 +846,14 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,if (of_device_is_compatible (np,"marvell,mv78230-i2c" )) { drv_data->offload_enabled = true;/* The delay is only needed in standard mode (100kHz) */ -if (bus_freq <=100000 ) +if (bus_freq <=I2C_STANDARD_MODE_FREQ ) drv_data->errata_delay = true; }if (of_device_is_compatible (np,"marvell,mv78230-a0-i2c" )) { drv_data->offload_enabled = false;/* The delay is only needed in standard mode (100kHz) */ -if (bus_freq <=100000 ) +if (bus_freq <=I2C_STANDARD_MODE_FREQ ) drv_data->errata_delay = true; }Signature · 1 line
2.25.0
Signature · 3 lines
Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com