Skip to content

Commit

Permalink
dm: i2c: use CONFIG_IS_ENABLED macro for DM_I2C/DM_I2C_GPIO
Browse files Browse the repository at this point in the history
Use CONFIG_IS_ENABLED() macro, which provides more convenient
way to check $(SPL)DM_I2C/$(SPL)DM_I2C_GPIO configs
for both SPL and U-Boot proper.

CONFIG_IS_ENABLED(DM_I2C) expands to:
- 1 if CONFIG_SPL_BUILD is undefined and CONFIG_DM_I2C is set to 'y',
- 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_DM_I2C is set to 'y',
- 0 otherwise.

All occurences were replaced automatically using these bash cmds:
$ find . -type f -exec sed -i
     's/ifndef CONFIG_DM_I2C/if !CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C/if CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C)/CONFIG_IS_ENABLED(DM_I2C)/g' {} +
$ find . -type f -exec sed -i
    's/ifndef CONFIG_DM_I2C_GPIO/if !CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/ifdef CONFIG_DM_I2C_GPIO/if CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +
$ find . -type f -exec sed -i
    's/defined(CONFIG_DM_I2C_GPIO)/CONFIG_IS_ENABLED(DM_I2C_GPIO)/g' {} +

Reviewed-by: Heiko Schocher <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Signed-off-by: Igor Opaniuk <[email protected]>
Reviewed-by: Tom Rini <[email protected]>
Reviewed-by: Priyanka Jain <[email protected]>
  • Loading branch information
igoropaniuk authored and hsdenx committed Feb 21, 2021
1 parent a907dce commit 2147a16
Show file tree
Hide file tree
Showing 107 changed files with 311 additions and 311 deletions.
2 changes: 1 addition & 1 deletion arch/arm/include/asm/arch-fsl-layerscape/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
#elif defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
#define TZPC_BASE 0x02200000
#define TZPCDECPROT_0_SET_BASE (TZPC_BASE + 0x804)
#if !defined(CONFIG_DM_I2C)
#if !CONFIG_IS_ENABLED(DM_I2C)
#define CONFIG_SYS_I2C
#define CONFIG_SYS_I2C_EARLY_INIT
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/include/asm/arch-lpc32xx/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct lpc32xx_i2c_base {
u32 stxfl;
};

