Commit 9a2accb44f871af9c87c34d1c9ac95010f4e6f09

Authored by Heiko Schocher
1 parent 00f792e0df

i2c, multibus: get rid of CONFIG_I2C_MUX

CONFIG_I2C_MUX is replaced through the new i2c multibus/multiadapter
framework, configured through CONFIG_SYS_I2C. As CONFIG_I2C_MUX
is only used on the keymile boards, and they are now completely
moved to the new framework, remove CONFIG_I2C_MUX.

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Holger Brunck <holger.brunck@keymile.com>
Tested-By: Holger Brunck <holger.brunck@keymile.com>

Showing 5 changed files with 6 additions and 342 deletions Side-by-side Diff

... ... @@ -2225,53 +2225,6 @@
2225 2225 If not defined, then U-Boot uses predefined value for
2226 2226 specified DTT device.
2227 2227  
2228   - CONFIG_I2C_MUX
2229   -
2230   - Define this option if you have I2C devices reached over 1 .. n
2231   - I2C Muxes like the pca9544a. This option addes a new I2C
2232   - Command "i2c bus [muxtype:muxaddr:muxchannel]" which adds a
2233   - new I2C Bus to the existing I2C Busses. If you select the
2234   - new Bus with "i2c dev", u-bbot sends first the commandos for
2235   - the muxes to activate this new "bus".
2236   -
2237   - CONFIG_I2C_MULTI_BUS must be also defined, to use this
2238   - feature!
2239   -
2240   - Example:
2241   - Adding a new I2C Bus reached over 2 pca9544a muxes
2242   - The First mux with address 70 and channel 6
2243   - The Second mux with address 71 and channel 4
2244   -
2245   - => i2c bus pca9544a:70:6:pca9544a:71:4
2246   -
2247   - Use the "i2c bus" command without parameter, to get a list
2248   - of I2C Busses with muxes:
2249   -
2250   - => i2c bus
2251   - Busses reached over muxes:
2252   - Bus ID: 2
2253   - reached over Mux(es):
2254   - pca9544a@70 ch: 4
2255   - Bus ID: 3
2256   - reached over Mux(es):
2257   - pca9544a@70 ch: 6
2258   - pca9544a@71 ch: 4
2259   - =>
2260   -
2261   - If you now switch to the new I2C Bus 3 with "i2c dev 3"
2262   - u-boot first sends the command to the mux@70 to enable
2263   - channel 6, and then the command to the mux@71 to enable
2264   - the channel 4.
2265   -
2266   - After that, you can use the "normal" i2c commands as
2267   - usual to communicate with your I2C devices behind
2268   - the 2 muxes.
2269   -
2270   - This option is actually implemented for the bitbanging
2271   - algorithm in common/soft_i2c.c and for the Hardware I2C
2272   - Bus on the MPC8260. But it should be not so difficult
2273   - to add this option to other architectures.
2274   -
2275 2228 CONFIG_SOFT_I2C_READ_REPEATED_START
2276 2229  
2277 2230 defining this will force the i2c_read() function in
arch/powerpc/cpu/mpc8260/i2c.c
... ... @@ -746,23 +746,9 @@
746 746  
747 747 int i2c_set_bus_num(unsigned int bus)
748 748 {
749   -#if defined(CONFIG_I2C_MUX)
750   - if (bus < CONFIG_SYS_MAX_I2C_BUS) {
751   - i2c_bus_num = bus;
752   - } else {
753   - int ret;
754   -
755   - ret = i2x_mux_select_mux(bus);
756   - if (ret == 0)
757   - i2c_bus_num = bus;
758   - else
759   - return ret;
760   - }
761   -#else
762 749 if (bus >= CONFIG_SYS_MAX_I2C_BUS)
763 750 return -1;
764 751 i2c_bus_num = bus;
765   -#endif
766 752 return 0;
767 753 }
768 754  
... ... @@ -110,8 +110,7 @@
110 110 * pairs. The following macros take care of this */
111 111  
112 112 #if defined(CONFIG_SYS_I2C_NOPROBES)
113   -#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MUX) || \
114   - defined(CONFIG_I2C_MULTI_BUS)
  113 +#if defined(CONFIG_SYS_I2C) || defined(CONFIG_I2C_MULTI_BUS)
