]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - cpu/ppc4xx/i2c.c
rename CFG_ macros to CONFIG_SYS
[karo-tx-uboot.git] / cpu / ppc4xx / i2c.c
index 8f4da8621dde85bd2b3f75cac6659407e66ecc27..0deb1499307306e1e0449ed35c907d4219aec426 100644 (file)
@@ -42,8 +42,8 @@ DECLARE_GLOBAL_DATA_PTR;
  * runs from ROM, and we can't switch buses because we can't modify
  * the global variables.
  */
-#ifdef CFG_SPD_BUS_NUM
-static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = CFG_SPD_BUS_NUM;
+#ifdef CONFIG_SYS_SPD_BUS_NUM
+static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = CONFIG_SYS_SPD_BUS_NUM;
 #else
 static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
 #endif
@@ -61,7 +61,7 @@ static void _i2c_bus_reset(void)
        /* write 1 in IRQP IRQD LA ICT XFRA to clear these fields */
        out_8((u8 *)IIC_EXTSTS, 0x8F);
 
-       /* Place chip in the reset state */
+       /* Place chip in the reset state */
        out_8((u8 *)IIC_XTCNTLSS, IIC_XTCNTLSS_SRST);
 
        /* Check if bus is free */
@@ -91,19 +91,18 @@ static void _i2c_bus_reset(void)
 
 void i2c_init(int speed, int slaveadd)
 {
-       sys_info_t sysInfo;
        unsigned long freqOPB;
        int val, divisor;
        int bus;
 
-#ifdef CFG_I2C_INIT_BOARD
+#ifdef CONFIG_SYS_I2C_INIT_BOARD
        /* call board specific i2c bus reset routine before accessing the   */
        /* environment, which might be in a chip on that bus. For details   */
        /* about this problem see doc/I2C_Edge_Conditions.                  */
        i2c_init_board();
 #endif
 
-       for (bus = 0; bus < CFG_MAX_I2C_BUS; bus++) {
+       for (bus = 0; bus < CONFIG_SYS_MAX_I2C_BUS; bus++) {
                I2C_SET_BUS(bus);
 
                /* Handle possible failed I2C state */
@@ -124,8 +123,7 @@ void i2c_init(int speed, int slaveadd)
 
                /* Clock divide Register */
                /* get OPB frequency */
-               get_sys_info(&sysInfo);
-               freqOPB = sysInfo.freqPLB / sysInfo.pllOpbDiv;
+               freqOPB = get_OPB_freq();
                /* set divisor according to freqOPB */
                divisor = (freqOPB - 1) / 10000000;
                if (divisor == 0)
@@ -163,7 +161,7 @@ void i2c_init(int speed, int slaveadd)
        }
 
        /* set to SPD bus as default bus upon powerup */
-       I2C_SET_BUS(CFG_SPD_BUS_NUM);
+       I2C_SET_BUS(CONFIG_SYS_SPD_BUS_NUM);
 }
 
 /*
@@ -363,7 +361,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar * buffer, int len)
        }
 
 
-#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
+#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
        /*
         * EEPROM chips that implement "address overflow" are ones
         * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
@@ -376,7 +374,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar * buffer, int len)
         * hidden in the chip address.
         */
        if (alen > 0)
-               chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+               chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
        if ((ret = i2c_transfer(1, chip<<1, &xaddr[4-alen], alen, buffer, len)) != 0) {
                if (gd->have_console)
@@ -403,7 +401,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len)
                xaddr[3] = addr & 0xFF;
        }
 
-#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
+#ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
        /*
         * EEPROM chips that implement "address overflow" are ones
         * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
@@ -416,7 +414,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len)
         * hidden in the chip address.
         */
        if (alen > 0)
-               chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+               chip |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        return (i2c_transfer(0, chip<<1, &xaddr[4-alen], alen, buffer, len ) != 0);
@@ -453,7 +451,7 @@ unsigned int i2c_get_bus_num(void)
 
 int i2c_set_bus_num(unsigned int bus)
 {
-       if (bus >= CFG_MAX_I2C_BUS)
+       if (bus >= CONFIG_SYS_MAX_I2C_BUS)
                return -1;
 
        i2c_bus_num = bus;
@@ -465,12 +463,12 @@ int i2c_set_bus_num(unsigned int bus)
 /* TODO: add 100/400k switching */
 unsigned int i2c_get_bus_speed(void)
 {
-       return CFG_I2C_SPEED;
+       return CONFIG_SYS_I2C_SPEED;
 }
 
 int i2c_set_bus_speed(unsigned int speed)
 {
-       if (speed != CFG_I2C_SPEED)
+       if (speed != CONFIG_SYS_I2C_SPEED)
                return -1;
 
        return 0;