#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
enum {
I2C_0, I2C_1, I2C_2,
};
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/include/asm/mach-imx/mxc_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct mxc_i2c_bus {
#if CONFIG_IS_ENABLED(CLK)
struct clk per_clk;
#endif
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
int (*idle_bus_fn)(void *p);
void *idle_bus_data;
#else
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/include/asm/omap_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef _OMAP_I2C_H
#define _OMAP_I2C_H

#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)

/* Information about a GPIO bank */
struct omap_i2c_plat {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-imx/i2c-mxv7.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int setup_i2c(unsigned i2c_index, int speed, int slave_addr,
if (ret)
goto err_idle;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
bus_i2c_init(i2c_index, speed, slave_addr, force_idle_bus, p);
#endif

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-keystone/ddr3_spd.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static void init_ddr3param(struct ddr3_spd_cb *spd_cb,
static int ddr3_read_spd(ddr3_spd_eeprom_t *spd_params)
{
int ret;
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
int old_bus;

i2c_init(CONFIG_SYS_DAVINCI_I2C_SPEED, CONFIG_SYS_DAVINCI_I2C_SLAVE);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-kirkwood/include/mach/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/*
* I2C related stuff
*/
#if defined(CONFIG_CMD_I2C) && !defined(CONFIG_DM_I2C)
#if defined(CONFIG_CMD_I2C) && !CONFIG_IS_ENABLED(DM_I2C)
#ifndef CONFIG_SYS_I2C_SOFT
#define CONFIG_SYS_I2C
#define CONFIG_SYS_I2C_MVTWSI
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/am33xx/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ U_BOOT_DRVINFOS(am33xx_uarts) = {
# endif
};

#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
static const struct omap_i2c_plat am33xx_i2c[] = {
{ I2C_BASE1, 100000, OMAP_I2C_REV_V2},
{ I2C_BASE2, 100000, OMAP_I2C_REV_V2},
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-omap2/am33xx/clk_synthesizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int clk_synthesizer_reg_read(struct udevice *dev, int addr, u8 *buf)
/* Enable Bye read */
addr = addr | CLK_SYNTHESIZER_BYTE_MODE;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
/* Send the command byte */
rc = i2c_write(CLK_SYNTHESIZER_I2C_ADDR, addr, 1, buf, 1);
if (rc)
Expand Down Expand Up @@ -72,7 +72,7 @@ static int clk_synthesizer_reg_write(struct udevice *dev, int addr, u8 val)
cmd[0] = addr | CLK_SYNTHESIZER_BYTE_MODE;
cmd[1] = val;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
rc = i2c_write(CLK_SYNTHESIZER_I2C_ADDR, addr, 1, cmd, 2);
#else
rc = dm_i2c_write(dev, addr, cmd, 2);
Expand All @@ -96,7 +96,7 @@ int setup_clock_synthesizer(struct clk_synth *data)
int rc;
u8 val = 0;
struct udevice *dev = NULL;
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
rc = i2c_probe(CLK_SYNTHESIZER_I2C_ADDR);
if (rc) {
printf("i2c probe failed at address 0x%x\n",
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/boot-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void spl_board_init(void)
#if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
gpmc_init();
#endif
#if defined(CONFIG_SPL_I2C_SUPPORT) && !defined(CONFIG_DM_I2C)
#if defined(CONFIG_SPL_I2C_SUPPORT) && !CONFIG_IS_ENABLED(DM_I2C)
i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
#endif
#if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/clocks-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ void prcm_init(void)
enable_basic_uboot_clocks();
}

#if !defined(CONFIG_DM_I2C)
#if !CONFIG_IS_ENABLED(DM_I2C)
void gpi2c_init(void)
{
static int gpi2c = 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-sunxi/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void s_init(void)
clock_init();
timer_init();
gpio_init();
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
i2c_init_board();
#endif
eth_init_board();
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/fsl_i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct fsl_i2c_base {
u8 res6[0xE8];
} fsl_i2c_t;

#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct fsl_i2c_dev {
struct fsl_i2c_base __iomem *base; /* register base */
u32 i2c_clk;
Expand Down
2 changes: 1 addition & 1 deletion board/freescale/common/dcu_sii9022a.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int dcu_set_dvi_encoder(struct fb_videomode *videomode)
u8 temp;
u16 temp1, temp2;
u32 temp3;
#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *dev;
int ret;

Expand Down
2 changes: 1 addition & 1 deletion board/freescale/common/diu_ch7301.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int diu_set_dvi_encoder(unsigned int pixclock)
u8 temp;

temp = I2C_DVI_TEST_PATTERN_VAL;
#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *dev;

ret = i2c_get_chip_for_busnum(CONFIG_SYS_I2C_DVI_BUS_NUM,
Expand Down
4 changes: 2 additions & 2 deletions board/freescale/common/emc2305.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void set_fan_speed(u8 data, int chip_addr)
I2C_EMC2305_FAN5};

for (index = 0; index < NUM_OF_FANS; index++) {
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
if (i2c_write(chip_addr, Fan[index], 1, &data, 1) != 0) {
printf("Error: failed to change fan speed @%x\n",
Fan[index]);
Expand All @@ -48,7 +48,7 @@ void emc2305_init(int chip_addr)
u8 data;

data = I2C_EMC2305_CMD;
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
if (i2c_write(chip_addr, I2C_EMC2305_CONF, 1, &data, 1) != 0)
printf("Error: failed to configure EMC2305\n");
#else
Expand Down
4 changes: 2 additions & 2 deletions board/freescale/common/qixis.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#ifdef CONFIG_SYS_I2C_FPGA_ADDR
u8 qixis_read_i2c(unsigned int reg)
{
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
return i2c_reg_read(CONFIG_SYS_I2C_FPGA_ADDR, reg);
#else
struct udevice *dev;
Expand All @@ -47,7 +47,7 @@ u8 qixis_read_i2c(unsigned int reg)
void qixis_write_i2c(unsigned int reg, u8 value)
{
u8 val = value;
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
i2c_reg_write(CONFIG_SYS_I2C_FPGA_ADDR, reg, val);
#else
struct udevice *dev;
Expand Down
20 changes: 10 additions & 10 deletions board/freescale/common/sys_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static int read_eeprom(void)
{
int ret;
#ifdef CONFIG_SYS_EEPROM_BUS_NUM
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
unsigned int bus;
#endif
#endif
Expand All @@ -161,13 +161,13 @@ static int read_eeprom(void)
return 0;

#ifdef CONFIG_SYS_EEPROM_BUS_NUM
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
bus = i2c_get_bus_num();
i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
#endif
#endif

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
(void *)&e, sizeof(e));
Expand All @@ -186,7 +186,7 @@ static int read_eeprom(void)
#endif

#ifdef CONFIG_SYS_EEPROM_BUS_NUM
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
i2c_set_bus_num(bus);
#endif
#endif
Expand Down Expand Up @@ -223,7 +223,7 @@ static int prog_eeprom(void)
int i;
void *p;
#ifdef CONFIG_SYS_EEPROM_BUS_NUM
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
unsigned int bus;
#endif
#endif
Expand All @@ -237,7 +237,7 @@ static int prog_eeprom(void)
#endif
update_crc();

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
#ifdef CONFIG_SYS_EEPROM_BUS_NUM
bus = i2c_get_bus_num();
i2c_set_bus_num(CONFIG_SYS_EEPROM_BUS_NUM);
Expand All @@ -250,7 +250,7 @@ static int prog_eeprom(void)
* complete a given write.
*/
for (i = 0, p = &e; i < sizeof(e); i += 8, p += 8) {
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_write(CONFIG_SYS_I2C_EEPROM_ADDR, i,
CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
p, min((int)(sizeof(e) - i), 8));
Expand Down Expand Up @@ -279,7 +279,7 @@ static int prog_eeprom(void)
/* Verify the write by reading back the EEPROM and comparing */
struct eeprom e2;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0,
CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
(void *)&e2, sizeof(e2));
Expand All @@ -302,7 +302,7 @@ static int prog_eeprom(void)
ret = -1;
}

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
#ifdef CONFIG_SYS_EEPROM_BUS_NUM
i2c_set_bus_num(bus);
#endif
Expand Down Expand Up @@ -594,7 +594,7 @@ unsigned int get_cpu_board_revision(void)
u8 minor; /* 0x05 Board revision, minor */
} be;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
(void *)&be, sizeof(be));
#else
Expand Down
24 changes: 12 additions & 12 deletions board/freescale/common/vid.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ static int find_ir_chip_on_i2c(void)
u8 byte;
int i;
const int ir_i2c_addr[] = {0x38, 0x08, 0x09};
#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *dev;
#endif

/* Check all the address */
for (i = 0; i < (sizeof(ir_i2c_addr)/sizeof(ir_i2c_addr[0])); i++) {
i2caddress = ir_i2c_addr[i];
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(i2caddress,
IR36021_MFR_ID_OFFSET, 1, (void *)&byte,
sizeof(byte));
Expand Down Expand Up @@ -117,12 +117,12 @@ static int read_voltage_from_INA220(int i2caddress)
int i, ret, voltage_read = 0;
u16 vol_mon;
u8 buf[2];
#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *dev;
#endif

for (i = 0; i < NUM_READINGS; i++) {
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(I2C_VOL_MONITOR_ADDR,
I2C_VOL_MONITOR_BUS_V_OFFSET, 1,
(void *)&buf, 2);
Expand Down Expand Up @@ -160,12 +160,12 @@ static int read_voltage_from_IR(int i2caddress)
int i, ret, voltage_read = 0;
u16 vol_mon;
u8 buf;
#ifdef CONFIG_DM_I2C
#if CONFIG_IS_ENABLED(DM_I2C)
struct udevice *dev;
#endif

for (i = 0; i < NUM_READINGS; i++) {
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(i2caddress,
IR36021_LOOP1_VOUT_OFFSET,
1, (void *)&buf, 1);
Expand Down Expand Up @@ -213,7 +213,7 @@ static int read_voltage_from_LTC(int i2caddress)
int ret, vcode = 0;
u8 chan = PWM_CHANNEL0;

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
/* select the PAGE 0 using PMBus commands PAGE for VDD*/
ret = i2c_write(I2C_VOL_MONITOR_ADDR,
PMBUS_CMD_PAGE, 1, &chan, 1);
Expand All @@ -229,7 +229,7 @@ static int read_voltage_from_LTC(int i2caddress)
return ret;
}

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
/*read the output voltage using PMBus command READ_VOUT*/
ret = i2c_read(I2C_VOL_MONITOR_ADDR,
PMBUS_CMD_READ_VOUT, 1, (void *)&vcode, 2);
Expand Down Expand Up @@ -344,7 +344,7 @@ static int set_voltage_to_IR(int i2caddress, int vdd)
vid = DIV_ROUND_UP(vdd - 245, 5);
#endif

#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_write(i2caddress, IR36021_LOOP1_MANUAL_ID_OFFSET,
1, (void *)&vid, sizeof(vid));
#else
Expand Down Expand Up @@ -392,7 +392,7 @@ static int set_voltage_to_LTC(int i2caddress, int vdd)
vdd & 0xFF, (vdd & 0xFF00) >> 8};

/* Write the desired voltage code to the regulator */
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
/* Check write protect state */
ret = i2c_read(I2C_VOL_MONITOR_ADDR,
PMBUS_CMD_WRITE_PROTECT, 1,
Expand Down Expand Up @@ -621,7 +621,7 @@ int adjust_vdd(ulong vdd_override)
}

/* check IR chip work on Intel mode*/
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(i2caddress,
IR36021_INTEL_MODE_OOFSET,
1, (void *)&buf, 1);
Expand Down Expand Up @@ -803,7 +803,7 @@ int adjust_vdd(ulong vdd_override)
}

/* check IR chip work on Intel mode*/
#ifndef CONFIG_DM_I2C
#if !CONFIG_IS_ENABLED(DM_I2C)
ret = i2c_read(i2caddress,
IR36021_INTEL_MODE_OOFSET,
1, (void *)&buf, 1);
Expand Down
Loading

0 comments on commit 2147a16

Please sign in to comment.