115 114 static struct
116 115 {
117 116 uchar bus;
... ... @@ -132,11 +131,6 @@
132 131 #define NUM_ELEMENTS_NOPROBE (sizeof(i2c_no_probes)/sizeof(i2c_no_probes[0]))
133 132 #endif
134 133  
135   -#if defined(CONFIG_I2C_MUX)
136   -static I2C_MUX_DEVICE *i2c_mux_devices = NULL;
137   -static int i2c_mux_busid = CONFIG_SYS_MAX_I2C_BUS;
138   -#endif
139   -
140 134 #define DISP_LINE_LEN 16
141 135  
142 136 /**
... ... @@ -1554,7 +1548,7 @@
1554 1548 static cmd_tbl_t cmd_i2c_sub[] = {
1555 1549 #if defined(CONFIG_SYS_I2C)
1556 1550 U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_show_bus, "", ""),
1557   -#endif /* CONFIG_I2C_MUX */
  1551 +#endif
1558 1552 U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""),
1559 1553 #if defined(CONFIG_SYS_I2C) || \
1560 1554 defined(CONFIG_I2C_MULTI_BUS)
... ... @@ -1618,7 +1612,7 @@
1618 1612 static char i2c_help_text[] =
1619 1613 #if defined(CONFIG_SYS_I2C)
1620 1614 "bus [muxtype:muxaddr:muxchannel] - show I2C bus info\n"
1621   -#endif /* CONFIG_I2C_MUX */
  1615 +#endif
