X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=drivers%2Fi2c%2Fkona_i2c.c;h=4edcba29110e31fb63b53e13897a8535ec119b42;hb=c27178ba3649f539c9f1890ea147f4c5415f63b5;hp=9af496bbb1cdbd8454c5fd927bfda5b1bf44b53e;hpb=eca99c02566534940b95ee77b6ea1f098da93adc;p=oweals%2Fu-boot.git diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c index 9af496bbb1..4edcba2911 100644 --- a/drivers/i2c/kona_i2c.c +++ b/drivers/i2c/kona_i2c.c @@ -1,12 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2013 Broadcom Corporation. * - * SPDX-License-Identifier: GPL-2.0+ + * NOTE: This driver should be converted to driver model before June 2017. + * Please see doc/driver-model/i2c-howto.rst for instructions. */ #include +#include #include -#include +#include +#include #include #include #include @@ -96,12 +100,6 @@ enum bcm_kona_cmd_t { BCM_CMD_STOP, }; -enum bus_speed_index { - BCM_SPD_100K = 0, - BCM_SPD_400K, - BCM_SPD_1MHZ, -}; - /* Internal divider settings for standard mode, fast mode and fast mode plus */ struct bus_speed_cfg { uint8_t time_m; /* Number of cycles for setup time */ @@ -113,9 +111,9 @@ struct bus_speed_cfg { }; static const struct bus_speed_cfg std_cfg_table[] = { - [BCM_SPD_100K] = {0x01, 0x01, 0x03, 0x06, 0x00, 0x02}, - [BCM_SPD_400K] = {0x05, 0x01, 0x03, 0x05, 0x01, 0x02}, - [BCM_SPD_1MHZ] = {0x01, 0x01, 0x03, 0x01, 0x01, 0x03}, + [IC_SPEED_MODE_STANDARD] = {0x01, 0x01, 0x03, 0x06, 0x00, 0x02}, + [IC_SPEED_MODE_FAST] = {0x05, 0x01, 0x03, 0x05, 0x01, 0x02}, + [IC_SPEED_MODE_FAST_PLUS] = {0x01, 0x01, 0x03, 0x01, 0x01, 0x03}, }; struct bcm_kona_i2c_dev { @@ -125,8 +123,8 @@ struct bcm_kona_i2c_dev { }; /* Keep these two defines in sync */ -#define DEF_SPD 100000 -#define DEF_SPD_ENUM BCM_SPD_100K +#define DEF_SPD I2C_SPEED_STANDARD_RATE +#define DEF_SPD_ENUM IC_SPEED_MODE_STANDARD #define DEF_DEVICE(num) \ {(void *)CONFIG_SYS_I2C_BASE##num, DEF_SPD, &std_cfg_table[DEF_SPD_ENUM]} @@ -381,7 +379,7 @@ static int bcm_kona_i2c_write_fifo_single(struct bcm_kona_i2c_dev *dev, return -EREMOTEIO; } - /* Check if a timeout occured */ + /* Check if a timeout occurred */ if (!time_left) { printf("completion timed out\n"); return -EREMOTEIO; @@ -558,14 +556,14 @@ static uint bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev, uint speed) { switch (speed) { - case 100000: - dev->std_cfg = &std_cfg_table[BCM_SPD_100K]; + case I2C_SPEED_STANDARD_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_STANDARD]; break; - case 400000: - dev->std_cfg = &std_cfg_table[BCM_SPD_400K]; + case I2C_SPEED_FAST_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_FAST]; break; - case 1000000: - dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ]; + case I2C_SPEED_FAST_PLUS_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_FAST_PLUS]; break; default: printf("%d hz bus speed not supported\n", speed);