Commit 0bdffe71fddeaa46768a39305797e4512dee0f15

Authored by Heiko Schocher
1 parent 6789e84eca

i2c, zynq: convert zynq i2c driver to new multibus/multiadapter framework

- add zync i2c driver to new multibus/multiadpater support
- adapted all config files, which uses this driver

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Michal Simek <michal.simek@xilinx.com>

Showing 4 changed files with 26 additions and 18 deletions Side-by-side Diff

... ... @@ -2071,6 +2071,11 @@
2071 2071 - CONFIG_SYS_OMAP24_I2C_SPEED4 speed channel 4
2072 2072 - CONFIG_SYS_OMAP24_I2C_SLAVE4 slave addr channel 4
2073 2073  
  2074 + - drivers/i2c/zynq_i2c.c
  2075 + - activate this driver with CONFIG_SYS_I2C_ZYNQ
  2076 + - set CONFIG_SYS_I2C_ZYNQ_SPEED for speed setting
  2077 + - set CONFIG_SYS_I2C_ZYNQ_SLAVE for slave addr
  2078 +
2074 2079 additional defines:
2075 2080  
2076 2081 CONFIG_SYS_NUM_I2C_BUSES
drivers/i2c/Makefile
... ... @@ -28,5 +28,5 @@
28 28 obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o
29 29 obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
30 30 obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o
31   -obj-$(CONFIG_ZYNQ_I2C) += zynq_i2c.o
  31 +obj-$(CONFIG_SYS_I2C_ZYNQ) += zynq_i2c.o
drivers/i2c/zynq_i2c.c
... ... @@ -74,7 +74,8 @@
74 74 (struct zynq_i2c_registers *)ZYNQ_I2C_BASE;
75 75  
76 76 /* I2C init called by cmd_i2c when doing 'i2c reset'. */
77   -void i2c_init(int requested_speed, int slaveadd)
  77 +static void zynq_i2c_init(struct i2c_adapter *adap, int requested_speed,
  78 + int slaveadd)
78 79 {
79 80 /* 111MHz / ( (3 * 17) * 22 ) = ~100KHz */
80 81 writel((16 << ZYNQ_I2C_CONTROL_DIV_B_SHIFT) |
... ... @@ -151,7 +152,7 @@
151 152 * I2C probe called by cmd_i2c when doing 'i2c probe'.
152 153 * Begin read, nak data byte, end.
153 154 */
154   -int i2c_probe(u8 dev)
  155 +static int zynq_i2c_probe(struct i2c_adapter *adap, u8 dev)
155 156 {
156 157 /* Attempt to read a byte */
157 158 setbits_le32(&zynq_i2c->control, ZYNQ_I2C_CONTROL_CLR_FIFO |
... ... @@ -170,7 +171,8 @@
170 171 * I2C read called by cmd_i2c when doing 'i2c read' and by cmd_eeprom.c
171 172 * Begin write, send address byte(s), begin read, receive data bytes, end.
172 173 */
173   -int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
  174 +static int zynq_i2c_read(struct i2c_adapter *adap, u8 dev, uint addr,
  175 + int alen, u8 *data, int length)
174 176 {
175 177 u32 status;
176 178 u32 i = 0;
... ... @@ -235,7 +237,8 @@
235 237 * I2C write called by cmd_i2c when doing 'i2c write' and by cmd_eeprom.c
236 238 * Begin write, send address byte(s), send data bytes, end.
237 239 */
238   -int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
  240 +static int zynq_i2c_write(struct i2c_adapter *adap, u8 dev, uint addr,
  241 + int alen, u8 *data, int length)
239 242 {
240 243 u8 *cur_data = data;
241 244  
242 245  
243 246  
244 247  
... ... @@ -275,17 +278,17 @@
275 278 return 0;
276 279 }
277 280  
278   -int i2c_set_bus_num(unsigned int bus)
  281 +static unsigned int zynq_i2c_set_bus_speed(struct i2c_adapter *adap,
  282 + unsigned int speed)
279 283 {
280   - /* Only support bus 0 */
281   - if (bus > 0)
282   - return -1;
283   - return 0;
284   -}
  284 + if (speed != 1000000)
  285 + return -EINVAL;
285 286  
286   -unsigned int i2c_get_bus_num(void)
287   -{
288   - /* Only support bus 0 */
289 287 return 0;
290 288 }
  289 +
  290 +U_BOOT_I2C_ADAP_COMPLETE(zynq_0, zynq_i2c_init, zynq_i2c_probe, zynq_i2c_read,
  291 + zynq_i2c_write, zynq_i2c_set_bus_speed,
  292 + CONFIG_SYS_I2C_ZYNQ_SPEED, CONFIG_SYS_I2C_ZYNQ_SLAVE,
  293 + 0)
include/configs/zynq.h
... ... @@ -60,10 +60,10 @@
60 60 /* I2C */
61 61 #if defined(CONFIG_ZYNQ_I2C0) || defined(CONFIG_ZYNQ_I2C1)
62 62 # define CONFIG_CMD_I2C
63   -# define CONFIG_ZYNQ_I2C
64   -# define CONFIG_HARD_I2C
65   -# define CONFIG_SYS_I2C_SPEED 100000
66   -# define CONFIG_SYS_I2C_SLAVE 1
  63 +# define CONFIG_SYS_I2C
  64 +# define CONFIG_SYS_I2C_ZYNQ
  65 +# define CONFIG_SYS_I2C_ZYNQ_SPEED 100000
  66 +# define CONFIG_SYS_I2C_ZYNQ_SLAVE 1
67 67 #endif
68 68  
69 69 #if defined(CONFIG_ZYNQ_DCC)