1622 1616 "crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n"
1623 1617 #if defined(CONFIG_SYS_I2C) || \
1624 1618 defined(CONFIG_I2C_MULTI_BUS)
... ... @@ -1647,226 +1641,4 @@
1647 1641 "I2C sub-system",
1648 1642 i2c_help_text
1649 1643 );
1650   -
1651   -#if defined(CONFIG_I2C_MUX)
1652   -static int i2c_mux_add_device(I2C_MUX_DEVICE *dev)
1653   -{
1654   - I2C_MUX_DEVICE *devtmp = i2c_mux_devices;
1655   -
1656   - if (i2c_mux_devices == NULL) {
1657   - i2c_mux_devices = dev;
1658   - return 0;
1659   - }
1660   - while (devtmp->next != NULL)
1661   - devtmp = devtmp->next;
1662   -
1663   - devtmp->next = dev;
1664   - return 0;
1665   -}
1666   -
1667   -I2C_MUX_DEVICE *i2c_mux_search_device(int id)
1668   -{
1669   - I2C_MUX_DEVICE *device = i2c_mux_devices;
1670   -
1671   - while (device != NULL) {
1672   - if (device->busid == id)
1673   - return device;
1674   - device = device->next;
1675   - }
1676   - return NULL;
1677   -}
1678   -
1679   -/* searches in the buf from *pos the next ':'.
1680   - * returns:
1681   - * 0 if found (with *pos = where)
1682   - * < 0 if an error occured
1683   - * > 0 if the end of buf is reached
1684   - */
1685   -static int i2c_mux_search_next (int *pos, uchar *buf, int len)
1686   -{
1687   - while ((buf[*pos] != ':') && (*pos < len)) {
1688   - *pos += 1;
1689   - }
1690   - if (*pos >= len)
1691   - return 1;
1692   - if (buf[*pos] != ':')
1693   - return -1;
1694   - return 0;
1695   -}
1696   -
1697   -static int i2c_mux_get_busid (void)
1698   -{
1699   - int tmp = i2c_mux_busid;
1700   -
1701   - i2c_mux_busid ++;
1702   - return tmp;
1703   -}
1704   -
1705   -/* Analyses a Muxstring and immediately sends the
1706   - commands to the muxes. Runs from flash.
1707   - */
1708   -int i2c_mux_ident_muxstring_f (uchar *buf)
1709   -{
1710   - int pos = 0;
1711   - int oldpos;
1712   - int ret = 0;
1713   - int len = strlen((char *)buf);
1714   - int chip;
1715   - uchar channel;
1716   - int was = 0;
1717   -
1718   - while (ret == 0) {
1719   - oldpos = pos;
1720   - /* search name */
1721   - ret = i2c_mux_search_next(&pos, buf, len);
1722   - if (ret != 0)
1723   - printf ("ERROR\n");
1724   - /* search address */
1725   - pos ++;
1726   - oldpos = pos;
1727   - ret = i2c_mux_search_next(&pos, buf, len);
1728   - if (ret != 0)
1729   - printf ("ERROR\n");
1730   - buf[pos] = 0;
1731   - chip = simple_strtoul((char *)&buf[oldpos], NULL, 16);
1732   - buf[pos] = ':';
1733   - /* search channel */
1734   - pos ++;
1735   - oldpos = pos;
1736   - ret = i2c_mux_search_next(&pos, buf, len);
1737   - if (ret < 0)
1738   - printf ("ERROR\n");
1739   - was = 0;
1740   - if (buf[pos] != 0) {
1741   - buf[pos] = 0;
1742   - was = 1;
1743   - }
1744   - channel = simple_strtoul((char *)&buf[oldpos], NULL, 16);
1745   - if (was)
1746   - buf[pos] = ':';
1747   - if (i2c_write(chip, 0, 0, &channel, 1) != 0) {
1748   - printf ("Error setting Mux: chip:%x channel: \
1749   - %x\n", chip, channel);
1750   - return -1;
1751   - }
1752   - pos ++;
1753   - oldpos = pos;
1754   -
1755   - }
1756   - i2c_init_board();
1757   -
1758   - return 0;
1759   -}
1760   -
1761   -/* Analyses a Muxstring and if this String is correct
1762   - * adds a new I2C Bus.
1763   - */
1764   -I2C_MUX_DEVICE *i2c_mux_ident_muxstring (uchar *buf)
1765   -{
1766   - I2C_MUX_DEVICE *device;
1767   - I2C_MUX *mux;
1768   - int pos = 0;
1769   - int oldpos;
1770   - int ret = 0;
1771   - int len = strlen((char *)buf);
1772   - int was = 0;
1773   -
1774   - device = (I2C_MUX_DEVICE *)malloc (sizeof(I2C_MUX_DEVICE));
1775   - device->mux = NULL;
1776   - device->busid = i2c_mux_get_busid ();
1777   - device->next = NULL;
1778   - while (ret == 0) {
1779   - mux = (I2C_MUX *)malloc (sizeof(I2C_MUX));
1780   - mux->next = NULL;
1781   - /* search name of mux */
1782   - oldpos = pos;
1783   - ret = i2c_mux_search_next(&pos, buf, len);
1784   - if (ret != 0)
1785   - printf ("%s no name.\n", __FUNCTION__);
1786   - mux->name = (char *)malloc (pos - oldpos + 1);
1787   - memcpy (mux->name, &buf[oldpos], pos - oldpos);
1788   - mux->name[pos - oldpos] = 0;
1789   - /* search address */
1790   - pos ++;
1791   - oldpos = pos;
1792   - ret = i2c_mux_search_next(&pos, buf, len);
1793   - if (ret != 0)
1794   - printf ("%s no mux address.\n", __FUNCTION__);
1795   - buf[pos] = 0;
1796   - mux->chip = simple_strtoul((char *)&buf[oldpos], NULL, 16);
1797   - buf[pos] = ':';
1798   - /* search channel */
1799   - pos ++;
1800   - oldpos = pos;
1801   - ret = i2c_mux_search_next(&pos, buf, len);
1802   - if (ret < 0)
1803   - printf ("%s no mux channel.\n", __FUNCTION__);
1804   - was = 0;
1805   - if (buf[pos] != 0) {
1806   - buf[pos] = 0;
1807   - was = 1;
1808   - }
1809   - mux->channel = simple_strtoul((char *)&buf[oldpos], NULL, 16);
1810   - if (was)
1811   - buf[pos] = ':';
1812   - if (device->mux == NULL)
1813   - device->mux = mux;
1814   - else {
1815   - I2C_MUX *muxtmp = device->mux;
1816   - while (muxtmp->next != NULL) {
1817   - muxtmp = muxtmp->next;
1818   - }
1819   - muxtmp->next = mux;
1820   - }
1821   - pos ++;
1822   - oldpos = pos;
1823   - }
1824   - if (ret > 0) {
1825   - /* Add Device */
1826   - i2c_mux_add_device (device);
1827   - return device;
1828   - }
1829   -
1830   - return NULL;
1831   -}
1832   -
1833   -int i2x_mux_select_mux(int bus)
1834   -{
1835   - I2C_MUX_DEVICE *dev;
1836   - I2C_MUX *mux;
1837   -
1838   - if ((gd->flags & GD_FLG_RELOC) != GD_FLG_RELOC) {
1839   - /* select Default Mux Bus */
1840   -#if defined(CONFIG_SYS_I2C_IVM_BUS)
1841   - i2c_mux_ident_muxstring_f ((uchar *)CONFIG_SYS_I2C_IVM_BUS);
1842   -#else
1843   - {
1844   - unsigned char *buf;
1845   - buf = (unsigned char *) getenv("EEprom_ivm");
1846   - if (buf != NULL)
1847   - i2c_mux_ident_muxstring_f (buf);
1848   - }
1849   -#endif
1850   - return 0;
1851   - }
1852   - dev = i2c_mux_search_device(bus);
1853   - if (dev == NULL)
1854   - return -1;
1855   -
1856   - mux = dev->mux;
1857   - while (mux != NULL) {
1858   - /* do deblocking on each level of mux, before mux config */
1859   - i2c_init_board();
1860   - if (i2c_write(mux->chip, 0, 0, &mux->channel, 1) != 0) {
1861   - printf ("Error setting Mux: chip:%x channel: \
1862   - %x\n", mux->chip, mux->channel);
1863   - return -1;
1864   - }
1865   - mux = mux->next;
1866   - }
1867   - /* do deblocking on each level of mux and after mux config */
1868   - i2c_init_board();
1869   - return 0;
1870   -}
1871   -#endif /* CONFIG_I2C_MUX */
... ... @@ -49,41 +49,17 @@
49 49 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
50 50 int old_bus = i2c_get_bus_num();
51 51  
52   -#if defined(CONFIG_SYS_I2C)
53 52 if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
54 53 i2c_set_bus_num(CONFIG_I2C_ENV_EEPROM_BUS);
55   -#else
56   - if (gd->flags & GD_FLG_RELOC) {
57   - if (env_eeprom_bus == -1) {
58   - I2C_MUX_DEVICE *dev = NULL;
59   - dev = i2c_mux_ident_muxstring(
60   - (uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
61   - if (dev != NULL)
62   - env_eeprom_bus = dev->busid;
63   - else
64   - printf("error adding env eeprom bus.\n");
65   - }
66   - if (old_bus != env_eeprom_bus) {
67   - i2c_set_bus_num(env_eeprom_bus);
68   - old_bus = env_eeprom_bus;
69   - }
70   - } else {
71   - rcode = i2c_mux_ident_muxstring_f(
72   - (uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
73   - }
74 54 #endif
75   -#endif
76 55  
77 56 rcode = eeprom_read(dev_addr, offset, buffer, cnt);
78 57  
79 58 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
80   -#if defined(CONFIG_SYS_I2C)
81   - if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
82   -#else
83 59 if (old_bus != env_eeprom_bus)
84   -#endif
85 60 i2c_set_bus_num(old_bus);
86 61 #endif
  62 +
87 63 return rcode;
88 64 }
89 65  
90 66  
91 67  
92 68  
... ... @@ -94,14 +70,12 @@
94 70 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
95 71 int old_bus = i2c_get_bus_num();
96 72  
97   -#if defined(CONFIG_SYS_I2C)
98 73 if (old_bus != CONFIG_I2C_ENV_EEPROM_BUS)
99 74 i2c_set_bus_num(CONFIG_I2C_ENV_EEPROM_BUS);
100   -#else
101   - rcode = i2c_mux_ident_muxstring_f((uchar *)CONFIG_I2C_ENV_EEPROM_BUS);
102 75 #endif
103   -#endif
  76 +
104 77 rcode = eeprom_write(dev_addr, offset, buffer, cnt);
  78 +
105 79 #if defined(CONFIG_I2C_ENV_EEPROM_BUS)
106 80 i2c_set_bus_num(old_bus);
107 81 #endif
... ... @@ -197,27 +197,6 @@
197 197 void i2c_board_late_init(void);
198 198 #endif
199 199  
200   -#if defined(CONFIG_I2C_MUX)
201   -
202   -typedef struct _mux {
203   - uchar chip;
204   - uchar channel;
205   - char *name;
206   - struct _mux *next;
207   -} I2C_MUX;
208   -
209   -typedef struct _mux_device {
210   - int busid;
211   - I2C_MUX *mux; /* List of muxes, to reach the device */
212   - struct _mux_device *next;
213   -} I2C_MUX_DEVICE;
214   -
215   -I2C_MUX_DEVICE *i2c_mux_search_device(int id);
216   -I2C_MUX_DEVICE *i2c_mux_ident_muxstring (uchar *buf);
217   -int i2x_mux_select_mux(int bus);
218   -int i2c_mux_ident_muxstring_f (uchar *buf);
219   -#endif
220   -
221 200 #ifdef CONFIG_SYS_I2C
222 201 /*
223 202 * i2c_get_bus_num: